From: Bjorn Helgaas <helgaas@kernel.org>
To: Rajat Jain <rajatja@google.com>
Cc: linux-pci@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>,
Shawn Lin <shawn.lin@rock-chips.com>,
Jeffy Chen <jeffy.chen@rock-chips.com>,
Wenrui Li <wenrui.li@rock-chips.com>,
Brian Norris <briannorris@chromium.org>,
rajatxjain@gmail.com
Subject: Re: [PATCH v3] PCI: rockchip: Increase the Max Credit update interval.
Date: Tue, 4 Oct 2016 12:17:31 -0500 [thread overview]
Message-ID: <20161004171730.GB3449@localhost> (raw)
In-Reply-To: <1474591842-27836-1-git-send-email-rajatja@google.com>
On Thu, Sep 22, 2016 at 05:50:42PM -0700, Rajat Jain wrote:
> This increases the likelihood of link state to automatically go to L1
> and save some power.
>
> The default credit update interval of 7.5 us results in the rootport
> sending UpdateFC-P and UpdateFC-NP packets too often, thus resulting
> in the link never going to L1, and always staying in L0/L0s. The
> value 24 us was chosen after some experiments and peeking over the
> PCIe bus to see that we do enter L1 substate when there is not enough
> traffic on the PCIe bus.
>
> Signed-off-by: Rajat Jain <rajatja@google.com>
Applied with Shawn's ack to pci/host-rockchip for v4.9, thanks!
> ---
> v3: Fix the commit message.
> v2: Use the link bandwidth change irq to program the register.
>
> drivers/pci/host/pcie-rockchip.c | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/drivers/pci/host/pcie-rockchip.c b/drivers/pci/host/pcie-rockchip.c
> index c3593e6..99e700f 100644
> --- a/drivers/pci/host/pcie-rockchip.c
> +++ b/drivers/pci/host/pcie-rockchip.c
> @@ -95,6 +95,11 @@
> #define PCIE_CORE_PL_CONF_SPEED_MASK 0x00000018
> #define PCIE_CORE_PL_CONF_LANE_MASK 0x00000006
> #define PCIE_CORE_PL_CONF_LANE_SHIFT 1
> +#define PCIE_CORE_TXCREDIT_CFG1 (PCIE_CORE_CTRL_MGMT_BASE + 0x020)
> +#define PCIE_CORE_TXCREDIT_CFG1_MUI_MASK 0xFFFF0000
> +#define PCIE_CORE_TXCREDIT_CFG1_MUI_SHIFT 16
> +#define PCIE_CORE_TXCREDIT_CFG1_MUI_ENCODE(x) \
> + (((x) >> 3) << PCIE_CORE_TXCREDIT_CFG1_MUI_SHIFT)
> #define PCIE_CORE_INT_STATUS (PCIE_CORE_CTRL_MGMT_BASE + 0x20c)
> #define PCIE_CORE_INT_PRFPE BIT(0)
> #define PCIE_CORE_INT_CRFPE BIT(1)
> @@ -224,6 +229,17 @@ static void rockchip_pcie_clr_bw_int(struct rockchip_pcie *rockchip)
> rockchip_pcie_write(rockchip, status, PCIE_RC_CONFIG_LCS);
> }
>
> +static void rockchip_pcie_update_txcredit_mui(struct rockchip_pcie *rockchip)
> +{
> + u32 val;
> +
> + /* Update Tx credit maximum update interval */
> + val = rockchip_pcie_read(rockchip, PCIE_CORE_TXCREDIT_CFG1);
> + val &= ~PCIE_CORE_TXCREDIT_CFG1_MUI_MASK;
> + val |= PCIE_CORE_TXCREDIT_CFG1_MUI_ENCODE(24000); /* ns */
> + rockchip_pcie_write(rockchip, val, PCIE_CORE_TXCREDIT_CFG1);
> +}
> +
> static int rockchip_pcie_valid_device(struct rockchip_pcie *rockchip,
> struct pci_bus *bus, int dev)
> {
> @@ -597,6 +613,7 @@ static irqreturn_t rockchip_pcie_subsys_irq_handler(int irq, void *arg)
> rockchip_pcie_write(rockchip, sub_reg, PCIE_CORE_INT_STATUS);
> } else if (reg & PCIE_CLIENT_INT_PHY) {
> dev_dbg(dev, "phy link changes\n");
> + rockchip_pcie_update_txcredit_mui(rockchip);
> rockchip_pcie_clr_bw_int(rockchip);
> }
>
> --
> 2.8.0.rc3.226.g39d4020
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
prev parent reply other threads:[~2016-10-04 17:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-22 21:00 [PATCH] rockchip: Increase the Max Credit update interval Rajat Jain
2016-09-22 21:14 ` Brian Norris
2016-09-22 21:56 ` Rajat Jain
2016-09-22 22:37 ` Rajat Jain
2016-09-22 22:38 ` [PATCH v2] PCI: " Rajat Jain
2016-09-23 0:42 ` Shawn Lin
2016-09-23 0:50 ` [PATCH v3] " Rajat Jain
2016-09-23 1:07 ` Shawn Lin
2016-10-04 17:17 ` Bjorn Helgaas [this message]
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=20161004171730.GB3449@localhost \
--to=helgaas@kernel.org \
--cc=bhelgaas@google.com \
--cc=briannorris@chromium.org \
--cc=jeffy.chen@rock-chips.com \
--cc=linux-pci@vger.kernel.org \
--cc=rajatja@google.com \
--cc=rajatxjain@gmail.com \
--cc=shawn.lin@rock-chips.com \
--cc=wenrui.li@rock-chips.com \
/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