Skip to content

Commit aad659e

Browse files
committed
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
4 parents 0b22125 + 2bc6262 + 2dfbacc + e7b07d3 commit aad659e

7 files changed

Lines changed: 132 additions & 29 deletions

File tree

drivers/acpi/acpi_video.c

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2182,6 +2182,30 @@ static bool dmi_is_desktop(void)
21822182
return false;
21832183
}
21842184

2185+
/*
2186+
* We're seeing a lot of bogus backlight interfaces on newer machines
2187+
* without a LCD such as desktops, servers and HDMI sticks. Checking the
2188+
* lcd flag fixes this, enable this by default on any machines which are:
2189+
* 1. Win8 ready (where we also prefer the native backlight driver, so
2190+
* normally the acpi_video code should not register there anyways); *and*
2191+
* 2.1 Report a desktop/server DMI chassis-type, or
2192+
* 2.2 Are an ACPI-reduced-hardware platform (and thus won't use the EC for
2193+
backlight control)
2194+
*/
2195+
static bool should_check_lcd_flag(void)
2196+
{
2197+
if (!acpi_osi_is_win8())
2198+
return false;
2199+
2200+
if (dmi_is_desktop())
2201+
return true;
2202+
2203+
if (acpi_reduced_hardware())
2204+
return true;
2205+
2206+
return false;
2207+
}
2208+
21852209
int acpi_video_register(void)
21862210
{
21872211
int ret = 0;
@@ -2195,19 +2219,8 @@ int acpi_video_register(void)
21952219
goto leave;
21962220
}
21972221

2198-
/*
2199-
* We're seeing a lot of bogus backlight interfaces on newer machines
2200-
* without a LCD such as desktops, servers and HDMI sticks. Checking
2201-
* the lcd flag fixes this, so enable this on any machines which are
2202-
* win8 ready (where we also prefer the native backlight driver, so
2203-
* normally the acpi_video code should not register there anyways).
2204-
*/
2205-
if (only_lcd == -1) {
2206-
if (dmi_is_desktop() && acpi_osi_is_win8())
2207-
only_lcd = true;
2208-
else
2209-
only_lcd = false;
2210-
}
2222+
if (only_lcd == -1)
2223+
only_lcd = should_check_lcd_flag();
22112224

22122225
dmi_check_system(video_dmi_table);
22132226

drivers/acpi/cppc_acpi.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333

3434
#define pr_fmt(fmt) "ACPI CPPC: " fmt
3535

36-
#include <linux/cpufreq.h>
3736
#include <linux/delay.h>
3837
#include <linux/iopoll.h>
3938
#include <linux/ktime.h>
@@ -119,23 +118,15 @@ static DEFINE_PER_CPU(struct cpc_desc *, cpc_desc_ptr);
119118
*/
120119
#define NUM_RETRIES 500ULL
121120

