Skip to content

Commit

Permalink
Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/g…
Browse files Browse the repository at this point in the history
…it/lenb/linux-acpi-2.6

* 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6:
  x86 ACPI: Add support for Always Running APIC timer
  ACPI x86: Make aperf/mperf MSR access in acpi_cpufreq read_only
  ACPI x86: Cleanup acpi_cpufreq structures related to aperf/mperf
  ACPICA: delete check for AML access to port 0x81-83
  ACPI: WMI: use .notify method instead of installing handler directly
  sony-laptop: use .notify method instead of installing handler directly
  panasonic-laptop: use .notify method instead of installing handler directly
  fujitsu-laptop: use .notify method instead of installing hotkey handler directly
  fujitsu-laptop: use .notify method instead of installing handler directly
  ACPI: video: use .notify method instead of installing handler directly
  ACPI: thermal: use .notify method instead of installing handler directly
  ACPI battery: fix async boot oops
  ACPI: delete acpi_device.g_list
  NULL noise: drivers/platform/x86/panasonic-laptop.c
  ACPI: cpufreq: remove dupilcated #include
  ACPI: Adjust Kelvin offset to match local implementation
  ACPI: convert acpi_device_lock spinlock to mutex
  • Loading branch information
Linus Torvalds committed Apr 8, 2009
2 parents 139ef17 + 8897c18 commit 7b85a88
Show file tree
Hide file tree
Showing 19 changed files with 131 additions and 248 deletions.
1 change: 1 addition & 0 deletions arch/x86/include/asm/cpufeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
* CPUID levels like 0x6, 0xA etc
*/
#define X86_FEATURE_IDA (7*32+ 0) /* Intel Dynamic Acceleration */
#define X86_FEATURE_ARAT (7*32+ 1) /* Always Running APIC Timer */

/* Virtualization flags: Linux defined */
#define X86_FEATURE_TPR_SHADOW (8*32+ 0) /* Intel TPR Shadow */
Expand Down
6 changes: 6 additions & 0 deletions arch/x86/kernel/apic/apic.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,12 @@ static void __cpuinit setup_APIC_timer(void)
{
struct clock_event_device *levt = &__get_cpu_var(lapic_events);

if (cpu_has(&current_cpu_data, X86_FEATURE_ARAT)) {
lapic_clockevent.features &= ~CLOCK_EVT_FEAT_C3STOP;
/* Make LAPIC timer preferrable over percpu HPET */
lapic_clockevent.rating = 150;
}

memcpy(levt, &lapic_clockevent, sizeof(*levt));
levt->cpumask = cpumask_of(smp_processor_id());

Expand Down
1 change: 1 addition & 0 deletions arch/x86/kernel/cpu/addon_cpuid_features.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c)

static const struct cpuid_bit __cpuinitconst cpuid_bits[] = {
{ X86_FEATURE_IDA, CR_EAX, 1, 0x00000006 },
{ X86_FEATURE_ARAT, CR_EAX, 2, 0x00000006 },
{ 0, 0, 0, 0 }
};

Expand Down
55 changes: 29 additions & 26 deletions arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ struct acpi_cpufreq_data {
unsigned int max_freq;
unsigned int resume;
unsigned int cpu_feature;
u64 saved_aperf, saved_mperf;
};

static DEFINE_PER_CPU(struct acpi_cpufreq_data *, drv_data);
Expand Down Expand Up @@ -241,26 +242,23 @@ static u32 get_cur_val(const struct cpumask *mask)
return cmd.val;
}

struct perf_cur {
struct perf_pair {
union {
struct {
u32 lo;
u32 hi;
} split;
u64 whole;
} aperf_cur, mperf_cur;
} aperf, mperf;
};


