Skip to contentSkip to conversation

PCI/IOV: Clarify error message for unbound devices

PATCH RESEND Applied Moritz Fischer 2 participants 2 messages Mar 27, 2021 – May 27, 2021 PCI

lore
Share & tools
lore
#0 lore raw

PATCH RESEND v2 1/1 PCI/IOV: Clarify error message for unbound devices

Be more verbose to disambiguate the error case when trying to configure SRIOV with no driver bound vs. a driver that does not implement the SRIOV callback.

---
Changes from v1:
- Added Krzysztof's Reviewed-by

---
 drivers/pci/iov.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/pci/iov.c +8 -1
index 4afd4ee4f7f0..f9ecc691daf5 100644
@@ -304,8 +304,15 @@ static ssize_t sriov_numvfs_store(struct device *dev,
 	if (num_vfs == pdev->sriov->num_VFs)
 		goto exit;
 
+	/* is PF driver loaded */
+	if (!pdev->driver) {
+		pci_info(pdev, "No driver bound to device. Cannot configure SRIOV\n");
+		ret = -ENOENT;
+		goto exit;
+	}
+
 	/* is PF driver loaded w/callback */
-	if (!pdev->driver || !pdev->driver->sriov_configure) {
+	if (!pdev->driver->sriov_configure) {
 		pci_info(pdev, "Driver does not support SRIOV configuration via sysfs\n");
 		ret = -ENOENT;
 		goto exit;
Signature · 1 line
2.30.2
#1 lore raw
Quoted 7 lines · Moritz Fischer

Be more verbose to disambiguate the error case when trying to configure SRIOV with no driver bound vs. a driver that does not implement the SRIOV callback.

Applied to pci/virtualization for v5.14, thanks!

Quoted 31 lines

---
Changes from v1:
- Added Krzysztof's Reviewed-by

---
 drivers/pci/iov.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/pci/iov.c +8 -1
index 4afd4ee4f7f0..f9ecc691daf5 100644
@@ -304,8 +304,15 @@ static ssize_t sriov_numvfs_store(struct device *dev,
 	if (num_vfs == pdev->sriov->num_VFs)
 		goto exit;
 
+	/* is PF driver loaded */
+	if (!pdev->driver) {
+		pci_info(pdev, "No driver bound to device. Cannot configure SRIOV\n");
+		ret = -ENOENT;
+		goto exit;
+	}
+
 	/* is PF driver loaded w/callback */
-	if (!pdev->driver || !pdev->driver->sriov_configure) {
+	if (!pdev->driver->sriov_configure) {
 		pci_info(pdev, "Driver does not support SRIOV configuration via sysfs\n");
 		ret = -ENOENT;
 		goto exit;
Signature · 1 line
2.30.2