Skip to contentSkip to conversation

vfio: Use dev_printk() when possible

PATCH Superseded Bjorn Helgaas 5 participants 6 messages Mar 25, 2019 – Mar 29, 2019

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vfio: Use dev_printk() when possible

From: Bjorn Helgaas <[email protected]>

Use dev_printk() when possible to make messages consistent with other device-related messages.

---
 drivers/vfio/pci/vfio_pci.c                   |  8 ++---
 drivers/vfio/pci/vfio_pci_config.c            | 29 +++++++++----------
 .../platform/reset/vfio_platform_amdxgbe.c    |  5 ++--
 drivers/vfio/platform/vfio_platform_common.c  | 12 ++++----
 drivers/vfio/vfio.c                           | 29 +++++++++----------
 5 files changed, 40 insertions(+), 43 deletions(-)
drivers/vfio/pci/vfio_pci.c +4 -4
index a25659b5a5d1..a538fd995429 100644
@@ -287,8 +287,8 @@ static int vfio_pci_enable(struct vfio_pci_device *vdev)
 	pci_save_state(pdev);
 	vdev->pci_saved_state = pci_store_saved_state(pdev);
 	if (!vdev->pci_saved_state)
-		pr_debug("%s: Couldn't store %s saved state\n",
-			 __func__, dev_name(&pdev->dev));
+		dev_dbg(&pdev->dev, "%s: Couldn't store saved state\n",
+			__func__);
 
 	if (likely(!nointxmask)) {
 		if (vfio_pci_nointx(pdev)) {
@@ -429,8 +429,8 @@ static void vfio_pci_disable(struct vfio_pci_device *vdev)
 	 * is just busy work.
 	 */
 	if (pci_load_and_free_saved_state(pdev, &vdev->pci_saved_state)) {
-		pr_info("%s: Couldn't reload %s saved state\n",
-			__func__, dev_name(&pdev->dev));
+		dev_info(&pdev->dev, "%s: Couldn't reload saved state\n",
+			 __func__);
 
 		if (!vdev->reset_works)
 			goto out;
drivers/vfio/pci/vfio_pci_config.c +13 -16
index e82b51114687..44d865576a92 100644
@@ -412,8 +412,7 @@ static void vfio_bar_restore(struct vfio_pci_device *vdev)
 	if (pdev->is_virtfn)
 		return;
 
-	pr_info("%s: %s reset recovery - restoring bars\n",
-		__func__, dev_name(&pdev->dev));
+	dev_info(&pdev->dev, "%s: reset recovery - restoring BARs\n", __func__);
 
 	for (i = PCI_BASE_ADDRESS_0; i <= PCI_BASE_ADDRESS_5; i += 4, rbar++)
 		pci_user_write_config_dword(pdev, i, *rbar);
@@ -1298,8 +1297,8 @@ static int vfio_cap_len(struct vfio_pci_device *vdev, u8 cap, u8 pos)
 		else
 			return PCI_SATA_SIZEOF_SHORT;
 	default:
-		pr_warn("%s: %s unknown length for pci cap 0x%x@0x%x\n",
-			dev_name(&pdev->dev), __func__, cap, pos);
+		dev_warn(&pdev->dev, "%s: unknown length for PCI cap %#x@%#x\n",
+			 __func__, cap, pos);
 	}
 
 	return 0;
@@ -1372,8 +1371,8 @@ static int vfio_ext_cap_len(struct vfio_pci_device *vdev, u16 ecap, u16 epos)
 		}
 		return PCI_TPH_BASE_SIZEOF;
 	default:
-		pr_warn("%s: %s unknown length for pci ecap 0x%x@0x%x\n",
-			dev_name(&pdev->dev), __func__, ecap, epos);
+		dev_warn(&pdev->dev, "%s: unknown length for PCI ecap %#x@%#x\n",
+			 __func__, ecap, epos);
 	}
 
 	return 0;
