Skip to content

Commit 7a8379e

Browse files
committed
ACPICA: Add support for using logical addresses of GPE blocks
The logical address of every GPE block in system memory must be known before passing it to acpi_ev_initialize_gpe_block(), because memory cannot be mapped on the fly from an interrupt handler. Accordingly, the host OS must map every GPE block in system memory upfront and it can store the logical addresses of GPE blocks for future use. If these logical addresses were known to ACPICA, it could use them instead of the corresponding physical addresses of GPE block for GPE register accesses and the memory mapping lookups carried out by acpi_os_read_memory() and acpi_os_write_memory() on every attempt to access a GPE register would not be necessary any more. To allow that to happen, introduce the ACPI_GPE_USE_LOGICAL_ADDRESSES symbol to indicate whether or not the host OS wants ACPICA to use the logical addresses of GPE registers in system memory directly (which is the case if this symbol is defined). Moreover, conditional on whether ACPI_GPE_USE_LOGICAL_ADDRESSES is defined, introduce two new global variables for storing the logical addresses of the FADT GPE blocks 0 and 1, respectively, acpi_gbl_xgpe0_block_logical_address and acpi_gbl_xgpe1_block_logical_address, make acpi_ev_gpe_initialize() pass their values instead of the physical addresses of the GPE blocks in question to acpi_ev_create_gpe_block() and modify acpi_hw_gpe_read() and acpi_hw_gpe_write() to access memory directly via the addresses stored in the struct acpi_gpe_address objects, which are expected to be the logical addresses of GPE registers if ACPI_GPE_USE_LOGICAL_ADDRESSES is defined. With the above changes in place, a host OS wanting ACPICA to access GPE registers directly through their logical addresses needs to define the ACPI_GPE_USE_LOGICAL_ADDRESSES symbol and make sure that the logical addresses of the FADT GPE blocks 0 and 1 are stored in acpi_gbl_xgpe0_block_logical_address and acpi_gbl_xgpe1_block_logical_address, respectively, prior to calling acpi_ev_gpe_initialize(). [If such a host OS also uses acpi_install_gpe_block() to add non-FADT GPE register blocks located in system memory, it must pass their logical addresses instead of their physical addresses to this function.] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 9da8e9a commit 7a8379e

3 files changed

Lines changed: 33 additions & 6 deletions

File tree

drivers/acpi/acpica/acglobal.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ ACPI_GLOBAL(struct acpi_generic_address, acpi_gbl_xpm1a_enable);
4242
ACPI_GLOBAL(struct acpi_generic_address, acpi_gbl_xpm1b_status);
4343
ACPI_GLOBAL(struct acpi_generic_address, acpi_gbl_xpm1b_enable);
4444

45+
#ifdef ACPI_GPE_USE_LOGICAL_ADDRESSES
46+
ACPI_GLOBAL(unsigned long, acpi_gbl_xgpe0_block_logical_address);
47+
ACPI_GLOBAL(unsigned long, acpi_gbl_xgpe1_block_logical_address);
48+
49+
#endif /* ACPI_GPE_USE_LOGICAL_ADDRESSES */
50+
4551
/*
4652
* Handle both ACPI 1.0 and ACPI 2.0+ Integer widths. The integer width is
4753
* determined by the revision of the DSDT: If the DSDT revision is less than

drivers/acpi/acpica/evgpeinit.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ ACPI_MODULE_NAME("evgpeinit")
3232
* kernel boot time as well.
3333
*/
3434

