Debugfs and Sysfs entries for MHI
Subsystems (2)
v2 cover Debugfs and Sysfs entries for MHI
Introduce debugfs and sysfs entries for MHI.
Fixes to allow building MHI as a module without warnings/errors.
This set of patches was tested on arm64 and x86_64 architectures.
v2:
-Remove the patch for removal of MODULE_LICENSE() warnings -Add fixes to adhere to the Kconfig coding style
Bhaumik Bhatt (3):
bus: mhi: Fix entries based on Kconfig conding style
bus: mhi: core: Introduce debugfs entries for MHI
bus: mhi: core: Introduce sysfs entries for MHI
Documentation/ABI/stable/sysfs-bus-mhi | 21 ++ MAINTAINERS | 1 + drivers/bus/mhi/Kconfig | 20 +- drivers/bus/mhi/core/Makefile | 1 + drivers/bus/mhi/core/debugfs.c | 410 +++++++++++++++++++++++++++++++++ drivers/bus/mhi/core/init.c | 60 +++++ drivers/bus/mhi/core/internal.h | 24 ++ include/linux/mhi.h | 2 + 8 files changed, 533 insertions(+), 6 deletions(-) create mode 100644 Documentation/ABI/stable/sysfs-bus-mhi create mode 100644 drivers/bus/mhi/core/debugfs.c
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v2 1/3 bus: mhi: Fix entries based on Kconfig conding style
Kconfig coding style suggests use of tabs for the configuration definition and an additional two spaces for the help text. Make the required changes to the MHI Kconfig adhering to those guidelines.
--- drivers/bus/mhi/Kconfig | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/bus/mhi/Kconfig +6 -6
@@ -6,9 +6,9 @@ # config MHI_BUS - tristate "Modem Host Interface (MHI) bus" - help - Bus driver for MHI protocol. Modem Host Interface (MHI) is a - communication protocol used by the host processors to control - and communicate with modem devices over a high speed peripheral - bus or shared memory. + tristate "Modem Host Interface (MHI) bus" + help + Bus driver for MHI protocol. Modem Host Interface (MHI) is a + communication protocol used by the host processors to control + and communicate with modem devices over a high speed peripheral + bus or shared memory.
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v2 2/3 bus: mhi: core: Introduce debugfs entries for MHI
In reply to Bhaumik BhattIntroduce debugfs entries to show state, register, channel, device, and event rings information. Allow the host to dump registers, issue device wake, and change the MHI timeout to help in debug.
--- drivers/bus/mhi/Kconfig | 8 + drivers/bus/mhi/core/Makefile | 1 + drivers/bus/mhi/core/debugfs.c | 410 ++++++++++++++++++++++++++++++++++++++++ drivers/bus/mhi/core/init.c | 7 + drivers/bus/mhi/core/internal.h | 24 +++ include/linux/mhi.h | 2 + 6 files changed, 452 insertions(+) create mode 100644 drivers/bus/mhi/core/debugfs.c
drivers/bus/mhi/Kconfig +8 -0
@@ -12,3 +12,11 @@ config MHI_BUS communication protocol used by the host processors to control and communicate with modem devices over a high speed peripheral bus or shared memory. + +config MHI_BUS_DEBUG + bool "Debugfs support for the MHI bus" + depends on MHI_BUS && DEBUG_FS + help + Enable debugfs support for use with the MHI transport. Allows + reading and/or modifying some values within the MHI controller + for debug and test purposes.
drivers/bus/mhi/core/Makefile +1 -0
@@ -1,3 +1,4 @@ obj-$(CONFIG_MHI_BUS) := mhi.o mhi-y := init.o main.o pm.o boot.o +mhi-$(CONFIG_MHI_BUS_DEBUG) += debugfs.o
drivers/bus/mhi/core/debugfs.c new file +410 -0
410 lines not on this page · raw message
drivers/bus/mhi/core/init.c +7 -0
@@ -4,6 +4,7 @@* */ +#include <linux/debugfs.h> #include <linux/device.h> #include <linux/dma-direction.h> #include <linux/dma-mapping.h>
@@ -915,6 +916,8 @@ int mhi_register_controller(struct mhi_controller *mhi_cntrl, mhi_cntrl->mhi_dev = mhi_dev; +mhi_create_debugfs (mhi_cntrl); +return 0 ; error_add_dev:
@@ -937,6 +940,8 @@ void mhi_unregister_controller(struct mhi_controller *mhi_cntrl)struct mhi_chan *mhi_chan = mhi_cntrl->mhi_chan;unsigned int i; +mhi_destroy_debugfs (mhi_cntrl); +kfree (mhi_cntrl->mhi_cmd);kfree (mhi_cntrl->mhi_event);
@@ -1300,11 +1305,13 @@ struct bus_type mhi_bus_type = {static int __init mhi_init (void ) { +mhi_debugfs_init ();return bus_register (&mhi_bus_type); } static void __exit mhi_exit(void) { +mhi_debugfs_exit ();bus_unregister (&mhi_bus_type); }
drivers/bus/mhi/core/internal.h +24 -0
@@ -570,6 +570,30 @@ struct mhi_chan {/* Default MHI timeout */ #define MHI_TIMEOUT_MS (1000) +/* debugfs related functions */ +#ifdef CONFIG_MHI_BUS_DEBUG +void mhi_create_debugfs (struct mhi_controller *mhi_cntrl); +void mhi_destroy_debugfs (struct mhi_controller *mhi_cntrl); +void mhi_debugfs_init (void ); +void mhi_debugfs_exit (void ); +#else +static inline void mhi_create_debugfs (struct mhi_controller *mhi_cntrl) +{ +} + +static inline void mhi_destroy_debugfs (struct mhi_controller *mhi_cntrl) +{ +} + +static inline void mhi_debugfs_init (void ) +{ +} + +static inline void mhi_debugfs_exit (void ) +{ +} +#endif +struct mhi_device *mhi_alloc_device (struct mhi_controller *mhi_cntrl);int mhi_destroy_device (struct device *dev,void *data);
include/linux/mhi.h +2 -0
@@ -291,6 +291,7 @@ struct mhi_controller_config {* @cntrl_dev: Pointer to the struct device of physical bus acting as the MHI * controller (required) * @mhi_dev: MHI device instance for the controller +* @debugfs_dentry: MHI controller debugfs directory * @regs: Base address of MHI MMIO register space (required) * @bhi: Points to base of MHI BHI register space * @bhie: Points to base of MHI BHIe register space
@@ -370,6 +371,7 @@ struct mhi_controller_config {struct mhi_controller {struct device *cntrl_dev;struct mhi_device *mhi_dev; +struct dentry *debugfs_dentry;void __iomem *regs;void __iomem *bhi;void __iomem *bhie;
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v2 3/3 bus: mhi: core: Introduce sysfs entries for MHI
In reply to Bhaumik BhattIntroduce sysfs entries to enable userspace clients the ability to read the serial number and the OEM PK Hash values obtained from BHI. OEMs need to read these device-specific hardware information values through userspace for factory testing purposes and cannot be exposed via degbufs as it may remain disabled for performance reasons. Also, update the documentation for ABI to include these entries.
--- Documentation/ABI/stable/sysfs-bus-mhi | 21 ++++++++++++++ MAINTAINERS | 1 + drivers/bus/mhi/core/init.c | 53 ++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 Documentation/ABI/stable/sysfs-bus-mhi
Documentation/ABI/stable/sysfs-bus-mhi new file +21 -0
@@ -0,0 +1,21 @@ +What: /sys/bus/mhi/devices/.../serialnumber +Date: Sept 2020 +KernelVersion: 5.10 +Contact: Bhaumik Bhatt <[email protected]> +Description: The file holds the serial number of the client device obtained + using a BHI (Boot Host Interface) register read after at least + one attempt to power up the device has been done. If read + without having the device power on at least once, the file will + read all 0's. +Users: Any userspace application or clients interested in device info. + +What: /sys/bus/mhi/devices/.../oem_pk_hash +Date: Sept 2020 +KernelVersion: 5.10 +Contact: Bhaumik Bhatt <[email protected]> +Description: The file holds the OEM PK Hash value of the endpoint device + obtained using a BHI (Boot Host Interface) register read after + at least one attempt to power up the device has been done. If + read without having the device power on at least once, the file + will read all 0's. +Users: Any userspace application or clients interested in device info.
MAINTAINERS +1 -0
@@ -11323,6 +11323,7 @@ M: Hemant Kumar <[email protected]> L: [email protected] S: Maintained T: git git://git.kernel.org/pub/scm/linux/kernel/git/mani/mhi.git +F: Documentation/ABI/stable/sysfs-bus-mhi F: Documentation/mhi/ F: drivers/bus/mhi/ F: include/linux/mhi.h
drivers/bus/mhi/core/init.c +53 -0
71 lines not on this page · raw message
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project