Skip to content

Commit c02b2fc

Browse files
committed
ACPI: PCI: Replace ACPI_DEBUG_PRINT() and ACPI_EXCEPTION()
The ACPI_DEBUG_PRINT() and ACPI_EXCEPTION() macros are used for message printing in the ACPICA code and they should not be used elsewhere. Special configuration (either kernel command line or sysfs-based) is needed to see the messages printed by them and the format of those messages is also special and convoluted. For this reason, replace all of the ACPI_DEBUG_PRINT() and ACPI_EXCEPTION() instances in pci_link.c with acpi_handle_*() calls relative to the ACPI handle of the given link device (wherever that handle is readily available) or pr_debug() invocations. While at it, make acpi_pci_link_check_current() print all messages with pr_debug(), because all of them are in the same category (_CRS return buffer issues) and they all should be printed at the same log level. Also make acpi_pci_link_set() use acpi_handle_*() for printing all messages for consistency. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Hanjun Guo <guohanjun@huawei.com>
1 parent bf5144a commit c02b2fc

1 file changed

Lines changed: 36 additions & 44 deletions

File tree

drivers/acpi/pci_link.c

Lines changed: 36 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727

2828
#include "internal.h"
2929

30-
#define _COMPONENT ACPI_PCI_COMPONENT
31-
ACPI_MODULE_NAME("pci_link");
3230
#define ACPI_PCI_LINK_CLASS "pci_irq_routing"
3331
#define ACPI_PCI_LINK_DEVICE_NAME "PCI Interrupt Link"
3432
#define ACPI_PCI_LINK_MAX_POSSIBLE 16
@@ -85,6 +83,7 @@ static acpi_status acpi_pci_link_check_possible(struct acpi_resource *resource,
8583
void *context)
8684
{
8785
struct acpi_pci_link *link = context;
86+
acpi_handle handle = link->device->handle;
8887
u32 i;
8988

9089
switch (resource->type) {
@@ -95,8 +94,8 @@ static acpi_status acpi_pci_link_check_possible(struct acpi_resource *resource,
9594
{
9695
struct acpi_resource_irq *p = &resource->data.irq;
9796
if (!p || !p->interrupt_count) {
98-
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
99-
"Blank _PRS IRQ resource\n"));
97+
acpi_handle_debug(handle,
98+
"Blank _PRS IRQ resource\n");
10099
return AE_OK;
101100
}
102101
for (i = 0;
@@ -153,18 +152,18 @@ static acpi_status acpi_pci_link_check_possible(struct acpi_resource *resource,
153152

154153
static int acpi_pci_link_get_possible(struct acpi_pci_link *link)
155154
{
155+
acpi_handle handle = link->device->handle;
156156
acpi_status status;
157157

158-
status = acpi_walk_resources(link->device->handle, METHOD_NAME__PRS,
158+
status = acpi_walk_resources(handle, METHOD_NAME__PRS,
159159
acpi_pci_link_check_possible, link);
160160
if (ACPI_FAILURE(status)) {
161-
acpi_handle_debug(link->device->handle, "_PRS not present or invalid");
161+
acpi_handle_debug(handle, "_PRS not present or invalid");
162162
return 0;
163163
}
164164

165-
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
166-
"Found %d possible IRQs\n",
167-
link->irq.possible_count));
165+
acpi_handle_debug(handle, "Found %d possible IRQs\n",
166+
link->irq.possible_count);
168167

169168
return 0;
170169
}
@@ -186,8 +185,7 @@ static acpi_status acpi_pci_link_check_current(struct acpi_resource *resource,
186185
* IRQ descriptors may have no IRQ# bits set,
187186
* particularly those those w/ _STA disabled
188187
*/
189-
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
190-
"Blank _CRS IRQ resource\n"));
188+
pr_debug("Blank _CRS IRQ resource\n");
191189
return AE_OK;
192190
}
193191
*irq = p->interrupts[0];
@@ -202,17 +200,16 @@ static acpi_status acpi_pci_link_check_current(struct acpi_resource *resource,
202200
* extended IRQ descriptors must
203201
* return at least 1 IRQ
204202
*/
205-
printk(KERN_WARNING PREFIX
206-
"Blank _CRS EXT IRQ resource\n");
203+
pr_debug("Blank _CRS EXT IRQ resource\n");
207204
return AE_OK;
208205
}
209206
*irq = p->interrupts[0];
210207
break;
211208
}
212209
break;
213210
default:
214-
printk(KERN_ERR PREFIX "_CRS resource type 0x%x isn't an IRQ\n",
215-
resource->type);
211+
pr_debug("_CRS resource type 0x%x is not IRQ\n",
212+
resource->type);
216213
return AE_OK;
217214
}
218215