122-
struct cppc_attr {
123-
struct attribute attr;
124-
ssize_t (*show)(struct kobject *kobj,
125-
struct attribute *attr, char *buf);
126-
ssize_t (*store)(struct kobject *kobj,
127-
struct attribute *attr, const char *c, ssize_t count);
128-
};
129-
130121
#define define_one_cppc_ro(_name) \
131-
static struct cppc_attr _name = \
122+
static struct kobj_attribute _name = \
132123
__ATTR(_name, 0444, show_##_name, NULL)
133124

134125
#define to_cpc_desc(a) container_of(a, struct cpc_desc, kobj)
135126

136127
#define show_cppc_data(access_fn, struct_name, member_name) \
137128
static ssize_t show_##member_name(struct kobject *kobj, \
138-
struct attribute *attr, char *buf) \
129+
struct kobj_attribute *attr, char *buf) \
139130
{ \
140131
struct cpc_desc *cpc_ptr = to_cpc_desc(kobj); \
141132
struct struct_name st_name = {0}; \
@@ -161,7 +152,7 @@ show_cppc_data(cppc_get_perf_ctrs, cppc_perf_fb_ctrs, reference_perf);
161152
show_cppc_data(cppc_get_perf_ctrs, cppc_perf_fb_ctrs, wraparound_time);
162153

163154
static ssize_t show_feedback_ctrs(struct kobject *kobj,
164-
struct attribute *attr, char *buf)
155+
struct kobj_attribute *attr, char *buf)
165156
{
166157
struct cpc_desc *cpc_ptr = to_cpc_desc(kobj);
167158
struct cppc_perf_fb_ctrs fb_ctrs = {0};

drivers/acpi/utils.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ static int acpi_dev_match_cb(struct device *dev, const void *data)
811811
* Note that if the device is pluggable, it may since have disappeared.
812812
*
813813
* Note that unlike acpi_dev_found() this function checks the status
814-
* of the device. So for devices which are present in the dsdt, but
814+
* of the device. So for devices which are present in the DSDT, but
815815
* which are disabled (their _STA callback returns 0) this function
816816
* will return false.
817817
*
@@ -838,15 +838,19 @@ EXPORT_SYMBOL(acpi_dev_present);
838838

839839
/**
840840
* acpi_dev_get_next_match_dev - Return the next match of ACPI device
841-
* @adev: Pointer to the previous acpi_device matching this @hid, @uid and @hrv
841+
* @adev: Pointer to the previous ACPI device matching this @hid, @uid and @hrv
842842
* @hid: Hardware ID of the device.
843843
* @uid: Unique ID of the device, pass NULL to not check _UID
844844
* @hrv: Hardware Revision of the device, pass -1 to not check _HRV
845845
*
846846
* Return the next match of ACPI device if another matching device was present
847847
* at the moment of invocation, or NULL otherwise.
848848
*
849-
* The caller is responsible to call put_device() on the returned device.
849+
* FIXME: The function does not tolerate the sudden disappearance of @adev, e.g.
850+
* in the case of a hotplug event. That said, the caller should ensure that
851+
* this will never happen.
852+
*
853+
* The caller is responsible for invoking acpi_dev_put() on the returned device.
850854
*
851855
* See additional information in acpi_dev_present() as well.
852856
*/
@@ -875,7 +879,7 @@ EXPORT_SYMBOL(acpi_dev_get_next_match_dev);
875879
* Return the first match of ACPI device if a matching device was present
876880
* at the moment of invocation, or NULL otherwise.
877881
*
878-
* The caller is responsible to call put_device() on the returned device.
882+
* The caller is responsible for invoking acpi_dev_put() on the returned device.
879883
*
880884
* See additional information in acpi_dev_present() as well.
881885
*/
@@ -886,6 +890,17 @@ acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv)
886890
}
887891
EXPORT_SYMBOL(acpi_dev_get_first_match_dev);
888892