@@ -1474,8 +1473,8 @@ static int vfio_cap_init(struct vfio_pci_device *vdev)
 		}
 
 		if (!len) {
-			pr_info("%s: %s hiding cap 0x%x\n",
-				__func__, dev_name(&pdev->dev), cap);
+			dev_info(&pdev->dev, "%s: hiding cap %#x@%#x\n",
+				 __func__, cap, pos);
 			*prev = next;
 			pos = next;
 			continue;
@@ -1486,9 +1485,8 @@ static int vfio_cap_init(struct vfio_pci_device *vdev)
 			if (likely(map[pos + i] == PCI_CAP_ID_INVALID))
 				continue;
 
-			pr_warn("%s: %s pci config conflict @0x%x, was cap 0x%x now cap 0x%x\n",
-				__func__, dev_name(&pdev->dev),
-				pos + i, map[pos + i], cap);
+			dev_warn(&pdev->dev, "%s: PCI config conflict @%#x, was cap %#x now cap %#x\n",
+				 __func__, pos + i, map[pos + i], cap);
 		}
 
 		BUILD_BUG_ON(PCI_CAP_ID_MAX >= PCI_CAP_ID_INVALID_VIRT);
@@ -1549,8 +1547,8 @@ static int vfio_ecap_init(struct vfio_pci_device *vdev)
 		}
 
 		if (!len) {
-			pr_info("%s: %s hiding ecap 0x%x@0x%x\n",
-				__func__, dev_name(&pdev->dev), ecap, epos);
+			dev_info(&pdev->dev, "%s: hiding ecap %#x@%#x\n",
+				 __func__, ecap, epos);
 
 			/* If not the first in the chain, we can skip over it */
 			if (prev) {
@@ -1572,9 +1570,8 @@ static int vfio_ecap_init(struct vfio_pci_device *vdev)
 			if (likely(map[epos + i] == PCI_CAP_ID_INVALID))
 				continue;
 
-			pr_warn("%s: %s pci config conflict @0x%x, was ecap 0x%x now ecap 0x%x\n",
-				__func__, dev_name(&pdev->dev),
-				epos + i, map[epos + i], ecap);
+			dev_warn(&pdev->dev, "%s: PCI config conflict @%#x, was ecap %#x now ecap %#x\n",
+				 __func__, epos + i, map[epos + i], ecap);
 		}
 
 		/*
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c +3 -2
index 3ddb2704221d..5ee06f1ff597 100644
@@ -89,7 +89,8 @@ static int vfio_platform_amdxgbe_reset(struct vfio_platform_device *vdev)
 	} while ((pcs_value & MDIO_CTRL1_RESET) && --count);
 
 	if (pcs_value & MDIO_CTRL1_RESET)
-		pr_warn("%s XGBE PHY reset timeout\n", __func__);
+		dev_warn(&vdev->device, "%s XGBE PHY reset timeout\n",
+			 __func__);
 
 	/* disable auto-negotiation */
 	value = xmdio_read(xpcs_regs->ioaddr, MDIO_MMD_AN, MDIO_CTRL1);
@@ -114,7 +115,7 @@ static int vfio_platform_amdxgbe_reset(struct vfio_platform_device *vdev)
 		usleep_range(500, 600);
 
 	if (!count)
-		pr_warn("%s MAC SW reset failed\n", __func__);
+		dev_warn(&vdev->device, "%s MAC SW reset failed\n", __func__);
 
 	return 0;
 }
