mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sricharan Ramabadhran <quic_srichara@quicinc.com>
To: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>,
	<andersson@kernel.org>, <lpieralisi@kernel.org>, <kw@linux.com>,
	<krzysztof.kozlowski+dt@linaro.org>, <robh@kernel.org>
Cc: <konrad.dybcio@linaro.org>, <linux-arm-msm@vger.kernel.org>,
	<devicetree@vger.kernel.org>, <linux-pci@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 17/17] PCI: qcom: Expose link transition counts via debugfs
Date: Thu, 9 Mar 2023 17:21:38 +0530	[thread overview]
Message-ID: <73269ad0-5662-519c-f6c0-e5e2f918cd4e@quicinc.com> (raw)
In-Reply-To: <20230309085102.120977-18-manivannan.sadhasivam@linaro.org>



On 3/9/2023 2:21 PM, Manivannan Sadhasivam wrote:
> Qualcomm PCIe controllers have debug registers in the MHI region that
> count PCIe link transitions. Expose them over debugfs to userspace to
> help debug the low power issues.
> 
> Note that even though the registers are prefixed as PARF_, they don't
> live under the "parf" register region. The register naming is following
> the Qualcomm's internal documentation as like other registers.
> 
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> ---
>   drivers/pci/controller/dwc/pcie-qcom.c | 59 ++++++++++++++++++++++++++
>   1 file changed, 59 insertions(+)
> 
> diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c
> index e1180c84f0fa..6d9bde64c9e9 100644
> --- a/drivers/pci/controller/dwc/pcie-qcom.c
> +++ b/drivers/pci/controller/dwc/pcie-qcom.c
> @@ -10,6 +10,7 @@
>   
>   #include <linux/clk.h>
>   #include <linux/crc8.h>
> +#include <linux/debugfs.h>
>   #include <linux/delay.h>
>   #include <linux/gpio/consumer.h>
>   #include <linux/interconnect.h>
> @@ -62,6 +63,13 @@
>   #define AXI_MSTR_RESP_COMP_CTRL1		0x81c
>   #define MISC_CONTROL_1_REG			0x8bc
>   
> +/* MHI registers */
> +#define PARF_DEBUG_CNT_PM_LINKST_IN_L2		0xc04
> +#define PARF_DEBUG_CNT_PM_LINKST_IN_L1		0xc0c
> +#define PARF_DEBUG_CNT_PM_LINKST_IN_L0S		0xc10
> +#define PARF_DEBUG_CNT_AUX_CLK_IN_L1SUB_L1	0xc84
> +#define PARF_DEBUG_CNT_AUX_CLK_IN_L1SUB_L2	0xc88
> +
>   /* PARF_SYS_CTRL register fields */
>   #define MAC_PHY_POWERDOWN_IN_P2_D_MUX_EN	BIT(29)
>   #define MST_WAKEUP_EN				BIT(13)
> @@ -229,11 +237,13 @@ struct qcom_pcie {
>   	struct dw_pcie *pci;
>   	void __iomem *parf;			/* DT parf */
>   	void __iomem *elbi;			/* DT elbi */
> +	void __iomem *mhi;
>   	union qcom_pcie_resources res;
>   	struct phy *phy;
>   	struct gpio_desc *reset;
>   	struct icc_path *icc_mem;
>   	const struct qcom_pcie_cfg *cfg;
> +	struct dentry *debugfs;
>   };
>   
>   #define to_qcom_pcie(x)		dev_get_drvdata((x)->dev)
> @@ -1385,6 +1395,37 @@ static void qcom_pcie_icc_update(struct qcom_pcie *pcie)
>   	}
>   }
>   
> +static int qcom_pcie_link_transition_count(struct seq_file *s, void *data)
> +{
> +	struct qcom_pcie *pcie = (struct qcom_pcie *)
> +				     dev_get_drvdata(s->private);
> +
> +	seq_printf(s, "L0s transition count: %u\n",
> +		   readl_relaxed(pcie->mhi + PARF_DEBUG_CNT_PM_LINKST_IN_L0S));
> +
> +	seq_printf(s, "L1 transition count: %u\n",
> +		   readl_relaxed(pcie->mhi + PARF_DEBUG_CNT_PM_LINKST_IN_L1));
> +
> +	seq_printf(s, "L1.1 transition count: %u\n",
> +		   readl_relaxed(pcie->mhi + PARF_DEBUG_CNT_AUX_CLK_IN_L1SUB_L1));
> +
> +	seq_printf(s, "L1.2 transition count: %u\n",
> +		   readl_relaxed(pcie->mhi + PARF_DEBUG_CNT_AUX_CLK_IN_L1SUB_L2));
> +
> +	seq_printf(s, "L2 transition count: %u\n",
> +		   readl_relaxed(pcie->mhi + PARF_DEBUG_CNT_PM_LINKST_IN_L2));
> +
> +	return 0;
> +}
> +
> +static void qcom_pcie_init_debugfs(struct qcom_pcie *pcie)
> +{
> +	struct dw_pcie *pci = pcie->pci;
> +
> +	debugfs_create_devm_seqfile(pci->dev, "link_transition_count", pcie->debugfs,
> +				    qcom_pcie_link_transition_count);
> +}
> +
>   static int qcom_pcie_probe(struct platform_device *pdev)
>   {
>   	struct device *dev = &pdev->dev;
> @@ -1392,6 +1433,7 @@ static int qcom_pcie_probe(struct platform_device *pdev)
>   	struct dw_pcie *pci;
>   	struct qcom_pcie *pcie;
>   	const struct qcom_pcie_cfg *pcie_cfg;
> +	char *name;
>   	int ret;
>   
>   	pcie_cfg = of_device_get_match_data(dev);
> @@ -1439,6 +1481,12 @@ static int qcom_pcie_probe(struct platform_device *pdev)
>   		goto err_pm_runtime_put;
>   	}
>   
> +	pcie->mhi = devm_platform_ioremap_resource_byname(pdev, "mhi");
> +	if (IS_ERR(pcie->mhi)) {
> +		ret = PTR_ERR(pcie->mhi);
> +		goto err_pm_runtime_put;
> +	}
> +

  Tested this series on ipq4019-ap.dk07.1-c1 board and the above hunk
  breaks enumeration because there is no 'mhi' region. All the debug bits
  used in the transition_count function is inside the PARF_STTS register
  at offset 0x24 inside the PARF region.

  Register: PCIE_0_PCIE20_PARF_PM_STTS | 0x80024
  Offset:    0x24    Reset State:    0x00040000

