Skip to content

Commit 2cbd407

Browse files
committed
Merge branches 'acpi-osl', 'acpi-power' and 'acpi-misc'
* acpi-osl: ACPI: Add memory semantics to acpi_os_map_memory() * acpi-power: ACPI: power: Drop name from struct acpi_power_resource ACPI: power: Use acpi_handle_debug() to print debug messages * acpi-misc: ACPI: button: Add DMI quirk for Lenovo Yoga 9 (14INTL5)
4 parents 2fec5b8 + 437b38c + 2bc4eb9 + 1a20d40 commit 2cbd407

File tree

6 files changed

+77
-25
lines changed

6 files changed

+77
-25
lines changed

arch/arm64/include/asm/acpi.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ pgprot_t __acpi_get_mem_attribute(phys_addr_t addr);
5050
void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size);
5151
#define acpi_os_ioremap acpi_os_ioremap
5252

53+
void __iomem *acpi_os_memmap(acpi_physical_address phys, acpi_size size);
54+
#define acpi_os_memmap acpi_os_memmap
55+
5356
typedef u64 phys_cpuid_t;
5457
#define PHYS_CPUID_INVALID INVALID_HWID
5558

arch/arm64/kernel/acpi.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ pgprot_t __acpi_get_mem_attribute(phys_addr_t addr)
273273
return __pgprot(PROT_DEVICE_nGnRnE);
274274
}
275275

276-
void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size)
276+
static void __iomem *__acpi_os_ioremap(acpi_physical_address phys,
277+
acpi_size size, bool memory)
277278
{
278279
efi_memory_desc_t *md, *region = NULL;
279280
pgprot_t prot;
@@ -299,9 +300,11 @@ void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size)
299300
* It is fine for AML to remap regions that are not represented in the
300301
* EFI memory map at all, as it only describes normal memory, and MMIO
301302
* regions that require a virtual mapping to make them accessible to
302-
* the EFI runtime services.
303+
* the EFI runtime services. Determine the region default
304+
* attributes by checking the requested memory semantics.
303305
*/
304-
prot = __pgprot(PROT_DEVICE_nGnRnE);
306+
prot = memory ? __pgprot(PROT_NORMAL_NC) :
307+
__pgprot(PROT_DEVICE_nGnRnE);
305308
if (region) {
306309
switch (region->type) {
307310
case EFI_LOADER_CODE:
@@ -361,6 +364,16 @@ void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size)
361364
return __ioremap(phys, size, prot);
362365
}
363366