drivers/vfio/platform/vfio_platform_common.c +7 -5
index c0cd824be2b7..438aa40c5bde 100644
@@ -63,7 +63,7 @@ static int vfio_platform_acpi_probe(struct vfio_platform_device *vdev,
 
 	adev = ACPI_COMPANION(dev);
 	if (!adev) {
-		pr_err("VFIO: ACPI companion device not found for %s\n",
+		dev_err(dev, "VFIO: ACPI companion device not found for %s\n",
 			vdev->name);
 		return -ENODEV;
 	}
@@ -638,7 +638,8 @@ static int vfio_platform_of_probe(struct vfio_platform_device *vdev,
 	ret = device_property_read_string(dev, "compatible",
 					  &vdev->compat);
 	if (ret)
-		pr_err("VFIO: Cannot retrieve compat for %s\n", vdev->name);
+		dev_err(dev, "VFIO: Cannot retrieve compat for %s\n",
+			vdev->name);
 
 	return ret;
 }
@@ -680,14 +681,15 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,
 
 	ret = vfio_platform_get_reset(vdev);
 	if (ret && vdev->reset_required) {
-		pr_err("VFIO: No reset function found for device %s\n",
-		       vdev->name);
+		dev_err(dev, "VFIO: No reset function found for device %s\n",
+		        vdev->name);
 		return ret;
 	}
 
 	group = vfio_iommu_group_get(dev);
 	if (!group) {
-		pr_err("VFIO: No IOMMU group for device %s\n", vdev->name);
+		dev_err(dev, "VFIO: No IOMMU group for device %s\n",
+			vdev->name);
 		ret = -EINVAL;
 		goto put_reset;
 	}
drivers/vfio/vfio.c +13 -16
index a3030cdf3c18..7fb68968097a 100644
@@ -704,8 +704,8 @@ static int vfio_group_nb_add_dev(struct vfio_group *group, struct device *dev)
 		return 0;
 
 	/* TODO Prevent device auto probing */
-	WARN(1, "Device %s added to live group %d!\n", dev_name(dev),
-	     iommu_group_id(group->iommu_group));
+	dev_WARN(dev, "Device added to live group %d!\n",
+		 iommu_group_id(group->iommu_group));
 
 	return 0;
 }
@@ -748,25 +748,22 @@ static int vfio_iommu_group_notifier(struct notifier_block *nb,
 		 */
 		break;
 	case IOMMU_GROUP_NOTIFY_BIND_DRIVER:
-		pr_debug("%s: Device %s, group %d binding to driver\n",
-			 __func__, dev_name(dev),
-			 iommu_group_id(group->iommu_group));
+		dev_dbg(dev, "%s: group %d binding to driver\n", __func__,
+			iommu_group_id(group->iommu_group));
 		break;
 	case IOMMU_GROUP_NOTIFY_BOUND_DRIVER:
-		pr_debug("%s: Device %s, group %d bound to driver %s\n",
-			 __func__, dev_name(dev),
-			 iommu_group_id(group->iommu_group), dev->driver->name);
+		dev_dbg(dev, "%s: group %d bound to driver %s\n", __func__,
+			iommu_group_id(group->iommu_group), dev->driver->name);
 		BUG_ON(vfio_group_nb_verify(group, dev));
 		break;
 	case IOMMU_GROUP_NOTIFY_UNBIND_DRIVER:
-		pr_debug("%s: Device %s, group %d unbinding from driver %s\n",
-			 __func__, dev_name(dev),
-			 iommu_group_id(group->iommu_group), dev->driver->name);
+		dev_dbg(dev, "%s: group %d unbinding from driver %s\n",
+			__func__, iommu_group_id(group->iommu_group),
+			dev->driver->name);
 		break;
 	case IOMMU_GROUP_NOTIFY_UNBOUND_DRIVER:
-		pr_debug("%s: Device %s, group %d unbound from driver\n",
-			 __func__, dev_name(dev),
-			 iommu_group_id(group->iommu_group));
+		dev_dbg(dev, "%s: group %d unbound from driver\n", __func__,
+			iommu_group_id(group->iommu_group));
 		/*
 		 * XXX An unbound device in a live group is ok, but we'd
 		 * really like to avoid the above BUG_ON by preventing other
@@ -830,8 +827,8 @@ int vfio_add_group_dev(struct device *dev,
 
 	device = vfio_group_get_device(group, dev);
 	if (device) {
-		WARN(1, "Device %s already exists on group %d\n",
-		     dev_name(dev), iommu_group_id(iommu_group));
+		dev_WARN(dev, "Device already exists on group %d\n",
+			 iommu_group_id(iommu_group));
 		vfio_device_put(device);
 		vfio_group_put(group);
 		return -EBUSY;
Signature · 1 line
2.21.0.392.gf8f6787159e-goog
#1 lore raw
Quoted 2 lines · Bjorn Helgaas

Use dev_printk() when possible to make messages consistent with other device-related messages.

trivial note:

drivers/vfio/platform/reset/vfio_platform_amdxgbe.c

Quoted 1 line
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c +0 -0

[]

drivers/vfio/platform/reset/vfio_platform_amdxgbe.c static int vfio_platform_amdxgbe_reset(struct vfio_platform_device *vdev) · line 93

Quoted 7 lines
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c +2 -1
@@ -89,7 +89,8 @@ static int vfio_platform_amdxgbe_reset(struct vfio_platform_device *vdev)
 	} while ((pcs_value & MDIO_CTRL1_RESET) && --count);
 
 	if (pcs_value & MDIO_CTRL1_RESET)
-		pr_warn("%s XGBE PHY reset timeout\n", __func__);
+		dev_warn(&vdev->device, "%s XGBE PHY reset timeout\n",
+			 __func__);

Many of these could use a colon after the %s used with __func__ to make the output more consistent with other modules.

#2 lore raw
Quoted 12 lines · Joe Perches
Quoted 2 lines · Bjorn Helgaas

Use dev_printk() when possible to make messages consistent with other device-related messages.

trivial note:

drivers/vfio/platform/reset/vfio_platform_amdxgbe.c

Quoted 1 line
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c +0 -0

[]

Quoted 3 lines
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c +0 -0
@@ -89,7 +89,8 @@ static int vfio_platform_amdxgbe_reset(struct vfio_platform_device *vdev)
      } while ((pcs_value & MDIO_CTRL1_RESET) && --count);
 
Quoted 7 lines

drivers/vfio/platform/reset/vfio_platform_amdxgbe.c static int vfio_platform_amdxgbe_reset(struct vfio_platform_device *vdev) · line 93

Quoted 4 lines
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c +2 -1
      if (pcs_value & MDIO_CTRL1_RESET)
-             pr_warn("%s XGBE PHY reset timeout\n", __func__);
+             dev_warn(&vdev->device, "%s XGBE PHY reset timeout\n",
+                      __func__);

Many of these could use a colon after the %s used with __func__ to make the output more consistent with other modules.

Thanks, Joe. I added a colon to the two in vfio_platform_amdxgbe_reset(). Those were the only ones I saw, except for a couple "%s failed" messages in drivers/vfio/vfio_iommu_spapr_tce.c, which I didn't change because (1) they can't use dev_err() so slightly out of scope for this patch, and
(2) it arguably reads more naturally without the colon.

In vfio_pci.c, I converted some pr_info() to dev_info() without adding a dev_fmt definition, so that removed the KBUILD_MODNAME prefix, which I didn't intend. I'll add "#define dev_fmt pr_fmt" to restore the prefix.

Messages from drivers/vfio use a variety of prefixes (none, "VFIO: ", KBUILD_MODNAME, __func__). That could potentially be rationalized but I would want Alex's guidance first.

Bjorn

#3 lore raw
Quoted 28 lines · On Fri, 29 Mar 2019 12:03:11 -0500 Bjorn Helgaas <[email protected]> wrote:
Quoted 12 lines · Joe Perches
Quoted 2 lines · Bjorn Helgaas

Use dev_printk() when possible to make messages consistent with other device-related messages.

trivial note:

drivers/vfio/platform/reset/vfio_platform_amdxgbe.c

Quoted 1 line
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c +0 -0

[]

Quoted 3 lines
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c +0 -0
@@ -89,7 +89,8 @@ static int vfio_platform_amdxgbe_reset(struct vfio_platform_device *vdev)
      } while ((pcs_value & MDIO_CTRL1_RESET) && --count);
 
Quoted 7 lines

drivers/vfio/platform/reset/vfio_platform_amdxgbe.c static int vfio_platform_amdxgbe_reset(struct vfio_platform_device *vdev) · line 93

Quoted 4 lines
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c +2 -1
      if (pcs_value & MDIO_CTRL1_RESET)
-             pr_warn("%s XGBE PHY reset timeout\n", __func__);
+             dev_warn(&vdev->device, "%s XGBE PHY reset timeout\n",
+                      __func__);  

Many of these could use a colon after the %s used with __func__ to make the output more consistent with other modules.

Thanks, Joe. I added a colon to the two in vfio_platform_amdxgbe_reset(). Those were the only ones I saw, except for a couple "%s failed" messages in drivers/vfio/vfio_iommu_spapr_tce.c, which I didn't change because (1) they can't use dev_err() so slightly out of scope for this patch, and
(2) it arguably reads more naturally without the colon.

Quoted 8 lines

In vfio_pci.c, I converted some pr_info() to dev_info() without adding a dev_fmt definition, so that removed the KBUILD_MODNAME prefix, which I didn't intend. I'll add "#define dev_fmt pr_fmt" to restore the prefix.

Messages from drivers/vfio use a variety of prefixes (none, "VFIO: ", KBUILD_MODNAME, __func__). That could potentially be rationalized but I would want Alex's guidance first.

Hmm, sort of hard to generalize. I suspect "VFIO:" is not super useful, the module name is probably a better choice, augmented by __func__ where it adds useful context. That's probably the approach I'd take. Thanks,

Alex

maintainer
#4 lore raw
In reply to Bjorn Helgaas

Hi Bjorn,

Quoted 126 lines · Bjorn Helgaas

From: Bjorn Helgaas <[email protected]>

Use dev_printk() when possible to make messages consistent with other device-related messages>

---
 drivers/vfio/pci/vfio_pci.c                   |  8 ++---
 drivers/vfio/pci/vfio_pci_config.c            | 29 +++++++++----------
 .../platform/reset/vfio_platform_amdxgbe.c    |  5 ++--
 drivers/vfio/platform/vfio_platform_common.c  | 12 ++++----
 drivers/vfio/vfio.c                           | 29 +++++++++----------
 5 files changed, 40 insertions(+), 43 deletions(-)
drivers/vfio/pci/vfio_pci.c +4 -4
index a25659b5a5d1..a538fd995429 100644
@@ -287,8 +287,8 @@ static int vfio_pci_enable(struct vfio_pci_device *vdev)
 	pci_save_state(pdev);
 	vdev->pci_saved_state = pci_store_saved_state(pdev);
 	if (!vdev->pci_saved_state)
-		pr_debug("%s: Couldn't store %s saved state\n",
-			 __func__, dev_name(&pdev->dev));
+		dev_dbg(&pdev->dev, "%s: Couldn't store saved state\n",
+			__func__);
 
 	if (likely(!nointxmask)) {
 		if (vfio_pci_nointx(pdev)) {
@@ -429,8 +429,8 @@ static void vfio_pci_disable(struct vfio_pci_device *vdev)
 	 * is just busy work.
 	 */
 	if (pci_load_and_free_saved_state(pdev, &vdev->pci_saved_state)) {
-		pr_info("%s: Couldn't reload %s saved state\n",
-			__func__, dev_name(&pdev->dev));
+		dev_info(&pdev->dev, "%s: Couldn't reload saved state\n",
+			 __func__);
 
 		if (!vdev->reset_works)
 			goto out;
drivers/vfio/pci/vfio_pci_config.c +13 -16
index e82b51114687..44d865576a92 100644
@@ -412,8 +412,7 @@ static void vfio_bar_restore(struct vfio_pci_device *vdev)
 	if (pdev->is_virtfn)
 		return;
 
-	pr_info("%s: %s reset recovery - restoring bars\n",
-		__func__, dev_name(&pdev->dev));
+	dev_info(&pdev->dev, "%s: reset recovery - restoring BARs\n", __func__);
 
 	for (i = PCI_BASE_ADDRESS_0; i <= PCI_BASE_ADDRESS_5; i += 4, rbar++)
 		pci_user_write_config_dword(pdev, i, *rbar);
@@ -1298,8 +1297,8 @@ static int vfio_cap_len(struct vfio_pci_device *vdev, u8 cap, u8 pos)
 		else
 			return PCI_SATA_SIZEOF_SHORT;
 	default:
-		pr_warn("%s: %s unknown length for pci cap 0x%x@0x%x\n",
-			dev_name(&pdev->dev), __func__, cap, pos);
+		dev_warn(&pdev->dev, "%s: unknown length for PCI cap %#x@%#x\n",
+			 __func__, cap, pos);
 	}
 
 	return 0;
@@ -1372,8 +1371,8 @@ static int vfio_ext_cap_len(struct vfio_pci_device *vdev, u16 ecap, u16 epos)
 		}
 		return PCI_TPH_BASE_SIZEOF;
 	default:
-		pr_warn("%s: %s unknown length for pci ecap 0x%x@0x%x\n",
-			dev_name(&pdev->dev), __func__, ecap, epos);
+		dev_warn(&pdev->dev, "%s: unknown length for PCI ecap %#x@%#x\n",
+			 __func__, ecap, epos);
 	}
 
 	return 0;
