[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAOuDEK28-ruD-DabsD7V0B8M8zZPVDu0vv1aYRnwYq+qTUua6Q@mail.gmail.com>
Date: Tue, 3 Jun 2025 16:46:00 +0800
From: Guan-Yu Lin <guanyulin@...gle.com>
To: Greg KH <gregkh@...uxfoundation.org>
Cc: mathias.nyman@...el.com, gargaditya08@...e.com, kekrby@...il.com,
jeff.johnson@....qualcomm.com, quic_zijuhu@...cinc.com,
andriy.shevchenko@...ux.intel.com, ben@...adent.org.uk, broonie@...nel.org,
quic_wcheng@...cinc.com, krzysztof.kozlowski@...aro.org,
linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v13 2/4] usb: add apis for offload usage tracking
On Wed, May 28, 2025 at 5:16 PM Greg KH <gregkh@...uxfoundation.org> wrote:
>
> On Wed, May 28, 2025 at 09:04:07AM +0000, Guan-Yu Lin wrote:
> > @@ -2036,6 +2036,131 @@ int usb_disable_usb2_hardware_lpm(struct usb_device *udev)
> >
> > #endif /* CONFIG_PM */
> >
> > +#if IS_ENABLED(CONFIG_USB_XHCI_SIDEBAND_SUSPEND)
>
> ifdef in .c files are messy and hard to maintain.
>
> Also, why is an xhci-specific option enabling/disabling core USB
> functions like this? Shouldn't it be a generic USB config option name
> instead?
>
To address the above 2 suggestions, I'll move related codes into a new
file offload.c, and create a new config to manage them.
> > +int usb_offload_get(struct usb_device *udev)
> > +{
> > + int ret;
> > +
> > + usb_lock_device(udev);
> > + if (udev->state == USB_STATE_NOTATTACHED) {
> > + ret = -ENODEV;
> > + goto unlock_device;
>
> Shouldn't we using the guard logic here instead? That would make all of
> this look much simpler and easier to maintain over time.
>
Thanks for the suggestion. Guard logics would be adapted in the next version.
> > +
> > + if (ret < 0)
>
> Why the blank line?
>
I'll remove the blank line. Thanks for the heads up.
> > +bool usb_offload_check(struct usb_device *udev)
> > +{
> > + struct usb_device *child;
> > + bool active;
> > + int port1;
> > +
> > + usb_hub_for_each_child(udev, port1, child) {
> > + usb_lock_device(child);
> > + active = usb_offload_check(child);
> > + usb_unlock_device(child);
> > + if (active)
> > + return true;
> > + }
> > +
> > + return !!udev->offload_usage;
>
> I think you forgot to mark this function as requiring that the lock be
> held, right? Just documenting it isn't going to be simple to notice or
> maintain over time...
>
> thanks,
>
> greg k-h
__must_hold marco would be added in the next version. Thanks for the heads up.
Regards,
Guan-Yu
Powered by blists - more mailing lists