35+
#ifdef ACPI_GPE_USE_LOGICAL_ADDRESSES
36+
#define ACPI_FADT_GPE_BLOCK_ADDRESS(N) \
37+
acpi_gbl_FADT.xgpe##N##_block.space_id == \
38+
ACPI_ADR_SPACE_SYSTEM_MEMORY ? \
39+
(u64)acpi_gbl_xgpe##N##_block_logical_address : \
40+
acpi_gbl_FADT.xgpe##N##_block.address
41+
#else
42+
#define ACPI_FADT_GPE_BLOCK_ADDRESS(N) acpi_gbl_FADT.xgpe##N##_block.address
43+
#endif /* ACPI_GPE_USE_LOGICAL_ADDRESSES */
44+
3545
/*******************************************************************************
3646
*
3747
* FUNCTION: acpi_ev_gpe_initialize
@@ -49,6 +59,7 @@ acpi_status acpi_ev_gpe_initialize(void)
4959
u32 register_count1 = 0;
5060
u32 gpe_number_max = 0;
5161
acpi_status status;
62+
u64 address;
5263

5364
ACPI_FUNCTION_TRACE(ev_gpe_initialize);
5465

@@ -85,8 +96,9 @@ acpi_status acpi_ev_gpe_initialize(void)
8596
* If EITHER the register length OR the block address are zero, then that
8697
* particular block is not supported.
8798
*/
88-
if (acpi_gbl_FADT.gpe0_block_length &&
89-
acpi_gbl_FADT.xgpe0_block.address) {
99+
address = ACPI_FADT_GPE_BLOCK_ADDRESS(0);
100+
101+
if (acpi_gbl_FADT.gpe0_block_length && address) {
90102

91103
/* GPE block 0 exists (has both length and address > 0) */
92104

@@ -97,7 +109,6 @@ acpi_status acpi_ev_gpe_initialize(void)
97109
/* Install GPE Block 0 */
98110

99111
status = acpi_ev_create_gpe_block(acpi_gbl_fadt_gpe_device,
100-
acpi_gbl_FADT.xgpe0_block.
101112
address,
102113
acpi_gbl_FADT.xgpe0_block.
103114
space_id, register_count0, 0,
@@ -110,8 +121,9 @@ acpi_status acpi_ev_gpe_initialize(void)
110121
}
111122
}
112123

113-
if (acpi_gbl_FADT.gpe1_block_length &&
114-
acpi_gbl_FADT.xgpe1_block.address) {
124+
address = ACPI_FADT_GPE_BLOCK_ADDRESS(1);
125+
126+
if (acpi_gbl_FADT.gpe1_block_length && address) {
115127

116128
/* GPE block 1 exists (has both length and address > 0) */
117129

@@ -137,7 +149,6 @@ acpi_status acpi_ev_gpe_initialize(void)
137149

138150
status =
139151
acpi_ev_create_gpe_block(acpi_gbl_fadt_gpe_device,
140-
acpi_gbl_FADT.xgpe1_block.
141152
address,
142153
acpi_gbl_FADT.xgpe1_block.
143154
space_id, register_count1,

drivers/acpi/acpica/hwgpe.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,13 @@ acpi_status acpi_hw_gpe_read(u64 *value, struct acpi_gpe_address *reg)
4646
u32 value32;
4747

4848
if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
49+
#ifdef ACPI_GPE_USE_LOGICAL_ADDRESSES
50+
*value = (u64)ACPI_GET8(reg->address);
51+
return_ACPI_STATUS(AE_OK);
52+
#else
4953
return acpi_os_read_memory((acpi_physical_address)reg->address,
5054
value, ACPI_GPE_REGISTER_WIDTH);
55+
#endif
5156
}
5257

5358
status = acpi_os_read_port((acpi_io_address)reg->address,
@@ -76,8 +81,13 @@ acpi_status acpi_hw_gpe_read(u64 *value, struct acpi_gpe_address *reg)
7681
acpi_status acpi_hw_gpe_write(u64 value, struct acpi_gpe_address *reg)
7782
{
7883
if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
84+
#ifdef ACPI_GPE_USE_LOGICAL_ADDRESSES
85+
ACPI_SET8(reg->address, value);
86+
return_ACPI_STATUS(AE_OK);
87+
#else
7988
return acpi_os_write_memory((acpi_physical_address)reg->address,
8089
value, ACPI_GPE_REGISTER_WIDTH);
90+
#endif
8191
}
8292

8393
return acpi_os_write_port((acpi_io_address)reg->address, (u32)value,

0 commit comments

Comments
 (0)