From patchwork Tue Sep 12 10:44:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linyu Yuan X-Patchwork-Id: 722098 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23EC8CA0EC3 for ; Tue, 12 Sep 2023 10:48:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234556AbjILKsH (ORCPT ); Tue, 12 Sep 2023 06:48:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234580AbjILKrb (ORCPT ); Tue, 12 Sep 2023 06:47:31 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C0012D49 for ; Tue, 12 Sep 2023 03:46:13 -0700 (PDT) Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38C7RmCn029021; Tue, 12 Sep 2023 10:45:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=GaT13gaZ5ErTcPmyi7wI80e49jYlWh55hml06Bp2juQ=; b=Iq2l2sjzX9F9duzjUQcDSdLw0/B9bDVJ8uWxdOfK5A4D41jo83iYqAYIA/6UQ+SDGZCD iKNgTj1vTzFSl92nrOHI2fIOJlexYDNjarB1MuX2XCCUvu1CH47MO4sjWA07emsc6hQm gxN474fU0kBDB1UUdQ73mTJ9lULYLFMatrYW1oAfIpOV6IXDD4as7JdAA+zcPR/MHSz0 +BuSOO1nMWVJrOMIRB2V/4i6gzO8YMLfwlUh12sx8Cib9X8VKAKHGMPrdIVeX1b8aL4Z iCbtNWPKzJ+oBDUGfNLQo8boUGvcwF01yfPwSUvNxSqYQJe49kCnsaJwwDdXRV7cQpLP Vg== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3t268fj3f3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 Sep 2023 10:45:28 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 38CAjQwu019293 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 Sep 2023 10:45:27 GMT Received: from linyyuan-gv.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.36; Tue, 12 Sep 2023 03:45:19 -0700 From: Linyu Yuan To: Thinh Nguyen , Peter Chen , Pawel Laszczak , Roger Quadros , Linus Walleij , Chunfeng Yun , Neal Liu , "Cristian Birsan" , Bin Liu , "Kevin Cernekee" , Justin Chen , "Al Cooper" , Li Yang , "Vladimir Zapolskiy" , Daniel Mack , Haojian Zhuang , Robert Jarzmik , "Philipp Zabel" , Herve Codina , hierry Reding , Jonathan Hunter , Michal Simek , Rui Miguel Silva , Valentina Manea , "Shuah Khan" , Hongren Zheng , Greg Kroah-Hartman CC: , Linyu Yuan Subject: [PATCH v3 02/10] usb: gadget: add anonymous definition in struct usb_request Date: Tue, 12 Sep 2023 18:44:47 +0800 Message-ID: <20230912104455.7737-3-quic_linyyuan@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230912104455.7737-1-quic_linyyuan@quicinc.com> References: <20230912104455.7737-1-quic_linyyuan@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: cWFi6nQRTGT7iEZ_IL4l-TrI_eR5kiOP X-Proofpoint-ORIG-GUID: cWFi6nQRTGT7iEZ_IL4l-TrI_eR5kiOP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-12_08,2023-09-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 spamscore=0 adultscore=0 mlxscore=0 bulkscore=0 phishscore=0 malwarescore=0 impostorscore=0 priorityscore=1501 clxscore=1015 mlxlogscore=535 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309120090 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org 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. In order to allow trace event output stage access the bit from saved u32 'dw1', add following macros, define USB_REQ_BITFIELD(n, name) \ ({\ 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;\ } __aligned(4) __r_u_##name;\ u32 __r_##name; \ BUILD_BUG_ON(sizeof(__r_u_##name) != 4);\ __r_u_##name.dw1 = (n); __r_##name = __r_u_##name.name;\ __r_##name; }) define USB_REQ_STREAM_ID(n) USB_REQ_BITFIELD((n), stream_id) ... change to use this kind of macros for all related trace files later. Signed-off-by: Linyu Yuan --- v2: no change v3: change method to extract bit field include/linux/usb/gadget.h | 43 ++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index f02e1bd20924..a1717c633942 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,17 @@ 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; + } __aligned(4); void (*complete)(struct usb_ep *ep, struct usb_request *req); @@ -123,6 +129,31 @@ struct usb_request { unsigned actual; }; +#define USB_REQ_BITFIELD(n, name) \ + ({\ + 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;\ + } __aligned(4) __r_u_##name;\ + u32 __r_##name; \ + BUILD_BUG_ON(sizeof(__r_u_##name) != 4);\ + __r_u_##name.dw1 = (n); __r_##name = __r_u_##name.name;\ + __r_##name; }) + +#define USB_REQ_STREAM_ID(n) USB_REQ_BITFIELD((n), stream_id) +#define USB_REQ_IS_LAST(n) USB_REQ_BITFIELD((n), stream_id) +#define USB_REQ_NO_INTERRUPT(n) USB_REQ_BITFIELD((n), stream_id) +#define USB_REQ_ZERO(n) USB_REQ_BITFIELD((n), stream_id) +#define USB_REQ_SHORT_NOT_OK(n) USB_REQ_BITFIELD((n), stream_id) +#define USB_REQ_DMA_MAPPED(n) USB_REQ_BITFIELD((n), stream_id) + /*-------------------------------------------------------------------------*/ /* endpoint-specific parts of the api to the usb controller hardware. From patchwork Tue Sep 12 10:44:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linyu Yuan X-Patchwork-Id: 722097 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1120ACA0ECA for ; Tue, 12 Sep 2023 10:48:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234276AbjILKsO (ORCPT ); Tue, 12 Sep 2023 06:48:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234614AbjILKri (ORCPT ); Tue, 12 Sep 2023 06:47:38 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EC9A2D66 for ; Tue, 12 Sep 2023 03:46:18 -0700 (PDT) Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38C5j2Jk021252; Tue, 12 Sep 2023 10:45:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=ql0MXUqnRp4qZTJ5FGKsA7pW/NJ/IDI6mp45YiyGHx8=; b=ihgRRitmgWPhLrh/WZyI25qMHMRZuNd0DM7VvxtpFcBMPPlzMKvqkUprpCjXA6wBfXlR yiygvutmXO0nJTtaIHH2R/bQQ0vspgWQ9DU+PpsKGbwNm+yseqjB7kbZ6UBVKoMWCfN3 xUYxojgo17dletdGXCEU0ITc6wDlAl8jWwOeDKdEEDl0EReqyoLIj6zwwBO9fKGeAPGu pHIW39H4DPDoiORAkzxMOzG/y2iVkvphj0BsLle2S0tevTLXiMhcAYZOGY4JC+rMi9mL 23st8iwnsJmSo1R5xtqYUzh3HvGSxRYWcD+qvCQGEzcZNhcSNAxyjxu3FgZIQN6ySUXU jg== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3t22hyjq3k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 Sep 2023 10:45:34 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 38CAjXCh029993 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 Sep 2023 10:45:33 GMT Received: from linyyuan-gv.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.36; Tue, 12 Sep 2023 03:45:26 -0700 From: Linyu Yuan To: Thinh Nguyen , Peter Chen , Pawel Laszczak , Roger Quadros , Linus Walleij , Chunfeng Yun , Neal Liu , "Cristian Birsan" , Bin Liu , "Kevin Cernekee" , Justin Chen , "Al Cooper" , Li Yang , "Vladimir Zapolskiy" , Daniel Mack , Haojian Zhuang , Robert Jarzmik , "Philipp Zabel" , Herve Codina , hierry Reding , Jonathan Hunter , Michal Simek , Rui Miguel Silva , Valentina Manea , "Shuah Khan" , Hongren Zheng , Greg Kroah-Hartman CC: , Linyu Yuan Subject: [PATCH v3 03/10] usb: gadget: add anonymous definition in struct usb_ep Date: Tue, 12 Sep 2023 18:44:48 +0800 Message-ID: <20230912104455.7737-4-quic_linyyuan@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230912104455.7737-1-quic_linyyuan@quicinc.com> References: <20230912104455.7737-1-quic_linyyuan@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: KkoYaF0lOxHE8l9WYB4Q5Y6cMX8DFGZv X-Proofpoint-GUID: KkoYaF0lOxHE8l9WYB4Q5Y6cMX8DFGZv X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-12_08,2023-09-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 priorityscore=1501 mlxlogscore=992 phishscore=0 spamscore=0 impostorscore=0 mlxscore=0 adultscore=0 suspectscore=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309120090 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Some UDC trace event will save usb endpoint information, but it will use one int size buffer to save one bit information of usb endpoint, so more than one int buffer to save several bit fields which is not good. Add some 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 exist maxpacket and other bit field into anonymous struct which inside anonymous union and Change them from unsigned to u32 type. Signed-off-by: Linyu Yuan --- v2: no change v3: change method to extract bit field include/linux/usb/gadget.h | 106 +++++++++++++++++++++++++++++++------ 1 file changed, 90 insertions(+), 16 deletions(-) diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index a1717c633942..1b63843f5c31 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -194,13 +194,14 @@ struct usb_ep_ops { * @dir_out:Endpoint supports OUT direction. */ struct usb_ep_caps { - unsigned type_control:1; - unsigned type_iso:1; - unsigned type_bulk:1; - unsigned type_int:1; - unsigned dir_in:1; - unsigned dir_out:1; -}; + u8 type_control:1; + u8 type_iso:1; + u8 type_bulk:1; + u8 type_int:1; + u8 dir_in:1; + u8 dir_out:1; + u8 reserve:2; +} __packed; #define USB_EP_CAPS_TYPE_CONTROL 0x01 #define USB_EP_CAPS_TYPE_ISO 0x02 @@ -230,6 +231,9 @@ struct usb_ep_caps { * @caps:The structure describing types and directions supported by endpoint. * @enabled: The current endpoint enabled/disabled state. * @claimed: True if this endpoint is claimed by a function. + * @dw1: trace event purpose + * @dw2: trace event purpose + * @dw3: trace event purpose * @maxpacket:The maximum packet size used on this endpoint. The initial * value can sometimes be reduced (hardware allowing), according to * the endpoint descriptor used to configure the endpoint. @@ -259,19 +263,89 @@ struct usb_ep { const char *name; const struct usb_ep_ops *ops; struct list_head ep_list; - struct usb_ep_caps caps; - bool claimed; - bool enabled; - unsigned maxpacket:16; - unsigned maxpacket_limit:16; - unsigned max_streams:16; - unsigned mult:2; - unsigned maxburst:5; - u8 address; + union { + struct { + u32 maxpacket:16; + u32 maxpacket_limit:16; + } __packed; + u32 dw1; + } __aligned(4); + union { + struct { + u32 max_streams:16; + u32 mult:2; + u32 maxburst:5; + } __packed; + u32 dw2; + } __aligned(4); + union { + struct { + struct usb_ep_caps caps; + u8 claimed:1; + u8 enabled:1; + u8 address; + } __packed; + u32 dw3; + } __aligned(4); const struct usb_endpoint_descriptor *desc; const struct usb_ss_ep_comp_descriptor *comp_desc; }; +#define USB_EP_DW1_BITFIELD(n, name) \ + ({\ + union {\ + struct {\ + u32 maxpacket:16;\ + u32 maxpacket_limit:16;\ + } __packed;\ + u32 dw1;\ + } __aligned(4) __e_u_##name;\ + u32 __e_##name;\ + BUILD_BUG_ON(sizeof(__e_u_##name) != 4);\ + __e_u_##name.dw1 = (n); __e_##name = __e_u_##name.name;\ + __e_##name; }) + +#define USB_EP_MAXPACKET(n) USB_EP_DW1_BITFIELD((n), maxpacket) +#define USB_EP_MAXPACKET_LIMIT(n) USB_EP_DW1_BITFIELD((n), maxpacket_limit) + +#define USB_EP_DW2_BITFIELD(n, name) \ + ({\ + union {\ + struct {\ + u32 max_streams:16;\ + u32 mult:2;\ + u32 maxburst:5;\ + } __packed;\ + u32 dw2;\ + } __aligned(4) __e_u_##name;\ + u32 __e_##name; \ + BUILD_BUG_ON(sizeof(__e_u_##name) != 4);\ + __e_u_##name.dw2 = (n); __e_##name = __e_u_##name.name;\ + __e_##name; }) + +#define USB_EP_MAX_STREAMS(n) USB_EP_DW2_BITFIELD((n), max_streams) +#define USB_EP_MULT(n) USB_EP_DW2_BITFIELD((n), mult) +#define USB_EP_MAXBURST(n) USB_EP_DW2_BITFIELD((n), maxburst) + + +#define USB_EP_NAME(n) \ + ({char __s[9]; /* max 8: ep127out */ \ + union {\ + struct {\ + struct usb_ep_caps caps;\ + u8 claimed:1;\ + u8 enabled:1;\ + u8 address;\ + } __packed;\ + u32 dw3;\ + } __aligned(4) __e_u_##name;\ + BUILD_BUG_ON(sizeof(__e_u_##name) != 4);\ + __e_u_##name.dw3 = (n);\ + snprintf(__s, 9, "ep%d%s", __e_u_##name.address, \ + (__e_u_##name.caps.dir_in && __e_u_##name.caps.dir_out) ? "" : \ + __e_u_##name.caps.dir_in ? "in" : "out");\ + __s; }) + /*-------------------------------------------------------------------------*/ #if IS_ENABLED(CONFIG_USB_GADGET) From patchwork Tue Sep 12 10:44:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linyu Yuan X-Patchwork-Id: 722096 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03557CA0ECA for ; Tue, 12 Sep 2023 10:48:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234387AbjILKsU (ORCPT ); Tue, 12 Sep 2023 06:48:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234430AbjILKru (ORCPT ); Tue, 12 Sep 2023 06:47:50 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95F37B9 for ; Tue, 12 Sep 2023 03:46:36 -0700 (PDT) Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38C7wacY019746; Tue, 12 Sep 2023 10:45:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=2gkkjGRgv5gTWhUWygT2JQoreUZTWlJi9nw41Ls33S0=; b=HH2ZGRST5Z9gAs4D9wsVRbgj1SuL6DmNead68SdGQGAqfciYii7B2iF/Td3ctCw6rtNs JnSzSY31oljEZgAufRgN3C14mJ8Vx9f78pF9yBb617HHCnp6cJZZHKjhRHldzwmwmpUW c5YVLv1PSFdIt+H3hgEcQIJNIAR0CTBFx+bvFaplPe/9kWFidnkPcNS9Hz+i8ZNpEDS0 xE8FVasAhx5MWwZHPcfYsSD9fR2p6U8npWhp1SkzOSKDzsKi0uj6mwARPI1W1UPDDt/h EDqlrWUYM1PDrAONjH7ZGKtj9/LEhQcdJ7P5PEGO/3/Khe+yXj7mDfTdYMPzrP4Z2ikR VA== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3t268fj3fk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 Sep 2023 10:45:55 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 38CAjsVc022844 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 Sep 2023 10:45:54 GMT Received: from linyyuan-gv.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.36; Tue, 12 Sep 2023 03:45:47 -0700 From: Linyu Yuan To: Thinh Nguyen , Peter Chen , Pawel Laszczak , Roger Quadros , Linus Walleij , Chunfeng Yun , Neal Liu , "Cristian Birsan" , Bin Liu , "Kevin Cernekee" , Justin Chen , "Al Cooper" , Li Yang , "Vladimir Zapolskiy" , Daniel Mack , Haojian Zhuang , Robert Jarzmik , "Philipp Zabel" , Herve Codina , hierry Reding , Jonathan Hunter , Michal Simek , Rui Miguel Silva , Valentina Manea , "Shuah Khan" , Hongren Zheng , Greg Kroah-Hartman CC: , Linyu Yuan Subject: [PATCH v3 06/10] usb: cdns3: trace: reduce buffer usage of trace event Date: Tue, 12 Sep 2023 18:44:51 +0800 Message-ID: <20230912104455.7737-7-quic_linyyuan@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230912104455.7737-1-quic_linyyuan@quicinc.com> References: <20230912104455.7737-1-quic_linyyuan@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: MpOGtxOa-SOyhSxlliTd-u1Bryap2XNy X-Proofpoint-ORIG-GUID: MpOGtxOa-SOyhSxlliTd-u1Bryap2XNy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-12_08,2023-09-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 spamscore=0 adultscore=0 mlxscore=0 bulkscore=0 phishscore=0 malwarescore=0 impostorscore=0 priorityscore=1501 clxscore=1015 mlxlogscore=485 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309120090 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Save u32 members into trace event ring buffer and parse it for possible bit information. Signed-off-by: Linyu Yuan --- v2: no change v3: no change drivers/usb/cdns3/cdns3-trace.h | 93 +++++++++++++++------------------ 1 file changed, 42 insertions(+), 51 deletions(-) diff --git a/drivers/usb/cdns3/cdns3-trace.h b/drivers/usb/cdns3/cdns3-trace.h index 40db89e3333c..391547546530 100644 --- a/drivers/usb/cdns3/cdns3-trace.h +++ b/drivers/usb/cdns3/cdns3-trace.h @@ -28,45 +28,45 @@ TRACE_EVENT(cdns3_halt, TP_PROTO(struct cdns3_endpoint *ep_priv, u8 halt, u8 flush), TP_ARGS(ep_priv, halt, flush), TP_STRUCT__entry( - __string(name, ep_priv->name) + __field(u32, edw3) __field(u8, halt) __field(u8, flush) ), TP_fast_assign( - __assign_str(name, ep_priv->name); + __entry->edw3 = ep_priv->endpoint.dw3; __entry->halt = halt; __entry->flush = flush; ), TP_printk("Halt %s for %s: %s", __entry->flush ? " and flush" : "", - __get_str(name), __entry->halt ? "set" : "cleared") + USB_EP_NAME(__entry->edw3), __entry->halt ? "set" : "cleared") ); TRACE_EVENT(cdns3_wa1, TP_PROTO(struct cdns3_endpoint *ep_priv, char *msg), TP_ARGS(ep_priv, msg), TP_STRUCT__entry( - __string(ep_name, ep_priv->name) + __field(u32, edw3) __string(msg, msg) ), TP_fast_assign( - __assign_str(ep_name, ep_priv->name); + __entry->edw3 = ep_priv->endpoint.dw3; __assign_str(msg, msg); ), - TP_printk("WA1: %s %s", __get_str(ep_name), __get_str(msg)) + TP_printk("WA1: %s %s", USB_EP_NAME(__entry->edw3), __get_str(msg)) ); TRACE_EVENT(cdns3_wa2, TP_PROTO(struct cdns3_endpoint *ep_priv, char *msg), TP_ARGS(ep_priv, msg), TP_STRUCT__entry( - __string(ep_name, ep_priv->name) + __field(u32, edw3) __string(msg, msg) ), TP_fast_assign( - __assign_str(ep_name, ep_priv->name); + __entry->edw3 = ep_priv->endpoint.dw3; __assign_str(msg, msg); ), - TP_printk("WA2: %s %s", __get_str(ep_name), __get_str(msg)) + TP_printk("WA2: %s %s", USB_EP_NAME(__entry->edw3), __get_str(msg)) ); DECLARE_EVENT_CLASS(cdns3_log_doorbell, @@ -118,14 +118,14 @@ DECLARE_EVENT_CLASS(cdns3_log_epx_irq, TP_PROTO(struct cdns3_device *priv_dev, struct cdns3_endpoint *priv_ep), TP_ARGS(priv_dev, priv_ep), TP_STRUCT__entry( - __string(ep_name, priv_ep->name) + __field(u32, edw3) __field(u32, ep_sts) __field(u32, ep_traddr) __field(u32, ep_last_sid) __field(u32, use_streams) ), TP_fast_assign( - __assign_str(ep_name, priv_ep->name); + __entry->edw3 = priv_ep->endpoint.dw3; __entry->ep_sts = readl(&priv_dev->regs->ep_sts); __entry->ep_traddr = readl(&priv_dev->regs->ep_traddr); __entry->ep_last_sid = priv_ep->last_stream_id; @@ -133,7 +133,7 @@ DECLARE_EVENT_CLASS(cdns3_log_epx_irq, ), TP_printk("%s, ep_traddr: %08x ep_last_sid: %08x use_streams: %d", cdns3_decode_epx_irq(__get_buf(CDNS3_MSG_MAX), - __get_str(ep_name), + USB_EP_NAME(__entry->edw3), __entry->ep_sts), __entry->ep_traddr, __entry->ep_last_sid, @@ -199,47 +199,42 @@ DECLARE_EVENT_CLASS(cdns3_log_request, TP_PROTO(struct cdns3_request *req), TP_ARGS(req), TP_STRUCT__entry( - __string(name, req->priv_ep->name) + __field(u32, edw3) __field(struct cdns3_request *, req) __field(void *, buf) __field(unsigned int, actual) __field(unsigned int, length) __field(int, status) - __field(int, zero) - __field(int, short_not_ok) - __field(int, no_interrupt) + __field(u32, rdw1) __field(int, start_trb) __field(int, end_trb) __field(int, flags) __field(unsigned int, stream_id) ), TP_fast_assign( - __assign_str(name, req->priv_ep->name); + __entry->edw3 = req->priv_ep->endpoint.dw3; __entry->req = req; __entry->buf = req->request.buf; __entry->actual = req->request.actual; __entry->length = req->request.length; __entry->status = req->request.status; - __entry->zero = req->request.zero; - __entry->short_not_ok = req->request.short_not_ok; - __entry->no_interrupt = req->request.no_interrupt; + __entry->rdw1 = req->request.dw1; __entry->start_trb = req->start_trb; __entry->end_trb = req->end_trb; __entry->flags = req->flags; - __entry->stream_id = req->request.stream_id; ), TP_printk("%s: req: %p, req buff %p, length: %u/%u %s%s%s, status: %d," " trb: [start:%d, end:%d], flags:%x SID: %u", - __get_str(name), __entry->req, __entry->buf, __entry->actual, + USB_EP_NAME(__entry->edw3), __entry->req, __entry->buf, __entry->actual, __entry->length, - __entry->zero ? "Z" : "z", - __entry->short_not_ok ? "S" : "s", - __entry->no_interrupt ? "I" : "i", + USB_REQ_ZERO(__entry->rdw1) ? "Z" : "z", + USB_REQ_SHORT_NOT_OK(__entry->rdw1) ? "S" : "s", + USB_REQ_NO_INTERRUPT(__entry->rdw1) ? "I" : "i", __entry->status, __entry->start_trb, __entry->end_trb, __entry->flags, - __entry->stream_id + USB_REQ_STREAM_ID(__entry->rdw1) ) ); @@ -287,21 +282,21 @@ DECLARE_EVENT_CLASS(cdns3_stream_split_transfer_len, TP_PROTO(struct cdns3_request *req), TP_ARGS(req), TP_STRUCT__entry( - __string(name, req->priv_ep->name) + __field(u32, edw3) __field(struct cdns3_request *, req) __field(unsigned int, length) __field(unsigned int, actual) __field(unsigned int, stream_id) ), TP_fast_assign( - __assign_str(name, req->priv_ep->name); + __entry->edw3 = req->priv_ep->endpoint.dw3; __entry->req = req; __entry->actual = req->request.length; __entry->length = req->request.actual; __entry->stream_id = req->request.stream_id; ), TP_printk("%s: req: %p,request length: %u actual length: %u SID: %u", - __get_str(name), __entry->req, __entry->length, + USB_EP_NAME(__entry->edw3), __entry->req, __entry->length, __entry->actual, __entry->stream_id) ); @@ -320,7 +315,7 @@ DECLARE_EVENT_CLASS(cdns3_log_aligned_request, TP_PROTO(struct cdns3_request *priv_req), TP_ARGS(priv_req), TP_STRUCT__entry( - __string(name, priv_req->priv_ep->name) + __field(u32, edw3) __field(struct usb_request *, req) __field(void *, buf) __field(dma_addr_t, dma) @@ -329,7 +324,7 @@ DECLARE_EVENT_CLASS(cdns3_log_aligned_request, __field(u32, aligned_buf_size) ), TP_fast_assign( - __assign_str(name, priv_req->priv_ep->name); + __entry->edw3 = priv_req->priv_ep->endpoint.dw3; __entry->req = &priv_req->request; __entry->buf = priv_req->request.buf; __entry->dma = priv_req->request.dma; @@ -338,7 +333,7 @@ DECLARE_EVENT_CLASS(cdns3_log_aligned_request, __entry->aligned_buf_size = priv_req->aligned_buf->size; ), TP_printk("%s: req: %p, req buf %p, dma %pad a_buf %p a_dma %pad, size %d", - __get_str(name), __entry->req, __entry->buf, &__entry->dma, + USB_EP_NAME(__entry->edw3), __entry->req, __entry->buf, &__entry->dma, __entry->aligned_buf, &__entry->aligned_dma, __entry->aligned_buf_size ) @@ -358,19 +353,19 @@ DECLARE_EVENT_CLASS(cdns3_log_map_request, TP_PROTO(struct cdns3_request *priv_req), TP_ARGS(priv_req), TP_STRUCT__entry( - __string(name, priv_req->priv_ep->name) + __field(u32, edw3) __field(struct usb_request *, req) __field(void *, buf) __field(dma_addr_t, dma) ), TP_fast_assign( - __assign_str(name, priv_req->priv_ep->name); + __entry->edw3 = priv_req->priv_ep->endpoint.dw3; __entry->req = &priv_req->request; __entry->buf = priv_req->request.buf; __entry->dma = priv_req->request.dma; ), TP_printk("%s: req: %p, req buf %p, dma %p", - __get_str(name), __entry->req, __entry->buf, &__entry->dma + USB_EP_NAME(__entry->edw3), __entry->req, __entry->buf, &__entry->dma ) ); DEFINE_EVENT(cdns3_log_map_request, cdns3_map_request, @@ -386,7 +381,7 @@ DECLARE_EVENT_CLASS(cdns3_log_trb, TP_PROTO(struct cdns3_endpoint *priv_ep, struct cdns3_trb *trb), TP_ARGS(priv_ep, trb), TP_STRUCT__entry( - __string(name, priv_ep->name) + __field(u32, edw3) __field(struct cdns3_trb *, trb) __field(u32, buffer) __field(u32, length) @@ -395,7 +390,7 @@ DECLARE_EVENT_CLASS(cdns3_log_trb, __field(unsigned int, last_stream_id) ), TP_fast_assign( - __assign_str(name, priv_ep->name); + __entry->edw3 = priv_ep->endpoint.dw3; __entry->trb = trb; __entry->buffer = le32_to_cpu(trb->buffer); __entry->length = le32_to_cpu(trb->length); @@ -404,7 +399,7 @@ DECLARE_EVENT_CLASS(cdns3_log_trb, __entry->last_stream_id = priv_ep->last_stream_id; ), TP_printk("%s: trb %p, dma buf: 0x%08x, size: %ld, burst: %d ctrl: 0x%08x (%s%s%s%s%s%s%s) SID:%lu LAST_SID:%u", - __get_str(name), __entry->trb, __entry->buffer, + USB_EP_NAME(__entry->edw3), __entry->trb, __entry->buffer, TRB_LEN(__entry->length), (u8)TRB_BURST_LEN_GET(__entry->length), __entry->control, @@ -455,24 +450,20 @@ DECLARE_EVENT_CLASS(cdns3_log_ep, TP_PROTO(struct cdns3_endpoint *priv_ep), TP_ARGS(priv_ep), TP_STRUCT__entry( - __string(name, priv_ep->name) - __field(unsigned int, maxpacket) - __field(unsigned int, maxpacket_limit) - __field(unsigned int, max_streams) + __field(u32, edw3) + __field(u32, edw1) + __field(u32, edw2) __field(unsigned int, use_streams) - __field(unsigned int, maxburst) __field(unsigned int, flags) __field(unsigned int, dir) __field(u8, enqueue) __field(u8, dequeue) ), TP_fast_assign( - __assign_str(name, priv_ep->name); - __entry->maxpacket = priv_ep->endpoint.maxpacket; - __entry->maxpacket_limit = priv_ep->endpoint.maxpacket_limit; - __entry->max_streams = priv_ep->endpoint.max_streams; + __entry->edw3 = priv_ep->endpoint.dw3; + __entry->edw2 = priv_ep->endpoint.dw2; + __entry->edw1 = priv_ep->endpoint.dw1; __entry->use_streams = priv_ep->use_streams; - __entry->maxburst = priv_ep->endpoint.maxburst; __entry->flags = priv_ep->flags; __entry->dir = priv_ep->dir; __entry->enqueue = priv_ep->enqueue; @@ -480,10 +471,10 @@ DECLARE_EVENT_CLASS(cdns3_log_ep, ), TP_printk("%s: mps: %d/%d. streams: %d, stream enable: %d, burst: %d, " "enq idx: %d, deq idx: %d, flags %s%s%s%s%s%s%s%s, dir: %s", - __get_str(name), __entry->maxpacket, - __entry->maxpacket_limit, __entry->max_streams, + USB_EP_NAME(__entry->edw3), USB_EP_MAXPACKET(__entry->edw1), + USB_EP_MAXPACKET_LIMIT(__entry->edw1), USB_EP_MAX_STREAMS(__entry->edw2), __entry->use_streams, - __entry->maxburst, __entry->enqueue, + USB_EP_MAXBURST(__entry->edw2), __entry->enqueue, __entry->dequeue, __entry->flags & EP_ENABLED ? "EN | " : "", __entry->flags & EP_STALLED ? "STALLED | " : "", From patchwork Tue Sep 12 10:44:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linyu Yuan X-Patchwork-Id: 722094 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D4AFCA0ECA for ; Tue, 12 Sep 2023 10:48:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234515AbjILKs2 (ORCPT ); Tue, 12 Sep 2023 06:48:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234431AbjILKru (ORCPT ); Tue, 12 Sep 2023 06:47:50 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDF32CD for ; Tue, 12 Sep 2023 03:46:41 -0700 (PDT) Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38C9UYWU019298; Tue, 12 Sep 2023 10:46:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=NVGd+PwEiIJ8ua260IDboA8Zi0tt2L0/37wl/H5owRQ=; b=eBHrp+Cpnr4SqRGUIUQcqJVz0SR8JrmQNIJ31xhoCA0T9LK1Xq3o7WXWCSLbt0B37xxt gCnxlAUEMWLdJDgA6hpPc5W+cWy0DJZk0PpQrR7dDG8kAi9+urPjnXjFLrAIA7GxiMdj 0NRd9p/rT9301A3ETz3UCD7Uu0KXe+iB7t8uMKBeYWjM2OZkyloevHIPt4uc5OXZ+0bs 2nQnT9o09w8yhfcKNKJ/SgdDX0rJgHe2CHs2VrDMcEtaEmGBab8pmuKHjShb4GRGLNSJ W/Ww304sdwhDwh9oLpb8IB3wNtMCVAPcvkzj9lP1BRxJjkhggLq+okc7eTrhZKX7bxLI GQ== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3t2ncp04wv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 Sep 2023 10:46:02 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 38CAk1uq030171 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 Sep 2023 10:46:01 GMT Received: from linyyuan-gv.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.36; Tue, 12 Sep 2023 03:45:54 -0700 From: Linyu Yuan To: Thinh Nguyen , Peter Chen , Pawel Laszczak , Roger Quadros , Linus Walleij , Chunfeng Yun , Neal Liu , "Cristian Birsan" , Bin Liu , "Kevin Cernekee" , Justin Chen , "Al Cooper" , Li Yang , "Vladimir Zapolskiy" , Daniel Mack , Haojian Zhuang , Robert Jarzmik , "Philipp Zabel" , Herve Codina , hierry Reding , Jonathan Hunter , Michal Simek , Rui Miguel Silva , Valentina Manea , "Shuah Khan" , Hongren Zheng , Greg Kroah-Hartman CC: , Linyu Yuan Subject: [PATCH v3 07/10] usb: dwc3: trace: reduce buffer usage of trace event Date: Tue, 12 Sep 2023 18:44:52 +0800 Message-ID: <20230912104455.7737-8-quic_linyyuan@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230912104455.7737-1-quic_linyyuan@quicinc.com> References: <20230912104455.7737-1-quic_linyyuan@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: URKpVZJmAS2dfO087CoTDPKJHNsJwhF1 X-Proofpoint-ORIG-GUID: URKpVZJmAS2dfO087CoTDPKJHNsJwhF1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-12_08,2023-09-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 phishscore=0 bulkscore=0 spamscore=0 priorityscore=1501 mlxscore=0 suspectscore=0 clxscore=1015 malwarescore=0 mlxlogscore=528 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309120090 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Save u32 members into trace event ring buffer and parse it for possible bit information. Signed-off-by: Linyu Yuan --- v2: no change v3: no change drivers/usb/dwc3/trace.h | 54 +++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/drivers/usb/dwc3/trace.h b/drivers/usb/dwc3/trace.h index d2997d17cfbe..e1885b83fff8 100644 --- a/drivers/usb/dwc3/trace.h +++ b/drivers/usb/dwc3/trace.h @@ -102,30 +102,26 @@ DECLARE_EVENT_CLASS(dwc3_log_request, TP_PROTO(struct dwc3_request *req), TP_ARGS(req), TP_STRUCT__entry( - __string(name, req->dep->name) + __field(u32, edw3) __field(struct dwc3_request *, req) __field(unsigned int, actual) __field(unsigned int, length) __field(int, status) - __field(int, zero) - __field(int, short_not_ok) - __field(int, no_interrupt) + __field(u32, rdw1) ), TP_fast_assign( - __assign_str(name, req->dep->name); + __entry->edw3 = req->dep->endpoint.dw3; __entry->req = req; __entry->actual = req->request.actual; __entry->length = req->request.length; __entry->status = req->request.status; - __entry->zero = req->request.zero; - __entry->short_not_ok = req->request.short_not_ok; - __entry->no_interrupt = req->request.no_interrupt; + __entry->rdw1 = req->request.dw1; ), TP_printk("%s: req %p length %u/%u %s%s%s ==> %d", - __get_str(name), __entry->req, __entry->actual, __entry->length, - __entry->zero ? "Z" : "z", - __entry->short_not_ok ? "S" : "s", - __entry->no_interrupt ? "i" : "I", + USB_EP_NAME(__entry->edw3), __entry->req, __entry->actual, __entry->length, + USB_REQ_ZERO(__entry->rdw1) ? "Z" : "z", + USB_REQ_SHORT_NOT_OK(__entry->rdw1) ? "S" : "s", + USB_REQ_NO_INTERRUPT(__entry->rdw1) ? "i" : "I", __entry->status ) ); @@ -185,7 +181,7 @@ DECLARE_EVENT_CLASS(dwc3_log_gadget_ep_cmd, struct dwc3_gadget_ep_cmd_params *params, int cmd_status), TP_ARGS(dep, cmd, params, cmd_status), TP_STRUCT__entry( - __string(name, dep->name) + __field(u32, edw3) __field(unsigned int, cmd) __field(u32, param0) __field(u32, param1) @@ -193,7 +189,7 @@ DECLARE_EVENT_CLASS(dwc3_log_gadget_ep_cmd, __field(int, cmd_status) ), TP_fast_assign( - __assign_str(name, dep->name); + __entry->edw3 = dep->endpoint.dw3; __entry->cmd = cmd; __entry->param0 = params->param0; __entry->param1 = params->param1; @@ -201,7 +197,7 @@ DECLARE_EVENT_CLASS(dwc3_log_gadget_ep_cmd, __entry->cmd_status = cmd_status; ), TP_printk("%s: cmd '%s' [%x] params %08x %08x %08x --> status: %s", - __get_str(name), dwc3_gadget_ep_cmd_string(__entry->cmd), + USB_EP_NAME(__entry->edw3), dwc3_gadget_ep_cmd_string(__entry->cmd), __entry->cmd, __entry->param0, __entry->param1, __entry->param2, dwc3_ep_cmd_status_string(__entry->cmd_status) @@ -218,7 +214,7 @@ DECLARE_EVENT_CLASS(dwc3_log_trb, TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb), TP_ARGS(dep, trb), TP_STRUCT__entry( - __string(name, dep->name) + __field(u32, edw3) __field(struct dwc3_trb *, trb) __field(u32, bpl) __field(u32, bph) @@ -229,7 +225,7 @@ DECLARE_EVENT_CLASS(dwc3_log_trb, __field(u32, dequeue) ), TP_fast_assign( - __assign_str(name, dep->name); + __entry->edw3 = dep->endpoint.dw3; __entry->trb = trb; __entry->bpl = trb->bpl; __entry->bph = trb->bph; @@ -240,7 +236,7 @@ DECLARE_EVENT_CLASS(dwc3_log_trb, __entry->dequeue = dep->trb_dequeue; ), TP_printk("%s: trb %p (E%d:D%d) buf %08x%08x size %s%d ctrl %08x sofn %08x (%c%c%c%c:%c%c:%s)", - __get_str(name), __entry->trb, __entry->enqueue, + USB_EP_NAME(__entry->edw3), __entry->trb, __entry->enqueue, __entry->dequeue, __entry->bph, __entry->bpl, ({char *s; int pcm = ((__entry->size >> 24) & 3) + 1; @@ -290,31 +286,27 @@ DECLARE_EVENT_CLASS(dwc3_log_ep, TP_PROTO(struct dwc3_ep *dep), TP_ARGS(dep), TP_STRUCT__entry( - __string(name, dep->name) - __field(unsigned int, maxpacket) - __field(unsigned int, maxpacket_limit) - __field(unsigned int, max_streams) - __field(unsigned int, maxburst) + __field(u32, edw3) + __field(u32, edw1) + __field(u32, edw2) __field(unsigned int, flags) __field(unsigned int, direction) __field(u8, trb_enqueue) __field(u8, trb_dequeue) ), TP_fast_assign( - __assign_str(name, dep->name); - __entry->maxpacket = dep->endpoint.maxpacket; - __entry->maxpacket_limit = dep->endpoint.maxpacket_limit; - __entry->max_streams = dep->endpoint.max_streams; - __entry->maxburst = dep->endpoint.maxburst; + __entry->edw3 = dep->endpoint.dw3; + __entry->edw1 = dep->endpoint.dw1; + __entry->edw2 = dep->endpoint.dw2; __entry->flags = dep->flags; __entry->direction = dep->direction; __entry->trb_enqueue = dep->trb_enqueue; __entry->trb_dequeue = dep->trb_dequeue; ), TP_printk("%s: mps %d/%d streams %d burst %d ring %d/%d flags %c:%c%c%c%c:%c", - __get_str(name), __entry->maxpacket, - __entry->maxpacket_limit, __entry->max_streams, - __entry->maxburst, __entry->trb_enqueue, + USB_EP_NAME(__entry->edw3), USB_EP_MAXPACKET(__entry->edw1), + USB_EP_MAXPACKET_LIMIT(__entry->edw1), USB_EP_MAX_STREAMS(__entry->edw2), + USB_EP_MAXBURST(__entry->edw2), __entry->trb_enqueue, __entry->trb_dequeue, __entry->flags & DWC3_EP_ENABLED ? 'E' : 'e', __entry->flags & DWC3_EP_STALL ? 'S' : 's', From patchwork Tue Sep 12 10:44:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linyu Yuan X-Patchwork-Id: 722095 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E13DCA0EC3 for ; Tue, 12 Sep 2023 10:48:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234439AbjILKsX (ORCPT ); Tue, 12 Sep 2023 06:48:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234433AbjILKrv (ORCPT ); Tue, 12 Sep 2023 06:47:51 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7538F1 for ; Tue, 12 Sep 2023 03:46:48 -0700 (PDT) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38C8ojYj004676; Tue, 12 Sep 2023 10:46:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=Wd+mGRly5P+fr5HdxoACpJxaYPxAgV58A9ajTCceOYk=; b=S3GrslUBB7nIktJM6MVwDrQ5YUWztGpt1M0FgtIbr7b+hvUNRn1OBnPhTKGySEL2sQeU iEerxpv/JVBAV+e0Ylg6ZbHBGtI/cbu5BBs7/SHhs2OGkhqqfUhh96Z8sul9LTXu7C2W mYc9uInjTAV72l87ClrdUYLBVow7uiviull1CdphCUd+6JfPk+rCbFhUGIwZ6J4qPIOB DmzdMOTSm2DQOECvh1bqVy+/J4wRffn+6vHpdxV5JTj4fXtmiJkEnhNW70DKN3o9jfCm 5+buSitjLs4tHtkAEnaw6IpZVgN50u/km+GcXLCqBiHxVjYHs9RmI7A11sVtbYZfFOMu JA== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3t1xkju663-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 Sep 2023 10:46:10 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 38CAk83u028720 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 Sep 2023 10:46:08 GMT Received: from linyyuan-gv.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.36; Tue, 12 Sep 2023 03:46:01 -0700 From: Linyu Yuan To: Thinh Nguyen , Peter Chen , Pawel Laszczak , Roger Quadros , Linus Walleij , Chunfeng Yun , Neal Liu , "Cristian Birsan" , Bin Liu , "Kevin Cernekee" , Justin Chen , "Al Cooper" , Li Yang , "Vladimir Zapolskiy" , Daniel Mack , Haojian Zhuang , Robert Jarzmik , "Philipp Zabel" , Herve Codina , hierry Reding , Jonathan Hunter , Michal Simek , Rui Miguel Silva , Valentina Manea , "Shuah Khan" , Hongren Zheng , Greg Kroah-Hartman CC: , Linyu Yuan Subject: [PATCH v3 08/10] usb: cdns2: trace: reduce buffer usage of trace event Date: Tue, 12 Sep 2023 18:44:53 +0800 Message-ID: <20230912104455.7737-9-quic_linyyuan@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230912104455.7737-1-quic_linyyuan@quicinc.com> References: <20230912104455.7737-1-quic_linyyuan@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: iPEvMwlXNUADmlq0BYzkuCpW6C0omZU- X-Proofpoint-ORIG-GUID: iPEvMwlXNUADmlq0BYzkuCpW6C0omZU- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-12_08,2023-09-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 suspectscore=0 phishscore=0 spamscore=0 lowpriorityscore=0 bulkscore=0 adultscore=0 malwarescore=0 mlxlogscore=562 mlxscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309120090 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Save u32 members into trace event ring buffer and parse it for possible bit information. Signed-off-by: Linyu Yuan --- v2: no change v3: no change drivers/usb/gadget/udc/cdns2/cdns2-trace.h | 77 ++++++++++------------ 1 file changed, 35 insertions(+), 42 deletions(-) diff --git a/drivers/usb/gadget/udc/cdns2/cdns2-trace.h b/drivers/usb/gadget/udc/cdns2/cdns2-trace.h index 61f241634ea5..23d15597dbaa 100644 --- a/drivers/usb/gadget/udc/cdns2/cdns2-trace.h +++ b/drivers/usb/gadget/udc/cdns2/cdns2-trace.h @@ -98,46 +98,45 @@ TRACE_EVENT(cdns2_ep_halt, TP_PROTO(struct cdns2_endpoint *ep_priv, u8 halt, u8 flush), TP_ARGS(ep_priv, halt, flush), TP_STRUCT__entry( - __string(name, ep_priv->name) + __field(u32, edw3) __field(u8, halt) __field(u8, flush) ), TP_fast_assign( - __assign_str(name, ep_priv->name); + __entry->edw3 = ep_priv->endpoint.dw3; __entry->halt = halt; __entry->flush = flush; ), TP_printk("Halt %s for %s: %s", __entry->flush ? " and flush" : "", - __get_str(name), __entry->halt ? "set" : "cleared") + USB_EP_NAME(__entry->edw3), __entry->halt ? "set" : "cleared") ); TRACE_EVENT(cdns2_wa1, TP_PROTO(struct cdns2_endpoint *ep_priv, char *msg), TP_ARGS(ep_priv, msg), TP_STRUCT__entry( - __string(ep_name, ep_priv->name) + __field(u32, edw3) __string(msg, msg) ), TP_fast_assign( - __assign_str(ep_name, ep_priv->name); + __entry->edw3 = ep_priv->endpoint.dw3; __assign_str(msg, msg); ), - TP_printk("WA1: %s %s", __get_str(ep_name), __get_str(msg)) + TP_printk("WA1: %s %s", USB_EP_NAME(__entry->edw3), __get_str(msg)) ); DECLARE_EVENT_CLASS(cdns2_log_doorbell, TP_PROTO(struct cdns2_endpoint *pep, u32 ep_trbaddr), TP_ARGS(pep, ep_trbaddr), TP_STRUCT__entry( - __string(name, pep->num ? pep->name : - (pep->dir ? "ep0in" : "ep0out")) + __field(u32, edw3) __field(u32, ep_trbaddr) ), TP_fast_assign( - __assign_str(name, pep->name); + __entry->edw3 = pep->endpoint.dw3; __entry->ep_trbaddr = ep_trbaddr; ), - TP_printk("%s, ep_trbaddr %08x", __get_str(name), + TP_printk("%s, ep_trbaddr %08x", USB_EP_NAME(__entry->edw3), __entry->ep_trbaddr) ); @@ -190,20 +189,20 @@ DECLARE_EVENT_CLASS(cdns2_log_epx_irq, TP_PROTO(struct cdns2_device *pdev, struct cdns2_endpoint *pep), TP_ARGS(pdev, pep), TP_STRUCT__entry( - __string(ep_name, pep->name) + __field(u32, edw3) __field(u32, ep_sts) __field(u32, ep_ists) __field(u32, ep_traddr) ), TP_fast_assign( - __assign_str(ep_name, pep->name); + __entry->edw3 = pep->endpoint.dw3; __entry->ep_sts = readl(&pdev->adma_regs->ep_sts); __entry->ep_ists = readl(&pdev->adma_regs->ep_ists); __entry->ep_traddr = readl(&pdev->adma_regs->ep_traddr); ), TP_printk("%s, ep_traddr: %08x", cdns2_decode_epx_irq(__get_buf(CDNS2_MSG_MAX), CDNS2_MSG_MAX, - __get_str(ep_name), + USB_EP_NAME(__entry->edw3), __entry->ep_ists, __entry->ep_sts), __entry->ep_traddr) ); @@ -270,7 +269,7 @@ DECLARE_EVENT_CLASS(cdns2_log_request, TP_PROTO(struct cdns2_request *preq), TP_ARGS(preq), TP_STRUCT__entry( - __string(name, preq->pep->name) + __field(u32, edw3) __field(struct usb_request *, request) __field(struct cdns2_request *, preq) __field(void *, buf) @@ -278,9 +277,7 @@ DECLARE_EVENT_CLASS(cdns2_log_request, __field(unsigned int, length) __field(int, status) __field(dma_addr_t, dma) - __field(int, zero) - __field(int, short_not_ok) - __field(int, no_interrupt) + __field(u32, rdw1) __field(struct scatterlist*, sg) __field(unsigned int, num_sgs) __field(unsigned int, num_mapped_sgs) @@ -288,7 +285,7 @@ DECLARE_EVENT_CLASS(cdns2_log_request, __field(int, end_trb) ), TP_fast_assign( - __assign_str(name, preq->pep->name); + __entry->edw3 = preq->pep->endpoint.dw3; __entry->request = &preq->request; __entry->preq = preq; __entry->buf = preq->request.buf; @@ -296,9 +293,7 @@ DECLARE_EVENT_CLASS(cdns2_log_request, __entry->length = preq->request.length; __entry->status = preq->request.status; __entry->dma = preq->request.dma; - __entry->zero = preq->request.zero; - __entry->short_not_ok = preq->request.short_not_ok; - __entry->no_interrupt = preq->request.no_interrupt; + __entry->rdw1 = preq->request.dw1; __entry->sg = preq->request.sg; __entry->num_sgs = preq->request.num_sgs; __entry->num_mapped_sgs = preq->request.num_mapped_sgs; @@ -308,12 +303,12 @@ DECLARE_EVENT_CLASS(cdns2_log_request, TP_printk("%s: req: %p, preq: %p, req buf: %p, length: %u/%u, status: %d," "buf dma: (%pad), %s%s%s, sg: %p, num_sgs: %d, num_m_sgs: %d," "trb: [start: %d, end: %d]", - __get_str(name), __entry->request, __entry->preq, + USB_EP_NAME(__entry->edw3), __entry->request, __entry->preq, __entry->buf, __entry->actual, __entry->length, __entry->status, &__entry->dma, - __entry->zero ? "Z" : "z", - __entry->short_not_ok ? "S" : "s", - __entry->no_interrupt ? "I" : "i", + USB_REQ_ZERO(__entry->rdw1) ? "Z" : "z", + USB_REQ_SHORT_NOT_OK(__entry->rdw1) ? "S" : "s", + USB_REQ_NO_INTERRUPT(__entry->rdw1) ? "I" : "i", __entry->sg, __entry->num_sgs, __entry->num_mapped_sgs, __entry->start_trb, __entry->end_trb @@ -374,19 +369,19 @@ DECLARE_EVENT_CLASS(cdns2_log_map_request, TP_PROTO(struct cdns2_request *priv_req), TP_ARGS(priv_req), TP_STRUCT__entry( - __string(name, priv_req->pep->name) + __field(u32, edw3) __field(struct usb_request *, req) __field(void *, buf) __field(dma_addr_t, dma) ), TP_fast_assign( - __assign_str(name, priv_req->pep->name); + __entry->edw3 = priv_req->pep->endpoint.dw3; __entry->req = &priv_req->request; __entry->buf = priv_req->request.buf; __entry->dma = priv_req->request.dma; ), TP_printk("%s: req: %p, req buf %p, dma %p", - __get_str(name), __entry->req, __entry->buf, &__entry->dma + USB_EP_NAME(__entry->edw3), __entry->req, __entry->buf, &__entry->dma ) ); @@ -403,7 +398,7 @@ DECLARE_EVENT_CLASS(cdns2_log_trb, TP_PROTO(struct cdns2_endpoint *pep, struct cdns2_trb *trb), TP_ARGS(pep, trb), TP_STRUCT__entry( - __string(name, pep->name) + __field(u32, edw3) __field(struct cdns2_trb *, trb) __field(u32, buffer) __field(u32, length) @@ -411,7 +406,7 @@ DECLARE_EVENT_CLASS(cdns2_log_trb, __field(u32, type) ), TP_fast_assign( - __assign_str(name, pep->name); + __entry->edw3 = pep->endpoint.dw3; __entry->trb = trb; __entry->buffer = le32_to_cpu(trb->buffer); __entry->length = le32_to_cpu(trb->length); @@ -419,7 +414,7 @@ DECLARE_EVENT_CLASS(cdns2_log_trb, __entry->type = usb_endpoint_type(pep->endpoint.desc); ), TP_printk("%s: trb V: %p, dma buf: P: 0x%08x, %s", - __get_str(name), __entry->trb, __entry->buffer, + USB_EP_NAME(__entry->edw3), __entry->trb, __entry->buffer, cdns2_decode_trb(__get_buf(CDNS2_MSG_MAX), CDNS2_MSG_MAX, __entry->control, __entry->length, __entry->buffer)) @@ -467,18 +462,16 @@ DECLARE_EVENT_CLASS(cdns2_log_ep, TP_PROTO(struct cdns2_endpoint *pep), TP_ARGS(pep), TP_STRUCT__entry( - __string(name, pep->name) - __field(unsigned int, maxpacket) - __field(unsigned int, maxpacket_limit) + __field(u32, edw3) + __field(u32, edw1) __field(unsigned int, flags) __field(unsigned int, dir) __field(u8, enqueue) __field(u8, dequeue) ), TP_fast_assign( - __assign_str(name, pep->name); - __entry->maxpacket = pep->endpoint.maxpacket; - __entry->maxpacket_limit = pep->endpoint.maxpacket_limit; + __entry->edw3 = pep->endpoint.dw3; + __entry->edw1 = pep->endpoint.dw1; __entry->flags = pep->ep_state; __entry->dir = pep->dir; __entry->enqueue = pep->ring.enqueue; @@ -486,8 +479,8 @@ DECLARE_EVENT_CLASS(cdns2_log_ep, ), TP_printk("%s: mps: %d/%d, enq idx: %d, deq idx: %d, " "flags: %s%s%s%s, dir: %s", - __get_str(name), __entry->maxpacket, - __entry->maxpacket_limit, __entry->enqueue, + USB_EP_NAME(__entry->edw3), USB_EP_MAXPACKET(__entry->edw1), + USB_EP_MAXPACKET_LIMIT(__entry->edw1), __entry->enqueue, __entry->dequeue, __entry->flags & EP_ENABLED ? "EN | " : "", __entry->flags & EP_STALLED ? "STALLED | " : "", @@ -559,7 +552,7 @@ DECLARE_EVENT_CLASS(cdns2_log_epx_reg_config, TP_PROTO(struct cdns2_device *pdev, struct cdns2_endpoint *pep), TP_ARGS(pdev, pep), TP_STRUCT__entry( - __string(ep_name, pep->name) + __field(u32, edw3) __field(u8, burst_size) __field(__le16, maxpack_reg) __field(__u8, con_reg) @@ -568,7 +561,7 @@ DECLARE_EVENT_CLASS(cdns2_log_epx_reg_config, __field(u32, ep_cfg_reg) ), TP_fast_assign( - __assign_str(ep_name, pep->name); + __entry->edw3 = pep->endpoint.dw3; __entry->burst_size = pep->trb_burst_size; __entry->maxpack_reg = pep->dir ? readw(&pdev->epx_regs->txmaxpack[pep->num - 1]) : readw(&pdev->epx_regs->rxmaxpack[pep->num - 1]); @@ -581,7 +574,7 @@ DECLARE_EVENT_CLASS(cdns2_log_epx_reg_config, TP_printk("%s, maxpack: %d, con: %02x, dma_ep_sel: %08x, dma_ep_sts_en: %08x" " dma_ep_cfg %08x", - __get_str(ep_name), __entry->maxpack_reg, __entry->con_reg, + USB_EP_NAME(__entry->edw3), __entry->maxpack_reg, __entry->con_reg, __entry->ep_sel_reg, __entry->ep_sts_en_reg, __entry->ep_cfg_reg )