lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <737eeb51-b5eb-4585-a9d2-f1578b21d86f@linux.intel.com>
Date: Wed, 9 Oct 2024 09:33:16 +0200
From: Amadeusz Sławiński
 <amadeuszx.slawinski@...ux.intel.com>
To: Guan-Yu Lin <guanyulin@...gle.com>, Thinh.Nguyen@...opsys.com,
 gregkh@...uxfoundation.org, mathias.nyman@...el.com,
 stern@...land.harvard.edu, elder@...nel.org, oneukum@...e.com,
 yajun.deng@...ux.dev, dianders@...omium.org, kekrby@...il.com,
 perex@...ex.cz, tiwai@...e.com, tj@...nel.org, stanley_chang@...ltek.com,
 andreyknvl@...il.com, christophe.jaillet@...adoo.fr,
 quic_jjohnson@...cinc.com, ricardo@...liere.net, grundler@...omium.org,
 niko.mauno@...sala.com
Cc: linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
 linux-sound@...r.kernel.org, badhri@...gle.com, albertccwang@...gle.com,
 quic_wcheng@...cinc.com, pumahsu@...gle.com
Subject: Re: [PATCH v4 3/5] usb: add apis for sideband uasge tracking

On 10/9/2024 7:42 AM, Guan-Yu Lin wrote:
> Introduce sb_usage_count and corresponding apis to track sideband usage
> on each usb_device. A sideband refers to the co-processor that accesses
> the usb_device via shared control on the same USB host controller. To
> optimize power usage, it's essential to monitor whether ther sideband is
> actively using the usb_device. This information is vital when
> determining if a usb_device can be safely suspended during system power
> state transitions.
> 
> Signed-off-by: Guan-Yu Lin <guanyulin@...gle.com>
> ---
>   drivers/usb/core/driver.c | 54 +++++++++++++++++++++++++++++++++++++++
>   include/linux/usb.h       | 13 ++++++++++
>   2 files changed, 67 insertions(+)
> 
> diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
> index 0c3f12daac79..c1ba5ed15214 100644
> --- a/drivers/usb/core/driver.c
> +++ b/drivers/usb/core/driver.c
> @@ -1673,6 +1673,60 @@ void usb_disable_autosuspend(struct usb_device *udev)
>   }
>   EXPORT_SYMBOL_GPL(usb_disable_autosuspend);
>   
> +/**
> + * usb_sideband_get - notify usb driver there's a new active sideband
> + * @udev: the usb_device which has an active sideband
> + *
> + * An active sideband indicates that another entity is currently using the usb
> + * device. Notify the usb device by increasing the sb_usage_count. This allows
> + * usb driver to adjust power management policy based on sideband activities.
> + */
> +void usb_sideband_get(struct usb_device *udev)
> +{
> +	struct usb_device *parent = udev;

Is it really "parent" in this case? Perhaps better variable name would 
just be "device".

> +
> +	do {
> +		atomic_inc(&parent->sb_usage_count);
> +		parent = parent->parent;
> +	} while (parent);
> +}
> +EXPORT_SYMBOL_GPL(usb_sideband_get);
> +
> +/**
> + * usb_sideband_put - notify usb driver there's a sideband deactivated
> + * @udev: the usb_device which has a sideband deactivated
> + *
> + * The inverse operation of usb_sideband_get, which notifies the usb device by
> + * decreasing the sb_usage_count. This allows usb driver to adjust power
> + * management policy based on sideband activities.
> + */
> +void usb_sideband_put(struct usb_device *udev)
> +{
> +	struct usb_device *parent = udev;

Similarly here.

> +
> +	do {
> +		atomic_dec(&parent->sb_usage_count);
> +		parent = parent->parent;
> +	} while (parent);
> +}
> +EXPORT_SYMBOL_GPL(usb_sideband_put);
> +

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