893+
/**
894+
* acpi_reduced_hardware - Return if this is an ACPI-reduced-hw machine
895+
*
896+
* Return true when running on an ACPI-reduced-hw machine, false otherwise.
897+
*/
898+
bool acpi_reduced_hardware(void)
899+
{
900+
return acpi_gbl_reduced_hardware;
901+
}
902+
EXPORT_SYMBOL_GPL(acpi_reduced_hardware);
903+
889904
/*
890905
* acpi_backlight= handling, this is done here rather then in video_detect.c
891906
* because __setup cannot be used in modules.

drivers/acpi/video_detect.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,30 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
385385
DMI_MATCH(DMI_BOARD_NAME, "BA51_MV"),
386386
},
387387
},
388+
{
389+
.callback = video_detect_force_native,
390+
.ident = "ASUSTeK COMPUTER INC. GA401",
391+
.matches = {
392+
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
393+
DMI_MATCH(DMI_PRODUCT_NAME, "GA401"),
394+
},
395+
},
396+
{
397+
.callback = video_detect_force_native,
398+
.ident = "ASUSTeK COMPUTER INC. GA502",
399+
.matches = {
400+
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
401+
DMI_MATCH(DMI_PRODUCT_NAME, "GA502"),
402+
},
403+
},
404+
{
405+
.callback = video_detect_force_native,
406+
.ident = "ASUSTeK COMPUTER INC. GA503",
407+
.matches = {
408+
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
409+
DMI_MATCH(DMI_PRODUCT_NAME, "GA503"),
410+
},
411+
},
388412

389413
/*
390414
* Desktops which falsely report a backlight and which our heuristics

include/acpi/acpi_bus.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ acpi_evaluate_dsm_typed(acpi_handle handle, const guid_t *guid, u64 rev,
7878

7979
bool acpi_dev_found(const char *hid);
8080
bool acpi_dev_present(const char *hid, const char *uid, s64 hrv);
81+
bool acpi_reduced_hardware(void);
8182

8283
#ifdef CONFIG_ACPI
8384

@@ -689,6 +690,20 @@ acpi_dev_get_next_match_dev(struct acpi_device *adev, const char *hid, const cha
689690
struct acpi_device *
690691
acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv);
691692

693+
/**
694+
* for_each_acpi_dev_match - iterate over ACPI devices that matching the criteria
695+
* @adev: pointer to the matching ACPI device, NULL at the end of the loop
696+
* @hid: Hardware ID of the device.
697+
* @uid: Unique ID of the device, pass NULL to not check _UID
698+
* @hrv: Hardware Revision of the device, pass -1 to not check _HRV
699+
*
700+
* The caller is responsible for invoking acpi_dev_put() on the returned device.
701+
*
702+
* FIXME: Due to above requirement there is a window that may invalidate @adev
703+
* and next iteration will use a dangling pointer, e.g. in the case of a
704+
* hotplug event. That said, the caller should ensure that this will never
705+
* happen.
706+
*/
692707
#define for_each_acpi_dev_match(adev, hid, uid, hrv) \
693708
for (adev = acpi_dev_get_first_match_dev(hid, uid, hrv); \
694709
adev; \

include/acpi/cppc_acpi.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define _CPPC_ACPI_H
1212

1313
#include <linux/acpi.h>
14+
#include <linux/cpufreq.h>
1415
#include <linux/types.h>
1516

1617
#include <acpi/pcc.h>
@@ -132,6 +133,7 @@ struct cppc_cpudata {
132133
cpumask_var_t shared_cpu_map;
133134
};
134135

136+
#ifdef CONFIG_ACPI_CPPC_LIB
135137
extern int cppc_get_desired_perf(int cpunum, u64 *desired_perf);
136138
extern int cppc_get_perf_ctrs(int cpu, struct cppc_perf_fb_ctrs *perf_fb_ctrs);
137139
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);
142144
extern bool cpc_ffh_supported(void);
143145
extern int cpc_read_ffh(int cpunum, struct cpc_reg *reg, u64 *val);
144146
extern int cpc_write_ffh(int cpunum, struct cpc_reg *reg, u64 val);
147+
#else /* !CONFIG_ACPI_CPPC_LIB */
148+
static inline int cppc_get_desired_perf(int cpunum, u64 *desired_perf)
149+
{
150+
return -ENOTSUPP;
151+
}
152+
static inline int cppc_get_perf_ctrs(int cpu, struct cppc_perf_fb_ctrs *perf_fb_ctrs)
153+
{
154+
return -ENOTSUPP;
155+
}
156+
static inline int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls)
157+
{
158+
return -ENOTSUPP;
159+
}
160+
static inline int cppc_get_perf_caps(int cpu, struct cppc_perf_caps *caps)
161+
{
162+
return -ENOTSUPP;
163+
}
164+
static inline bool acpi_cpc_valid(void)
165+
{
166+
return false;
167+
}
168+
static inline unsigned int cppc_get_transition_latency(int cpu)
169+
{
170+
return CPUFREQ_ETERNAL;
171+
}
172+
static inline bool cpc_ffh_supported(void)
173+
{
174+
return false;
175+
}
176+
static inline int cpc_read_ffh(int cpunum, struct cpc_reg *reg, u64 *val)
177+
{
178+
return -ENOTSUPP;
179+
}
180+
static inline int cpc_write_ffh(int cpunum, struct cpc_reg *reg, u64 val)
181+
{
182+
return -ENOTSUPP;
183+
}
184+
#endif /* !CONFIG_ACPI_CPPC_LIB */
145185

146186
#endif /* _CPPC_ACPI_H*/

include/linux/acpi.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,11 @@ acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv)
748748
return NULL;
749749
}
750750

751+
static inline bool acpi_reduced_hardware(void)
752+
{
753+
return false;
754+
}
755+
751756
static inline void acpi_dev_put(struct acpi_device *adev) {}
752757

753758
static inline bool is_acpi_node(const struct fwnode_handle *fwnode)

0 commit comments

Comments
 (0)