Message ID | 20230310040816.22094-20-manivannan.sadhasivam@linaro.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp680493wrd; Thu, 9 Mar 2023 20:29:06 -0800 (PST) X-Google-Smtp-Source: AK7set9qghtymnFbyxypz1CDmWppDmTeGdk0aTBgXw2bX+qiH/Sce0qvCwtt+7VspkEbeqhkiPu+ X-Received: by 2002:a05:6a21:9992:b0:cd:2ed3:b7f8 with SMTP id ve18-20020a056a21999200b000cd2ed3b7f8mr26830345pzb.40.1678422546285; Thu, 09 Mar 2023 20:29:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678422546; cv=none; d=google.com; s=arc-20160816; b=KsSfoz1NpVwtnnRtFOvlx9ciStg3KZBMaoJKyiUJYQaq9tcLVGXiRMnSiCi8YzQlZm urMoCWqkNZ9PWswGUP0Z2TSRDDbQ1uUpYpt47poP+TkfC7Q9iXqNxHUXcN395wkrF9Wj ShtyoQgTpAB7V2IJi0dAkJcYvGoiVTio8W+7NV9Entilo14LvnQmfXQbI8to01nJp0NR mXxWCD0fY7c7Uv8Jj6x2zgcLsMSunMt0C4YUn0/uMMwLWodHweb2xazK9ba6n2ZXX26E EBaa1HP9jvErJRFPasriamAQuevHR2koq/NnMRpoTrEw43b4BuTkRslDLLEXx4Biszkh M2Ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Cfp/acTiWdK8wUm8C9dXVBGQPGUivfzPYcratFFfeXU=; b=XfG9NKcvD10r2ZqnZVHRuRX9WS10lNQxqWLqAgM+dnqeJVhJ/t2/npEDBUV107oe7c 0ht26IDzDZs6n4XPDewB8wz8yyQcKwNVydd7vibqRUvF7fR7ENjWwyMzNLVcetQkeQ7Z 5tDYC1iTNHMkNLozJpbEabDh2Dza5ka7rzJfEqkLhCnk1xbWFhx8M1FyIRGTrhQXpZUj nu2SPbZuDBqBGtyJ6nGAyNz7XELvF7R6d+mz6JHpMCIScZ/ncDXluy0pw1CbX7ruNKFv z1Kelw0HAXkO/yzMOf/tLEckrkqZ64FJDIoT1O4a+InmrW7QG6lNeJqPxCcu70Z6vlPa PSkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IS3acGy5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a8-20020a63d408000000b00502ffff6533si970207pgh.88.2023.03.09.20.28.53; Thu, 09 Mar 2023 20:29:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IS3acGy5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230337AbjCJEMn (ORCPT <rfc822;carlos.wei.hk@gmail.com> + 99 others); Thu, 9 Mar 2023 23:12:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230251AbjCJELO (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 9 Mar 2023 23:11:14 -0500 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92AFA103EE1 for <linux-kernel@vger.kernel.org>; Thu, 9 Mar 2023 20:09:57 -0800 (PST) Received: by mail-pl1-x632.google.com with SMTP id v11so4297360plz.8 for <linux-kernel@vger.kernel.org>; Thu, 09 Mar 2023 20:09:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678421392; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Cfp/acTiWdK8wUm8C9dXVBGQPGUivfzPYcratFFfeXU=; b=IS3acGy5v+D1VrXLpVM4lVMitkBA6ZuCnc6t6WwzHNiDo99e6PL6fuhKYY/+Yq/yMZ LdZat7BftgHuO2RraexQ1g77BV+Iz7iCa5UrrspEL6OT7wykulaC0h6Yd4h/JTBCz30J FCSJMwZARxsKLBmXk5AzY9vcsd7hnx9Q47KT+pLYE0FOJEArcER7cOWmMZP6K9zgbs15 KJSMQv5e+JhI+WA4xdf1Yfxy1dDLvzbSMhivgV8JqxUd86wnhq6JfNkZ/XnrI77uK0+W 0kQ1oFhSV33XY1D0/YTfp42tBnyEsgYoxF6R8pAELjDFhsnAHB9hv9R6Vh6vSROBErEE 62KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678421392; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Cfp/acTiWdK8wUm8C9dXVBGQPGUivfzPYcratFFfeXU=; b=bMURQ9o1Aq4OzVT+dN+mk/iEP5XFvoQ5Lhkl4cO8VpGnwYzSCgt5iUfgdGR+uF0nCH 6n6XYuMDi19mf6rppwPuRSlyIS69GQ5bPMWyUmOI37zZ1yCumAyDU1Ph7cU30C2ngpCj U1wshPPBWoepWzvk5vl5QjsJ2U2nFxOio8uraJ+T4kNGpgk2ti+jis0RbcNHTp+Ry45m Ay+C9WAm842FppABSA26wcYftf65FcvNh2rosdw851hSobdZ4yoqqfbOsju6ayWaKlzr l4XavnilPuGSz2WgpKi0SY+3Le5T3W/7ewKsaFY3T3014Kr+6x/YUzCMlf3J8pruMaCd iugw== X-Gm-Message-State: AO0yUKUZbfkbLHBd+ZVLc1vH2Q6R+0FkUD/0pPzdyxEmWiNHD8bFgi+R PoedMx1ZIAv8LQKZF6XiWdvK X-Received: by 2002:a05:6a20:548a:b0:cc:d891:b2b1 with SMTP id i10-20020a056a20548a00b000ccd891b2b1mr31419746pzk.35.1678421392094; Thu, 09 Mar 2023 20:09:52 -0800 (PST) Received: from localhost.localdomain ([27.111.75.67]) by smtp.gmail.com with ESMTPSA id y26-20020aa7855a000000b0058d92d6e4ddsm361846pfn.5.2023.03.09.20.09.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 20:09:51 -0800 (PST) From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> To: 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, quic_srichara@quicinc.com, Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> Subject: [PATCH v3 19/19] PCI: qcom: Expose link transition counts via debugfs for v2.4.0 Date: Fri, 10 Mar 2023 09:38:16 +0530 Message-Id: <20230310040816.22094-20-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230310040816.22094-1-manivannan.sadhasivam@linaro.org> References: <20230310040816.22094-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759953600043730754?= X-GMAIL-MSGID: =?utf-8?q?1759953600043730754?= |
Series |
Qcom PCIe cleanups and improvements
|
|
Commit Message
Manivannan Sadhasivam
March 10, 2023, 4:08 a.m. UTC
Qualcomm PCIe controllers of version v2.4.0 have debug registers in the
PARF region that count PCIe link transitions. Expose them over debugfs to
userspace to help debug the low power issues.
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
drivers/pci/controller/dwc/pcie-qcom.c | 33 ++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
Comments
On 3/10/2023 9:38 AM, Manivannan Sadhasivam wrote: > Qualcomm PCIe controllers of version v2.4.0 have debug registers in the > PARF region that count PCIe link transitions. Expose them over debugfs to > userspace to help debug the low power issues. > > Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> > --- > drivers/pci/controller/dwc/pcie-qcom.c | 33 ++++++++++++++++++++++++++ > 1 file changed, 33 insertions(+) > > diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c > index f99b7e7f3f73..0b41f007fa90 100644 > --- a/drivers/pci/controller/dwc/pcie-qcom.c > +++ b/drivers/pci/controller/dwc/pcie-qcom.c > @@ -37,6 +37,7 @@ > /* PARF registers */ > #define PARF_SYS_CTRL 0x00 > #define PARF_PM_CTRL 0x20 > +#define PARF_PM_STTS 0x24 > #define PARF_PCS_DEEMPH 0x34 > #define PARF_PCS_SWING 0x38 > #define PARF_PHY_CTRL 0x40 > @@ -84,6 +85,12 @@ > /* PARF_PM_CTRL register fields */ > #define REQ_NOT_ENTR_L1 BIT(5) > > +/* PARF_PM_STTS register fields */ > +#define PM_LINKST_IN_L1SUB BIT(8) > +#define PM_LINKST_IN_L0S BIT(7) > +#define PM_LINKST_IN_L2 BIT(5) > +#define PM_LINKST_IN_L1 BIT(4) > + > /* PARF_PCS_DEEMPH register fields */ > #define PCS_DEEMPH_TX_DEEMPH_GEN1(x) FIELD_PREP(GENMASK(21, 16), x) > #define PCS_DEEMPH_TX_DEEMPH_GEN2_3_5DB(x) FIELD_PREP(GENMASK(13, 8), x) > @@ -737,6 +744,31 @@ static int qcom_pcie_post_init_2_4_0(struct qcom_pcie *pcie) > return 0; > } > > +static int qcom_pcie_debugfs_func_2_4_0(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->parf + PM_LINKST_IN_L0S)); > + > + seq_printf(s, "L1 transition count: %u\n", > + readl_relaxed(pcie->parf + PM_LINKST_IN_L1)); > + > + seq_printf(s, "L1.1 transition count: %u\n", > + readl_relaxed(pcie->parf + PM_LINKST_IN_L1SUB)); > + > + seq_printf(s, "L2 transition count: %u\n", > + readl_relaxed(pcie->parf + PM_LINKST_IN_L2)); > + Using bitmask as register offset ? instead use PM_STTS and bitmask it ? Regards, Sricharan
On 3/14/2023 4:06 PM, Sricharan Ramabadhran wrote: > > > On 3/10/2023 9:38 AM, Manivannan Sadhasivam wrote: >> Qualcomm PCIe controllers of version v2.4.0 have debug registers in the >> PARF region that count PCIe link transitions. Expose them over debugfs to >> userspace to help debug the low power issues. >> >> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> >> --- >> drivers/pci/controller/dwc/pcie-qcom.c | 33 ++++++++++++++++++++++++++ >> 1 file changed, 33 insertions(+) >> >> diff --git a/drivers/pci/controller/dwc/pcie-qcom.c >> b/drivers/pci/controller/dwc/pcie-qcom.c >> index f99b7e7f3f73..0b41f007fa90 100644 >> --- a/drivers/pci/controller/dwc/pcie-qcom.c >> +++ b/drivers/pci/controller/dwc/pcie-qcom.c >> @@ -37,6 +37,7 @@ >> /* PARF registers */ >> #define PARF_SYS_CTRL 0x00 >> #define PARF_PM_CTRL 0x20 >> +#define PARF_PM_STTS 0x24 >> #define PARF_PCS_DEEMPH 0x34 >> #define PARF_PCS_SWING 0x38 >> #define PARF_PHY_CTRL 0x40 >> @@ -84,6 +85,12 @@ >> /* PARF_PM_CTRL register fields */ >> #define REQ_NOT_ENTR_L1 BIT(5) >> +/* PARF_PM_STTS register fields */ >> +#define PM_LINKST_IN_L1SUB BIT(8) >> +#define PM_LINKST_IN_L0S BIT(7) >> +#define PM_LINKST_IN_L2 BIT(5) >> +#define PM_LINKST_IN_L1 BIT(4) >> + >> /* PARF_PCS_DEEMPH register fields */ >> #define PCS_DEEMPH_TX_DEEMPH_GEN1(x) FIELD_PREP(GENMASK(21, >> 16), x) >> #define PCS_DEEMPH_TX_DEEMPH_GEN2_3_5DB(x) FIELD_PREP(GENMASK(13, >> 8), x) >> @@ -737,6 +744,31 @@ static int qcom_pcie_post_init_2_4_0(struct >> qcom_pcie *pcie) >> return 0; >> } >> +static int qcom_pcie_debugfs_func_2_4_0(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->parf + PM_LINKST_IN_L0S)); >> + >> + seq_printf(s, "L1 transition count: %u\n", >> + readl_relaxed(pcie->parf + PM_LINKST_IN_L1)); >> + >> + seq_printf(s, "L1.1 transition count: %u\n", >> + readl_relaxed(pcie->parf + PM_LINKST_IN_L1SUB)); >> + >> + seq_printf(s, "L2 transition count: %u\n", >> + readl_relaxed(pcie->parf + PM_LINKST_IN_L2)); >> + > > Using bitmask as register offset ? instead use PM_STTS and bitmask it ? Also, since its 1 bit, all are status and not count. Not sure, if you want it to limit this debug based on 'mhi' property being populated ? Regards, Sricharan
On Tue, Mar 14, 2023 at 04:25:29PM +0530, Sricharan Ramabadhran wrote: > > > On 3/14/2023 4:06 PM, Sricharan Ramabadhran wrote: > > > > > > On 3/10/2023 9:38 AM, Manivannan Sadhasivam wrote: > > > Qualcomm PCIe controllers of version v2.4.0 have debug registers in the > > > PARF region that count PCIe link transitions. Expose them over debugfs to > > > userspace to help debug the low power issues. > > > > > > Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> > > > --- > > > drivers/pci/controller/dwc/pcie-qcom.c | 33 ++++++++++++++++++++++++++ > > > 1 file changed, 33 insertions(+) > > > > > > diff --git a/drivers/pci/controller/dwc/pcie-qcom.c > > > b/drivers/pci/controller/dwc/pcie-qcom.c > > > index f99b7e7f3f73..0b41f007fa90 100644 > > > --- a/drivers/pci/controller/dwc/pcie-qcom.c > > > +++ b/drivers/pci/controller/dwc/pcie-qcom.c > > > @@ -37,6 +37,7 @@ > > > /* PARF registers */ > > > #define PARF_SYS_CTRL 0x00 > > > #define PARF_PM_CTRL 0x20 > > > +#define PARF_PM_STTS 0x24 > > > #define PARF_PCS_DEEMPH 0x34 > > > #define PARF_PCS_SWING 0x38 > > > #define PARF_PHY_CTRL 0x40 > > > @@ -84,6 +85,12 @@ > > > /* PARF_PM_CTRL register fields */ > > > #define REQ_NOT_ENTR_L1 BIT(5) > > > +/* PARF_PM_STTS register fields */ > > > +#define PM_LINKST_IN_L1SUB BIT(8) > > > +#define PM_LINKST_IN_L0S BIT(7) > > > +#define PM_LINKST_IN_L2 BIT(5) > > > +#define PM_LINKST_IN_L1 BIT(4) > > > + > > > /* PARF_PCS_DEEMPH register fields */ > > > #define PCS_DEEMPH_TX_DEEMPH_GEN1(x) FIELD_PREP(GENMASK(21, > > > 16), x) > > > #define PCS_DEEMPH_TX_DEEMPH_GEN2_3_5DB(x) > > > FIELD_PREP(GENMASK(13, 8), x) > > > @@ -737,6 +744,31 @@ static int qcom_pcie_post_init_2_4_0(struct > > > qcom_pcie *pcie) > > > return 0; > > > } > > > +static int qcom_pcie_debugfs_func_2_4_0(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->parf + PM_LINKST_IN_L0S)); > > > + > > > + seq_printf(s, "L1 transition count: %u\n", > > > + readl_relaxed(pcie->parf + PM_LINKST_IN_L1)); > > > + > > > + seq_printf(s, "L1.1 transition count: %u\n", > > > + readl_relaxed(pcie->parf + PM_LINKST_IN_L1SUB)); > > > + > > > + seq_printf(s, "L2 transition count: %u\n", > > > + readl_relaxed(pcie->parf + PM_LINKST_IN_L2)); > > > + > > > > Using bitmask as register offset ? instead use PM_STTS and bitmask it ? > > Also, since its 1 bit, all are status and not count. > Not sure, if you want it to limit this debug based on 'mhi' property > being populated ? > Err... Look like I blindly copied the debugfs function from 2.7.0 :/ Sry, since these are all just 1 bit, we cannot use it for getting the count. So I'll drop this patch in next revision. Thanks, Mani > Regards, > Sricharan
diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c index f99b7e7f3f73..0b41f007fa90 100644 --- a/drivers/pci/controller/dwc/pcie-qcom.c +++ b/drivers/pci/controller/dwc/pcie-qcom.c @@ -37,6 +37,7 @@ /* PARF registers */ #define PARF_SYS_CTRL 0x00 #define PARF_PM_CTRL 0x20 +#define PARF_PM_STTS 0x24 #define PARF_PCS_DEEMPH 0x34 #define PARF_PCS_SWING 0x38 #define PARF_PHY_CTRL 0x40 @@ -84,6 +85,12 @@ /* PARF_PM_CTRL register fields */ #define REQ_NOT_ENTR_L1 BIT(5) +/* PARF_PM_STTS register fields */ +#define PM_LINKST_IN_L1SUB BIT(8) +#define PM_LINKST_IN_L0S BIT(7) +#define PM_LINKST_IN_L2 BIT(5) +#define PM_LINKST_IN_L1 BIT(4) + /* PARF_PCS_DEEMPH register fields */ #define PCS_DEEMPH_TX_DEEMPH_GEN1(x) FIELD_PREP(GENMASK(21, 16), x) #define PCS_DEEMPH_TX_DEEMPH_GEN2_3_5DB(x) FIELD_PREP(GENMASK(13, 8), x) @@ -737,6 +744,31 @@ static int qcom_pcie_post_init_2_4_0(struct qcom_pcie *pcie) return 0; } +static int qcom_pcie_debugfs_func_2_4_0(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->parf + PM_LINKST_IN_L0S)); + + seq_printf(s, "L1 transition count: %u\n", + readl_relaxed(pcie->parf + PM_LINKST_IN_L1)); + + seq_printf(s, "L1.1 transition count: %u\n", + readl_relaxed(pcie->parf + PM_LINKST_IN_L1SUB)); + + seq_printf(s, "L2 transition count: %u\n", + readl_relaxed(pcie->parf + PM_LINKST_IN_L2)); + + return 0; +} + + +static void qcom_pcie_init_debugfs_2_4_0(struct qcom_pcie *pcie) +{ + qcom_pcie_init_debugfs(pcie, qcom_pcie_debugfs_func_2_4_0); +} + static int qcom_pcie_get_resources_2_3_3(struct qcom_pcie *pcie) { struct qcom_pcie_resources_2_3_3 *res = &pcie->res.v2_3_3; @@ -1300,6 +1332,7 @@ static const struct qcom_pcie_ops ops_2_4_0 = { .post_init = qcom_pcie_post_init_2_4_0, .deinit = qcom_pcie_deinit_2_4_0, .ltssm_enable = qcom_pcie_2_3_2_ltssm_enable, + .init_debugfs = qcom_pcie_init_debugfs_2_4_0, }; /* Qcom IP rev.: 2.3.3 Synopsys IP rev.: 4.30a */