From patchwork Tue Aug 24 03:54:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linyu Yuan X-Patchwork-Id: 12453893 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22710C4338F for ; Tue, 24 Aug 2021 03:55:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 032A161058 for ; Tue, 24 Aug 2021 03:55:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234148AbhHXD4E (ORCPT ); Mon, 23 Aug 2021 23:56:04 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:2083 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234052AbhHXDzw (ORCPT ); Mon, 23 Aug 2021 23:55:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1629777309; x=1661313309; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dwR9OjbcqpBXAJOeXbmWqMiNdG11O0SRU1WSEq1kSMQ=; b=feemfcxQds25ZfbY45PSz7MLuaHMqAAyVjioL1n6oQRpI3D8c4BxM5DN XFCye4ftzvgWlfNLKaUl/zq6NKNj274xbbbBqf/s04hx0gWkeyIMz+YYf +FGU4s8rPqPSUes/6GAiYly+ipS/7SByKUhyxSh3pYhVlHScRb7sC/RDL Y=; Received: from ironmsg09-lv.qualcomm.com ([10.47.202.153]) by alexa-out.qualcomm.com with ESMTP; 23 Aug 2021 20:55:09 -0700 X-QCInternal: smtphost Received: from nalasex01a.na.qualcomm.com ([10.47.209.196]) by ironmsg09-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2021 20:55:08 -0700 Received: from linyyuan-gv.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.922.7; Mon, 23 Aug 2021 20:55:06 -0700 From: Linyu Yuan To: Felipe Balbi , Greg Kroah-Hartman CC: , Linyu Yuan Subject: [PATCH V4 1/3] usb: gadget: configfs: add UDC trace entry Date: Tue, 24 Aug 2021 11:54:39 +0800 Message-ID: <1629777281-30188-2-git-send-email-quic_linyyuan@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1629777281-30188-1-git-send-email-quic_linyyuan@quicinc.com> References: <1629777281-30188-1-git-send-email-quic_linyyuan@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanexm03h.na.qualcomm.com (10.85.0.50) To nalasex01a.na.qualcomm.com (10.47.209.196) Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org add trace in function gadget_dev_desc_UDC_store() will show when user space enable/disable the gadget. Signed-off-by: Linyu Yuan --- drivers/usb/gadget/Makefile | 1 + drivers/usb/gadget/configfs.c | 3 +++ drivers/usb/gadget/configfs_trace.c | 7 +++++++ drivers/usb/gadget/configfs_trace.h | 39 +++++++++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 drivers/usb/gadget/configfs_trace.c create mode 100644 drivers/usb/gadget/configfs_trace.h diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile index 130dad7..8e9c2b8 100644 --- a/drivers/usb/gadget/Makefile +++ b/drivers/usb/gadget/Makefile @@ -9,5 +9,6 @@ ccflags-y += -I$(srctree)/drivers/usb/gadget/udc obj-$(CONFIG_USB_LIBCOMPOSITE) += libcomposite.o libcomposite-y := usbstring.o config.o epautoconf.o libcomposite-y += composite.o functions.o configfs.o u_f.o +libcomposite-y += configfs_trace.o obj-$(CONFIG_USB_GADGET) += udc/ function/ legacy/ diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c index 477e72a..f7f3af8 100644 --- a/drivers/usb/gadget/configfs.c +++ b/drivers/usb/gadget/configfs.c @@ -9,6 +9,7 @@ #include "configfs.h" #include "u_f.h" #include "u_os_desc.h" +#include "configfs_trace.h" int check_user_usb_string(const char *name, struct usb_gadget_strings *stringtab_dev) @@ -270,6 +271,8 @@ static ssize_t gadget_dev_desc_UDC_store(struct config_item *item, if (name[len - 1] == '\n') name[len - 1] = '\0'; + trace_gadget_dev_desc_UDC_store(config_item_name(item), name); + mutex_lock(&gi->lock); if (!strlen(name)) { diff --git a/drivers/usb/gadget/configfs_trace.c b/drivers/usb/gadget/configfs_trace.c new file mode 100644 index 0000000..b74ff21 --- /dev/null +++ b/drivers/usb/gadget/configfs_trace.c @@ -0,0 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved. + */ + +#define CREATE_TRACE_POINTS +#include "configfs_trace.h" diff --git a/drivers/usb/gadget/configfs_trace.h b/drivers/usb/gadget/configfs_trace.h new file mode 100644 index 0000000..f2e17e4 --- /dev/null +++ b/drivers/usb/gadget/configfs_trace.h @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved. + */ + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM configfs_gadget + +#if !defined(__GADGET_TRACE_H) || defined(TRACE_HEADER_MULTI_READ) +#define __GADGET_TRACE_H + +#include + +TRACE_EVENT(gadget_dev_desc_UDC_store, + TP_PROTO(char *name, char *udc), + TP_ARGS(name, udc), + TP_STRUCT__entry( + __string(group_name, name) + __string(udc_name, udc) + ), + TP_fast_assign( + __assign_str(group_name, name); + __assign_str(udc_name, udc); + ), + TP_printk("gadget:%s UDC:%s", __get_str(group_name), + __get_str(udc_name)) +); + +#endif /* __GADGET_TRACE_H */ + +/* this part has to be here */ + +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH ../../drivers/usb/gadget + +#undef TRACE_INCLUDE_FILE +#define TRACE_INCLUDE_FILE configfs_trace + +#include From patchwork Tue Aug 24 03:54:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linyu Yuan X-Patchwork-Id: 12453895 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4FEBBC4338F for ; Tue, 24 Aug 2021 03:55:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 35A1361058 for ; Tue, 24 Aug 2021 03:55:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234374AbhHXD4L (ORCPT ); Mon, 23 Aug 2021 23:56:11 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:65129 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234127AbhHXDz4 (ORCPT ); Mon, 23 Aug 2021 23:55:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1629777313; x=1661313313; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NXGWrHEYB4sSzdu9YW922C7tszszO+TjV0An8VGqRNg=; b=NL+QUCtc9B5y1XV1/cgNAQK9fBHNiOFK//XWG/vG8QE62xrDvAM1JOEo ydrcOSRVVYVA8RSU8mQyDkPttrgbtFAly3naT2Tn+VysFatnY7S07vg6W Uc6aiSBnhPc2SRkG0O1qRtDigKHl2jvZd2cK/SgqUz7cZU+3iqgeSCAVT 0=; Received: from ironmsg09-lv.qualcomm.com ([10.47.202.153]) by alexa-out.qualcomm.com with ESMTP; 23 Aug 2021 20:55:12 -0700 X-QCInternal: smtphost Received: from nalasex01a.na.qualcomm.com ([10.47.209.196]) by ironmsg09-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2021 20:55:13 -0700 Received: from linyyuan-gv.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.922.7; Mon, 23 Aug 2021 20:55:11 -0700 From: Linyu Yuan To: Felipe Balbi , Greg Kroah-Hartman CC: , Linyu Yuan Subject: [PATCH V4 2/3] usb: gadget: configfs: add function link trace entry Date: Tue, 24 Aug 2021 11:54:40 +0800 Message-ID: <1629777281-30188-3-git-send-email-quic_linyyuan@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1629777281-30188-1-git-send-email-quic_linyyuan@quicinc.com> References: <1629777281-30188-1-git-send-email-quic_linyyuan@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanexm03h.na.qualcomm.com (10.85.0.50) To nalasex01a.na.qualcomm.com (10.47.209.196) Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org add trace in function config_usb_cfg_link() will show which function was added to gadget configuration. Signed-off-by: Linyu Yuan --- drivers/usb/gadget/configfs.c | 4 ++++ drivers/usb/gadget/configfs_trace.h | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c index f7f3af8..8c64640 100644 --- a/drivers/usb/gadget/configfs.c +++ b/drivers/usb/gadget/configfs.c @@ -426,6 +426,10 @@ static int config_usb_cfg_link( struct usb_function *f; int ret; + trace_config_usb_cfg_link(config_item_name(&gi->group.cg_item), + config_item_name(usb_cfg_ci), + config_item_name(usb_func_ci)); + mutex_lock(&gi->lock); /* * Make sure this function is from within our _this_ gadget and not diff --git a/drivers/usb/gadget/configfs_trace.h b/drivers/usb/gadget/configfs_trace.h index f2e17e4..5c666f1 100644 --- a/drivers/usb/gadget/configfs_trace.h +++ b/drivers/usb/gadget/configfs_trace.h @@ -26,6 +26,23 @@ TRACE_EVENT(gadget_dev_desc_UDC_store, __get_str(udc_name)) ); +TRACE_EVENT(config_usb_cfg_link, + TP_PROTO(char *name, char *cfg, char *func), + TP_ARGS(name, cfg, func), + TP_STRUCT__entry( + __string(group_name, name) + __string(cfg_name, cfg) + __string(func_name, func) + ), + TP_fast_assign( + __assign_str(group_name, name); + __assign_str(cfg_name, cfg); + __assign_str(func_name, func) + ), + TP_printk("gadget:%s cfg:%s link func:%s", __get_str(group_name), + __get_str(cfg_name), __get_str(func_name)) +); + #endif /* __GADGET_TRACE_H */ /* this part has to be here */ From patchwork Tue Aug 24 03:54:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linyu Yuan X-Patchwork-Id: 12453897 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EE4EC4338F for ; Tue, 24 Aug 2021 03:55:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 32C8B61058 for ; Tue, 24 Aug 2021 03:55:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234329AbhHXD4P (ORCPT ); Mon, 23 Aug 2021 23:56:15 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:65129 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234205AbhHXD4B (ORCPT ); Mon, 23 Aug 2021 23:56:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1629777318; x=1661313318; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ql9IFwzvmcGkbx7Q4DxwFRBpOLSH4M13mtKUGEsC2Go=; b=HzydB3ltH+DZ9VK//D7D7xW8CWi/9CnT2ESUyqDlspF67cw7AOa0BzCN VZiCQISMofoG65amP/V3uHYUe80IcKkmWzlpScBMoKnYe7X1k9TGzgolz CnMb50+GY7m84LS9XCstfXODQeW2RaKb8GpDE5qyGhaISDaq5jCDZ+HbU s=; Received: from ironmsg08-lv.qualcomm.com ([10.47.202.152]) by alexa-out.qualcomm.com with ESMTP; 23 Aug 2021 20:55:17 -0700 X-QCInternal: smtphost Received: from nalasex01a.na.qualcomm.com ([10.47.209.196]) by ironmsg08-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2021 20:55:17 -0700 Received: from linyyuan-gv.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.922.7; Mon, 23 Aug 2021 20:55:15 -0700 From: Linyu Yuan To: Felipe Balbi , Greg Kroah-Hartman CC: , Linyu Yuan Subject: [PATCH V4 3/3] usb: gadget: configfs: add function unlink trace entry Date: Tue, 24 Aug 2021 11:54:41 +0800 Message-ID: <1629777281-30188-4-git-send-email-quic_linyyuan@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1629777281-30188-1-git-send-email-quic_linyyuan@quicinc.com> References: <1629777281-30188-1-git-send-email-quic_linyyuan@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanexm03h.na.qualcomm.com (10.85.0.50) To nalasex01a.na.qualcomm.com (10.47.209.196) Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org add trace in function config_usb_cfg_unlink() whill show which function was removed from gadget configuraion. Signed-off-by: Linyu Yuan --- drivers/usb/gadget/configfs.c | 4 ++++ drivers/usb/gadget/configfs_trace.h | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c index 8c64640..4024f9b 100644 --- a/drivers/usb/gadget/configfs.c +++ b/drivers/usb/gadget/configfs.c @@ -479,6 +479,10 @@ static void config_usb_cfg_unlink( struct usb_function_instance, group); struct usb_function *f; + trace_config_usb_cfg_unlink(config_item_name(&gi->group.cg_item), + config_item_name(usb_cfg_ci), + config_item_name(usb_func_ci)); + /* * ideally I would like to forbid to unlink functions while a gadget is * bound to an UDC. Since this isn't possible at the moment, we simply diff --git a/drivers/usb/gadget/configfs_trace.h b/drivers/usb/gadget/configfs_trace.h index 5c666f1..82e0121 100644 --- a/drivers/usb/gadget/configfs_trace.h +++ b/drivers/usb/gadget/configfs_trace.h @@ -43,6 +43,23 @@ TRACE_EVENT(config_usb_cfg_link, __get_str(cfg_name), __get_str(func_name)) ); +TRACE_EVENT(config_usb_cfg_unlink, + TP_PROTO(char *name, char *cfg, char *func), + TP_ARGS(name, cfg, func), + TP_STRUCT__entry( + __string(group_name, name) + __string(cfg_name, cfg) + __string(func_name, func) + ), + TP_fast_assign( + __assign_str(group_name, name); + __assign_str(cfg_name, cfg); + __assign_str(func_name, func) + ), + TP_printk("gadget:%s cfg:%s unlink func:%s", __get_str(group_name), + __get_str(cfg_name), __get_str(func_name)) +); + #endif /* __GADGET_TRACE_H */ /* this part has to be here */