Skip to content

Commit aa6ec56

Browse files
Erik Schmaussrafaeljw
authored andcommitted
ACPICA: ACPI 6.3: add PCC operation region support for AML interpreter
ACPICA commit a4849944e80f97970e99843f4975850753584a4e This change adds PCC operation region support in the AML interpreter and a default handler for acpiexec. According to the specification, the PCC operation region performs a transaction when the COMD field is written. This allows ASL to write data to other fields before sending the data. In order to accommodate this protocol, a temorary buffer is added to the regionfield object to accumulate writes. If any offset that spans COMD is written, the temporary buffer is sent to the PCC operation region handler to be processed. This change also renames the PCC keyword to platform_comm_channel. Link: acpica/acpica@a4849944 Reviewed-by: Kyle Pelton <kyle.d.pelton@intel.com> Signed-off-by: Erik Schmauss <erik.schmauss@intel.com> Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent aa475a5 commit aa6ec56

File tree

4 files changed

+80
-0
lines changed

4 files changed

+80
-0
lines changed

drivers/acpi/acpica/acobject.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ struct acpi_object_region_field {
239239
union acpi_operand_object *region_obj; /* Containing op_region object */
240240
u8 *resource_buffer; /* resource_template for serial regions/fields */
241241
u16 pin_number_index; /* Index relative to previous Connection/Template */
242+
u8 *internal_pcc_buffer; /* Internal buffer for fields associated with PCC */
242243
};
243244

244245
struct acpi_object_bank_field {

drivers/acpi/acpica/dsfield.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,13 @@ acpi_ds_create_field(union acpi_parse_object *op,
518518
info.region_node = region_node;
519519

520520
status = acpi_ds_get_field_names(&info, walk_state, arg->common.next);
521+
if (info.region_node->object->region.space_id ==
522+
ACPI_ADR_SPACE_PLATFORM_COMM
523+
&& !(region_node->object->field.internal_pcc_buffer =
524+
ACPI_ALLOCATE_ZEROED(info.region_node->object->region.
525+
length))) {
526+
return_ACPI_STATUS(AE_NO_MEMORY);
527+
}
521528
return_ACPI_STATUS(status);
522529
}
523530

drivers/acpi/acpica/exfield.c

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@ const u8 acpi_protocol_lengths[] = {
4141
0xFF /* F - ATTRIB_RAW_PROCESS_BYTES */
4242
};
4343

44+
#define PCC_MASTER_SUBSPACE 3
45+
46+
/*
47+
* The following macros determine a given offset is a COMD field.
48+
* According to the specification, generic subspaces (types 0-2) contains a
49+
* 2-byte COMD field at offset 4 and master subspaces (type 3) contains a 4-byte
50+
* COMD field starting at offset 12.
51+
*/
52+
#define GENERIC_SUBSPACE_COMMAND(a) (4 == a || a == 5)
53+
#define MASTER_SUBSPACE_COMMAND(a) (12 <= a && a <= 15)
54+
4455
/*******************************************************************************
4556
*
4657
* FUNCTION: acpi_ex_get_protocol_buffer_length
@@ -177,6 +188,25 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
177188

178189
status = acpi_ex_read_gpio(obj_desc, buffer);
179190
goto exit;
191+
} else if ((obj_desc->common.type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
192+
(obj_desc->field.region_obj->region.space_id ==
193+
ACPI_ADR_SPACE_PLATFORM_COMM)) {
194+
/*
195+
* Reading from a PCC field unit does not require the handler because
196+
* it only requires reading from the internal_pcc_buffer.
197+
*/
198+
ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
199+
"PCC FieldRead bits %u\n",
200+
obj_desc->field.bit_length));
201+
202+
memcpy(buffer,
203+
obj_desc->field.region_obj->field.internal_pcc_buffer +
204+
obj_desc->field.base_byte_offset,
205+
(acpi_size)ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->field.
206+
bit_length));
207+
208+
*ret_buffer_desc = buffer_desc;
209+
return AE_OK;
180210
}
181211

182212
ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
@@ -229,6 +259,7 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
229259
{
230260
acpi_status status;
231261
u32 buffer_length;
262+
u32 data_length;
232263
void *buffer;
233264

234265
ACPI_FUNCTION_TRACE_PTR(ex_write_data_to_field, obj_desc);
@@ -272,6 +303,43 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
272303
acpi_ex_write_serial_bus(source_desc, obj_desc,
273304
result_desc);
274305
return_ACPI_STATUS(status);
306+
} else if ((obj_desc->common.type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
307+
(obj_desc->field.region_obj->region.space_id ==
308+
ACPI_ADR_SPACE_PLATFORM_COMM)) {
309+
/*
310+
* According to the spec a write to the COMD field will invoke the
311+
* region handler. Otherwise, write to the pcc_internal buffer. This
312+
* implementation will use the offsets specified rather than the name
313+
* of the field. This is considered safer because some firmware tools
314+
* are known to obfiscate named objects.
315+
*/
316+
data_length =
317+
(acpi_size)ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->field.
318+
bit_length);
319+
memcpy(obj_desc->field.region_obj->field.internal_pcc_buffer +
320+
obj_desc->field.base_byte_offset,
321+
source_desc->buffer.pointer, data_length);
322+
if ((obj_desc->field.region_obj->region.address ==
323+
PCC_MASTER_SUBSPACE
324+
&& MASTER_SUBSPACE_COMMAND(obj_desc->field.
325+
base_byte_offset))
326+
|| GENERIC_SUBSPACE_COMMAND(obj_desc->field.
327+
base_byte_offset)) {
328+
329+
/* Perform the write */
330+
331+
ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
332+
"PCC COMD field has been written. Invoking PCC handler now.\n"));
333+
334+
status =
335+
acpi_ex_access_region(obj_desc, 0,
336+
(u64 *)obj_desc->field.
337+
region_obj->field.
338+
internal_pcc_buffer,
339+
ACPI_WRITE);
340+
return_ACPI_STATUS(status);
341+
}
342+
return (AE_OK);
275343
}
276344

277345
/* Get a pointer to the data to be written */

drivers/acpi/acpica/utdelete.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,10 @@ static void acpi_ut_delete_internal_obj(union acpi_operand_object *object)
257257

258258
acpi_ut_delete_object_desc(second_desc);
259259
}
260+
if (object->field.internal_pcc_buffer) {
261+
ACPI_FREE(object->field.internal_pcc_buffer);
262+
}
263+
260264
break;
261265

262266
case ACPI_TYPE_BUFFER_FIELD:

0 commit comments

Comments
 (0)