Skip to content

Commit 39f26d1

Browse files
committed
Merge branches 'acpi-apei', 'acpi-x86', 'acpi-battery' and 'acpi-pfrut'
Make ACPI APEI updates, x86-specific ACPI updates, ACPI battery driver fix and ACPI PFRU/T driver fixes for 6.2-rc1: - Drop unsetting ACPI APEI driver data on remove (Uwe Kleine-König). - Use xchg_release() instead of cmpxchg() for updating new GHES cache slots (Ard Biesheuvel). - Clean up the ACPI APEI code (Sudeep Holla, Christophe JAILLET, Jay Lu). - Add new I2C device enumeration quirks for Medion Lifetab S10346 and Lenovo Yoga Tab 3 Pro (YT3-X90F) (Hans de Goede). - Make the ACPI battery driver notify user space about adding new battery hooks and removing the existing ones (Armin Wolf). - Modify the pfr_update and pfr_telemetry drivers to use ACPI_FREE() for freeing acpi_object structures to help diagnostics (Wang ShaoBo). * acpi-apei: ACPI: APEI: EINJ: Refactor available_error_type_show() ACPI: APEI: EINJ: Fix formatting errors ACPI: APEI: Remove a useless include ACPI: APEI: Silence missing prototype warnings apei/ghes: Use xchg_release() for updating new cache slot instead of cmpxchg() ACPI: APEI: Drop unsetting driver data on remove * acpi-x86: ACPI: x86: Add skip i2c clients quirk for Medion Lifetab S10346 ACPI: x86: Add skip i2c clients quirk for Lenovo Yoga Tab 3 Pro (YT3-X90F) * acpi-battery: ACPI: battery: Call power_supply_changed() when adding hooks * acpi-pfrut: ACPI: pfr_update: use ACPI_FREE() to free acpi_object ACPI: pfr_telemetry: use ACPI_FREE() to free acpi_object
5 parents 6f15818 + 87386ee + ecc6aaa + 98b0cf2 + e335bee commit 39f26d1

File tree

7 files changed

+92
-69
lines changed

7 files changed

+92
-69
lines changed

drivers/acpi/apei/apei-base.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
#include <linux/slab.h>
2626
#include <linux/io.h>
2727
#include <linux/kref.h>
28-
#include <linux/rculist.h>
2928
#include <linux/interrupt.h>
3029
#include <linux/debugfs.h>
30+
#include <acpi/apei.h>
3131
#include <asm/unaligned.h>
3232

3333
#include "apei-internal.h"

