* [PATCH 5.10.y-cip] usb: cdns3: gadget: fix state inconsistency on gadget init failure
@ 2026-11-27 12:18 Dickson Wu via B4 Relay
2026-11-27 13:11 ` Greg KH
0 siblings, 1 reply; 6+ messages in thread
From: Dickson Wu via B4 Relay @ 2026-11-27 12:18 UTC (permalink / raw)
To: cip-dev
Cc: Pavel Machek, Nobuhiro Iwamatsu, Ulrich Hecht, Yongchao Wu,
linux-usb
From: Yongchao Wu <yongchao.wu@autochips.com>
commit c32f8748d70c8fc77676ad92ed76cede17bf2c48 upstream.
When cdns3_gadget_start() fails, the DRD hardware is left in gadget mode
while software state remains INACTIVE, creating hardware/software state
inconsistency.
When switching to host mode via sysfs:
echo host > /sys/class/usb_role/13180000.usb-role-switch/role
The role state is not set to CDNS_ROLE_STATE_ACTIVE due to the error,
so cdns_role_stop() skips cleanup because state is still INACTIVE.
This violates the DRD controller design specification (Figure22),
which requires returning to idle state before switching roles.
This leads to a synchronous external abort in xhci_gen_setup() when
setting up the host controller:
[ 516.440698] configfs-gadget 13180000.usb: failed to start g1: -19
[ 516.442035] cdns-usb3 13180000.usb: Failed to add gadget
[ 516.443278] cdns-usb3 13180000.usb: set role 2 has failed
...
[ 1301.375722] xhci-hcd xhci-hcd.1.auto: xHCI Host Controller
[ 1301.377716] Internal error: synchronous external abort: 96000010 [#1] PREEMPT SMP
[ 1301.382485] pc : xhci_gen_setup+0xa4/0x408
[ 1301.393391] backtrace:
...
xhci_gen_setup+0xa4/0x408 <-- CRASH
xhci_plat_setup+0x44/0x58
usb_add_hcd+0x284/0x678
...
cdns_role_set+0x9c/0xbc <-- Role switch
Fix by calling cdns_drd_gadget_off() in the error path to properly
clean up the DRD gadget state.
Fixes: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver")
Cc: stable <stable@kernel.org>
Signed-off-by: Yongchao Wu <yongchao.wu@autochips.com>
Acked-by: Peter Chen <peter.chen@kernel.org>
Link: https://patch.msgid.link/20260401001000.5761-1-yongchao.wu@autochips.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[ adapted to 5.10.y-cip: use gadget.c and cdns3_drd_gadget_off() ]
Signed-off-by: Dickson Wu <dickson.wu@certik.com>
---
5.10 has the old cdns3 layout, so the call goes in gadget.c and uses
cdns3_drd_gadget_off(). This failed to apply to 5.10.y and never made
it into a 5.10.y release, and 5.10.y is now end-of-life, so I'm sending
it here.
Tested on 5.10.275-cip80: the touched object
drivers/usb/cdns3/gadget.o builds with W=1. The same change on
v5.10.275 built with no new W=1 diagnostics and booted under QEMU. I
don't have Cadence hardware, so the failing-init path itself wasn't
exercised.
The backport and the test runs were prepared with AI coding tools
(OpenAI Codex agents, with review by Claude). I went over the result
before signing off.
---
drivers/usb/cdns3/gadget.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c
index d0378ecd0c98..b6cb690208cd 100644
--- a/drivers/usb/cdns3/gadget.c
+++ b/drivers/usb/cdns3/gadget.c
@@ -3418,6 +3418,7 @@ static int __cdns3_gadget_init(struct cdns3 *cdns)
ret = cdns3_gadget_start(cdns);
if (ret) {
pm_runtime_put_sync(cdns->dev);
+ cdns3_drd_gadget_off(cdns);
return ret;
}
---
base-commit: bd8b111cdf1d9897bf4d826b7305a9c16bfe5f71
change-id: 20261127-cip-cdns3-510c-10094b795da1
Best regards,
--
Dickson Wu <dickson.wu@certik.com>
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 5.10.y-cip] usb: cdns3: gadget: fix state inconsistency on gadget init failure
2026-11-27 12:18 [PATCH 5.10.y-cip] usb: cdns3: gadget: fix state inconsistency on gadget init failure Dickson Wu via B4 Relay
@ 2026-11-27 13:11 ` Greg KH
2026-11-27 18:46 ` Dickson Wu
2026-11-27 22:07 ` Pavel Machek
0 siblings, 2 replies; 6+ messages in thread
From: Greg KH @ 2026-11-27 13:11 UTC (permalink / raw)
To: dickson.wu
Cc: cip-dev, Pavel Machek, Nobuhiro Iwamatsu, Ulrich Hecht,
Yongchao Wu, linux-usb
On Fri, Nov 27, 2026 at 12:18:44PM +0000, Dickson Wu via B4 Relay wrote:
> From: Yongchao Wu <yongchao.wu@autochips.com>
>
> commit c32f8748d70c8fc77676ad92ed76cede17bf2c48 upstream.
There's no need to send cip-only patches to the usb public mailing lists
(or any other lore.kernel.org list).
thanks,
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 5.10.y-cip] usb: cdns3: gadget: fix state inconsistency on gadget init failure
2026-11-27 13:11 ` Greg KH
@ 2026-11-27 18:46 ` Dickson Wu
2026-11-27 22:07 ` Pavel Machek
1 sibling, 0 replies; 6+ messages in thread
From: Dickson Wu @ 2026-11-27 18:46 UTC (permalink / raw)
To: Greg KH
Cc: cip-dev, Pavel Machek, Nobuhiro Iwamatsu, Ulrich Hecht,
Yongchao Wu, linux-usb
On Fri, Nov 27, 2026 at 01:11:56PM +0000, Greg KH wrote:
> There's no need to send cip-only patches to the usb public mailing lists
> (or any other lore.kernel.org list).
Ah got it, sorry for the noise! I'll keep the CIP ones to cip-dev and
the people involved from now on
Thanks,
Dickson
On Fri, 27 Nov 2026 14:11:56 +0100, Greg KH <greg@kroah.com> wrote:
> On Fri, Nov 27, 2026 at 12:18:44PM +0000, Dickson Wu via B4 Relay wrote:
> > From: Yongchao Wu <yongchao.wu@autochips.com>
> >
> > commit c32f8748d70c8fc77676ad92ed76cede17bf2c48 upstream.
>
> There's no need to send cip-only patches to the usb public mailing lists
> (or any other lore.kernel.org list).
>
> thanks,
>
> greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 5.10.y-cip] usb: cdns3: gadget: fix state inconsistency on gadget init failure
2026-11-27 13:11 ` Greg KH
2026-11-27 18:46 ` Dickson Wu
@ 2026-11-27 22:07 ` Pavel Machek
2026-11-27 22:19 ` Dickson Wu
1 sibling, 1 reply; 6+ messages in thread
From: Pavel Machek @ 2026-11-27 22:07 UTC (permalink / raw)
To: Greg KH
Cc: dickson.wu, cip-dev, Pavel Machek, Nobuhiro Iwamatsu,
Ulrich Hecht, Yongchao Wu, linux-usb
[-- Attachment #1: Type: text/plain, Size: 532 bytes --]
Hi!
> > From: Yongchao Wu <yongchao.wu@autochips.com>
> >
> > commit c32f8748d70c8fc77676ad92ed76cede17bf2c48 upstream.
>
> There's no need to send cip-only patches to the usb public mailing lists
> (or any other lore.kernel.org list).
Could you share some kind of motivation / background why are you doing
this? Do you have product using -cip? Or is it just AI advertising?
There will still be 5.10-stable releases, no? This is not -cip
specific, so I'd preffer this to go there.
Best regards,
Pavel
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 5.10.y-cip] usb: cdns3: gadget: fix state inconsistency on gadget init failure
2026-11-27 22:07 ` Pavel Machek
@ 2026-11-27 22:19 ` Dickson Wu
2026-12-01 12:12 ` Pavel Machek
0 siblings, 1 reply; 6+ messages in thread
From: Dickson Wu @ 2026-11-27 22:19 UTC (permalink / raw)
To: Greg KH
Cc: cip-dev, Pavel Machek, Nobuhiro Iwamatsu, Ulrich Hecht,
Yongchao Wu, linux-usb
On Fri, Nov 27, 2026 at 10:07:39PM +0000, Pavel Machek wrote:
> Could you share some kind of motivation / background why are you doing
> this? Do you have product using -cip? Or is it just AI advertising?
>
> There will still be 5.10-stable releases, no? This is not -cip
> specific, so I'd preffer this to go there.
Hi Pavel,
Fair question. No product on -cip, and nothing to advertise. I'm a
security researcher, and I've been going through security fixes that
reached mainline and the newer stable trees but never made it to the
older ones downstreams still build on.
I was sending the 5.10 ones to stable, but Greg said on stable@ earlier
today that 5.10.y has had its final -rc and won't take anything more.
That's why I moved them to -cip, since that's where 5.10 keeps going.
If these aren't useful for CIP, just say so and I'll stop sending them
Best,
Dickson
On Fri, 27 Nov 2026 23:07:39 +0100, Pavel Machek <pavel@nabladev.com> wrote:
> Hi!
>
> > > From: Yongchao Wu <yongchao.wu@autochips.com>
> > >
> > > commit c32f8748d70c8fc77676ad92ed76cede17bf2c48 upstream.
> >
> > There's no need to send cip-only patches to the usb public mailing lists
> > (or any other lore.kernel.org list).
>
> Could you share some kind of motivation / background why are you doing
> this? Do you have product using -cip? Or is it just AI advertising?
>
> There will still be 5.10-stable releases, no? This is not -cip
> specific, so I'd preffer this to go there.
>
> Best regards,
> Pavel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 5.10.y-cip] usb: cdns3: gadget: fix state inconsistency on gadget init failure
2026-11-27 22:19 ` Dickson Wu
@ 2026-12-01 12:12 ` Pavel Machek
0 siblings, 0 replies; 6+ messages in thread
From: Pavel Machek @ 2026-12-01 12:12 UTC (permalink / raw)
To: Dickson Wu
Cc: Greg KH, cip-dev, Pavel Machek, Nobuhiro Iwamatsu, Ulrich Hecht,
Yongchao Wu, linux-usb
[-- Attachment #1: Type: text/plain, Size: 1411 bytes --]
Hi!
> > Could you share some kind of motivation / background why are you doing
> > this? Do you have product using -cip? Or is it just AI advertising?
> >
> > There will still be 5.10-stable releases, no? This is not -cip
> > specific, so I'd preffer this to go there.
>
> Fair question. No product on -cip, and nothing to advertise. I'm a
> security researcher, and I've been going through security fixes that
> reached mainline and the newer stable trees but never made it to the
> older ones downstreams still build on.
Thanks for answers!
> I was sending the 5.10 ones to stable, but Greg said on stable@ earlier
> today that 5.10.y has had its final -rc and won't take anything more.
> That's why I moved them to -cip, since that's where 5.10 keeps going.
>
> If these aren't useful for CIP, just say so and I'll stop sending
> them
Ok, let me take a look. It looks like we'll need to start
self-mainintaining 5.10.
I'll review your patches, and likely we'll apply them.
But I'll ask two things:
a) only backport fixes for bad bugs. "user can gain root"
counts. "random data corruption" counts. "root can crash machine" or
"bad dts can result in memory leak"... lets ignore these.
b) write one or two lines in the footer why the bug is bad. "malicious
machine on local LAN can crash system" would be good explanation.
Thanks and best regards,
Pavel
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-12-01 12:13 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 12:18 [PATCH 5.10.y-cip] usb: cdns3: gadget: fix state inconsistency on gadget init failure Dickson Wu via B4 Relay
2026-11-27 13:11 ` Greg KH
2026-11-27 18:46 ` Dickson Wu
2026-11-27 22:07 ` Pavel Machek
2026-11-27 22:19 ` Dickson Wu
2026-12-01 12:12 ` Pavel Machek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox