Skip to content

Commit d61991d

Browse files
committed
Merge branches 'acpi-resource' and 'acpi-pm'
Merge ACPI resource management and ACPI power management chages for 6.1-rc1: - Filter out non-memory resources in is_memory(), add a helper function to find all memory type resources of an ACPI device object and use that function in 3 places (Heikki Krogerus). - Add IRQ override quirks for Asus Vivobook K3402ZA/K3502ZA and ASUS model S5402ZA (Tamim Khan, Kellen Renshaw). - Fix acpi_dev_state_d0() kerneldoc (Sakari Ailus). - Fix up suspend-to-idle support on ASUS Rembrandt laptops (Mario Limonciello). * acpi-resource: ACPI: resource: Add ASUS model S5402ZA to quirks usb: typec: intel_pmc_mux: Use the helper acpi_dev_get_memory_resources() ACPI: resource: Skip IRQ override on Asus Vivobook K3402ZA/K3502ZA ACPI: LPSS: Use the helper acpi_dev_get_memory_resources() ACPI: APD: Use the helper acpi_dev_get_memory_resources() ACPI: resource: Add helper function acpi_dev_get_memory_resources() ACPI: resource: Filter out the non memory resources in is_memory() * acpi-pm: ACPI: x86: s2idle: Add another ID to s2idle_dmi_table ACPI: x86: s2idle: Fix a NULL pointer dereference ACPI: x86: s2idle: Add a quirk for ASUSTeK COMPUTER INC. ROG Flow X13 ACPI: x86: s2idle: Add a quirk for Lenovo Slim 7 Pro 14ARH7 ACPI: x86: s2idle: Add a quirk for ASUS ROG Zephyrus G14 ACPI: x86: s2idle: Add a quirk for ASUS TUF Gaming A17 FA707RE ACPI: x86: s2idle: Add module parameter to prefer Microsoft GUID ACPI: x86: s2idle: If a new AMD _HID is missing assume Rembrandt ACPI: x86: s2idle: Move _HID handling for AMD systems into structures ACPI: PM: Fix acpi_dev_state_d0() kerneldoc
3 parents 80487a3 + 6e5cbe7 + 54bd1e5 commit d61991d

File tree

7 files changed

+174
-51
lines changed

7 files changed

+174
-51
lines changed

drivers/acpi/acpi_apd.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,6 @@ static int acpi_apd_setup(struct apd_private_data *pdata)
6060
}
6161

6262
#ifdef CONFIG_X86_AMD_PLATFORM_DEVICE
63-
static int misc_check_res(struct acpi_resource *ares, void *data)
64-
{
65-
struct resource res;
66-
67-
return !acpi_dev_resource_memory(ares, &res);
68-
}
6963

7064
static int fch_misc_setup(struct apd_private_data *pdata)
7165
{
@@ -82,8 +76,7 @@ static int fch_misc_setup(struct apd_private_data *pdata)
8276
return -ENOMEM;
8377

8478
INIT_LIST_HEAD(&resource_list);
85-
ret = acpi_dev_get_resources(adev, &resource_list, misc_check_res,
86-
NULL);
79+
ret = acpi_dev_get_memory_resources(adev, &resource_list);
8780
if (ret < 0)
8881
return -ENOENT;
8982

drivers/acpi/acpi_lpss.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -392,13 +392,6 @@ static const struct acpi_device_id acpi_lpss_device_ids[] = {
392392

393393
#ifdef CONFIG_X86_INTEL_LPSS
394394

395-
static int is_memory(struct acpi_resource *res, void *not_used)
396-
{
397-
struct resource r;
398-
399-
return !acpi_dev_resource_memory(res, &r);
400-
}
401-
402395
/* LPSS main clock device. */
403396
static struct platform_device *lpss_clk_dev;
404397

@@ -659,7 +652,7 @@ static int acpi_lpss_create_device(struct acpi_device *adev,
659652
return -ENOMEM;
660653

661654
INIT_LIST_HEAD(&resource_list);
662-
ret = acpi_dev_get_resources(adev, &resource_list, is_memory, NULL);
655+
ret = acpi_dev_get_memory_resources(adev, &resource_list);
663656
if (ret < 0)
664657
goto err_out;
665658

drivers/acpi/device_pm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1466,7 +1466,7 @@ EXPORT_SYMBOL_GPL(acpi_storage_d3);
14661466
* not valid to ask for the ACPI power state of the device in that time frame.
14671467
*
14681468
* This function is intended to be used in a driver's probe or remove
1469-
* function. See Documentation/firmware-guide/acpi/low-power-probe.rst for
1469+
* function. See Documentation/firmware-guide/acpi/non-d0-probe.rst for
14701470
* more information.
14711471
*/
14721472
bool acpi_dev_state_d0(struct device *dev)

drivers/acpi/resource.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,31 @@ static const struct dmi_system_id medion_laptop[] = {
399399
{ }
400400
};
401401

402+
static const struct dmi_system_id asus_laptop[] = {
403+
{
404+
.ident = "Asus Vivobook K3402ZA",
405+
.matches = {
406+
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
407+
DMI_MATCH(DMI_BOARD_NAME, "K3402ZA"),
408+
},
409+
},
410+
{
411+
.ident = "Asus Vivobook K3502ZA",
412+
.matches = {
413+
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
414+
DMI_MATCH(DMI_BOARD_NAME, "K3502ZA"),
415+
},
416+
},
417+
{
418+
.ident = "Asus Vivobook S5402ZA",
419+
.matches = {
420+
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
421+
DMI_MATCH(DMI_BOARD_NAME, "S5402ZA"),
422+
},
423+
},
424+
{ }
425+
};
426+
402427
struct irq_override_cmp {
403428
const struct dmi_system_id *system;
404429
unsigned char irq;
@@ -409,6 +434,7 @@ struct irq_override_cmp {
409434

410435
static const struct irq_override_cmp skip_override_table[] = {
411436
{ medion_laptop, 1, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 0 },
437+
{ asus_laptop, 1, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 0 },
412438
};
413439

414440
static bool acpi_dev_irq_override(u32 gsi, u8 triggering, u8 polarity,
@@ -690,6 +716,9 @@ static int is_memory(struct acpi_resource *ares, void *not_used)
690716

691717
memset(&win, 0, sizeof(win));
692718

719+
if (acpi_dev_filter_resource_type(ares, IORESOURCE_MEM))
720+
return 1;
721+
693722
return !(acpi_dev_resource_memory(ares, res)
694723
|| acpi_dev_resource_address_space(ares, &win)
695724
|| acpi_dev_resource_ext_address_space(ares, &win));
@@ -718,6 +747,23 @@ int acpi_dev_get_dma_resources(struct acpi_device *adev, struct list_head *list)
718747
}
719748
EXPORT_SYMBOL_GPL(acpi_dev_get_dma_resources);
720749

750+
/**
751+
* acpi_dev_get_memory_resources - Get current memory resources of a device.
752+
* @adev: ACPI device node to get the resources for.
753+
* @list: Head of the resultant list of resources (must be empty).
754+
*
755+
* This is a helper function that locates all memory type resources of @adev
756+
* with acpi_dev_get_resources().
757+
*
758+
* The number of resources in the output list is returned on success, an error
759+
* code reflecting the error condition is returned otherwise.
760+
*/
761+
int acpi_dev_get_memory_resources(struct acpi_device *adev, struct list_head *list)
762+
{
763+
return acpi_dev_get_resources(adev, list, is_memory, NULL);
764+
}
765+
EXPORT_SYMBOL_GPL(acpi_dev_get_memory_resources);
766+
721767
/**
722768
* acpi_dev_filter_resource_type - Filter ACPI resource according to resource
723769
* types

drivers/acpi/x86/s2idle.c

Lines changed: 123 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include <linux/acpi.h>
1919
#include <linux/device.h>
20+
#include <linux/dmi.h>
2021
#include <linux/suspend.h>
2122

2223
#include "../sleep.h"
@@ -27,6 +28,10 @@ static bool sleep_no_lps0 __read_mostly;
2728
module_param(sleep_no_lps0, bool, 0644);
2829
MODULE_PARM_DESC(sleep_no_lps0, "Do not use the special LPS0 device interface");
2930

31+
static bool prefer_microsoft_dsm_guid __read_mostly;
32+
module_param(prefer_microsoft_dsm_guid, bool, 0644);
33+
MODULE_PARM_DESC(prefer_microsoft_dsm_guid, "Prefer using Microsoft GUID in LPS0 device _DSM evaluation");
34+
3035
static const struct acpi_device_id lps0_device_ids[] = {
3136
{"PNP0D80", },
3237
{"", },
@@ -363,48 +368,141 @@ static int validate_dsm(acpi_handle handle, const char *uuid, int rev, guid_t *d
363368
return ret;
364369
}
365370

371+
struct amd_lps0_hid_device_data {
372+
const unsigned int rev_id;
373+
const bool check_off_by_one;
374+
const bool prefer_amd_guid;
375+
};
376+
377+
static const struct amd_lps0_hid_device_data amd_picasso = {
378+
.rev_id = 0,
379+
.check_off_by_one = true,
380+
.prefer_amd_guid = false,
381+
};
382+
383+
static const struct amd_lps0_hid_device_data amd_cezanne = {
384+
.rev_id = 0,
385+
.check_off_by_one = false,
386+
.prefer_amd_guid = false,
387+
};
388+
389+
static const struct amd_lps0_hid_device_data amd_rembrandt = {
390+
.rev_id = 2,
391+
.check_off_by_one = false,
392+
.prefer_amd_guid = true,
393+
};
394+
395+
static const struct acpi_device_id amd_hid_ids[] = {
396+
{"AMD0004", (kernel_ulong_t)&amd_picasso, },
397+
{"AMD0005", (kernel_ulong_t)&amd_picasso, },
398+
{"AMDI0005", (kernel_ulong_t)&amd_picasso, },
399+
{"AMDI0006", (kernel_ulong_t)&amd_cezanne, },
400+
{"AMDI0007", (kernel_ulong_t)&amd_rembrandt, },
401+
{}
402+
};
403+
404+
static int lps0_prefer_microsoft(const struct dmi_system_id *id)
405+
{
406+
pr_debug("Preferring Microsoft GUID.\n");
407+
prefer_microsoft_dsm_guid = true;
408+
return 0;
409+
}
410+
411+
static const struct dmi_system_id s2idle_dmi_table[] __initconst = {
412+
{
413+
/*
414+
* ASUS TUF Gaming A17 FA707RE
415+
* https://bugzilla.kernel.org/show_bug.cgi?id=216101
416+
*/
417+
.callback = lps0_prefer_microsoft,
418+
.matches = {
419+
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
420+
DMI_MATCH(DMI_PRODUCT_NAME, "ASUS TUF Gaming A17"),
421+
},
422+
},
423+
{
424+
/* ASUS ROG Zephyrus G14 (2022) */
425+
.callback = lps0_prefer_microsoft,
426+
.matches = {
427+
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
428+
DMI_MATCH(DMI_PRODUCT_NAME, "ROG Zephyrus G14 GA402"),
429+
},
430+
},
431+
{
432+
/*
433+
* Lenovo Yoga Slim 7 Pro X 14ARH7
434+
* https://bugzilla.kernel.org/show_bug.cgi?id=216473 : 82V2
435+
* https://bugzilla.kernel.org/show_bug.cgi?id=216438 : 82TL
436+
*/
437+
.callback = lps0_prefer_microsoft,
438+
.matches = {
439+
DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"),
440+
DMI_MATCH(DMI_PRODUCT_NAME, "82"),
441+
},
442+
},
443+
{
444+
/*
445+
* ASUSTeK COMPUTER INC. ROG Flow X13 GV301RE_GV301RE
446+
* https://gitlab.freedesktop.org/drm/amd/-/issues/2148
447+
*/
448+
.callback = lps0_prefer_microsoft,
449+
.matches = {
450+
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
451+
DMI_MATCH(DMI_PRODUCT_NAME, "ROG Flow X13 GV301"),
452+
},
453+
},
454+
{
455+
/*
456+
* ASUSTeK COMPUTER INC. ROG Flow X16 GV601RW_GV601RW
457+
* https://gitlab.freedesktop.org/drm/amd/-/issues/2148
458+
*/
459+
.callback = lps0_prefer_microsoft,
460+
.matches = {
461+
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
462+
DMI_MATCH(DMI_PRODUCT_NAME, "ROG Flow X16 GV601"),
463+
},
464+
},
465+
{}
466+
};
467+
366468
static int lps0_device_attach(struct acpi_device *adev,
367469
const struct acpi_device_id *not_used)
368470
{
369471
if (lps0_device_handle)
370472
return 0;
371473

474+
lps0_dsm_func_mask_microsoft = validate_dsm(adev->handle,
475+
ACPI_LPS0_DSM_UUID_MICROSOFT, 0,
476+
&lps0_dsm_guid_microsoft);
372477
if (acpi_s2idle_vendor_amd()) {
373-
/* AMD0004, AMD0005, AMDI0005:
374-
* - Should use rev_id 0x0
375-
* - function mask > 0x3: Should use AMD method, but has off by one bug
376-
* - function mask = 0x3: Should use Microsoft method
377-
* AMDI0006:
378-
* - should use rev_id 0x0
379-
* - function mask = 0x3: Should use Microsoft method
380-
* AMDI0007:
381-
* - Should use rev_id 0x2
382-
* - Should only use AMD method
383-
*/
384-
const char *hid = acpi_device_hid(adev);
385-
rev_id = strcmp(hid, "AMDI0007") ? 0 : 2;
478+
static const struct acpi_device_id *dev_id;
479+
const struct amd_lps0_hid_device_data *data;
480+
481+
for (dev_id = &amd_hid_ids[0]; dev_id->id[0]; dev_id++)
482+
if (acpi_dev_hid_uid_match(adev, dev_id->id, NULL))
483+
break;
484+
if (dev_id->id[0])
485+
data = (const struct amd_lps0_hid_device_data *) dev_id->driver_data;
486+
else
487+
data = &amd_rembrandt;
488+
rev_id = data->rev_id;
386489
lps0_dsm_func_mask = validate_dsm(adev->handle,
387490
ACPI_LPS0_DSM_UUID_AMD, rev_id, &lps0_dsm_guid);
388-
lps0_dsm_func_mask_microsoft = validate_dsm(adev->handle,
389-
ACPI_LPS0_DSM_UUID_MICROSOFT, 0,
390-
&lps0_dsm_guid_microsoft);
391-
if (lps0_dsm_func_mask > 0x3 && (!strcmp(hid, "AMD0004") ||
392-
!strcmp(hid, "AMD0005") ||
393-
!strcmp(hid, "AMDI0005"))) {
491+
if (lps0_dsm_func_mask > 0x3 && data->check_off_by_one) {
394492
lps0_dsm_func_mask = (lps0_dsm_func_mask << 1) | 0x1;
395493
acpi_handle_debug(adev->handle, "_DSM UUID %s: Adjusted function mask: 0x%x\n",
396494
ACPI_LPS0_DSM_UUID_AMD, lps0_dsm_func_mask);
397-
} else if (lps0_dsm_func_mask_microsoft > 0 &&
398-
(!strcmp(hid, "AMDI0007") ||
399-
!strcmp(hid, "AMDI0008"))) {
495+
} else if (lps0_dsm_func_mask_microsoft > 0 && data->prefer_amd_guid &&
496+
!prefer_microsoft_dsm_guid) {
400497
lps0_dsm_func_mask_microsoft = -EINVAL;
401498
acpi_handle_debug(adev->handle, "_DSM Using AMD method\n");
402499
}
403500
} else {
404501
rev_id = 1;
405502
lps0_dsm_func_mask = validate_dsm(adev->handle,
406503
ACPI_LPS0_DSM_UUID, rev_id, &lps0_dsm_guid);
407-
lps0_dsm_func_mask_microsoft = -EINVAL;
504+
if (!prefer_microsoft_dsm_guid)
505+
lps0_dsm_func_mask_microsoft = -EINVAL;
408506
}
409507

410508
if (lps0_dsm_func_mask < 0 && lps0_dsm_func_mask_microsoft < 0)
@@ -533,8 +631,9 @@ static const struct platform_s2idle_ops acpi_s2idle_ops_lps0 = {
533631
.end = acpi_s2idle_end,
534632
};
535633

536-
void acpi_s2idle_setup(void)
634+
void __init acpi_s2idle_setup(void)
537635
{
636+
dmi_check_system(s2idle_dmi_table);
538637
acpi_scan_add_handler(&lps0_handler);
539638
s2idle_set_ops(&acpi_s2idle_ops_lps0);
540639
}

drivers/usb/typec/mux/intel_pmc_mux.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -569,15 +569,6 @@ static int pmc_usb_register_port(struct pmc_usb *pmc, int index,
569569
return ret;
570570
}
571571

572-
static int is_memory(struct acpi_resource *res, void *data)
573-
{
574-
struct resource_win win = {};
575-
struct resource *r = &win.res;
576-
577-
return !(acpi_dev_resource_memory(res, r) ||
578-
acpi_dev_resource_address_space(res, &win));
579-
}
580-
581572
/* IOM ACPI IDs and IOM_PORT_STATUS_OFFSET */
582573
static const struct acpi_device_id iom_acpi_ids[] = {
583574
/* TigerLake */
@@ -611,7 +602,7 @@ static int pmc_usb_probe_iom(struct pmc_usb *pmc)
611602
return -ENODEV;
612603

613604
INIT_LIST_HEAD(&resource_list);
614-
ret = acpi_dev_get_resources(adev, &resource_list, is_memory, NULL);
605+
ret = acpi_dev_get_memory_resources(adev, &resource_list);
615606
if (ret < 0)
616607
return ret;
617608

include/linux/acpi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@ int acpi_dev_get_resources(struct acpi_device *adev, struct list_head *list,
506506
void *preproc_data);
507507
int acpi_dev_get_dma_resources(struct acpi_device *adev,
508508
struct list_head *list);
509+
int acpi_dev_get_memory_resources(struct acpi_device *adev, struct list_head *list);
509510
int acpi_dev_filter_resource_type(struct acpi_resource *ares,
510511
unsigned long types);
511512

0 commit comments

Comments
 (0)