Message ID | 1516213829-14844-1-git-send-email-karahmed@amazon.de |
---|---|
State | Accepted |
Delegated to: | Bjorn Helgaas |
Headers | show |
Series | pci: Do not read INTx PIN and LINE registers for virtual functions | expand |
On Wed, 17 Jan 2018 19:30:29 +0100 KarimAllah Ahmed <karahmed@amazon.de> wrote: > ... since INTx is not supported by-spec for virtual functions. But the spec also states that VFs must implement the interrupt pin register as read-only zero, so either this is redundant or it's a workaround for VFs that aren't quite compliant? Thanks, Alex > > Cc: Bjorn Helgaas <bhelgaas@google.com> > Cc: linux-pci@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > Signed-off-by: KarimAllah Ahmed <karahmed@amazon.de> > Signed-off-by: Jan H. Schönherr <jschoenh@amazon.de> > --- > drivers/pci/probe.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c > index 65099d0..61002fb 100644 > --- a/drivers/pci/probe.c > +++ b/drivers/pci/probe.c > @@ -1232,6 +1232,13 @@ static void pci_read_irq(struct pci_dev *dev) > { > unsigned char irq; > > + /* Virtual functions do not have INTx support */ > + if (dev->is_virtfn) { > + dev->pin = 0; > + dev->irq = 0; > + return; > + } > + > pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &irq); > dev->pin = irq; > if (irq)
On 01/17/2018 07:49 PM, Alex Williamson wrote: > On Wed, 17 Jan 2018 19:30:29 +0100 > KarimAllah Ahmed <karahmed@amazon.de> wrote: > >> ... since INTx is not supported by-spec for virtual functions. > But the spec also states that VFs must implement the interrupt pin > register as read-only zero, so either this is redundant or it's a > workaround for VFs that aren't quite compliant? Thanks, The end goal for me is just to NOT do the read across the PCI bus for no good reason. We have devices with thousands of virtual functions and this read is simply not useful in this case and can be optimized as I did. So from a functionality point of view probably the patch does not add any value as you mentioned, but it is really useful as a micro-optimization. > > Alex > >> Cc: Bjorn Helgaas <bhelgaas@google.com> >> Cc: linux-pci@vger.kernel.org >> Cc: linux-kernel@vger.kernel.org >> Signed-off-by: KarimAllah Ahmed <karahmed@amazon.de> >> Signed-off-by: Jan H. Schönherr <jschoenh@amazon.de> >> --- >> drivers/pci/probe.c | 7 +++++++ >> 1 file changed, 7 insertions(+) >> >> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c >> index 65099d0..61002fb 100644 >> --- a/drivers/pci/probe.c >> +++ b/drivers/pci/probe.c >> @@ -1232,6 +1232,13 @@ static void pci_read_irq(struct pci_dev *dev) >> { >> unsigned char irq; >> >> + /* Virtual functions do not have INTx support */ >> + if (dev->is_virtfn) { >> + dev->pin = 0; >> + dev->irq = 0; >> + return; >> + } >> + >> pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &irq); >> dev->pin = irq; >> if (irq) > Amazon Development Center Germany GmbH Berlin - Dresden - Aachen main office: Krausenstr. 38, 10117 Berlin Geschaeftsfuehrer: Dr. Ralf Herbrich, Christian Schlaeger Ust-ID: DE289237879 Eingetragen am Amtsgericht Charlottenburg HRB 149173 B
On Wed, 17 Jan 2018 20:02:44 +0100 KarimAllah Ahmed <karahmed@amazon.com> wrote: > On 01/17/2018 07:49 PM, Alex Williamson wrote: > > On Wed, 17 Jan 2018 19:30:29 +0100 > > KarimAllah Ahmed <karahmed@amazon.de> wrote: > > > >> ... since INTx is not supported by-spec for virtual functions. > > But the spec also states that VFs must implement the interrupt pin > > register as read-only zero, so either this is redundant or it's a > > workaround for VFs that aren't quite compliant? Thanks, > > The end goal for me is just to NOT do the read across the PCI bus for no > good reason. We have devices with thousands of virtual functions and > this read is simply not useful in this case and can be optimized as I > did. So from a functionality point of view probably the patch does not > add any value as you mentioned, but it is really useful as a > micro-optimization. Thanks for the clarification, it's helpful to understand the motivation for a patch that otherwise seems unnecessary. Alex > >> Cc: Bjorn Helgaas <bhelgaas@google.com> > >> Cc: linux-pci@vger.kernel.org > >> Cc: linux-kernel@vger.kernel.org > >> Signed-off-by: KarimAllah Ahmed <karahmed@amazon.de> > >> Signed-off-by: Jan H. Schönherr <jschoenh@amazon.de> > >> --- > >> drivers/pci/probe.c | 7 +++++++ > >> 1 file changed, 7 insertions(+) > >> > >> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c > >> index 65099d0..61002fb 100644 > >> --- a/drivers/pci/probe.c > >> +++ b/drivers/pci/probe.c > >> @@ -1232,6 +1232,13 @@ static void pci_read_irq(struct pci_dev *dev) > >> { > >> unsigned char irq; > >> > >> + /* Virtual functions do not have INTx support */ > >> + if (dev->is_virtfn) { > >> + dev->pin = 0; > >> + dev->irq = 0; > >> + return; > >> + } > >> + > >> pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &irq); > >> dev->pin = irq; > >> if (irq) > > > > Amazon Development Center Germany GmbH > Berlin - Dresden - Aachen > main office: Krausenstr. 38, 10117 Berlin > Geschaeftsfuehrer: Dr. Ralf Herbrich, Christian Schlaeger > Ust-ID: DE289237879 > Eingetragen am Amtsgericht Charlottenburg HRB 149173 B
On Wed, Jan 17, 2018 at 07:30:29PM +0100, KarimAllah Ahmed wrote: > ... since INTx is not supported by-spec for virtual functions. > > Cc: Bjorn Helgaas <bhelgaas@google.com> > Cc: linux-pci@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > Signed-off-by: KarimAllah Ahmed <karahmed@amazon.de> > Signed-off-by: Jan H. Schönherr <jschoenh@amazon.de> Applied to pci/virtualization for v4.17, thanks! I tweaked the changelog to include the motivation: commit 16edf1c6345ab177ccf1e8b5ba3324ee01a50eb7 Author: KarimAllah Ahmed <karahmed@amazon.de> Date: Wed Jan 17 19:30:29 2018 +0100 PCI/IOV: Skip INTx config reads for VFs Per PCIe r4.0, sec 9.2.1.4, VFs can not implement INTX, and their Interrupt Line and Interrupt Pin registers must be RO Zero. Some devices have thousands of VFs, so skip reading the registers as an optimization. Signed-off-by: KarimAllah Ahmed <karahmed@amazon.de> Signed-off-by: Jan H. Schönherr <jschoenh@amazon.de> [bhelgaas: changelog, comment] Signed-off-by: Bjorn Helgaas <helgaas@kernel.org> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 489660d0d384..a1cddca37793 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1230,6 +1230,13 @@ static void pci_read_irq(struct pci_dev *dev) { unsigned char irq; + /* VFs are not allowed to use INTx, so skip the config reads */ + if (dev->is_virtfn) { + dev->pin = 0; + dev->irq = 0; + return; + } + pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &irq); dev->pin = irq; if (irq)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 65099d0..61002fb 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1232,6 +1232,13 @@ static void pci_read_irq(struct pci_dev *dev) { unsigned char irq; + /* Virtual functions do not have INTx support */ + if (dev->is_virtfn) { + dev->pin = 0; + dev->irq = 0; + return; + } + pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &irq); dev->pin = irq; if (irq)