diff mbox

[RFC,V3,02/17] pci/of: Match PCI VFs to dev-tree nodes dynamically

Message ID 1402365399-5121-3-git-send-email-weiyang@linux.vnet.ibm.com (mailing list archive)
State Superseded
Headers show

Commit Message

Wei Yang June 10, 2014, 1:56 a.m. UTC
As introduced by commit 98d9f30c82 ("pci/of: Match PCI devices to dev-tree nodes
dynamically"), we need to match PCI devices to their corresponding dev-tree
nodes. While for VFs, this step was missed.

This patch matches VFs' PCI devices to dev-tree nodes dynamically.

Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com>
---
 drivers/pci/iov.c |    1 +
 1 file changed, 1 insertion(+)

Comments

Gavin Shan June 23, 2014, 5:07 a.m. UTC | #1
On Tue, Jun 10, 2014 at 09:56:24AM +0800, Wei Yang wrote:
>As introduced by commit 98d9f30c82 ("pci/of: Match PCI devices to dev-tree nodes
>dynamically"), we need to match PCI devices to their corresponding dev-tree
>nodes. While for VFs, this step was missed.
>
>This patch matches VFs' PCI devices to dev-tree nodes dynamically.
>
>Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com>
>---
> drivers/pci/iov.c |    1 +
> 1 file changed, 1 insertion(+)
>
>diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
>index 589ef7d..1d21f43 100644
>--- a/drivers/pci/iov.c
>+++ b/drivers/pci/iov.c
>@@ -67,6 +67,7 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset)
>
> 	virtfn->devfn = pci_iov_virtfn_devfn(dev, id);
> 	virtfn->vendor = dev->vendor;
>+	pci_set_of_node(virtfn);

If the VF and PF seats on different PCI buses, I guess pci_set_of_node() always
binds nothing with the VF. It might be one of the problem your code missed and
I didn't catch this in the code review done previously. However, it shouldn't
be a real problem if we're not going to rely on dynamic device_node.

> 	pci_read_config_word(dev, iov->pos + PCI_SRIOV_VF_DID, &virtfn->device);
> 	pci_setup_device(virtfn);
> 	virtfn->dev.parent = dev->dev.parent;

Thanks,
Gavin
Wei Yang June 23, 2014, 6:29 a.m. UTC | #2
On Mon, Jun 23, 2014 at 03:07:47PM +1000, Gavin Shan wrote:
>On Tue, Jun 10, 2014 at 09:56:24AM +0800, Wei Yang wrote:
>>As introduced by commit 98d9f30c82 ("pci/of: Match PCI devices to dev-tree nodes
>>dynamically"), we need to match PCI devices to their corresponding dev-tree
>>nodes. While for VFs, this step was missed.
>>
>>This patch matches VFs' PCI devices to dev-tree nodes dynamically.
>>
>>Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com>
>>---
>> drivers/pci/iov.c |    1 +
>> 1 file changed, 1 insertion(+)
>>
>>diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
>>index 589ef7d..1d21f43 100644
>>--- a/drivers/pci/iov.c
>>+++ b/drivers/pci/iov.c
>>@@ -67,6 +67,7 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset)
>>
>> 	virtfn->devfn = pci_iov_virtfn_devfn(dev, id);
>> 	virtfn->vendor = dev->vendor;
>>+	pci_set_of_node(virtfn);
>
>If the VF and PF seats on different PCI buses, I guess pci_set_of_node() always
>binds nothing with the VF. It might be one of the problem your code missed and
>I didn't catch this in the code review done previously. However, it shouldn't
>be a real problem if we're not going to rely on dynamic device_node.
>

Thanks for the comment.

This case is not took into consideration yet, so it is not supported now.
While I think it is time to think about the solution now.

Hmm... after reading the code a while, this seems some change in current code.

1. The hierarchy of VF's device node
   
                    +---------+
                    |P2P      |parent
                    +----+----+
                         |       pbus
            +------------+------------+              vbus
            |                         |           ---------------+
       +---------+              +-----+---+          |
       |DEV      |child1        |DEV      |child2    |
       +---------+              +---------+          |
                                                  +----+------+
                                                  |VF         | vchild
                                                  +-----------+

   From the chart above, the left side is the device node hierarchy without
   VFs. Each pci device is the direct child of the P2P bridge. When match pci
   device and its device node, the code go through the parent bus node's child
   list and find the one with same devfn.(in pci_set_of_node()). And we can
   tell the parent bus node is the P2P bridge's device node.

   This works fine, untill VFs need to be added. vbus is a child of the pbus,
   and vbus->self is NULL. So first thing is to set the correct device node
   for this virtual bus. From the chart above, looks both P2P bridge and the
   DEV could be the device node. While the later one seems more reasonable.

2. Reserve virtual bus number in firmware
   This is not a big issue, just reserve enough bus number in firmware.
   Otherwise, pci device and device node may not match.

>> 	pci_|ead_config_word(dev, iov->pos + PCI_SRIOV_VF_DID, &virtfn->device);
>> 	pci_setup_device(virtfn);
>> 	virtfn->dev.parent = dev->dev.parent;
>
>Thanks,
>Gavin
diff mbox

Patch

diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index 589ef7d..1d21f43 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -67,6 +67,7 @@  static int virtfn_add(struct pci_dev *dev, int id, int reset)
 
 	virtfn->devfn = pci_iov_virtfn_devfn(dev, id);
 	virtfn->vendor = dev->vendor;
+	pci_set_of_node(virtfn);
 	pci_read_config_word(dev, iov->pos + PCI_SRIOV_VF_DID, &virtfn->device);
 	pci_setup_device(virtfn);
 	virtfn->dev.parent = dev->dev.parent;