367+
void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size)
368+
{
369+
return __acpi_os_ioremap(phys, size, false);
370+
}
371+
372+
void __iomem *acpi_os_memmap(acpi_physical_address phys, acpi_size size)
373+
{
374+
return __acpi_os_ioremap(phys, size, true);
375+
}
376+
364377
/*
365378
* Claim Synchronous External Aborts as a firmware first notification.
366379
*

drivers/acpi/button.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,17 @@ static const struct dmi_system_id dmi_lid_quirks[] = {
7777
},
7878
.driver_data = (void *)(long)ACPI_BUTTON_LID_INIT_DISABLED,
7979
},
80+
{
81+
/*
82+
* Lenovo Yoga 9 14ITL5, initial notification of the LID device
83+
* never happens.
84+
*/
85+
.matches = {
86+
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
87+
DMI_MATCH(DMI_PRODUCT_NAME, "82BG"),
88+
},
89+
.driver_data = (void *)(long)ACPI_BUTTON_LID_INIT_OPEN,
90+
},
8091
{
8192
/*
8293
* Medion Akoya E2215T, notification of the LID device only

drivers/acpi/osl.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@ acpi_map_lookup_virt(void __iomem *virt, acpi_size size)
284284
#define should_use_kmap(pfn) page_is_ram(pfn)
285285
#endif
286286

287-
static void __iomem *acpi_map(acpi_physical_address pg_off, unsigned long pg_sz)
287+
static void __iomem *acpi_map(acpi_physical_address pg_off, unsigned long pg_sz,
288+
bool memory)
288289
{
289290
unsigned long pfn;
290291

@@ -294,7 +295,8 @@ static void __iomem *acpi_map(acpi_physical_address pg_off, unsigned long pg_sz)
294295
return NULL;
295296
return (void __iomem __force *)kmap(pfn_to_page(pfn));
296297
} else
297-
return acpi_os_ioremap(pg_off, pg_sz);
298+
return memory ? acpi_os_memmap(pg_off, pg_sz) :
299+
acpi_os_ioremap(pg_off, pg_sz);
298300
}
299301

300302
static void acpi_unmap(acpi_physical_address pg_off, void __iomem *vaddr)
@@ -309,9 +311,10 @@ static void acpi_unmap(acpi_physical_address pg_off, void __iomem *vaddr)
309311
}
310312

311313
/**
312-
* acpi_os_map_iomem - Get a virtual address for a given physical address range.
314+
* __acpi_os_map_iomem - Get a virtual address for a given physical address range.
313315
* @phys: Start of the physical address range to map.
314316
* @size: Size of the physical address range to map.
317+
* @memory: true if remapping memory, false if IO
315318
*
316319
* Look up the given physical address range in the list of existing ACPI memory
317320
* mappings. If found, get a reference to it and return a pointer to it (its
@@ -321,8 +324,8 @@ static void acpi_unmap(acpi_physical_address pg_off, void __iomem *vaddr)
321324
* During early init (when acpi_permanent_mmap has not been set yet) this
322325
* routine simply calls __acpi_map_table() to get the job done.
323326
*/
324-
void __iomem __ref
325-
*acpi_os_map_iomem(acpi_physical_address phys, acpi_size size)
327+
static void __iomem __ref
328+
*__acpi_os_map_iomem(acpi_physical_address phys, acpi_size size, bool memory)
326329
{
327330
struct acpi_ioremap *map;
328331
void __iomem *virt;
@@ -353,7 +356,7 @@ void __iomem __ref
353356

354357
pg_off = round_down(phys, PAGE_SIZE);
355358
pg_sz = round_up(phys + size, PAGE_SIZE) - pg_off;
356-
virt = acpi_map(phys, size);
359+
virt = acpi_map(phys, size, memory);
357360
if (!virt) {
358361
mutex_unlock(&acpi_ioremap_lock);
359362
kfree(map);
@@ -372,11 +375,17 @@ void __iomem __ref
372375
mutex_unlock(&acpi_ioremap_lock);
373376
return map->virt + (phys - map->phys);
374377
}
378+
379+
void __iomem *__ref
380+
acpi_os_map_iomem(acpi_physical_address phys, acpi_size size)
381+
{
382+
return __acpi_os_map_iomem(phys, size, false);
383+
}
375384
EXPORT_SYMBOL_GPL(acpi_os_map_iomem);
376385

377386
void *__ref acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
378387
{
379-
return (void *)acpi_os_map_iomem(phys, size);
388+
return (void *)__acpi_os_map_iomem(phys, size, true);
380389
}
381390
EXPORT_SYMBOL_GPL(acpi_os_map_memory);
382391

drivers/acpi/power.c

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ struct acpi_power_dependent_device {
4848
struct acpi_power_resource {
4949
struct acpi_device device;
5050
struct list_head list_node;
51-
char *name;
5251
u32 system_level;
5352
u32 order;
5453
unsigned int ref_count;
@@ -70,6 +69,11 @@ static DEFINE_MUTEX(power_resource_list_lock);
7069
Power Resource Management
7170
-------------------------------------------------------------------------- */
7271

72+
static inline const char *resource_dev_name(struct acpi_power_resource *pr)
73+
{
74+
return dev_name(&pr->device.dev);
75+
}
76+
7377
static inline
7478
struct acpi_power_resource *to_power_resource(struct acpi_device *device)
7579
{
@@ -264,7 +268,8 @@ acpi_power_resource_add_dependent(struct acpi_power_resource *resource,
264268

265269
dep->dev = dev;
266270
list_add_tail(&dep->node, &resource->dependents);
267-
dev_dbg(dev, "added power dependency to [%s]\n", resource->name);
271+
dev_dbg(dev, "added power dependency to [%s]\n",
272+
resource_dev_name(resource));
268273

269274
unlock:
270275
mutex_unlock(&resource->resource_lock);
@@ -283,7 +288,7 @@ acpi_power_resource_remove_dependent(struct acpi_power_resource *resource,
283288
list_del(&dep->node);
284289
kfree(dep);
285290
dev_dbg(dev, "removed power dependency to [%s]\n",
286-
resource->name);
291+
resource_dev_name(resource));
287292
break;
288293
}
289294
}
@@ -356,18 +361,19 @@ void acpi_device_power_remove_dependent(struct acpi_device *adev,
356361

357362
static int __acpi_power_on(struct acpi_power_resource *resource)
358363
{
364+
acpi_handle handle = resource->device.handle;
359365
struct acpi_power_dependent_device *dep;
360366
acpi_status status = AE_OK;
361367

362-
status = acpi_evaluate_object(resource->device.handle, "_ON", NULL, NULL);
368+
status = acpi_evaluate_object(handle, "_ON", NULL, NULL);
363369
if (ACPI_FAILURE(status)) {
364370
resource->state = ACPI_POWER_RESOURCE_STATE_UNKNOWN;
365371
return -ENODEV;
366372
}
367373

368374
resource->state = ACPI_POWER_RESOURCE_STATE_ON;
369375

370-
pr_debug("Power resource [%s] turned on\n", resource->name);
376+
acpi_handle_debug(handle, "Power resource turned on\n");
371377

372378
/*
373379
* If there are other dependents on this power resource we need to
@@ -380,7 +386,7 @@ static int __acpi_power_on(struct acpi_power_resource *resource)
380386

381387
list_for_each_entry(dep, &resource->dependents, node) {
382388
dev_dbg(dep->dev, "runtime resuming because [%s] turned on\n",
383-
resource->name);
389+
resource_dev_name(resource));
384390
pm_request_resume(dep->dev);
385391
}
386392

@@ -392,7 +398,8 @@ static int acpi_power_on_unlocked(struct acpi_power_resource *resource)
392398
int result = 0;
393399

394400
if (resource->ref_count++) {
395-
pr_debug("Power resource [%s] already on\n", resource->name);
401+
acpi_handle_debug(resource->device.handle,
402+
"Power resource already on\n");
396403
} else {
397404
result = __acpi_power_on(resource);
398405
if (result)
@@ -413,18 +420,18 @@ static int acpi_power_on(struct acpi_power_resource *resource)
413420

414421
static int __acpi_power_off(struct acpi_power_resource *resource)
415422
{
423+
acpi_handle handle = resource->device.handle;
416424
acpi_status status;
417425

418-
status = acpi_evaluate_object(resource->device.handle, "_OFF",
419-
NULL, NULL);
426+
status = acpi_evaluate_object(handle, "_OFF", NULL, NULL);
420427
if (ACPI_FAILURE(status)) {
421428
resource->state = ACPI_POWER_RESOURCE_STATE_UNKNOWN;
422429
return -ENODEV;
423430
}
424431

425432
resource->state = ACPI_POWER_RESOURCE_STATE_OFF;
426433

427-
pr_debug("Power resource [%s] turned off\n", resource->name);
434+
acpi_handle_debug(handle, "Power resource turned off\n");
428435

429436
return 0;
430437
}
@@ -434,12 +441,14 @@ static int acpi_power_off_unlocked(struct acpi_power_resource *resource)
434441
int result = 0;
435442

436443
if (!resource->ref_count) {
437-
pr_debug("Power resource [%s] already off\n", resource->name);
444+
acpi_handle_debug(resource->device.handle,
445+
"Power resource already off\n");
438446
return 0;
439447
}
440448

441449
if (--resource->ref_count) {
442-
pr_debug("Power resource [%s] still in use\n", resource->name);
450+
acpi_handle_debug(resource->device.handle,
451+
"Power resource still in use\n");
443452
} else {
444453
result = __acpi_power_off(resource);
445454
if (result)
@@ -949,7 +958,6 @@ struct acpi_device *acpi_add_power_resource(acpi_handle handle)
949958
mutex_init(&resource->resource_lock);
950959
INIT_LIST_HEAD(&resource->list_node);
951960
INIT_LIST_HEAD(&resource->dependents);
952-
resource->name = device->pnp.bus_id;
953961
strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME);
954962
strcpy(acpi_device_class(device), ACPI_POWER_CLASS);
955963
device->power.state = ACPI_STATE_UNKNOWN;
@@ -1004,7 +1012,7 @@ void acpi_resume_power_resources(void)
10041012

10051013
if (state == ACPI_POWER_RESOURCE_STATE_OFF
10061014
&& resource->ref_count) {
1007-
dev_dbg(&resource->device.dev, "Turning ON\n");
1015+
acpi_handle_debug(resource->device.handle, "Turning ON\n");
10081016
__acpi_power_on(resource);
10091017
}
10101018

@@ -1034,7 +1042,7 @@ void acpi_turn_off_unused_power_resources(void)
10341042
*/
10351043
if (!resource->ref_count &&
10361044
resource->state != ACPI_POWER_RESOURCE_STATE_OFF) {
1037-
dev_dbg(&resource->device.dev, "Turning OFF\n");
1045+
acpi_handle_debug(resource->device.handle, "Turning OFF\n");
10381046
__acpi_power_off(resource);
10391047
}
10401048

include/acpi/acpi_io.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys,
1414
}
1515
#endif
1616

17+
#ifndef acpi_os_memmap
18+
static inline void __iomem *acpi_os_memmap(acpi_physical_address phys,
19+
acpi_size size)
20+
{
21+
return ioremap_cache(phys, size);
22+
}
23+
#endif
24+
1725
extern bool acpi_permanent_mmap;
1826

1927
void __iomem __ref

0 commit comments

Comments
 (0)