All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Guan-Yu Lin <guanyulin@google.com>
Cc: mathias.nyman@intel.com, stern@rowland.harvard.edu,
	sumit.garg@kernel.org, gargaditya08@live.com, kekrby@gmail.com,
	jeff.johnson@oss.qualcomm.com, quic_zijuhu@quicinc.com,
	andriy.shevchenko@linux.intel.com, ben@decadent.org.uk,
	broonie@kernel.org, quic_wcheng@quicinc.com,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v12 3/4] xhci: sideband: add api to trace sideband usage
Date: Fri, 25 Apr 2025 13:14:26 +0200	[thread overview]
Message-ID: <2025042518-shoplift-garnish-3a69@gregkh> (raw)
In-Reply-To: <20250416144917.16822-4-guanyulin@google.com>

On Wed, Apr 16, 2025 at 02:43:03PM +0000, Guan-Yu Lin wrote:
> The existing sideband driver only registers sidebands without tracking
> their active usage. To address this, sideband will now record its active
> usage when it creates/removes interrupters. In addition, a new api is
> introduced to provide a means for other dirvers to fetch sideband
> activity information on a USB host controller.
> 
> Signed-off-by: Guan-Yu Lin <guanyulin@google.com>
> ---
>  drivers/usb/host/xhci-sideband.c  | 43 +++++++++++++++++++++++++++++++
>  include/linux/usb/xhci-sideband.h |  9 +++++++
>  2 files changed, 52 insertions(+)
> 
> diff --git a/drivers/usb/host/xhci-sideband.c b/drivers/usb/host/xhci-sideband.c
> index d49f9886dd84..67f31b0ec726 100644
> --- a/drivers/usb/host/xhci-sideband.c
> +++ b/drivers/usb/host/xhci-sideband.c
> @@ -266,6 +266,31 @@ xhci_sideband_get_event_buffer(struct xhci_sideband *sb)
>  }
>  EXPORT_SYMBOL_GPL(xhci_sideband_get_event_buffer);
>  
> +#if IS_ENABLED(CONFIG_USB_XHCI_SIDEBAND_SUSPEND)
> +/**
> + * xhci_sideband_check - check the existence of active sidebands
> + * @hcd: the host controller driver associated with the target host controller
> + *
> + * Allow other drivers, such as usb controller driver, to check if there are
> + * any sideband activity on the host controller. This information could be used
> + * for power management or other forms of resource management.
> + *
> + * Returns true on any active sideband existence, false otherwise.
> + */
> +bool xhci_sideband_check(struct usb_hcd *hcd)
> +{
> +	struct usb_device *udev = hcd->self.root_hub;
> +	bool active;
> +
> +	device_lock(&udev->dev);
> +	active = usb_offload_check(udev);
> +	device_unlock(&udev->dev);
> +
> +	return active;

What happens if the value changes right after reading it?  What are you
going to do with the value?

> +}
> +EXPORT_SYMBOL_GPL(xhci_sideband_check);
> +#endif /* IS_ENABLED(CONFIG_USB_XHCI_SIDEBAND_SUSPEND) */
> +
>  /**
>   * xhci_sideband_create_interrupter - creates a new interrupter for this sideband
>   * @sb: sideband instance for this usb device
> @@ -286,6 +311,7 @@ xhci_sideband_create_interrupter(struct xhci_sideband *sb, int num_seg,
>  				 bool ip_autoclear, u32 imod_interval, int intr_num)
>  {
>  	int ret = 0;
> +	struct usb_device *udev;
>  
>  	if (!sb || !sb->xhci)
>  		return -ENODEV;
> @@ -304,6 +330,11 @@ xhci_sideband_create_interrupter(struct xhci_sideband *sb, int num_seg,
>  		goto out;
>  	}
>  
> +	udev = sb->vdev->udev;
> +	device_lock(&udev->dev);
> +	ret = usb_offload_get(udev);
> +	device_unlock(&udev->dev);

A "raw" call to device_lock/unlock feels rough, and harsh, why doesn't
the function do that itself?

thanks,

greg k-h

  reply	other threads:[~2025-04-25 11:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-16 14:43 [PATCH v12 0/4] Support system sleep with offloaded usb transfers Guan-Yu Lin
2025-04-16 14:43 ` [PATCH v12 1/4] usb: xhci-plat: separate dev_pm_ops for each pm_event Guan-Yu Lin
2025-04-16 14:43 ` [PATCH v12 2/4] usb: add apis for offload usage tracking Guan-Yu Lin
2025-04-25 11:12   ` Greg KH
2025-05-16  4:45     ` Guan-Yu Lin
2025-04-16 14:43 ` [PATCH v12 3/4] xhci: sideband: add api to trace sideband usage Guan-Yu Lin
2025-04-25 11:14   ` Greg KH [this message]
2025-05-15 11:28     ` Guan-Yu Lin
2025-04-16 14:43 ` [PATCH v12 4/4] usb: host: enable USB offload during system sleep Guan-Yu Lin
2025-04-25 11:15   ` Greg KH
2025-05-15 10:37     ` Guan-Yu Lin

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=2025042518-shoplift-garnish-3a69@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=ben@decadent.org.uk \
    --cc=broonie@kernel.org \
    --cc=gargaditya08@live.com \
    --cc=guanyulin@google.com \
    --cc=jeff.johnson@oss.qualcomm.com \
    --cc=kekrby@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=quic_wcheng@quicinc.com \
    --cc=quic_zijuhu@quicinc.com \
    --cc=stern@rowland.harvard.edu \
    --cc=sumit.garg@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.