aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci-acpi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/pci-acpi.c')
-rw-r--r--drivers/pci/pci-acpi.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 736bb248008e..3582512e7226 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -24,15 +24,14 @@ struct acpi_osc_data {
24 acpi_handle handle; 24 acpi_handle handle;
25 u32 support_set; 25 u32 support_set;
26 u32 control_set; 26 u32 control_set;
27 u32 control_query;
27 int is_queried; 28 int is_queried;
28 u32 query_result;
29 struct list_head sibiling; 29 struct list_head sibiling;
30}; 30};
31static LIST_HEAD(acpi_osc_data_list); 31static LIST_HEAD(acpi_osc_data_list);
32 32
33struct acpi_osc_args { 33struct acpi_osc_args {
34 u32 capbuf[3]; 34 u32 capbuf[3];
35 u32 query_result;
36}; 35};
37 36
38static DEFINE_MUTEX(pci_acpi_lock); 37static DEFINE_MUTEX(pci_acpi_lock);
@@ -58,7 +57,7 @@ static u8 OSC_UUID[16] = {0x5B, 0x4D, 0xDB, 0x33, 0xF7, 0x1F, 0x1C, 0x40,
58 0x96, 0x57, 0x74, 0x41, 0xC0, 0x3D, 0xD7, 0x66}; 57 0x96, 0x57, 0x74, 0x41, 0xC0, 0x3D, 0xD7, 0x66};
59 58
60static acpi_status acpi_run_osc(acpi_handle handle, 59static acpi_status acpi_run_osc(acpi_handle handle,
61 struct acpi_osc_args *osc_args) 60 struct acpi_osc_args *osc_args, u32 *retval)
62{ 61{
63 acpi_status status; 62 acpi_status status;
64 struct acpi_object_list input; 63 struct acpi_object_list input;
@@ -114,9 +113,7 @@ static acpi_status acpi_run_osc(acpi_handle handle,
114 goto out_kfree; 113 goto out_kfree;
115 } 114 }
116out_success: 115out_success:
117 if (flags & OSC_QUERY_ENABLE) 116 *retval = *((u32 *)(out_obj->buffer.pointer + 8));
118 osc_args->query_result =
119 *((u32 *)(out_obj->buffer.pointer + 8));
120 status = AE_OK; 117 status = AE_OK;
121 118
122out_kfree: 119out_kfree:
@@ -127,7 +124,7 @@ out_kfree:
127static acpi_status __acpi_query_osc(u32 flags, struct acpi_osc_data *osc_data) 124static acpi_status __acpi_query_osc(u32 flags, struct acpi_osc_data *osc_data)
128{ 125{
129 acpi_status status; 126 acpi_status status;
130 u32 support_set; 127 u32 support_set, result;
131 struct acpi_osc_args osc_args; 128 struct acpi_osc_args osc_args;
132 129
133 /* do _OSC query for all possible controls */ 130 /* do _OSC query for all possible controls */
@@ -136,10 +133,10 @@ static acpi_status __acpi_query_osc(u32 flags, struct acpi_osc_data *osc_data)
136 osc_args.capbuf[OSC_SUPPORT_TYPE] = support_set; 133 osc_args.capbuf[OSC_SUPPORT_TYPE] = support_set;
137 osc_args.capbuf[OSC_CONTROL_TYPE] = OSC_CONTROL_MASKS; 134 osc_args.capbuf[OSC_CONTROL_TYPE] = OSC_CONTROL_MASKS;
138 135
139 status = acpi_run_osc(osc_data->handle, &osc_args); 136 status = acpi_run_osc(osc_data->handle, &osc_args, &result);
140 if (ACPI_SUCCESS(status)) { 137 if (ACPI_SUCCESS(status)) {
141 osc_data->support_set = support_set; 138 osc_data->support_set = support_set;
142 osc_data->query_result = osc_args.query_result; 139 osc_data->control_query = result;
143 osc_data->is_queried = 1; 140 osc_data->is_queried = 1;
144 } 141 }
145 142
@@ -187,7 +184,7 @@ out:
187acpi_status pci_osc_control_set(acpi_handle handle, u32 flags) 184acpi_status pci_osc_control_set(acpi_handle handle, u32 flags)
188{ 185{
189 acpi_status status; 186 acpi_status status;
190 u32 ctrlset, control_set; 187 u32 control_req, control_set, result;
191 acpi_handle tmp; 188 acpi_handle tmp;
192 struct acpi_osc_data *osc_data; 189 struct acpi_osc_data *osc_data;
193 struct acpi_osc_args osc_args; 190 struct acpi_osc_args osc_args;
@@ -204,14 +201,14 @@ acpi_status pci_osc_control_set(acpi_handle handle, u32 flags)
204 goto out; 201 goto out;
205 } 202 }
206 203
207 ctrlset = (flags & OSC_CONTROL_MASKS); 204 control_req = (flags & OSC_CONTROL_MASKS);
208 if (!ctrlset) { 205 if (!control_req) {
209 status = AE_TYPE; 206 status = AE_TYPE;
210 goto out; 207 goto out;
211 } 208 }
212 209
213 /* No need to evaluate _OSC if the control was already granted. */ 210 /* No need to evaluate _OSC if the control was already granted. */
214 if ((osc_data->control_set & ctrlset) == ctrlset) 211 if ((osc_data->control_set & control_req) == control_req)
215 goto out; 212 goto out;
216 213
217 if (!osc_data->is_queried) { 214 if (!osc_data->is_queried) {
@@ -220,18 +217,18 @@ acpi_status pci_osc_control_set(acpi_handle handle, u32 flags)
220 goto out; 217 goto out;
221 } 218 }
222 219
223 if ((osc_data->query_result & ctrlset) != ctrlset) { 220 if ((osc_data->control_query & control_req) != control_req) {
224 status = AE_SUPPORT; 221 status = AE_SUPPORT;
225 goto out; 222 goto out;
226 } 223 }
227 224
228 control_set = osc_data->control_set | ctrlset; 225 control_set = osc_data->control_set | control_req;
229 osc_args.capbuf[OSC_QUERY_TYPE] = 0; 226 osc_args.capbuf[OSC_QUERY_TYPE] = 0;
230 osc_args.capbuf[OSC_SUPPORT_TYPE] = osc_data->support_set; 227 osc_args.capbuf[OSC_SUPPORT_TYPE] = osc_data->support_set;
231 osc_args.capbuf[OSC_CONTROL_TYPE] = control_set; 228 osc_args.capbuf[OSC_CONTROL_TYPE] = control_set;
232 status = acpi_run_osc(handle, &osc_args); 229 status = acpi_run_osc(handle, &osc_args, &result);
233 if (ACPI_SUCCESS(status)) 230 if (ACPI_SUCCESS(status))
234 osc_data->control_set = control_set; 231 osc_data->control_set = result;
235out: 232out:
236 mutex_unlock(&pci_acpi_lock); 233 mutex_unlock(&pci_acpi_lock);
237 return status; 234 return status;