Linux USB
 help / color / mirror / Atom feed
From: Linyu Yuan <quic_linyyuan@quicinc.com>
To: 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>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: <linux-usb@vger.kernel.org>, Linyu Yuan <quic_linyyuan@quicinc.com>
Subject: [PATCH v2 02/11] usb: gadget: add anonymous definition in struct usb_request
Date: Mon, 11 Sep 2023 19:24:37 +0800	[thread overview]
Message-ID: <20230911112446.1791-3-quic_linyyuan@quicinc.com> (raw)
In-Reply-To: <20230911112446.1791-1-quic_linyyuan@quicinc.com>

Some UDC trace event will save usb request information, but it will use
one int size buffer to save one bit information of usb request, so more
than one int buffer to save several bit fields which is not good.

First add an anonymous union which have one u32 member dw1 which can be
used by trace event during fast assign stage to reduce trace buffer
usage, add related macro to extract bit fields from dw1 for later trace
event output state usage.

Also move exist stread_id and other bit fields into one anonymous struct
which inside anonymous union, Change them from unsigned to u32 type,
it will make sure union member have same memory size as dw1.

Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
---
v2: no change

 include/linux/usb/gadget.h | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index cdf62e7f34e7..045ebd4637c5 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -41,6 +41,7 @@ struct usb_ep;
  * @num_sgs: number of SG entries
  * @num_mapped_sgs: number of SG entries mapped to DMA (internal)
  * @length: Length of that data
+ * @dw1: trace event purpose
  * @stream_id: The stream id, when USB3.0 bulk streams are being used
  * @is_last: Indicates if this is the last request of a stream_id before
  *	switching to a different stream (required for DWC3 controllers).
@@ -105,12 +106,23 @@ struct usb_request {
 	unsigned		num_sgs;
 	unsigned		num_mapped_sgs;
 
-	unsigned		stream_id:16;
-	unsigned		is_last:1;
-	unsigned		no_interrupt:1;
-	unsigned		zero:1;
-	unsigned		short_not_ok:1;
-	unsigned		dma_mapped:1;
+	union {
+		struct {
+			u32	stream_id:16;
+			u32	is_last:1;
+			u32	no_interrupt:1;
+			u32	zero:1;
+			u32	short_not_ok:1;
+			u32	dma_mapped:1;
+		} __packed;
+		u32		dw1;
+#define		USB_REQ_STREAM_ID(n)	((n) & 0xffff)
+#define		USB_REQ_IS_LAST(n)	(((n) >> 16) & 1)
+#define		USB_REQ_NO_INTERRUPT(n)	(((n) >> 17) & 1)
+#define		USB_REQ_ZERO(n)		(((n) >> 18) & 1)
+#define		USB_REQ_SHORT_NOT_OK(n)	(((n) >> 19) & 1)
+#define		USB_REQ_DMA_MAPPED(n)	(((n) >> 20) & 1)
+	};
 
 	void			(*complete)(struct usb_ep *ep,
 					struct usb_request *req);
-- 
2.17.1


  parent reply	other threads:[~2023-09-11 21:48 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
2023-09-11 13:20     ` Linyu Yuan
2023-09-11 11:24 ` Linyu Yuan [this message]
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=20230911112446.1791-3-quic_linyyuan@quicinc.com \
    --to=quic_linyyuan@quicinc.com \
    --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=gregkh@linuxfoundation.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=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