drivers/acpi/apei/einj.c

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
358358
*/
359359
if ((param_extension || acpi5) && (type & MEM_ERROR_MASK) && param2) {
360360
struct apei_resources addr_resources;
361+
361362
apei_resources_init(&addr_resources);
362363
trigger_param_region = einj_get_trigger_parameter_region(
363364
trigger_tab, param1, param2);
@@ -432,11 +433,11 @@ static int __einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2,
432433
}
433434
v5param->flags = vendor_flags;
434435
} else if (flags) {
435-
v5param->flags = flags;
436-
v5param->memory_address = param1;
437-
v5param->memory_address_range = param2;
438-
v5param->apicid = param3;
439-
v5param->pcie_sbdf = param4;
436+
v5param->flags = flags;
437+
v5param->memory_address = param1;
438+
v5param->memory_address_range = param2;
439+
v5param->apicid = param3;
440+
v5param->pcie_sbdf = param4;
440441
} else {
441442
switch (type) {
442443
case ACPI_EINJ_PROCESSOR_CORRECTABLE:
@@ -466,6 +467,7 @@ static int __einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2,
466467
return rc;
467468
if (einj_param) {
468469
struct einj_parameter *v4param = einj_param;
470+
469471
v4param->param1 = param1;
470472
v4param->param2 = param2;
471473
}
@@ -569,6 +571,20 @@ static u64 error_param2;
569571
static u64 error_param3;
570572
static u64 error_param4;
571573
static struct dentry *einj_debug_dir;
574+
static const char * const einj_error_type_string[] = {
575+
"0x00000001\tProcessor Correctable\n",
576+
"0x00000002\tProcessor Uncorrectable non-fatal\n",
577+
"0x00000004\tProcessor Uncorrectable fatal\n",
578+
"0x00000008\tMemory Correctable\n",
579+
"0x00000010\tMemory Uncorrectable non-fatal\n",
580+
"0x00000020\tMemory Uncorrectable fatal\n",
581+
"0x00000040\tPCI Express Correctable\n",
582+
"0x00000080\tPCI Express Uncorrectable non-fatal\n",
583+
"0x00000100\tPCI Express Uncorrectable fatal\n",
584+
"0x00000200\tPlatform Correctable\n",
585+
"0x00000400\tPlatform Uncorrectable non-fatal\n",
586+
"0x00000800\tPlatform Uncorrectable fatal\n",
587+
};
572588

573589
static int available_error_type_show(struct seq_file *m, void *v)
574590
{
@@ -578,30 +594,9 @@ static int available_error_type_show(struct seq_file *m, void *v)
578594
rc = einj_get_available_error_type(&available_error_type);
579595
if (rc)
580596
return rc;
581-
if (available_error_type & 0x0001)
582-
seq_printf(m, "0x00000001\tProcessor Correctable\n");
583-
if (available_error_type & 0x0002)
584-
seq_printf(m, "0x00000002\tProcessor Uncorrectable non-fatal\n");
585-
if (available_error_type & 0x0004)
586-
seq_printf(m, "0x00000004\tProcessor Uncorrectable fatal\n");
587-
if (available_error_type & 0x0008)
588-
seq_printf(m, "0x00000008\tMemory Correctable\n");
589-
if (available_error_type & 0x0010)
590-
seq_printf(m, "0x00000010\tMemory Uncorrectable non-fatal\n");
591-
if (available_error_type & 0x0020)
592-
seq_printf(m, "0x00000020\tMemory Uncorrectable fatal\n");
593-
if (available_error_type & 0x0040)
594-
seq_printf(m, "0x00000040\tPCI Express Correctable\n");
595-
if (available_error_type & 0x0080)
596-
seq_printf(m, "0x00000080\tPCI Express Uncorrectable non-fatal\n");
597-
if (available_error_type & 0x0100)
598-
seq_printf(m, "0x00000100\tPCI Express Uncorrectable fatal\n");
599-
if (available_error_type & 0x0200)
600-
seq_printf(m, "0x00000200\tPlatform Correctable\n");
601-
if (available_error_type & 0x0400)
602-
seq_printf(m, "0x00000400\tPlatform Uncorrectable non-fatal\n");
603-
if (available_error_type & 0x0800)
604-
seq_printf(m, "0x00000800\tPlatform Uncorrectable fatal\n");
597+
for (int pos = 0; pos < ARRAY_SIZE(einj_error_type_string); pos++)
598+
if (available_error_type & BIT(pos))
599+
seq_puts(m, einj_error_type_string[pos]);
605600

606601
return 0;
607602
}
@@ -689,8 +684,7 @@ static int __init einj_init(void)
689684
if (status == AE_NOT_FOUND) {
690685
pr_warn("EINJ table not found.\n");
691686
return -ENODEV;
692-
}
693-
else if (ACPI_FAILURE(status)) {
687+
} else if (ACPI_FAILURE(status)) {
694688
pr_err("Failed to get EINJ table: %s\n",
695689
acpi_format_exception(status));
696690
return -EINVAL;

drivers/acpi/apei/ghes.c

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ struct ghes_vendor_record_entry {
138138
static struct gen_pool *ghes_estatus_pool;
139139
static unsigned long ghes_estatus_pool_size_request;
140140

141-
static struct ghes_estatus_cache *ghes_estatus_caches[GHES_ESTATUS_CACHES_SIZE];
141+
static struct ghes_estatus_cache __rcu *ghes_estatus_caches[GHES_ESTATUS_CACHES_SIZE];
142142
static atomic_t ghes_estatus_cache_alloced;
143143

144144
static int ghes_panic_timeout __read_mostly = 30;
@@ -773,48 +773,42 @@ static struct ghes_estatus_cache *ghes_estatus_cache_alloc(
773773
return cache;
774774
}
775775

776-
static void ghes_estatus_cache_free(struct ghes_estatus_cache *cache)
776+
static void ghes_estatus_cache_rcu_free(struct rcu_head *head)
777777
{
778+
struct ghes_estatus_cache *cache;
778779
u32 len;
779780

781+
cache = container_of(head, struct ghes_estatus_cache, rcu);
780782
len = cper_estatus_len(GHES_ESTATUS_FROM_CACHE(cache));
781783
len = GHES_ESTATUS_CACHE_LEN(len);
782784
gen_pool_free(ghes_estatus_pool, (unsigned long)cache, len);
783785
atomic_dec(&ghes_estatus_cache_alloced);
784786
}
785787

786-
static void ghes_estatus_cache_rcu_free(struct rcu_head *head)
787-
{
788-
struct ghes_estatus_cache *cache;
789-
790-
cache = container_of(head, struct ghes_estatus_cache, rcu);
791-
ghes_estatus_cache_free(cache);
792-
}
793-
794-
static void ghes_estatus_cache_add(
795-
struct acpi_hest_generic *generic,
796-
struct acpi_hest_generic_status *estatus)
788+
static void
789+
ghes_estatus_cache_add(struct acpi_hest_generic *generic,
790+
struct acpi_hest_generic_status *estatus)
797791
{
798-
int i, slot = -1, count;
799792
unsigned long long now, duration, period, max_period = 0;
800-
struct ghes_estatus_cache *cache, *slot_cache = NULL, *new_cache;
793+
struct ghes_estatus_cache *cache, *new_cache;
794+
struct ghes_estatus_cache __rcu *victim;
795+
int i, slot = -1, count;
801796

802797
new_cache = ghes_estatus_cache_alloc(generic, estatus);
803-
if (new_cache == NULL)
798+
if (!new_cache)
804799
return;
800+
805801
rcu_read_lock();
806802
now = sched_clock();
807803
for (i = 0; i < GHES_ESTATUS_CACHES_SIZE; i++) {
808804
cache = rcu_dereference(ghes_estatus_caches[i]);
809805
if (cache == NULL) {
810806
slot = i;
811-
slot_cache = NULL;
812807
break;
813808
}
814809
duration = now - cache->time_in;
815810
if (duration >= GHES_ESTATUS_IN_CACHE_MAX_NSEC) {
816811
slot = i;
817-
slot_cache = cache;
818812
break;
819813
}
820814
count = atomic_read(&cache->count);
@@ -823,18 +817,30 @@ static void ghes_estatus_cache_add(
823817
if (period > max_period) {
824818
max_period = period;
825819
slot = i;
826-
slot_cache = cache;
827820
}
828821
}
829-
/* new_cache must be put into array after its contents are written */
830-
smp_wmb();
831-
if (slot != -1 && cmpxchg(ghes_estatus_caches + slot,
832-
slot_cache, new_cache) == slot_cache) {
833-
if (slot_cache)
834-
call_rcu(&slot_cache->rcu, ghes_estatus_cache_rcu_free);
835-
} else
836-
ghes_estatus_cache_free(new_cache);
837822
rcu_read_unlock();
823+
824+
if (slot != -1) {
825+
/*
826+
* Use release semantics to ensure that ghes_estatus_cached()
827+
* running on another CPU will see the updated cache fields if
828+
* it can see the new value of the pointer.
829+
*/
830+
victim = xchg_release(&ghes_estatus_caches[slot],
831+
RCU_INITIALIZER(new_cache));
832+
833+
/*
834+
* At this point, victim may point to a cached item different
835+
* from the one based on which we selected the slot. Instead of
836+
* going to the loop again to pick another slot, let's just
837+
* drop the other item anyway: this may cause a false cache
838+
* miss later on, but that won't cause any problems.
839+
*/
840+
if (victim)
841+
call_rcu(&unrcu_pointer(victim)->rcu,
842+
ghes_estatus_cache_rcu_free);
843+
}
838844
}
839845

840846
static void __ghes_panic(struct ghes *ghes,
@@ -1444,8 +1450,6 @@ static int ghes_remove(struct platform_device *ghes_dev)
14441450

14451451
kfree(ghes);
14461452

1447-
platform_set_drvdata(ghes_dev, NULL);
1448-
14491453
return 0;
14501454
}
14511455

drivers/acpi/battery.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,8 @@ static void __battery_hook_unregister(struct acpi_battery_hook *hook, int lock)
696696
if (lock)
697697
mutex_lock(&hook_mutex);
698698
list_for_each_entry(battery, &acpi_battery_list, list) {
699-
hook->remove_battery(battery->bat);
699+
if (!hook->remove_battery(battery->bat))
700+
power_supply_changed(battery->bat);
700701
}
701702
list_del(&hook->list);
702703
if (lock)
@@ -735,6 +736,8 @@ void battery_hook_register(struct acpi_battery_hook *hook)
735736
__battery_hook_unregister(hook, 0);
736737
goto end;
737738
}
739+
740+
power_supply_changed(battery->bat);
738741
}
739742
pr_info("new extension: %s\n", hook->name);
740743
end:

drivers/acpi/pfr_telemetry.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static int get_pfrt_log_data_info(struct pfrt_log_data_info *data_info,
144144
ret = 0;
145145

146146
free_acpi_buffer:
147-
kfree(out_obj);
147+
ACPI_FREE(out_obj);
148148

149149
return ret;
150150
}
@@ -180,7 +180,7 @@ static int set_pfrt_log_level(int level, struct pfrt_log_device *pfrt_log_dev)
180180
ret = -EBUSY;
181181
}
182182

183-
kfree(out_obj);
183+
ACPI_FREE(out_obj);
184184

185185
return ret;
186186
}
@@ -218,7 +218,7 @@ static int get_pfrt_log_level(struct pfrt_log_device *pfrt_log_dev)
218218
ret = obj->integer.value;
219219

220220
free_acpi_buffer:
221-
kfree(out_obj);
221+
ACPI_FREE(out_obj);
222222

223223
return ret;
224224
}