@@ -1474,8 +1473,8 @@ static int vfio_cap_init(struct vfio_pci_device *vdev)
 		}
 
 		if (!len) {
-			pr_info("%s: %s hiding cap 0x%x\n",
-				__func__, dev_name(&pdev->dev), cap);
+			dev_info(&pdev->dev, "%s: hiding cap %#x@%#x\n",
+				 __func__, cap, pos);
 			*prev = next;
 			pos = next;
 			continue;
@@ -1486,9 +1485,8 @@ static int vfio_cap_init(struct vfio_pci_device *vdev)
 			if (likely(map[pos + i] == PCI_CAP_ID_INVALID))
 				continue;
 
-			pr_warn("%s: %s pci config conflict @0x%x, was cap 0x%x now cap 0x%x\n",
-				__func__, dev_name(&pdev->dev),
-				pos + i, map[pos + i], cap);
+			dev_warn(&pdev->dev, "%s: PCI config conflict @%#x, was cap %#x now cap %#x\n",
+				 __func__, pos + i, map[pos + i], cap);
 		}
 
 		BUILD_BUG_ON(PCI_CAP_ID_MAX >= PCI_CAP_ID_INVALID_VIRT);
@@ -1549,8 +1547,8 @@ static int vfio_ecap_init(struct vfio_pci_device *vdev)
 		}
 
 		if (!len) {
-			pr_info("%s: %s hiding ecap 0x%x@0x%x\n",
-				__func__, dev_name(&pdev->dev), ecap, epos);
+			dev_info(&pdev->dev, "%s: hiding ecap %#x@%#x\n",
+				 __func__, ecap, epos);
 
 			/* If not the first in the chain, we can skip over it */
 			if (prev) {
@@ -1572,9 +1570,8 @@ static int vfio_ecap_init(struct vfio_pci_device *vdev)
 			if (likely(map[epos + i] == PCI_CAP_ID_INVALID))
 				continue;
 
-			pr_warn("%s: %s pci config conflict @0x%x, was ecap 0x%x now ecap 0x%x\n",
-				__func__, dev_name(&pdev->dev),
-				epos + i, map[epos + i], ecap);
+			dev_warn(&pdev->dev, "%s: PCI config conflict @%#x, was ecap %#x now ecap %#x\n",
+				 __func__, epos + i, map[epos + i], ecap);
 		}
 
 		/*
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c +0 -0
index 3ddb2704221d..5ee06f1ff597 100644

drivers/vfio/platform/reset/vfio_platform_amdxgbe.c static int vfio_platform_amdxgbe_reset(struct vfio_platform_device *vdev) · line 92

Quoted 5 lines
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c +1 -1
@@ -89,7 +89,8 @@ static int vfio_platform_amdxgbe_reset(struct vfio_platform_device *vdev)
 	} while ((pcs_value & MDIO_CTRL1_RESET) && --count);
 
 	if (pcs_value & MDIO_CTRL1_RESET)
-		pr_warn("%s XGBE PHY reset timeout\n", __func__);
+		dev_warn(&vdev->device, "%s XGBE PHY reset timeout\n",

vdev->device

drivers/vfio/platform/reset/vfio_platform_amdxgbe.c static int vfio_platform_amdxgbe_reset(struct vfio_platform_device *vdev) · line 118

Quoted 10 lines
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c +2 -1
+			 __func__);
 
 	/* disable auto-negotiation */
 	value = xmdio_read(xpcs_regs->ioaddr, MDIO_MMD_AN, MDIO_CTRL1);
@@ -114,7 +115,7 @@ static int vfio_platform_amdxgbe_reset(struct vfio_platform_device *vdev)
 		usleep_range(500, 600);
 
 	if (!count)
-		pr_warn("%s MAC SW reset failed\n", __func__);
+		dev_warn(&vdev->device, "%s MAC SW reset failed\n", __func__);

vdev->device

Quoted 8 lines
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c +0 -0
 	return 0;
 }
