Skip to content

Commit b089cdb

Browse files
Xu Yanggregkh
Xu Yang
authored andcommitted
usb: dwc3: imx8mp: fix software node kernel dump
commit a4faee0 upstream. When unbind and bind the device again, kernel will dump below warning: [ 173.972130] sysfs: cannot create duplicate filename '/devices/platform/soc/4c010010.usb/software_node' [ 173.981564] CPU: 2 UID: 0 PID: 536 Comm: sh Not tainted 6.12.0-rc6-06344-g2aed7c4a5c56 #144 [ 173.989923] Hardware name: NXP i.MX95 15X15 board (DT) [ 173.995062] Call trace: [ 173.997509] dump_backtrace+0x90/0xe8 [ 174.001196] show_stack+0x18/0x24 [ 174.004524] dump_stack_lvl+0x74/0x8c [ 174.008198] dump_stack+0x18/0x24 [ 174.011526] sysfs_warn_dup+0x64/0x80 [ 174.015201] sysfs_do_create_link_sd+0xf0/0xf8 [ 174.019656] sysfs_create_link+0x20/0x40 [ 174.023590] software_node_notify+0x90/0x100 [ 174.027872] device_create_managed_software_node+0xec/0x108 ... The '4c010010.usb' device is a platform device created during the initcall and is never removed, which causes its associated software node to persist indefinitely. The existing device_create_managed_software_node() does not provide a corresponding removal function. Replace device_create_managed_software_node() with the device_add_software_node() and device_remove_software_node() pair to ensure proper addition and removal of software nodes, addressing this issue. Fixes: a9400f1 ("usb: dwc3: imx8mp: add 2 software managed quirk properties for host mode") Cc: stable@vger.kernel.org Reviewed-by: Frank Li <Frank.Li@nxp.com> Signed-off-by: Xu Yang <xu.yang_2@nxp.com> Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com> Link: https://lore.kernel.org/r/20241126032841.2458338-1-xu.yang_2@nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f4911ec commit b089cdb

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

drivers/usb/dwc3/dwc3-imx8mp.c

+16-14
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@ static void dwc3_imx8mp_wakeup_disable(struct dwc3_imx8mp *dwc3_imx)
129129
writel(val, dwc3_imx->hsio_blk_base + USB_WAKEUP_CTRL);
130130
}
131131

132+
static const struct property_entry dwc3_imx8mp_properties[] = {
133+
PROPERTY_ENTRY_BOOL("xhci-missing-cas-quirk"),
134+
PROPERTY_ENTRY_BOOL("xhci-skip-phy-init-quirk"),
135+
{},
136+
};
137+
138+
static const struct software_node dwc3_imx8mp_swnode = {
139+
.properties = dwc3_imx8mp_properties,
140+
};
141+
132142
static irqreturn_t dwc3_imx8mp_interrupt(int irq, void *_dwc3_imx)
133143
{
134144
struct dwc3_imx8mp *dwc3_imx = _dwc3_imx;
@@ -148,17 +158,6 @@ static irqreturn_t dwc3_imx8mp_interrupt(int irq, void *_dwc3_imx)
148158
return IRQ_HANDLED;
149159
}
150160

151-
static int dwc3_imx8mp_set_software_node(struct device *dev)
152-
{
153-
struct property_entry props[3] = { 0 };
154-
int prop_idx = 0;
155-
156-
props[prop_idx++] = PROPERTY_ENTRY_BOOL("xhci-missing-cas-quirk");
157-
props[prop_idx++] = PROPERTY_ENTRY_BOOL("xhci-skip-phy-init-quirk");
158-
159-
return device_create_managed_software_node(dev, props, NULL);
160-
}
161-
162161
static int dwc3_imx8mp_probe(struct platform_device *pdev)
163162
{
164163
struct device *dev = &pdev->dev;
@@ -221,17 +220,17 @@ static int dwc3_imx8mp_probe(struct platform_device *pdev)
221220
if (err < 0)
222221
goto disable_rpm;
223222

224-
err = dwc3_imx8mp_set_software_node(dev);
223+
err = device_add_software_node(dev, &dwc3_imx8mp_swnode);
225224
if (err) {
226225
err = -ENODEV;
227-
dev_err(dev, "failed to create software node\n");
226+
dev_err(dev, "failed to add software node\n");
228227
goto disable_rpm;
229228
}
230229

231230
err = of_platform_populate(node, NULL, NULL, dev);
232231
if (err) {
233232
dev_err(&pdev->dev, "failed to create dwc3 core\n");
234-
goto disable_rpm;
233+
goto remove_swnode;
235234
}
236235

237236
dwc3_imx->dwc3 = of_find_device_by_node(dwc3_np);
@@ -255,6 +254,8 @@ static int dwc3_imx8mp_probe(struct platform_device *pdev)
255254

256255
depopulate:
257256
of_platform_depopulate(dev);
257+
remove_swnode:
258+
device_remove_software_node(dev);
258259
disable_rpm:
259260
pm_runtime_disable(dev);
260261
pm_runtime_put_noidle(dev);
@@ -268,6 +269,7 @@ static void dwc3_imx8mp_remove(struct platform_device *pdev)
268269

269270
pm_runtime_get_sync(dev);
270271
of_platform_depopulate(dev);
272+
device_remove_software_node(dev);
271273

272274
pm_runtime_disable(dev);
273275
pm_runtime_put_noidle(dev);

0 commit comments

Comments
 (0)