drivers/acpi/pfr_update.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ static int query_capability(struct pfru_update_cap_info *cap_hdr,
178178
ret = 0;
179179

180180
free_acpi_buffer:
181-
kfree(out_obj);
181+
ACPI_FREE(out_obj);
182182

183183
return ret;
184184
}
@@ -224,7 +224,7 @@ static int query_buffer(struct pfru_com_buf_info *info,
224224
ret = 0;
225225

226226
free_acpi_buffer:
227-
kfree(out_obj);
227+
ACPI_FREE(out_obj);
228228

229229
return ret;
230230
}
@@ -385,7 +385,7 @@ static int start_update(int action, struct pfru_device *pfru_dev)
385385
ret = 0;
386386

387387
free_acpi_buffer:
388-
kfree(out_obj);
388+
ACPI_FREE(out_obj);
389389

390390
return ret;
391391
}

drivers/acpi/x86/utils.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ static const struct dmi_system_id acpi_quirk_skip_dmi_ids[] = {
308308
ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY),
309309
},
310310
{
311-
/* Lenovo Yoga Tablet 1050F/L */
311+
/* Lenovo Yoga Tablet 2 1050F/L */
312312
.matches = {
313313
DMI_MATCH(DMI_SYS_VENDOR, "Intel Corp."),
314314
DMI_MATCH(DMI_PRODUCT_NAME, "VALLEYVIEW C0 PLATFORM"),
@@ -319,6 +319,27 @@ static const struct dmi_system_id acpi_quirk_skip_dmi_ids[] = {
319319
.driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS |
320320
ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY),
321321
},
322+
{
323+
/* Lenovo Yoga Tab 3 Pro X90F */
324+
.matches = {
325+
DMI_MATCH(DMI_SYS_VENDOR, "Intel Corporation"),
326+
DMI_MATCH(DMI_PRODUCT_NAME, "CHERRYVIEW D1 PLATFORM"),
327+
DMI_MATCH(DMI_PRODUCT_VERSION, "Blade3-10A-001"),
328+
},
329+
.driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS |
330+
ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY),
331+
},
332+
{
333+
/* Medion Lifetab S10346 */
334+
.matches = {
335+
DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
336+
DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
337+
/* Way too generic, also match on BIOS data */
338+
DMI_MATCH(DMI_BIOS_DATE, "10/22/2015"),
339+
},
340+
.driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS |
341+
ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY),
342+
},
322343
{
323344
/* Nextbook Ares 8 */
324345
.matches = {
@@ -348,6 +369,7 @@ static const struct acpi_device_id i2c_acpi_known_good_ids[] = {
348369
{ "10EC5640", 0 }, /* RealTek ALC5640 audio codec */
349370
{ "INT33F4", 0 }, /* X-Powers AXP288 PMIC */
350371
{ "INT33FD", 0 }, /* Intel Crystal Cove PMIC */
372+
{ "INT34D3", 0 }, /* Intel Whiskey Cove PMIC */
351373
{ "NPCE69A", 0 }, /* Asus Transformer keyboard dock */
352374
{}
353375
};

0 commit comments

Comments
 (0)