From patchwork Sun Nov 28 12:38:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Ryazanov X-Patchwork-Id: 12642865 X-Patchwork-Delegate: kuba@kernel.org 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 8A8F0C433EF for ; Sun, 28 Nov 2021 12:41:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357622AbhK1Mol (ORCPT ); Sun, 28 Nov 2021 07:44:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357425AbhK1Mml (ORCPT ); Sun, 28 Nov 2021 07:42:41 -0500 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91EFFC061761 for ; Sun, 28 Nov 2021 04:38:48 -0800 (PST) Received: by mail-lj1-x229.google.com with SMTP id l7so28935820lja.2 for ; Sun, 28 Nov 2021 04:38:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lAYjBODWXtYE0eUrwiIG3wvz5YgUWiz/ucehD2kVx78=; b=M9UFVS48INXQTKg7FcmvmIbSjSYsJHpJFXoR3C4klQaTAqrs4K2KB7GORilRtZPR4K 3W43c7yu7Z1G7Wyvj+drqfZaNUxPBzAbIO/f1615ZR/83binANZ7T9vpJO/aBoONYCQK +qmZzbCwZdfZx52dJzrBB/7YiC9Sh0sTSAxJ6RoCKbF7lz1Jm6DY5AcxBdqbLoaTU+5D HK5DC0ag4Gmup4PiOV+nV7n4/sAxuGCunaWNej57ipVGXiJZnYDq4UUf7l7dczr1oiJd d73aGtrGW8sk8vF/s8gXTGkARTcurOA+A79679QAs/gocWjwOGo3M2lfomP6HXiwhaOK qdKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lAYjBODWXtYE0eUrwiIG3wvz5YgUWiz/ucehD2kVx78=; b=b73wf8BrCZGbuJdFnFqpW2lrprqJJo+9kZdGFHTJCBcGOrTCIGNvhiWT8oP3JRDfUZ cfGkNjodGhtV0doF/H6lqCEYhjjGwC1L8QyUxwK9CRH1zYmBVREAMR2ISoH+JL+BR3TX T3ZyIqkWuH+GXpFqtwDgxZGH7MD8UiFLIrp4JPGQXGglKOumbo2QWbg4x9eE9zVKC0eZ 0MhJw4mIT+YhMd8KkTcr3kgJqyhpY2PR99WE0/A+Qr3BU9IeQyQ6LY4QOKntLPFrgvxe dc/DzYIO1shxlXtU6JNKyvvP0ZaIDAHXWiyvyPrcmhRTum97NMIowrZI9Cd1uhBruQ8x lt4w== X-Gm-Message-State: AOAM532NlcCLSRoHhRmKfm8cMlhae4IZ7DKlQNdHE5LIsr/UYcWj7f2Z C0HUkBLAgyPMAE9Mx6eyUtE= X-Google-Smtp-Source: ABdhPJzoxYj27HZ2+Gp7pT5tk/JVfgtmPqmJcOymSjJZXO3LHQ3EPnC8di0XgNvcJ5PYkLNDd2o6CA== X-Received: by 2002:a2e:8753:: with SMTP id q19mr44198168ljj.375.1638103126892; Sun, 28 Nov 2021 04:38:46 -0800 (PST) Received: from rsa-laptop.internal.lan ([217.25.229.52]) by smtp.gmail.com with ESMTPSA id v198sm976533lfa.89.2021.11.28.04.38.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Nov 2021 04:38:46 -0800 (PST) From: Sergey Ryazanov To: "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, M Chetan Kumar , Intel Corporation , Loic Poulain , Johannes Berg Subject: [PATCH 1/5] net: wwan: iosm: consolidate trace port init code Date: Sun, 28 Nov 2021 15:38:33 +0300 Message-Id: <20211128123837.22829-2-ryazanov.s.a@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211128123837.22829-1-ryazanov.s.a@gmail.com> References: <20211128123837.22829-1-ryazanov.s.a@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Move the channel related structures initialization from ipc_imem_channel_init() to ipc_trace_init() and call it directly. On the one hand, this makes the trace port initialization symmetric to the deitialization, that is, it removes the additional wrapper. On the other hand, this change consolidates the trace port related code into a single source file, what facilitates an upcoming disabling of this functionality by a user choise. Signed-off-by: Sergey Ryazanov --- drivers/net/wwan/iosm/iosm_ipc_imem.c | 2 +- drivers/net/wwan/iosm/iosm_ipc_imem_ops.c | 18 ------------------ drivers/net/wwan/iosm/iosm_ipc_imem_ops.h | 2 +- drivers/net/wwan/iosm/iosm_ipc_trace.c | 8 +++++++- 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/drivers/net/wwan/iosm/iosm_ipc_imem.c b/drivers/net/wwan/iosm/iosm_ipc_imem.c index 1be07114c85d..49bdadb855e5 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_imem.c +++ b/drivers/net/wwan/iosm/iosm_ipc_imem.c @@ -554,7 +554,7 @@ static void ipc_imem_run_state_worker(struct work_struct *instance) ctrl_chl_idx++; } - ipc_imem->trace = ipc_imem_trace_channel_init(ipc_imem); + ipc_imem->trace = ipc_trace_init(ipc_imem); if (!ipc_imem->trace) { dev_err(ipc_imem->dev, "trace channel init failed"); return; diff --git a/drivers/net/wwan/iosm/iosm_ipc_imem_ops.c b/drivers/net/wwan/iosm/iosm_ipc_imem_ops.c index 43f1796a8984..d2072a84ab08 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_imem_ops.c +++ b/drivers/net/wwan/iosm/iosm_ipc_imem_ops.c @@ -11,7 +11,6 @@ #include "iosm_ipc_imem_ops.h" #include "iosm_ipc_port.h" #include "iosm_ipc_task_queue.h" -#include "iosm_ipc_trace.h" /* Open a packet data online channel between the network layer and CP. */ int ipc_imem_sys_wwan_open(struct iosm_imem *ipc_imem, int if_id) @@ -108,23 +107,6 @@ void ipc_imem_wwan_channel_init(struct iosm_imem *ipc_imem, "failed to register the ipc_wwan interfaces"); } -/** - * ipc_imem_trace_channel_init - Initializes trace channel. - * @ipc_imem: Pointer to iosm_imem struct. - * - * Returns: Pointer to trace instance on success else NULL - */ -struct iosm_trace *ipc_imem_trace_channel_init(struct iosm_imem *ipc_imem) -{ - struct ipc_chnl_cfg chnl_cfg = { 0 }; - - ipc_chnl_cfg_get(&chnl_cfg, IPC_MEM_CTRL_CHL_ID_3); - ipc_imem_channel_init(ipc_imem, IPC_CTYPE_CTRL, chnl_cfg, - IRQ_MOD_OFF); - - return ipc_trace_init(ipc_imem); -} - /* Map SKB to DMA for transfer */ static int ipc_imem_map_skb_to_dma(struct iosm_imem *ipc_imem, struct sk_buff *skb) diff --git a/drivers/net/wwan/iosm/iosm_ipc_imem_ops.h b/drivers/net/wwan/iosm/iosm_ipc_imem_ops.h index e36ee2782629..f8afb217d9e2 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_imem_ops.h +++ b/drivers/net/wwan/iosm/iosm_ipc_imem_ops.h @@ -141,5 +141,5 @@ int ipc_imem_sys_devlink_read(struct iosm_devlink *ipc_devlink, u8 *data, */ int ipc_imem_sys_devlink_write(struct iosm_devlink *ipc_devlink, unsigned char *buf, int count); -struct iosm_trace *ipc_imem_trace_channel_init(struct iosm_imem *ipc_imem); + #endif diff --git a/drivers/net/wwan/iosm/iosm_ipc_trace.c b/drivers/net/wwan/iosm/iosm_ipc_trace.c index c5fa12599c2b..5f5cfd39bede 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_trace.c +++ b/drivers/net/wwan/iosm/iosm_ipc_trace.c @@ -132,9 +132,15 @@ static const struct file_operations ipc_trace_fops = { */ struct iosm_trace *ipc_trace_init(struct iosm_imem *ipc_imem) { - struct iosm_trace *ipc_trace = kzalloc(sizeof(*ipc_trace), GFP_KERNEL); + struct ipc_chnl_cfg chnl_cfg = { 0 }; + struct iosm_trace *ipc_trace; struct dentry *debugfs_pdev; + ipc_chnl_cfg_get(&chnl_cfg, IPC_MEM_CTRL_CHL_ID_3); + ipc_imem_channel_init(ipc_imem, IPC_CTYPE_CTRL, chnl_cfg, + IRQ_MOD_OFF); + + ipc_trace = kzalloc(sizeof(*ipc_trace), GFP_KERNEL); if (!ipc_trace) return NULL; From patchwork Sun Nov 28 12:38:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Ryazanov X-Patchwork-Id: 12642875 X-Patchwork-Delegate: kuba@kernel.org 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 29ECDC433F5 for ; Sun, 28 Nov 2021 12:41:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357637AbhK1Mor (ORCPT ); Sun, 28 Nov 2021 07:44:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357446AbhK1Mmp (ORCPT ); Sun, 28 Nov 2021 07:42:45 -0500 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92802C061763 for ; Sun, 28 Nov 2021 04:38:49 -0800 (PST) Received: by mail-lf1-x12a.google.com with SMTP id m27so37015395lfj.12 for ; Sun, 28 Nov 2021 04:38:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MGJnwlQPpiNh66b9SCMbW7HB4dAqYbf0gLkVpa0vFto=; b=obA7XDn85RpbIt1jBiGBdrsWsaBUNCKRKNVSF0oqOIw/OS0eTxpDYlHXmW4eTSftrC o53R2ztL5DGbxQYekxwoAM87z1prwiP9XH5hfBJ3jiEk6oIXQbHb1iF9D7bceDEjYU5H kiziM+9sMnBuQ/11ygZ/FPQ8Lqo00AGLbvZKtESY/Ha32cSipdoF5EMMDTkxQfoMtMUK MJ3Beg5eId81sCXY4utsY47JcvBscPPjZ+YhqietAaBmEzujzMPuwSJfkRbD9fvv4bEs GhLdmqXsYkawL/fGdfEHxOe4ufnm1wPr5o/Y/QtRH/l93hDef7BaoyNpO1jsNUWhNRo2 BHfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MGJnwlQPpiNh66b9SCMbW7HB4dAqYbf0gLkVpa0vFto=; b=y9cl/Hw7Kq5tAhqr6Rn24NY4P0pcCWk4YdAj5TgV1QN6herVY9e76SRWnRNq0nHRqd 8T2bhpS+VzD031Egrzozb0zPc+tone7gMvmis/fvXrkp7+PfrBKOcNuphRu6hWktKRuF FgYDWWkuWDfzPZww8OCrEiPw321KiUihSEw4M+FyAVcN8WJihMgG4NN47p3MrDsiuXVH 7X/8WeFULL/7ACAepi+YvuPbsbABHdeokmaiCeQc3RhdyeTJkU126KksDnZ4YC82A+j0 dZcQ7DQrQ0j/AfXi9tvjgYmctqTdDe1q0p0RUL7mylGPFIOgmeOSDgSOnBj8zJvNh+QW 76DQ== X-Gm-Message-State: AOAM530jm8dZh3KcKTpwBtEtV1EcgjPBYP3bwBShvYRqEHXrJ1hW1Wt6 Bj1dzs07r/PCmICvXXwcFsU= X-Google-Smtp-Source: ABdhPJyKtOoP0146KfaPiZ6L6qKHzkjN5BatT7HusqKHLZOnOIlglViYhBKZzT3+RG+MuiOdf5G3wA== X-Received: by 2002:a05:6512:1313:: with SMTP id x19mr22092679lfu.279.1638103127878; Sun, 28 Nov 2021 04:38:47 -0800 (PST) Received: from rsa-laptop.internal.lan ([217.25.229.52]) by smtp.gmail.com with ESMTPSA id v198sm976533lfa.89.2021.11.28.04.38.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Nov 2021 04:38:47 -0800 (PST) From: Sergey Ryazanov To: "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, M Chetan Kumar , Intel Corporation , Loic Poulain , Johannes Berg Subject: [PATCH 2/5] net: wwan: iosm: allow trace port be uninitialized Date: Sun, 28 Nov 2021 15:38:34 +0300 Message-Id: <20211128123837.22829-3-ryazanov.s.a@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211128123837.22829-1-ryazanov.s.a@gmail.com> References: <20211128123837.22829-1-ryazanov.s.a@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Collecting modem firmware traces is optional for the regular modem use. There are not many reasons for aborting device initialization due to an inability to initialize the trace port and (or) its debugfs interface. So, demote the initialization failure erro message into a warning and do not break the initialization sequence in this case. Rework packet processing and deinitialization so that they do not crash in case of uninitialized trace port. This change is mainly a preparation for an upcoming configuration option introduction that will help disable driver debugfs functionality. Signed-off-by: Sergey Ryazanov --- drivers/net/wwan/iosm/iosm_ipc_imem.c | 8 +++----- drivers/net/wwan/iosm/iosm_ipc_trace.c | 3 +++ drivers/net/wwan/iosm/iosm_ipc_trace.h | 5 +++++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/net/wwan/iosm/iosm_ipc_imem.c b/drivers/net/wwan/iosm/iosm_ipc_imem.c index 49bdadb855e5..a60b93cefd2e 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_imem.c +++ b/drivers/net/wwan/iosm/iosm_ipc_imem.c @@ -272,7 +272,7 @@ static void ipc_imem_dl_skb_process(struct iosm_imem *ipc_imem, if (port_id == IPC_MEM_CTRL_CHL_ID_7) ipc_imem_sys_devlink_notify_rx(ipc_imem->ipc_devlink, skb); - else if (port_id == ipc_imem->trace->chl_id) + else if (ipc_is_trace_channel(ipc_imem, port_id)) ipc_trace_port_rx(ipc_imem->trace, skb); else wwan_port_rx(ipc_imem->ipc_port[port_id]->iosm_port, @@ -555,10 +555,8 @@ static void ipc_imem_run_state_worker(struct work_struct *instance) } ipc_imem->trace = ipc_trace_init(ipc_imem); - if (!ipc_imem->trace) { - dev_err(ipc_imem->dev, "trace channel init failed"); - return; - } + if (!ipc_imem->trace) + dev_warn(ipc_imem->dev, "trace channel init failed"); ipc_task_queue_send_task(ipc_imem, ipc_imem_send_mdm_rdy_cb, 0, NULL, 0, false); diff --git a/drivers/net/wwan/iosm/iosm_ipc_trace.c b/drivers/net/wwan/iosm/iosm_ipc_trace.c index 5f5cfd39bede..c588a394cd94 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_trace.c +++ b/drivers/net/wwan/iosm/iosm_ipc_trace.c @@ -172,6 +172,9 @@ struct iosm_trace *ipc_trace_init(struct iosm_imem *ipc_imem) */ void ipc_trace_deinit(struct iosm_trace *ipc_trace) { + if (!ipc_trace) + return; + debugfs_remove(ipc_trace->ctrl_file); relay_close(ipc_trace->ipc_rchan); mutex_destroy(&ipc_trace->trc_mutex); diff --git a/drivers/net/wwan/iosm/iosm_ipc_trace.h b/drivers/net/wwan/iosm/iosm_ipc_trace.h index 53346183af9c..419540c91219 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_trace.h +++ b/drivers/net/wwan/iosm/iosm_ipc_trace.h @@ -45,6 +45,11 @@ struct iosm_trace { enum trace_ctrl_mode mode; }; +static inline bool ipc_is_trace_channel(struct iosm_imem *ipc_mem, u16 chl_id) +{ + return ipc_mem->trace && ipc_mem->trace->chl_id == chl_id; +} + struct iosm_trace *ipc_trace_init(struct iosm_imem *ipc_imem); void ipc_trace_deinit(struct iosm_trace *ipc_trace); void ipc_trace_port_rx(struct iosm_trace *ipc_trace, struct sk_buff *skb); From patchwork Sun Nov 28 12:38:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Ryazanov X-Patchwork-Id: 12642869 X-Patchwork-Delegate: kuba@kernel.org 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 1CD36C433EF for ; Sun, 28 Nov 2021 12:41:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357443AbhK1Moq (ORCPT ); Sun, 28 Nov 2021 07:44:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357445AbhK1Mmp (ORCPT ); Sun, 28 Nov 2021 07:42:45 -0500 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C113C0613D7 for ; Sun, 28 Nov 2021 04:38:50 -0800 (PST) Received: by mail-lj1-x230.google.com with SMTP id v15so29068176ljc.0 for ; Sun, 28 Nov 2021 04:38:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=s27J6fDgX0QHTWxUXiBGVD1cv9maHn+rDsd48EIRwRk=; b=jQ4GA0fx05TNYklM8lNnrwjqFQCKt5EqFpf+U3m/tsJkE7vm+Mi9HsIIuDDLhh68/R QDosE/tOUOBEgp0EutI9LMASCMKXSEsJ5WiITnpEYJGjh4z4F/BczoPw3xSXvnx+1ZPB EPuALqv8fQ1mnUD//nnQfZZMtjCNd16X6/K3yUAL/BSLZ372Y5nccbonn7jtOJFSK2rh sZFXH1e5SrdUeG2dHrRC23Or6CrLNG1n6PTVlCSDEGqjf6hQjuQXs7O/m+D0/yb1MM+J 9wGgvuzhHtn2ji3yUvOc8p6MMlRjYU0UoCTlh1z8tXjcSYh/D3MnduuyJYzN+xL0qS4K 6fcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s27J6fDgX0QHTWxUXiBGVD1cv9maHn+rDsd48EIRwRk=; b=FyuCjFK7kHe04OtKENndOsMzTL+id2lx7TT9ussWQTYbkekpP6s0Y7rBdymR39qFpG UDq5fGJwkyLE1xmM+u7CLq9ZF7lyF7GQklwp0Dxp5lkw5x4p64biW/QHIGm4FKIEsM7w 6K9iL2PL7p5h4HSXYZOVND6f4iQ8MkVp8a8BCoywq3OTGIWnD8YKXr9PSH3agB+kbJ1J zVcHaCaXgLQ2lsHWEjr1Usrmk3jkT7B4+bhg66qeyLASECncVX/z7O5kTF6s7d6fGXjQ ai/b3OpwgMuiWZIoV0797ijKFCINABD3U+auzgMNo+t3CJ4UbO/ZQSjs+iKbJs4GJQfj pl4Q== X-Gm-Message-State: AOAM5323KedgWdig0PybAM4qtHhMAQUxRLHoTiD1iG30wSUIYhgiZdWx LcF3wrncJOa6X6NHvDX/q2s= X-Google-Smtp-Source: ABdhPJym1LJSTlySgbDD8TmaUwh9qQe3j2HpzwH3ektjQ793rN68rB2/T0OonWPqSXNwjSD0zCwHVA== X-Received: by 2002:a2e:b541:: with SMTP id a1mr43927642ljn.289.1638103128885; Sun, 28 Nov 2021 04:38:48 -0800 (PST) Received: from rsa-laptop.internal.lan ([217.25.229.52]) by smtp.gmail.com with ESMTPSA id v198sm976533lfa.89.2021.11.28.04.38.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Nov 2021 04:38:48 -0800 (PST) From: Sergey Ryazanov To: "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, M Chetan Kumar , Intel Corporation , Loic Poulain , Johannes Berg Subject: [PATCH 3/5] net: wwan: iosm: move debugfs knobs into a subdir Date: Sun, 28 Nov 2021 15:38:35 +0300 Message-Id: <20211128123837.22829-4-ryazanov.s.a@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211128123837.22829-1-ryazanov.s.a@gmail.com> References: <20211128123837.22829-1-ryazanov.s.a@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The modem traces collection is a device (and so driver) specific option. Therefore, move the related debugfs files into a driver-specific subdirectory under the common per WWAN device directory. Signed-off-by: Sergey Ryazanov --- drivers/net/wwan/iosm/Makefile | 1 + drivers/net/wwan/iosm/iosm_ipc_debugfs.c | 29 ++++++++++++++++++++++++ drivers/net/wwan/iosm/iosm_ipc_debugfs.h | 12 ++++++++++ drivers/net/wwan/iosm/iosm_ipc_imem.c | 7 +++--- drivers/net/wwan/iosm/iosm_ipc_imem.h | 1 + drivers/net/wwan/iosm/iosm_ipc_trace.c | 6 ++--- 6 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 drivers/net/wwan/iosm/iosm_ipc_debugfs.c create mode 100644 drivers/net/wwan/iosm/iosm_ipc_debugfs.h diff --git a/drivers/net/wwan/iosm/Makefile b/drivers/net/wwan/iosm/Makefile index 5c2528beca2a..5091f664af0d 100644 --- a/drivers/net/wwan/iosm/Makefile +++ b/drivers/net/wwan/iosm/Makefile @@ -22,6 +22,7 @@ iosm-y = \ iosm_ipc_devlink.o \ iosm_ipc_flash.o \ iosm_ipc_coredump.o \ + iosm_ipc_debugfs.o \ iosm_ipc_trace.o obj-$(CONFIG_IOSM) := iosm.o diff --git a/drivers/net/wwan/iosm/iosm_ipc_debugfs.c b/drivers/net/wwan/iosm/iosm_ipc_debugfs.c new file mode 100644 index 000000000000..f2f57751a7d2 --- /dev/null +++ b/drivers/net/wwan/iosm/iosm_ipc_debugfs.c @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2020-2021 Intel Corporation. + */ + +#include +#include + +#include "iosm_ipc_imem.h" +#include "iosm_ipc_trace.h" +#include "iosm_ipc_debugfs.h" + +void ipc_debugfs_init(struct iosm_imem *ipc_imem) +{ + struct dentry *debugfs_pdev = wwan_get_debugfs_dir(ipc_imem->dev); + + ipc_imem->debugfs_dir = debugfs_create_dir(KBUILD_MODNAME, + debugfs_pdev); + + ipc_imem->trace = ipc_trace_init(ipc_imem); + if (!ipc_imem->trace) + dev_warn(ipc_imem->dev, "trace channel init failed"); +} + +void ipc_debugfs_deinit(struct iosm_imem *ipc_imem) +{ + ipc_trace_deinit(ipc_imem->trace); + debugfs_remove_recursive(ipc_imem->debugfs_dir); +} diff --git a/drivers/net/wwan/iosm/iosm_ipc_debugfs.h b/drivers/net/wwan/iosm/iosm_ipc_debugfs.h new file mode 100644 index 000000000000..35788039f13f --- /dev/null +++ b/drivers/net/wwan/iosm/iosm_ipc_debugfs.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0-only + * + * Copyright (C) 2020-2021 Intel Corporation. + */ + +#ifndef IOSM_IPC_DEBUGFS_H +#define IOSM_IPC_DEBUGFS_H + +void ipc_debugfs_init(struct iosm_imem *ipc_imem); +void ipc_debugfs_deinit(struct iosm_imem *ipc_imem); + +#endif diff --git a/drivers/net/wwan/iosm/iosm_ipc_imem.c b/drivers/net/wwan/iosm/iosm_ipc_imem.c index a60b93cefd2e..25b889922912 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_imem.c +++ b/drivers/net/wwan/iosm/iosm_ipc_imem.c @@ -11,6 +11,7 @@ #include "iosm_ipc_imem.h" #include "iosm_ipc_port.h" #include "iosm_ipc_trace.h" +#include "iosm_ipc_debugfs.h" /* Check the wwan ips if it is valid with Channel as input. */ static int ipc_imem_check_wwan_ips(struct ipc_mem_channel *chnl) @@ -554,9 +555,7 @@ static void ipc_imem_run_state_worker(struct work_struct *instance) ctrl_chl_idx++; } - ipc_imem->trace = ipc_trace_init(ipc_imem); - if (!ipc_imem->trace) - dev_warn(ipc_imem->dev, "trace channel init failed"); + ipc_debugfs_init(ipc_imem); ipc_task_queue_send_task(ipc_imem, ipc_imem_send_mdm_rdy_cb, 0, NULL, 0, false); @@ -1173,7 +1172,7 @@ void ipc_imem_cleanup(struct iosm_imem *ipc_imem) if (test_and_clear_bit(FULLY_FUNCTIONAL, &ipc_imem->flag)) { ipc_mux_deinit(ipc_imem->mux); - ipc_trace_deinit(ipc_imem->trace); + ipc_debugfs_deinit(ipc_imem); ipc_wwan_deinit(ipc_imem->wwan); ipc_port_deinit(ipc_imem->ipc_port); } diff --git a/drivers/net/wwan/iosm/iosm_ipc_imem.h b/drivers/net/wwan/iosm/iosm_ipc_imem.h index cec38009c44a..df3b471f6fa9 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_imem.h +++ b/drivers/net/wwan/iosm/iosm_ipc_imem.h @@ -380,6 +380,7 @@ struct iosm_imem { ev_mux_net_transmit_pending:1, reset_det_n:1, pcie_wake_n:1; + struct dentry *debugfs_dir; }; /** diff --git a/drivers/net/wwan/iosm/iosm_ipc_trace.c b/drivers/net/wwan/iosm/iosm_ipc_trace.c index c588a394cd94..5243ead90b5f 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_trace.c +++ b/drivers/net/wwan/iosm/iosm_ipc_trace.c @@ -134,7 +134,6 @@ struct iosm_trace *ipc_trace_init(struct iosm_imem *ipc_imem) { struct ipc_chnl_cfg chnl_cfg = { 0 }; struct iosm_trace *ipc_trace; - struct dentry *debugfs_pdev; ipc_chnl_cfg_get(&chnl_cfg, IPC_MEM_CTRL_CHL_ID_3); ipc_imem_channel_init(ipc_imem, IPC_CTYPE_CTRL, chnl_cfg, @@ -150,15 +149,14 @@ struct iosm_trace *ipc_trace_init(struct iosm_imem *ipc_imem) ipc_trace->chl_id = IPC_MEM_CTRL_CHL_ID_3; mutex_init(&ipc_trace->trc_mutex); - debugfs_pdev = wwan_get_debugfs_dir(ipc_imem->dev); ipc_trace->ctrl_file = debugfs_create_file(IOSM_TRC_DEBUGFS_TRACE_CTRL, IOSM_TRC_FILE_PERM, - debugfs_pdev, + ipc_imem->debugfs_dir, ipc_trace, &ipc_trace_fops); ipc_trace->ipc_rchan = relay_open(IOSM_TRC_DEBUGFS_TRACE, - debugfs_pdev, + ipc_imem->debugfs_dir, IOSM_TRC_SUB_BUFF_SIZE, IOSM_TRC_N_SUB_BUFF, &relay_callbacks, NULL); From patchwork Sun Nov 28 12:38:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Ryazanov X-Patchwork-Id: 12642871 X-Patchwork-Delegate: kuba@kernel.org 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 9BC4EC433FE for ; Sun, 28 Nov 2021 12:41:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357636AbhK1Moq (ORCPT ); Sun, 28 Nov 2021 07:44:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357447AbhK1Mmp (ORCPT ); Sun, 28 Nov 2021 07:42:45 -0500 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7679EC0613DD for ; Sun, 28 Nov 2021 04:38:51 -0800 (PST) Received: by mail-lf1-x130.google.com with SMTP id m27so37015492lfj.12 for ; Sun, 28 Nov 2021 04:38:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ut2j330bo/IxIjJswmV42yHAdJERMb8IowsBpx/nbpM=; b=cjoz1i70gY9S/JC5egwxWffZLxYpBHz4+NFebNNvKEqO0NgkZcPicwslSEPTr2KQip ADnMotnwNZhGw/IpWdWtfo3iCFDXDU7iahT8EStWRk+A0WLv6PFW/ldCbd68R+FNuiIR hqcTIQ4UoQsPD9OPwB2/Usk5uPea4xEjgdAvXgf1/XLhQjZoA2ltFLWG1ynx/1FH06e4 CTJzWu4vdYFvpHNffM4cfAM3kUD34TSoiFdDCd0FFQPN51jGs0ah7/bdzCrL96EhEEw9 wZMaEeuFeTNopXHAo0na0Sj4+flrr2SnwOFYcmz70QjXXs00mG50Js/BWrYR4+6KohFr eJjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ut2j330bo/IxIjJswmV42yHAdJERMb8IowsBpx/nbpM=; b=bZtbfUd4mpg0ucIgibteP81YNOt+DXu3LW2F7VKhpXU2CFBz0NR38kMj357SAu0auk zZrch75YZ133fQh1ibWWqfJq7rL78nGrHfBDn5P83KX5dGLvcKtvGFE9Rj55doTW4jVZ P19Bq09E5Z6Jj9lG6gsaied5luDUoE578lQHXKnkDaHx6Y5muef4rVM+qYK+icrQarb8 YPRe1H431mbGS8Mh99zg9tmFQt4o6gV+Aib+Z5egXp5hu/GpSyLiJkGiIsvI8Gd/RWua lYde+OD/LTK3Z0yHyGyHUFgPTyUHaY78pKSD6SxMdUgHIvnjmeZkV1MBPzTL6YDVLT3W 4Mpg== X-Gm-Message-State: AOAM532pWd32Msqv/+4FfgsT8v037ZOGoTP/bQuGvG5/ON4Wi+rlvwmy 37JV64bzuu/esWAsEp0TJK0= X-Google-Smtp-Source: ABdhPJxtXlRcgWY0kQXw88u617ccGQBR6HE+b2tIlAicA/eOnJ4cO0tW4v3jdDgfVq1TUwHX4njUJw== X-Received: by 2002:a05:6512:3a90:: with SMTP id q16mr40712738lfu.135.1638103129831; Sun, 28 Nov 2021 04:38:49 -0800 (PST) Received: from rsa-laptop.internal.lan ([217.25.229.52]) by smtp.gmail.com with ESMTPSA id v198sm976533lfa.89.2021.11.28.04.38.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Nov 2021 04:38:49 -0800 (PST) From: Sergey Ryazanov To: "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, M Chetan Kumar , Intel Corporation , Loic Poulain , Johannes Berg Subject: [PATCH 4/5] net: wwan: iosm: make debugfs optional Date: Sun, 28 Nov 2021 15:38:36 +0300 Message-Id: <20211128123837.22829-5-ryazanov.s.a@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211128123837.22829-1-ryazanov.s.a@gmail.com> References: <20211128123837.22829-1-ryazanov.s.a@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Collecting modem firmware traces is optional for the regular modem use. Some distros and users will want to disable this feature for security or kernel size reasons. So add a configuration option that allows to completely disable the driver debugfs interface. Signed-off-by: Sergey Ryazanov --- drivers/net/wwan/Kconfig | 8 ++++++++ drivers/net/wwan/iosm/Makefile | 4 +++- drivers/net/wwan/iosm/iosm_ipc_debugfs.h | 5 +++++ drivers/net/wwan/iosm/iosm_ipc_imem.c | 2 +- drivers/net/wwan/iosm/iosm_ipc_imem.h | 4 ++++ drivers/net/wwan/iosm/iosm_ipc_trace.c | 6 ++++-- drivers/net/wwan/iosm/iosm_ipc_trace.h | 20 +++++++++++++++++++- 7 files changed, 44 insertions(+), 5 deletions(-) diff --git a/drivers/net/wwan/Kconfig b/drivers/net/wwan/Kconfig index 17543be14665..e204e74edcec 100644 --- a/drivers/net/wwan/Kconfig +++ b/drivers/net/wwan/Kconfig @@ -80,6 +80,14 @@ config IOSM If unsure, say N. +config IOSM_DEBUGFS + bool "IOSM Debugfs support" + depends on IOSM && DEBUG_FS + help + Enables debugfs driver interface for traces collection. + + If unsure, say N. + endif # WWAN endmenu diff --git a/drivers/net/wwan/iosm/Makefile b/drivers/net/wwan/iosm/Makefile index 5091f664af0d..bf28b29f6151 100644 --- a/drivers/net/wwan/iosm/Makefile +++ b/drivers/net/wwan/iosm/Makefile @@ -21,7 +21,9 @@ iosm-y = \ iosm_ipc_mux_codec.o \ iosm_ipc_devlink.o \ iosm_ipc_flash.o \ - iosm_ipc_coredump.o \ + iosm_ipc_coredump.o + +iosm-$(CONFIG_IOSM_DEBUGFS) += \ iosm_ipc_debugfs.o \ iosm_ipc_trace.o diff --git a/drivers/net/wwan/iosm/iosm_ipc_debugfs.h b/drivers/net/wwan/iosm/iosm_ipc_debugfs.h index 35788039f13f..3e3bb968fa03 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_debugfs.h +++ b/drivers/net/wwan/iosm/iosm_ipc_debugfs.h @@ -6,7 +6,12 @@ #ifndef IOSM_IPC_DEBUGFS_H #define IOSM_IPC_DEBUGFS_H +#ifdef CONFIG_IOSM_DEBUGFS void ipc_debugfs_init(struct iosm_imem *ipc_imem); void ipc_debugfs_deinit(struct iosm_imem *ipc_imem); +#else +static inline void ipc_debugfs_init(struct iosm_imem *ipc_imem) {} +static inline void ipc_debugfs_deinit(struct iosm_imem *ipc_imem) {} +#endif #endif diff --git a/drivers/net/wwan/iosm/iosm_ipc_imem.c b/drivers/net/wwan/iosm/iosm_ipc_imem.c index 25b889922912..2a6ddd7c6c88 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_imem.c +++ b/drivers/net/wwan/iosm/iosm_ipc_imem.c @@ -274,7 +274,7 @@ static void ipc_imem_dl_skb_process(struct iosm_imem *ipc_imem, ipc_imem_sys_devlink_notify_rx(ipc_imem->ipc_devlink, skb); else if (ipc_is_trace_channel(ipc_imem, port_id)) - ipc_trace_port_rx(ipc_imem->trace, skb); + ipc_trace_port_rx(ipc_imem, skb); else wwan_port_rx(ipc_imem->ipc_port[port_id]->iosm_port, skb); diff --git a/drivers/net/wwan/iosm/iosm_ipc_imem.h b/drivers/net/wwan/iosm/iosm_ipc_imem.h index df3b471f6fa9..cca4b32c63cd 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_imem.h +++ b/drivers/net/wwan/iosm/iosm_ipc_imem.h @@ -350,7 +350,9 @@ struct iosm_imem { struct iosm_mux *mux; struct iosm_cdev *ipc_port[IPC_MEM_MAX_CHANNELS]; struct iosm_pcie *pcie; +#ifdef CONFIG_IOSM_DEBUGFS struct iosm_trace *trace; +#endif struct device *dev; enum ipc_mem_device_ipc_state ipc_requested_state; struct ipc_mem_channel channels[IPC_MEM_MAX_CHANNELS]; @@ -380,7 +382,9 @@ struct iosm_imem { ev_mux_net_transmit_pending:1, reset_det_n:1, pcie_wake_n:1; +#ifdef CONFIG_IOSM_DEBUGFS struct dentry *debugfs_dir; +#endif }; /** diff --git a/drivers/net/wwan/iosm/iosm_ipc_trace.c b/drivers/net/wwan/iosm/iosm_ipc_trace.c index 5243ead90b5f..eeecfa3d10c5 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_trace.c +++ b/drivers/net/wwan/iosm/iosm_ipc_trace.c @@ -17,11 +17,13 @@ /** * ipc_trace_port_rx - Receive trace packet from cp and write to relay buffer - * @ipc_trace: Pointer to the ipc trace data-struct + * @ipc_imem: Pointer to iosm_imem structure * @skb: Pointer to struct sk_buff */ -void ipc_trace_port_rx(struct iosm_trace *ipc_trace, struct sk_buff *skb) +void ipc_trace_port_rx(struct iosm_imem *ipc_imem, struct sk_buff *skb) { + struct iosm_trace *ipc_trace = ipc_imem->trace; + if (ipc_trace->ipc_rchan) relay_write(ipc_trace->ipc_rchan, skb->data, skb->len); diff --git a/drivers/net/wwan/iosm/iosm_ipc_trace.h b/drivers/net/wwan/iosm/iosm_ipc_trace.h index 419540c91219..0d74836df90c 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_trace.h +++ b/drivers/net/wwan/iosm/iosm_ipc_trace.h @@ -45,6 +45,8 @@ struct iosm_trace { enum trace_ctrl_mode mode; }; +#ifdef CONFIG_IOSM_DEBUGFS + static inline bool ipc_is_trace_channel(struct iosm_imem *ipc_mem, u16 chl_id) { return ipc_mem->trace && ipc_mem->trace->chl_id == chl_id; @@ -52,5 +54,21 @@ static inline bool ipc_is_trace_channel(struct iosm_imem *ipc_mem, u16 chl_id) struct iosm_trace *ipc_trace_init(struct iosm_imem *ipc_imem); void ipc_trace_deinit(struct iosm_trace *ipc_trace); -void ipc_trace_port_rx(struct iosm_trace *ipc_trace, struct sk_buff *skb); +void ipc_trace_port_rx(struct iosm_imem *ipc_imem, struct sk_buff *skb); + +#else + +static inline bool ipc_is_trace_channel(struct iosm_imem *ipc_mem, u16 chl_id) +{ + return false; +} + +static inline void ipc_trace_port_rx(struct iosm_imem *ipc_imem, + struct sk_buff *skb) +{ + dev_kfree_skb(skb); +} + +#endif + #endif From patchwork Sun Nov 28 12:38:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Ryazanov X-Patchwork-Id: 12642873 X-Patchwork-Delegate: kuba@kernel.org 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 8D735C4332F for ; Sun, 28 Nov 2021 12:41:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242823AbhK1Mor (ORCPT ); Sun, 28 Nov 2021 07:44:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357448AbhK1Mmp (ORCPT ); Sun, 28 Nov 2021 07:42:45 -0500 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CC75C0613E0 for ; Sun, 28 Nov 2021 04:38:52 -0800 (PST) Received: by mail-lj1-x234.google.com with SMTP id z8so28946417ljz.9 for ; Sun, 28 Nov 2021 04:38:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1EfcGdLjQUtK7/5MZ3LTCPhBBgh6JFpaX3qkMx9GGyA=; b=DVhW81hrjMa8XpqZ335BvysMZxYu+Tq1u9d53Xa4khI1uaoCy9H1UPdZ+zw5+hNEPC UgSFvwm4MVCAk5EPAzDRW/74rDVymVNszFMUD0MUd7JE9+D9t37VDdvvdnWRMzB6rtvg 9uDquM3BbtRRATTXoR4eDV5KLFNiMbkYM2Ntr7rcQ3kE9HY2nUgoLayBRxZGxicIpsOu dhxUqU4rBD//knoylX+Dg8IEec4LIvnil2IZvHB5H2xzaq+kYDPnjg/J93IPvfTTYQU0 9Wh+MOkEIKQskfWjOsDvH90tg7YgYNKn/+uZgsUjS15gZ2v1qjb2DXibJLwPErcsjLQM hZ1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1EfcGdLjQUtK7/5MZ3LTCPhBBgh6JFpaX3qkMx9GGyA=; b=KnZCyimJ4RP73QkTLAmfrPWc/Hmg3XhV/Q3TEqSnE91S8LTQnfo/1zfxUraUcev4Qs u74JdeKRk6QLVq/Aeos8uDooF6mv0Ey7T3CLgULH6zxNqPhAkUOhthwrr+6tgbtRKX9+ j8B0nG853n+jymnKf9gOqJaL2dD8GGiI2/+tS7TsxUxpzH8IAdkCmjNj6tsBnObcmPGf biR6Ew+tLJH8im3HNQViM8tljWZTFPXXXgctUOva/U9h3Xapeizq+i1Lfxl53EvitgTg zS8MAwTie8ebUGlg3I+Z6xucxvAwI2Q3Rj8rl0nO+IqF84X7PA2AeKcsHwvHWpacHvZ6 mCug== X-Gm-Message-State: AOAM530d1l+xb7hDxsms3CauQpym1UGvK78oxVytWTf/TZ4rN3cSdTXk Aj6PiDl8IzaaDU+r9jgsq7g= X-Google-Smtp-Source: ABdhPJwUsqNplg89zv0PwwxznW/Tv5cNWkmB99pdFoeGDrcuo9xPPCYwDnrmpwucWPTWiqzE3CZTFA== X-Received: by 2002:a05:651c:1503:: with SMTP id e3mr43602086ljf.182.1638103130871; Sun, 28 Nov 2021 04:38:50 -0800 (PST) Received: from rsa-laptop.internal.lan ([217.25.229.52]) by smtp.gmail.com with ESMTPSA id v198sm976533lfa.89.2021.11.28.04.38.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Nov 2021 04:38:50 -0800 (PST) From: Sergey Ryazanov To: "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, M Chetan Kumar , Intel Corporation , Loic Poulain , Johannes Berg Subject: [PATCH 5/5] net: wwan: core: make debugfs optional Date: Sun, 28 Nov 2021 15:38:37 +0300 Message-Id: <20211128123837.22829-6-ryazanov.s.a@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211128123837.22829-1-ryazanov.s.a@gmail.com> References: <20211128123837.22829-1-ryazanov.s.a@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Current WWAN debugfs interface does not take too much space, but it is useless without driver-specific debugfs interfaces. To avoid overloading debugfs with empty directories, make the common WWAN debugfs interface optional. And force its selection if any driver-specific interface (only IOSM at the moment) is enabled by user. Signed-off-by: Sergey Ryazanov --- drivers/net/wwan/Kconfig | 9 +++++++++ drivers/net/wwan/wwan_core.c | 8 ++++++++ include/linux/wwan.h | 7 +++++++ 3 files changed, 24 insertions(+) diff --git a/drivers/net/wwan/Kconfig b/drivers/net/wwan/Kconfig index e204e74edcec..6e1ef08650c9 100644 --- a/drivers/net/wwan/Kconfig +++ b/drivers/net/wwan/Kconfig @@ -16,6 +16,14 @@ config WWAN if WWAN +config WWAN_DEBUGFS + bool "WWAN subsystem common debugfs interface" + depends on DEBUG_FS + help + Enables common debugfs infrastructure for WWAN devices. + + If unsure, say N. + config WWAN_HWSIM tristate "Simulated WWAN device" help @@ -83,6 +91,7 @@ config IOSM config IOSM_DEBUGFS bool "IOSM Debugfs support" depends on IOSM && DEBUG_FS + select WWAN_DEBUGFS help Enables debugfs driver interface for traces collection. diff --git a/drivers/net/wwan/wwan_core.c b/drivers/net/wwan/wwan_core.c index 5bf62dc35ac7..b41104129d1a 100644 --- a/drivers/net/wwan/wwan_core.c +++ b/drivers/net/wwan/wwan_core.c @@ -146,6 +146,7 @@ static struct wwan_device *wwan_dev_get_by_name(const char *name) return to_wwan_dev(dev); } +#ifdef CONFIG_WWAN_DEBUGFS struct dentry *wwan_get_debugfs_dir(struct device *parent) { struct wwan_device *wwandev; @@ -157,6 +158,7 @@ struct dentry *wwan_get_debugfs_dir(struct device *parent) return wwandev->debugfs_dir; } EXPORT_SYMBOL_GPL(wwan_get_debugfs_dir); +#endif /* This function allocates and registers a new WWAN device OR if a WWAN device * already exist for the given parent, it gets a reference and return it. @@ -207,8 +209,10 @@ static struct wwan_device *wwan_create_dev(struct device *parent) } wwandev_name = kobject_name(&wwandev->dev.kobj); +#ifdef CONFIG_WWAN_DEBUGFS wwandev->debugfs_dir = debugfs_create_dir(wwandev_name, wwan_debugfs_dir); +#endif done_unlock: mutex_unlock(&wwan_register_lock); @@ -240,7 +244,9 @@ static void wwan_remove_dev(struct wwan_device *wwandev) ret = device_for_each_child(&wwandev->dev, NULL, is_wwan_child); if (!ret) { +#ifdef CONFIG_WWAN_DEBUGFS debugfs_remove_recursive(wwandev->debugfs_dir); +#endif device_unregister(&wwandev->dev); } else { put_device(&wwandev->dev); @@ -1140,7 +1146,9 @@ static int __init wwan_init(void) goto destroy; } +#ifdef CONFIG_WWAN_DEBUGFS wwan_debugfs_dir = debugfs_create_dir("wwan", NULL); +#endif return 0; diff --git a/include/linux/wwan.h b/include/linux/wwan.h index 1646aa3e6779..b84ccf7d34da 100644 --- a/include/linux/wwan.h +++ b/include/linux/wwan.h @@ -171,6 +171,13 @@ int wwan_register_ops(struct device *parent, const struct wwan_ops *ops, void wwan_unregister_ops(struct device *parent); +#ifdef CONFIG_WWAN_DEBUGFS struct dentry *wwan_get_debugfs_dir(struct device *parent); +#else +static inline struct dentry *wwan_get_debugfs_dir(struct device *parent) +{ + return NULL; +} +#endif #endif /* __WWAN_H */