linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: linux-pci@vger.kernel.org, "Bjorn Helgaas" <bhelgaas@google.com>,
	"Mahesh J Salgaonkar" <mahesh@linux.ibm.com>,
	"Oliver O'Halloran" <oohall@gmail.com>,
	"Lukas Wunner" <lukas@wunner.de>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	LKML <linux-kernel@vger.kernel.org>,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v6 5/8] PCI: Store # of supported End-End TLP Prefixes
Date: Thu, 12 Dec 2024 20:03:59 +0200 (EET)	[thread overview]
Message-ID: <349c5b75-3f6c-c119-fedb-32dd1ec61725@linux.intel.com> (raw)
In-Reply-To: <20241211163629.00002937@huawei.com>

[-- Attachment #1: Type: text/plain, Size: 4383 bytes --]

On Wed, 11 Dec 2024, Jonathan Cameron wrote:

> On Fri, 13 Sep 2024 17:36:29 +0300
> Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> wrote:
> 
> > eetlp_prefix_path in the struct pci_dev tells if End-End TLP Prefixes
> > are supported by the path or not, the value is only calculated if
> > CONFIG_PCI_PASID is set.
> > 
> > The Max End-End TLP Prefixes field in the Device Capabilities Register
> > 2 also tells how many (1-4) End-End TLP Prefixes are supported (PCIe r6
> > sec 7.5.3.15). The number of supported End-End Prefixes is useful for
> > reading correct number of DWORDs from TLP Prefix Log register in AER
> > capability (PCIe r6 sec 7.8.4.12).
> > 
> > Replace eetlp_prefix_path with eetlp_prefix_max and determine the
> > number of supported End-End Prefixes regardless of CONFIG_PCI_PASID so
> > that an upcoming commit generalizing TLP Prefix Log register reading
> > does not have to read extra DWORDs for End-End Prefixes that never will
> > be there.
> > 
> > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> > ---
> >  drivers/pci/ats.c             |  2 +-
> >  drivers/pci/probe.c           | 14 +++++++++-----
> >  include/linux/pci.h           |  2 +-
> >  include/uapi/linux/pci_regs.h |  1 +
> >  4 files changed, 12 insertions(+), 7 deletions(-)
> > 
> > diff --git a/drivers/pci/ats.c b/drivers/pci/ats.c
> > index c570892b2090..e13433dcfc82 100644
> > --- a/drivers/pci/ats.c
> > +++ b/drivers/pci/ats.c
> > @@ -377,7 +377,7 @@ int pci_enable_pasid(struct pci_dev *pdev, int features)
> >  	if (WARN_ON(pdev->pasid_enabled))
> >  		return -EBUSY;
> >  
> > -	if (!pdev->eetlp_prefix_path && !pdev->pasid_no_tlp)
> > +	if (!pdev->eetlp_prefix_max && !pdev->pasid_no_tlp)
> >  		return -EINVAL;
> >  
> >  	if (!pasid)
> > diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> > index b14b9876c030..0ab70ea6840c 100644
> > --- a/drivers/pci/probe.c
> > +++ b/drivers/pci/probe.c
> > @@ -2228,8 +2228,8 @@ static void pci_configure_relaxed_ordering(struct pci_dev *dev)
> >  
> >  static void pci_configure_eetlp_prefix(struct pci_dev *dev)
> >  {
> > -#ifdef CONFIG_PCI_PASID
> >  	struct pci_dev *bridge;
> > +	unsigned int eetlp_max;
> >  	int pcie_type;
> >  	u32 cap;
> >  
> > @@ -2241,15 +2241,19 @@ static void pci_configure_eetlp_prefix(struct pci_dev *dev)
> >  		return;
> >  
> >  	pcie_type = pci_pcie_type(dev);
> > +
> > +	eetlp_max = FIELD_GET(PCI_EXP_DEVCAP2_EE_PREFIX_MAX, cap);
> > +	/* 00b means 4 */
> > +	eetlp_max = eetlp_max ?: 4;
> > +
> >  	if (pcie_type == PCI_EXP_TYPE_ROOT_PORT ||
> >  	    pcie_type == PCI_EXP_TYPE_RC_END)
> > -		dev->eetlp_prefix_path = 1;
> > +		dev->eetlp_prefix_max = eetlp_max;
> >  	else {
> >  		bridge = pci_upstream_bridge(dev);
> > -		if (bridge && bridge->eetlp_prefix_path)
> > -			dev->eetlp_prefix_path = 1;
> > +		if (bridge && bridge->eetlp_prefix_max)
> 
> What happens if they disagree?  That is the bridge supports 2
> and the device 3?

That's a good question.

The current code obviously only checks if Prefixes are supported or not so 
the max value doesn't matter for the existing code.

I went to read spec and my reading from TLP logging point of view is that 
the device's own maximum matters even if it might never get >2 Prefixes
(r6.1 2.2.10.4 & 6.2.4).

AFAIK, things happen on low level and there's no way to program this 
value. So it's not like the kernel is telling that hw must only use x 
Prefixes at most if that's what you were worried about.

But there are more things to consider, e.g., I noticed End-End TLP Prefix 
Blocking in DevCtl2 which might impact the existing usage too and is not
checked by the kernel currently.

My interest here lies on cleaning this up so I'm not sure if functional 
changes such as considering End-End TLP Prefix Blocking really matter for 
some case or not. I can obviously easily add the code for that too if it's 
required for this series to be acceptable but I don't have a test case for 
it. My main goal with this TLP logging consolidation series is to get to a 
point that extending it to support Flit mode is easier.

There's also TLP Prefix Log Present which I think the reader should 
consider, which matters to another patch in this series and I'm going to 
alter the length based on that flag.

-- 
 i.

  reply	other threads:[~2024-12-12 18:04 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-13 14:36 [PATCH v6 0/8] PCI: Consolidate TLP Log reading and printing Ilpo Järvinen
2024-09-13 14:36 ` [PATCH v6 1/8] PCI: Don't expose pcie_read_tlp_log() outside of PCI subsystem Ilpo Järvinen
2024-12-11 16:22   ` Jonathan Cameron
2024-09-13 14:36 ` [PATCH v6 2/8] PCI: Move TLP Log handling to own file Ilpo Järvinen
2024-12-11 16:25   ` Jonathan Cameron
2024-09-13 14:36 ` [PATCH v6 3/8] PCI: Make pcie_read_tlp_log() signature same Ilpo Järvinen
2024-12-11 16:26   ` Jonathan Cameron
2024-09-13 14:36 ` [PATCH v6 4/8] PCI: Use unsigned int i in pcie_read_tlp_log() Ilpo Järvinen
2024-12-11 16:58   ` Jonathan Cameron
2024-09-13 14:36 ` [PATCH v6 5/8] PCI: Store # of supported End-End TLP Prefixes Ilpo Järvinen
2024-12-11 16:36   ` Jonathan Cameron
2024-12-12 18:03     ` Ilpo Järvinen [this message]
2024-09-13 14:36 ` [PATCH v6 6/8] PCI: Add TLP Prefix reading into pcie_read_tlp_log() Ilpo Järvinen
2024-12-11 16:49   ` Jonathan Cameron
2024-12-12 16:12     ` Ilpo Järvinen
2024-12-12 18:48       ` Ilpo Järvinen
2024-12-13 15:54         ` Jonathan Cameron
2024-09-13 14:36 ` [PATCH v6 7/8] PCI: Create helper to print TLP Header and Prefix Log Ilpo Järvinen
2024-12-11 16:56   ` Jonathan Cameron
2024-09-13 14:36 ` [PATCH v6 8/8] PCI/AER: Add prefixes to printouts Ilpo Järvinen
2024-12-11 16:58   ` Jonathan Cameron
2024-10-23  8:27 ` [PATCH v6 0/8] PCI: Consolidate TLP Log reading and printing Ilpo Järvinen
2024-12-10 18:19   ` Ilpo Järvinen

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=349c5b75-3f6c-c119-fedb-32dd1ec61725@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=bhelgaas@google.com \
    --cc=kw@linux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=lukas@wunner.de \
    --cc=mahesh@linux.ibm.com \
    --cc=oohall@gmail.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).