From patchwork Sun Nov 28 12:55:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Ryazanov X-Patchwork-Id: 12642889 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 E5C4BC433F5 for ; Sun, 28 Nov 2021 12:59:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357560AbhK1NDF (ORCPT ); Sun, 28 Nov 2021 08:03:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236517AbhK1NBF (ORCPT ); Sun, 28 Nov 2021 08:01:05 -0500 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 638FCC061748 for ; Sun, 28 Nov 2021 04:55:34 -0800 (PST) Received: by mail-lj1-x22e.google.com with SMTP id e11so28905559ljo.13 for ; Sun, 28 Nov 2021 04:55:34 -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=kTk7vS1DNYJmNSIyeXsuB+dukq9g7/GuS9VjE26bFaVewgg4Fqg0Tm+i5r5gHh4WTi RKeCEcHAX1N7b2k9cTkQNcgi/5dvGhrg7CQmdttBCteftJz0gQq6ojyhkLB4j94VWNjs scP8Ua/X0vMaSIiiShWdCJ6gvrlWO6YgP4jQGKLQZq+4gDuUZte3jBweAnF7ZKRpiyYu BxZFDuIEpby0BMeY94cI9xB9PZLnF5oAbyiYTz7DvU1NkN0dGS7wb0W469d/3pVmRRDH Yu+Ns15jYS+4bdho2TugNxxQf0q1C/QvtUCf5axzJkYRlKmpjgLBiEUUxIg38v/qmPCO n8bQ== 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=xEhqzVq/r1EfbgwdDqfggBZiIi45WE5Tj1cGEBNlgwmEN4RTR/B72oZ1uD18kDJweX IqqoEMA8yMTTTGWzhlpXTYFehxFGfM9IBP/htx7ut6Jl2gIr6DlDuKE04nlK7Ayj00Yx RCQnPioYZKUc6M6do+twX2s9gfGpkeR9OlFCN38DiL+9nl+Vbtw3MR/y2xHP8IEvYuFD 1U0Wb5II05KVTaCCeoZdbd+0gTyEPIq2bFgQjDvIVODTL44kVdzHPYf04YB9ps/pCrV0 Q2OA7GFIQeSAXjQU/EFFMKOcKB4DDU3sVoe0CYZ0pBerM/1y0fjCJnGlxwxcOv0RzbWQ ZRNQ== X-Gm-Message-State: AOAM533i7/F1CLUk6d33vDqf5nghv1ZE4U84XZM8R3VKqE8qsDLFVMLV y1MgQGmLQrZGYmkwm2vebjkgsTVtQxI= X-Google-Smtp-Source: ABdhPJwhbcEef4669LMtcVutfFp4ELRRrvqJbnDrfFqIEJ0F67g/ite3zDdhm4d/fHXq0WkZDC5+tw== X-Received: by 2002:a2e:9915:: with SMTP id v21mr44506756lji.155.1638104132706; Sun, 28 Nov 2021 04:55:32 -0800 (PST) Received: from rsa-laptop.internal.lan ([217.25.229.52]) by smtp.gmail.com with ESMTPSA id c1sm1066595ljr.111.2021.11.28.04.55.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Nov 2021 04:55:32 -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 RESEND net-next 1/5] net: wwan: iosm: consolidate trace port init code Date: Sun, 28 Nov 2021 15:55:18 +0300 Message-Id: <20211128125522.23357-2-ryazanov.s.a@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211128125522.23357-1-ryazanov.s.a@gmail.com> References: <20211128125522.23357-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:55:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Ryazanov X-Patchwork-Id: 12642893 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 F34C4C433F5 for ; Sun, 28 Nov 2021 12:59:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357650AbhK1NDO (ORCPT ); Sun, 28 Nov 2021 08:03:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237099AbhK1NBL (ORCPT ); Sun, 28 Nov 2021 08:01:11 -0500 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 596D0C06174A for ; Sun, 28 Nov 2021 04:55:35 -0800 (PST) Received: by mail-lj1-x236.google.com with SMTP id t11so28968903ljh.6 for ; Sun, 28 Nov 2021 04:55:35 -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=JMSzX6o+VRm356r2Bi3IMM0w/ZYfpYpTVDyFEB6JgG8Yp/qqbOB2OvOKEmbBVpAG4K 8vHunV3XW36t/ZkvWcFpW6F8Wo9r/1kryIDNlUc7EDRb/Np3CIns/LXDsdJ9r63arMB7 PlMnBprD8guItWFoxkzw0o3doaLMTDOV5w1zXeLGZB0b1784q8ZJ0NSJxtnQv1CE51yW 3KCuD/+vnYmOyY4kazOec4Nps57zWW0K6em7r53FhAA7KSyOPBDcIL0BmaBSxfpyjSBl +dxXtqz0rVxZYJkv5WkBhesgF80IEu9mkweF7LPAKa5PaHyPV424x3Te8SuqW4uIWpDZ Pi4w== 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=14ngfcZ6dTnX3wakH0Nfa0/qmHhGysY1lK7JCuVmaloFP5dpPNZjKAc+mOiPfZUmC4 Fg7sAr1jH8Kq7uRdCfR+1Jra6j2i9L6GbBcPGeahTw2LyHfoQ5ZnVnLbi9tsFcwBP2QW 5hBMlMI7VVQdSlm5Fd6QHxVexCgBaWIHSS2vQEUdw50CYPqqFe5HE7rNX+8cGTUVLdA6 ZxWDlpiF61O9Bjq1ro8CjG3gdtZ7P9Sjg4MhbqUQdPBDT2doZfxpG62ZMaBWas8F09sh wx2gLdTttWgdSKkwy6y6EoCa3vw6BhI72Qd2YwnhWc9rUIO+GDqezA/LGWFutYfGx47u Zavw== X-Gm-Message-State: AOAM531O1NI7We/Q1t8aw7pqHcOm8xSija371NYwr4lQo4vA4kK9z34m XEWsGW+vgA0kZahBzTI164y1r0AQkvs= X-Google-Smtp-Source: ABdhPJzKcdo+ch7UGtXKUn0nEHjxq6NYWtzrj8JEcVBL6uxqzwPmHewJei5pX0uow6E9sNundTbHcw== X-Received: by 2002:a05:651c:1548:: with SMTP id y8mr44044693ljp.458.1638104133705; Sun, 28 Nov 2021 04:55:33 -0800 (PST) Received: from rsa-laptop.internal.lan ([217.25.229.52]) by smtp.gmail.com with ESMTPSA id c1sm1066595ljr.111.2021.11.28.04.55.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Nov 2021 04:55:33 -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 RESEND net-next 2/5] net: wwan: iosm: allow trace port be uninitialized Date: Sun, 28 Nov 2021 15:55:19 +0300 Message-Id: <20211128125522.23357-3-ryazanov.s.a@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211128125522.23357-1-ryazanov.s.a@gmail.com> References: <20211128125522.23357-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:55:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Ryazanov X-Patchwork-Id: 12642891 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 2B728C433FE for ; Sun, 28 Nov 2021 13:00:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237099AbhK1NDO (ORCPT ); Sun, 28 Nov 2021 08:03:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231358AbhK1NBM (ORCPT ); Sun, 28 Nov 2021 08:01:12 -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 7426CC061756 for ; Sun, 28 Nov 2021 04:55:36 -0800 (PST) Received: by mail-lj1-x234.google.com with SMTP id e11so28905674ljo.13 for ; Sun, 28 Nov 2021 04:55:36 -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=H1W8Ikfs1zmjxyt7D3Hs3t/SAqM8cGzelAkXTA9P4pMLjQA8wXbRb7dIS26rWQaNrr A41V2vYxta3xDBofOq/GKoddczvPdTexWgGFd1hxIAhPLcNcVcgLXBYAloXMH0ed1j/1 yXZOVS81AXPIuoCtY8HCXrD9o82VnlmP9UAYMU6Nhooy1DlXnyVwBTbTDCk25B/TiS2o KMMLy6lDpX2efcPc7JAdXBFhRZiEub68u/OjxWvBn/sBlHnf9kxWdMGymPlQaX98RVzP /J5UHc/Wz18H9U9RfwHWw0p/8b1gzRr6ax1sJYav/gefR1kbMOkbdobe55BfQzTXgvIs njGg== 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=IXSKbA3m7WO2yRks/E42XrM4plfHnLek00JRZOYIYx8+w0vsE0A0V9s8tBJoYgtC82 NXBUNtWv86JTEIa+WbyhK7VwT2lByIjtLEMzET59sh6rwIcpqiFrertqg9eEBU8M7LKE yXIqF720p6KehmsEHMwNyaN5BpvUFXNU2Tt+/rwiXLbNiAX3gurxFbXmOFnPNM247lQh GxlOaTHSiktq153UK3gOnk9tDxA00u3Oxy0z1oEhYpaxoWNj/KGmmctHwm4toqxMH4O6 GaADdvnDLRmbe4czVrFR0YzSpxoFd5b07V/u9IEzwtSI5OZIQy+RWA3X3Ft/ok9viT+e od6Q== X-Gm-Message-State: AOAM530TagIrJYfp9l1jeXd0hsj6iVPvup4W/iixYn3nfpoEOblD2QfZ nZAn3ajQ37tQWJwTxVpEyW0= X-Google-Smtp-Source: ABdhPJzDmrgogS9uHacf29GVe5T4qmnlxhFq2//jV8BcXSoV+voLX1qKta0ySwlH69OtjZF2+32OPA== X-Received: by 2002:a2e:89c4:: with SMTP id c4mr42773328ljk.230.1638104134805; Sun, 28 Nov 2021 04:55:34 -0800 (PST) Received: from rsa-laptop.internal.lan ([217.25.229.52]) by smtp.gmail.com with ESMTPSA id c1sm1066595ljr.111.2021.11.28.04.55.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Nov 2021 04:55:34 -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 RESEND net-next 3/5] net: wwan: iosm: move debugfs knobs into a subdir Date: Sun, 28 Nov 2021 15:55:20 +0300 Message-Id: <20211128125522.23357-4-ryazanov.s.a@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211128125522.23357-1-ryazanov.s.a@gmail.com> References: <20211128125522.23357-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:55:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Ryazanov X-Patchwork-Id: 12642895 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 88438C433EF for ; Sun, 28 Nov 2021 13:00:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357420AbhK1ND3 (ORCPT ); Sun, 28 Nov 2021 08:03:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344496AbhK1NB2 (ORCPT ); Sun, 28 Nov 2021 08:01:28 -0500 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4FC8C061758 for ; Sun, 28 Nov 2021 04:55:37 -0800 (PST) Received: by mail-lf1-x136.google.com with SMTP id u3so37159005lfl.2 for ; Sun, 28 Nov 2021 04:55:37 -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=THZa4bBhSrqWyIRUpaQ8GE7t418jV9HGBRuFRTOJqEe8ZkzfO5JvxQFtJ4O5GIkBIE 7pkqYOISlPapLHtdfZmLj/3N3naZ+orlOunQLpn+dy4mz/W+ZO6GMShhGgeO9XnYPnVg garVYVZM95xBe2+++UVtL82b7l0Xy+hxw8Steci0Sh4NmOLXDj87avUTkmz9IYlHJO2t ipJarGlJXSAnRlAZ//yZeyB8JJC9cquyNVEOP/0CqlgQqPhBFvBUL4j8yn5OxeXd/QS1 MV7G7OSUrKtxYofBF0orhlUZki/cwxUVvNzwRhvp3WUH5PLJt3L0syAgZWEUdjXdT4TR CSrg== 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=XZlvOPtdlpH/lMbwwN0M6VqFKE/mCByvV5wr55DGBULfVhQvtcN7YXyNj1dCS16H1X hrHM8YcygQ8rJlCKVeCG/KUugqcorXeB1Jfq1TGLQrdiBff2BCtYEG0aCvTmeuvWUILK kPBoVS6tUeIUmjsbrEtc7YHBu8EGs6iyVz1ri3chfOAYzovaslNWDNUc71F/N9JmMuEI aMTza93jJ+lgQX9GV2kNWQIoN1AowoJc0lKzq82WWDnXhVcI+iNfjgVPaG7F7Qog7ZIu P12OPQvZPxG1v0lMGpLwDQ1SU81T5/FIx8ybXQuo28K2DyLq5LP5fPmPrRyu1kPs5Z0T U0Lg== X-Gm-Message-State: AOAM530yhrMsOQL3iUoRsXopURc92maB9RRveLzHCr0nko5RfJeLUkyZ c3nrekEU7xWy2Wh6xWZaplE= X-Google-Smtp-Source: ABdhPJyGSMUla9XIloHOuxPhrzy26KU1v/iksoa5hSj3DCSnVsHNgaVjMEc4bmJE4WkVov6taKcZBw== X-Received: by 2002:a19:4895:: with SMTP id v143mr39384108lfa.142.1638104136037; Sun, 28 Nov 2021 04:55:36 -0800 (PST) Received: from rsa-laptop.internal.lan ([217.25.229.52]) by smtp.gmail.com with ESMTPSA id c1sm1066595ljr.111.2021.11.28.04.55.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Nov 2021 04:55:35 -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 RESEND net-next 4/5] net: wwan: iosm: make debugfs optional Date: Sun, 28 Nov 2021 15:55:21 +0300 Message-Id: <20211128125522.23357-5-ryazanov.s.a@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211128125522.23357-1-ryazanov.s.a@gmail.com> References: <20211128125522.23357-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:55:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Ryazanov X-Patchwork-Id: 12642897 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 0E9A0C433F5 for ; Sun, 28 Nov 2021 13:00:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357565AbhK1NDh (ORCPT ); Sun, 28 Nov 2021 08:03:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345845AbhK1NBg (ORCPT ); Sun, 28 Nov 2021 08:01:36 -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 CFF37C06175B for ; Sun, 28 Nov 2021 04:55:38 -0800 (PST) Received: by mail-lf1-x130.google.com with SMTP id z7so2812598lfi.11 for ; Sun, 28 Nov 2021 04:55:38 -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=oKhdIwStzFQ5YOX/4wsWIAzClfhNLG1/SMrM63T6ir5e+YHsV012Cp9v5Vbi4GVXnh N3BTZ7b0Td44x8gvKWzyXsXoHz+eOPHOhK7oasqjAsSW2l6VnG2z0OYSpJKdVNMrsl3m gbRX+aBRxIb68BkeTFz3h9+2XGu1IJ8ji48lS6wF8qXNmzUlkXlL/XHLfwmR++ee3veI xnC3CbpyrSZclBLA3sy6SZDuI539bcccKOLIrxBab8lC9xGqBaml0dqZxjZqs20kHazw xw9kW68C8L5KdSmevNfnssYSg70sS4cN+ZsAlAIYb4y+uGEPAjDobFUzo5+wsP8JB53H xDxQ== 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=hzhOxId1RtrenhxEkYize0R8v1C4NbeBGAvwotUhLaSw04TKitqzeYKT+NZj0xmEkO vjB7cW+Losu+XOme5VKag3zp7nSm/GSgTsCKQk1LWudhOa0RixyPo2KPPSbdPlF9SNP5 lJTmE/2dtRKA7TgMbPQXVEifxepW13TIWvwfe9Q8wlxzEKdBYBmZ4/rTMvxmnGj7+VyY 9pt0wh39KVPVaUPGHjr7et4YQViY3S4THxj1u5VWIQ7ZobGzyzgmlCDvgKd77DV/fhmZ 32OVhjoS654Kev9DLFLgTVwJaN9k5rSUSsVDS06ybg4dPW9DizZHzHoS/HL+lNeG4bXQ t17w== X-Gm-Message-State: AOAM533WgbudqdLrQxDi69gmO0/5v19OqM4EujBfx5eU9q5RwJieQLTI 2YcUj290VQKkiPDktBRMSFA= X-Google-Smtp-Source: ABdhPJxqfOWEAbqAa9OGo38k4nmEHdQtuXpRH4a7G+KP1Vj47D6+JZ0Dco/5ZxW7rjO1aESlpZtBJA== X-Received: by 2002:a05:6512:1690:: with SMTP id bu16mr2899777lfb.38.1638104137176; Sun, 28 Nov 2021 04:55:37 -0800 (PST) Received: from rsa-laptop.internal.lan ([217.25.229.52]) by smtp.gmail.com with ESMTPSA id c1sm1066595ljr.111.2021.11.28.04.55.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Nov 2021 04:55:36 -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 RESEND net-next 5/5] net: wwan: core: make debugfs optional Date: Sun, 28 Nov 2021 15:55:22 +0300 Message-Id: <20211128125522.23357-6-ryazanov.s.a@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211128125522.23357-1-ryazanov.s.a@gmail.com> References: <20211128125522.23357-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 Reported-by: kernel test robot --- 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 */