Skip to contentSkip to conversation

perf/smmuv3: add a check of devm_add_action in smmu_pmu_setup_msi

PATCH In review void0red 2 participants 2 messages Feb 27, 2023 – Mar 27, 2023 Arm PMU profiling and debugging

lore
Share & tools
lore

void0red

author
#0 lore raw

PATCH 1/1 perf/smmuv3: add a check of devm_add_action in smmu_pmu_setup_msi

From: Kang Chen <[email protected]>

devm_add_action may fails, add a warning when it happens.

---
 drivers/perf/arm_smmuv3_pmu.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/perf/arm_smmuv3_pmu.c +5 -1
index 25a269d43..307bac904 100644
@@ -724,7 +724,11 @@ static void smmu_pmu_setup_msi(struct smmu_pmu *pmu)
 	pmu->irq = msi_get_virq(dev, 0);
 
 	/* Add callback to free MSIs on teardown */
-	devm_add_action(dev, smmu_pmu_free_msis, dev);
+	ret = devm_add_action(dev, smmu_pmu_free_msis, dev);
+	if (ret) {
+		dev_warn(dev, "failed to add callback to free MSIs on teardown\n");
+		return;
+	}
 }
 
 static int smmu_pmu_setup_irq(struct smmu_pmu *pmu)
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 14 lines · On Mon, Feb 27, 2023 at 11:25:57AM +0800, void0red wrote:

From: Kang Chen <[email protected]>

devm_add_action may fails, add a warning when it happens.

---
 drivers/perf/arm_smmuv3_pmu.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/perf/arm_smmuv3_pmu.c +0 -0
index 25a269d43..307bac904 100644

drivers/perf/arm_smmuv3_pmu.c static void smmu_pmu_setup_msi(struct smmu_pmu *pmu) · line 731

Quoted 9 lines
drivers/perf/arm_smmuv3_pmu.c +5 -1
@@ -724,7 +724,11 @@ static void smmu_pmu_setup_msi(struct smmu_pmu *pmu)
 	pmu->irq = msi_get_virq(dev, 0);
 
 	/* Add callback to free MSIs on teardown */
-	devm_add_action(dev, smmu_pmu_free_msis, dev);
+	ret = devm_add_action(dev, smmu_pmu_free_msis, dev);
+	if (ret) {
+		dev_warn(dev, "failed to add callback to free MSIs on teardown\n");
+		return;
+	}

I appreciate that you're following the existing error handling in this function, but I don't think this message is especially helpful. We'd be better off propagating the error and failing the probe in this case, I reckon.

Will