linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI: Fix devfn for VPD access through function 0
@ 2015-09-15 17:17 Alex Williamson
  2015-09-23 17:19 ` Myron Stowe
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Alex Williamson @ 2015-09-15 17:17 UTC (permalink / raw)
  To: bhelgaas, linux-pci; +Cc: mark.d.rustad, myron.stowe, linux-kernel

Commit 932c435caba8 ("PCI: Add dev_flags bit to access VPD through
function 0") passes PCI_SLOT(devfn) for the devfn parameter of
pci_get_slot().  Generally this works because we're fairly well
guaranteed that a PCIe device is at slot address 0, but for the
general case, including conventional PCI, it's incorrect.  We need
to get the slot and then convert it back into a devfn.

Fixes: 932c435caba8 ("PCI: Add dev_flags bit to access VPD through function 0")
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Cc: stable@vger.kernel.org
---

Since the original patch and quirk was marked for stable and applies
to all Intel NICs, regardless of the bus type, I assume this needs to
chase it or VPD might disappear on e1000/e100 if it currently exists.

 drivers/pci/access.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/access.c b/drivers/pci/access.c
index 769f7e3..5a5f0a7 100644
--- a/drivers/pci/access.c
+++ b/drivers/pci/access.c
@@ -442,7 +442,8 @@ static const struct pci_vpd_ops pci_vpd_pci22_ops = {
 static ssize_t pci_vpd_f0_read(struct pci_dev *dev, loff_t pos, size_t count,
 			       void *arg)
 {
-	struct pci_dev *tdev = pci_get_slot(dev->bus, PCI_SLOT(dev->devfn));
+	struct pci_dev *tdev = pci_get_slot(dev->bus,
+					    PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
 	ssize_t ret;
 
 	if (!tdev)
@@ -456,7 +457,8 @@ static ssize_t pci_vpd_f0_read(struct pci_dev *dev, loff_t pos, size_t count,
 static ssize_t pci_vpd_f0_write(struct pci_dev *dev, loff_t pos, size_t count,
 				const void *arg)
 {
-	struct pci_dev *tdev = pci_get_slot(dev->bus, PCI_SLOT(dev->devfn));
+	struct pci_dev *tdev = pci_get_slot(dev->bus,
+					    PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
 	ssize_t ret;
 
 	if (!tdev)
@@ -475,7 +477,8 @@ static const struct pci_vpd_ops pci_vpd_f0_ops = {
 
 static int pci_vpd_f0_dev_check(struct pci_dev *dev)
 {
-	struct pci_dev *tdev = pci_get_slot(dev->bus, PCI_SLOT(dev->devfn));
+	struct pci_dev *tdev = pci_get_slot(dev->bus,
+					    PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
 	int ret = 0;
 
 	if (!tdev)


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

* Re: [PATCH] PCI: Fix devfn for VPD access through function 0
  2015-09-15 17:17 [PATCH] PCI: Fix devfn for VPD access through function 0 Alex Williamson
@ 2015-09-23 17:19 ` Myron Stowe
  2015-09-23 19:11 ` Rustad, Mark D
  2015-09-24 18:27 ` Bjorn Helgaas
  2 siblings, 0 replies; 6+ messages in thread
From: Myron Stowe @ 2015-09-23 17:19 UTC (permalink / raw)
  To: Alex Williamson
  Cc: Bjorn Helgaas, linux-pci, mark.d.rustad, Myron Stowe, LKML