@@ -228,8 +225,9 @@ static acpi_status acpi_pci_link_check_current(struct acpi_resource *resource,
228225
*/
229226
static int acpi_pci_link_get_current(struct acpi_pci_link *link)
230227
{
231-
int result = 0;
228+
acpi_handle handle = link->device->handle;
232229
acpi_status status;
230+
int result = 0;
233231
int irq = 0;
234232

235233
link->irq.active = 0;
@@ -239,12 +237,12 @@ static int acpi_pci_link_get_current(struct acpi_pci_link *link)
239237
/* Query _STA, set link->device->status */
240238
result = acpi_bus_get_status(link->device);
241239
if (result) {
242-
printk(KERN_ERR PREFIX "Unable to read status\n");
240+
acpi_handle_err(handle, "Unable to read status\n");
243241
goto end;
244242
}
245243

246244
if (!link->device->status.enabled) {
247-
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Link disabled\n"));
245+
acpi_handle_debug(handle, "Link disabled\n");
248246
return 0;
249247
}
250248
}
@@ -253,36 +251,38 @@ static int acpi_pci_link_get_current(struct acpi_pci_link *link)
253251
* Query and parse _CRS to get the current IRQ assignment.
254252
*/
255253

256-
status = acpi_walk_resources(link->device->handle, METHOD_NAME__CRS,
254+
status = acpi_walk_resources(handle, METHOD_NAME__CRS,
257255
acpi_pci_link_check_current, &irq);
258256
if (ACPI_FAILURE(status)) {
259-
ACPI_EXCEPTION((AE_INFO, status, "Evaluating _CRS"));
257+
acpi_handle_warn(handle, "_CRS evaluation failed: %s\n",
258+
acpi_format_exception(status));
260259
result = -ENODEV;
261260
goto end;
262261
}
263262

264263
if (acpi_strict && !irq) {
265-
printk(KERN_ERR PREFIX "_CRS returned 0\n");
264+
acpi_handle_err(handle, "_CRS returned 0\n");
266265
result = -ENODEV;
267266
}
268267

269268
link->irq.active = irq;
270269

271-
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Link at IRQ %d \n", link->irq.active));
270+
acpi_handle_debug(handle, "Link at IRQ %d \n", link->irq.active);
272271

273272
end:
274273
return result;
275274
}
276275

277276
static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
278277
{
279-
int result;
280-
acpi_status status;
281278
struct {
282279
struct acpi_resource res;
283280
struct acpi_resource end;
284281
} *resource;
285282
struct acpi_buffer buffer = { 0, NULL };
283+
acpi_handle handle = link->device->handle;
284+
acpi_status status;
285+
int result;
286286

287287
if (!irq)
288288
return -EINVAL;
@@ -329,7 +329,8 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
329329
/* ignore resource_source, it's optional */
330330
break;
331331
default:
332-
printk(KERN_ERR PREFIX "Invalid Resource_type %d\n", link->irq.resource_type);
332+
acpi_handle_err(handle, "Invalid resource type %d\n",
333+
link->irq.resource_type);
333334
result = -EINVAL;
334335
goto end;
335336

@@ -342,23 +343,20 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
342343

343344
/* check for total failure */
344345
if (ACPI_FAILURE(status)) {
345-
ACPI_EXCEPTION((AE_INFO, status, "Evaluating _SRS"));
346+
acpi_handle_warn(handle, "_SRS evaluation failed: %s",
347+
acpi_format_exception(status));
346348
result = -ENODEV;
347349
goto end;
348350
}
349351

350352
/* Query _STA, set device->status */
351353
result = acpi_bus_get_status(link->device);
352354
if (result) {
353-
printk(KERN_ERR PREFIX "Unable to read status\n");
355+
acpi_handle_err(handle, "Unable to read status\n");
354356
goto end;
355357
}
356-
if (!link->device->status.enabled) {
357-
printk(KERN_WARNING PREFIX
358-
"%s [%s] disabled and referenced, BIOS bug\n",
359-
acpi_device_name(link->device),
360-
acpi_device_bid(link->device));
361-
}
358+
if (!link->device->status.enabled)
359+
acpi_handle_warn(handle, "Disabled and referenced, BIOS bug\n");
362360

363361
/* Query _CRS, set link->irq.active */
364362
result = acpi_pci_link_get_current(link);
@@ -375,14 +373,12 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
375373
* policy: when _CRS doesn't return what we just _SRS
376374
* assume _SRS worked and override _CRS value.
377375
*/
378-
printk(KERN_WARNING PREFIX
379-
"%s [%s] BIOS reported IRQ %d, using IRQ %d\n",
380-
acpi_device_name(link->device),
381-
acpi_device_bid(link->device), link->irq.active, irq);
376+
acpi_handle_warn(handle, "BIOS reported IRQ %d, using IRQ %d\n",
377+
link->irq.active, irq);
382378
link->irq.active = irq;
383379
}
384380

385-
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Set IRQ %d\n", link->irq.active));
381+
acpi_handle_debug(handle, "Set IRQ %d\n", link->irq.active);
386382

387383
end:
388384
kfree(resource);
@@ -656,9 +652,7 @@ int acpi_pci_link_allocate_irq(acpi_handle handle, int index, int *triggering,
656652
*polarity = link->irq.polarity;
657653
if (name)
658654
*name = acpi_device_bid(link->device);
659-
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
660-
"Link %s is referenced\n",
661-
acpi_device_bid(link->device)));
655+
acpi_handle_debug(handle, "Link is referenced\n");
662656
return link->irq.active;
663657
}
664658

@@ -702,9 +696,7 @@ int acpi_pci_link_free_irq(acpi_handle handle)
702696
*/
703697
link->refcnt--;
704698
#endif
705-
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
706-
"Link %s is dereferenced\n",
707-
acpi_device_bid(link->device)));
699+
acpi_handle_debug(handle, "Link is dereferenced\n");
708700

709701
if (link->refcnt == 0)
710702
acpi_evaluate_object(link->device->handle, "_DIS", NULL, NULL);

0 commit comments

Comments
 (0)