Skip to content

Commit 0f318ba

Browse files
committed
Merge branches 'acpi-apei', 'acpi-properties', 'acpi-sbs' and 'acpi-thermal'
Merge ACPI APEI changes, ACPI device properties handling update, ACPI SBS driver fixes and ACPI thermal driver cleanup for 6.4-rc1: - Make the APEI error injection code warn on invalid arguments when explicitly indicated by platform (Shuai Xue). - Add CXL error types to the error injection code in APEI (Tony Luck). - Refactor acpi_data_prop_read_single() (Andy Shevchenko). - Fix two issues in the ACPI SBS driver (Armin Wolf). - Replace ternary operator with min_t() in the generic ACPI thermal zone driver (Jiangshan Yi). * acpi-apei: ACPI: APEI: EINJ: warn on invalid argument when explicitly indicated by platform ACPI: APEI: EINJ: Add CXL error types * acpi-properties: ACPI: property: Refactor acpi_data_prop_read_single() * acpi-sbs: ACPI: SBS: Fix handling of Smart Battery Selectors ACPI: EC: Fix oops when removing custom query handlers ACPI: EC: Limit explicit removal of query handlers to custom query handlers * acpi-thermal: ACPI: thermal: Replace ternary operator with min_t()
5 parents 0e83828 + f1e6571 + 1fbd902 + 3bd554e + 0dc9a71 commit 0f318ba

5 files changed

Lines changed: 83 additions & 63 deletions

File tree

drivers/acpi/apei/einj.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,9 +489,15 @@ static int __einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2,
489489
if (rc)
490490
return rc;
491491
val = apei_exec_ctx_get_output(&ctx);
492-
if (val != EINJ_STATUS_SUCCESS)
492+
if (val == EINJ_STATUS_FAIL)
493493
return -EBUSY;
494+
else if (val == EINJ_STATUS_INVAL)
495+
return -EINVAL;
494496

497+
/*
498+
* The error is injected into the platform successfully, then it needs
499+
* to trigger the error.
500+
*/
495501
rc = apei_exec_run(&ctx, ACPI_EINJ_GET_TRIGGER_TABLE);
496502
if (rc)
497503
return rc;
@@ -584,6 +590,12 @@ static const char * const einj_error_type_string[] = {
584590
"0x00000200\tPlatform Correctable\n",
585591
"0x00000400\tPlatform Uncorrectable non-fatal\n",
586592
"0x00000800\tPlatform Uncorrectable fatal\n",
593+
"0x00001000\tCXL.cache Protocol Correctable\n",
594+
"0x00002000\tCXL.cache Protocol Uncorrectable non-fatal\n",
595+
"0x00004000\tCXL.cache Protocol Uncorrectable fatal\n",
596+
"0x00008000\tCXL.mem Protocol Correctable\n",
597+
"0x00010000\tCXL.mem Protocol Uncorrectable non-fatal\n",
598+
"0x00020000\tCXL.mem Protocol Uncorrectable fatal\n",
587599
};
588600

589601
static int available_error_type_show(struct seq_file *m, void *v)