On Tue, Sep 15, 2015 at 11:17 AM, Alex Williamson
<alex.williamson@redhat.com> wrote:
> Commit 932c435caba8 ("PCI: Add dev_flags bit to access VPD through
> function 0") passes PCI_SLOT(devfn) for the devfn parameter of
> pci_get_slot().  Generally this works because we're fairly well
> guaranteed that a PCIe device is at slot address 0, but for the
> general case, including conventional PCI, it's incorrect.  We need
> to get the slot and then convert it back into a devfn.
>
> Fixes: 932c435caba8 ("PCI: Add dev_flags bit to access VPD through function 0")
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> Cc: stable@vger.kernel.org
> ---
>
> Since the original patch and quirk was marked for stable and applies
> to all Intel NICs, regardless of the bus type, I assume this needs to
> chase it or VPD might disappear on e1000/e100 if it currently exists.
>
>  drivers/pci/access.c |    9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/pci/access.c b/drivers/pci/access.c
> index 769f7e3..5a5f0a7 100644
> --- a/drivers/pci/access.c
> +++ b/drivers/pci/access.c
> @@ -442,7 +442,8 @@ static const struct pci_vpd_ops pci_vpd_pci22_ops = {
>  static ssize_t pci_vpd_f0_read(struct pci_dev *dev, loff_t pos, size_t count,
>                                void *arg)
>  {
> -       struct pci_dev *tdev = pci_get_slot(dev->bus, PCI_SLOT(dev->devfn));
> +       struct pci_dev *tdev = pci_get_slot(dev->bus,
> +                                           PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
>         ssize_t ret;
>
>         if (!tdev)
> @@ -456,7 +457,8 @@ static ssize_t pci_vpd_f0_read(struct pci_dev *dev, loff_t pos, size_t count,
>  static ssize_t pci_vpd_f0_write(struct pci_dev *dev, loff_t pos, size_t count,
>                                 const void *arg)
>  {
> -       struct pci_dev *tdev = pci_get_slot(dev->bus, PCI_SLOT(dev->devfn));
> +       struct pci_dev *tdev = pci_get_slot(dev->bus,
> +                                           PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
>         ssize_t ret;
>
>         if (!tdev)
> @@ -475,7 +477,8 @@ static const struct pci_vpd_ops pci_vpd_f0_ops = {
>
>  static int pci_vpd_f0_dev_check(struct pci_dev *dev)
>  {
> -       struct pci_dev *tdev = pci_get_slot(dev->bus, PCI_SLOT(dev->devfn));
> +       struct pci_dev *tdev = pci_get_slot(dev->bus,
> +                                           PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
>         int ret = 0;
>
>         if (!tdev)
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Acked-by: Myron Stowe <myron.stowe@redhat.com>

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

* Re: [PATCH] PCI: Fix devfn for VPD access through function 0
  2015-09-15 17:17 [PATCH] PCI: Fix devfn for VPD access through function 0 Alex Williamson
  2015-09-23 17:19 ` Myron Stowe
@ 2015-09-23 19:11 ` Rustad, Mark D
  2015-09-24 18:27 ` Bjorn Helgaas
  2 siblings, 0 replies; 6+ messages in thread
From: Rustad, Mark D @ 2015-09-23 19:11 UTC (permalink / raw)
  To: Alex Williamson
  Cc: bhelgaas@google.com, linux-pci@vger.kernel.org,
	myron.stowe@redhat.com, linux-kernel@vger.kernel.org

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

> On Sep 15, 2015, at 10:17 AM, Alex Williamson <alex.williamson@redhat.com> wrote:
> 
> Commit 932c435caba8 ("PCI: Add dev_flags bit to access VPD through
> function 0") passes PCI_SLOT(devfn) for the devfn parameter of
> pci_get_slot().  Generally this works because we're fairly well
> guaranteed that a PCIe device is at slot address 0, but for the
> general case, including conventional PCI, it's incorrect.  We need
> to get the slot and then convert it back into a devfn.
> 
> Fixes: 932c435caba8 ("PCI: Add dev_flags bit to access VPD through function 0")
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> Cc: stable@vger.kernel.org
> ---
> 
> Since the original patch and quirk was marked for stable and applies
> to all Intel NICs, regardless of the bus type, I assume this needs to
> chase it or VPD might disappear on e1000/e100 if it currently exists.

This looks good to me.
Acked-by: Mark Rustad <mark.d.rustad@intel.com>

--
Mark Rustad, Networking Division, Intel Corporation


[-- Attachment #2: Message signed with OpenPGP using GPGMail --]
[-- Type: application/pgp-signature, Size: 841 bytes --]

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

* Re: [PATCH] PCI: Fix devfn for VPD access through function 0
  2015-09-15 17:17 [PATCH] PCI: Fix devfn for VPD access through function 0 Alex Williamson
  2015-09-23 17:19 ` Myron Stowe
  2015-09-23 19:11 ` Rustad, Mark D
@ 2015-09-24 18:27 ` Bjorn Helgaas
  2015-09-24 18:35   ` Rustad, Mark D
  2 siblings, 1 reply; 6+ messages in thread
From: Bjorn Helgaas @ 2015-09-24 18:27 UTC (permalink / raw)
  To: Alex Williamson
  Cc: bhelgaas, linux-pci, mark.d.rustad, myron.stowe, linux-kernel

On Tue, Sep 15, 2015 at 11:17:21AM -0600, Alex Williamson wrote:
> Commit 932c435caba8 ("PCI: Add dev_flags bit to access VPD through
> function 0") passes PCI_SLOT(devfn) for the devfn parameter of
> pci_get_slot().  Generally this works because we're fairly well
> guaranteed that a PCIe device is at slot address 0, but for the
> general case, including conventional PCI, it's incorrect.  We need
> to get the slot and then convert it back into a devfn.
> 
> Fixes: 932c435caba8 ("PCI: Add dev_flags bit to access VPD through function 0")
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> Cc: stable@vger.kernel.org

Applied to for-linus for v4.3 with acks from Myron & Mark, thanks!

I removed the stable tag because 932c435caba8 first appeared in
v4.3-rc1, so it shouldn't appear in any stable kernels yet.  Right?

> ---
> 
> Since the original patch and quirk was marked for stable and applies
> to all Intel NICs, regardless of the bus type, I assume this needs to
> chase it or VPD might disappear on e1000/e100 if it currently exists.
> 
>  drivers/pci/access.c |    9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pci/access.c b/drivers/pci/access.c
> index 769f7e3..5a5f0a7 100644
> --- a/drivers/pci/access.c
> +++ b/drivers/pci/access.c
> @@ -442,7 +442,8 @@ static const struct pci_vpd_ops pci_vpd_pci22_ops = {
>  static ssize_t pci_vpd_f0_read(struct pci_dev *dev, loff_t pos, size_t count,
>  			       void *arg)
>  {
> -	struct pci_dev *tdev = pci_get_slot(dev->bus, PCI_SLOT(dev->devfn));
> +	struct pci_dev *tdev = pci_get_slot(dev->bus,
> +					    PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
>  	ssize_t ret;
>  
>  	if (!tdev)
> @@ -456,7 +457,8 @@ static ssize_t pci_vpd_f0_read(struct pci_dev *dev, loff_t pos, size_t count,
>  static ssize_t pci_vpd_f0_write(struct pci_dev *dev, loff_t pos, size_t count,
>  				const void *arg)
>  {
> -	struct pci_dev *tdev = pci_get_slot(dev->bus, PCI_SLOT(dev->devfn));
> +	struct pci_dev *tdev = pci_get_slot(dev->bus,
> +					    PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
>  	ssize_t ret;
>  
>  	if (!tdev)
> @@ -475,7 +477,8 @@ static const struct pci_vpd_ops pci_vpd_f0_ops = {
>  
>  static int pci_vpd_f0_dev_check(struct pci_dev *dev)
>  {
> -	struct pci_dev *tdev = pci_get_slot(dev->bus, PCI_SLOT(dev->devfn));
> +	struct pci_dev *tdev = pci_get_slot(dev->bus,
> +					    PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
>  	int ret = 0;
>  
>  	if (!tdev)
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [PATCH] PCI: Fix devfn for VPD access through function 0
  2015-09-24 18:27 ` Bjorn Helgaas
@ 2015-09-24 18:35   ` Rustad, Mark D
  2015-09-24 19:03     ` Bjorn Helgaas
  0 siblings, 1 reply; 6+ messages in thread
From: Rustad, Mark D @ 2015-09-24 18:35 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Alex Williamson, bhelgaas@google.com, linux-pci@vger.kernel.org,
	myron.stowe@redhat.com, linux-kernel@vger.kernel.org

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

> On Sep 24, 2015, at 11:27 AM, Bjorn Helgaas <helgaas@kernel.org> wrote:
> 
> Applied to for-linus for v4.3 with acks from Myron & Mark, thanks!
> 
> I removed the stable tag because 932c435caba8 first appeared in
> v4.3-rc1, so it shouldn't appear in any stable kernels yet.  Right?

I have seen the patch in some stable code reviews already. I know it was deferred from one, but I see it in the changelogs for 4.1.8 and 4.2.1. I have lost track if it is in any others.

--
Mark Rustad, Networking Division, Intel Corporation


[-- Attachment #2: Message signed with OpenPGP using GPGMail --]
[-- Type: application/pgp-signature, Size: 841 bytes --]

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

* Re: [PATCH] PCI: Fix devfn for VPD access through function 0
  2015-09-24 18:35   ` Rustad, Mark D
@ 2015-09-24 19:03     ` Bjorn Helgaas
  0 siblings, 0 replies; 6+ messages in thread
From: Bjorn Helgaas @ 2015-09-24 19:03 UTC (permalink / raw)
  To: Rustad, Mark D
  Cc: Alex Williamson, bhelgaas@google.com, linux-pci@vger.kernel.org,
	myron.stowe@redhat.com, linux-kernel@vger.kernel.org

On Thu, Sep 24, 2015 at 06:35:30PM +0000, Rustad, Mark D wrote:
> > On Sep 24, 2015, at 11:27 AM, Bjorn Helgaas <helgaas@kernel.org> wrote:
> > 
> > Applied to for-linus for v4.3 with acks from Myron & Mark, thanks!
> > 
> > I removed the stable tag because 932c435caba8 first appeared in
> > v4.3-rc1, so it shouldn't appear in any stable kernels yet.  Right?
> 
> I have seen the patch in some stable code reviews already. I know it
> was deferred from one, but I see it in the changelogs for 4.1.8 and
> 4.2.1. I have lost track if it is in any others.

I added the stable tag back.  932c435caba8 itself was marked for
stable, so I guess bugfixes to it should be marked the same way.

Bjorn

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

end of thread, other threads:[~2015-09-24 19:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-15 17:17 [PATCH] PCI: Fix devfn for VPD access through function 0 Alex Williamson
2015-09-23 17:19 ` Myron Stowe
2015-09-23 19:11 ` Rustad, Mark D
2015-09-24 18:27 ` Bjorn Helgaas
2015-09-24 18:35   ` Rustad, Mark D
2015-09-24 19:03     ` Bjorn Helgaas

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