Skip to content

Commit fc72395

Browse files
committed
Merge branches 'acpi-pci', 'acpi-misc' and 'acpi-tools'
* acpi-pci: ACPI,PCI,IRQ: remove SCI penalize function ACPI,PCI,IRQ: remove redundant code in acpi_irq_penalty_init() ACPI,PCI,IRQ: reduce static IRQ array size to 16 ACPI,PCI,IRQ: reduce resource requirements * acpi-misc: ACPI / sysfs: fix error code in get_status() ACPI / device_sysfs: Clean up checkpatch errors ACPI / device_sysfs: Change _SUN and _STA show functions error return to EIO ACPI / device_sysfs: Add sysfs support for _HRV hardware revision arm64: defconfig: Enable ACPI ACPI / ARM64: Remove EXPERT dependency for ACPI on ARM64 ACPI / ARM64: Don't enable ACPI by default on ARM64 acer-wmi: Use acpi_dev_found() eeepc-wmi: Use acpi_dev_found() ACPI / utils: Rename acpi_dev_present() * acpi-tools: tools/power/acpi: close file only if it is open
4 parents efc499f + 9e5ed6d + f18ebc2 + 60438d9 commit fc72395

File tree

18 files changed

+122
-129
lines changed

18 files changed

+122
-129
lines changed

arch/arm64/configs/defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ CONFIG_PHY_RCAR_GEN3_USB2=y
264264
CONFIG_PHY_HI6220_USB=y
265265
CONFIG_PHY_XGENE=y
266266
CONFIG_ARM_SCPI_PROTOCOL=y
267+
CONFIG_ACPI=y
267268
CONFIG_EXT2_FS=y
268269
CONFIG_EXT3_FS=y
269270
CONFIG_FANOTIFY=y

