Linux-ARM-MSM Archive on lore.kernel.org
 help / color / Atom feed
From: Bhaumik Bhatt <bbhatt@codeaurora.org>
To: manivannan.sadhasivam@linaro.org
Cc: linux-arm-msm@vger.kernel.org, hemantk@codeaurora.org,
	jhugo@codeaurora.org, linux-kernel@vger.kernel.org,
	Bhaumik Bhatt <bbhatt@codeaurora.org>
Subject: [PATCH v6 07/11] bus: mhi: core: Introduce counters to track MHI device state transitions
Date: Mon, 27 Jul 2020 19:02:16 -0700
Message-ID: <1595901740-27379-8-git-send-email-bbhatt@codeaurora.org> (raw)
In-Reply-To: <1595901740-27379-1-git-send-email-bbhatt@codeaurora.org>

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.

Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
---
 drivers/bus/mhi/core/pm.c | 4 ++++
 include/linux/mhi.h       | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/drivers/bus/mhi/core/pm.c b/drivers/bus/mhi/core/pm.c
index 27bb471..ce4d969 100644
--- a/drivers/bus/mhi/core/pm.c
+++ b/drivers/bus/mhi/core/pm.c
@@ -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;
diff --git a/include/linux/mhi.h b/include/linux/mhi.h
index a8379b3..e38de6d 100644
--- a/include/linux/mhi.h
+++ b/include/linux/mhi.h
@@ -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, 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
@@ -407,6 +408,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;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


  parent reply index

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-28  2:02 [PATCH v6 00/11] Introduce features and debugfs/sysfs entries for MHI Bhaumik Bhatt
2020-07-28  2:02 ` [PATCH v6 01/11] bus: mhi: core: Remove double occurrence for mhi_ctrl_ev_task() declaration Bhaumik Bhatt
2020-07-28  2:02 ` [PATCH v6 02/11] bus: mhi: core: Abort suspends due to outgoing pending packets Bhaumik Bhatt
2020-07-28  2:02 ` [PATCH v6 03/11] bus: mhi: core: Use helper API to trigger a non-blocking host resume Bhaumik Bhatt
2020-07-28  2:02 ` [PATCH v6 04/11] bus: mhi: core: Trigger host resume if suspended during mhi_device_get() Bhaumik Bhatt
2020-07-28  2:02 ` [PATCH v6 05/11] bus: mhi: core: Use generic name field for an MHI device Bhaumik Bhatt
2020-07-28  2:02 ` [PATCH v6 06/11] bus: mhi: core: Introduce helper function to check device state Bhaumik Bhatt
2020-07-28  2:02 ` Bhaumik Bhatt [this message]
2020-08-07  5:13   ` [PATCH v6 07/11] bus: mhi: core: Introduce counters to track MHI device state transitions Manivannan Sadhasivam
2020-07-28  2:02 ` [PATCH v6 08/11] bus: mhi: core: Introduce debugfs entries for MHI Bhaumik Bhatt
2020-08-01  7:08   ` kernel test robot
2020-07-28  2:02 ` [PATCH v6 09/11] bus: mhi: core: Read and save device hardware information from BHI Bhaumik Bhatt
2020-07-28  2:02 ` [PATCH v6 10/11] bus: mhi: core: Introduce APIs to allocate and free the MHI controller Bhaumik Bhatt
2020-08-07  5:15   ` Manivannan Sadhasivam
2020-07-28  2:02 ` [PATCH v6 11/11] bus: mhi: core: Introduce sysfs entries for MHI Bhaumik Bhatt
2020-08-07  5:22   ` Manivannan Sadhasivam
2020-08-10 19:11     ` bbhatt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1595901740-27379-8-git-send-email-bbhatt@codeaurora.org \
    --to=bbhatt@codeaurora.org \
    --cc=hemantk@codeaurora.org \
    --cc=jhugo@codeaurora.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manivannan.sadhasivam@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-ARM-MSM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-msm/0 linux-arm-msm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-msm linux-arm-msm/ https://lore.kernel.org/linux-arm-msm \
		linux-arm-msm@vger.kernel.org
	public-inbox-index linux-arm-msm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-arm-msm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git