Skip to content

Commit 5f226da

Browse files
bjorn-helgaasjoergroedel
authored andcommitted
iommu/amd: Use dev_printk() when possible
Use dev_printk() when possible so the IOMMU messages are more consistent with other messages related to the device. Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent 5a63f0a commit 5f226da

File tree

2 files changed

+22
-24
lines changed

2 files changed

+22
-24
lines changed

drivers/iommu/amd_iommu.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919

2020
#define pr_fmt(fmt) "AMD-Vi: " fmt
21+
#define dev_fmt(fmt) pr_fmt(fmt)
2122

2223
#include <linux/ratelimit.h>
2324
#include <linux/pci.h>
@@ -279,10 +280,10 @@ static u16 get_alias(struct device *dev)
279280
return pci_alias;
280281
}
281282

282-
pr_info("Using IVRS reported alias %02x:%02x.%d "
283-
"for device %s[%04x:%04x], kernel reported alias "
283+
pci_info(pdev, "Using IVRS reported alias %02x:%02x.%d "
284+
"for device [%04x:%04x], kernel reported alias "
284285
"%02x:%02x.%d\n", PCI_BUS_NUM(ivrs_alias), PCI_SLOT(ivrs_alias),
285-
PCI_FUNC(ivrs_alias), dev_name(dev), pdev->vendor, pdev->device,
286+
PCI_FUNC(ivrs_alias), pdev->vendor, pdev->device,
286287
PCI_BUS_NUM(pci_alias), PCI_SLOT(pci_alias),
287288
PCI_FUNC(pci_alias));
288289

@@ -293,9 +294,8 @@ static u16 get_alias(struct device *dev)
293294
if (pci_alias == devid &&
294295
PCI_BUS_NUM(ivrs_alias) == pdev->bus->number) {
295296
pci_add_dma_alias(pdev, ivrs_alias & 0xff);
296-
pr_info("Added PCI DMA alias %02x.%d for %s\n",
297-
PCI_SLOT(ivrs_alias), PCI_FUNC(ivrs_alias),
298-
dev_name(dev));
297+
pci_info(pdev, "Added PCI DMA alias %02x.%d\n",
298+
PCI_SLOT(ivrs_alias), PCI_FUNC(ivrs_alias));
299299
}
300300

301301
return ivrs_alias;
@@ -545,7 +545,7 @@ static void amd_iommu_report_page_fault(u16 devid, u16 domain_id,
545545
dev_data = get_dev_data(&pdev->dev);
546546

547547
if (dev_data && __ratelimit(&dev_data->rs)) {
548-
dev_err(&pdev->dev, "Event logged [IO_PAGE_FAULT domain=0x%04x address=0x%llx flags=0x%04x]\n",
548+
pci_err(pdev, "Event logged [IO_PAGE_FAULT domain=0x%04x address=0x%llx flags=0x%04x]\n",
549549
domain_id, address, flags);
550550
} else if (printk_ratelimit()) {
551551
pr_err("Event logged [IO_PAGE_FAULT device=%02x:%02x.%x domain=0x%04x address=0x%llx flags=0x%04x]\n",
@@ -2251,8 +2251,7 @@ static int amd_iommu_add_device(struct device *dev)
22512251
ret = iommu_init_device(dev);
22522252
if (ret) {
22532253
if (ret != -ENOTSUPP)
2254-
pr_err("Failed to initialize device %s - trying to proceed anyway\n",
2255-
dev_name(dev));
2254+
dev_err(dev, "Failed to initialize - trying to proceed anyway\n");
22562255

22572256
iommu_ignore_device(dev);
22582257
dev->dma_ops = NULL;
@@ -2605,8 +2604,8 @@ static int map_sg(struct device *dev, struct scatterlist *sglist,
26052604
return nelems;
26062605

26072606
out_unmap:
2608-
pr_err("%s: IOMMU mapping error in %s (io-pages: %d) reason: %d\n",
2609-
dev_name(dev), __func__, npages, ret);
2607+
dev_err(dev, "IOMMU mapping error in map_sg (io-pages: %d reason: %d)\n",
2608+
npages, ret);
26102609

26112610
for_each_sg(sglist, s, nelems, i) {
26122611
int j, pages = iommu_num_pages(sg_phys(s), s->length, PAGE_SIZE);
@@ -2800,7 +2799,7 @@ static int init_reserved_iova_ranges(void)
28002799
IOVA_PFN(r->start),
28012800
IOVA_PFN(r->end));
28022801
if (!val) {
2803-
pr_err("Reserve pci-resource range failed\n");
2802+
pci_err(pdev, "Reserve pci-resource range %pR failed\n", r);
28042803
return -ENOMEM;
28052804
}
28062805
}
@@ -3170,8 +3169,7 @@ static void amd_iommu_get_resv_regions(struct device *dev,
31703169
length, prot,
31713170
IOMMU_RESV_DIRECT);
31723171
if (!region) {
3173-
pr_err("Out of memory allocating dm-regions for %s\n",
3174-
dev_name(dev));
3172+
dev_err(dev, "Out of memory allocating dm-regions\n");
31753173
return;
31763174
}
31773175
list_add_tail(&region->list, head);

drivers/iommu/amd_iommu_init.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919

2020
#define pr_fmt(fmt) "AMD-Vi: " fmt
21+
#define dev_fmt(fmt) pr_fmt(fmt)
2122

2223
#include <linux/pci.h>
2324
#include <linux/acpi.h>
@@ -1457,8 +1458,7 @@ static void amd_iommu_erratum_746_workaround(struct amd_iommu *iommu)
14571458
pci_write_config_dword(iommu->dev, 0xf0, 0x90 | (1 << 8));
14581459

14591460
pci_write_config_dword(iommu->dev, 0xf4, value | 0x4);
1460-
pr_info("Applying erratum 746 workaround for IOMMU at %s\n",
1461-
dev_name(&iommu->dev->dev));
1461+
pci_info(iommu->dev, "Applying erratum 746 workaround\n");
14621462

14631463
/* Clear the enable writing bit */
14641464
pci_write_config_dword(iommu->dev, 0xf0, 0x90);
@@ -1488,8 +1488,7 @@ static void amd_iommu_ats_write_check_workaround(struct amd_iommu *iommu)
14881488
/* Set L2_DEBUG_3[AtsIgnoreIWDis] = 1 */
14891489
iommu_write_l2(iommu, 0x47, value | BIT(0));
14901490

1491-
pr_info("Applying ATS write check workaround for IOMMU at %s\n",
1492-
dev_name(&iommu->dev->dev));
1491+
pci_info(iommu->dev, "Applying ATS write check workaround\n");
14931492
}
14941493

14951494
/*
@@ -1665,6 +1664,7 @@ static int iommu_pc_get_set_reg(struct amd_iommu *iommu, u8 bank, u8 cntr,
16651664

16661665
static void init_iommu_perf_ctr(struct amd_iommu *iommu)
16671666
{
1667+
struct pci_dev *pdev = iommu->dev;
16681668
u64 val = 0xabcd, val2 = 0;
16691669

16701670
if (!iommu_feature(iommu, FEATURE_PC))
@@ -1676,12 +1676,12 @@ static void init_iommu_perf_ctr(struct amd_iommu *iommu)
16761676
if ((iommu_pc_get_set_reg(iommu, 0, 0, 0, &val, true)) ||
16771677
(iommu_pc_get_set_reg(iommu, 0, 0, 0, &val2, false)) ||
16781678
(val != val2)) {
1679-
pr_err("Unable to write to IOMMU perf counter.\n");
1679+
pci_err(pdev, "Unable to write to IOMMU perf counter.\n");
16801680
amd_iommu_pc_present = false;
16811681
return;
16821682
}
16831683

1684-
pr_info("IOMMU performance counters supported\n");
1684+
pci_info(pdev, "IOMMU performance counters supported\n");
16851685

16861686
val = readl(iommu->mmio_base + MMIO_CNTR_CONF_OFFSET);
16871687
iommu->max_banks = (u8) ((val >> 12) & 0x3f);
@@ -1840,14 +1840,14 @@ static void print_iommu_info(void)
18401840
struct amd_iommu *iommu;
18411841

18421842
for_each_iommu(iommu) {
1843+
struct pci_dev *pdev = iommu->dev;
18431844
int i;
18441845

1845-
pr_info("Found IOMMU at %s cap 0x%hx\n",
1846-
dev_name(&iommu->dev->dev), iommu->cap_ptr);
1846+
pci_info(pdev, "Found IOMMU cap 0x%hx\n", iommu->cap_ptr);
18471847

18481848
if (iommu->cap & (1 << IOMMU_CAP_EFR)) {
1849-
pr_info("Extended features (%#llx):\n",
1850-
iommu->features);
1849+
pci_info(pdev, "Extended features (%#llx):\n",
1850+
iommu->features);
18511851
for (i = 0; i < ARRAY_SIZE(feat_str); ++i) {
18521852
if (iommu_feature(iommu, (1ULL << i)))
18531853
pr_cont(" %s", feat_str[i]);

0 commit comments

Comments
 (0)