diff options
author | Bjorn Helgaas <bhelgaas@google.com> | 2013-06-05 14:27:19 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2013-06-05 14:27:19 -0400 |
commit | bb4bac9308bf8df5027dcbf27f1016104e3a504f (patch) | |
tree | 7c02fddf034225871db208cc6e7fee0f959bcaf3 | |
parent | 06886e8043877d5c439f5e2a3bcf23761bc1ae9d (diff) | |
parent | dfab88beda88d6c24111e5966b08ecf813c3a18a (diff) |
Merge branch 'pci/jiang-iov-fixes' into next
* pci/jiang-iov-fixes:
PCI: Hide remove and rescan sysfs interfaces for SR-IOV virtual functions
PCI: Finish SR-IOV VF setup before adding the device
-rw-r--r-- | drivers/pci/iov.c | 5 | ||||
-rw-r--r-- | drivers/pci/pci-sysfs.c | 30 |
2 files changed, 30 insertions, 5 deletions
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index c93071d428f5..a971a6f6268d 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c | |||
@@ -92,6 +92,8 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset) | |||
92 | pci_read_config_word(dev, iov->pos + PCI_SRIOV_VF_DID, &virtfn->device); | 92 | pci_read_config_word(dev, iov->pos + PCI_SRIOV_VF_DID, &virtfn->device); |
93 | pci_setup_device(virtfn); | 93 | pci_setup_device(virtfn); |
94 | virtfn->dev.parent = dev->dev.parent; | 94 | virtfn->dev.parent = dev->dev.parent; |
95 | virtfn->physfn = pci_dev_get(dev); | ||
96 | virtfn->is_virtfn = 1; | ||
95 | 97 | ||
96 | for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) { | 98 | for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) { |
97 | res = dev->resource + PCI_IOV_RESOURCES + i; | 99 | res = dev->resource + PCI_IOV_RESOURCES + i; |
@@ -113,9 +115,6 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset) | |||
113 | pci_device_add(virtfn, virtfn->bus); | 115 | pci_device_add(virtfn, virtfn->bus); |
114 | mutex_unlock(&iov->dev->sriov->lock); | 116 | mutex_unlock(&iov->dev->sriov->lock); |
115 | 117 | ||
116 | virtfn->physfn = pci_dev_get(dev); | ||
117 | virtfn->is_virtfn = 1; | ||
118 | |||
119 | rc = pci_bus_add_device(virtfn); | 118 | rc = pci_bus_add_device(virtfn); |
120 | sprintf(buf, "virtfn%u", id); | 119 | sprintf(buf, "virtfn%u", id); |
121 | rc = sysfs_create_link(&dev->dev.kobj, &virtfn->dev.kobj, buf); | 120 | rc = sysfs_create_link(&dev->dev.kobj, &virtfn->dev.kobj, buf); |
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 0b56e0865f38..c0dbe1f61362 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c | |||
@@ -325,6 +325,8 @@ dev_rescan_store(struct device *dev, struct device_attribute *attr, | |||
325 | } | 325 | } |
326 | return count; | 326 | return count; |
327 | } | 327 | } |
328 | struct device_attribute dev_rescan_attr = __ATTR(rescan, (S_IWUSR|S_IWGRP), | ||
329 | NULL, dev_rescan_store); | ||
328 | 330 | ||
329 | static void remove_callback(struct device *dev) | 331 | static void remove_callback(struct device *dev) |
330 | { | 332 | { |
@@ -354,6 +356,8 @@ remove_store(struct device *dev, struct device_attribute *dummy, | |||
354 | count = ret; | 356 | count = ret; |
355 | return count; | 357 | return count; |
356 | } | 358 | } |
359 | struct device_attribute dev_remove_attr = __ATTR(remove, (S_IWUSR|S_IWGRP), | ||
360 | NULL, remove_store); | ||
357 | 361 | ||
358 | static ssize_t | 362 | static ssize_t |
359 | dev_bus_rescan_store(struct device *dev, struct device_attribute *attr, | 363 | dev_bus_rescan_store(struct device *dev, struct device_attribute *attr, |
@@ -504,8 +508,6 @@ struct device_attribute pci_dev_attrs[] = { | |||
504 | __ATTR(broken_parity_status,(S_IRUGO|S_IWUSR), | 508 | __ATTR(broken_parity_status,(S_IRUGO|S_IWUSR), |
505 | broken_parity_status_show,broken_parity_status_store), | 509 | broken_parity_status_show,broken_parity_status_store), |
506 | __ATTR(msi_bus, 0644, msi_bus_show, msi_bus_store), | 510 | __ATTR(msi_bus, 0644, msi_bus_show, msi_bus_store), |
507 | __ATTR(remove, (S_IWUSR|S_IWGRP), NULL, remove_store), | ||
508 | __ATTR(rescan, (S_IWUSR|S_IWGRP), NULL, dev_rescan_store), | ||
509 | #if defined(CONFIG_PM_RUNTIME) && defined(CONFIG_ACPI) | 511 | #if defined(CONFIG_PM_RUNTIME) && defined(CONFIG_ACPI) |
510 | __ATTR(d3cold_allowed, 0644, d3cold_allowed_show, d3cold_allowed_store), | 512 | __ATTR(d3cold_allowed, 0644, d3cold_allowed_show, d3cold_allowed_store), |
511 | #endif | 513 | #endif |
@@ -1463,6 +1465,29 @@ static umode_t pci_dev_attrs_are_visible(struct kobject *kobj, | |||
1463 | return a->mode; | 1465 | return a->mode; |
1464 | } | 1466 | } |
1465 | 1467 | ||
1468 | static struct attribute *pci_dev_hp_attrs[] = { | ||
1469 | &dev_remove_attr.attr, | ||
1470 | &dev_rescan_attr.attr, | ||
1471 | NULL, | ||
1472 | }; | ||
1473 | |||
1474 | static umode_t pci_dev_hp_attrs_are_visible(struct kobject *kobj, | ||
1475 | struct attribute *a, int n) | ||
1476 | { | ||
1477 | struct device *dev = container_of(kobj, struct device, kobj); | ||
1478 | struct pci_dev *pdev = to_pci_dev(dev); | ||
1479 | |||
1480 | if (pdev->is_virtfn) | ||
1481 | return 0; | ||
1482 | |||
1483 | return a->mode; | ||
1484 | } | ||
1485 | |||
1486 | static struct attribute_group pci_dev_hp_attr_group = { | ||
1487 | .attrs = pci_dev_hp_attrs, | ||
1488 | .is_visible = pci_dev_hp_attrs_are_visible, | ||
1489 | }; | ||
1490 | |||
1466 | #ifdef CONFIG_PCI_IOV | 1491 | #ifdef CONFIG_PCI_IOV |
1467 | static struct attribute *sriov_dev_attrs[] = { | 1492 | static struct attribute *sriov_dev_attrs[] = { |
1468 | &sriov_totalvfs_attr.attr, | 1493 | &sriov_totalvfs_attr.attr, |
@@ -1494,6 +1519,7 @@ static struct attribute_group pci_dev_attr_group = { | |||
1494 | 1519 | ||
1495 | static const struct attribute_group *pci_dev_attr_groups[] = { | 1520 | static const struct attribute_group *pci_dev_attr_groups[] = { |
1496 | &pci_dev_attr_group, | 1521 | &pci_dev_attr_group, |
1522 | &pci_dev_hp_attr_group, | ||
1497 | #ifdef CONFIG_PCI_IOV | 1523 | #ifdef CONFIG_PCI_IOV |
1498 | &sriov_dev_attr_group, | 1524 | &sriov_dev_attr_group, |
1499 | #endif | 1525 | #endif |