Introduce features and debugfs/sysfs entries for MHI
Subsystems (2)
v3 cover Introduce features and debugfs/sysfs entries for MHI
Introduce independent bus and device voting mechanism for clients and save hardware information from BHI.
Allow reading and modifying some MHI variables for debug, test, and informational purposes using debugfs.
Read values for device specific hardware information to be used by OEMs in factory testing such as serial number and PK hash using sysfs.
This set of patches was tested on arm64 and x86.
v3:
-Add patch to check for pending packets in suspend as a dependency for the independent voting mechanism introduction
-Include register dump entry for debugfs to dump MHI, BHI, and BHIe registers -Update commit message for the debugfs patch
-Updated Documentation/ABI with the required info for sysfs -Updated debugfs patch to include a new KConfig entry and dependencies -Updated reviewed-by for some patches
v2:
-Added a new debugfs.c file for specific debugfs entries and code -Updated commit text and addressed some comments for voting change -Made sure sysfs is only used for serial number and OEM PK hash usage
Bhaumik Bhatt (7):
bus: mhi: core: Abort suspends due to outgoing pending packets
bus: mhi: core: Introduce independent voting mechanism
bus: mhi: core: Use generic name field for an MHI device
bus: mhi: core: Introduce helper function to check device state
bus: mhi: core: Introduce debugfs entries and counters for MHI
bus: mhi: core: Read and save device hardware information from BHI
bus: mhi: core: Introduce sysfs entries for MHI
Documentation/ABI/stable/sysfs-bus-mhi | 25 ++ MAINTAINERS | 1 + drivers/bus/mhi/Kconfig | 8 + drivers/bus/mhi/core/Makefile | 5 +- drivers/bus/mhi/core/boot.c | 17 +- drivers/bus/mhi/core/debugfs.c | 501 +++++++++++++++++++++++++++++++++ drivers/bus/mhi/core/init.c | 80 +++++- drivers/bus/mhi/core/internal.h | 29 ++ drivers/bus/mhi/core/main.c | 6 +- drivers/bus/mhi/core/pm.c | 79 ++++-- include/linux/mhi.h | 39 ++- 11 files changed, 745 insertions(+), 45 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 v3 1/7 bus: mhi: core: Abort suspends due to outgoing pending packets
Add the missing check to abort suspends if a client has pending outgoing packets to send to the device. This allows better utilization of the MHI bus wherein clients on the host are not left waiting for longer suspend or resume cycles to finish for data transfers.
--- drivers/bus/mhi/core/pm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/bus/mhi/core/pm.c +4 -2
@@ -686,7 +686,8 @@ int mhi_pm_suspend(struct mhi_controller *mhi_cntrl)return -EIO ;/* Return busy if there are any pending resources */ -if (atomic_read (&mhi_cntrl->dev_wake)) +if (atomic_read (&mhi_cntrl->dev_wake) || +atomic_read (&mhi_cntrl->pending_pkts))return -EBUSY ;/* Take MHI out of M2 state */
@@ -712,7 +713,8 @@ int mhi_pm_suspend(struct mhi_controller *mhi_cntrl)write_lock_irq (&mhi_cntrl->pm_lock); -if (atomic_read (&mhi_cntrl->dev_wake)) { +if (atomic_read (&mhi_cntrl->dev_wake) || +atomic_read (&mhi_cntrl->pending_pkts)) {write_unlock_irq (&mhi_cntrl->pm_lock);return -EBUSY ; }
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v3 4/7 bus: mhi: core: Introduce helper function to check device state
In reply to Bhaumik BhattIntroduce a helper function to determine whether the device is in a powered ON state and resides in one of the active MHI states. This will allow for some use cases in reading debugfs entries.
--- drivers/bus/mhi/core/internal.h | 5 +++++ 1 file changed, 5 insertions(+)
drivers/bus/mhi/core/internal.h +5 -0
@@ -599,6 +599,11 @@ int mhi_queue_state_transition(struct mhi_controller *mhi_cntrl,int __mhi_device_get_sync (struct mhi_controller *mhi_cntrl);int mhi_send_cmd (struct mhi_controller *mhi_cntrl,struct mhi_chan *mhi_chan,enum mhi_cmd_type cmd); +static inline bool mhi_is_active (struct mhi_controller *mhi_cntrl) +{ +return (mhi_cntrl->dev_state >=MHI_STATE_M0 && + mhi_cntrl->dev_state <=MHI_STATE_M3_FAST ); +}/* Register access methods */ void mhi_db_brstmode(struct mhi_controller *mhi_cntrl, struct db_cfg *db_cfg,
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v3 7/7 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 | 25 ++++++++++++++++ MAINTAINERS | 1 + drivers/bus/mhi/core/init.c | 53 ++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 Documentation/ABI/stable/sysfs-bus-mhi
Documentation/ABI/stable/sysfs-bus-mhi new file +25 -0
@@ -0,0 +1,25 @@ +What: /sys/bus/mhi/devices/.../serialnumber +Date: May 2020 +KernelVersion: 5.8 +Contact: Bhaumik Bhatt <[email protected]> +Description: + The file holds the serial number 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 the device + hardware information. + +What: /sys/bus/mhi/devices/.../oem_pk_hash +Date: May 2020 +KernelVersion: 5.8 +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 the device + hardware information.
MAINTAINERS +1 -0
@@ -11018,6 +11018,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
PATCH v3 5/7 bus: mhi: core: Introduce debugfs entries and counters for MHI
In reply to Bhaumik BhattIntroduce debugfs entries to show state, register, channel, and event ring information. Add MHI state counters to keep track of the state changes on the device. Also, allow the host to trigger a device reset, issue bus or device votes, and change the MHI timeout to help in debug.
--- drivers/bus/mhi/Kconfig | 8 + drivers/bus/mhi/core/Makefile | 5 +- drivers/bus/mhi/core/debugfs.c | 501 ++++++++++++++++++++++++++++++++++++++++ drivers/bus/mhi/core/init.c | 7 + drivers/bus/mhi/core/internal.h | 24 ++ drivers/bus/mhi/core/pm.c | 4 + include/linux/mhi.h | 4 + 7 files changed, 550 insertions(+), 3 deletions(-) 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 +2 -3
@@ -1,3 +1,2 @@ -obj-$(CONFIG_MHI_BUS) := mhi.o - -mhi-y := init.o main.o pm.o boot.o +obj-$(CONFIG_MHI_BUS) := init.o main.o pm.o boot.o +obj-$(CONFIG_MHI_BUS_DEBUG) += debugfs.o
drivers/bus/mhi/core/debugfs.c new file +501 -0
501 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);
@@ -1287,11 +1292,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);
drivers/bus/mhi/core/pm.c +4 -0
@@ -256,6 +256,7 @@ int mhi_pm_m0_transition(struct mhi_controller *mhi_cntrl)dev_err (dev,"Unable to transition to M0 state\n" );return -EIO ; } + mhi_cntrl->M0++;/* Wake up the device */ read_lock_bh (&mhi_cntrl->pm_lock);
@@ -326,6 +327,8 @@ void mhi_pm_m1_transition(struct mhi_controller *mhi_cntrl) mhi_cntrl->dev_state =MHI_STATE_M2 ;write_unlock_irq (&mhi_cntrl->pm_lock); + + mhi_cntrl->M2++;wake_up_all (&mhi_cntrl->state_event);/* If there are any pending resources, exit M2 immediately */
@@ -362,6 +365,7 @@ int mhi_pm_m3_transition(struct mhi_controller *mhi_cntrl)return -EIO ; } + mhi_cntrl->M3++;wake_up_all (&mhi_cntrl->state_event);return 0 ;
include/linux/mhi.h +4 -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
@@ -329,6 +330,7 @@ struct mhi_controller_config {* @dev_state: MHI device state * @dev_wake: Device wakeup count * @pending_pkts: Pending packets for the controller +* @M0, M2, M3, M3_fast: Counters to track number of device MHI state changes * @transition_list: List of MHI state transitions * @transition_lock: Lock for protecting MHI state transition list * @wlock: Lock for protecting device wakeup
@@ -367,6 +369,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;
@@ -408,6 +411,7 @@ struct mhi_controller {enum mhi_state dev_state;atomic_t dev_wake;atomic_t pending_pkts; +u32 M0 ,M2 ,M3 , M3_fast;struct list_head transition_list;spinlock_t transition_lock;spinlock_t wlock;
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v3 3/7 bus: mhi: core: Use generic name field for an MHI device
In reply to Bhaumik BhattAn MHI device is not necessarily associated with only channels as we can have one associated with the controller itself. Hence, the chan_name field within the mhi_device structure should instead be replaced with a generic name to accurately reflect any type of MHI device.
--- drivers/bus/mhi/core/init.c | 5 +++-- drivers/bus/mhi/core/main.c | 6 +++--- include/linux/mhi.h | 8 ++++---- 3 files changed, 10 insertions(+), 9 deletions(-)
drivers/bus/mhi/core/init.c +3 -2
@@ -904,6 +904,7 @@ int mhi_register_controller(struct mhi_controller *mhi_cntrl, mhi_dev->dev_type =MHI_DEVICE_CONTROLLER ; mhi_dev->mhi_cntrl = mhi_cntrl;dev_set_name (&mhi_dev->dev,"%s" ,dev_name (mhi_cntrl->cntrl_dev)); + mhi_dev->name =dev_name (mhi_cntrl->cntrl_dev);/* Init wakeup source */ device_init_wakeup (&mhi_dev->dev, true);
@@ -1252,7 +1253,7 @@ static int mhi_uevent(struct device *dev, struct kobj_uevent_env *env)struct mhi_device *mhi_dev =to_mhi_device (dev);return add_uevent_var (env,"MODALIAS=" MHI_DEVICE_MODALIAS_FMT , - mhi_dev->chan_name); + mhi_dev->name); }static int mhi_match (struct device *dev,struct device_driver *drv)
@@ -1269,7 +1270,7 @@ static int mhi_match(struct device *dev, struct device_driver *drv)return 0 ;for (id = mhi_drv->id_table; id->chan[0 ]; id++) -if (!strcmp (mhi_dev->chan_name, id->chan)) { +if (!strcmp (mhi_dev->name, id->chan)) { mhi_dev->id = id;return 1 ; }
drivers/bus/mhi/core/main.c +3 -3
@@ -249,7 +249,7 @@ int mhi_destroy_device(struct device *dev, void *data)put_device (&mhi_dev->dl_chan->mhi_dev->dev);dev_dbg (&mhi_cntrl->mhi_dev->dev,"destroy device for chan:%s\n" , - mhi_dev->chan_name); + mhi_dev->name);/* Notify the client and remove the device from MHI bus */ device_del (dev);
@@ -327,10 +327,10 @@ void mhi_create_devices(struct mhi_controller *mhi_cntrl) }/* Channel name is same for both UL and DL */ - mhi_dev->chan_name = mhi_chan->name; + mhi_dev->name = mhi_chan->name;dev_set_name (&mhi_dev->dev,"%s_%s" ,dev_name (mhi_cntrl->cntrl_dev), - mhi_dev->chan_name); + mhi_dev->name);/* Init wakeup source if available */ if (mhi_dev->dl_chan && mhi_dev->dl_chan->wake_capable)
include/linux/mhi.h +4 -4
@@ -439,10 +439,10 @@ struct mhi_controller { };/** -* struct mhi_device - Structure representing a MHI device which binds -* to channels +* struct mhi_device - Structure representing an MHI device which binds +* to channels or is associated with controllers * @id: Pointer to MHI device ID struct -* @chan_name: Name of the channel to which the device binds +* @name: Name of the associated MHI device * @mhi_cntrl: Controller the device belongs to * @ul_chan: UL channel for the device * @dl_chan: DL channel for the device
@@ -454,7 +454,7 @@ struct mhi_controller {*/ struct mhi_device {const struct mhi_device_id *id; -const char *chan_name; +const char *name;struct mhi_controller *mhi_cntrl;struct mhi_chan *ul_chan;struct mhi_chan *dl_chan;
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v3 2/7 bus: mhi: core: Introduce independent voting mechanism
In reply to Bhaumik BhattAllow independent votes from clients such that they can choose to vote for either the device or the bus or both. This helps in cases where the device supports autonomous low power mode wherein it can move to M2 state without the need to notify the host. Clients can also vote only to keep the underlying bus active without having the device in M0 state to support offload use cases.
--- drivers/bus/mhi/core/init.c | 15 ++++++---- drivers/bus/mhi/core/pm.c | 73 +++++++++++++++++++++++++++++++++------------ include/linux/mhi.h | 21 ++++++++----- 3 files changed, 77 insertions(+), 32 deletions(-)
drivers/bus/mhi/core/init.c +9 -6
@@ -1062,7 +1062,8 @@ struct mhi_device *mhi_alloc_device(struct mhi_controller *mhi_cntrl) dev->release = mhi_release_device; dev->parent = mhi_cntrl->cntrl_dev; mhi_dev->mhi_cntrl = mhi_cntrl; - mhi_dev->dev_wake =0 ; +atomic_set (&mhi_dev->dev_vote,0 ); +atomic_set (&mhi_dev->bus_vote,0 );return mhi_dev; }
@@ -1079,7 +1080,7 @@ static int mhi_driver_probe(struct device *dev)int ret;/* Bring device out of LPM */ - ret =mhi_device_get_sync (mhi_dev); + ret =mhi_device_get_sync (mhi_dev,MHI_VOTE_DEVICE );if (ret)return ret;
@@ -1139,14 +1140,14 @@ static int mhi_driver_probe(struct device *dev)if (dl_chan && dl_chan->auto_start)mhi_prepare_channel (mhi_cntrl, dl_chan); -mhi_device_put (mhi_dev); +mhi_device_put (mhi_dev,MHI_VOTE_DEVICE );return ret; exit_probe:mhi_unprepare_from_transfer (mhi_dev); -mhi_device_put (mhi_dev); +mhi_device_put (mhi_dev,MHI_VOTE_DEVICE );return ret; }
@@ -1215,8 +1216,10 @@ static int mhi_driver_remove(struct device *dev) }read_lock_bh (&mhi_cntrl->pm_lock); -while (mhi_dev->dev_wake) -mhi_device_put (mhi_dev); +while (atomic_read (&mhi_dev->dev_vote)) +mhi_device_put (mhi_dev,MHI_VOTE_DEVICE ); +while (atomic_read (&mhi_dev->bus_vote)) +mhi_device_put (mhi_dev,MHI_VOTE_BUS );read_unlock_bh (&mhi_cntrl->pm_lock);return 0 ;
drivers/bus/mhi/core/pm.c +54 -19
117 lines not on this page · raw message
include/linux/mhi.h +14 -7
@@ -16,6 +16,9 @@#include <linux/wait.h> #include <linux/workqueue.h> +#define MHI_VOTE_BUS BIT(0)/* do not disable the mhi bus */ +#define MHI_VOTE_DEVICE BIT(1)/* prevent mhi device from entering lpm */ +struct mhi_chan ;struct mhi_event ;struct mhi_ctxt ;
@@ -459,7 +462,8 @@ struct mhi_device {enum mhi_device_type dev_type;int ul_chan_id;int dl_chan_id; -u32 dev_wake; +atomic_t dev_vote; +atomic_t bus_vote; };/**
@@ -644,23 +648,26 @@ void mhi_set_mhi_state(struct mhi_controller *mhi_cntrl,enum mhi_state mhi_get_mhi_state (struct mhi_controller *mhi_cntrl);/** -* mhi_device_get - Disable device low power mode +* mhi_device_get - Disable device and/or bus low power mode * @mhi_dev: Device associated with the channel +* @vote: requested vote (bus, device or both) */ -void mhi_device_get (struct mhi_device *mhi_dev); +void mhi_device_get (struct mhi_device *mhi_dev,int vote);/** -* mhi_device_get_sync - Disable device low power mode. Synchronously +* mhi_device_get_sync - Disable device and/or bus low power mode. Synchronously * take the controller out of suspended state * @mhi_dev: Device associated with the channel +* @vote: requested vote (bus, device or both) */ -int mhi_device_get_sync (struct mhi_device *mhi_dev); +int mhi_device_get_sync (struct mhi_device *mhi_dev,int vote);/** -* mhi_device_put - Re-enable device low power mode +* mhi_device_put - Re-enable device and/or bus low power mode * @mhi_dev: Device associated with the channel +* @vote: vote(s) to remove (bus, device or both) */ -void mhi_device_put (struct mhi_device *mhi_dev); +void mhi_device_put (struct mhi_device *mhi_dev,int vote);/** * mhi_prepare_for_transfer - Setup channel for data transfer
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v3 6/7 bus: mhi: core: Read and save device hardware information from BHI
In reply to Bhaumik BhattDevice hardware specific information such as serial number and the OEM PK hash can be read using BHI and saved on host to identify the endpoint.
--- drivers/bus/mhi/core/boot.c | 17 ++++++++++++++++- include/linux/mhi.h | 6 ++++++ 2 files changed, 22 insertions(+), 1 deletion(-)
drivers/bus/mhi/core/boot.c +16 -1
@@ -392,13 +392,28 @@ void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl)void *buf;dma_addr_t dma_addr;size_t size; -int ret; +int i, ret;if (MHI_PM_IN_ERROR_STATE (mhi_cntrl->pm_state)) {dev_err (dev,"Device MHI is not in valid state\n" );return ; } +/* save hardware info from BHI */ + ret =mhi_read_reg (mhi_cntrl, mhi_cntrl->bhi,BHI_SERIALNU , + &mhi_cntrl->serial_number); +if (ret) +dev_err (dev,"Could not capture serial number via BHI\n" ); + +for (i =0 ; i <ARRAY_SIZE (mhi_cntrl->oem_pk_hash); i++) { + ret =mhi_read_reg (mhi_cntrl, mhi_cntrl->bhi,BHI_OEMPKHASH (i), + &mhi_cntrl->oem_pk_hash[i]); +if (ret) { +dev_err (dev,"Could not capture OEM PK HASH via BHI\n" ); +break ; + } + } +/* If device is in pass through, do reset to ready state transition */ if (mhi_cntrl->ee ==MHI_EE_PTHRU ) goto fw_load_ee_pthru;
include/linux/mhi.h +6 -0
@@ -19,6 +19,8 @@#define MHI_VOTE_BUS BIT(0)/* do not disable the mhi bus */ #define MHI_VOTE_DEVICE BIT(1)/* prevent mhi device from entering lpm */ +#define MHI_MAX_OEM_PK_HASH_SEGMENTS 16 +struct mhi_chan ;struct mhi_event ;struct mhi_ctxt ;
@@ -318,6 +320,8 @@ struct mhi_controller_config {* @device_number: MHI controller device number * @major_version: MHI controller major revision number * @minor_version: MHI controller minor revision number +* @serial_number: MHI controller serial number obtained from BHI +* @oem_pk_hash: MHI controller OEM PK Hash obtained from BHI * @mhi_event: MHI event ring configurations table * @mhi_cmd: MHI command ring configurations table * @mhi_ctxt: MHI device context, shared memory between host and device
@@ -397,6 +401,8 @@ struct mhi_controller {u32 device_number;u32 major_version;u32 minor_version; +u32 serial_number; +u32 oem_pk_hash[MHI_MAX_OEM_PK_HASH_SEGMENTS ];struct mhi_event *mhi_event;struct mhi_cmd *mhi_cmd;
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v3 1/7] bus: mhi: core: Abort suspends due to outgoing pending packets
In reply to Bhaumik BhattQuoted 7 lines · Bhaumik Bhatt
Add the missing check to abort suspends if a client has pending outgoing packets to send to the device. This allows better utilization of the MHI bus wherein clients on the host are not left waiting for longer suspend or resume cycles to finish for data transfers.
Signed-off-by Bhaumik Bhatt <[email protected]>---
Signature · 3 lines
Jeffrey Hugo Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Re: [PATCH v3 2/7] bus: mhi: core: Introduce independent voting mechanism
In reply to Bhaumik BhattQuoted 9 lines · Bhaumik Bhatt
Allow independent votes from clients such that they can choose to vote for either the device or the bus or both. This helps in cases where the device supports autonomous low power mode wherein it can move to M2 state without the need to notify the host. Clients can also vote only to keep the underlying bus active without having the device in M0 state to support offload use cases.
Signed-off-by Bhaumik Bhatt <[email protected]>---
I wonder, why doesn't this fit with runtimePM?
Signature · 3 lines
Jeffrey Hugo Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Re: [PATCH v3 2/7] bus: mhi: core: Introduce independent voting mechanism
Quoted 8 lines · Jeffrey Hugo
Quoted 7 lines · Bhaumik Bhatt
Allow independent votes from clients such that they can choose to vote for either the device or the bus or both. This helps in cases where the device supports autonomous low power mode wherein it can move to M2 state without the need to notify the host. Clients can also vote only to keep the underlying bus active without having the device in M0 state to support offload use cases.
Quoted 4 lines
Quoted 2 lines
Signed-off-by Bhaumik Bhatt <[email protected]>---
I wonder, why doesn't this fit with runtimePM?
Hi Jeff,
Can you elaborate?
In short, with this patch, MHI just wants to give controller the option to choose the vote type so we can implement autonomous low power mode entries on both host and device.
Let us know if you need some more information.
Thanks,
Bhaumik
Re: [PATCH v3 2/7] bus: mhi: core: Introduce independent voting mechanism
Quoted 12 lines · On 5/20/2020 12:43 PM, [email protected] wrote:
Quoted 11 lines · Jeffrey Hugo
Quoted 9 lines · Bhaumik Bhatt
Allow independent votes from clients such that they can choose to vote for either the device or the bus or both. This helps in cases where the device supports autonomous low power mode wherein it can move to M2 state without the need to notify the host. Clients can also vote only to keep the underlying bus active without having the device in M0 state to support offload use cases.
Signed-off-by Bhaumik Bhatt <[email protected]>---
Quoted 8 lines
Quoted 1 line
I wonder, why doesn't this fit with runtimePM?
Hi Jeff,
Can you elaborate?
In short, with this patch, MHI just wants to give controller the option to choose the vote type so we can implement autonomous low power mode entries on both host and device.
So, you are attempting to manage the power mode of the device. The standard mechanism to do so in Linux is runtime pm.
https://elixir.bootlin.com/linux/latest/source/Documentation/driver-api/pm/devices.rst
I'm no runtime pm expert, but it feels like your whole voting mechanism, etc is just reimplemeting that. Reimplementing the wheel, when its been a standard thing that the majority of the kernel uses is not usually acceptable.
IMO, you need some sort of justification why runtime pm is not applicable for you, because I'm willing to bet Mani/Greg are going to ask the same.
Signature · 3 lines
Jeffrey Hugo Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Re: [PATCH v3 2/7] bus: mhi: core: Introduce independent voting mechanism
Quoted 27 lines · Jeffrey Hugo
Quoted 12 lines · On 5/20/2020 12:43 PM, [email protected] wrote:
Quoted 11 lines · Jeffrey Hugo
Quoted 9 lines · Bhaumik Bhatt
Allow independent votes from clients such that they can choose to vote for either the device or the bus or both. This helps in cases where the device supports autonomous low power mode wherein it can move to M2 state without the need to notify the host. Clients can also vote only to keep the underlying bus active without having the device in M0 state to support offload use cases.
Signed-off-by Bhaumik Bhatt <[email protected]>---
Quoted 8 lines
Quoted 1 line
I wonder, why doesn't this fit with runtimePM?
Hi Jeff,
Can you elaborate?
In short, with this patch, MHI just wants to give controller the option to choose the vote type so we can implement autonomous low power mode entries on both host and device.
So, you are attempting to manage the power mode of the device. The standard mechanism to do so in Linux is runtime pm.
https://elixir.bootlin.com/linux/latest/source/Documentation/driver-api/pm/devices.rst
Quoted 8 lines
I'm no runtime pm expert, but it feels like your whole voting mechanism, etc is just reimplemeting that. Reimplementing the wheel, when its been a standard thing that the majority of the kernel uses is not usually acceptable.
IMO, you need some sort of justification why runtime pm is not applicable for you, because I'm willing to bet Mani/Greg are going to ask the same.
I think we can look at the patch as simply expanding the scope of what already exists.
The client here has been calling mhi_device_get/put/sync APIs to gain device vote and with new features yet to come in, this introductory change is only re-purposing what voting means going forward. i.e. allowing individual bus and device votes.
If you're suggesting using runtimePM APIs to replace the newly introduced bus vote, it would be kind of overkill here IMO. Is that what you were getting at? Because currently, we just have controllers use runtimePM and provide callbacks to them.
If you have ideas, we can discuss them.
Re: [PATCH v3 2/7] bus: mhi: core: Introduce independent voting mechanism
Quoted 43 lines · On 5/20/2020 1:44 PM, [email protected] wrote:
Quoted 28 lines · Jeffrey Hugo
Quoted 12 lines · On 5/20/2020 12:43 PM, [email protected] wrote:
Quoted 11 lines · Jeffrey Hugo
Quoted 9 lines · Bhaumik Bhatt
Allow independent votes from clients such that they can choose to vote for either the device or the bus or both. This helps in cases where the device supports autonomous low power mode wherein it can move to M2 state without the need to notify the host. Clients can also vote only to keep the underlying bus active without having the device in M0 state to support offload use cases.
Signed-off-by Bhaumik Bhatt <[email protected]>---
Quoted 8 lines
Quoted 1 line
I wonder, why doesn't this fit with runtimePM?
Hi Jeff,
Can you elaborate?
In short, with this patch, MHI just wants to give controller the option to choose the vote type so we can implement autonomous low power mode entries on both host and device.
So, you are attempting to manage the power mode of the device. The standard mechanism to do so in Linux is runtime pm.
https://elixir.bootlin.com/linux/latest/source/Documentation/driver-api/pm/devices.rst
Quoted 8 lines
I'm no runtime pm expert, but it feels like your whole voting mechanism, etc is just reimplemeting that. Reimplementing the wheel, when its been a standard thing that the majority of the kernel uses is not usually acceptable.
IMO, you need some sort of justification why runtime pm is not applicable for you, because I'm willing to bet Mani/Greg are going to ask the same.
I think we can look at the patch as simply expanding the scope of what already exists.
The client here has been calling mhi_device_get/put/sync APIs to gain device vote and with new features yet to come in, this introductory change is only re-purposing what voting means going forward. i.e. allowing individual bus and device votes.
Quoted 5 lines
If you're suggesting using runtimePM APIs to replace the newly introduced bus vote, it would be kind of overkill here IMO. Is that what you were getting at? Because currently, we just have controllers use runtimePM and provide callbacks to them.
If you have ideas, we can discuss them.
Ultimately, yes I think I am suggesting replacing this API with the runtime pm API.
As near as I can tell, if I'm a device driver on some other bus, and I want to keep my device alive because I'm doing a DMA to it or something, I would call pm_runtime_get(), and when I have confirmation my activity is done, I would use pm_runtime_put().
As near as I can tell, this is already plumbed into the bus framework, such that the MHI bus would get a callback when the device driver does that. In the MHI bus callback, you would be able to route the request as needed.
So, with this API (that has no consumers currently), I call pm_runtime_get() and also mhi_device_get()?
Signature · 3 lines
Jeffrey Hugo Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Hi,
Quoted 7 lines · Bhaumik Bhatt
Introduce independent bus and device voting mechanism for clients and save hardware information from BHI.
Allow reading and modifying some MHI variables for debug, test, and informational purposes using debugfs.
Read values for device specific hardware information to be used by OEMs in factory testing such as serial number and PK hash using sysfs.
I think this series is not yet ready. So will not merge any patches in this series for 5.8.
Or let me know if there are any independent patches which should get merged. I'm planning to send the final 5.8 series to Greg by Friday.
Thanks,
Mani
Quoted 43 lines
This set of patches was tested on arm64 and x86.
v3:
-Add patch to check for pending packets in suspend as a dependency for the independent voting mechanism introduction(quoted diff) +0
-5-Include register dump entry for debugfs to dump MHI, BHI, and BHIe registers -Update commit message for the debugfs patch -Updated Documentation/ABI with the required info for sysfs -Updated debugfs patch to include a new KConfig entry and dependencies -Updated reviewed-by for some patchesv2:
(quoted diff) +0
-3-Added a new debugfs.c file for specific debugfs entries and code -Updated commit text and addressed some comments for voting change -Made sure sysfs is only used for serial number and OEM PK hash usageBhaumik Bhatt (7):
bus: mhi: core: Abort suspends due to outgoing pending packets
bus: mhi: core: Introduce independent voting mechanism
bus: mhi: core: Use generic name field for an MHI device
bus: mhi: core: Introduce helper function to check device state
bus: mhi: core: Introduce debugfs entries and counters for MHI
bus: mhi: core: Read and save device hardware information from BHI
bus: mhi: core: Introduce sysfs entries for MHIDocumentation/ABI/stable/sysfs-bus-mhi | 25 ++ MAINTAINERS | 1 + drivers/bus/mhi/Kconfig | 8 + drivers/bus/mhi/core/Makefile | 5 +- drivers/bus/mhi/core/boot.c | 17 +- drivers/bus/mhi/core/debugfs.c | 501 +++++++++++++++++++++++++++++++++ drivers/bus/mhi/core/init.c | 80 +++++- drivers/bus/mhi/core/internal.h | 29 ++ drivers/bus/mhi/core/main.c | 6 +- drivers/bus/mhi/core/pm.c | 79 ++++-- include/linux/mhi.h | 39 ++- 11 files changed, 745 insertions(+), 45 deletions(-) create mode 100644 Documentation/ABI/stable/sysfs-bus-mhi create mode 100644 drivers/bus/mhi/core/debugfs.cSignature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 11 lines · Manivannan Sadhasivam
Hi,
Quoted 7 lines · Bhaumik Bhatt
Introduce independent bus and device voting mechanism for clients and save hardware information from BHI.
Allow reading and modifying some MHI variables for debug, test, and informational purposes using debugfs.
Read values for device specific hardware information to be used by OEMs in factory testing such as serial number and PK hash using sysfs.
Quoted 6 lines
I think this series is not yet ready. So will not merge any patches in this series for 5.8.
Or let me know if there are any independent patches which should get merged. I'm planning to send the final 5.8 series to Greg by Friday.
Sorry. I just realised that we are running out of time as we are ending rc6. So I've sent the 5.8 series to Greg.
Thanks,
Mani
Quoted 46 lines
Thanks,
ManiQuoted 43 lines
This set of patches was tested on arm64 and x86.
v3:
-Add patch to check for pending packets in suspend as a dependency for the independent voting mechanism introduction(quoted diff) +0
-5-Include register dump entry for debugfs to dump MHI, BHI, and BHIe registers -Update commit message for the debugfs patch -Updated Documentation/ABI with the required info for sysfs -Updated debugfs patch to include a new KConfig entry and dependencies -Updated reviewed-by for some patchesv2:
(quoted diff) +0
-3-Added a new debugfs.c file for specific debugfs entries and code -Updated commit text and addressed some comments for voting change -Made sure sysfs is only used for serial number and OEM PK hash usageBhaumik Bhatt (7):
bus: mhi: core: Abort suspends due to outgoing pending packets
bus: mhi: core: Introduce independent voting mechanism
bus: mhi: core: Use generic name field for an MHI device
bus: mhi: core: Introduce helper function to check device state
bus: mhi: core: Introduce debugfs entries and counters for MHI
bus: mhi: core: Read and save device hardware information from BHI
bus: mhi: core: Introduce sysfs entries for MHIDocumentation/ABI/stable/sysfs-bus-mhi | 25 ++ MAINTAINERS | 1 + drivers/bus/mhi/Kconfig | 8 + drivers/bus/mhi/core/Makefile | 5 +- drivers/bus/mhi/core/boot.c | 17 +- drivers/bus/mhi/core/debugfs.c | 501 +++++++++++++++++++++++++++++++++ drivers/bus/mhi/core/init.c | 80 +++++- drivers/bus/mhi/core/internal.h | 29 ++ drivers/bus/mhi/core/main.c | 6 +- drivers/bus/mhi/core/pm.c | 79 ++++-- include/linux/mhi.h | 39 ++- 11 files changed, 745 insertions(+), 45 deletions(-) create mode 100644 Documentation/ABI/stable/sysfs-bus-mhi create mode 100644 drivers/bus/mhi/core/debugfs.cSignature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 63 lines · Manivannan Sadhasivam
Hi,
Quoted 7 lines · Bhaumik Bhatt
Introduce independent bus and device voting mechanism for clients and save hardware information from BHI.
Allow reading and modifying some MHI variables for debug, test, and informational purposes using debugfs.
Read values for device specific hardware information to be used by OEMs in factory testing such as serial number and PK hash using sysfs.I think this series is not yet ready. So will not merge any patches in this series for 5.8.
Or let me know if there are any independent patches which should get merged. I'm planning to send the final 5.8 series to Greg by Friday.
Thanks,
ManiQuoted 43 lines
This set of patches was tested on arm64 and x86.
v3:
-Add patch to check for pending packets in suspend as a dependency for the
independent voting mechanism introduction
-Include register dump entry for debugfs to dump MHI, BHI, and BHIe registers(quoted diff) +0
-4-Update commit message for the debugfs patch -Updated Documentation/ABI with the required info for sysfs -Updated debugfs patch to include a new KConfig entry and dependencies -Updated reviewed-by for some patchesv2:
(quoted diff) +0
-3-Added a new debugfs.c file for specific debugfs entries and code -Updated commit text and addressed some comments for voting change -Made sure sysfs is only used for serial number and OEM PK hash usageBhaumik Bhatt (7):
bus: mhi: core: Abort suspends due to outgoing pending packets
bus: mhi: core: Introduce independent voting mechanism
bus: mhi: core: Use generic name field for an MHI device
bus: mhi: core: Introduce helper function to check device state
bus: mhi: core: Introduce debugfs entries and counters for MHI
bus: mhi: core: Read and save device hardware information from BHI
bus: mhi: core: Introduce sysfs entries for MHIDocumentation/ABI/stable/sysfs-bus-mhi | 25 ++ MAINTAINERS | 1 + drivers/bus/mhi/Kconfig | 8 + drivers/bus/mhi/core/Makefile | 5 +- drivers/bus/mhi/core/boot.c | 17 +- drivers/bus/mhi/core/debugfs.c | 501 +++++++++++++++++++++++++++++++++ drivers/bus/mhi/core/init.c | 80 +++++- drivers/bus/mhi/core/internal.h | 29 ++ drivers/bus/mhi/core/main.c | 6 +- drivers/bus/mhi/core/pm.c | 79 ++++-- include/linux/mhi.h | 39 ++- 11 files changed, 745 insertions(+), 45 deletions(-) create mode 100644 Documentation/ABI/stable/sysfs-bus-mhi create mode 100644 drivers/bus/mhi/core/debugfs.c
Quoted 3 lines
Quoted 3 lines
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Hi Mani,
These are patches already reviewed, small and important and good to go:
bus: mhi: core: Abort suspends due to outgoing pending packets
bus: mhi: core: Use generic name field for an MHI device
bus: mhi: core: Introduce helper function to check device state
bus: mhi: core: Read and save device hardware information from BHI
Please let us know if you have any concerns.
Thanks,
Bhaumik
Re: [PATCH v3 5/7] bus: mhi: core: Introduce debugfs entries and counters for MHI
In reply to Bhaumik Bhattdrivers/bus/mhi/core/debugfs.c line 459
Quoted 4 lines · Bhaumik Bhatt
drivers/bus/mhi/core/debugfs.c new file +4
-0+void mhi_create_debugfs (struct mhi_controller *mhi_cntrl) +{ +if (IS_ERR_OR_NULL (mhi_debugfs_root)) +return ;
Why? Should not matter.
drivers/bus/mhi/core/debugfs.c line 465
Quoted 5 lines
drivers/bus/mhi/core/debugfs.c new file +5
-0+ mhi_cntrl->debugfs_dentry = +debugfs_create_dir (dev_name (mhi_cntrl->cntrl_dev), + mhi_debugfs_root); +if (IS_ERR_OR_NULL (mhi_cntrl->debugfs_dentry)) +return ;
No need for this check either, just call debugfs and keep on moving :)
thanks,
greg k-h