Commit e9071b0b authored by Donald Dutile's avatar Donald Dutile Committed by Ingo Molnar

iommu/dmar: Use pr_format() instead of PREFIX to tidy up pr_*() calls

Joe Perches recommended getting rid of the redundant
formatting of adding "PREFIX" to all the uses of pr_*() calls.

The recommendation helps to reduce source and improve
readibility.

While cleaning up the PREFIX's, I saw that one of
the pr_warn() was redundant in dmar_parse_one_dev_scope(),
since the same message was printed after breaking out of the
while loop for the same condition, !pdev.
So, to avoid a duplicate message, I removed the one in the while
loop.
Reported-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarDonald Dutile <ddutile@redhat.com>
Cc: iommu@lists.linux-foundation.org
Cc: chrisw@redhat.com
Cc: suresh.b.siddha@intel.com
Cc: dwmw2@infradead.org
Link: http://lkml.kernel.org/r/1339189991-13129-1-git-send-email-ddutile@redhat.com
[ Small whitespace fixes. ]
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 6f5cf521
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
* These routines are used by both DMA-remapping and Interrupt-remapping * These routines are used by both DMA-remapping and Interrupt-remapping
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt /* has to precede printk.h */
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/dmar.h> #include <linux/dmar.h>
#include <linux/iova.h> #include <linux/iova.h>
...@@ -39,8 +41,6 @@ ...@@ -39,8 +41,6 @@
#include <asm/irq_remapping.h> #include <asm/irq_remapping.h>
#include <asm/iommu_table.h> #include <asm/iommu_table.h>
#define PREFIX "DMAR: "
/* No locks are needed as DMA remapping hardware unit /* No locks are needed as DMA remapping hardware unit
* list is constructed at boot time and hotplug of * list is constructed at boot time and hotplug of
* these units are not supported by the architecture. * these units are not supported by the architecture.
...@@ -83,15 +83,12 @@ static int __init dmar_parse_one_dev_scope(struct acpi_dmar_device_scope *scope, ...@@ -83,15 +83,12 @@ static int __init dmar_parse_one_dev_scope(struct acpi_dmar_device_scope *scope,
* ignore it * ignore it
*/ */
if (!bus) { if (!bus) {
pr_warn(PREFIX "Device scope bus [%d] not found\n", pr_warn("Device scope bus [%d] not found\n", scope->bus);
scope->bus);
break; break;
} }
pdev = pci_get_slot(bus, PCI_DEVFN(path->dev, path->fn)); pdev = pci_get_slot(bus, PCI_DEVFN(path->dev, path->fn));
if (!pdev) { if (!pdev) {
pr_warn(PREFIX "Device scope device" /* warning will be printed below */
"[%04x:%02x:%02x.%02x] not found\n",
segment, bus->number, path->dev, path->fn);
break; break;
} }
path ++; path ++;
...@@ -99,8 +96,7 @@ static int __init dmar_parse_one_dev_scope(struct acpi_dmar_device_scope *scope, ...@@ -99,8 +96,7 @@ static int __init dmar_parse_one_dev_scope(struct acpi_dmar_device_scope *scope,
bus = pdev->subordinate; bus = pdev->subordinate;
} }
if (!pdev) { if (!pdev) {
pr_warn(PREFIX pr_warn("Device scope device [%04x:%02x:%02x.%02x] not found\n",
"Device scope device [%04x:%02x:%02x.%02x] not found\n",
segment, scope->bus, path->dev, path->fn); segment, scope->bus, path->dev, path->fn);
*dev = NULL; *dev = NULL;
return 0; return 0;
...@@ -109,7 +105,7 @@ static int __init dmar_parse_one_dev_scope(struct acpi_dmar_device_scope *scope, ...@@ -109,7 +105,7 @@ static int __init dmar_parse_one_dev_scope(struct acpi_dmar_device_scope *scope,
pdev->subordinate) || (scope->entry_type == \ pdev->subordinate) || (scope->entry_type == \
ACPI_DMAR_SCOPE_TYPE_BRIDGE && !pdev->subordinate)) { ACPI_DMAR_SCOPE_TYPE_BRIDGE && !pdev->subordinate)) {
pci_dev_put(pdev); pci_dev_put(pdev);
pr_warn(PREFIX "Device scope type does not match for %s\n", pr_warn("Device scope type does not match for %s\n",
pci_name(pdev)); pci_name(pdev));
return -EINVAL; return -EINVAL;
} }
...@@ -132,7 +128,7 @@ int __init dmar_parse_dev_scope(void *start, void *end, int *cnt, ...@@ -132,7 +128,7 @@ int __init dmar_parse_dev_scope(void *start, void *end, int *cnt,
scope->entry_type == ACPI_DMAR_SCOPE_TYPE_BRIDGE) scope->entry_type == ACPI_DMAR_SCOPE_TYPE_BRIDGE)
(*cnt)++; (*cnt)++;
else if (scope->entry_type != ACPI_DMAR_SCOPE_TYPE_IOAPIC) { else if (scope->entry_type != ACPI_DMAR_SCOPE_TYPE_IOAPIC) {
pr_warn(PREFIX "Unsupported device scope\n"); pr_warn("Unsupported device scope\n");
} }
start += scope->length; start += scope->length;
} }
...@@ -258,23 +254,23 @@ dmar_table_print_dmar_entry(struct acpi_dmar_header *header) ...@@ -258,23 +254,23 @@ dmar_table_print_dmar_entry(struct acpi_dmar_header *header)
case ACPI_DMAR_TYPE_HARDWARE_UNIT: case ACPI_DMAR_TYPE_HARDWARE_UNIT:
drhd = container_of(header, struct acpi_dmar_hardware_unit, drhd = container_of(header, struct acpi_dmar_hardware_unit,
header); header);
pr_info(PREFIX "DRHD base: %#016Lx flags: %#x\n", pr_info("DRHD base: %#016Lx flags: %#x\n",
(unsigned long long)drhd->address, drhd->flags); (unsigned long long)drhd->address, drhd->flags);
break; break;
case ACPI_DMAR_TYPE_RESERVED_MEMORY: case ACPI_DMAR_TYPE_RESERVED_MEMORY:
rmrr = container_of(header, struct acpi_dmar_reserved_memory, rmrr = container_of(header, struct acpi_dmar_reserved_memory,
header); header);
pr_info(PREFIX "RMRR base: %#016Lx end: %#016Lx\n", pr_info("RMRR base: %#016Lx end: %#016Lx\n",
(unsigned long long)rmrr->base_address, (unsigned long long)rmrr->base_address,
(unsigned long long)rmrr->end_address); (unsigned long long)rmrr->end_address);
break; break;
case ACPI_DMAR_TYPE_ATSR: case ACPI_DMAR_TYPE_ATSR:
atsr = container_of(header, struct acpi_dmar_atsr, header); atsr = container_of(header, struct acpi_dmar_atsr, header);
pr_info(PREFIX "ATSR flags: %#x\n", atsr->flags); pr_info("ATSR flags: %#x\n", atsr->flags);
break; break;
case ACPI_DMAR_HARDWARE_AFFINITY: case ACPI_DMAR_HARDWARE_AFFINITY:
rhsa = container_of(header, struct acpi_dmar_rhsa, header); rhsa = container_of(header, struct acpi_dmar_rhsa, header);
pr_info(PREFIX "RHSA base: %#016Lx proximity domain: %#x\n", pr_info("RHSA base: %#016Lx proximity domain: %#x\n",
(unsigned long long)rhsa->base_address, (unsigned long long)rhsa->base_address,
rhsa->proximity_domain); rhsa->proximity_domain);
break; break;
...@@ -294,7 +290,7 @@ static int __init dmar_table_detect(void) ...@@ -294,7 +290,7 @@ static int __init dmar_table_detect(void)
&dmar_tbl_size); &dmar_tbl_size);
if (ACPI_SUCCESS(status) && !dmar_tbl) { if (ACPI_SUCCESS(status) && !dmar_tbl) {
pr_warn(PREFIX "Unable to map DMAR\n"); pr_warn("Unable to map DMAR\n");
status = AE_NOT_FOUND; status = AE_NOT_FOUND;
} }
...@@ -328,18 +324,18 @@ parse_dmar_table(void) ...@@ -328,18 +324,18 @@ parse_dmar_table(void)
return -ENODEV; return -ENODEV;
if (dmar->width < PAGE_SHIFT - 1) { if (dmar->width < PAGE_SHIFT - 1) {
pr_warn(PREFIX "Invalid DMAR haw\n"); pr_warn("Invalid DMAR haw\n");
return -EINVAL; return -EINVAL;
} }
pr_info(PREFIX "Host address width %d\n", dmar->width + 1); pr_info("Host address width %d\n", dmar->width + 1);
entry_header = (struct acpi_dmar_header *)(dmar + 1); entry_header = (struct acpi_dmar_header *)(dmar + 1);
while (((unsigned long)entry_header) < while (((unsigned long)entry_header) <
(((unsigned long)dmar) + dmar_tbl->length)) { (((unsigned long)dmar) + dmar_tbl->length)) {
/* Avoid looping forever on bad ACPI tables */ /* Avoid looping forever on bad ACPI tables */
if (entry_header->length == 0) { if (entry_header->length == 0) {
pr_warn(PREFIX "Invalid 0-length structure\n"); pr_warn("Invalid 0-length structure\n");
ret = -EINVAL; ret = -EINVAL;
break; break;
} }
...@@ -362,7 +358,7 @@ parse_dmar_table(void) ...@@ -362,7 +358,7 @@ parse_dmar_table(void)
#endif #endif
break; break;
default: default:
pr_warn(PREFIX "Unknown DMAR structure type %d\n", pr_warn("Unknown DMAR structure type %d\n",
entry_header->type); entry_header->type);
ret = 0; /* for forward compatibility */ ret = 0; /* for forward compatibility */
break; break;
...@@ -461,12 +457,12 @@ int __init dmar_table_init(void) ...@@ -461,12 +457,12 @@ int __init dmar_table_init(void)
ret = parse_dmar_table(); ret = parse_dmar_table();
if (ret) { if (ret) {
if (ret != -ENODEV) if (ret != -ENODEV)
pr_info(PREFIX "parse DMAR table failure.\n"); pr_info("parse DMAR table failure.\n");
return ret; return ret;
} }
if (list_empty(&dmar_drhd_units)) { if (list_empty(&dmar_drhd_units)) {
pr_info(PREFIX "No DMAR devices found\n"); pr_info("No DMAR devices found\n");
return -ENODEV; return -ENODEV;
} }
...@@ -498,7 +494,7 @@ int __init check_zero_address(void) ...@@ -498,7 +494,7 @@ int __init check_zero_address(void)
(((unsigned long)dmar) + dmar_tbl->length)) { (((unsigned long)dmar) + dmar_tbl->length)) {
/* Avoid looping forever on bad ACPI tables */ /* Avoid looping forever on bad ACPI tables */
if (entry_header->length == 0) { if (entry_header->length == 0) {
pr_warn(PREFIX "Invalid 0-length structure\n"); pr_warn("Invalid 0-length structure\n");
return 0; return 0;
} }
...@@ -549,8 +545,7 @@ int __init detect_intel_iommu(void) ...@@ -549,8 +545,7 @@ int __init detect_intel_iommu(void)
if (ret && irq_remapping_enabled && cpu_has_x2apic && if (ret && irq_remapping_enabled && cpu_has_x2apic &&
dmar->flags & 0x1) dmar->flags & 0x1)
pr_info("Queued invalidation will be enabled to " pr_info("Queued invalidation will be enabled to support x2apic and Intr-remapping.\n");
"support x2apic and Intr-remapping.\n");
if (ret && !no_iommu && !iommu_detected && !dmar_disabled) { if (ret && !no_iommu && !iommu_detected && !dmar_disabled) {
iommu_detected = 1; iommu_detected = 1;
...@@ -1302,8 +1297,7 @@ int __init enable_drhd_fault_handling(void) ...@@ -1302,8 +1297,7 @@ int __init enable_drhd_fault_handling(void)
ret = dmar_set_interrupt(iommu); ret = dmar_set_interrupt(iommu);
if (ret) { if (ret) {
pr_err("DRHD %Lx: failed to enable fault, " pr_err("DRHD %Lx: failed to enable fault, interrupt, ret %d\n",
" interrupt, ret %d\n",
(unsigned long long)drhd->reg_base_addr, ret); (unsigned long long)drhd->reg_base_addr, ret);
return -1; return -1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment