commit e2abc47a5a1a ("ACPI: APEI: Fix AER info corruption when error
status data has multiple sections") passed to aer_recover_queue() a
newly allocated copy of pcie_err->aer_info instead of providing a
pointer to the ghes struct. This prevented corruptions of the ghes
record (in case the ghes record was re-used for a new error before
the previous error was logged).To prepare for using a common logging/reporting structure for ghes/MCE and merging extlog_print_pcie() / ghes_handle_aer() into a common helper, remove the dependency of ghes_handle_aer() over gen_pool_alloc(). To achieve the above, replace (struct aer_recover_entry).regs by a plain struct instead of a pointer, allowing to remove the memory allocation. No functional change intended. Signed-off-by: Pierre Gondois <[email protected]> --- drivers/pci/pcie/aer.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index 8708ca3257bb8..57406494ec1f7 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -1352,7 +1352,7 @@ struct aer_recover_entry { u8 devfn; u16 domain; int severity; - struct aer_capability_regs *regs; + struct aer_capability_regs regs; }; static DEFINE_KFIFO(aer_recover_ring, struct aer_recover_entry, @@ -1374,24 +1374,14 @@ static void aer_recover_work_func(struct work_struct *work) PCI_SLOT(entry.devfn), PCI_FUNC(entry.devfn)); else - pci_print_aer(pdev, entry.severity, entry.regs); + pci_print_aer(pdev, entry.severity, &entry.regs); - regs = entry.regs; + regs = &entry.regs; if (entry.severity == AER_CORRECTABLE) err = regs->cor_status & ~regs->cor_mask; else err = regs->uncor_status & ~regs->uncor_mask; - /* - * Memory for aer_capability_regs(entry.regs) is being - * allocated from the ghes_estatus_pool to protect it from - * overwriting when multiple sections are present in the - * error status. Thus free the same after processing the - * data. - */ - ghes_estatus_pool_region_free((unsigned long)entry.regs, - sizeof(struct aer_capability_regs)); - if (!pdev) continue; @@ -1429,9 +1419,9 @@ static DECLARE_WORK(aer_recover_work, aer_recover_work_func); * * Takes ownership of @aer_regs, which must have been allocated from * ghes_estatus_pool with a size of sizeof(struct aer_capability_regs). - * The buffer is freed with ghes_estatus_pool_region_free() by the work - * item that processes the record, or immediately if the queue is full. - * The caller must not access or free @aer_regs after this call. + * Copies the registers into the queue entry and frees the supplied buffer + * before returning, including when the queue is full. The caller must not + * access or free @aer_regs after this call. */ void aer_recover_queue(int domain, unsigned int bus, unsigned int devfn, int severity, struct aer_capability_regs *aer_regs) @@ -1441,17 +1431,18 @@ void aer_recover_queue(int domain, unsigned int bus, unsigned int devfn, .devfn = devfn, .domain = domain, .severity = severity, - .regs = aer_regs, + .regs = *aer_regs, }; + ghes_estatus_pool_region_free((unsigned long)aer_regs, + sizeof(struct aer_capability_regs)); + if (kfifo_in_spinlocked(&aer_recover_ring, &entry, 1, &aer_recover_ring_lock)) { schedule_work(&aer_recover_work); } else { pr_err("buffer overflow in recovery for %04x:%02x:%02x.%x\n", domain, bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); - ghes_estatus_pool_region_free((unsigned long)aer_regs, - sizeof(struct aer_capability_regs)); } } EXPORT_SYMBOL_GPL(aer_recover_queue); -- 2.43.0
