public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] accel/habanalabs/gaudi2: fix spmu mask creation
@ 2023-09-28 13:25 Oded Gabbay
  2023-10-01  9:14 ` Ofir Bitton
  0 siblings, 1 reply; 2+ messages in thread
From: Oded Gabbay @ 2023-09-28 13:25 UTC (permalink / raw)
  To: dri-devel, linux-kernel

event_types_num received from the user can be 0. In that case, the
event_mask should be 0.

In addition, to create a correct mask we need to match the number
of event types to the bit location such that bit 0 represents a single
event type, bit 1 represents 2 types and so on.

Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
---
 drivers/accel/habanalabs/gaudi2/gaudi2_coresight.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/accel/habanalabs/gaudi2/gaudi2_coresight.c b/drivers/accel/habanalabs/gaudi2/gaudi2_coresight.c
index 14a855cdc96b..2423620ff358 100644
--- a/drivers/accel/habanalabs/gaudi2/gaudi2_coresight.c
+++ b/drivers/accel/habanalabs/gaudi2/gaudi2_coresight.c
@@ -2500,7 +2500,8 @@ static int gaudi2_config_spmu(struct hl_device *hdev, struct hl_debug_params *pa
 		 * set enabled events mask based on input->event_types_num
 		 */
 		event_mask = 0x80000000;
-		event_mask |= GENMASK(input->event_types_num, 0);
+		if (input->event_types_num)
+			event_mask |= GENMASK(input->event_types_num - 1, 0);
 
 		WREG32(base_reg + mmSPMU_PMCNTENSET_EL0_OFFSET, event_mask);
 	} else {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] accel/habanalabs/gaudi2: fix spmu mask creation
  2023-09-28 13:25 [PATCH] accel/habanalabs/gaudi2: fix spmu mask creation Oded Gabbay
@ 2023-10-01  9:14 ` Ofir Bitton
  0 siblings, 0 replies; 2+ messages in thread
From: Ofir Bitton @ 2023-10-01  9:14 UTC (permalink / raw)
  To: Oded Gabbay, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org

On 28/09/2023 16:25, Oded Gabbay wrote:
> event_types_num received from the user can be 0. In that case, the
> event_mask should be 0.
> 
> In addition, to create a correct mask we need to match the number
> of event types to the bit location such that bit 0 represents a single
> event type, bit 1 represents 2 types and so on.
> 
> Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
> ---
>   drivers/accel/habanalabs/gaudi2/gaudi2_coresight.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/accel/habanalabs/gaudi2/gaudi2_coresight.c b/drivers/accel/habanalabs/gaudi2/gaudi2_coresight.c
> index 14a855cdc96b..2423620ff358 100644
> --- a/drivers/accel/habanalabs/gaudi2/gaudi2_coresight.c
> +++ b/drivers/accel/habanalabs/gaudi2/gaudi2_coresight.c
> @@ -2500,7 +2500,8 @@ static int gaudi2_config_spmu(struct hl_device *hdev, struct hl_debug_params *pa
>   		 * set enabled events mask based on input->event_types_num
>   		 */
>   		event_mask = 0x80000000;
> -		event_mask |= GENMASK(input->event_types_num, 0);
> +		if (input->event_types_num)
> +			event_mask |= GENMASK(input->event_types_num - 1, 0);
>   
>   		WREG32(base_reg + mmSPMU_PMCNTENSET_EL0_OFFSET, event_mask);
>   	} else {

Reviewed-by: Ofir Bitton <obitton@habana.ai>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-10-01  9:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-28 13:25 [PATCH] accel/habanalabs/gaudi2: fix spmu mask creation Oded Gabbay
2023-10-01  9:14 ` Ofir Bitton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox