summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjorn Helgaas <bhelgaas@google.com>2019-03-30 10:41:35 -0400
committerAlex Williamson <alex.williamson@redhat.com>2019-04-22 13:45:42 -0400
commita88a7b3eb076ade6205176915fd2ee73a60f4a32 (patch)
tree27517aa02ee5bef7c0c3b17f56c168dde35bf3e0
parent085b7755808aa11f78ab9377257e1dad2e6fa4bb (diff)
vfio: Use dev_printk() when possible
Use dev_printk() when possible to make messages consistent with other device-related messages. Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Acked-by: Eric Auger <eric.auger@redhat.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
-rw-r--r--drivers/vfio/pci/vfio_pci.c23
-rw-r--r--drivers/vfio/pci/vfio_pci_config.c29
-rw-r--r--drivers/vfio/platform/reset/vfio_platform_amdxgbe.c5
-rw-r--r--drivers/vfio/platform/vfio_platform_common.c12
-rw-r--r--drivers/vfio/vfio.c29
-rw-r--r--include/linux/pci.h3
6 files changed, 49 insertions, 52 deletions
diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index 3fa20e95a6bb..cab71da46f4a 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -12,6 +12,7 @@
12 */ 12 */
13 13
14#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 14#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
15#define dev_fmt pr_fmt
15 16
16#include <linux/device.h> 17#include <linux/device.h>
17#include <linux/eventfd.h> 18#include <linux/eventfd.h>
@@ -287,12 +288,11 @@ static int vfio_pci_enable(struct vfio_pci_device *vdev)
287 pci_save_state(pdev); 288 pci_save_state(pdev);
288 vdev->pci_saved_state = pci_store_saved_state(pdev); 289 vdev->pci_saved_state = pci_store_saved_state(pdev);
289 if (!vdev->pci_saved_state) 290 if (!vdev->pci_saved_state)
290 pr_debug("%s: Couldn't store %s saved state\n", 291 pci_dbg(pdev, "%s: Couldn't store saved state\n", __func__);
291 __func__, dev_name(&pdev->dev));
292 292
293 if (likely(!nointxmask)) { 293 if (likely(!nointxmask)) {
294 if (vfio_pci_nointx(pdev)) { 294 if (vfio_pci_nointx(pdev)) {
295 dev_info(&pdev->dev, "Masking broken INTx support\n"); 295 pci_info(pdev, "Masking broken INTx support\n");
296 vdev->nointx = true; 296 vdev->nointx = true;
297 pci_intx(pdev, 0); 297 pci_intx(pdev, 0);
298 } else 298 } else
@@ -336,8 +336,7 @@ static int vfio_pci_enable(struct vfio_pci_device *vdev)
336 IS_ENABLED(CONFIG_VFIO_PCI_IGD)) { 336 IS_ENABLED(CONFIG_VFIO_PCI_IGD)) {
337 ret = vfio_pci_igd_init(vdev); 337 ret = vfio_pci_igd_init(vdev);
338 if (ret) { 338 if (ret) {
339 dev_warn(&vdev->pdev->dev, 339 pci_warn(pdev, "Failed to setup Intel IGD regions\n");
340 "Failed to setup Intel IGD regions\n");
341 goto disable_exit; 340 goto disable_exit;
342 } 341 }
343 } 342 }
@@ -346,8 +345,7 @@ static int vfio_pci_enable(struct vfio_pci_device *vdev)
346 IS_ENABLED(CONFIG_VFIO_PCI_NVLINK2)) { 345 IS_ENABLED(CONFIG_VFIO_PCI_NVLINK2)) {
347 ret = vfio_pci_nvdia_v100_nvlink2_init(vdev); 346 ret = vfio_pci_nvdia_v100_nvlink2_init(vdev);
348 if (ret && ret != -ENODEV) { 347 if (ret && ret != -ENODEV) {
349 dev_warn(&vdev->pdev->dev, 348 pci_warn(pdev, "Failed to setup NVIDIA NV2 RAM region\n");
350 "Failed to setup NVIDIA NV2 RAM region\n");
351 goto disable_exit; 349 goto disable_exit;
352 } 350 }
353 } 351 }
@@ -356,8 +354,7 @@ static int vfio_pci_enable(struct vfio_pci_device *vdev)
356 IS_ENABLED(CONFIG_VFIO_PCI_NVLINK2)) { 354 IS_ENABLED(CONFIG_VFIO_PCI_NVLINK2)) {
357 ret = vfio_pci_ibm_npu2_init(vdev); 355 ret = vfio_pci_ibm_npu2_init(vdev);
358 if (ret && ret != -ENODEV) { 356 if (ret && ret != -ENODEV) {
359 dev_warn(&vdev->pdev->dev, 357 pci_warn(pdev, "Failed to setup NVIDIA NV2 ATSD region\n");
360 "Failed to setup NVIDIA NV2 ATSD region\n");
361 goto disable_exit; 358 goto disable_exit;
362 } 359 }
363 } 360 }
@@ -429,8 +426,7 @@ static void vfio_pci_disable(struct vfio_pci_device *vdev)
429 * is just busy work. 426 * is just busy work.
430 */ 427 */
431 if (pci_load_and_free_saved_state(pdev, &vdev->pci_saved_state)) { 428 if (pci_load_and_free_saved_state(pdev, &vdev->pci_saved_state)) {
432 pr_info("%s: Couldn't reload %s saved state\n", 429 pci_info(pdev, "%s: Couldn't reload saved state\n", __func__);
433 __func__, dev_name(&pdev->dev));
434 430
435 if (!vdev->reset_works) 431 if (!vdev->reset_works)
436 goto out; 432 goto out;
@@ -1255,17 +1251,18 @@ static int vfio_pci_mmap(void *device_data, struct vm_area_struct *vma)
1255static void vfio_pci_request(void *device_data, unsigned int count) 1251static void vfio_pci_request(void *device_data, unsigned int count)
1256{ 1252{
1257 struct vfio_pci_device *vdev = device_data; 1253 struct vfio_pci_device *vdev = device_data;
1254 struct pci_dev *pdev = vdev->pdev;
1258 1255
1259 mutex_lock(&vdev->igate); 1256 mutex_lock(&vdev->igate);
1260 1257
1261 if (vdev->req_trigger) { 1258 if (vdev->req_trigger) {
1262 if (!(count % 10)) 1259 if (!(count % 10))
1263 dev_notice_ratelimited(&vdev->pdev->dev, 1260 pci_notice_ratelimited(pdev,
1264 "Relaying device request to user (#%u)\n", 1261 "Relaying device request to user (#%u)\n",
1265 count); 1262 count);
1266 eventfd_signal(vdev->req_trigger, 1); 1263 eventfd_signal(vdev->req_trigger, 1);
1267 } else if (count == 0) { 1264 } else if (count == 0) {
1268 dev_warn(&vdev->pdev->dev, 1265 pci_warn(pdev,
1269 "No device request channel registered, blocked until released by user\n"); 1266 "No device request channel registered, blocked until released by user\n");
1270 } 1267 }
1271 1268
diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c
index e82b51114687..52963a904790 100644
--- a/drivers/vfio/pci/vfio_pci_config.c
+++ b/drivers/vfio/pci/vfio_pci_config.c
@@ -412,8 +412,7 @@ static void vfio_bar_restore(struct vfio_pci_device *vdev)
412 if (pdev->is_virtfn) 412 if (pdev->is_virtfn)
413 return; 413 return;
414 414
415 pr_info("%s: %s reset recovery - restoring bars\n", 415 pci_info(pdev, "%s: reset recovery - restoring BARs\n", __func__);
416 __func__, dev_name(&pdev->dev));
417 416
418 for (i = PCI_BASE_ADDRESS_0; i <= PCI_BASE_ADDRESS_5; i += 4, rbar++) 417 for (i = PCI_BASE_ADDRESS_0; i <= PCI_BASE_ADDRESS_5; i += 4, rbar++)
419 pci_user_write_config_dword(pdev, i, *rbar); 418 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)
1298 else 1297 else
1299 return PCI_SATA_SIZEOF_SHORT; 1298 return PCI_SATA_SIZEOF_SHORT;
1300 default: 1299 default:
1301 pr_warn("%s: %s unknown length for pci cap 0x%x@0x%x\n", 1300 pci_warn(pdev, "%s: unknown length for PCI cap %#x@%#x\n",
1302 dev_name(&pdev->dev), __func__, cap, pos); 1301 __func__, cap, pos);
1303 } 1302 }
1304 1303
1305 return 0; 1304 return 0;
@@ -1372,8 +1371,8 @@ static int vfio_ext_cap_len(struct vfio_pci_device *vdev, u16 ecap, u16 epos)
1372 } 1371 }
1373 return PCI_TPH_BASE_SIZEOF; 1372 return PCI_TPH_BASE_SIZEOF;
1374 default: 1373 default:
1375 pr_warn("%s: %s unknown length for pci ecap 0x%x@0x%x\n", 1374 pci_warn(pdev, "%s: unknown length for PCI ecap %#x@%#x\n",
1376 dev_name(&pdev->dev), __func__, ecap, epos); 1375 __func__, ecap, epos);
1377 } 1376 }
1378 1377
1379 return 0; 1378 return 0;
@@ -1474,8 +1473,8 @@ static int vfio_cap_init(struct vfio_pci_device *vdev)
1474 } 1473 }
1475 1474
1476 if (!len) { 1475 if (!len) {
1477 pr_info("%s: %s hiding cap 0x%x\n", 1476 pci_info(pdev, "%s: hiding cap %#x@%#x\n", __func__,
1478 __func__, dev_name(&pdev->dev), cap); 1477 cap, pos);
1479 *prev = next; 1478 *prev = next;
1480 pos = next; 1479 pos = next;
1481 continue; 1480 continue;
@@ -1486,9 +1485,8 @@ static int vfio_cap_init(struct vfio_pci_device *vdev)
1486 if (likely(map[pos + i] == PCI_CAP_ID_INVALID)) 1485 if (likely(map[pos + i] == PCI_CAP_ID_INVALID))
1487 continue; 1486 continue;
1488 1487
1489 pr_warn("%s: %s pci config conflict @0x%x, was cap 0x%x now cap 0x%x\n", 1488 pci_warn(pdev, "%s: PCI config conflict @%#x, was cap %#x now cap %#x\n",
1490 __func__, dev_name(&pdev->dev), 1489 __func__, pos + i, map[pos + i], cap);
1491 pos + i, map[pos + i], cap);
1492 } 1490 }
1493 1491
1494 BUILD_BUG_ON(PCI_CAP_ID_MAX >= PCI_CAP_ID_INVALID_VIRT); 1492 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)
1549 } 1547 }
1550 1548
1551 if (!len) { 1549 if (!len) {
1552 pr_info("%s: %s hiding ecap 0x%x@0x%x\n", 1550 pci_info(pdev, "%s: hiding ecap %#x@%#x\n",
1553 __func__, dev_name(&pdev->dev), ecap, epos); 1551 __func__, ecap, epos);
1554 1552
1555 /* If not the first in the chain, we can skip over it */ 1553 /* If not the first in the chain, we can skip over it */
1556 if (prev) { 1554 if (prev) {
@@ -1572,9 +1570,8 @@ static int vfio_ecap_init(struct vfio_pci_device *vdev)
1572 if (likely(map[epos + i] == PCI_CAP_ID_INVALID)) 1570 if (likely(map[epos + i] == PCI_CAP_ID_INVALID))
1573 continue; 1571 continue;
1574 1572
1575 pr_warn("%s: %s pci config conflict @0x%x, was ecap 0x%x now ecap 0x%x\n", 1573 pci_warn(pdev, "%s: PCI config conflict @%#x, was ecap %#x now ecap %#x\n",
1576 __func__, dev_name(&pdev->dev), 1574 __func__, epos + i, map[epos + i], ecap);
1577 epos + i, map[epos + i], ecap);
1578 } 1575 }
1579 1576
1580 /* 1577 /*
diff --git a/drivers/vfio/platform/reset/vfio_platform_amdxgbe.c b/drivers/vfio/platform/reset/vfio_platform_amdxgbe.c
index 3ddb2704221d..fe95964bc3be 100644
--- a/drivers/vfio/platform/reset/vfio_platform_amdxgbe.c
+++ b/drivers/vfio/platform/reset/vfio_platform_amdxgbe.c
@@ -89,7 +89,8 @@ static int vfio_platform_amdxgbe_reset(struct vfio_platform_device *vdev)
89 } while ((pcs_value & MDIO_CTRL1_RESET) && --count); 89 } while ((pcs_value & MDIO_CTRL1_RESET) && --count);
90 90
91 if (pcs_value & MDIO_CTRL1_RESET) 91 if (pcs_value & MDIO_CTRL1_RESET)
92 pr_warn("%s XGBE PHY reset timeout\n", __func__); 92 dev_warn(vdev->device, "%s: XGBE PHY reset timeout\n",
93 __func__);
93 94
94 /* disable auto-negotiation */ 95 /* disable auto-negotiation */
95 value = xmdio_read(xpcs_regs->ioaddr, MDIO_MMD_AN, MDIO_CTRL1); 96 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)
114 usleep_range(500, 600); 115 usleep_range(500, 600);
115 116
116 if (!count) 117 if (!count)
117 pr_warn("%s MAC SW reset failed\n", __func__); 118 dev_warn(vdev->device, "%s: MAC SW reset failed\n", __func__);
118 119
119 return 0; 120 return 0;
120} 121}
diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c
index c0cd824be2b7..2a45b36bcf58 100644
--- a/drivers/vfio/platform/vfio_platform_common.c
+++ b/drivers/vfio/platform/vfio_platform_common.c
@@ -12,6 +12,8 @@
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 */ 13 */
14 14
15#define dev_fmt(fmt) "VFIO: " fmt
16
15#include <linux/device.h> 17#include <linux/device.h>
16#include <linux/acpi.h> 18#include <linux/acpi.h>
17#include <linux/iommu.h> 19#include <linux/iommu.h>
@@ -63,7 +65,7 @@ static int vfio_platform_acpi_probe(struct vfio_platform_device *vdev,
63 65
64 adev = ACPI_COMPANION(dev); 66 adev = ACPI_COMPANION(dev);
65 if (!adev) { 67 if (!adev) {
66 pr_err("VFIO: ACPI companion device not found for %s\n", 68 dev_err(dev, "ACPI companion device not found for %s\n",
67 vdev->name); 69 vdev->name);
68 return -ENODEV; 70 return -ENODEV;
69 } 71 }
@@ -638,7 +640,7 @@ static int vfio_platform_of_probe(struct vfio_platform_device *vdev,
638 ret = device_property_read_string(dev, "compatible", 640 ret = device_property_read_string(dev, "compatible",
639 &vdev->compat); 641 &vdev->compat);
640 if (ret) 642 if (ret)
641 pr_err("VFIO: Cannot retrieve compat for %s\n", vdev->name); 643 dev_err(dev, "Cannot retrieve compat for %s\n", vdev->name);
642 644
643 return ret; 645 return ret;
644} 646}
@@ -680,14 +682,14 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,
680 682
681 ret = vfio_platform_get_reset(vdev); 683 ret = vfio_platform_get_reset(vdev);
682 if (ret && vdev->reset_required) { 684 if (ret && vdev->reset_required) {
683 pr_err("VFIO: No reset function found for device %s\n", 685 dev_err(dev, "No reset function found for device %s\n",
684 vdev->name); 686 vdev->name);
685 return ret; 687 return ret;
686 } 688 }
687 689
688 group = vfio_iommu_group_get(dev); 690 group = vfio_iommu_group_get(dev);
689 if (!group) { 691 if (!group) {
690 pr_err("VFIO: No IOMMU group for device %s\n", vdev->name); 692 dev_err(dev, "No IOMMU group for device %s\n", vdev->name);
691 ret = -EINVAL; 693 ret = -EINVAL;
692 goto put_reset; 694 goto put_reset;
693 } 695 }
diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
index a3030cdf3c18..7fb68968097a 100644
--- a/drivers/vfio/vfio.c
+++ b/drivers/vfio/vfio.c
@@ -704,8 +704,8 @@ static int vfio_group_nb_add_dev(struct vfio_group *group, struct device *dev)
704 return 0; 704 return 0;
705 705
706 /* TODO Prevent device auto probing */ 706 /* TODO Prevent device auto probing */
707 WARN(1, "Device %s added to live group %d!\n", dev_name(dev), 707 dev_WARN(dev, "Device added to live group %d!\n",
708 iommu_group_id(group->iommu_group)); 708 iommu_group_id(group->iommu_group));
709 709
710 return 0; 710 return 0;
711} 711}
@@ -748,25 +748,22 @@ static int vfio_iommu_group_notifier(struct notifier_block *nb,
748 */ 748 */
749 break; 749 break;
750 case IOMMU_GROUP_NOTIFY_BIND_DRIVER: 750 case IOMMU_GROUP_NOTIFY_BIND_DRIVER:
751 pr_debug("%s: Device %s, group %d binding to driver\n", 751 dev_dbg(dev, "%s: group %d binding to driver\n", __func__,
752 __func__, dev_name(dev), 752 iommu_group_id(group->iommu_group));
753 iommu_group_id(group->iommu_group));
754 break; 753 break;
755 case IOMMU_GROUP_NOTIFY_BOUND_DRIVER: 754 case IOMMU_GROUP_NOTIFY_BOUND_DRIVER:
756 pr_debug("%s: Device %s, group %d bound to driver %s\n", 755 dev_dbg(dev, "%s: group %d bound to driver %s\n", __func__,
757 __func__, dev_name(dev), 756 iommu_group_id(group->iommu_group), dev->driver->name);
758 iommu_group_id(group->iommu_group), dev->driver->name);
759 BUG_ON(vfio_group_nb_verify(group, dev)); 757 BUG_ON(vfio_group_nb_verify(group, dev));
760 break; 758 break;
761 case IOMMU_GROUP_NOTIFY_UNBIND_DRIVER: 759 case IOMMU_GROUP_NOTIFY_UNBIND_DRIVER:
762 pr_debug("%s: Device %s, group %d unbinding from driver %s\n", 760 dev_dbg(dev, "%s: group %d unbinding from driver %s\n",
763 __func__, dev_name(dev), 761 __func__, iommu_group_id(group->iommu_group),
764 iommu_group_id(group->iommu_group), dev->driver->name); 762 dev->driver->name);
765 break; 763 break;
766 case IOMMU_GROUP_NOTIFY_UNBOUND_DRIVER: 764 case IOMMU_GROUP_NOTIFY_UNBOUND_DRIVER:
767 pr_debug("%s: Device %s, group %d unbound from driver\n", 765 dev_dbg(dev, "%s: group %d unbound from driver\n", __func__,
768 __func__, dev_name(dev), 766 iommu_group_id(group->iommu_group));
769 iommu_group_id(group->iommu_group));
770 /* 767 /*
771 * XXX An unbound device in a live group is ok, but we'd 768 * XXX An unbound device in a live group is ok, but we'd
772 * really like to avoid the above BUG_ON by preventing other 769 * really like to avoid the above BUG_ON by preventing other
@@ -830,8 +827,8 @@ int vfio_add_group_dev(struct device *dev,
830 827
831 device = vfio_group_get_device(group, dev); 828 device = vfio_group_get_device(group, dev);
832 if (device) { 829 if (device) {
833 WARN(1, "Device %s already exists on group %d\n", 830 dev_WARN(dev, "Device already exists on group %d\n",
834 dev_name(dev), iommu_group_id(iommu_group)); 831 iommu_group_id(iommu_group));
835 vfio_device_put(device); 832 vfio_device_put(device);
836 vfio_group_put(group); 833 vfio_group_put(group);
837 return -EBUSY; 834 return -EBUSY;
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 77448215ef5b..27854731afc4 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -2363,4 +2363,7 @@ void pci_uevent_ers(struct pci_dev *pdev, enum pci_ers_result err_type);
2363#define pci_info(pdev, fmt, arg...) dev_info(&(pdev)->dev, fmt, ##arg) 2363#define pci_info(pdev, fmt, arg...) dev_info(&(pdev)->dev, fmt, ##arg)
2364#define pci_dbg(pdev, fmt, arg...) dev_dbg(&(pdev)->dev, fmt, ##arg) 2364#define pci_dbg(pdev, fmt, arg...) dev_dbg(&(pdev)->dev, fmt, ##arg)
2365 2365
2366#define pci_notice_ratelimited(pdev, fmt, arg...) \
2367 dev_notice_ratelimited(&(pdev)->dev, fmt, ##arg)
2368
2366#endif /* LINUX_PCI_H */ 2369#endif /* LINUX_PCI_H */