Skip to content

Commit cae4ef6

Browse files
committed
Merge tag 'acpi-7.1-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull ACPI support fixes from Rafael Wysocki: "These fix leftover issues in the ACPI Time and Alarm Device (TAD) driver on top of the recently merged updates of it and address assorted issues in the ACPI support code: - Fix removal code ordering in the ACPI TAD driver, refine timer value computations and checks in its RTC class device interface, make it use the __ATTRIBUTE_GROUPS() macro, and fix a comment in it (Rafael Wysocki) - Fix EINJV2 memory error injection in APEI (Tony Luck) - Add missing notifier_block structure forward declaration to acpi_bus.h (Bartosz Golaszewski) - Fix related_cpus inconsistency during CPU hotplug in the ACPI CPPC library (Jinjie Ruan) - Add a quirk to force native backlight on HP OMEN 16 (8A44) in the ACPI video bus driver (Shivam Kalra)" * tag 'acpi-7.1-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: ACPI: bus: add missing forward declaration to acpi_bus.h ACPI: video: force native backlight on HP OMEN 16 (8A44) ACPI: TAD: Fix up a comment in acpi_tad_probe() ACPI: TAD: RTC: Refine timer value computations and checks ACPI: TAD: Use devres for all driver cleanup ACPI: TAD: Use __ATTRIBUTE_GROUPS() macro ACPI: CPPC: Fix related_cpus inconsistency during CPU hotplug ACPI: APEI: EINJ: Fix EINJV2 memory error injection ACPICA: Provide #defines for EINJV2 error types
2 parents 74b54e9 + 36a96ed commit cae4ef6

6 files changed

Lines changed: 63 additions & 39 deletions

File tree

drivers/acpi/acpi_tad.c

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -605,15 +605,12 @@ static umode_t acpi_tad_attr_is_visible(struct kobject *kobj,
605605
return 0;
606606
}
607607

608-
static const struct attribute_group acpi_tad_attr_group = {
608+
static const struct attribute_group acpi_tad_group = {
609609
.attrs = acpi_tad_attrs,
610610
.is_visible = acpi_tad_attr_is_visible,
611611
};
612612

613-
static const struct attribute_group *acpi_tad_attr_groups[] = {
614-
&acpi_tad_attr_group,
615-
NULL,
616-
};
613+
__ATTRIBUTE_GROUPS(acpi_tad);
617614

618615
#ifdef CONFIG_RTC_CLASS
619616
/* RTC class device interface */
@@ -683,9 +680,8 @@ static int acpi_tad_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *t)
683680

684681
acpi_tad_rt_to_tm(&rt, &tm_now);
685682

686-
value = ktime_divns(ktime_sub(rtc_tm_to_ktime(t->time),
687-
rtc_tm_to_ktime(tm_now)), NSEC_PER_SEC);
688-
if (value <= 0 || value > U32_MAX)
683+
value = rtc_tm_to_time64(&t->time) - rtc_tm_to_time64(&tm_now);
684+
if (value <= 0 || value >= U32_MAX)
689685
return -EINVAL;
690686
}
691687

@@ -748,8 +744,7 @@ static int acpi_tad_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *t)
748744

749745
if (retval != ACPI_TAD_WAKE_DISABLED) {
750746
t->enabled = 1;
751-
t->time = rtc_ktime_to_tm(ktime_add_ns(rtc_tm_to_ktime(tm_now),
752-
(u64)retval * NSEC_PER_SEC));
747+
rtc_time64_to_tm(rtc_tm_to_time64(&tm_now) + retval, &t->time);
753748
} else {
754749
t->enabled = 0;
755750
t->time = tm_now;
@@ -795,9 +790,9 @@ static int acpi_tad_disable_timer(struct device *dev, u32 timer_id)
795790
return acpi_tad_wake_set(dev, "_STV", timer_id, ACPI_TAD_WAKE_DISABLED);
796791
}
797792

