Commit 16daf3d9 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'wwan-debugfs-tweaks'

Sergey Ryazanov says:

====================
WWAN debugfs tweaks

This is a follow-up series to just applied IOSM (and WWAN) debugfs
interface support [1]. The series has two main goals:
1. move the driver-specific debugfs knobs to a subdirectory;
2. make the debugfs interface optional for both IOSM and for the WWAN
   core.

As for the first part, I must say that it was my mistake. I suggested to
place debugfs entries under a common per WWAN device directory. But I
missed the driver subdirectory in the example, so it become:

/sys/kernel/debugfs/wwan/wwan0/trace

Since the traces collection is a driver-specific feature, it is better
to keep it under the driver-specific subdirectory:

/sys/kernel/debugfs/wwan/wwan0/iosm/trace

It is desirable to be able to entirely disable the debugfs interface. It
can be disabled for several reasons, including security and consumed
storage space. See detailed rationale with usage example in the 4th
patch.

The changes themselves are relatively simple, but require a code
rearrangement. So to make changes clear, I chose to split them into
preparatory and main changes and properly describe each of them.

IOSM part is compile-tested only since I do not have IOSM supported
device, so it needs Ack from the driver developers.

I would like to thank Johannes Berg and Leon Romanovsky. Their
suggestions and comments helped a lot to rework the initial
over-engineered solution to something less confusing and much more
simple. Thanks!

1. https://lore.kernel.org/netdev/20211120162155.1216081-1-m.chetan.kumar@linux.intel.com
2. https://patchwork.kernel.org/project/netdevbpf/patch/20211204174033.950528-1-arnd@kernel.org/
====================

Link: https://lore.kernel.org/r/20211207092140.19142-1-ryazanov.s.a@gmail.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents a43a0720 283e6f5a
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -16,6 +16,17 @@ config WWAN

if WWAN

config WWAN_DEBUGFS
	bool "WWAN devices debugfs interface" if EXPERT
	depends on DEBUG_FS
	default y
	help
	  Enables debugfs infrastructure for the WWAN core and device drivers.

	  If this option is selected, then you can find the debug interface
	  elements for each WWAN device in a directory that is corresponding to
	  the device name: debugfs/wwan/wwanX.

config WWAN_HWSIM
	tristate "Simulated WWAN device"
	help
@@ -85,7 +96,7 @@ config IOSM
	tristate "IOSM Driver for Intel M.2 WWAN Device"
	depends on INTEL_IOMMU
	select NET_DEVLINK
	select RELAY
	select RELAY if WWAN_DEBUGFS
	help
	  This driver enables Intel M.2 WWAN Device communication.

+4 −1
Original line number Diff line number Diff line
@@ -21,7 +21,10 @@ 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_WWAN_DEBUGFS) += \
	iosm_ipc_debugfs.o		\
	iosm_ipc_trace.o

obj-$(CONFIG_IOSM) := iosm.o
+29 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (C) 2020-2021 Intel Corporation.
 */

#include <linux/debugfs.h>
#include <linux/wwan.h>

#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);
}
+17 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only
 *
 * Copyright (C) 2020-2021 Intel Corporation.
 */

#ifndef IOSM_IPC_DEBUGFS_H
#define IOSM_IPC_DEBUGFS_H

#ifdef CONFIG_WWAN_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
+5 −8
Original line number Diff line number Diff line
@@ -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)
@@ -272,8 +273,8 @@ 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)
			ipc_trace_port_rx(ipc_imem->trace, skb);
		else if (ipc_is_trace_channel(ipc_imem, port_id))
			ipc_trace_port_rx(ipc_imem, skb);
		else
			wwan_port_rx(ipc_imem->ipc_port[port_id]->iosm_port,
				     skb);
@@ -554,11 +555,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);
	if (!ipc_imem->trace) {
		dev_err(ipc_imem->dev, "trace channel init failed");
		return;
	}
	ipc_debugfs_init(ipc_imem);

	ipc_task_queue_send_task(ipc_imem, ipc_imem_send_mdm_rdy_cb, 0, NULL, 0,
				 false);
@@ -1175,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);
	}
Loading