* [PATCH] drm/amdkfd: Use logical AND operator (&&) instead of bitwise AND (&) with a bool operand
@ 2023-12-21 2:42 Srinivasan Shanmugam
2023-12-21 12:56 ` Lazar, Lijo
0 siblings, 1 reply; 2+ messages in thread
From: Srinivasan Shanmugam @ 2023-12-21 2:42 UTC (permalink / raw)
To: Alex Deucher, Christian König, Felix Kuehling
Cc: Srinivasan Shanmugam, amd-gfx
Doing a bitwise AND between a bool and an int is generally not a good
idea. The bool will be promoted to an int with value 0 or 1, the int is
generally regarded as true with a non-zero value, thus ANDing them using
bitwise has the potential to yield an undesired result.
Thus fixes the below:
drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_packet_manager_v9.c:117 pm_map_process_aldebaran() warn: maybe use && instead of &
Cc: Felix Kuehling <Felix.Kuehling@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
---
drivers/gpu/drm/amd/amdkfd/kfd_packet_manager_v9.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager_v9.c b/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager_v9.c
index 8ee2bedd301a..da83deee45a7 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager_v9.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager_v9.c
@@ -114,7 +114,7 @@ static int pm_map_process_aldebaran(struct packet_manager *pm,
packet->tcp_watch_cntl[i] = pdd->watch_points[i];
packet->bitfields2.single_memops =
- !!(pdd->process->dbg_flags & KFD_DBG_TRAP_FLAG_SINGLE_MEM_OP);
+ !!(pdd->process->dbg_flags && KFD_DBG_TRAP_FLAG_SINGLE_MEM_OP);
}
packet->sh_mem_config = qpd->sh_mem_config;
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/amdkfd: Use logical AND operator (&&) instead of bitwise AND (&) with a bool operand
2023-12-21 2:42 [PATCH] drm/amdkfd: Use logical AND operator (&&) instead of bitwise AND (&) with a bool operand Srinivasan Shanmugam
@ 2023-12-21 12:56 ` Lazar, Lijo
0 siblings, 0 replies; 2+ messages in thread
From: Lazar, Lijo @ 2023-12-21 12:56 UTC (permalink / raw)
To: Srinivasan Shanmugam, Alex Deucher, Christian König, Felix Kuehling
Cc: amd-gfx
On 12/21/2023 8:12 AM, Srinivasan Shanmugam wrote:
> Doing a bitwise AND between a bool and an int is generally not a good
> idea. The bool will be promoted to an int with value 0 or 1, the int is
> generally regarded as true with a non-zero value, thus ANDing them using
> bitwise has the potential to yield an undesired result.
>
> Thus fixes the below:
>
> drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_packet_manager_v9.c:117 pm_map_process_aldebaran() warn: maybe use && instead of &
>
> Cc: Felix Kuehling <Felix.Kuehling@amd.com>
> Cc: Christian König <christian.koenig@amd.com>
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
> ---
> drivers/gpu/drm/amd/amdkfd/kfd_packet_manager_v9.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager_v9.c b/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager_v9.c
> index 8ee2bedd301a..da83deee45a7 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager_v9.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager_v9.c
> @@ -114,7 +114,7 @@ static int pm_map_process_aldebaran(struct packet_manager *pm,
> packet->tcp_watch_cntl[i] = pdd->watch_points[i];
>
> packet->bitfields2.single_memops =
> - !!(pdd->process->dbg_flags & KFD_DBG_TRAP_FLAG_SINGLE_MEM_OP);
> + !!(pdd->process->dbg_flags && KFD_DBG_TRAP_FLAG_SINGLE_MEM_OP);
Logical AND of bool with a known constant doesn't make sense. dbg_flags
looks to be defined in the wrong way; to process multiple debug flag
options, better to define as u32.
Thanks,
Lijo
> }
>
> packet->sh_mem_config = qpd->sh_mem_config;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-12-21 12:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-21 2:42 [PATCH] drm/amdkfd: Use logical AND operator (&&) instead of bitwise AND (&) with a bool operand Srinivasan Shanmugam
2023-12-21 12:56 ` Lazar, Lijo
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.