All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pci: Do not read INTx PIN and LINE registers for virtual functions
@ 2018-01-17 18:30 KarimAllah Ahmed
  2018-01-17 18:49 ` Alex Williamson
  2018-02-28 22:06 ` Bjorn Helgaas
  0 siblings, 2 replies; 6+ messages in thread
From: KarimAllah Ahmed @ 2018-01-17 18:30 UTC (permalink / raw)
  To: linux-pci
  Cc: KarimAllah Ahmed, Bjorn Helgaas, linux-kernel, Jan H . Schönherr

... 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>
---
 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)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] pci: Do not read INTx PIN and LINE registers for virtual functions
  2018-01-17 18:30 [PATCH] pci: Do not read INTx PIN and LINE registers for virtual functions KarimAllah Ahmed
@ 2018-01-17 18:49 ` Alex Williamson
  2018-01-17 19:02     ` KarimAllah Ahmed
  2018-02-28 22:06 ` Bjorn Helgaas
  1 sibling, 1 reply; 6+ messages in thread
From: Alex Williamson @ 2018-01-17 18:49 UTC (permalink / raw)
  To: KarimAllah Ahmed
  Cc: linux-pci, Bjorn Helgaas, linux-kernel, Jan H . Schönherr

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)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] pci: Do not read INTx PIN and LINE registers for virtual functions
  2018-01-17 18:49 ` Alex Williamson
@ 2018-01-17 19:02     ` KarimAllah Ahmed
  0 siblings, 0 replies; 6+ messages in thread
From: KarimAllah Ahmed @ 2018-01-17 19:02 UTC (permalink / raw)
  To: Alex Williamson, KarimAllah Ahmed
  Cc: linux-pci, Bjorn Helgaas, linux-kernel, Jan H . Schönherr



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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] pci: Do not read INTx PIN and LINE registers for virtual functions
@ 2018-01-17 19:02     ` KarimAllah Ahmed
  0 siblings, 0 replies; 6+ messages in thread
From: KarimAllah Ahmed @ 2018-01-17 19:02 UTC (permalink / raw)
  To: Alex Williamson, KarimAllah Ahmed
  Cc: linux-pci, Bjorn Helgaas, linux-kernel, Jan H . Schönherr

CgpPbiAwMS8xNy8yMDE4IDA3OjQ5IFBNLCBBbGV4IFdpbGxpYW1zb24gd3JvdGU6Cj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F6
b24gRGV2ZWxvcG1lbnQgQ2VudGVyIEdlcm1hbnkgR21iSApCZXJsaW4gLSBEcmVzZGVuIC0gQWFj
aGVuCm1haW4gb2ZmaWNlOiBLcmF1c2Vuc3RyLiAzOCwgMTAxMTcgQmVybGluCkdlc2NoYWVmdHNm
dWVocmVyOiBEci4gUmFsZiBIZXJicmljaCwgQ2hyaXN0aWFuIFNjaGxhZWdlcgpVc3QtSUQ6IERF
Mjg5MjM3ODc5CkVpbmdldHJhZ2VuIGFtIEFtdHNnZXJpY2h0IENoYXJsb3R0ZW5idXJnIEhSQiAx
NDkxNzMgQgo=

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] pci: Do not read INTx PIN and LINE registers for virtual functions
  2018-01-17 19:02     ` KarimAllah Ahmed
  (?)
@ 2018-01-17 19:12     ` Alex Williamson
  -1 siblings, 0 replies; 6+ messages in thread
From: Alex Williamson @ 2018-01-17 19:12 UTC (permalink / raw)
  To: KarimAllah Ahmed
  Cc: KarimAllah Ahmed, linux-pci, Bjorn Helgaas, linux-kernel,
	Jan H . Schönherr

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] pci: Do not read INTx PIN and LINE registers for virtual functions
  2018-01-17 18:30 [PATCH] pci: Do not read INTx PIN and LINE registers for virtual functions KarimAllah Ahmed
  2018-01-17 18:49 ` Alex Williamson
@ 2018-02-28 22:06 ` Bjorn Helgaas
  1 sibling, 0 replies; 6+ messages in thread
From: Bjorn Helgaas @ 2018-02-28 22:06 UTC (permalink / raw)
  To: KarimAllah Ahmed
  Cc: linux-pci, Bjorn Helgaas, linux-kernel, Jan H . Schönherr

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)

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-02-28 22:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-17 18:30 [PATCH] pci: Do not read INTx PIN and LINE registers for virtual functions KarimAllah Ahmed
2018-01-17 18:49 ` Alex Williamson
2018-01-17 19:02   ` KarimAllah Ahmed
2018-01-17 19:02     ` KarimAllah Ahmed
2018-01-17 19:12     ` Alex Williamson
2018-02-28 22:06 ` Bjorn Helgaas

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.