Skip to content

Commit

Permalink
Merge branches 'acpi-apei', 'acpi-dptf', 'acpi-x86' and 'acpi-docs'
Browse files Browse the repository at this point in the history
Merge APEI material, changes related to DPTF, ACPI-related x86 cleanup
and documentation improvement for 5.19-rc1:

 - Fix missing ERST record ID in the APEI code (Liu Xinpeng).

 - Make APEI error injection to refuse to inject into the zero
   page (Tony Luck).

 - Correct description of INT3407 / INT3532 DPTF attributes in sysfs
   (Sumeet Pawnikar).

 - Add support for high frequency impedance notification to the DPTF
   driver (Sumeet Pawnikar).

 - Make mp_config_acpi_gsi() a void function (Li kunyu).

 - Unify Package () representation for properties in the ACPI device
   properties documentation (Andy Shevchenko).

* acpi-apei:
  ACPI, APEI, EINJ: Refuse to inject into the zero page
  ACPI: APEI: Fix missing ERST record id

* acpi-dptf:
  ACPI: DPTF: Add support for high frequency impedance notification
  ACPI: DPTF: Correct description of INT3407 / INT3532 attributes

* acpi-x86:
  x86: ACPI: Make mp_config_acpi_gsi() a void function

* acpi-docs:
  ACPI: docs: enumeration: Unify Package () for properties (part 2)
  • Loading branch information
rafaeljw committed May 23, 2022
5 parents 4aa8c70 + ab59c89 + 42e5ed0 + 24773e6 + e802ca7 commit 5db9ce2
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 22 deletions.
3 changes: 1 addition & 2 deletions Documentation/firmware-guide/acpi/enumeration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ The table below shows an example of its usage::
Name (_DSD, Package () {
ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
Package () {
Package () {"interrupt-names",
Package (2) {"default", "alert"}},
Package () { "interrupt-names", Package () { "default", "alert" } },
}
...
})
Expand Down
7 changes: 3 additions & 4 deletions arch/x86/kernel/acpi/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ static void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger,
isa_irq_to_gsi[bus_irq] = gsi;
}