798-
static void acpi_tad_remove(struct platform_device *pdev)
793+
static void acpi_tad_remove(void *data)
799794
{
800-
struct device *dev = &pdev->dev;
795+
struct device *dev = data;
801796
struct acpi_tad_driver_data *dd = dev_get_drvdata(dev);
802797

803798
device_init_wakeup(dev, false);
@@ -824,6 +819,7 @@ static int acpi_tad_probe(struct platform_device *pdev)
824819
struct acpi_tad_driver_data *dd;
825820
acpi_status status;
826821
unsigned long long caps;
822+
int ret;
827823

828824
/*
829825
* Initialization failure messages are mostly about firmware issues, so
@@ -863,13 +859,21 @@ static int acpi_tad_probe(struct platform_device *pdev)
863859
}
864860

865861
/*
866-
* The platform bus type layer tells the ACPI PM domain powers up the
867-
* device, so set the runtime PM status of it to "active".
862+
* The platform bus type probe callback tells the ACPI PM domain to
863+
* power up the device, so set the runtime PM status of it to "active".
868864
*/
869865
pm_runtime_set_active(dev);
870866
pm_runtime_enable(dev);
871867
pm_runtime_suspend(dev);
872868

869+
/*
870+
* acpi_tad_remove() needs to run after unregistering the RTC class
871+
* device to avoid racing with the latter's callbacks.
872+
*/
873+
ret = devm_add_action_or_reset(&pdev->dev, acpi_tad_remove, &pdev->dev);
874+
if (ret)
875+
return ret;
876+
873877
if (caps & ACPI_TAD_RT)
874878
acpi_tad_register_rtc(dev, caps);
875879

@@ -885,10 +889,9 @@ static struct platform_driver acpi_tad_driver = {
885889
.driver = {
886890
.name = "acpi-tad",
887891
.acpi_match_table = acpi_tad_ids,
888-
.dev_groups = acpi_tad_attr_groups,
892+
.dev_groups = acpi_tad_groups,
889893
},
890894
.probe = acpi_tad_probe,
891-
.remove = acpi_tad_remove,
892895
};
893896
MODULE_DEVICE_TABLE(acpi, acpi_tad_ids);
894897

drivers/acpi/apei/einj-core.c

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,18 @@ static struct acpi_generic_address *einj_get_trigger_parameter_region(
401401

402402
return NULL;
403403
}
404+
405+
static bool is_memory_injection(u32 type, u32 flags)
406+
{
407+
if (flags & SETWA_FLAGS_EINJV2)
408+
return !!(type & ACPI_EINJV2_MEMORY);
409+
if (type & ACPI5_VENDOR_BIT)
410+
return !!(vendor_flags & SETWA_FLAGS_MEM);
411+
return !!(type & MEM_ERROR_MASK) || !!(flags & SETWA_FLAGS_MEM);
412+
}
413+
404414
/* Execute instructions in trigger error action table */
405-
static int __einj_error_trigger(u64 trigger_paddr, u32 type,
415+
static int __einj_error_trigger(u64 trigger_paddr, u32 type, u32 flags,
406416
u64 param1, u64 param2)
407417
{
408418
struct acpi_einj_trigger trigger_tab;
@@ -480,7 +490,7 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
480490
* This will cause resource conflict with regular memory. So
481491
* remove it from trigger table resources.
482492
*/
483-
if ((param_extension || acpi5) && (type & MEM_ERROR_MASK) && param2) {
493+
if ((param_extension || acpi5) && is_memory_injection(type, flags)) {
484494
struct apei_resources addr_resources;
485495

486496
apei_resources_init(&addr_resources);
@@ -660,7 +670,7 @@ static int __einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2,
660670
return rc;
661671
trigger_paddr = apei_exec_ctx_get_output(&ctx);
662672
if (notrigger == 0) {
663-
rc = __einj_error_trigger(trigger_paddr, type, param1, param2);
673+
rc = __einj_error_trigger(trigger_paddr, type, flags, param1, param2);
664674
if (rc)
665675
return rc;
666676
}
@@ -718,35 +728,30 @@ int einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2, u64 param3,
718728
SETWA_FLAGS_PCIE_SBDF | SETWA_FLAGS_EINJV2)))
719729
return -EINVAL;
720730

731+
/*
732+
* Injections targeting a CXL 1.0/1.1 port have to be injected
733+
* via the einj_cxl_rch_error_inject() path as that does the proper
734+
* validation of the given RCRB base (MMIO) address.
735+
*/
736+
if (einj_is_cxl_error_type(type) && (flags & SETWA_FLAGS_MEM))
737+
return -EINVAL;
738+
721739
/* check if type is a valid EINJv2 error type */
722740
if (is_v2) {
723741
if (!(type & available_error_type_v2))
724742
return -EINVAL;
725743
}
726-
/*
727-
* We need extra sanity checks for memory errors.
728-
* Other types leap directly to injection.
729-
*/
730744

731745
/* ensure param1/param2 existed */
732746
if (!(param_extension || acpi5))
733747
goto inject;
734748

735-
/* ensure injection is memory related */
736-
if (type & ACPI5_VENDOR_BIT) {
737-
if (vendor_flags != SETWA_FLAGS_MEM)
738-
goto inject;
739-
} else if (!(type & MEM_ERROR_MASK) && !(flags & SETWA_FLAGS_MEM)) {
740-
goto inject;
741-
}
742-
743749
/*
744-
* Injections targeting a CXL 1.0/1.1 port have to be injected
745-
* via the einj_cxl_rch_error_inject() path as that does the proper
746-
* validation of the given RCRB base (MMIO) address.
750+
* We need extra sanity checks for memory errors.
751+
* Other types leap directly to injection.
747752
*/
748-
if (einj_is_cxl_error_type(type) && (flags & SETWA_FLAGS_MEM))
749-
return -EINVAL;
753+
if (!is_memory_injection(type, flags))
754+
goto inject;
750755

751756
/*
752757
* Disallow crazy address masks that give BIOS leeway to pick

drivers/acpi/cppc_acpi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ static int send_pcc_cmd(int pcc_ss_id, u16 cmd)
362362
end:
363363
if (cmd == CMD_WRITE) {
364364
if (unlikely(ret)) {
365-
for_each_online_cpu(i) {
365+
for_each_possible_cpu(i) {
366366
struct cpc_desc *desc = per_cpu(cpc_desc_ptr, i);
367367

368368
if (!desc)
@@ -524,13 +524,13 @@ int acpi_get_psd_map(unsigned int cpu, struct cppc_cpudata *cpu_data)
524524
else if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ANY)
525525
cpu_data->shared_type = CPUFREQ_SHARED_TYPE_ANY;
526526

527-
for_each_online_cpu(i) {
527+
for_each_possible_cpu(i) {
528528
if (i == cpu)
529529
continue;
530530

531531
match_cpc_ptr = per_cpu(cpc_desc_ptr, i);
532532
if (!match_cpc_ptr)
533-
goto err_fault;
533+
continue;
534534

535535
match_pdomain = &(match_cpc_ptr->domain_info);
536536
if (match_pdomain->domain != pdomain->domain)

drivers/acpi/video_detect.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,14 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
916916
DMI_MATCH(DMI_PRODUCT_NAME, "82K8"),
917917
},
918918
},
919+
{
920+
.callback = video_detect_force_native,
921+
/* HP OMEN Gaming Laptop 16-n0xxx */
922+
.matches = {
923+
DMI_MATCH(DMI_SYS_VENDOR, "HP"),
924+
DMI_MATCH(DMI_PRODUCT_NAME, "OMEN by HP Gaming Laptop 16-n0xxx"),
925+
},
926+
},
919927

920928
/*
921929
* x86 android tablets which directly control the backlight through

include/acpi/acpi_bus.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include <linux/property.h>
1818
#include <linux/types.h>
1919

20+
struct notifier_block;
21+
2022
struct acpi_handle_list {
2123
u32 count;
2224
acpi_handle *handles;

include/acpi/actbl1.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,6 +1386,12 @@ enum acpi_einj_command_status {
13861386
#define ACPI_EINJ_CXL_MEM_FATAL (1<<17)
13871387
#define ACPI_EINJ_VENDOR_DEFINED (1<<31)
13881388

1389+
/* EINJV2 error types from EINJV2_GET_ERROR_TYPE (ACPI 6.6) */
1390+
1391+
#define ACPI_EINJV2_PROCESSOR (1)
1392+
#define ACPI_EINJV2_MEMORY (1<<1)
1393+
#define ACPI_EINJV2_PCIE (1<<2)
1394+
13891395
/*******************************************************************************
13901396
*
13911397
* ERST - Error Record Serialization Table (ACPI 4.0)

0 commit comments

Comments
 (0)