Bits    Field Name
31    LINK_REQ_RST_NOT
30    XMLH_LINK_UP
29    PM_DSTATE_0
0x0: D0
0x1: D3
28    PHYSTATUS
27:16    PM_DSTATE
15:12    PM_PME_EN
11    PHYCLK_REQ_N
10    L1SS_CLKREQN_OE
9    L1SS_CLKREQN_IN
8    PM_LINKST_IN_L1SUB
7    PM_LINKST_IN_L0S
6    PM_LINKST_L2_EXIT
5    PM_LINKST_IN_L2
4    PM_LINKST_IN_L1
3:0    PM_STATUS

Otherwise, with rest of the patches enumeration was fine.
Tested with a pcie ethernet adapter.

Regards,
  Sricharan

  reply	other threads:[~2023-03-09 11:52 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-09  8:50 [PATCH v2 00/17] Qcom PCIe cleanups and improvements Manivannan Sadhasivam
2023-03-09  8:50 ` [PATCH v2 01/17] PCI: qcom: Remove PCIE20_ prefix from register definitions Manivannan Sadhasivam
2023-03-09  8:50 ` [PATCH v2 02/17] PCI: qcom: Sort and group registers and bitfield definitions Manivannan Sadhasivam
2023-03-09  8:50 ` [PATCH v2 03/17] PCI: qcom: Use bitfield definitions for register fields Manivannan Sadhasivam
2023-03-09  8:50 ` [PATCH v2 04/17] PCI: qcom: Add missing macros " Manivannan Sadhasivam
2023-03-09  8:50 ` [PATCH v2 05/17] PCI: qcom: Use lower case for hex Manivannan Sadhasivam
2023-03-09  8:50 ` [PATCH v2 06/17] PCI: qcom: Use bulk reset APIs for handling resets for IP rev 2.1.0 Manivannan Sadhasivam
2023-03-09  8:50 ` [PATCH v2 07/17] PCI: qcom: Use bulk clock APIs for handling clocks for IP rev 1.0.0 Manivannan Sadhasivam
2023-03-09  8:50 ` [PATCH v2 08/17] PCI: qcom: Use bulk clock APIs for handling clocks for IP rev 2.3.2 Manivannan Sadhasivam
2023-03-09  8:50 ` [PATCH v2 09/17] PCI: qcom: Use bulk clock APIs for handling clocks for IP rev 2.3.3 Manivannan Sadhasivam
2023-03-09  8:50 ` [PATCH v2 10/17] PCI: qcom: Use bulk reset APIs for handling resets " Manivannan Sadhasivam
2023-03-09  8:50 ` [PATCH v2 11/17] PCI: qcom: Use bulk reset APIs for handling resets for IP rev 2.4.0 Manivannan Sadhasivam
2023-03-09  8:50 ` [PATCH v2 12/17] PCI: qcom: Use macros for defining total no. of clocks & supplies Manivannan Sadhasivam
2023-03-09  8:50 ` [PATCH v2 13/17] dt-bindings: PCI: qcom: Add "mhi" register region to supported SoCs Manivannan Sadhasivam
2023-03-09  8:50 ` [PATCH v2 14/17] arm64: dts: qcom: sdm845: Add "mhi" region to the PCIe nodes Manivannan Sadhasivam
2023-03-09  8:51 ` [PATCH v2 15/17] arm64: dts: qcom: sm8250: " Manivannan Sadhasivam
2023-03-09  8:51 ` [PATCH v2 16/17] arm64: dts: qcom: sc8280xp: " Manivannan Sadhasivam
2023-03-09  8:51 ` [PATCH v2 17/17] PCI: qcom: Expose link transition counts via debugfs Manivannan Sadhasivam
2023-03-09 11:51   ` Sricharan Ramabadhran [this message]
2023-03-09 14:53     ` Manivannan Sadhasivam

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=73269ad0-5662-519c-f6c0-e5e2f918cd4e@quicinc.com \
    --to=quic_srichara@quicinc.com \
    --cc=andersson@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=konrad.dybcio@linaro.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=kw@linux.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=robh@kernel.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®