drivers/acpi/ec.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,9 +1083,12 @@ int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit,
10831083
acpi_handle handle, acpi_ec_query_func func,
10841084
void *data)
10851085
{
1086-
struct acpi_ec_query_handler *handler =
1087-
kzalloc(sizeof(struct acpi_ec_query_handler), GFP_KERNEL);
1086+
struct acpi_ec_query_handler *handler;
1087+
1088+
if (!handle && !func)
1089+
return -EINVAL;
10881090

1091+
handler = kzalloc(sizeof(*handler), GFP_KERNEL);
10891092
if (!handler)
10901093
return -ENOMEM;
10911094

@@ -1097,6 +1100,7 @@ int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit,
10971100
kref_init(&handler->kref);
10981101
list_add(&handler->node, &ec->list);
10991102
mutex_unlock(&ec->mutex);
1103+
11001104
return 0;
11011105
}
11021106
EXPORT_SYMBOL_GPL(acpi_ec_add_query_handler);
@@ -1109,9 +1113,16 @@ static void acpi_ec_remove_query_handlers(struct acpi_ec *ec,
11091113

11101114
mutex_lock(&ec->mutex);
11111115
list_for_each_entry_safe(handler, tmp, &ec->list, node) {
1112-
if (remove_all || query_bit == handler->query_bit) {
1116+
/*
1117+
* When remove_all is false, only remove custom query handlers
1118+
* which have handler->func set. This is done to preserve query
1119+
* handlers discovered thru ACPI, as they should continue handling
1120+
* EC queries.
1121+
*/
1122+
if (remove_all || (handler->func && handler->query_bit == query_bit)) {
11131123
list_del_init(&handler->node);
11141124
list_add(&handler->node, &free_list);
1125+
11151126
}
11161127
}
11171128
mutex_unlock(&ec->mutex);
@@ -1122,6 +1133,7 @@ static void acpi_ec_remove_query_handlers(struct acpi_ec *ec,
11221133
void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit)
11231134
{
11241135
acpi_ec_remove_query_handlers(ec, false, query_bit);
1136+
flush_workqueue(ec_query_wq);
11251137
}
11261138
EXPORT_SYMBOL_GPL(acpi_ec_remove_query_handler);
11271139

drivers/acpi/property.c

Lines changed: 34 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -971,60 +971,48 @@ static int acpi_data_prop_read_single(const struct acpi_device_data *data,
971971
enum dev_prop_type proptype, void *val)
972972
{
973973
const union acpi_object *obj;
974-
int ret;
974+
int ret = 0;
975975

976-
if (proptype >= DEV_PROP_U8 && proptype <= DEV_PROP_U64) {
976+
if (proptype >= DEV_PROP_U8 && proptype <= DEV_PROP_U64)
977977
ret = acpi_data_get_property(data, propname, ACPI_TYPE_INTEGER, &obj);
978-
if (ret)
979-
return ret;
980-
981-
switch (proptype) {
982-
case DEV_PROP_U8:
983-
if (obj->integer.value > U8_MAX)
984-
return -EOVERFLOW;
985-
986-
if (val)
987-
*(u8 *)val = obj->integer.value;
988-
989-
break;
990-
case DEV_PROP_U16:
991-
if (obj->integer.value > U16_MAX)
992-
return -EOVERFLOW;
993-
994-
if (val)
995-
*(u16 *)val = obj->integer.value;
996-
997-
break;
998-
case DEV_PROP_U32:
999-
if (obj->integer.value > U32_MAX)
1000-
return -EOVERFLOW;
1001-
1002-
if (val)
1003-
*(u32 *)val = obj->integer.value;
1004-
1005-
break;
1006-
default:
1007-
if (val)
1008-
*(u64 *)val = obj->integer.value;
1009-
1010-
break;
1011-
}
1012-
1013-
if (!val)
1014-
return 1;
1015-
} else if (proptype == DEV_PROP_STRING) {
978+
else if (proptype == DEV_PROP_STRING)
1016979
ret = acpi_data_get_property(data, propname, ACPI_TYPE_STRING, &obj);
1017-
if (ret)
1018-
return ret;
980+
if (ret)
981+
return ret;
1019982

983+
switch (proptype) {
984+
case DEV_PROP_U8:
985+
if (obj->integer.value > U8_MAX)
986+
return -EOVERFLOW;
987+
if (val)
988+
*(u8 *)val = obj->integer.value;
989+
break;
990+
case DEV_PROP_U16:
991+
if (obj->integer.value > U16_MAX)
992+
return -EOVERFLOW;
993+
if (val)
994+
*(u16 *)val = obj->integer.value;
995+
break;
996+
case DEV_PROP_U32:
997+
if (obj->integer.value > U32_MAX)
998+
return -EOVERFLOW;
999+
if (val)
1000+
*(u32 *)val = obj->integer.value;
1001+
break;
1002+
case DEV_PROP_U64:
1003+
if (val)
1004+
*(u64 *)val = obj->integer.value;
1005+
break;
1006+
case DEV_PROP_STRING:
10201007
if (val)
10211008
*(char **)val = obj->string.pointer;
1022-
10231009
return 1;
1024-
} else {
1025-
ret = -EINVAL;
1010+
default:
1011+
return -EINVAL;
10261012
}
1027-
return ret;
1013+
1014+
/* When no storage provided return number of available values */
1015+
return val ? 0 : 1;
10281016
}
10291017

10301018
#define acpi_copy_property_array_uint(items, val, nval) \

drivers/acpi/sbs.c

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -473,23 +473,32 @@ static const struct device_attribute alarm_attr = {
473473
-------------------------------------------------------------------------- */
474474
static int acpi_battery_read(struct acpi_battery *battery)
475475
{
476-
int result = 0, saved_present = battery->present;
476+
int result, saved_present = battery->present;
477477
u16 state;
478478

479479
if (battery->sbs->manager_present) {
480480
result = acpi_smbus_read(battery->sbs->hc, SMBUS_READ_WORD,
481481
ACPI_SBS_MANAGER, 0x01, (u8 *)&state);
482-
if (!result)
483-
battery->present = state & (1 << battery->id);
484-
state &= 0x0fff;
482+
if (result)
483+
return result;
484+
485+
battery->present = state & (1 << battery->id);
486+
if (!battery->present)
487+
return 0;
488+
489+
/* Masking necessary for Smart Battery Selectors */
490+
state = 0x0fff;
485491
state |= 1 << (battery->id + 12);
486492
acpi_smbus_write(battery->sbs->hc, SMBUS_WRITE_WORD,
487493
ACPI_SBS_MANAGER, 0x01, (u8 *)&state, 2);
488-
} else if (battery->id == 0)
489-
battery->present = 1;
490-
491-
if (result || !battery->present)
492-
return result;
494+
} else {
495+
if (battery->id == 0) {
496+
battery->present = 1;
497+
} else {
498+
if (!battery->present)
499+
return 0;
500+
}
501+
}
493502

494503
if (saved_present != battery->present) {
495504
battery->update_time = 0;

drivers/acpi/thermal.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -419,10 +419,9 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
419419
* the next higher trip point
420420
*/
421421
tz->trips.active[i-1].temperature =
422-
(tz->trips.active[i-2].temperature <
423-
celsius_to_deci_kelvin(act) ?
424-
tz->trips.active[i-2].temperature :
425-
celsius_to_deci_kelvin(act));
422+
min_t(unsigned long,
423+
tz->trips.active[i-2].temperature,
424+
celsius_to_deci_kelvin(act));
426425

427426
break;
428427
} else {

0 commit comments

Comments
 (0)