aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iommu/dmar.c
diff options
context:
space:
mode:
authorDonald Dutile <ddutile@redhat.com>2012-06-08 17:13:11 -0400
committerIngo Molnar <mingo@kernel.org>2012-06-11 04:27:44 -0400
commite9071b0be5e7ce4903b7f7c370769d485774d3e3 (patch)
tree06b1a1adfe2f807d28e9b3ab6cf2b56f6744bc4c /drivers/iommu/dmar.c
parent6f5cf52114dd87f9ed091678f7dfc8ff21bbe2b3 (diff)
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: Joe Perches <joe@perches.com> Signed-off-by: Donald 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: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'drivers/iommu/dmar.c')
-rw-r--r--drivers/iommu/dmar.c54
1 files changed, 24 insertions, 30 deletions
diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
index 9ab6ebf46f7a..86e2f4a62b9a 100644
--- a/drivers/iommu/dmar.c
+++ b/drivers/iommu/dmar.c
@@ -26,6 +26,8 @@
26 * These routines are used by both DMA-remapping and Interrupt-remapping 26 * These routines are used by both DMA-remapping and Interrupt-remapping
27 */ 27 */
28 28
29#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt /* has to precede printk.h */
30
29#include <linux/pci.h> 31#include <linux/pci.h>
30#include <linux/dmar.h> 32#include <linux/dmar.h>
31#include <linux/iova.h> 33#include <linux/iova.h>
@@ -39,8 +41,6 @@
39#include <asm/irq_remapping.h> 41#include <asm/irq_remapping.h>
40#include <asm/iommu_table.h> 42#include <asm/iommu_table.h>
41 43
42#define PREFIX "DMAR: "
43
44/* No locks are needed as DMA remapping hardware unit 44/* No locks are needed as DMA remapping hardware unit
45 * list is constructed at boot time and hotplug of 45 * list is constructed at boot time and hotplug of
46 * these units are not supported by the architecture. 46 * 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 * ignore it 83 * ignore it
84 */ 84 */
85 if (!bus) { 85 if (!bus) {
86 pr_warn(PREFIX "Device scope bus [%d] not found\n", 86 pr_warn("Device scope bus [%d] not found\n", scope->bus);
87 scope->bus);
88 break; 87 break;
89 } 88 }
90 pdev = pci_get_slot(bus, PCI_DEVFN(path->dev, path->fn)); 89 pdev = pci_get_slot(bus, PCI_DEVFN(path->dev, path->fn));
91 if (!pdev) { 90 if (!pdev) {
92 pr_warn(PREFIX "Device scope device" 91 /* warning will be printed below */
93 "[%04x:%02x:%02x.%02x] not found\n",
94 segment, bus->number, path->dev, path->fn);
95 break; 92 break;
96 } 93 }
97 path ++; 94 path ++;
@@ -99,8 +96,7 @@ static int __init dmar_parse_one_dev_scope(struct acpi_dmar_device_scope *scope,
99 bus = pdev->subordinate; 96 bus = pdev->subordinate;
100 } 97 }
101 if (!pdev) { 98 if (!pdev) {
102 pr_warn(PREFIX 99 pr_warn("Device scope device [%04x:%02x:%02x.%02x] not found\n",
103 "Device scope device [%04x:%02x:%02x.%02x] not found\n",
104 segment, scope->bus, path->dev, path->fn); 100 segment, scope->bus, path->dev, path->fn);
105 *dev = NULL; 101 *dev = NULL;
106 return 0; 102 return 0;
@@ -109,8 +105,8 @@ static int __init dmar_parse_one_dev_scope(struct acpi_dmar_device_scope *scope,
109 pdev->subordinate) || (scope->entry_type == \ 105 pdev->subordinate) || (scope->entry_type == \
110 ACPI_DMAR_SCOPE_TYPE_BRIDGE && !pdev->subordinate)) { 106 ACPI_DMAR_SCOPE_TYPE_BRIDGE && !pdev->subordinate)) {
111 pci_dev_put(pdev); 107 pci_dev_put(pdev);
112 pr_warn(PREFIX "Device scope type does not match for %s\n", 108 pr_warn("Device scope type does not match for %s\n",
113 pci_name(pdev)); 109 pci_name(pdev));
114 return -EINVAL; 110 return -EINVAL;
115 } 111 }
116 *dev = pdev; 112 *dev = pdev;
@@ -132,7 +128,7 @@ int __init dmar_parse_dev_scope(void *start, void *end, int *cnt,
132 scope->entry_type == ACPI_DMAR_SCOPE_TYPE_BRIDGE) 128 scope->entry_type == ACPI_DMAR_SCOPE_TYPE_BRIDGE)
133 (*cnt)++; 129 (*cnt)++;
134 else if (scope->entry_type != ACPI_DMAR_SCOPE_TYPE_IOAPIC) { 130 else if (scope->entry_type != ACPI_DMAR_SCOPE_TYPE_IOAPIC) {
135 pr_warn(PREFIX "Unsupported device scope\n"); 131 pr_warn("Unsupported device scope\n");
136 } 132 }
137 start += scope->length; 133 start += scope->length;
138 } 134 }
@@ -258,23 +254,23 @@ dmar_table_print_dmar_entry(struct acpi_dmar_header *header)
258 case ACPI_DMAR_TYPE_HARDWARE_UNIT: 254 case ACPI_DMAR_TYPE_HARDWARE_UNIT:
259 drhd = container_of(header, struct acpi_dmar_hardware_unit, 255 drhd = container_of(header, struct acpi_dmar_hardware_unit,
260 header); 256 header);
261 pr_info(PREFIX "DRHD base: %#016Lx flags: %#x\n", 257 pr_info("DRHD base: %#016Lx flags: %#x\n",
262 (unsigned long long)drhd->address, drhd->flags); 258 (unsigned long long)drhd->address, drhd->flags);
263 break; 259 break;
264 case ACPI_DMAR_TYPE_RESERVED_MEMORY: 260 case ACPI_DMAR_TYPE_RESERVED_MEMORY:
265 rmrr = container_of(header, struct acpi_dmar_reserved_memory, 261 rmrr = container_of(header, struct acpi_dmar_reserved_memory,
266 header); 262 header);
267 pr_info(PREFIX "RMRR base: %#016Lx end: %#016Lx\n", 263 pr_info("RMRR base: %#016Lx end: %#016Lx\n",
268 (unsigned long long)rmrr->base_address, 264 (unsigned long long)rmrr->base_address,
269 (unsigned long long)rmrr->end_address); 265 (unsigned long long)rmrr->end_address);
270 break; 266 break;
271 case ACPI_DMAR_TYPE_ATSR: 267 case ACPI_DMAR_TYPE_ATSR:
272 atsr = container_of(header, struct acpi_dmar_atsr, header); 268 atsr = container_of(header, struct acpi_dmar_atsr, header);
273 pr_info(PREFIX "ATSR flags: %#x\n", atsr->flags); 269 pr_info("ATSR flags: %#x\n", atsr->flags);
274 break; 270 break;
275 case ACPI_DMAR_HARDWARE_AFFINITY: 271 case ACPI_DMAR_HARDWARE_AFFINITY:
276 rhsa = container_of(header, struct acpi_dmar_rhsa, header); 272 rhsa = container_of(header, struct acpi_dmar_rhsa, header);
277 pr_info(PREFIX "RHSA base: %#016Lx proximity domain: %#x\n", 273 pr_info("RHSA base: %#016Lx proximity domain: %#x\n",
278 (unsigned long long)rhsa->base_address, 274 (unsigned long long)rhsa->base_address,
279 rhsa->proximity_domain); 275 rhsa->proximity_domain);
280 break; 276 break;
@@ -294,7 +290,7 @@ static int __init dmar_table_detect(void)
294 &dmar_tbl_size); 290 &dmar_tbl_size);
295 291
296 if (ACPI_SUCCESS(status) && !dmar_tbl) { 292 if (ACPI_SUCCESS(status) && !dmar_tbl) {
297 pr_warn(PREFIX "Unable to map DMAR\n"); 293 pr_warn("Unable to map DMAR\n");
298 status = AE_NOT_FOUND; 294 status = AE_NOT_FOUND;
299 } 295 }
300 296
@@ -328,18 +324,18 @@ parse_dmar_table(void)
328 return -ENODEV; 324 return -ENODEV;
329 325
330 if (dmar->width < PAGE_SHIFT - 1) { 326 if (dmar->width < PAGE_SHIFT - 1) {
331 pr_warn(PREFIX "Invalid DMAR haw\n"); 327 pr_warn("Invalid DMAR haw\n");
332 return -EINVAL; 328 return -EINVAL;
333 } 329 }
334 330
335 pr_info(PREFIX "Host address width %d\n", dmar->width + 1); 331 pr_info("Host address width %d\n", dmar->width + 1);
336 332
337 entry_header = (struct acpi_dmar_header *)(dmar + 1); 333 entry_header = (struct acpi_dmar_header *)(dmar + 1);
338 while (((unsigned long)entry_header) < 334 while (((unsigned long)entry_header) <
339 (((unsigned long)dmar) + dmar_tbl->length)) { 335 (((unsigned long)dmar) + dmar_tbl->length)) {
340 /* Avoid looping forever on bad ACPI tables */ 336 /* Avoid looping forever on bad ACPI tables */
341 if (entry_header->length == 0) { 337 if (entry_header->length == 0) {
342 pr_warn(PREFIX "Invalid 0-length structure\n"); 338 pr_warn("Invalid 0-length structure\n");
343 ret = -EINVAL; 339 ret = -EINVAL;
344 break; 340 break;
345 } 341 }
@@ -362,7 +358,7 @@ parse_dmar_table(void)
362#endif 358#endif
363 break; 359 break;
364 default: 360 default:
365 pr_warn(PREFIX "Unknown DMAR structure type %d\n", 361 pr_warn("Unknown DMAR structure type %d\n",
366 entry_header->type); 362 entry_header->type);
367 ret = 0; /* for forward compatibility */ 363 ret = 0; /* for forward compatibility */
368 break; 364 break;
@@ -461,12 +457,12 @@ int __init dmar_table_init(void)
461 ret = parse_dmar_table(); 457 ret = parse_dmar_table();
462 if (ret) { 458 if (ret) {
463 if (ret != -ENODEV) 459 if (ret != -ENODEV)
464 pr_info(PREFIX "parse DMAR table failure.\n"); 460 pr_info("parse DMAR table failure.\n");
465 return ret; 461 return ret;
466 } 462 }
467 463
468 if (list_empty(&dmar_drhd_units)) { 464 if (list_empty(&dmar_drhd_units)) {
469 pr_info(PREFIX "No DMAR devices found\n"); 465 pr_info("No DMAR devices found\n");
470 return -ENODEV; 466 return -ENODEV;
471 } 467 }
472 468
@@ -498,7 +494,7 @@ int __init check_zero_address(void)
498 (((unsigned long)dmar) + dmar_tbl->length)) { 494 (((unsigned long)dmar) + dmar_tbl->length)) {
499 /* Avoid looping forever on bad ACPI tables */ 495 /* Avoid looping forever on bad ACPI tables */
500 if (entry_header->length == 0) { 496 if (entry_header->length == 0) {
501 pr_warn(PREFIX "Invalid 0-length structure\n"); 497 pr_warn("Invalid 0-length structure\n");
502 return 0; 498 return 0;
503 } 499 }
504 500
@@ -549,8 +545,7 @@ int __init detect_intel_iommu(void)
549 545
550 if (ret && irq_remapping_enabled && cpu_has_x2apic && 546 if (ret && irq_remapping_enabled && cpu_has_x2apic &&
551 dmar->flags & 0x1) 547 dmar->flags & 0x1)
552 pr_info("Queued invalidation will be enabled to " 548 pr_info("Queued invalidation will be enabled to support x2apic and Intr-remapping.\n");
553 "support x2apic and Intr-remapping.\n");
554 549
555 if (ret && !no_iommu && !iommu_detected && !dmar_disabled) { 550 if (ret && !no_iommu && !iommu_detected && !dmar_disabled) {
556 iommu_detected = 1; 551 iommu_detected = 1;
@@ -580,9 +575,9 @@ static void unmap_iommu(struct intel_iommu *iommu)
580 * map_iommu: map the iommu's registers 575 * map_iommu: map the iommu's registers
581 * @iommu: the iommu to map 576 * @iommu: the iommu to map
582 * @phys_addr: the physical address of the base resgister 577 * @phys_addr: the physical address of the base resgister
583 * 578 *
584 * Memory map the iommu's registers. Start w/ a single page, and 579 * Memory map the iommu's registers. Start w/ a single page, and
585 * possibly expand if that turns out to be insufficent. 580 * possibly expand if that turns out to be insufficent.
586 */ 581 */
587static int map_iommu(struct intel_iommu *iommu, u64 phys_addr) 582static int map_iommu(struct intel_iommu *iommu, u64 phys_addr)
588{ 583{
@@ -1302,8 +1297,7 @@ int __init enable_drhd_fault_handling(void)
1302 ret = dmar_set_interrupt(iommu); 1297 ret = dmar_set_interrupt(iommu);
1303 1298
1304 if (ret) { 1299 if (ret) {
1305 pr_err("DRHD %Lx: failed to enable fault, " 1300 pr_err("DRHD %Lx: failed to enable fault, interrupt, ret %d\n",
1306 " interrupt, ret %d\n",
1307 (unsigned long long)drhd->reg_base_addr, ret); 1301 (unsigned long long)drhd->reg_base_addr, ret);
1308 return -1; 1302 return -1;
1309 } 1303 }