Linux USB
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Linyu Yuan <quic_linyyuan@quicinc.com>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
	Peter Chen <peter.chen@kernel.org>,
	Pawel Laszczak <pawell@cadence.com>,
	Roger Quadros <rogerq@kernel.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Chunfeng Yun <chunfeng.yun@mediatek.com>,
	Neal Liu <neal_liu@aspeedtech.com>,
	Cristian Birsan <cristian.birsan@microchip.com>,
	Bin Liu <b-liu@ti.com>, Kevin Cernekee <cernekee@gmail.com>,
	Justin Chen <justin.chen@broadcom.com>,
	Al Cooper <alcooperx@gmail.com>, Li Yang <leoyang.li@nxp.com>,
	Vladimir Zapolskiy <vz@mleia.com>,
	Daniel Mack <daniel@zonque.org>,
	Haojian Zhuang <haojian.zhuang@gmail.com>,
	Robert Jarzmik <robert.jarzmik@free.fr>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Herve Codina <herve.codina@bootlin.com>,
	hierry Reding <thierry.reding@gmail.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Michal Simek <michal.simek@amd.com>,
	Rui Miguel Silva <rui.silva@linaro.org>,
	Valentina Manea <valentina.manea.m@gmail.com>,
	Shuah Khan <shuah@kernel.org>, Hongren Zheng <i@zenithal.me>,
	linux-usb@vger.kernel.org
Subject: Re: [PATCH v2 01/11] usb: gadget: add anonymous definition in struct usb_gadget
Date: Mon, 11 Sep 2023 13:37:33 +0200	[thread overview]
Message-ID: <2023091137-babble-chaffing-553c@gregkh> (raw)
In-Reply-To: <20230911112446.1791-2-quic_linyyuan@quicinc.com>

