Commit aad659e4 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

Merge branches 'acpi-cppc', 'acpi-video' and 'acpi-utils'

* acpi-cppc:
  ACPI: CPPC: Replace cppc_attr with kobj_attribute
  ACPI: CPPC: Add emtpy stubs of functions for CONFIG_ACPI_CPPC_LIB unset

* acpi-video:
  ACPI: video: use native backlight for GA401/GA502/GA503
  ACPI: video: Check LCD flag on ACPI-reduced-hardware devices
  ACPI: utils: Add acpi_reduced_hardware() helper

* acpi-utils:
  ACPI: utils: Capitalize abbreviations in the comments
  ACPI: utils: Document for_each_acpi_dev_match() macro
...@@ -2182,6 +2182,30 @@ static bool dmi_is_desktop(void) ...@@ -2182,6 +2182,30 @@ static bool dmi_is_desktop(void)
return false; return false;
} }
/*
* We're seeing a lot of bogus backlight interfaces on newer machines
* without a LCD such as desktops, servers and HDMI sticks. Checking the
* lcd flag fixes this, enable this by default on any machines which are:
* 1. Win8 ready (where we also prefer the native backlight driver, so
* normally the acpi_video code should not register there anyways); *and*
* 2.1 Report a desktop/server DMI chassis-type, or
* 2.2 Are an ACPI-reduced-hardware platform (and thus won't use the EC for
backlight control)
*/
static bool should_check_lcd_flag(void)
{
if (!acpi_osi_is_win8())
return false;
if (dmi_is_desktop())
return true;
if (acpi_reduced_hardware())
return true;
return false;
}
int acpi_video_register(void) int acpi_video_register(void)
{ {
int ret = 0; int ret = 0;
...@@ -2195,19 +2219,8 @@ int acpi_video_register(void) ...@@ -2195,19 +2219,8 @@ int acpi_video_register(void)
goto leave; goto leave;
} }
/* if (only_lcd == -1)
* We're seeing a lot of bogus backlight interfaces on newer machines only_lcd = should_check_lcd_flag();
* without a LCD such as desktops, servers and HDMI sticks. Checking
* the lcd flag fixes this, so enable this on any machines which are
* win8 ready (where we also prefer the native backlight driver, so
* normally the acpi_video code should not register there anyways).
*/
if (only_lcd == -1) {
if (dmi_is_desktop() && acpi_osi_is_win8())
only_lcd = true;
else
only_lcd = false;
}
dmi_check_system(video_dmi_table); dmi_check_system(video_dmi_table);
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#define pr_fmt(fmt) "ACPI CPPC: " fmt #define pr_fmt(fmt) "ACPI CPPC: " fmt
#include <linux/cpufreq.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/iopoll.h> #include <linux/iopoll.h>
#include <linux/ktime.h> #include <linux/ktime.h>
...@@ -119,23 +118,15 @@ static DEFINE_PER_CPU(struct cpc_desc *, cpc_desc_ptr); ...@@ -119,23 +118,15 @@ static DEFINE_PER_CPU(struct cpc_desc *, cpc_desc_ptr);
*/ */
#define NUM_RETRIES 500ULL #define NUM_RETRIES 500ULL
struct cppc_attr {
struct attribute attr;
ssize_t (*show)(struct kobject *kobj,
struct attribute *attr, char *buf);
ssize_t (*store)(struct kobject *kobj,
struct attribute *attr, const char *c, ssize_t count);
};
#define define_one_cppc_ro(_name) \ #define define_one_cppc_ro(_name) \
static struct cppc_attr _name = \ static struct kobj_attribute _name = \
__ATTR(_name, 0444, show_##_name, NULL) __ATTR(_name, 0444, show_##_name, NULL)
#define to_cpc_desc(a) container_of(a, struct cpc_desc, kobj) #define to_cpc_desc(a) container_of(a, struct cpc_desc, kobj)
#define show_cppc_data(access_fn, struct_name, member_name) \ #define show_cppc_data(access_fn, struct_name, member_name) \
static ssize_t show_##member_name(struct kobject *kobj, \ static ssize_t show_##member_name(struct kobject *kobj, \
struct attribute *attr, char *buf) \ struct kobj_attribute *attr, char *buf) \
{ \ { \
struct cpc_desc *cpc_ptr = to_cpc_desc(kobj); \ struct cpc_desc *cpc_ptr = to_cpc_desc(kobj); \
struct struct_name st_name = {0}; \ struct struct_name st_name = {0}; \
...@@ -161,7 +152,7 @@ show_cppc_data(cppc_get_perf_ctrs, cppc_perf_fb_ctrs, reference_perf); ...@@ -161,7 +152,7 @@ show_cppc_data(cppc_get_perf_ctrs, cppc_perf_fb_ctrs, reference_perf);
show_cppc_data(cppc_get_perf_ctrs, cppc_perf_fb_ctrs, wraparound_time); show_cppc_data(cppc_get_perf_ctrs, cppc_perf_fb_ctrs, wraparound_time);
static ssize_t show_feedback_ctrs(struct kobject *kobj, static ssize_t show_feedback_ctrs(struct kobject *kobj,
struct attribute *attr, char *buf) struct kobj_attribute *attr, char *buf)
{ {
struct cpc_desc *cpc_ptr = to_cpc_desc(kobj); struct cpc_desc *cpc_ptr = to_cpc_desc(kobj);
struct cppc_perf_fb_ctrs fb_ctrs = {0}; struct cppc_perf_fb_ctrs fb_ctrs = {0};
......
...@@ -811,7 +811,7 @@ static int acpi_dev_match_cb(struct device *dev, const void *data) ...@@ -811,7 +811,7 @@ static int acpi_dev_match_cb(struct device *dev, const void *data)
* Note that if the device is pluggable, it may since have disappeared. * Note that if the device is pluggable, it may since have disappeared.
* *
* Note that unlike acpi_dev_found() this function checks the status * Note that unlike acpi_dev_found() this function checks the status
* of the device. So for devices which are present in the dsdt, but * of the device. So for devices which are present in the DSDT, but
* which are disabled (their _STA callback returns 0) this function * which are disabled (their _STA callback returns 0) this function
* will return false. * will return false.
* *
...@@ -838,7 +838,7 @@ EXPORT_SYMBOL(acpi_dev_present); ...@@ -838,7 +838,7 @@ EXPORT_SYMBOL(acpi_dev_present);
/** /**
* acpi_dev_get_next_match_dev - Return the next match of ACPI device * acpi_dev_get_next_match_dev - Return the next match of ACPI device
* @adev: Pointer to the previous acpi_device matching this @hid, @uid and @hrv * @adev: Pointer to the previous ACPI device matching this @hid, @uid and @hrv
* @hid: Hardware ID of the device. * @hid: Hardware ID of the device.
* @uid: Unique ID of the device, pass NULL to not check _UID * @uid: Unique ID of the device, pass NULL to not check _UID
* @hrv: Hardware Revision of the device, pass -1 to not check _HRV * @hrv: Hardware Revision of the device, pass -1 to not check _HRV
...@@ -846,7 +846,11 @@ EXPORT_SYMBOL(acpi_dev_present); ...@@ -846,7 +846,11 @@ EXPORT_SYMBOL(acpi_dev_present);
* Return the next match of ACPI device if another matching device was present * Return the next match of ACPI device if another matching device was present
* at the moment of invocation, or NULL otherwise. * at the moment of invocation, or NULL otherwise.
* *
* The caller is responsible to call put_device() on the returned device. * FIXME: The function does not tolerate the sudden disappearance of @adev, e.g.
* in the case of a hotplug event. That said, the caller should ensure that
* this will never happen.
*
* The caller is responsible for invoking acpi_dev_put() on the returned device.
* *
* See additional information in acpi_dev_present() as well. * See additional information in acpi_dev_present() as well.
*/ */
...@@ -875,7 +879,7 @@ EXPORT_SYMBOL(acpi_dev_get_next_match_dev); ...@@ -875,7 +879,7 @@ EXPORT_SYMBOL(acpi_dev_get_next_match_dev);
* Return the first match of ACPI device if a matching device was present * Return the first match of ACPI device if a matching device was present
* at the moment of invocation, or NULL otherwise. * at the moment of invocation, or NULL otherwise.
* *
* The caller is responsible to call put_device() on the returned device. * The caller is responsible for invoking acpi_dev_put() on the returned device.
* *
* See additional information in acpi_dev_present() as well. * See additional information in acpi_dev_present() as well.
*/ */
...@@ -886,6 +890,17 @@ acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv) ...@@ -886,6 +890,17 @@ acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv)
} }
EXPORT_SYMBOL(acpi_dev_get_first_match_dev); EXPORT_SYMBOL(acpi_dev_get_first_match_dev);
/**
* acpi_reduced_hardware - Return if this is an ACPI-reduced-hw machine
*
* Return true when running on an ACPI-reduced-hw machine, false otherwise.
*/
bool acpi_reduced_hardware(void)
{
return acpi_gbl_reduced_hardware;
}
EXPORT_SYMBOL_GPL(acpi_reduced_hardware);
/* /*
* acpi_backlight= handling, this is done here rather then in video_detect.c * acpi_backlight= handling, this is done here rather then in video_detect.c
* because __setup cannot be used in modules. * because __setup cannot be used in modules.
......
...@@ -385,6 +385,30 @@ static const struct dmi_system_id video_detect_dmi_table[] = { ...@@ -385,6 +385,30 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
DMI_MATCH(DMI_BOARD_NAME, "BA51_MV"), DMI_MATCH(DMI_BOARD_NAME, "BA51_MV"),
}, },
}, },
{
.callback = video_detect_force_native,
.ident = "ASUSTeK COMPUTER INC. GA401",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
DMI_MATCH(DMI_PRODUCT_NAME, "GA401"),
},
},
{
.callback = video_detect_force_native,
.ident = "ASUSTeK COMPUTER INC. GA502",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
DMI_MATCH(DMI_PRODUCT_NAME, "GA502"),
},
},
{
.callback = video_detect_force_native,
.ident = "ASUSTeK COMPUTER INC. GA503",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
DMI_MATCH(DMI_PRODUCT_NAME, "GA503"),
},
},
/* /*
* Desktops which falsely report a backlight and which our heuristics * Desktops which falsely report a backlight and which our heuristics
......
...@@ -78,6 +78,7 @@ acpi_evaluate_dsm_typed(acpi_handle handle, const guid_t *guid, u64 rev, ...@@ -78,6 +78,7 @@ acpi_evaluate_dsm_typed(acpi_handle handle, const guid_t *guid, u64 rev,
bool acpi_dev_found(const char *hid); bool acpi_dev_found(const char *hid);
bool acpi_dev_present(const char *hid, const char *uid, s64 hrv); bool acpi_dev_present(const char *hid, const char *uid, s64 hrv);
bool acpi_reduced_hardware(void);
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
...@@ -689,6 +690,20 @@ acpi_dev_get_next_match_dev(struct acpi_device *adev, const char *hid, const cha ...@@ -689,6 +690,20 @@ acpi_dev_get_next_match_dev(struct acpi_device *adev, const char *hid, const cha
struct acpi_device * struct acpi_device *
acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv); acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv);
/**
* for_each_acpi_dev_match - iterate over ACPI devices that matching the criteria
* @adev: pointer to the matching ACPI device, NULL at the end of the loop
* @hid: Hardware ID of the device.
* @uid: Unique ID of the device, pass NULL to not check _UID
* @hrv: Hardware Revision of the device, pass -1 to not check _HRV
*
* The caller is responsible for invoking acpi_dev_put() on the returned device.
*
* FIXME: Due to above requirement there is a window that may invalidate @adev
* and next iteration will use a dangling pointer, e.g. in the case of a
* hotplug event. That said, the caller should ensure that this will never
* happen.
*/
#define for_each_acpi_dev_match(adev, hid, uid, hrv) \ #define for_each_acpi_dev_match(adev, hid, uid, hrv) \
for (adev = acpi_dev_get_first_match_dev(hid, uid, hrv); \ for (adev = acpi_dev_get_first_match_dev(hid, uid, hrv); \
adev; \ adev; \
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#define _CPPC_ACPI_H #define _CPPC_ACPI_H
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/cpufreq.h>
#include <linux/types.h> #include <linux/types.h>
#include <acpi/pcc.h> #include <acpi/pcc.h>
...@@ -132,6 +133,7 @@ struct cppc_cpudata { ...@@ -132,6 +133,7 @@ struct cppc_cpudata {
cpumask_var_t shared_cpu_map; cpumask_var_t shared_cpu_map;
}; };
#ifdef CONFIG_ACPI_CPPC_LIB
extern int cppc_get_desired_perf(int cpunum, u64 *desired_perf); extern int cppc_get_desired_perf(int cpunum, u64 *desired_perf);
extern int cppc_get_perf_ctrs(int cpu, struct cppc_perf_fb_ctrs *perf_fb_ctrs); extern int cppc_get_perf_ctrs(int cpu, struct cppc_perf_fb_ctrs *perf_fb_ctrs);
extern int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls); extern int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls);
...@@ -142,5 +144,43 @@ extern unsigned int cppc_get_transition_latency(int cpu); ...@@ -142,5 +144,43 @@ extern unsigned int cppc_get_transition_latency(int cpu);
extern bool cpc_ffh_supported(void); extern bool cpc_ffh_supported(void);
extern int cpc_read_ffh(int cpunum, struct cpc_reg *reg, u64 *val); extern int cpc_read_ffh(int cpunum, struct cpc_reg *reg, u64 *val);
extern int cpc_write_ffh(int cpunum, struct cpc_reg *reg, u64 val); extern int cpc_write_ffh(int cpunum, struct cpc_reg *reg, u64 val);
#else /* !CONFIG_ACPI_CPPC_LIB */
static inline int cppc_get_desired_perf(int cpunum, u64 *desired_perf)
{
return -ENOTSUPP;
}
static inline int cppc_get_perf_ctrs(int cpu, struct cppc_perf_fb_ctrs *perf_fb_ctrs)
{
return -ENOTSUPP;
}
static inline int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls)
{
return -ENOTSUPP;
}
static inline int cppc_get_perf_caps(int cpu, struct cppc_perf_caps *caps)
{
return -ENOTSUPP;
}
static inline bool acpi_cpc_valid(void)
{
return false;
}
static inline unsigned int cppc_get_transition_latency(int cpu)
{
return CPUFREQ_ETERNAL;
}
static inline bool cpc_ffh_supported(void)
{
return false;
}
static inline int cpc_read_ffh(int cpunum, struct cpc_reg *reg, u64 *val)
{
return -ENOTSUPP;
}
static inline int cpc_write_ffh(int cpunum, struct cpc_reg *reg, u64 val)
{
return -ENOTSUPP;
}
#endif /* !CONFIG_ACPI_CPPC_LIB */
#endif /* _CPPC_ACPI_H*/ #endif /* _CPPC_ACPI_H*/
...@@ -748,6 +748,11 @@ acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv) ...@@ -748,6 +748,11 @@ acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv)
return NULL; return NULL;
} }
static inline bool acpi_reduced_hardware(void)
{
return false;
}
static inline void acpi_dev_put(struct acpi_device *adev) {} static inline void acpi_dev_put(struct acpi_device *adev) {}
static inline bool is_acpi_node(const struct fwnode_handle *fwnode) static inline bool is_acpi_node(const struct fwnode_handle *fwnode)
......
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