static int mp_config_acpi_gsi(struct device *dev, u32 gsi, int trigger,
static void mp_config_acpi_gsi(struct device *dev, u32 gsi, int trigger,
int polarity)
{
#ifdef CONFIG_X86_MPPARSE
Expand All @@ -387,9 +387,9 @@ static int mp_config_acpi_gsi(struct device *dev, u32 gsi, int trigger,
u8 pin;

if (!acpi_ioapic)
return 0;
return;
if (!dev || !dev_is_pci(dev))
return 0;
return;

pdev = to_pci_dev(dev);
number = pdev->bus->number;
Expand All @@ -408,7 +408,6 @@ static int mp_config_acpi_gsi(struct device *dev, u32 gsi, int trigger,

mp_save_irq(&mp_irq);
#endif
return 0;
}

static int __init mp_register_ioapic_irq(u8 bus_irq, u8 polarity,
Expand Down
8 changes: 3 additions & 5 deletions arch/x86/kernel/cpu/mce/apei.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,14 @@ ssize_t apei_read_mce(struct mce *m, u64 *record_id)
/* no more record */
if (*record_id == APEI_ERST_INVALID_RECORD_ID)
goto out;
rc = erst_read(*record_id, &rcd.hdr, sizeof(rcd));
rc = erst_read_record(*record_id, &rcd.hdr, sizeof(rcd), sizeof(rcd),
&CPER_CREATOR_MCE);
/* someone else has cleared the record, try next one */
if (rc == -ENOENT)
goto retry;
else if (rc < 0)
goto out;
/* try to skip other type records in storage */
else if (rc != sizeof(rcd) ||
!guid_equal(&rcd.hdr.creator_id, &CPER_CREATOR_MCE))
goto retry;

memcpy(m, &rcd.mce, sizeof(*m));
rc = sizeof(*m);
out:
Expand Down
3 changes: 3 additions & 0 deletions drivers/acpi/apei/einj.c
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,9 @@ static int einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2,
!arch_is_platform_page(base_addr)))
return -EINVAL;

if (is_zero_pfn(base_addr >> PAGE_SHIFT))
return -EADDRINUSE;

inject:
mutex_lock(&einj_mutex);
rc = __einj_error_inject(type, flags, param1, param2, param3, param4);
Expand Down
3 changes: 2 additions & 1 deletion drivers/acpi/apei/erst-dbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ static ssize_t erst_dbg_read(struct file *filp, char __user *ubuf,
goto out;
}
retry:
rc = len = erst_read(id, erst_dbg_buf, erst_dbg_buf_len);
rc = len = erst_read_record(id, erst_dbg_buf, erst_dbg_buf_len,
erst_dbg_buf_len, NULL);
/* The record may be cleared by others, try read next record */
if (rc == -ENOENT)
goto retry_next;
Expand Down
77 changes: 71 additions & 6 deletions drivers/acpi/apei/erst.c
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,74 @@ ssize_t erst_read(u64 record_id, struct cper_record_header *record,
}
EXPORT_SYMBOL_GPL(erst_read);

static void erst_clear_cache(u64 record_id)
{
int i;
u64 *entries;

mutex_lock(&erst_record_id_cache.lock);

entries = erst_record_id_cache.entries;
for (i = 0; i < erst_record_id_cache.len; i++) {
if (entries[i] == record_id)
entries[i] = APEI_ERST_INVALID_RECORD_ID;
}
__erst_record_id_cache_compact();

mutex_unlock(&erst_record_id_cache.lock);
}

ssize_t erst_read_record(u64 record_id, struct cper_record_header *record,
size_t buflen, size_t recordlen, const guid_t *creatorid)
{
ssize_t len;

/*
* if creatorid is NULL, read any record for erst-dbg module
*/
if (creatorid == NULL) {
len = erst_read(record_id, record, buflen);
if (len == -ENOENT)
erst_clear_cache(record_id);

return len;
}

len = erst_read(record_id, record, buflen);
/*
* if erst_read return value is -ENOENT skip to next record_id,
* and clear the record_id cache.
*/
if (len == -ENOENT) {
erst_clear_cache(record_id);
goto out;
}

if (len < 0)
goto out;

/*
* if erst_read return value is less than record head length,
* consider it as -EIO, and clear the record_id cache.
*/
if (len < recordlen) {
len = -EIO;
erst_clear_cache(record_id);
goto out;
}

/*
* if creatorid is not wanted, consider it as not found,
* for skipping to next record_id.
*/
if (!guid_equal(&record->creator_id, creatorid))
len = -ENOENT;

out:
return len;
}
EXPORT_SYMBOL_GPL(erst_read_record);

int erst_clear(u64 record_id)
{
int rc, i;
Expand Down Expand Up @@ -996,16 +1064,13 @@ static ssize_t erst_reader(struct pstore_record *record)
goto out;
}

len = erst_read(record_id, &rcd->hdr, rcd_len);
len = erst_read_record(record_id, &rcd->hdr, rcd_len, sizeof(*rcd),
&CPER_CREATOR_PSTORE);
/* The record may be cleared by others, try read next record */
if (len == -ENOENT)
goto skip;
else if (len < 0 || len < sizeof(*rcd)) {
rc = -EIO;
else if (len < 0)
goto out;
}
if (!guid_equal(&rcd->hdr.creator_id, &CPER_CREATOR_PSTORE))
goto skip;

record->buf = kmalloc(len, GFP_KERNEL);
if (record->buf == NULL) {
Expand Down
9 changes: 5 additions & 4 deletions drivers/acpi/dptf/dptf_power.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@
/*
* Presentation of attributes which are defined for INT3407 and INT3532.
* They are:
* PMAX : Maximum platform powe
* PMAX : Maximum platform power
* PSRC : Platform power source
* ARTG : Adapter rating
* CTYP : Charger type
* PBSS : Battery steady power
* PROP : Rest of worst case platform Power
* PBSS : Power Battery Steady State
* PBSS : Power Battery Steady State
* RBHF : High Frequency Impedance
* VBNL : Instantaneous No-Load Voltage
* CMPP : Current Discharge Capability
Expand Down Expand Up @@ -117,7 +115,7 @@ static const struct attribute_group dptf_battery_attribute_group = {
#define POWER_STATE_CHANGED 0x81
#define STEADY_STATE_POWER_CHANGED 0x83
#define POWER_PROP_CHANGE_EVENT 0x84
#define IMPEDANCED_CHNGED 0x85
#define IMPEDANCE_CHANGED 0x85
#define VOLTAGE_CURRENT_CHANGED 0x86

static long long dptf_participant_type(acpi_handle handle)
Expand Down Expand Up @@ -150,6 +148,9 @@ static void dptf_power_notify(acpi_handle handle, u32 event, void *data)
case STEADY_STATE_POWER_CHANGED:
attr = "max_steady_state_power_mw";
break;
case IMPEDANCE_CHANGED:
attr = "high_freq_impedance_mohm";
break;
case VOLTAGE_CURRENT_CHANGED:
attr = "no_load_voltage_mv";
break;
Expand Down
2 changes: 2 additions & 0 deletions include/acpi/apei.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ int erst_get_record_id_next(int *pos, u64 *record_id);
void erst_get_record_id_end(void);
ssize_t erst_read(u64 record_id, struct cper_record_header *record,
size_t buflen);
ssize_t erst_read_record(u64 record_id, struct cper_record_header *record,
size_t buflen, size_t recordlen, const guid_t *creatorid);
int erst_clear(u64 record_id);

int arch_apei_enable_cmcff(struct acpi_hest_header *hest_hdr, void *data);
Expand Down

0 comments on commit 5db9ce2

Please sign in to comment.