From f9d82f5bb7ffc3562065fedc72dda740ac44edbe Mon Sep 17 00:00:00 2001 From: Manish Bhardwaj Date: Thu, 30 Jun 2022 15:10:02 +0530 Subject: [PATCH] nvidia: destroy device on probe failure Using this patch we are destroying the device if clock API gets failed and handling the failure case gracefully otherwise we are are going to get below warning if the probe gets deferred. [ 9.383997] sysfs: cannot create duplicate filename '/devices/virtual/tegra-soc-hwpm' [ 9.384000] CPU: 1 PID: 92 Comm: kworker/1:1 Tainted: G W 5.10.104-rt63-tegra #8 [ 9.384002] Hardware name: p3710-0010 (DT) [ 9.384004] Workqueue: events deferred_probe_work_func [ 9.384010] Call trace: [ 9.384011] dump_backtrace+0x0/0x1d0 [ 9.384016] show_stack+0x30/0x50 [ 9.384019] dump_stack+0xd8/0x140 [ 9.384022] sysfs_warn_dup+0x6c/0x90 [ 9.384026] sysfs_create_dir_ns+0xf0/0x110 [ 9.384028] kobject_add_internal+0x94/0x2a0 [ 9.384032] kobject_add+0x90/0x110 [ 9.384033] get_device_parent.isra.0+0x184/0x1b0 [ 9.384036] device_add+0xcc/0x760 [ 9.384039] device_create_groups_vargs+0xec/0x110 [ 9.384041] device_create+0x94/0xd0 [ 9.384043] tegra_hwpm_probe+0x114/0x4c0 [ 9.384048] platform_drv_probe+0x5c/0xd0 [ 9.384050] really_probe+0xf8/0x3e0 [ 9.384051] driver_probe_device+0x60/0xd0 [ 9.384053] __device_attach_driver+0x8c/0xf0 [ 9.384054] bus_for_each_drv+0x8c/0x100 [ 9.384057] __device_attach+0x100/0x160 [ 9.384058] device_initial_probe+0x28/0x40 [ 9.384060] bus_probe_device+0xac/0xd0 [ 9.384061] deferred_probe_work_func+0x90/0xd0 [ 9.384062] process_one_work+0x1c4/0x4f0 [ 9.384064] worker_thread+0x200/0x430 [ 9.384065] kthread+0x180/0x1c0 [ 9.384068] ret_from_fork+0x10/0x24 [ 9.384070] kobject_add_internal failed for tegra-soc-hwpm with -EEXIST, don't try to register things with the same name in the same directory. [ 9.384073] tegra-soc-hwpm: tegra_hwpm_probe: 127: ERROR: Failed to create device [ 9.384080] tegra-soc-hwpm: tegra_hwpm_probe: 208: ERROR: Probe failed! JIRA ESLC-6775 Signed-off-by: Manish Bhardwaj Change-Id: Ide0d16f420a1c52eadf1b6166859c02906c2ac2f Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2737713 Reviewed-by: Vedashree Vidwans Reviewed-by: Vipin Kumar GVS: Gerrit_Virtual_Submit --- os/linux/tegra_hwpm_linux.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/os/linux/tegra_hwpm_linux.c b/os/linux/tegra_hwpm_linux.c index 623ed89..a39e9ef 100644 --- a/os/linux/tegra_hwpm_linux.c +++ b/os/linux/tegra_hwpm_linux.c @@ -184,7 +184,6 @@ static int tegra_hwpm_probe(struct platform_device *pdev) goto success; init_sw_components_fail: -clock_reset_fail: if (tegra_platform_is_silicon()) { if (hwpm->la_clk) devm_clk_put(hwpm->dev, hwpm->la_clk); @@ -195,6 +194,8 @@ clock_reset_fail: if (hwpm->hwpm_rst) reset_control_assert(hwpm->hwpm_rst); } +clock_reset_fail: + device_destroy(&hwpm->class, hwpm->dev_t); device_create: cdev_del(&hwpm->cdev); cdev_add: