All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vadim Lomovtsev <Vadim.Lomovtsev@caviumnetworks.com>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: bhelgaas@google.com, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org, Wilson.Snyder@cavium.com,
	alex.williamson@redhat.com, David Daney <david.daney@cavium.com>,
	Manish Jaggi <mjaggi@caviumnetworks.com>,
	vadim.lomovtsev@cavium.com
Subject: Re: [PATCH v6] PCI: quirks: update Cavium ThunderX ACS quirk implementation
Date: Tue, 17 Oct 2017 04:29:24 -0700	[thread overview]
Message-ID: <20171017112924.GA2354@localhost.localdomain> (raw)
In-Reply-To: <20171016212320.GI25517@bhelgaas-glaptop.roam.corp.google.com>

On Mon, Oct 16, 2017 at 04:23:20PM -0500, Bjorn Helgaas wrote:
Hi Bjorn,

> [+cc David, Manish]
> 
> Please use a subject line that tells more about what's going on.
> "Update quirk" doesn't really convey any useful information.
> Something like "Apply Cavium ThunderX ACS quirk only to Root Ports".
> 
> On Wed, Sep 27, 2017 at 11:20:39AM -0700, Vadim Lomovtsev wrote:
> > This commit makes Cavium PCI ACS quirk applicable only to Cavium
> > ThunderX (CN8XXX) family PCIE Root Ports which has limited PCI capabilities
> > in terms of no ACS support advertisement. However, the RTL internally
> > implements similar protection as if ACS had completion/request redirection,
> > upstream forwarding and validation features enabled.
> > 
> > Current quirk implementation doesn't take into account PCIERCs which
> > also needs to be quirked. So the pci device id check mask is updated
> > and check of device ID moved into separate function.
> 
> s/PCIE/PCIe/ above
> 
> s/PCIERCs/PCIe Root Ports/ (I assume, since usually a Root Complex
> itself doesn't appear as a pci_dev)
> 
> > Signed-off-by: Vadim Lomovtsev <Vadim.Lomovtsev@caviumnetworks.com>
> > ---
> > 	v5 -> v6: comment typo fix: change 0xa00 to 0xa000
> > 
> >  drivers/pci/quirks.c | 29 +++++++++++++++++++++--------
> >  1 file changed, 21 insertions(+), 8 deletions(-)
> > 
> > diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
> > index a4d3361..ed6c76d 100644
> > --- a/drivers/pci/quirks.c
> > +++ b/drivers/pci/quirks.c
> > @@ -4211,20 +4211,33 @@ static int pci_quirk_amd_sb_acs(struct pci_dev *dev, u16 acs_flags)
> >  #endif
> >  }
> >  
> > -static int pci_quirk_cavium_acs(struct pci_dev *dev, u16 acs_flags)
> > +/*
> > + * The Cavium downstream ports doesn't advertise their ACS capability registers.
> > + * However, the RTL internally implements similar protection as if
> > + * ACS had completion redirection, forwarding and validation features enabled.
> > + * So by this flags we're asserting that the hardware implements and
> > + * enables equivalent ACS functionality for these flags.
> > + */
> > +#define CAVIUM_CN8XXX_ACS_FLAGS (PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_SV | PCI_ACS_UF)
> 
> You are changing the set of flags, which isn't mentioned in the changelog.
> I think the best thing would be to have two patches: one that changes the
> set of flags and a second that changes the set of affected devices.
> 
> This set of flags was used twice in the original patch, so a #define made
> sense.  But now you only use it once, so there's no benefit in adding the
> #define, and adding it makes the change in the set of flags harder to see.
> 
> > +static __inline__  bool pci_quirk_cavium_acs_match(struct pci_dev *dev)
> 
> No need to use "__inline__" here.  This isn't performance critical,
> and the compiler will probably inline it anyway because there's only
> one use.
>
> >  {
> >  	/*
> > -	 * Cavium devices matching this quirk do not perform peer-to-peer
> > -	 * with other functions, allowing masking out these bits as if they
> > -	 * were unimplemented in the ACS capability.
> > +	 * Effectively selects all downstream ports for whole ThunderX 1 family
> > +	 * by 0xa000 mask (which represents 8 SoCs), while the lower bits of device ID
> > +	 * are used to indicate which subdevice is used within the SoC.
> 
> Please wrap your comments so they fit in 80 columns.
> 
> >  	 */
> > -	acs_flags &= ~(PCI_ACS_SV | PCI_ACS_TB | PCI_ACS_RR |
> > -		       PCI_ACS_CR | PCI_ACS_UF | PCI_ACS_DT);
> > +	return (pci_is_pcie(dev) &&
> > +		(pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT) &&
> > +		((dev->device & 0xf800) == 0xa000));
> 
> I'm just a little confused by the 0xa000 mask you refer to in the
> comment, because the mask in the code is 0xf800.

Sorry for confusion, will correct it to 0xf800 for comment.

> 
> Previously the quirk applied to all Cavium device IDs in the range
> 0xa000-0xa0ff.  Now it applies to device IDs in the range
> 0xa000-0xa7ff, but only if they are PCIe Root Ports.  Right?

Correct. Since this quirk is necessary for Root Ports only.

Thanks for reply, I'll re-work this one accordingly to your comments and re-send v7.

WBR,
Vadim

> 
> > +}
> >  
> > -	if (!((dev->device >= 0xa000) && (dev->device <= 0xa0ff)))
> > +static int pci_quirk_cavium_acs(struct pci_dev *dev, u16 acs_flags)
> > +{
> > +	if (!pci_quirk_cavium_acs_match(dev))
> >  		return -ENOTTY;
> >  
> > -	return acs_flags ? 0 : 1;
> > +	return acs_flags & ~(CAVIUM_CN8XXX_ACS_FLAGS) ? 0 : 1;
> >  }
> >  
> >  static int pci_quirk_xgene_acs(struct pci_dev *dev, u16 acs_flags)
> > -- 
> > 2.4.11
> > 

  reply	other threads:[~2017-10-17 11:29 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-12 11:55 [PATCH] PCI: quirks: update cavium ACS quirk implementation Vadim Lomovtsev
2017-09-12 16:15 ` Alex Williamson
2017-09-13 11:37   ` Vadim Lomovtsev
2017-09-13 12:01   ` Vadim Lomovtsev
2017-09-15 12:57 ` [PATCH v3] PCI: quirks: update Cavium ThunderX " Vadim Lomovtsev
2017-09-15 19:20   ` Lomovtsev, Vadim
2017-09-15 19:20     ` Lomovtsev, Vadim
2017-09-18  8:48   ` [PATCH v4] " Vadim Lomovtsev
2017-09-20 11:33     ` Vadim Lomovtsev
2017-09-20 16:31     ` Alex Williamson
2017-09-21  8:39       ` Vadim Lomovtsev
2017-09-25 13:08     ` [PATCH v5] " Vadim Lomovtsev
2017-09-26 15:23       ` Vadim Lomovtsev
2017-09-26 15:43       ` Alex Williamson
2017-09-26 16:00         ` Vadim Lomovtsev
2017-09-27 18:03           ` Vadim Lomovtsev
2017-09-27 18:20       ` [PATCH v6] " Vadim Lomovtsev
2017-09-27 20:03         ` Vadim Lomovtsev
2017-09-27 20:18         ` Alex Williamson
2017-09-29 12:22           ` Vadim Lomovtsev
2017-10-09 16:14           ` Vadim Lomovtsev
2017-10-12 13:27         ` Robert Richter
2017-10-16 21:23         ` Bjorn Helgaas
2017-10-17 11:29           ` Vadim Lomovtsev [this message]
2017-10-17 12:47         ` [PATCH v7 0/2] PCI: quirks: Cavium ThunderX ACS quirk update Vadim Lomovtsev
2017-10-17 12:47           ` [PATCH v7 1/2] PCI: quirks: Set Cavium ACS capability quirk flags to assert RR/CR/SV/UF Vadim Lomovtsev
2017-10-17 12:47           ` [PATCH v7 2/2] PCI: quirks: Apply Cavium ThunderX ACS quirk only to Root Ports Vadim Lomovtsev
2017-10-19 11:26           ` [PATCH v7 0/2] PCI: quirks: Cavium ThunderX ACS quirk update Bjorn Helgaas
2017-10-19 11:59             ` Vadim Lomovtsev
2017-10-19 18:50               ` Bjorn Helgaas
2017-10-20 10:44                 ` Vadim Lomovtsev

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=20171017112924.GA2354@localhost.localdomain \
    --to=vadim.lomovtsev@caviumnetworks.com \
    --cc=Wilson.Snyder@cavium.com \
    --cc=alex.williamson@redhat.com \
    --cc=bhelgaas@google.com \
    --cc=david.daney@cavium.com \
    --cc=helgaas@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mjaggi@caviumnetworks.com \
    --cc=vadim.lomovtsev@cavium.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.