Skip to contentSkip to conversation

accel/habanalabs/gaudi2: fix spmu mask creation

PATCH In review Oded Gabbay 2 participants 2 messages Sep 28, 2023 – Oct 1, 2023

Subsystems (2)
lore
Share & tools
lore

Oded Gabbay

author maintainer
#0 lore raw

PATCH 1/1 accel/habanalabs/gaudi2: fix spmu mask creation

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.

---
 drivers/accel/habanalabs/gaudi2/gaudi2_coresight.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/accel/habanalabs/gaudi2/gaudi2_coresight.c +2 -1
index 14a855cdc96b..2423620ff358 100644
@@ -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 {
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · Oded Gabbay

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.

---
  drivers/accel/habanalabs/gaudi2/gaudi2_coresight.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/accel/habanalabs/gaudi2/gaudi2_coresight.c +0 -0
index 14a855cdc96b..2423620ff358 100644

drivers/accel/habanalabs/gaudi2/gaudi2_coresight.c static int gaudi2_config_spmu(struct hl_device *hdev, struct hl_debug_params *pa · line 2507

Quoted 9 lines
drivers/accel/habanalabs/gaudi2/gaudi2_coresight.c +2 -1
@@ -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 {