drivers/vfio/platform/vfio_platform_common.c +0 -0
index c0cd824be2b7..438aa40c5bde 100644

drivers/vfio/platform/vfio_platform_common.c static int vfio_platform_acpi_probe(struct vfio_platform_device *vdev, · line 67

Quoted 6 lines
drivers/vfio/platform/vfio_platform_common.c +1 -1
@@ -63,7 +63,7 @@ static int vfio_platform_acpi_probe(struct vfio_platform_device *vdev,
 
 	adev = ACPI_COMPANION(dev);
 	if (!adev) {
-		pr_err("VFIO: ACPI companion device not found for %s\n",
+		dev_err(dev, "VFIO: ACPI companion device not found for %s\n",
 			vdev->name);

nit: for VFIO platform devices vdev->name and dev_name(dev) are the same. But for amba devices they are different I think so it looks sensible to keep both names at the moment.

Thanks

Eric

Quoted 92 lines
drivers/vfio/platform/vfio_platform_common.c +6 -4
 		return -ENODEV;
 	}
@@ -638,7 +638,8 @@ static int vfio_platform_of_probe(struct vfio_platform_device *vdev,
 	ret = device_property_read_string(dev, "compatible",
 					  &vdev->compat);
 	if (ret)
-		pr_err("VFIO: Cannot retrieve compat for %s\n", vdev->name);
+		dev_err(dev, "VFIO: Cannot retrieve compat for %s\n",
+			vdev->name);
 
 	return ret;
 }
@@ -680,14 +681,15 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,
 
 	ret = vfio_platform_get_reset(vdev);
 	if (ret && vdev->reset_required) {
-		pr_err("VFIO: No reset function found for device %s\n",
-		       vdev->name);
+		dev_err(dev, "VFIO: No reset function found for device %s\n",
+		        vdev->name);
 		return ret;
 	}
 
 	group = vfio_iommu_group_get(dev);
 	if (!group) {
-		pr_err("VFIO: No IOMMU group for device %s\n", vdev->name);
+		dev_err(dev, "VFIO: No IOMMU group for device %s\n",
+			vdev->name);
 		ret = -EINVAL;
 		goto put_reset;
 	}
drivers/vfio/vfio.c +12 -16
index a3030cdf3c18..7fb68968097a 100644
@@ -704,8 +704,8 @@ static int vfio_group_nb_add_dev(struct vfio_group *group, struct device *dev)
 		return 0;
 
 	/* TODO Prevent device auto probing */
-	WARN(1, "Device %s added to live group %d!\n", dev_name(dev),
-	     iommu_group_id(group->iommu_group));
+	dev_WARN(dev, "Device added to live group %d!\n",> +		 iommu_group_id(group->iommu_group));
 
 	return 0;
 }
@@ -748,25 +748,22 @@ static int vfio_iommu_group_notifier(struct notifier_block *nb,
 		 */
 		break;
 	case IOMMU_GROUP_NOTIFY_BIND_DRIVER:
-		pr_debug("%s: Device %s, group %d binding to driver\n",
-			 __func__, dev_name(dev),
-			 iommu_group_id(group->iommu_group));
+		dev_dbg(dev, "%s: group %d binding to driver\n", __func__,
+			iommu_group_id(group->iommu_group));
 		break;
 	case IOMMU_GROUP_NOTIFY_BOUND_DRIVER:
-		pr_debug("%s: Device %s, group %d bound to driver %s\n",
-			 __func__, dev_name(dev),
-			 iommu_group_id(group->iommu_group), dev->driver->name);
+		dev_dbg(dev, "%s: group %d bound to driver %s\n", __func__,
+			iommu_group_id(group->iommu_group), dev->driver->name);
 		BUG_ON(vfio_group_nb_verify(group, dev));
 		break;
 	case IOMMU_GROUP_NOTIFY_UNBIND_DRIVER:
-		pr_debug("%s: Device %s, group %d unbinding from driver %s\n",
-			 __func__, dev_name(dev),
-			 iommu_group_id(group->iommu_group), dev->driver->name);
+		dev_dbg(dev, "%s: group %d unbinding from driver %s\n",
+			__func__, iommu_group_id(group->iommu_group),
+			dev->driver->name);
 		break;
 	case IOMMU_GROUP_NOTIFY_UNBOUND_DRIVER:
-		pr_debug("%s: Device %s, group %d unbound from driver\n",
-			 __func__, dev_name(dev),
-			 iommu_group_id(group->iommu_group));
+		dev_dbg(dev, "%s: group %d unbound from driver\n", __func__,
+			iommu_group_id(group->iommu_group));
 		/*
 		 * XXX An unbound device in a live group is ok, but we'd
 		 * really like to avoid the above BUG_ON by preventing other
@@ -830,8 +827,8 @@ int vfio_add_group_dev(struct device *dev,
 
 	device = vfio_group_get_device(group, dev);
 	if (device) {
-		WARN(1, "Device %s already exists on group %d\n",
-		     dev_name(dev), iommu_group_id(iommu_group));
+		dev_WARN(dev, "Device already exists on group %d\n",
+			 iommu_group_id(iommu_group));
 		vfio_device_put(device);
 		vfio_group_put(group);
 		return -EBUSY;
#5 lore raw
Quoted 10 lines · Auger Eric

Hi Bjorn,

Quoted 7 lines · Bjorn Helgaas

From: Bjorn Helgaas <[email protected]>

drivers/vfio/platform/reset/vfio_platform_amdxgbe.c +0 -0
@@ -89,7 +89,8 @@ static int vfio_platform_amdxgbe_reset(struct vfio_platform_device *vdev)
      } while ((pcs_value & MDIO_CTRL1_RESET) && --count);
 
Quoted 4 lines

drivers/vfio/platform/reset/vfio_platform_amdxgbe.c static int vfio_platform_amdxgbe_reset(struct vfio_platform_device *vdev) · line 92

Quoted 3 lines
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c +1 -1
      if (pcs_value & MDIO_CTRL1_RESET)
-             pr_warn("%s XGBE PHY reset timeout\n", __func__);
+             dev_warn(&vdev->device, "%s XGBE PHY reset timeout\n",

vdev->device

Indeed, thank you!

Quoted 10 lines

drivers/vfio/platform/reset/vfio_platform_amdxgbe.c static int vfio_platform_acpi_probe(struct vfio_platform_device *vdev, · line 67

Quoted 7 lines
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c +1 -1
@@ -63,7 +63,7 @@ static int vfio_platform_acpi_probe(struct vfio_platform_device *vdev,
 
      adev = ACPI_COMPANION(dev);
      if (!adev) {
-             pr_err("VFIO: ACPI companion device not found for %s\n",
+             dev_err(dev, "VFIO: ACPI companion device not found for %s\n",
                      vdev->name);

nit: for VFIO platform devices vdev->name and dev_name(dev) are the same. But for amba devices they are different I think so it looks sensible to keep both names at the moment.

OK, I'll keep this hunk as-is.

Bjorn