From: Niklas Cassel <cassel@kernel.org>
To: Hans Zhang <18255117159@163.com>
Cc: Bjorn Helgaas <helgaas@kernel.org>,
lpieralisi@kernel.org, kw@linux.com, bhelgaas@google.com,
heiko@sntech.de, manivannan.sadhasivam@linaro.org,
robh@kernel.org, jingoohan1@gmail.com,
thomas.richard@bootlin.com, linux-pci@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org,
Shawn Lin <shawn.lin@rock-chips.com>
Subject: Re: [PATCH] PCI: dw-rockchip: Configure max payload size on host init
Date: Thu, 17 Apr 2025 08:53:58 +0200 [thread overview]
Message-ID: <aAClhmwO3caYMonN@ryzen> (raw)
In-Reply-To: <a8cc995e-c6d5-4079-b6d9-765f76a7ec7a@163.com>
On Thu, Apr 17, 2025 at 02:47:23PM +0800, Hans Zhang wrote:
> On 2025/4/17 14:01, Niklas Cassel wrote:
> > On Thu, Apr 17, 2025 at 10:19:10AM +0800, Hans Zhang wrote:
> > > On 2025/4/17 04:40, Bjorn Helgaas wrote:
> > > > On Wed, Apr 16, 2025 at 11:19:26PM +0800, Hans Zhang wrote:
> > > > > The RK3588's PCIe controller defaults to a 128-byte max payload size,
> > > > > but its hardware capability actually supports 256 bytes. This results
> > > > > in suboptimal performance with devices that support larger payloads.
> > > > >
> > > > > Signed-off-by: Hans Zhang <18255117159@163.com>
> > > > > ---
> > > > > drivers/pci/controller/dwc/pcie-dw-rockchip.c | 18 ++++++++++++++++++
> > > > > 1 file changed, 18 insertions(+)
> > > > >
> > > > > diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> > > > > index c624b7ebd118..5bbb536a2576 100644
> > > > > --- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> > > > > +++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> > > > > @@ -477,6 +477,22 @@ static irqreturn_t rockchip_pcie_ep_sys_irq_thread(int irq, void *arg)
> > > > > return IRQ_HANDLED;
> > > > > }
> > > > > +static void rockchip_pcie_set_max_payload(struct rockchip_pcie *rockchip)
> > > > > +{
> > > > > + struct dw_pcie *pci = &rockchip->pci;
> > > > > + u32 dev_cap, dev_ctrl;
> > > > > + u16 offset;
> > > > > +
> > > > > + offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
> > > > > + dev_cap = dw_pcie_readl_dbi(pci, offset + PCI_EXP_DEVCAP);
> > > > > + dev_cap &= PCI_EXP_DEVCAP_PAYLOAD;
> > > > > +
> > > > > + dev_ctrl = dw_pcie_readl_dbi(pci, offset + PCI_EXP_DEVCTL);
> > > > > + dev_ctrl &= ~PCI_EXP_DEVCTL_PAYLOAD;
> > > > > + dev_ctrl |= dev_cap << 5;
> > > > > + dw_pcie_writel_dbi(pci, offset + PCI_EXP_DEVCTL, dev_ctrl);
> > > > > +}
> > > >
> > > > I can't really complain too much about this since meson does basically
> > > > the same thing, but there are some things I don't like about this:
> > > >
> > > > - I don't think it's safe to set MPS higher in all cases. If we set
> > > > the Root Port MPS=256, and an Endpoint only supports MPS=128, the
> > > > Endpoint may do a 256-byte DMA read (assuming its MRRS>=256). In
> > > > that case the RP may respond with a 256-byte payload the Endpoint
> > > > can't handle. The generic code in pci_configure_mps() might be
> > > > smart enough to avoid that situation, but I'm not confident about
> > > > it. Maybe I could be convinced.
> > > >
> > >
> > > Dear Bjorn,
> > >
> > > Thank you very much for your reply. If we set the Root Port MPS=256, and an
> > > Endpoint only supports MPS=128. Finally, Root Port is also set to MPS=128 in
> > > pci_configure_mps.
> >
> > In you example below, the Endpoint has:
> > DevCap: MaxPayload 512 bytes
> >
> > So at least your example can't be used to prove this specific point.
> > But perhaps you just wanted to show that your Max Payload Size increase
> > actually works?
> >
>
> Dear Niklas,
>
> Do you have an Endpoint with MPS=128? If so, you can also help verify the
> logic of the pci_configure_mps function. I don't have an Endpoint with
> MPS=128 here.
I imagine that it would be trivial to test with a PCIe controller running
in endpoint mode with the PCI endpoint subsystem in the kernel.
(As you should be able to set CAP.MPS before starting link training.)
> The processing logic of the pci_configure_mps function has been verified on
> our own SOC platform. Please refer to the following log.
> Our Root Port will set MPS=512.
(snip)
Ok, since it works to downgrade 512B to 256B, I would imagine that it also
would downgrade to 128B properly.
Kind regards,
Niklas
next prev parent reply other threads:[~2025-04-17 6:54 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-16 15:19 [PATCH] PCI: dw-rockchip: Configure max payload size on host init Hans Zhang
2025-04-16 20:40 ` Bjorn Helgaas
2025-04-17 2:19 ` Hans Zhang
2025-04-17 6:01 ` Niklas Cassel
2025-04-17 6:47 ` Hans Zhang
2025-04-17 6:53 ` Niklas Cassel [this message]
2025-04-17 7:04 ` Niklas Cassel
2025-04-17 7:08 ` Shawn Lin
2025-04-17 7:22 ` Niklas Cassel
2025-04-17 7:25 ` Shawn Lin
2025-04-17 7:48 ` Niklas Cassel
2025-04-17 8:07 ` Hans Zhang
2025-04-17 8:39 ` Niklas Cassel
2025-04-17 9:48 ` Hans Zhang
2025-04-17 9:54 ` Niklas Cassel
2025-04-17 16:52 ` Bjorn Helgaas
2025-04-18 12:33 ` Hans Zhang
2025-04-18 14:55 ` Niklas Cassel
2025-04-18 16:21 ` Bjorn Helgaas
2025-04-18 17:21 ` Hans Zhang
2025-04-21 14:53 ` Manivannan Sadhasivam
2025-04-21 15:59 ` Hans Zhang
2025-04-21 14:48 ` 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=aAClhmwO3caYMonN@ryzen \
--to=cassel@kernel.org \
--cc=18255117159@163.com \
--cc=bhelgaas@google.com \
--cc=heiko@sntech.de \
--cc=helgaas@kernel.org \
--cc=jingoohan1@gmail.com \
--cc=kw@linux.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=lpieralisi@kernel.org \
--cc=manivannan.sadhasivam@linaro.org \
--cc=robh@kernel.org \
--cc=shawn.lin@rock-chips.com \
--cc=thomas.richard@bootlin.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;
as well as URLs for NNTP newsgroup(s).