arch/x86/kernel/acpi/boot.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,6 @@ static void __init acpi_sci_ioapic_setup(u8 bus_irq, u16 polarity, u16 trigger,
445445
polarity = acpi_sci_flags & ACPI_MADT_POLARITY_MASK;
446446

447447
mp_override_legacy_irq(bus_irq, polarity, trigger, gsi);
448-
acpi_penalize_sci_irq(bus_irq, trigger, polarity);
449448

450449
/*
451450
* stash over-ride to indicate we've been here

arch/x86/pci/acpi.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,6 @@ int __init pci_acpi_init(void)
396396
return -ENODEV;
397397

398398
printk(KERN_INFO "PCI: Using ACPI for IRQ routing\n");
399-
acpi_irq_penalty_init();
400399
pcibios_enable_irq = acpi_pci_irq_enable;
401400
pcibios_disable_irq = acpi_pci_irq_disable;
402401
x86_init.pci.init_irq = x86_init_noop;

drivers/acpi/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
menuconfig ACPI
66
bool "ACPI (Advanced Configuration and Power Interface) Support"
77
depends on !IA64_HP_SIM
8-
depends on IA64 || X86 || (ARM64 && EXPERT)
8+
depends on IA64 || X86 || ARM64
99
depends on PCI
1010
select PNP
11-
default y
11+
default y if (IA64 || X86)
1212
help
1313
Advanced Configuration and Power Interface (ACPI) support for
1414
Linux requires an ACPI-compliant platform (hardware/firmware),

drivers/acpi/device_sysfs.c

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static ssize_t acpi_object_path(acpi_handle handle, char *buf)
3535
if (result)
3636
return result;
3737

38-
result = sprintf(buf, "%s\n", (char*)path.pointer);
38+
result = sprintf(buf, "%s\n", (char *)path.pointer);
3939
kfree(path.pointer);
4040
return result;
4141
}
@@ -333,7 +333,8 @@ int acpi_device_modalias(struct device *dev, char *buf, int size)
333333
EXPORT_SYMBOL_GPL(acpi_device_modalias);
334334

335335
static ssize_t
336-
acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, char *buf) {
336+
acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, char *buf)
337+
{
337338
return __acpi_device_modalias(to_acpi_device(dev), buf, 1024);
338339
}
339340
static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL);
@@ -397,7 +398,8 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
397398
static DEVICE_ATTR(eject, 0200, NULL, acpi_eject_store);
398399

399400
static ssize_t
400-
acpi_device_hid_show(struct device *dev, struct device_attribute *attr, char *buf) {
401+
acpi_device_hid_show(struct device *dev, struct device_attribute *attr, char *buf)
402+
{
401403
struct acpi_device *acpi_dev = to_acpi_device(dev);
402404

403405
return sprintf(buf, "%s\n", acpi_device_hid(acpi_dev));
@@ -467,12 +469,27 @@ acpi_device_sun_show(struct device *dev, struct device_attribute *attr,
467469

468470
status = acpi_evaluate_integer(acpi_dev->handle, "_SUN", NULL, &sun);
469471
if (ACPI_FAILURE(status))
470-
return -ENODEV;
472+
return -EIO;
471473

472474
return sprintf(buf, "%llu\n", sun);
473475
}
474476
static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL);
475477

478+
static ssize_t
479+
acpi_device_hrv_show(struct device *dev, struct device_attribute *attr,
480+
char *buf) {
481+
struct acpi_device *acpi_dev = to_acpi_device(dev);
482+
acpi_status status;
483+
unsigned long long hrv;
484+
485+
status = acpi_evaluate_integer(acpi_dev->handle, "_HRV", NULL, &hrv);
486+
if (ACPI_FAILURE(status))
487+
return -EIO;
488+
489+
return sprintf(buf, "%llu\n", hrv);
490+
}
491+
static DEVICE_ATTR(hrv, 0444, acpi_device_hrv_show, NULL);
492+
476493
static ssize_t status_show(struct device *dev, struct device_attribute *attr,
477494
char *buf) {
478495
struct acpi_device *acpi_dev = to_acpi_device(dev);
@@ -481,7 +498,7 @@ static ssize_t status_show(struct device *dev, struct device_attribute *attr,
481498

482499
status = acpi_evaluate_integer(acpi_dev->handle, "_STA", NULL, &sta);
483500
if (ACPI_FAILURE(status))
484-
return -ENODEV;
501+
return -EIO;
485502

486503
return sprintf(buf, "%llu\n", sta);
487504
}
@@ -541,16 +558,22 @@ int acpi_device_setup_files(struct acpi_device *dev)
541558
goto end;
542559
}
543560

561+
if (acpi_has_method(dev->handle, "_HRV")) {
562+
result = device_create_file(&dev->dev, &dev_attr_hrv);
563+
if (result)
564+
goto end;
565+
}
566+
544567
if (acpi_has_method(dev->handle, "_STA")) {
545568
result = device_create_file(&dev->dev, &dev_attr_status);
546569
if (result)
547570
goto end;
548571
}
549572

550-
/*
551-
* If device has _EJ0, 'eject' file is created that is used to trigger
552-
* hot-removal function from userland.
553-
*/
573+
/*
574+
* If device has _EJ0, 'eject' file is created that is used to trigger
575+
* hot-removal function from userland.
576+
*/
554577
if (acpi_has_method(dev->handle, "_EJ0")) {
555578
result = device_create_file(&dev->dev, &dev_attr_eject);
556579
if (result)
@@ -604,6 +627,9 @@ void acpi_device_remove_files(struct acpi_device *dev)
604627
if (acpi_has_method(dev->handle, "_SUN"))
605628
device_remove_file(&dev->dev, &dev_attr_sun);
606629

630+
if (acpi_has_method(dev->handle, "_HRV"))
631+
device_remove_file(&dev->dev, &dev_attr_hrv);
632+
607633
if (dev->pnp.unique_id)
608634
device_remove_file(&dev->dev, &dev_attr_uid);
609635
if (dev->pnp.type.bus_address)

drivers/acpi/pci_link.c

Lines changed: 65 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <linux/mutex.h>
3737
#include <linux/slab.h>
3838
#include <linux/acpi.h>
39+
#include <linux/irq.h>
3940

4041
#include "internal.h"
4142

@@ -437,17 +438,15 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
437438
* enabled system.
438439
*/
439440

440-
#define ACPI_MAX_IRQS 256
441-
#define ACPI_MAX_ISA_IRQ 16
441+
#define ACPI_MAX_ISA_IRQS 16
442442

443-
#define PIRQ_PENALTY_PCI_AVAILABLE (0)
444443
#define PIRQ_PENALTY_PCI_POSSIBLE (16*16)
445444
#define PIRQ_PENALTY_PCI_USING (16*16*16)
446445
#define PIRQ_PENALTY_ISA_TYPICAL (16*16*16*16)
447446
#define PIRQ_PENALTY_ISA_USED (16*16*16*16*16)
448447
#define PIRQ_PENALTY_ISA_ALWAYS (16*16*16*16*16*16)
449448

450-
static int acpi_irq_penalty[ACPI_MAX_IRQS] = {
449+
static int acpi_isa_irq_penalty[ACPI_MAX_ISA_IRQS] = {
451450
PIRQ_PENALTY_ISA_ALWAYS, /* IRQ0 timer */
452451
PIRQ_PENALTY_ISA_ALWAYS, /* IRQ1 keyboard */
453452
PIRQ_PENALTY_ISA_ALWAYS, /* IRQ2 cascade */
@@ -457,49 +456,68 @@ static int acpi_irq_penalty[ACPI_MAX_IRQS] = {
457456
PIRQ_PENALTY_ISA_TYPICAL, /* IRQ6 */
458457
PIRQ_PENALTY_ISA_TYPICAL, /* IRQ7 parallel, spurious */
459458
PIRQ_PENALTY_ISA_TYPICAL, /* IRQ8 rtc, sometimes */
460-
PIRQ_PENALTY_PCI_AVAILABLE, /* IRQ9 PCI, often acpi */
461-
PIRQ_PENALTY_PCI_AVAILABLE, /* IRQ10 PCI */
462-
PIRQ_PENALTY_PCI_AVAILABLE, /* IRQ11 PCI */
459+
0, /* IRQ9 PCI, often acpi */
460+
0, /* IRQ10 PCI */
461+
0, /* IRQ11 PCI */
463462
PIRQ_PENALTY_ISA_USED, /* IRQ12 mouse */
464463
PIRQ_PENALTY_ISA_USED, /* IRQ13 fpe, sometimes */
465464
PIRQ_PENALTY_ISA_USED, /* IRQ14 ide0 */
466465
PIRQ_PENALTY_ISA_USED, /* IRQ15 ide1 */
467466
/* >IRQ15 */
468467
};
469468

470-
int __init acpi_irq_penalty_init(void)
469+
static int acpi_irq_pci_sharing_penalty(int irq)
471470
{
472471
struct acpi_pci_link *link;
473-
int i;
472+
int penalty = 0;
474473

475-
/*
476-
* Update penalties to facilitate IRQ balancing.
477-
*/
478474
list_for_each_entry(link, &acpi_link_list, list) {
479-
480475
/*
481-
* reflect the possible and active irqs in the penalty table --
482-
* useful for breaking ties.
476+
* If a link is active, penalize its IRQ heavily
477+
* so we try to choose a different IRQ.
483478
*/
484-
if (link->irq.possible_count) {
485-
int penalty =
486-
PIRQ_PENALTY_PCI_POSSIBLE /
487-
link->irq.possible_count;
488-
489-
for (i = 0; i < link->irq.possible_count; i++) {
490-
if (link->irq.possible[i] < ACPI_MAX_ISA_IRQ)
491-
acpi_irq_penalty[link->irq.
492-
possible[i]] +=
493-
penalty;
494-
}
495-
496-
} else if (link->irq.active) {
497-
acpi_irq_penalty[link->irq.active] +=
498-
PIRQ_PENALTY_PCI_POSSIBLE;
479+
if (link->irq.active && link->irq.active == irq)
480+
penalty += PIRQ_PENALTY_PCI_USING;
481+
else {
482+
int i;
483+
484+
/*
485+
* If a link is inactive, penalize the IRQs it
486+
* might use, but not as severely.
487+
*/
488+
for (i = 0; i < link->irq.possible_count; i++)
489+
if (link->irq.possible[i] == irq)
490+
penalty += PIRQ_PENALTY_PCI_POSSIBLE /
491+
link->irq.possible_count;
499492
}
500493
}
501494

502-
return 0;
495+
return penalty;
496+
}
497+
498+
static int acpi_irq_get_penalty(int irq)
499+
{
500+
int penalty = 0;
501+
502+
if (irq < ACPI_MAX_ISA_IRQS)
503+
penalty += acpi_isa_irq_penalty[irq];
504+
505+
/*
506+
* Penalize IRQ used by ACPI SCI. If ACPI SCI pin attributes conflict
507+
* with PCI IRQ attributes, mark ACPI SCI as ISA_ALWAYS so it won't be
508+
* use for PCI IRQs.
509+
*/
510+
if (irq == acpi_gbl_FADT.sci_interrupt) {
511+
u32 type = irq_get_trigger_type(irq) & IRQ_TYPE_SENSE_MASK;
512+
513+
if (type != IRQ_TYPE_LEVEL_LOW)
514+
penalty += PIRQ_PENALTY_ISA_ALWAYS;
515+
else
516+
penalty += PIRQ_PENALTY_PCI_USING;
517+
}
518+
519+
penalty += acpi_irq_pci_sharing_penalty(irq);
520+
return penalty;
503521
}
504522

505523
static int acpi_irq_balance = -1; /* 0: static, 1: balance */
@@ -547,12 +565,12 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
547565
* the use of IRQs 9, 10, 11, and >15.
548566
*/
549567
for (i = (link->irq.possible_count - 1); i >= 0; i--) {
550-
if (acpi_irq_penalty[irq] >
551-
acpi_irq_penalty[link->irq.possible[i]])
568+
if (acpi_irq_get_penalty(irq) >
569+
acpi_irq_get_penalty(link->irq.possible[i]))
552570
irq = link->irq.possible[i];
553571
}
554572
}
555-
if (acpi_irq_penalty[irq] >= PIRQ_PENALTY_ISA_ALWAYS) {
573+
if (acpi_irq_get_penalty(irq) >= PIRQ_PENALTY_ISA_ALWAYS) {
556574
printk(KERN_ERR PREFIX "No IRQ available for %s [%s]. "
557575
"Try pci=noacpi or acpi=off\n",
558576
acpi_device_name(link->device),
@@ -568,7 +586,6 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
568586
acpi_device_bid(link->device));
569587
return -ENODEV;
570588
} else {
571-
acpi_irq_penalty[link->irq.active] += PIRQ_PENALTY_PCI_USING;
572589
printk(KERN_WARNING PREFIX "%s [%s] enabled at IRQ %d\n",
573590
acpi_device_name(link->device),
574591
acpi_device_bid(link->device), link->irq.active);
@@ -778,7 +795,7 @@ static void acpi_pci_link_remove(struct acpi_device *device)
778795
}
779796

780797
/*
781-
* modify acpi_irq_penalty[] from cmdline
798+
* modify acpi_isa_irq_penalty[] from cmdline
782799
*/
783800
static int __init acpi_irq_penalty_update(char *str, int used)
784801
{
@@ -787,23 +804,24 @@ static int __init acpi_irq_penalty_update(char *str, int used)
787804
for (i = 0; i < 16; i++) {
788805
int retval;
789806
int irq;
807+
int new_penalty;
790808

791809
retval = get_option(&str, &irq);
792810

793811
if (!retval)
794812
break; /* no number found */
795813

796-
if (irq < 0)
797-
continue;
798-
799-
if (irq >= ARRAY_SIZE(acpi_irq_penalty))
814+
/* see if this is a ISA IRQ */
815+
if ((irq < 0) || (irq >= ACPI_MAX_ISA_IRQS))
800816
continue;
801817

802818
if (used)
803-
acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_USED;
819+
new_penalty = acpi_irq_get_penalty(irq) +
820+
PIRQ_PENALTY_ISA_USED;
804821
else
805-
acpi_irq_penalty[irq] = PIRQ_PENALTY_PCI_AVAILABLE;
822+
new_penalty = 0;
806823

824+
acpi_isa_irq_penalty[irq] = new_penalty;
807825
if (retval != 2) /* no next number */
808826
break;
809827
}
@@ -819,34 +837,15 @@ static int __init acpi_irq_penalty_update(char *str, int used)
819837
*/
820838
void acpi_penalize_isa_irq(int irq, int active)
821839
{
822-
if (irq >= 0 && irq < ARRAY_SIZE(acpi_irq_penalty)) {
823-
if (active)
824-
acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_USED;
825-
else
826-
acpi_irq_penalty[irq] += PIRQ_PENALTY_PCI_USING;
827-
}
840+
if ((irq >= 0) && (irq < ARRAY_SIZE(acpi_isa_irq_penalty)))
841+
acpi_isa_irq_penalty[irq] = acpi_irq_get_penalty(irq) +
842+
active ? PIRQ_PENALTY_ISA_USED : PIRQ_PENALTY_PCI_USING;
828843
}
829844

830845
bool acpi_isa_irq_available(int irq)
831846
{
832-
return irq >= 0 && (irq >= ARRAY_SIZE(acpi_irq_penalty) ||
833-
acpi_irq_penalty[irq] < PIRQ_PENALTY_ISA_ALWAYS);
834-
}
835-
836-
/*
837-
* Penalize IRQ used by ACPI SCI. If ACPI SCI pin attributes conflict with
838-
* PCI IRQ attributes, mark ACPI SCI as ISA_ALWAYS so it won't be use for
839-
* PCI IRQs.
840-
*/
841-
void acpi_penalize_sci_irq(int irq, int trigger, int polarity)
842-
{
843-
if (irq >= 0 && irq < ARRAY_SIZE(acpi_irq_penalty)) {
844-
if (trigger != ACPI_MADT_TRIGGER_LEVEL ||
845-
polarity != ACPI_MADT_POLARITY_ACTIVE_LOW)
846-
acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_ALWAYS;
847-
else
848-
acpi_irq_penalty[irq] += PIRQ_PENALTY_PCI_USING;
849-
}
847+
return irq >= 0 && (irq >= ARRAY_SIZE(acpi_isa_irq_penalty) ||
848+
acpi_irq_get_penalty(irq) < PIRQ_PENALTY_ISA_ALWAYS);
850849
}
851850

852851
/*

drivers/acpi/sysfs.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -555,23 +555,22 @@ static void acpi_global_event_handler(u32 event_type, acpi_handle device,
555555
static int get_status(u32 index, acpi_event_status *status,
556556
acpi_handle *handle)
557557
{
558-
int result = 0;
558+
int result;
559559

560560
if (index >= num_gpes + ACPI_NUM_FIXED_EVENTS)
561-
goto end;
561+
return -EINVAL;
562562

563563
if (index < num_gpes) {
564564
result = acpi_get_gpe_device(index, handle);
565565
if (result) {
566566
ACPI_EXCEPTION((AE_INFO, AE_NOT_FOUND,
567567
"Invalid GPE 0x%x", index));
568-
goto end;
568+
return result;
569569
}
570570
result = acpi_get_gpe_status(*handle, index, status);
571571
} else if (index < (num_gpes + ACPI_NUM_FIXED_EVENTS))
572572
result = acpi_get_event_status(index - num_gpes, status);
573573

574-
end:
575574
return result;
576575
}
577576

0 commit comments

Comments
 (0)