PCI: set correct value for iov device before device
PATCH 1/1 PCI: set correct value for iov device before device
Since device registering is put into pci_device_add(), it must set value of Virtual Function device's member before the pci_dev is put to device tree. Or some relevant subsystem of driver model such as xen will report a incorrect IOV device to Xen hypervior.
--- drivers/pci/iov.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pci/iov.c +3 -3
@@ -110,12 +110,12 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset)if (reset)__pci_reset_function (virtfn); -pci_device_add (virtfn, virtfn->bus); -mutex_unlock (&iov->dev->sriov->lock); - virtfn->physfn =pci_dev_get (dev); virtfn->is_virtfn =1 ; +pci_device_add (virtfn, virtfn->bus); +mutex_unlock (&iov->dev->sriov->lock); + rc =pci_bus_add_device (virtfn);sprintf (buf,"virtfn%u" , id); rc =sysfs_create_link (&dev->dev.kobj, &virtfn->dev.kobj, buf);
Signature · 1 line
1.7.12.1
Hi Xudong,
This bug has been fixed by Jiang Liu in patch
https://patchwork.kernel.org/patch/2613481/
Quoted 31 lines · Xudong Hao
Since device registering is put into
pci_device_add(), it must set value of Virtual Function device's member before thepci_devis put to device tree. Or some relevant subsystem of driver model such as xen will report a incorrect IOV device to Xen hypervior.Signed-off-by Xudong Hao <[email protected]>--- drivers/pci/iov.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/pci/iov.c +3
-3@@ -110,12 +110,12 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset)if (reset)__pci_reset_function (virtfn); -pci_device_add (virtfn, virtfn->bus); -mutex_unlock (&iov->dev->sriov->lock); - virtfn->physfn =pci_dev_get (dev); virtfn->is_virtfn =1 ; +pci_device_add (virtfn, virtfn->bus); +mutex_unlock (&iov->dev->sriov->lock); + rc =pci_bus_add_device (virtfn);sprintf (buf,"virtfn%u" , id); rc =sysfs_create_link (&dev->dev.kobj, &virtfn->dev.kobj, buf);
Signature · 2 lines
Thanks! Yijing
Quoted 20 lines · Xudong Hao
Since device registering is put into
pci_device_add(), it must set value of Virtual Function device's member before thepci_devis put to device tree. Or some relevant subsystem of driver model such as xen will report a incorrect IOV device to Xen hypervior.Signed-off-by Xudong Hao <[email protected]>--- drivers/pci/iov.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/pci/iov.c +0
-2@@ -110,12 +110,12 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset)if (reset)__pci_reset_function (virtfn); -pci_device_add (virtfn, virtfn->bus); -mutex_unlock (&iov->dev->sriov->lock);
drivers/pci/iov.c static int virtfn_add(struct pci_dev *dev, int id, int reset) · line 121
Quoted 10 lines
drivers/pci/iov.c +3
-1- virtfn->physfn =pci_dev_get (dev); virtfn->is_virtfn =1 ; +pci_device_add (virtfn, virtfn->bus); +mutex_unlock (&iov->dev->sriov->lock); + rc =pci_bus_add_device (virtfn);sprintf (buf,"virtfn%u" , id); rc =sysfs_create_link (&dev->dev.kobj, &virtfn->dev.kobj, buf);
I have similar patch at
https://patchwork.kernel.org/patch/2562551/
[5/7] PCI, ACPI: Don't glue ACPI dev with pci VFs
and Jiang has another one
https://patchwork.kernel.org/patch/2613481/
[v3,part1,10/10] PCI, IOV: hide remove and rescan sysfs interfaces
for SR-IOV virtual functions
Thanks
Yinghai
Okay, I saw patch in PCI tree two days ago by Jiang Liu.
Thanks,
-Xudong
Quoted 54 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Yinghai Lu
Sent: Thursday, May 30, 2013 2:05 PM
To: Hao, Xudong
Cc: Bjorn Helgaas; [email protected]; Linux Kernel Mailing List
Subject: Re: [PATCH] PCI: set correct value for iov device before devicedrivers/pci/iov.c static int virtfn_add(struct pci_dev *dev, int id, int
Quoted 15 lines · Xudong Hao
Since device registering is put into
pci_device_add(), it must set value of Virtual Function device's member before thepci_devis put to device tree. Or some relevant subsystem of driver model such as xen will report a incorrect IOV device to Xen hypervior.Signed-off-by Xudong Hao <[email protected]>--- drivers/pci/iov.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/pci/iov.c +0
-0@@ -110,12 +110,12 @@ static int virtfn_add(struct pci_dev *dev, int id, intreset)
Quoted 5 lines
drivers/pci/iov.c +0
-2if (reset)__pci_reset_function (virtfn); -pci_device_add (virtfn, virtfn->bus); -mutex_unlock (&iov->dev->sriov->lock);drivers/pci/iov.c static int virtfn_add(struct pci_dev *dev, int id, int reset) · line 121
Quoted 10 lines
drivers/pci/iov.c +3
-1- virtfn->physfn =pci_dev_get (dev); virtfn->is_virtfn =1 ; +pci_device_add (virtfn, virtfn->bus); +mutex_unlock (&iov->dev->sriov->lock); + rc =pci_bus_add_device (virtfn);sprintf (buf,"virtfn%u" , id); rc =sysfs_create_link (&dev->dev.kobj, &virtfn->dev.kobj, buf);I have similar patch at
https://patchwork.kernel.org/patch/2562551/
[5/7] PCI, ACPI: Don't glue ACPI dev with pci VFsand Jiang has another one
https://patchwork.kernel.org/patch/2613481/
[v3,part1,10/10] PCI, IOV: hide remove and rescan sysfs interfaces
for SR-IOV virtual functionsThanks
Yinghai
Quoted 36 lines · Yinghai Lu
Quoted 20 lines · Xudong Hao
Since device registering is put into
pci_device_add(), it must set value of Virtual Function device's member before thepci_devis put to device tree. Or some relevant subsystem of driver model such as xen will report a incorrect IOV device to Xen hypervior.Signed-off-by Xudong Hao <[email protected]>--- drivers/pci/iov.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/pci/iov.c +0
-2@@ -110,12 +110,12 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset)if (reset)__pci_reset_function (virtfn); -pci_device_add (virtfn, virtfn->bus); -mutex_unlock (&iov->dev->sriov->lock);drivers/pci/iov.c static int virtfn_add(struct pci_dev *dev, int id, int reset) · line 121
Quoted 10 lines
drivers/pci/iov.c +3
-1- virtfn->physfn =pci_dev_get (dev); virtfn->is_virtfn =1 ; +pci_device_add (virtfn, virtfn->bus); +mutex_unlock (&iov->dev->sriov->lock); + rc =pci_bus_add_device (virtfn);sprintf (buf,"virtfn%u" , id); rc =sysfs_create_link (&dev->dev.kobj, &virtfn->dev.kobj, buf);I have similar patch at
https://patchwork.kernel.org/patch/2562551/
[5/7] PCI, ACPI: Don't glue ACPI dev with pci VFs
Quoted 4 lines
and Jiang has another one
https://patchwork.kernel.org/patch/2613481/
[v3,part1,10/10] PCI, IOV: hide remove and rescan sysfs interfaces
for SR-IOV virtual functions
Bjorn,
I double check this one, we should split the patch from me or Jiang. and the one about set virtfn=1 should be -stable material.
That will address another problem that is caused by moving device_add from pci_bus_add_device to pci_device_add.
Yinghai
Bjorn Helgaas
maintainerQuoted 37 lines · Yinghai Lu
Quoted 36 lines · Yinghai Lu
Quoted 20 lines · Xudong Hao
Since device registering is put into
pci_device_add(), it must set value of Virtual Function device's member before thepci_devis put to device tree. Or some relevant subsystem of driver model such as xen will report a incorrect IOV device to Xen hypervior.Signed-off-by Xudong Hao <[email protected]>--- drivers/pci/iov.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/pci/iov.c +0
-2@@ -110,12 +110,12 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset)if (reset)__pci_reset_function (virtfn); -pci_device_add (virtfn, virtfn->bus); -mutex_unlock (&iov->dev->sriov->lock);drivers/pci/iov.c static int virtfn_add(struct pci_dev *dev, int id, int reset) · line 121
Quoted 10 lines
drivers/pci/iov.c +3
-1- virtfn->physfn =pci_dev_get (dev); virtfn->is_virtfn =1 ; +pci_device_add (virtfn, virtfn->bus); +mutex_unlock (&iov->dev->sriov->lock); + rc =pci_bus_add_device (virtfn);sprintf (buf,"virtfn%u" , id); rc =sysfs_create_link (&dev->dev.kobj, &virtfn->dev.kobj, buf);I have similar patch at
https://patchwork.kernel.org/patch/2562551/
[5/7] PCI, ACPI: Don't glue ACPI dev with pci VFs
Quoted 8 lines
Quoted 4 lines
and Jiang has another one
https://patchwork.kernel.org/patch/2613481/
[v3,part1,10/10] PCI, IOV: hide remove and rescan sysfs interfaces
for SR-IOV virtual functionsBjorn,
I double check this one, we should split the patch from me or Jiang.
I don't know what the sentence above means.
Quoted 1 line
and the one about set virtfn=1 should be -stable material.
I assume you mean that Jiang's "[v3,part1,10/10] PCI, IOV: hide remove and rescan sysfs interfaces for SR-IOV virtual functions" patch does not need to be in v3.10, but it should be marked for -stable.
How far back should it go? v3.9+?
Quoted 2 lines
That will address another problem that is caused by moving
device_addfrompci_bus_add_devicetopci_device_add.
I assume you're talking about a problem caused by 4f535093 ("PCI: Put pci_dev in device tree as early as possible"). That commit appeared in v3.9.
If we're asking to add the "hide remove and rescan sysfs interfaces" patch to the v3.9 stable series, we should have a description of exactly what problem it fixes, and ideally, a bugzilla for it. Can you provide that?
That patch appears to be the only one in the [v3,part1,0/10] series that actually directly fixes an issue, so it would be nice to have more specifics in that changelog to begin with. The other patches in that series appear to to be cleanups and preparation for the real fixes that will come later.
Bjorn
Quoted 43 lines · Bjorn Helgaas
Quoted 42 lines · Yinghai Lu
Quoted 40 lines · Yinghai Lu
Quoted 20 lines · Xudong Hao
Since device registering is put into
pci_device_add(), it must set value of Virtual Function device's member before thepci_devis put to device tree. Or some relevant subsystem of driver model such as xen will report a incorrect IOV device to Xen hypervior.Signed-off-by Xudong Hao <[email protected]>--- drivers/pci/iov.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/pci/iov.c +0
-2@@ -110,12 +110,12 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset)if (reset)__pci_reset_function (virtfn); -pci_device_add (virtfn, virtfn->bus); -mutex_unlock (&iov->dev->sriov->lock);drivers/pci/iov.c static int virtfn_add(struct pci_dev *dev, int id, int reset) · line 121
Quoted 10 lines
drivers/pci/iov.c +3
-1- virtfn->physfn =pci_dev_get (dev); virtfn->is_virtfn =1 ; +pci_device_add (virtfn, virtfn->bus); +mutex_unlock (&iov->dev->sriov->lock); + rc =pci_bus_add_device (virtfn);sprintf (buf,"virtfn%u" , id); rc =sysfs_create_link (&dev->dev.kobj, &virtfn->dev.kobj, buf);I have similar patch at
https://patchwork.kernel.org/patch/2562551/
[5/7] PCI, ACPI: Don't glue ACPI dev with pci VFsand Jiang has another one
https://patchwork.kernel.org/patch/2613481/
[v3,part1,10/10] PCI, IOV: hide remove and rescan sysfs interfaces
for SR-IOV virtual functions
Quoted 5 lines
Quoted 3 lines
Bjorn,
I double check this one, we should split the patch from me or Jiang.
I don't know what the sentence above means.
I mean half of patch
https://patchwork.kernel.org/patch/2562551/
or half of patch
https://patchwork.kernel.org/patch/2613481/
just like what Xudong extracted.
Quoted 6 lines
Quoted 2 lines
and the one about set virtfn=1 should be -stable material.
I assume you mean that Jiang's "[v3,part1,10/10] PCI, IOV: hide remove and rescan sysfs interfaces for SR-IOV virtual functions" patch does not need to be in v3.10, but it should be marked for -stable.
no half of it, move set virtfn=1 two lines forward.
Quoted 2 lines
How far back should it go? v3.9+?
yes. v3.9+
Quoted 7 lines
Quoted 3 lines
That will address another problem that is caused by moving
device_addfrompci_bus_add_devicetopci_device_add.I assume you're talking about a problem caused by
4f535093("PCI: Putpci_devin device tree as early as possible"). That commit appeared in v3.9.
yes.
Quoted 5 lines
If we're asking to add the "hide remove and rescan sysfs interfaces" patch to the v3.9 stable series, we should have a description of exactly what problem it fixes, and ideally, a bugzilla for it. Can you provide that?
No. that is not what i mean.
That problem have been there when sriov support was added.
Quoted 6 lines
That patch appears to be the only one in the [v3,part1,0/10] series that actually directly fixes an issue, so it would be nice to have more specifics in that changelog to begin with. The other patches in that series appear to to be cleanups and preparation for the real fixes that will come later.
yes. even should be separated from that patchset.
Yinghai
Quoted 98 lines · Yinghai Lu
Quoted 43 lines · Bjorn Helgaas
Quoted 42 lines · Yinghai Lu
Quoted 40 lines · Yinghai Lu
Quoted 20 lines · Xudong Hao
Since device registering is put into
pci_device_add(), it must set value of Virtual Function device's member before thepci_devis put to device tree. Or some relevant subsystem of driver model such as xen will report a incorrect IOV device to Xen hypervior.Signed-off-by Xudong Hao <[email protected]>--- drivers/pci/iov.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/pci/iov.c +0
-2@@ -110,12 +110,12 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset)if (reset)__pci_reset_function (virtfn); -pci_device_add (virtfn, virtfn->bus); -mutex_unlock (&iov->dev->sriov->lock);drivers/pci/iov.c static int virtfn_add(struct pci_dev *dev, int id, int reset) · line 121
Quoted 10 lines
drivers/pci/iov.c +3
-1- virtfn->physfn =pci_dev_get (dev); virtfn->is_virtfn =1 ; +pci_device_add (virtfn, virtfn->bus); +mutex_unlock (&iov->dev->sriov->lock); + rc =pci_bus_add_device (virtfn);sprintf (buf,"virtfn%u" , id); rc =sysfs_create_link (&dev->dev.kobj, &virtfn->dev.kobj, buf);I have similar patch at
https://patchwork.kernel.org/patch/2562551/
[5/7] PCI, ACPI: Don't glue ACPI dev with pci VFsand Jiang has another one
https://patchwork.kernel.org/patch/2613481/
[v3,part1,10/10] PCI, IOV: hide remove and rescan sysfs interfaces
for SR-IOV virtual functionsQuoted 5 lines
Quoted 3 lines
Bjorn,
I double check this one, we should split the patch from me or Jiang.
I don't know what the sentence above means.
I mean half of patch
https://patchwork.kernel.org/patch/2562551/
or half of patch
https://patchwork.kernel.org/patch/2613481/just like what Xudong extracted.
Quoted 6 lines
Quoted 2 lines
and the one about set virtfn=1 should be -stable material.
I assume you mean that Jiang's "[v3,part1,10/10] PCI, IOV: hide remove and rescan sysfs interfaces for SR-IOV virtual functions" patch does not need to be in v3.10, but it should be marked for -stable.
no half of it, move set virtfn=1 two lines forward.
Quoted 2 lines
How far back should it go? v3.9+?
yes. v3.9+
Quoted 7 lines
Quoted 3 lines
That will address another problem that is caused by moving
device_addfrompci_bus_add_devicetopci_device_add.I assume you're talking about a problem caused by
4f535093("PCI: Putpci_devin device tree as early as possible"). That commit appeared in v3.9.yes.
Quoted 5 lines
If we're asking to add the "hide remove and rescan sysfs interfaces" patch to the v3.9 stable series, we should have a description of exactly what problem it fixes, and ideally, a bugzilla for it. Can you provide that?
No. that is not what i mean.
That problem have been there when sriov support was added.
Quoted 6 lines
That patch appears to be the only one in the [v3,part1,0/10] series that actually directly fixes an issue, so it would be nice to have more specifics in that changelog to begin with. The other patches in that series appear to to be cleanups and preparation for the real fixes that will come later.
Quoted 7 lines
yes. even should be separated from that patchset.
Yinghai
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Bjorn and Yinghai,
I think it's ok to separate out the bugfix part.
We found this issue when implementing the mechanism to hide
"remove"
sysfs entry for PCI virtual functions because it depends on "is_virtfn" flag to
hide "remove" sysfs entry. Actually I didn't realize it also fixes other issues
when making this change.
Sorry for the inconvenience!
Gerry