static long read_measured_perf_ctrs(void *_cur)
{
struct perf_cur *cur = _cur;
struct perf_pair *cur = _cur;

rdmsr(MSR_IA32_APERF, cur->aperf_cur.split.lo, cur->aperf_cur.split.hi);
rdmsr(MSR_IA32_MPERF, cur->mperf_cur.split.lo, cur->mperf_cur.split.hi);

wrmsr(MSR_IA32_APERF, 0, 0);
wrmsr(MSR_IA32_MPERF, 0, 0);
rdmsr(MSR_IA32_APERF, cur->aperf.split.lo, cur->aperf.split.hi);
rdmsr(MSR_IA32_MPERF, cur->mperf.split.lo, cur->mperf.split.hi);

return 0;
}
Expand All @@ -281,52 +279,57 @@ static long read_measured_perf_ctrs(void *_cur)
static unsigned int get_measured_perf(struct cpufreq_policy *policy,
unsigned int cpu)
{
struct perf_cur cur;
struct perf_pair readin, cur;
unsigned int perf_percent;
unsigned int retval;

if (!work_on_cpu(cpu, read_measured_perf_ctrs, &cur))
if (!work_on_cpu(cpu, read_measured_perf_ctrs, &readin))
return 0;

cur.aperf.whole = readin.aperf.whole -
per_cpu(drv_data, cpu)->saved_aperf;
cur.mperf.whole = readin.mperf.whole -
per_cpu(drv_data, cpu)->saved_mperf;
per_cpu(drv_data, cpu)->saved_aperf = readin.aperf.whole;
per_cpu(drv_data, cpu)->saved_mperf = readin.mperf.whole;

#ifdef __i386__
/*
* We dont want to do 64 bit divide with 32 bit kernel
* Get an approximate value. Return failure in case we cannot get
* an approximate value.
*/
if (unlikely(cur.aperf_cur.split.hi || cur.mperf_cur.split.hi)) {
if (unlikely(cur.aperf.split.hi || cur.mperf.split.hi)) {
int shift_count;
u32 h;

h = max_t(u32, cur.aperf_cur.split.hi, cur.mperf_cur.split.hi);
h = max_t(u32, cur.aperf.split.hi, cur.mperf.split.hi);
shift_count = fls(h);

cur.aperf_cur.whole >>= shift_count;
cur.mperf_cur.whole >>= shift_count;
cur.aperf.whole >>= shift_count;
cur.mperf.whole >>= shift_count;
}

if (((unsigned long)(-1) / 100) < cur.aperf_cur.split.lo) {
if (((unsigned long)(-1) / 100) < cur.aperf.split.lo) {
int shift_count = 7;
cur.aperf_cur.split.lo >>= shift_count;
cur.mperf_cur.split.lo >>= shift_count;
cur.aperf.split.lo >>= shift_count;
cur.mperf.split.lo >>= shift_count;
}

if (cur.aperf_cur.split.lo && cur.mperf_cur.split.lo)
perf_percent = (cur.aperf_cur.split.lo * 100) /
cur.mperf_cur.split.lo;
if (cur.aperf.split.lo && cur.mperf.split.lo)
perf_percent = (cur.aperf.split.lo * 100) / cur.mperf.split.lo;
else
perf_percent = 0;

#else
if (unlikely(((unsigned long)(-1) / 100) < cur.aperf_cur.whole)) {
if (unlikely(((unsigned long)(-1) / 100) < cur.aperf.whole)) {
int shift_count = 7;
cur.aperf_cur.whole >>= shift_count;
cur.mperf_cur.whole >>= shift_count;
cur.aperf.whole >>= shift_count;
cur.mperf.whole >>= shift_count;
}

if (cur.aperf_cur.whole && cur.mperf_cur.whole)
perf_percent = (cur.aperf_cur.whole * 100) /
cur.mperf_cur.whole;
if (cur.aperf.whole && cur.mperf.whole)
perf_percent = (cur.aperf.whole * 100) / cur.mperf.whole;
else
perf_percent = 0;

Expand Down
1 change: 0 additions & 1 deletion arch/x86/kernel/cpu/cpufreq/longhaul.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include <linux/timex.h>
#include <linux/io.h>
#include <linux/acpi.h>
#include <linux/kernel.h>

#include <asm/msr.h>
#include <acpi/processor.h>
Expand Down
1 change: 0 additions & 1 deletion drivers/acpi/acpica/hwvalid.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ static const struct acpi_port_info acpi_protected_ports[] = {
{"PIT2", 0x0048, 0x004B, ACPI_OSI_WIN_XP},
{"RTC", 0x0070, 0x0071, ACPI_OSI_WIN_XP},
{"CMOS", 0x0074, 0x0076, ACPI_OSI_WIN_XP},
{"DMA1", 0x0081, 0x0083, ACPI_OSI_WIN_XP},
{"DMA1L", 0x0087, 0x0087, ACPI_OSI_WIN_XP},
{"DMA2", 0x0089, 0x008B, ACPI_OSI_WIN_XP},
{"DMA2L", 0x008F, 0x008F, ACPI_OSI_WIN_XP},
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ static struct acpi_driver acpi_battery_driver = {
},
};

static void __init acpi_battery_init_async(void *unused, async_cookie_t cookie)
static void acpi_battery_init_async(void *unused, async_cookie_t cookie)
{
if (acpi_disabled)
return;
Expand Down
13 changes: 4 additions & 9 deletions drivers/acpi/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,25 +343,21 @@ acpi_system_write_alarm(struct file *file,
}
#endif /* HAVE_ACPI_LEGACY_ALARM */

extern struct list_head acpi_wakeup_device_list;
extern spinlock_t acpi_device_lock;

static int
acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
{
struct list_head *node, *next;

seq_printf(seq, "Device\tS-state\t Status Sysfs node\n");

spin_lock(&acpi_device_lock);
mutex_lock(&acpi_device_lock);
list_for_each_safe(node, next, &acpi_wakeup_device_list) {
struct acpi_device *dev =
container_of(node, struct acpi_device, wakeup_list);
struct device *ldev;

if (!dev->wakeup.flags.valid)
continue;
spin_unlock(&acpi_device_lock);

ldev = acpi_get_physical_device(dev->handle);
seq_printf(seq, "%s\t S%d\t%c%-8s ",
Expand All @@ -376,9 +372,8 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
seq_printf(seq, "\n");
put_device(ldev);

spin_lock(&acpi_device_lock);
}
spin_unlock(&acpi_device_lock);
mutex_unlock(&acpi_device_lock);
return 0;
}

Expand Down Expand Up @@ -409,7 +404,7 @@ acpi_system_write_wakeup_device(struct file *file,
strbuf[len] = '\0';
sscanf(strbuf, "%s", str);

spin_lock(&acpi_device_lock);
mutex_lock(&acpi_device_lock);
list_for_each_safe(node, next, &acpi_wakeup_device_list) {
struct acpi_device *dev =
container_of(node, struct acpi_device, wakeup_list);
Expand Down Expand Up @@ -446,7 +441,7 @@ acpi_system_write_wakeup_device(struct file *file,
}
}
}
spin_unlock(&acpi_device_lock);
mutex_unlock(&acpi_device_lock);
return count;
}

Expand Down
3 changes: 3 additions & 0 deletions drivers/acpi/processor_idle.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ static void acpi_timer_check_state(int state, struct acpi_processor *pr,
struct acpi_processor_power *pwr = &pr->power;
u8 type = local_apic_timer_c2_ok ? ACPI_STATE_C3 : ACPI_STATE_C2;

if (cpu_has(&cpu_data(pr->id), X86_FEATURE_ARAT))
return;

/*
* Check, if one of the previous states already marked the lapic
* unstable
Expand Down
31 changes: 11 additions & 20 deletions drivers/acpi/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extern struct acpi_device *acpi_root;

static LIST_HEAD(acpi_device_list);
static LIST_HEAD(acpi_bus_id_list);
DEFINE_SPINLOCK(acpi_device_lock);
DEFINE_MUTEX(acpi_device_lock);
LIST_HEAD(acpi_wakeup_device_list);

struct acpi_device_bus_id{
Expand Down Expand Up @@ -491,7 +491,6 @@ static int acpi_device_register(struct acpi_device *device,
*/
INIT_LIST_HEAD(&device->children);
INIT_LIST_HEAD(&device->node);
INIT_LIST_HEAD(&device->g_list);
INIT_LIST_HEAD(&device->wakeup_list);

new_bus_id = kzalloc(sizeof(struct acpi_device_bus_id), GFP_KERNEL);
Expand All @@ -500,7 +499,7 @@ static int acpi_device_register(struct acpi_device *device,
return -ENOMEM;
}

spin_lock(&acpi_device_lock);
mutex_lock(&acpi_device_lock);
/*
* Find suitable bus_id and instance number in acpi_bus_id_list
* If failed, create one and link it into acpi_bus_id_list
Expand All @@ -521,14 +520,12 @@ static int acpi_device_register(struct acpi_device *device,
}
dev_set_name(&device->dev, "%s:%02x", acpi_device_bus_id->bus_id, acpi_device_bus_id->instance_no);

if (device->parent) {
if (device->parent)
list_add_tail(&device->node, &device->parent->children);
list_add_tail(&device->g_list, &device->parent->g_list);
} else
list_add_tail(&device->g_list, &acpi_device_list);

if (device->wakeup.flags.valid)
list_add_tail(&device->wakeup_list, &acpi_wakeup_device_list);
spin_unlock(&acpi_device_lock);
mutex_unlock(&acpi_device_lock);

if (device->parent)
device->dev.parent = &parent->dev;
Expand All @@ -549,28 +546,22 @@ static int acpi_device_register(struct acpi_device *device,
device->removal_type = ACPI_BUS_REMOVAL_NORMAL;
return 0;
end:
spin_lock(&acpi_device_lock);
if (device->parent) {
mutex_lock(&acpi_device_lock);
if (device->parent)
list_del(&device->node);
list_del(&device->g_list);
} else
list_del(&device->g_list);
list_del(&device->wakeup_list);
spin_unlock(&acpi_device_lock);
mutex_unlock(&acpi_device_lock);
return result;
}

static void acpi_device_unregister(struct acpi_device *device, int type)
{
spin_lock(&acpi_device_lock);
if (device->parent) {
mutex_lock(&acpi_device_lock);
if (device->parent)
list_del(&device->node);
list_del(&device->g_list);
} else
list_del(&device->g_list);

list_del(&device->wakeup_list);
spin_unlock(&acpi_device_lock);
mutex_unlock(&acpi_device_lock);

acpi_detach_data(device->handle, acpi_bus_data_handler);

Expand Down
3 changes: 3 additions & 0 deletions drivers/acpi/sleep.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ extern int acpi_suspend (u32 state);
extern void acpi_enable_wakeup_device_prep(u8 sleep_state);
extern void acpi_enable_wakeup_device(u8 sleep_state);
extern void acpi_disable_wakeup_device(u8 sleep_state);

extern struct list_head acpi_wakeup_device_list;
extern struct mutex acpi_device_lock;
Loading

0 comments on commit 7b85a88

Please sign in to comment.