From: "Michał Pecio" <michal.pecio@gmail.com>
To: Pawel Laszczak <pawell@cadence.com>
Cc: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"stern@rowland.harvard.edu" <stern@rowland.harvard.edu>,
"krzysztof.kozlowski@linaro.org" <krzysztof.kozlowski@linaro.org>,
"christophe.jaillet@wanadoo.fr" <christophe.jaillet@wanadoo.fr>,
"javier.carrasco@wolfvision.net" <javier.carrasco@wolfvision.net>,
"make_ruc2021@163.com" <make_ruc2021@163.com>,
"peter.chen@nxp.com" <peter.chen@nxp.com>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Pawel Eichler <peichler@cadence.com>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH v3] usb: hub: lack of clearing xHC resources
Date: Fri, 16 May 2025 11:56:27 +0200 [thread overview]
Message-ID: <20250516115627.5e79831f@foxbook> (raw)
In-Reply-To: <PH7PR07MB953841E38C088678ACDCF6EEDDCC2@PH7PR07MB9538.namprd07.prod.outlook.com>
On Fri, 28 Feb 2025 07:50:25 +0000, Pawel Laszczak wrote:
> The xHC resources allocated for USB devices are not released in
> correct order after resuming in case when while suspend device was
> reconnected.
>
> This issue has been detected during the fallowing scenario:
> - connect hub HS to root port
> - connect LS/FS device to hub port
> - wait for enumeration to finish
> - force host to suspend
> - reconnect hub attached to root port
> - wake host
>
> For this scenario during enumeration of USB LS/FS device the Cadence
> xHC reports completion error code for xHC commands because the xHC
> resources used for devices has not been properly released.
> XHCI specification doesn't mention that device can be reset in any
> order so, we should not treat this issue as Cadence xHC controller
> bug. Similar as during disconnecting in this case the device
> resources should be cleared starting form the last usb device in tree
> toward the root hub. To fix this issue usbcore driver should call
> hcd->driver->reset_device for all USB devices connected to hub which
> was reconnected while suspending.
>
> Fixes: 3d82904559f4 ("usb: cdnsp: cdns3 Add main part of Cadence USBSSP DRD Driver")
> cc: <stable@vger.kernel.org>
> Signed-off-by: Pawel Laszczak <pawell@cadence.com>
Taking discussion about this patch out of bugzilla
https://bugzilla.kernel.org/show_bug.cgi?id=220069#c42
As Mathias pointed out, this whole idea is an explicit spec violation,
because it puts multiple Device Slots into the Default state.
(Which has nothing to do with actually resetting the devices, by the
way. USB core will still do it from the root towards the leaves. It
only means the xHC believes that they are reset when they are not.)
A reset-resume of a whole tree looks like a tricky case, because on one
hand a hub must resume (here: be reset) before its children in order to
reset them, but this apparently causes problems when some xHCs consider
the hub "in use" by the children (or its TT in use by their endpoints,
I suspect that's the case here and the reason why this patch helps).
I have done some experimentation with reset-resuming from autosuspend,
either by causing Transaction Errors while resuming (full speed only)
or simulating usb_get_std_status() error in finish_port_resume().
Either way, I noticed that the whole device tree ends up logically
disconnected and reconnected during reset-resume, so perhaps it would
be acceptable to disable all xHC Device Slots (leaf to root) before
resetting everything and re-enable Slots (root to leaf) one by one?
By the way, it's highly unclear if bug 220069 is caused by this spec
violation (I think it's not), but this is still very sloppy code.
Regards,
Michal
next prev parent reply other threads:[~2025-05-16 9:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20250228074307.728010-1-pawell@cadence.com>
2025-02-28 7:50 ` [PATCH v3] usb: hub: lack of clearing xHC resources Pawel Laszczak
2025-02-28 15:06 ` Alan Stern
2025-03-10 1:16 ` Peter Chen
2025-05-16 9:56 ` Michał Pecio [this message]
2025-05-20 6:28 ` Pawel Laszczak
2025-05-22 10:27 ` Pawel Laszczak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250516115627.5e79831f@foxbook \
--to=michal.pecio@gmail.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=gregkh@linuxfoundation.org \
--cc=javier.carrasco@wolfvision.net \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=make_ruc2021@163.com \
--cc=pawell@cadence.com \
--cc=peichler@cadence.com \
--cc=peter.chen@nxp.com \
--cc=stable@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox