bus: mhi: core: Introduce counters to track MHI device state transitions
authorBhaumik Bhatt <bbhatt@codeaurora.org>
Tue, 29 Sep 2020 17:52:07 +0000 (23:22 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 2 Oct 2020 09:33:47 +0000 (11:33 +0200)
Use counters to track MHI device state transitions such as those
to M0, M2, or M3 states. This can help in better debug, allowing
the user to see the number of transitions to a certain MHI state
when queried using debugfs entries or via other mechanisms.

Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Link: https://lore.kernel.org/r/20200929175218.8178-9-manivannan.sadhasivam@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/bus/mhi/core/pm.c
include/linux/mhi.h

index 27bb471c8f4eb6e12d42eb1e4c45b39b7c65da2a..ce4d969818b4e52cf5f2be347e234f3e8fb3e78b 100644 (file)
@@ -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;
index bb337d163dda2d547d7132d56fae7183ce47ae7b..c56b4447a4e9993fe609f3965fb1bdb69871d89c 100644 (file)
@@ -328,6 +328,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: 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
@@ -407,6 +408,7 @@ struct mhi_controller {
        enum mhi_state dev_state;
        atomic_t dev_wake;
        atomic_t pending_pkts;
+       u32 M0, M2, M3;
        struct list_head transition_list;
        spinlock_t transition_lock;
        spinlock_t wlock;