On Mon, Sep 11, 2023 at 07:24:36PM +0800, Linyu Yuan wrote:
> Some UDC trace event will save usb gadget information, but it will use
> one int size buffer to save one bit information of usb gadget, so more
> than one int buffer to save several bit fields which is not good.
> 
> Add one anonymous union have three u32 members which can be used by trace
> event during fast assign stage to reduce trace buffer usage, and add
> related macro to extract bit fields from u32 members for later trace event
> output state usage.
> 
> Also move sg_supported and other bit fields into one anonymous struct
> which inside anonymous union and Change bit fields from unsigned to u32
> type, it will make sure union member have expected u32 size.
> 
> Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
> ---
> v2: no change
> 
>  include/linux/usb/gadget.h | 63 ++++++++++++++++++++++++++------------
>  1 file changed, 44 insertions(+), 19 deletions(-)
> 
> diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
> index 75bda0783395..cdf62e7f34e7 100644
> --- a/include/linux/usb/gadget.h
> +++ b/include/linux/usb/gadget.h
> @@ -357,6 +357,7 @@ struct usb_gadget_ops {
>   * @in_epnum: last used in ep number
>   * @mA: last set mA value
>   * @otg_caps: OTG capabilities of this gadget.
> + * @dw1: trace event purpose
>   * @sg_supported: true if we can handle scatter-gather
>   * @is_otg: True if the USB device port uses a Mini-AB jack, so that the
>   *	gadget driver must provide a USB OTG descriptor.
> @@ -432,25 +433,49 @@ struct usb_gadget {
>  	unsigned			mA;
>  	struct usb_otg_caps		*otg_caps;
>  
> -	unsigned			sg_supported:1;
> -	unsigned			is_otg:1;
> -	unsigned			is_a_peripheral:1;
> -	unsigned			b_hnp_enable:1;
> -	unsigned			a_hnp_support:1;
> -	unsigned			a_alt_hnp_support:1;
> -	unsigned			hnp_polling_support:1;
> -	unsigned			host_request_flag:1;
> -	unsigned			quirk_ep_out_aligned_size:1;
> -	unsigned			quirk_altset_not_supp:1;
> -	unsigned			quirk_stall_not_supp:1;
> -	unsigned			quirk_zlp_not_supp:1;
> -	unsigned			quirk_avoids_skb_reserve:1;
> -	unsigned			is_selfpowered:1;
> -	unsigned			deactivated:1;
> -	unsigned			connected:1;
> -	unsigned			lpm_capable:1;
> -	unsigned			wakeup_capable:1;
> -	unsigned			wakeup_armed:1;
> +	union {
> +		struct {
> +			u32		sg_supported:1;
> +			u32		is_otg:1;
> +			u32		is_a_peripheral:1;
> +			u32		b_hnp_enable:1;
> +			u32		a_hnp_support:1;
> +			u32		a_alt_hnp_support:1;
> +			u32		hnp_polling_support:1;
> +			u32		host_request_flag:1;
> +			u32		quirk_ep_out_aligned_size:1;
> +			u32		quirk_altset_not_supp:1;
> +			u32		quirk_stall_not_supp:1;
> +			u32		quirk_zlp_not_supp:1;
> +			u32		quirk_avoids_skb_reserve:1;
> +			u32		is_selfpowered:1;
> +			u32		deactivated:1;
> +			u32		connected:1;
> +			u32		lpm_capable:1;
> +			u32		wakeup_capable:1;
> +			u32		wakeup_armed:1;
> +		} __packed;
> +		u32			dw1;
> +#define		USB_GADGET_SG_SUPPORTED(n)			((n) & BIT(0))
> +#define		USB_GADGET_IS_OTG(n)				((n) & BIT(1))
> +#define		USB_GADGET_IS_A_PERIPHERAL(n)			((n) & BIT(2))
> +#define		USB_GADGET_B_HNP_ENABLE(n)			((n) & BIT(3))
> +#define		USB_GADGET_A_HNP_SUPPORT(n)			((n) & BIT(4))
> +#define		USB_GADGET_A_ALT_HNP_SUPPORT(n)			((n) & BIT(5))
> +#define		USB_GADGET_HNP_POLLING_SUPPORT(n)		((n) & BIT(6))
> +#define		USB_GADGET_HOST_REQUEST_FLAG(n)			((n) & BIT(7))
> +#define		USB_GADGET_QUIRK_EP_OUT_ALIGNED_SIZE(n)		((n) & BIT(8))
> +#define		USB_GADGET_QUIRK_ALTSET_NOT_SUPP(n)		((n) & BIT(9))
> +#define		USB_GADGET_QUIRK_STALL_NOT_SUPP(n)		((n) & BIT(10))
> +#define		USB_GADGET_QUIRK_ZLP_NOT_SUPP(n)		((n) & BIT(11))
> +#define		USB_GADGET_QUIRK_AVOIDS_SKB_RESERVE(n)		((n) & BIT(12))
> +#define		USB_GADGET_IS_SELFPOWERED(n)			((n) & BIT(13))
> +#define		USB_GADGET_DEACTIVATED(n)			((n) & BIT(14))
> +#define		USB_GADGET_CONNECTED(n)				((n) & BIT(15))
> +#define		USB_GADGET_LPM_CAPABLE(n)			((n) & BIT(16))
> +#define		USB_GADGET_WAKEUP_CAPABLE(n)			((n) & BIT(17))
> +#define		USB_GADGET_WAKEUP_ARMED(n)			((n) & BIT(18))

Does this actually work on both types of endian-ness?

thanks,

greg k-h

  reply	other threads:[~2023-09-11 21:41 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-11 11:24 [PATCH v2 00/11] usb: gadget: reduce usb gadget trace event buffer usage Linyu Yuan
2023-09-11 11:24 ` [PATCH v2 01/11] usb: gadget: add anonymous definition in struct usb_gadget Linyu Yuan
2023-09-11 11:37   ` Greg Kroah-Hartman [this message]
2023-09-11 13:20     ` Linyu Yuan
2023-09-11 11:24 ` [PATCH v2 02/11] usb: gadget: add anonymous definition in struct usb_request Linyu Yuan
2023-09-11 11:24 ` [PATCH v2 03/11] usb: gadget: add anonymous definition in struct usb_ep Linyu Yuan
2023-09-11 11:24 ` [PATCH v2 04/11] usb: udc: assign epnum for each usb endpoint Linyu Yuan
2023-09-11 11:24 ` [PATCH v2 05/11] usb: udc: trace: reduce buffer usage of trace event Linyu Yuan
2023-09-11 11:24 ` [PATCH v2 06/11] usb: cdns3: cdnsp: " Linyu Yuan
2023-09-11 11:24 ` [PATCH v2 07/11] usb: cdns3: trace: " Linyu Yuan
2023-09-11 11:24 ` [PATCH v2 08/11] usb: dwc3: " Linyu Yuan
2023-09-11 11:24 ` [PATCH v2 09/11] usb: cdns2: " Linyu Yuan
2023-09-11 11:24 ` [PATCH v2 10/11] usb: mtu3: " Linyu Yuan
2023-09-11 13:33   ` Greg Kroah-Hartman
2023-09-11 11:24 ` [PATCH v2 11/11] usb: musb: " Linyu Yuan
2023-09-11 13:32 ` [PATCH v2 00/11] usb: gadget: reduce usb gadget trace event buffer usage Greg Kroah-Hartman
2023-09-11 13:44   ` Linyu Yuan
2023-09-11 13:48     ` Greg Kroah-Hartman
2023-09-11 13:56       ` Linyu Yuan

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=2023091137-babble-chaffing-553c@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=Thinh.Nguyen@synopsys.com \
    --cc=alcooperx@gmail.com \
    --cc=b-liu@ti.com \
    --cc=cernekee@gmail.com \
    --cc=chunfeng.yun@mediatek.com \
    --cc=cristian.birsan@microchip.com \
    --cc=daniel@zonque.org \
    --cc=haojian.zhuang@gmail.com \
    --cc=herve.codina@bootlin.com \
    --cc=i@zenithal.me \
    --cc=jonathanh@nvidia.com \
    --cc=justin.chen@broadcom.com \
    --cc=leoyang.li@nxp.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=michal.simek@amd.com \
    --cc=neal_liu@aspeedtech.com \
    --cc=p.zabel@pengutronix.de \
    --cc=pawell@cadence.com \
    --cc=peter.chen@kernel.org \
    --cc=quic_linyyuan@quicinc.com \
    --cc=robert.jarzmik@free.fr \
    --cc=rogerq@kernel.org \
    --cc=rui.silva@linaro.org \
    --cc=shuah@kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=valentina.manea.m@gmail.com \
    --cc=vz@mleia.com \
    /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