diff mbox series

pmu/smmuv3: Clear IRQ affinity hint on device removal

Message ID 20200422084805.237738-1-jean-philippe@linaro.org (mailing list archive)
State Mainlined
Commit 10f6cd2af21bb44faab31a50ec3361d7649e5a39
Headers show
Series pmu/smmuv3: Clear IRQ affinity hint on device removal | expand

Commit Message

Jean-Philippe Brucker April 22, 2020, 8:48 a.m. UTC
Currently when trying to remove the SMMUv3 PMU module we get a
WARN_ON_ONCE from free_irq(), because the affinity hint set during probe
hasn't been properly cleared.

[  238.878383] WARNING: CPU: 0 PID: 175 at kernel/irq/manage.c:1744 free_irq+0x324/0x358
...
[  238.897263] Call trace:
[  238.897998]  free_irq+0x324/0x358
[  238.898792]  devm_irq_release+0x18/0x28
[  238.899189]  release_nodes+0x1b0/0x228
[  238.899984]  devres_release_all+0x38/0x60
[  238.900779]  device_release_driver_internal+0x10c/0x1d0
[  238.901574]  driver_detach+0x50/0xe0
[  238.902368]  bus_remove_driver+0x5c/0xd8
[  238.903448]  driver_unregister+0x30/0x60
[  238.903958]  platform_driver_unregister+0x14/0x20
[  238.905075]  arm_smmu_pmu_exit+0x1c/0xecc [arm_smmuv3_pmu]
[  238.905547]  __arm64_sys_delete_module+0x14c/0x260
[  238.906342]  el0_svc_common.constprop.0+0x74/0x178
[  238.907355]  do_el0_svc+0x24/0x90
[  238.907932]  el0_sync_handler+0x11c/0x198
[  238.908979]  el0_sync+0x158/0x180

Just like the other perf drivers, clear the affinity hint before
releasing the device.

Fixes: 7d839b4b9e00 ("perf/smmuv3: Add arm64 smmuv3 pmu driver")
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
---
 drivers/perf/arm_smmuv3_pmu.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Will Deacon May 18, 2020, 11:04 p.m. UTC | #1
On Wed, 22 Apr 2020 10:48:06 +0200, Jean-Philippe Brucker wrote:
> Currently when trying to remove the SMMUv3 PMU module we get a
> WARN_ON_ONCE from free_irq(), because the affinity hint set during probe
> hasn't been properly cleared.
> 
> [  238.878383] WARNING: CPU: 0 PID: 175 at kernel/irq/manage.c:1744 free_irq+0x324/0x358
> ...
> [  238.897263] Call trace:
> [  238.897998]  free_irq+0x324/0x358
> [  238.898792]  devm_irq_release+0x18/0x28
> [  238.899189]  release_nodes+0x1b0/0x228
> [  238.899984]  devres_release_all+0x38/0x60
> [  238.900779]  device_release_driver_internal+0x10c/0x1d0
> [  238.901574]  driver_detach+0x50/0xe0
> [  238.902368]  bus_remove_driver+0x5c/0xd8
> [  238.903448]  driver_unregister+0x30/0x60
> [  238.903958]  platform_driver_unregister+0x14/0x20
> [  238.905075]  arm_smmu_pmu_exit+0x1c/0xecc [arm_smmuv3_pmu]
> [  238.905547]  __arm64_sys_delete_module+0x14c/0x260
> [  238.906342]  el0_svc_common.constprop.0+0x74/0x178
> [  238.907355]  do_el0_svc+0x24/0x90
> [  238.907932]  el0_sync_handler+0x11c/0x198
> [  238.908979]  el0_sync+0x158/0x180
> 
> [...]

Applied to will (for-next/perf), thanks!

[1/1] pmu/smmuv3: Clear IRQ affinity hint on device removal
      https://git.kernel.org/will/c/10f6cd2af21b

Cheers,
diff mbox series

Patch

diff --git a/drivers/perf/arm_smmuv3_pmu.c b/drivers/perf/arm_smmuv3_pmu.c
index 1bc378b68af83..245c8a1b42995 100644
--- a/drivers/perf/arm_smmuv3_pmu.c
+++ b/drivers/perf/arm_smmuv3_pmu.c
@@ -847,7 +847,7 @@  static int smmu_pmu_probe(struct platform_device *pdev)
 	if (err) {
 		dev_err(dev, "Error %d registering hotplug, PMU @%pa\n",
 			err, &res_0->start);
-		return err;
+		goto out_clear_affinity;
 	}
 
 	err = perf_pmu_register(&smmu_pmu->pmu, name, -1);
@@ -866,6 +866,8 @@  static int smmu_pmu_probe(struct platform_device *pdev)
 
 out_unregister:
 	cpuhp_state_remove_instance_nocalls(cpuhp_state_num, &smmu_pmu->node);
+out_clear_affinity:
+	irq_set_affinity_hint(smmu_pmu->irq, NULL);
 	return err;
 }
 
@@ -875,6 +877,7 @@  static int smmu_pmu_remove(struct platform_device *pdev)
 
 	perf_pmu_unregister(&smmu_pmu->pmu);
 	cpuhp_state_remove_instance_nocalls(cpuhp_state_num, &smmu_pmu->node);
+	irq_set_affinity_hint(smmu_pmu->irq, NULL);
 
 	return 0;
 }