From: Krishna Kurapati <krishna.kurapati@oss.qualcomm.com>
To: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>,
"linux-arm-msm@vger.kernel.org" <linux-arm-msm@vger.kernel.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 3/4] usb: dwc3: qcom: Facilitate autosuspend during host mode
Date: Tue, 24 Jun 2025 18:38:22 +0530 [thread overview]
Message-ID: <72f9de63-dc19-4467-b883-8637f95a8e82@oss.qualcomm.com> (raw)
In-Reply-To: <20250623235856.b2jwgf5j6yup2sww@synopsys.com>
On 6/24/2025 5:29 AM, Thinh Nguyen wrote:
> On Tue, Jun 10, 2025, Krishna Kurapati wrote:
>> When in host mode, it is intended that the controller goes to suspend
>> state to save power and wait for interrupts from connected peripheral
>> to wake it up. This is particularly used in cases where a HID or Audio
>> device is connected. In such scenarios, the usb controller can enter
>> auto suspend and resume action after getting interrupts from the
>> connected device.
>>
>> Allow autosuspend for and xhci device and allow userspace to decide
>> whether to enable this functionality.
>>
>> a) Register to usb-core notifications in set_role vendor callback to
>> identify when root hubs are being created. Configure them to
>> use_autosuspend.
>>
>> b) Identify usb core notifications where the HCD is being added and
>> enable autosuspend for that particular xhci device.
>>
>> Signed-off-by: Krishna Kurapati <krishna.kurapati@oss.qualcomm.com>
[...]
>> +static int dwc3_xhci_event_notifier(struct notifier_block *nb,
>> + unsigned long event, void *ptr)
>> +{
>> + struct dwc3_qcom *qcom = container_of(nb, struct dwc3_qcom, xhci_nb);
>> + struct dwc3 *dwc = &qcom->dwc;
>> + struct usb_bus *ubus = ptr;
>> + struct usb_hcd *hcd;
>> +
>> + if (!dwc->xhci)
>> + goto done;
>> +
>> + hcd = platform_get_drvdata(dwc->xhci);
>> + if (!hcd)
>> + goto done;
>> +
>> + if (event != USB_BUS_ADD)
>> + goto done;
>> +
>> + if (strcmp(dev_name(ubus->sysdev), dev_name(dwc->sysdev)) != 0)
>
> Can this be false? If possible, I'd like to avoid these pointers and
> strcmp here.
>
Needed this to identify if the dwc3 pointer corresponds to this glue or
not. This can be false.
BTW, Dmitry suggested to just do "runtime_use_autosuspend" inside probe
of xhci-plat.c and remove this logic. Hope that would be fine ?
>> + goto done;
>> +
>> + if (event == USB_BUS_ADD) {
>
> This condition is redundant when you have the check a few lines above.
>
ACK.
>> + /*
>> + * Identify instant of creation of primary hcd and
>> + * mark xhci as autosuspend capable at this point.
>> + */
>> + pm_runtime_use_autosuspend(&dwc->xhci->dev);
>> + }
>> +
>> +done:
>> + return NOTIFY_DONE;
>> +}
>> +
>> static void dwc3_qcom_set_role_notifier(struct dwc3 *dwc, enum usb_role next_role)
>> {
>> struct dwc3_qcom *qcom = to_dwc3_qcom(dwc);
>> @@ -659,12 +694,22 @@ static void dwc3_qcom_set_role_notifier(struct dwc3 *dwc, enum usb_role next_rol
>> return;
>> }
>>
>> - if (qcom->current_role == USB_ROLE_DEVICE &&
>> - next_role != USB_ROLE_DEVICE)
>> + if (qcom->current_role == USB_ROLE_NONE) {
>> + if (next_role == USB_ROLE_DEVICE) {
>> + dwc3_qcom_vbus_override_enable(qcom, true);
>> + } else if (next_role == USB_ROLE_HOST) {
>> + qcom->xhci_nb.notifier_call = dwc3_xhci_event_notifier;
>> + usb_register_notify(&qcom->xhci_nb);
>> + }
>> + } else if (qcom->current_role == USB_ROLE_DEVICE &&
>> + next_role != USB_ROLE_DEVICE) {
>> dwc3_qcom_vbus_override_enable(qcom, false);
>> - else if ((qcom->current_role != USB_ROLE_DEVICE) &&
>> - (next_role == USB_ROLE_DEVICE))
>> - dwc3_qcom_vbus_override_enable(qcom, true);
>> + } else if (qcom->current_role == USB_ROLE_HOST) {
>> + if (next_role == USB_ROLE_NONE)
>> + usb_unregister_notify(&qcom->xhci_nb);
>> + else if (next_role == USB_ROLE_DEVICE)
>> + dwc3_qcom_vbus_override_enable(qcom, true);
>
> We don't unregister the notifier when switching from host to device?
>
ACK. My bad, missed it.
Thanks for the review.
Regards,
Krishna,
next prev parent reply other threads:[~2025-06-24 13:08 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-10 9:13 [PATCH v2 0/4] usb: dwc3: Modify role-switching QC drd usb controllers Krishna Kurapati
2025-06-10 9:13 ` [PATCH v2 1/4] usb: dwc3: core: Introduce glue callbacks for flattened implementations Krishna Kurapati
2025-06-17 1:29 ` Thinh Nguyen
2025-06-23 23:24 ` Thinh Nguyen
2025-06-24 13:03 ` Krishna Kurapati
2025-06-10 9:13 ` [PATCH v2 2/4] usb: dwc3: qcom: Implement glue callbacks to facilitate runtime suspend Krishna Kurapati
2025-06-10 10:58 ` Dmitry Baryshkov
2025-06-10 16:36 ` Krishna Kurapati
2025-06-10 17:23 ` Dmitry Baryshkov
2025-06-11 14:44 ` Krishna Kurapati
2025-06-23 23:32 ` Thinh Nguyen
2025-06-24 13:04 ` Krishna Kurapati
2025-07-11 23:29 ` Thinh Nguyen
2025-07-13 9:29 ` Krishna Kurapati
2025-07-30 1:23 ` Thinh Nguyen
2025-07-30 2:16 ` Krishna Kurapati
2025-08-01 1:01 ` Thinh Nguyen
2025-08-05 11:18 ` Krishna Kurapati
2025-08-05 23:18 ` Thinh Nguyen
2025-08-06 0:18 ` Krishna Kurapati
2025-08-06 0:50 ` Thinh Nguyen
2025-06-10 9:13 ` [PATCH v2 3/4] usb: dwc3: qcom: Facilitate autosuspend during host mode Krishna Kurapati
2025-06-10 11:00 ` Dmitry Baryshkov
2025-06-10 16:40 ` Krishna Kurapati
2025-06-10 17:24 ` Dmitry Baryshkov
2025-06-23 23:59 ` Thinh Nguyen
2025-06-24 13:08 ` Krishna Kurapati [this message]
2025-06-10 9:13 ` [PATCH v2 4/4] usb: dwc3: qcom: Remove extcon functionality from glue Krishna Kurapati
2025-06-10 11:04 ` Dmitry Baryshkov
2025-06-10 10:01 ` [PATCH v2 0/4] usb: dwc3: Modify role-switching QC drd usb controllers Krishna Kurapati
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=72f9de63-dc19-4467-b883-8637f95a8e82@oss.qualcomm.com \
--to=krishna.kurapati@oss.qualcomm.com \
--cc=Thinh.Nguyen@synopsys.com \
--cc=bjorn.andersson@oss.qualcomm.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/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
all inboxes | Powered by JetHome®