| @@ -25,6 +25,7 @@ · 24 unmodified lines |
| 25 | 25 | * GNU General Public License for more details. |
| 26 | 26 | */ |
| 27 | 27 | |
| 28 | +#include <linux/arm_sdei.h> |
| 28 | 29 | #include <linux/kernel.h> |
| 29 | 30 | #include <linux/moduleparam.h> |
| 30 | 31 | #include <linux/init.h> |
| @@ -33,7 +34,6 @@ · 2 unmodified lines |
| 33 | 34 | #include <linux/interrupt.h> |
| 34 | 35 | #include <linux/timer.h> |
| 35 | 36 | #include <linux/cper.h> |
| 36 | | −#include <linux/kdebug.h> |
| 37 | 37 | #include <linux/platform_device.h> |
| 38 | 38 | #include <linux/mutex.h> |
| 39 | 39 | #include <linux/ratelimit.h> |
| @@ -42,6 +42,7 @@ · 2 unmodified lines |
| 42 | 42 | #include <linux/llist.h> |
| 43 | 43 | #include <linux/genalloc.h> |
| 44 | 44 | #include <linux/pci.h> |
| 45 | +#include <linux/pfn.h> |
| 45 | 46 | #include <linux/aer.h> |
| 46 | 47 | #include <linux/nmi.h> |
| 47 | 48 | #include <linux/sched/clock.h> |
| @@ -85,6 +86,15 @@ · 37 unmodified lines |
| 85 | 86 | ((struct acpi_hest_generic_status *) \ |
| 86 | 87 | ((struct ghes_estatus_node *)(estatus_node) + 1)) |
| 87 | 88 | |
| 89 | +/* |
| 90 | + * NMI-like notifications vary by architecture, before the compiler can prune |
| 91 | + * unused static functions it needs a value for these enums. |
| 92 | + */ |
| 93 | +#ifndef CONFIG_ARM_SDE_INTERFACE |
| 94 | +#define FIX_APEI_GHES_SDEI_NORMAL __end_of_fixed_addresses |
| 95 | +#define FIX_APEI_GHES_SDEI_CRITICAL __end_of_fixed_addresses |
| 96 | +#endif |
| 97 | + |
| 88 | 98 | static inline bool is_hest_type_generic_v2(struct ghes *ghes) |
| 89 | 99 | { |
| 90 | 100 | return ghes->generic->header.type == ACPI_HEST_TYPE_GENERIC_ERROR_V2; |
| @@ -115,11 +125,10 @@ static DEFINE_MUTEX(ghes_list_mutex); · 24 unmodified lines |
| 115 | 125 | * handler, but general ioremap can not be used in atomic context, so |
| 116 | 126 | * the fixmap is used instead. |
| 117 | 127 | * |
| 118 | | − * These 2 spinlocks are used to prevent the fixmap entries from being used |
| 128 | + * This spinlock is used to prevent the fixmap entry from being used |
| 119 | 129 | * simultaneously. |
| 120 | 130 | */ |
| 121 | | −static DEFINE_RAW_SPINLOCK(ghes_ioremap_lock_nmi); |
| 122 | | −static DEFINE_SPINLOCK(ghes_ioremap_lock_irq); |
| 131 | +static DEFINE_SPINLOCK(ghes_notify_lock_irq); |
| 123 | 132 | |
| 124 | 133 | static struct gen_pool *ghes_estatus_pool; |
| 125 | 134 | static unsigned long ghes_estatus_pool_size_request; |
| @@ -129,82 +138,49 @@ static atomic_t ghes_estatus_cache_alloced; · 3 unmodified lines |
| 129 | 138 | |
| 130 | 139 | static int ghes_panic_timeout __read_mostly = 30; |
| 131 | 140 | |
| 132 | | −static void __iomem *ghes_ioremap_pfn_nmi(u64 pfn) |
| 141 | +static void __iomem *ghes_map(u64 pfn, enum fixed_addresses fixmap_idx) |
| 133 | 142 | { |
| 134 | 143 | phys_addr_t paddr; |
| 135 | 144 | pgprot_t prot; |
| 136 | 145 | |
| 137 | | − paddr = pfn << PAGE_SHIFT; |
| 146 | + paddr = PFN_PHYS(pfn); |
| 138 | 147 | prot = arch_apei_get_mem_attribute(paddr); |
| 139 | | − __set_fixmap(FIX_APEI_GHES_NMI, paddr, prot); |
| 148 | + __set_fixmap(fixmap_idx, paddr, prot); |
| 140 | 149 | |
| 141 | | − return (void __iomem *) fix_to_virt(FIX_APEI_GHES_NMI); |
| 150 | + return (void __iomem *) __fix_to_virt(fixmap_idx); |
| 142 | 151 | } |
| 143 | 152 | |
| 144 | | −static void __iomem *ghes_ioremap_pfn_irq(u64 pfn) |
| 153 | +static void ghes_unmap(void __iomem *vaddr, enum fixed_addresses fixmap_idx) |
| 145 | 154 | { |
| 146 | | − phys_addr_t paddr; |
| 147 | | − pgprot_t prot; |
| 148 | | − |
| 149 | | − paddr = pfn << PAGE_SHIFT; |
| 150 | | − prot = arch_apei_get_mem_attribute(paddr); |
| 151 | | − __set_fixmap(FIX_APEI_GHES_IRQ, paddr, prot); |
| 152 | | − |
| 153 | | − return (void __iomem *) fix_to_virt(FIX_APEI_GHES_IRQ); |
| 154 | | −} |
| 155 | + int _idx = virt_to_fix((unsigned long)vaddr); |
| 155 | 156 | |
| 156 | | −static void ghes_iounmap_nmi(void) |
| 157 | | −{ |
| 158 | | − clear_fixmap(FIX_APEI_GHES_NMI); |
| 157 | + WARN_ON_ONCE(fixmap_idx != _idx); |
| 158 | + clear_fixmap(fixmap_idx); |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | | −static void ghes_iounmap_irq(void) |
| 161 | +int ghes_estatus_pool_init(int num_ghes) |
| 162 | 162 | { |
| 163 | | − clear_fixmap(FIX_APEI_GHES_IRQ); |
| 164 | | −} |
| 163 | + unsigned long addr, len; |
| 165 | 164 | |
| 166 | | −static int ghes_estatus_pool_init(void) |
| 167 | | −{ |
| 168 | 165 | ghes_estatus_pool = gen_pool_create(GHES_ESTATUS_POOL_MIN_ALLOC_ORDER, -1); |
| 169 | 166 | if (!ghes_estatus_pool) |
| 170 | 167 | return -ENOMEM; |
| 171 | | − return 0; |
| 172 | | −} |
| 173 | 168 | |
| 174 | | −static void ghes_estatus_pool_free_chunk_page(struct gen_pool *pool, |
| 175 | | − struct gen_pool_chunk *chunk, |
| 176 | | − void *data) |
| 177 | | −{ |
| 178 | | − free_page(chunk->start_addr); |
| 179 | | −} |
| 180 | | − |
| 181 | | −static void ghes_estatus_pool_exit(void) |
| 182 | | −{ |
| 183 | | − gen_pool_for_each_chunk(ghes_estatus_pool, |
| 184 | | − ghes_estatus_pool_free_chunk_page, NULL); |
| 185 | | − gen_pool_destroy(ghes_estatus_pool); |
| 186 | | −} |
| 169 | + len = GHES_ESTATUS_CACHE_AVG_SIZE * GHES_ESTATUS_CACHE_ALLOCED_MAX; |
| 170 | + len += (num_ghes * GHES_ESOURCE_PREALLOC_MAX_SIZE); |
| 187 | 171 | |
| 188 | | −static int ghes_estatus_pool_expand(unsigned long len) |
| 189 | | −{ |
| 190 | | − unsigned long i, pages, size, addr; |
| 191 | | − int ret; |
| 172 | + ghes_estatus_pool_size_request = PAGE_ALIGN(len); |
| 173 | + addr = (unsigned long)vmalloc(PAGE_ALIGN(len)); |
| 174 | + if (!addr) |
| 175 | + return -ENOMEM; |
| 192 | 176 | |
| 193 | | − ghes_estatus_pool_size_request += PAGE_ALIGN(len); |
| 194 | | − size = gen_pool_size(ghes_estatus_pool); |
| 195 | | − if (size >= ghes_estatus_pool_size_request) |
| 196 | | − return 0; |
| 197 | | − pages = (ghes_estatus_pool_size_request - size) / PAGE_SIZE; |
| 198 | | − for (i = 0; i < pages; i++) { |
| 199 | | − addr = __get_free_page(GFP_KERNEL); |
| 200 | | − if (!addr) |
| 201 | | − return -ENOMEM; |
| 202 | | − ret = gen_pool_add(ghes_estatus_pool, addr, PAGE_SIZE, -1); |
| 203 | | − if (ret) |
| 204 | | − return ret; |
| 205 | | − } |
| 177 | + /* |
| 178 | + * New allocation must be visible in all pgd before it can be found by |
| 179 | + * an NMI allocating from the pool. |
| 180 | + */ |
| 181 | + vmalloc_sync_all(); |
| 206 | 182 | |
| 207 | | − return 0; |
| 183 | + return gen_pool_add(ghes_estatus_pool, addr, PAGE_ALIGN(len), -1); |
| 208 | 184 | } |
| 209 | 185 | |
| 210 | 186 | static int map_gen_v2(struct ghes *ghes) |
| @@ -217,6 +193,21 @@ static void unmap_gen_v2(struct ghes *ghes) · 6 unmodified lines |
| 217 | 193 | apei_unmap_generic_address(&ghes->generic_v2->read_ack_register); |
| 218 | 194 | } |
| 219 | 195 | |
| 196 | +static void ghes_ack_error(struct acpi_hest_generic_v2 *gv2) |
| 197 | +{ |
| 198 | + int rc; |
| 199 | + u64 val = 0; |
| 200 | + |
| 201 | + rc = apei_read(&val, &gv2->read_ack_register); |
| 202 | + if (rc) |
| 203 | + return; |
| 204 | + |
| 205 | + val &= gv2->read_ack_preserve << gv2->read_ack_register.bit_offset; |
| 206 | + val |= gv2->read_ack_write << gv2->read_ack_register.bit_offset; |
| 207 | + |
| 208 | + apei_write(val, &gv2->read_ack_register); |
| 209 | +} |
| 210 | + |
| 220 | 211 | static struct ghes *ghes_new(struct acpi_hest_generic *generic) |
| 221 | 212 | { |
| 222 | 213 | struct ghes *ghes; |
| @@ -289,23 +280,16 @@ static inline int ghes_severity(int severity) · 66 unmodified lines |
| 289 | 280 | } |
| 290 | 281 | |
| 291 | 282 | static void ghes_copy_tofrom_phys(void *buffer, u64 paddr, u32 len, |
| 292 | | − int from_phys) |
| 283 | + int from_phys, |
| 284 | + enum fixed_addresses fixmap_idx) |
| 293 | 285 | { |
| 294 | 286 | void __iomem *vaddr; |
| 295 | | − unsigned long flags = 0; |
| 296 | | − int in_nmi = in_nmi(); |
| 297 | 287 | u64 offset; |
| 298 | 288 | u32 trunk; |
| 299 | 289 | |
| 300 | 290 | while (len > 0) { |
| 301 | 291 | offset = paddr - (paddr & PAGE_MASK); |
| 302 | | − if (in_nmi) { |
| 303 | | − raw_spin_lock(&ghes_ioremap_lock_nmi); |
| 304 | | − vaddr = ghes_ioremap_pfn_nmi(paddr >> PAGE_SHIFT); |
| 305 | | − } else { |
| 306 | | − spin_lock_irqsave(&ghes_ioremap_lock_irq, flags); |
| 307 | | − vaddr = ghes_ioremap_pfn_irq(paddr >> PAGE_SHIFT); |
| 308 | | − } |
| 292 | + vaddr = ghes_map(PHYS_PFN(paddr), fixmap_idx); |
| 309 | 293 | trunk = PAGE_SIZE - offset; |
| 310 | 294 | trunk = min(trunk, len); |
| 311 | 295 | if (from_phys) |
| @@ -315,72 +299,114 @@ static void ghes_copy_tofrom_phys(void *buffer, u64 paddr, u32 len, · 3 unmodified lines |
| 315 | 299 | len -= trunk; |
| 316 | 300 | paddr += trunk; |
| 317 | 301 | buffer += trunk; |
| 318 | | − if (in_nmi) { |
| 319 | | − ghes_iounmap_nmi(); |
| 320 | | − raw_spin_unlock(&ghes_ioremap_lock_nmi); |
| 321 | | − } else { |
| 322 | | − ghes_iounmap_irq(); |
| 323 | | − spin_unlock_irqrestore(&ghes_ioremap_lock_irq, flags); |
| 324 | | − } |
| 302 | + ghes_unmap(vaddr, fixmap_idx); |
| 303 | + } |
| 304 | +} |
| 305 | + |
| 306 | +/* Check the top-level record header has an appropriate size. */ |
| 307 | +static int __ghes_check_estatus(struct ghes *ghes, |
| 308 | + struct acpi_hest_generic_status *estatus) |
| 309 | +{ |
| 310 | + u32 len = cper_estatus_len(estatus); |
| 311 | + |
| 312 | + if (len < sizeof(*estatus)) { |
| 313 | + pr_warn_ratelimited(FW_WARN GHES_PFX "Truncated error status block!\n"); |
| 314 | + return -EIO; |
| 315 | + } |
| 316 | + |
| 317 | + if (len > ghes->generic->error_block_length) { |
| 318 | + pr_warn_ratelimited(FW_WARN GHES_PFX "Invalid error status block length!\n"); |
| 319 | + return -EIO; |
| 320 | + } |
| 321 | + |
| 322 | + if (cper_estatus_check_header(estatus)) { |
| 323 | + pr_warn_ratelimited(FW_WARN GHES_PFX "Invalid CPER header!\n"); |
| 324 | + return -EIO; |
| 325 | 325 | } |
| 326 | + |
| 327 | + return 0; |
| 326 | 328 | } |
| 327 | 329 | |
| 328 | | −static int ghes_read_estatus(struct ghes *ghes, int silent) |
| 330 | +/* Read the CPER block, returning its address, and header in estatus. */ |
| 331 | +static int __ghes_peek_estatus(struct ghes *ghes, |
| 332 | + struct acpi_hest_generic_status *estatus, |
| 333 | + u64 *buf_paddr, enum fixed_addresses fixmap_idx) |
| 329 | 334 | { |
| 330 | 335 | struct acpi_hest_generic *g = ghes->generic; |
| 331 | | − u64 buf_paddr; |
| 332 | | − u32 len; |
| 333 | 336 | int rc; |
| 334 | 337 | |
| 335 | | − rc = apei_read(&buf_paddr, &g->error_status_address); |
| 338 | + rc = apei_read(buf_paddr, &g->error_status_address); |
| 336 | 339 | if (rc) { |
| 337 | | − if (!silent && printk_ratelimit()) |
| 338 | | − pr_warning(FW_WARN GHES_PFX |
| 340 | + *buf_paddr = 0; |
| 341 | + pr_warn_ratelimited(FW_WARN GHES_PFX |
| 339 | 342 | "Failed to read error status block address for hardware error source: %d.\n", |
| 340 | 343 | g->header.source_id); |
| 341 | 344 | return -EIO; |
| 342 | 345 | } |
| 343 | | − if (!buf_paddr) |
| 346 | + if (!*buf_paddr) |
| 344 | 347 | return -ENOENT; |
| 345 | 348 | |
| 346 | | − ghes_copy_tofrom_phys(ghes->estatus, buf_paddr, |
| 347 | | − sizeof(*ghes->estatus), 1); |
| 348 | | − if (!ghes->estatus->block_status) |
| 349 | + ghes_copy_tofrom_phys(estatus, *buf_paddr, sizeof(*estatus), 1, |
| 350 | + fixmap_idx); |
| 351 | + if (!estatus->block_status) { |
| 352 | + *buf_paddr = 0; |
| 349 | 353 | return -ENOENT; |
| 354 | + } |
| 350 | 355 | |
| 351 | | − ghes->buffer_paddr = buf_paddr; |
| 352 | | − ghes->flags |= GHES_TO_CLEAR; |
| 356 | + return __ghes_check_estatus(ghes, estatus); |
| 357 | +} |
| 353 | 358 | |
| 354 | | − rc = -EIO; |
| 355 | | − len = cper_estatus_len(ghes->estatus); |
| 356 | | − if (len < sizeof(*ghes->estatus)) |
| 357 | | − goto err_read_block; |
| 358 | | − if (len > ghes->generic->error_block_length) |
| 359 | | − goto err_read_block; |
| 360 | | − if (cper_estatus_check_header(ghes->estatus)) |
| 361 | | − goto err_read_block; |
| 362 | | − ghes_copy_tofrom_phys(ghes->estatus + 1, |
| 363 | | − buf_paddr + sizeof(*ghes->estatus), |
| 364 | | − len - sizeof(*ghes->estatus), 1); |
| 365 | | − if (cper_estatus_check(ghes->estatus)) |
| 366 | | − goto err_read_block; |
| 367 | | − rc = 0; |
| 368 | | − |
| 369 | | −err_read_block: |
| 370 | | − if (rc && !silent && printk_ratelimit()) |
| 371 | | − pr_warning(FW_WARN GHES_PFX |
| 372 | | − "Failed to read error status block!\n"); |
| 373 | | − return rc; |
| 359 | +static int __ghes_read_estatus(struct acpi_hest_generic_status *estatus, |
| 360 | + u64 buf_paddr, enum fixed_addresses fixmap_idx, |
| 361 | + size_t buf_len) |
| 362 | +{ |
| 363 | + ghes_copy_tofrom_phys(estatus, buf_paddr, buf_len, 1, fixmap_idx); |
| 364 | + if (cper_estatus_check(estatus)) { |
| 365 | + pr_warn_ratelimited(FW_WARN GHES_PFX |
| 366 | + "Failed to read error status block!\n"); |
| 367 | + return -EIO; |
| 368 | + } |
| 369 | + |
| 370 | + return 0; |
| 374 | 371 | } |
| 375 | 372 | |
| 376 | | −static void ghes_clear_estatus(struct ghes *ghes) |
| 373 | +static int ghes_read_estatus(struct ghes *ghes, |
| 374 | + struct acpi_hest_generic_status *estatus, |
| 375 | + u64 *buf_paddr, enum fixed_addresses fixmap_idx) |
| 377 | 376 | { |
| 378 | | − ghes->estatus->block_status = 0; |
| 379 | | − if (!(ghes->flags & GHES_TO_CLEAR)) |
| 377 | + int rc; |
| 378 | + |
| 379 | + rc = __ghes_peek_estatus(ghes, estatus, buf_paddr, fixmap_idx); |
| 380 | + if (rc) |
| 381 | + return rc; |
| 382 | + |
| 383 | + rc = __ghes_check_estatus(ghes, estatus); |
| 384 | + if (rc) |
| 385 | + return rc; |
| 386 | + |
| 387 | + return __ghes_read_estatus(estatus, *buf_paddr, fixmap_idx, |
| 388 | + cper_estatus_len(estatus)); |
| 389 | +} |
| 390 | + |
| 391 | +static void ghes_clear_estatus(struct ghes *ghes, |
| 392 | + struct acpi_hest_generic_status *estatus, |
| 393 | + u64 buf_paddr, enum fixed_addresses fixmap_idx) |
| 394 | +{ |
| 395 | + estatus->block_status = 0; |
| 396 | + |
| 397 | + if (!buf_paddr) |
| 380 | 398 | return; |
| 381 | | − ghes_copy_tofrom_phys(ghes->estatus, ghes->buffer_paddr, |
| 382 | | − sizeof(ghes->estatus->block_status), 0); |
| 383 | | − ghes->flags &= ~GHES_TO_CLEAR; |
| 399 | + |
| 400 | + ghes_copy_tofrom_phys(estatus, buf_paddr, |
| 401 | + sizeof(estatus->block_status), 0, |
| 402 | + fixmap_idx); |
| 403 | + |
| 404 | + /* |
| 405 | + * GHESv2 type HEST entries introduce support for error acknowledgment, |
| 406 | + * so only acknowledge the error if this support is present. |
| 407 | + */ |
| 408 | + if (is_hest_type_generic_v2(ghes)) |
| 409 | + ghes_ack_error(ghes->generic_v2); |
| 384 | 410 | } |
| 385 | 411 | |
| 386 | 412 | static void ghes_handle_memory_failure(struct acpi_hest_generic_data *gdata, int sev) |
| @@ -672,26 +698,13 @@ static void ghes_estatus_cache_add( · 285 unmodified lines |
| 672 | 698 | rcu_read_unlock(); |
| 673 | 699 | } |
| 674 | 700 | |
| 675 | | −static int ghes_ack_error(struct acpi_hest_generic_v2 *gv2) |
| 701 | +static void __ghes_panic(struct ghes *ghes, |
| 702 | + struct acpi_hest_generic_status *estatus, |
| 703 | + u64 buf_paddr, enum fixed_addresses fixmap_idx) |
| 676 | 704 | { |
| 677 | | − int rc; |
| 678 | | − u64 val = 0; |
| 705 | + __ghes_print_estatus(KERN_EMERG, ghes->generic, estatus); |
| 679 | 706 | |
| 680 | | − rc = apei_read(&val, &gv2->read_ack_register); |
| 681 | | − if (rc) |
| 682 | | − return rc; |
| 683 | | − |
| 684 | | − val &= gv2->read_ack_preserve << gv2->read_ack_register.bit_offset; |
| 685 | | − val |= gv2->read_ack_write << gv2->read_ack_register.bit_offset; |
| 686 | | − |
| 687 | | − return apei_write(val, &gv2->read_ack_register); |
| 688 | | −} |
| 689 | | − |
| 690 | | −static void __ghes_panic(struct ghes *ghes) |
| 691 | | −{ |
| 692 | | − __ghes_print_estatus(KERN_EMERG, ghes->generic, ghes->estatus); |
| 693 | | − |
| 694 | | − ghes_clear_estatus(ghes); |
| 707 | + ghes_clear_estatus(ghes, estatus, buf_paddr, fixmap_idx); |
| 695 | 708 | |
| 696 | 709 | /* reboot to log the error! */ |
| 697 | 710 | if (!panic_timeout) |
| @@ -701,34 +714,25 @@ static void __ghes_panic(struct ghes *ghes) · 3 unmodified lines |
| 701 | 714 | |
| 702 | 715 | static int ghes_proc(struct ghes *ghes) |
| 703 | 716 | { |
| 717 | + struct acpi_hest_generic_status *estatus = ghes->estatus; |
| 718 | + u64 buf_paddr; |
| 704 | 719 | int rc; |
| 705 | 720 | |
| 706 | | − rc = ghes_read_estatus(ghes, 0); |
| 721 | + rc = ghes_read_estatus(ghes, estatus, &buf_paddr, FIX_APEI_GHES_IRQ); |
| 707 | 722 | if (rc) |
| 708 | 723 | goto out; |
| 709 | 724 | |
| 710 | | − if (ghes_severity(ghes->estatus->error_severity) >= GHES_SEV_PANIC) { |
| 711 | | − __ghes_panic(ghes); |
| 712 | | − } |
| 725 | + if (ghes_severity(estatus->error_severity) >= GHES_SEV_PANIC) |
| 726 | + __ghes_panic(ghes, estatus, buf_paddr, FIX_APEI_GHES_IRQ); |
| 713 | 727 | |
| 714 | | − if (!ghes_estatus_cached(ghes->estatus)) { |
| 715 | | − if (ghes_print_estatus(NULL, ghes->generic, ghes->estatus)) |
| 716 | | − ghes_estatus_cache_add(ghes->generic, ghes->estatus); |
| 728 | + if (!ghes_estatus_cached(estatus)) { |
| 729 | + if (ghes_print_estatus(NULL, ghes->generic, estatus)) |
| 730 | + ghes_estatus_cache_add(ghes->generic, estatus); |
| 717 | 731 | } |
| 718 | | − ghes_do_proc(ghes, ghes->estatus); |
| 732 | + ghes_do_proc(ghes, estatus); |
| 719 | 733 | |
| 720 | 734 | out: |
| 721 | | − ghes_clear_estatus(ghes); |
| 722 | | − |
| 723 | | − if (rc == -ENOENT) |
| 724 | | − return rc; |
| 725 | | − |
| 726 | | − /* |
| 727 | | − * GHESv2 type HEST entries introduce support for error acknowledgment, |
| 728 | | − * so only acknowledge the error if this support is present. |
| 729 | | − */ |
| 730 | | − if (is_hest_type_generic_v2(ghes)) |
| 731 | | − return ghes_ack_error(ghes->generic_v2); |
| 735 | + ghes_clear_estatus(ghes, estatus, buf_paddr, FIX_APEI_GHES_IRQ); |
| 732 | 736 | |
| 733 | 737 | return rc; |
| 734 | 738 | } |
| @@ -751,8 +755,11 @@ static void ghes_add_timer(struct ghes *ghes) · 16 unmodified lines |
| 751 | 755 | static void ghes_poll_func(struct timer_list *t) |
| 752 | 756 | { |
| 753 | 757 | struct ghes *ghes = from_timer(ghes, t, timer); |
| 758 | + unsigned long flags; |
| 754 | 759 | |
| 760 | + spin_lock_irqsave(&ghes_notify_lock_irq, flags); |
| 755 | 761 | ghes_proc(ghes); |
| 762 | + spin_unlock_irqrestore(&ghes_notify_lock_irq, flags); |
| 756 | 763 | if (!(ghes->flags & GHES_EXITING)) |
| 757 | 764 | ghes_add_timer(ghes); |
| 758 | 765 | } |
| @@ -760,9 +767,12 @@ static void ghes_poll_func(struct timer_list *t) · 1 unmodified line |
| 760 | 767 | static irqreturn_t ghes_irq_func(int irq, void *data) |
| 761 | 768 | { |
| 762 | 769 | struct ghes *ghes = data; |
| 770 | + unsigned long flags; |
| 763 | 771 | int rc; |
| 764 | 772 | |
| 773 | + spin_lock_irqsave(&ghes_notify_lock_irq, flags); |
| 765 | 774 | rc = ghes_proc(ghes); |
| 775 | + spin_unlock_irqrestore(&ghes_notify_lock_irq, flags); |
| 766 | 776 | if (rc) |
| 767 | 777 | return IRQ_NONE; |
| 768 | 778 | |
| @@ -773,14 +783,17 @@ static int ghes_notify_hed(struct notifier_block *this, unsigned long event, · 4 unmodified lines |
| 773 | 783 | void *data) |
| 774 | 784 | { |
| 775 | 785 | struct ghes *ghes; |
| 786 | + unsigned long flags; |
| 776 | 787 | int ret = NOTIFY_DONE; |
| 777 | 788 | |
| 789 | + spin_lock_irqsave(&ghes_notify_lock_irq, flags); |
| 778 | 790 | rcu_read_lock(); |
| 779 | 791 | list_for_each_entry_rcu(ghes, &ghes_hed, list) { |
| 780 | 792 | if (!ghes_proc(ghes)) |
| 781 | 793 | ret = NOTIFY_OK; |
| 782 | 794 | } |
| 783 | 795 | rcu_read_unlock(); |
| 796 | + spin_unlock_irqrestore(&ghes_notify_lock_irq, flags); |
| 784 | 797 | |
| 785 | 798 | return ret; |
| 786 | 799 | } |
| @@ -789,66 +802,20 @@ static struct notifier_block ghes_notifier_hed = { · 2 unmodified lines |
| 789 | 802 | .notifier_call = ghes_notify_hed, |
| 790 | 803 | }; |
| 791 | 804 | |
| 792 | | −#ifdef CONFIG_ACPI_APEI_SEA |
| 793 | | −static LIST_HEAD(ghes_sea); |
| 794 | | − |
| 795 | | −/* |
| 796 | | − * Return 0 only if one of the SEA error sources successfully reported an error |
| 797 | | − * record sent from the firmware. |
| 798 | | − */ |
| 799 | | −int ghes_notify_sea(void) |
| 800 | | −{ |
| 801 | | − struct ghes *ghes; |
| 802 | | − int ret = -ENOENT; |
| 803 | | − |
| 804 | | − rcu_read_lock(); |
| 805 | | − list_for_each_entry_rcu(ghes, &ghes_sea, list) { |
| 806 | | − if (!ghes_proc(ghes)) |
| 807 | | − ret = 0; |
| 808 | | − } |
| 809 | | − rcu_read_unlock(); |
| 810 | | − return ret; |
| 811 | | −} |
| 812 | | − |
| 813 | | −static void ghes_sea_add(struct ghes *ghes) |
| 814 | | −{ |
| 815 | | − mutex_lock(&ghes_list_mutex); |
| 816 | | − list_add_rcu(&ghes->list, &ghes_sea); |
| 817 | | − mutex_unlock(&ghes_list_mutex); |
| 818 | | −} |
| 819 | | − |
| 820 | | −static void ghes_sea_remove(struct ghes *ghes) |
| 821 | | −{ |
| 822 | | − mutex_lock(&ghes_list_mutex); |
| 823 | | − list_del_rcu(&ghes->list); |
| 824 | | − mutex_unlock(&ghes_list_mutex); |
| 825 | | − synchronize_rcu(); |
| 826 | | −} |
| 827 | | −#else /* CONFIG_ACPI_APEI_SEA */ |
| 828 | | −static inline void ghes_sea_add(struct ghes *ghes) { } |
| 829 | | −static inline void ghes_sea_remove(struct ghes *ghes) { } |
| 830 | | −#endif /* CONFIG_ACPI_APEI_SEA */ |
| 831 | | − |
| 832 | | −#ifdef CONFIG_HAVE_ACPI_APEI_NMI |
| 833 | 805 | /* |
| 834 | | − * printk is not safe in NMI context. So in NMI handler, we allocate |
| 835 | | − * required memory from lock-less memory allocator |
| 836 | | − * (ghes_estatus_pool), save estatus into it, put them into lock-less |
| 837 | | − * list (ghes_estatus_llist), then delay printk into IRQ context via |
| 838 | | − * irq_work (ghes_proc_irq_work). ghes_estatus_size_request record |
| 839 | | − * required pool size by all NMI error source. |
| 806 | + * Handlers for CPER records may not be NMI safe. For example, |
| 807 | + * memory_failure_queue() takes spinlocks and calls schedule_work_on(). |
| 808 | + * In any NMI-like handler, memory from ghes_estatus_pool is used to save |
| 809 | + * estatus, and added to the ghes_estatus_llist. irq_work_queue() causes |
| 810 | + * ghes_proc_in_irq() to run in IRQ context where each estatus in |
| 811 | + * ghes_estatus_llist is processed. |
| 812 | + * |
| 813 | + * Memory from the ghes_estatus_pool is also used with the ghes_estatus_cache |
| 814 | + * to suppress frequent messages. |
| 840 | 815 | */ |
| 841 | 816 | static struct llist_head ghes_estatus_llist; |
| 842 | 817 | static struct irq_work ghes_proc_irq_work; |
| 843 | 818 | |
| 844 | | −/* |
| 845 | | − * NMI may be triggered on any CPU, so ghes_in_nmi is used for |
| 846 | | − * having only one concurrent reader. |
| 847 | | − */ |
| 848 | | −static atomic_t ghes_in_nmi = ATOMIC_INIT(0); |
| 849 | | − |
| 850 | | −static LIST_HEAD(ghes_nmi); |
| 851 | | − |
| 852 | 819 | static void ghes_proc_in_irq(struct irq_work *irq_work) |
| 853 | 820 | { |
| 854 | 821 | struct llist_node *llnode, *next; |
| @@ -905,96 +872,154 @@ static void ghes_print_queued_estatus(void) · 50 unmodified lines |
| 905 | 872 | } |
| 906 | 873 | } |
| 907 | 874 | |
| 908 | | −/* Save estatus for further processing in IRQ context */ |
| 909 | | −static void __process_error(struct ghes *ghes) |
| 875 | +static int ghes_in_nmi_queue_one_entry(struct ghes *ghes, |
| 876 | + enum fixed_addresses fixmap_idx) |
| 910 | 877 | { |
| 911 | | −#ifdef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG |
| 912 | | − u32 len, node_len; |
| 878 | + struct acpi_hest_generic_status *estatus, tmp_header; |
| 913 | 879 | struct ghes_estatus_node *estatus_node; |
| 914 | | − struct acpi_hest_generic_status *estatus; |
| 880 | + u32 len, node_len; |
| 881 | + u64 buf_paddr; |
| 882 | + int sev, rc; |
| 915 | 883 | |
| 916 | | − if (ghes_estatus_cached(ghes->estatus)) |
| 917 | | − return; |
| 884 | + if (!IS_ENABLED(CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG)) |
| 885 | + return -EOPNOTSUPP; |
| 918 | 886 | |
| 919 | | − len = cper_estatus_len(ghes->estatus); |
| 920 | | − node_len = GHES_ESTATUS_NODE_LEN(len); |
| 887 | + rc = __ghes_peek_estatus(ghes, &tmp_header, &buf_paddr, fixmap_idx); |
| 888 | + if (rc) { |
| 889 | + ghes_clear_estatus(ghes, &tmp_header, buf_paddr, fixmap_idx); |
| 890 | + return rc; |
| 891 | + } |
| 921 | 892 | |
| 893 | + rc = __ghes_check_estatus(ghes, &tmp_header); |
| 894 | + if (rc) { |
| 895 | + ghes_clear_estatus(ghes, &tmp_header, buf_paddr, fixmap_idx); |
| 896 | + return rc; |
| 897 | + } |
| 898 | + |
| 899 | + len = cper_estatus_len(&tmp_header); |
| 900 | + node_len = GHES_ESTATUS_NODE_LEN(len); |
| 922 | 901 | estatus_node = (void *)gen_pool_alloc(ghes_estatus_pool, node_len); |
| 923 | 902 | if (!estatus_node) |
| 924 | | − return; |
| 903 | + return -ENOMEM; |
| 925 | 904 | |
| 926 | 905 | estatus_node->ghes = ghes; |
| 927 | 906 | estatus_node->generic = ghes->generic; |
| 928 | 907 | estatus = GHES_ESTATUS_FROM_NODE(estatus_node); |
| 929 | | − memcpy(estatus, ghes->estatus, len); |
| 930 | | − llist_add(&estatus_node->llnode, &ghes_estatus_llist); |
| 931 | | −#endif |
| 932 | | −} |
| 933 | 908 | |
| 934 | | −static int ghes_notify_nmi(unsigned int cmd, struct pt_regs *regs) |
| 935 | | −{ |
| 936 | | − struct ghes *ghes; |
| 937 | | − int sev, ret = NMI_DONE; |
| 909 | + if (__ghes_read_estatus(estatus, buf_paddr, fixmap_idx, len)) { |
| 910 | + ghes_clear_estatus(ghes, estatus, buf_paddr, fixmap_idx); |
| 911 | + rc = -ENOENT; |
| 912 | + goto no_work; |
| 913 | + } |
| 938 | 914 | |
| 939 | | − if (!atomic_add_unless(&ghes_in_nmi, 1, 1)) |
| 940 | | − return ret; |
| 915 | + sev = ghes_severity(estatus->error_severity); |
| 916 | + if (sev >= GHES_SEV_PANIC) { |
| 917 | + ghes_print_queued_estatus(); |
| 918 | + __ghes_panic(ghes, estatus, buf_paddr, fixmap_idx); |
| 919 | + } |
| 941 | 920 | |
| 942 | | − list_for_each_entry_rcu(ghes, &ghes_nmi, list) { |
| 943 | | − if (ghes_read_estatus(ghes, 1)) { |
| 944 | | − ghes_clear_estatus(ghes); |
| 945 | | − continue; |
| 946 | | − } else { |
| 947 | | − ret = NMI_HANDLED; |
| 948 | | − } |
| 921 | + ghes_clear_estatus(ghes, &tmp_header, buf_paddr, fixmap_idx); |
| 949 | 922 | |
| 950 | | − sev = ghes_severity(ghes->estatus->error_severity); |
| 951 | | − if (sev >= GHES_SEV_PANIC) { |
| 952 | | − oops_begin(); |
| 953 | | − ghes_print_queued_estatus(); |
| 954 | | − __ghes_panic(ghes); |
| 955 | | − } |
| 923 | + /* This error has been reported before, don't process it again. */ |
| 924 | + if (ghes_estatus_cached(estatus)) |
| 925 | + goto no_work; |
| 956 | 926 | |
| 957 | | − if (!(ghes->flags & GHES_TO_CLEAR)) |
| 958 | | − continue; |
| 927 | + llist_add(&estatus_node->llnode, &ghes_estatus_llist); |
| 928 | + |
| 929 | + return rc; |
| 930 | + |
| 931 | +no_work: |
| 932 | + gen_pool_free(ghes_estatus_pool, (unsigned long)estatus_node, |
| 933 | + node_len); |
| 934 | + |
| 935 | + return rc; |
| 936 | +} |
| 959 | 937 | |
| 960 | | − __process_error(ghes); |
| 961 | | − ghes_clear_estatus(ghes); |
| 938 | +static int ghes_in_nmi_spool_from_list(struct list_head *rcu_list, |
| 939 | + enum fixed_addresses fixmap_idx) |
| 940 | +{ |
| 941 | + int ret = -ENOENT; |
| 942 | + struct ghes *ghes; |
| 943 | + |
| 944 | + rcu_read_lock(); |
| 945 | + list_for_each_entry_rcu(ghes, rcu_list, list) { |
| 946 | + if (!ghes_in_nmi_queue_one_entry(ghes, fixmap_idx)) |
| 947 | + ret = 0; |
| 962 | 948 | } |
| 949 | + rcu_read_unlock(); |
| 963 | 950 | |
| 964 | | −#ifdef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG |
| 965 | | − if (ret == NMI_HANDLED) |
| 951 | + if (IS_ENABLED(CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG) && !ret) |
| 966 | 952 | irq_work_queue(&ghes_proc_irq_work); |
| 967 | | −#endif |
| 968 | | − atomic_dec(&ghes_in_nmi); |
| 953 | + |
| 969 | 954 | return ret; |
| 970 | 955 | } |
| 971 | 956 | |
| 972 | | −static unsigned long ghes_esource_prealloc_size( |
| 973 | | − const struct acpi_hest_generic *generic) |
| 957 | +#ifdef CONFIG_ACPI_APEI_SEA |
| 958 | +static LIST_HEAD(ghes_sea); |
| 959 | + |
| 960 | +/* |
| 961 | + * Return 0 only if one of the SEA error sources successfully reported an error |
| 962 | + * record sent from the firmware. |
| 963 | + */ |
| 964 | +int ghes_notify_sea(void) |
| 974 | 965 | { |
| 975 | | − unsigned long block_length, prealloc_records, prealloc_size; |
| 966 | + static DEFINE_RAW_SPINLOCK(ghes_notify_lock_sea); |
| 967 | + int rv; |
| 976 | 968 | |
| 977 | | − block_length = min_t(unsigned long, generic->error_block_length, |
| 978 | | − GHES_ESTATUS_MAX_SIZE); |
| 979 | | − prealloc_records = max_t(unsigned long, |
| 980 | | − generic->records_to_preallocate, 1); |
| 981 | | − prealloc_size = min_t(unsigned long, block_length * prealloc_records, |
| 982 | | − GHES_ESOURCE_PREALLOC_MAX_SIZE); |
| 969 | + raw_spin_lock(&ghes_notify_lock_sea); |
| 970 | + rv = ghes_in_nmi_spool_from_list(&ghes_sea, FIX_APEI_GHES_SEA); |
| 971 | + raw_spin_unlock(&ghes_notify_lock_sea); |
| 983 | 972 | |
| 984 | | − return prealloc_size; |
| 973 | + return rv; |
| 985 | 974 | } |
| 986 | 975 | |
| 987 | | −static void ghes_estatus_pool_shrink(unsigned long len) |
| 976 | +static void ghes_sea_add(struct ghes *ghes) |
| 988 | 977 | { |
| 989 | | − ghes_estatus_pool_size_request -= PAGE_ALIGN(len); |
| 978 | + mutex_lock(&ghes_list_mutex); |
| 979 | + list_add_rcu(&ghes->list, &ghes_sea); |
| 980 | + mutex_unlock(&ghes_list_mutex); |
| 990 | 981 | } |
| 991 | 982 | |
| 992 | | −static void ghes_nmi_add(struct ghes *ghes) |
| 983 | +static void ghes_sea_remove(struct ghes *ghes) |
| 993 | 984 | { |
| 994 | | − unsigned long len; |
| 985 | + mutex_lock(&ghes_list_mutex); |
| 986 | + list_del_rcu(&ghes->list); |
| 987 | + mutex_unlock(&ghes_list_mutex); |
| 988 | + synchronize_rcu(); |
| 989 | +} |
| 990 | +#else /* CONFIG_ACPI_APEI_SEA */ |
| 991 | +static inline void ghes_sea_add(struct ghes *ghes) { } |
| 992 | +static inline void ghes_sea_remove(struct ghes *ghes) { } |
| 993 | +#endif /* CONFIG_ACPI_APEI_SEA */ |
| 994 | + |
| 995 | +#ifdef CONFIG_HAVE_ACPI_APEI_NMI |
| 996 | +/* |
| 997 | + * NMI may be triggered on any CPU, so ghes_in_nmi is used for |
| 998 | + * having only one concurrent reader. |
| 999 | + */ |
| 1000 | +static atomic_t ghes_in_nmi = ATOMIC_INIT(0); |
| 1001 | + |
| 1002 | +static LIST_HEAD(ghes_nmi); |
| 1003 | + |
| 1004 | +static int ghes_notify_nmi(unsigned int cmd, struct pt_regs *regs) |
| 1005 | +{ |
| 1006 | + static DEFINE_RAW_SPINLOCK(ghes_notify_lock_nmi); |
| 1007 | + int ret = NMI_DONE; |
| 1008 | + |
| 1009 | + if (!atomic_add_unless(&ghes_in_nmi, 1, 1)) |
| 1010 | + return ret; |
| 1011 | + |
| 1012 | + raw_spin_lock(&ghes_notify_lock_nmi); |
| 1013 | + if (!ghes_in_nmi_spool_from_list(&ghes_nmi, FIX_APEI_GHES_NMI)) |
| 1014 | + ret = NMI_HANDLED; |
| 1015 | + raw_spin_unlock(&ghes_notify_lock_nmi); |
| 995 | 1016 | |
| 996 | | − len = ghes_esource_prealloc_size(ghes->generic); |
| 997 | | − ghes_estatus_pool_expand(len); |
| 1017 | + atomic_dec(&ghes_in_nmi); |
| 1018 | + return ret; |
| 1019 | +} |
| 1020 | + |
| 1021 | +static void ghes_nmi_add(struct ghes *ghes) |
| 1022 | +{ |
| 998 | 1023 | mutex_lock(&ghes_list_mutex); |
| 999 | 1024 | if (list_empty(&ghes_nmi)) |
| 1000 | 1025 | register_nmi_handler(NMI_LOCAL, ghes_notify_nmi, 0, "ghes"); |
| @@ -1004,8 +1029,6 @@ static void ghes_nmi_add(struct ghes *ghes) · 3 unmodified lines |
| 1004 | 1029 | |
| 1005 | 1030 | static void ghes_nmi_remove(struct ghes *ghes) |
| 1006 | 1031 | { |
| 1007 | | − unsigned long len; |
| 1008 | | − |
| 1009 | 1032 | mutex_lock(&ghes_list_mutex); |
| 1010 | 1033 | list_del_rcu(&ghes->list); |
| 1011 | 1034 | if (list_empty(&ghes_nmi)) |
| @@ -1016,24 +1039,79 @@ static void ghes_nmi_remove(struct ghes *ghes) · 4 unmodified lines |
| 1016 | 1039 | * freed after NMI handler finishes. |
| 1017 | 1040 | */ |
| 1018 | 1041 | synchronize_rcu(); |
| 1019 | | − len = ghes_esource_prealloc_size(ghes->generic); |
| 1020 | | − ghes_estatus_pool_shrink(len); |
| 1021 | 1042 | } |
| 1043 | +#else /* CONFIG_HAVE_ACPI_APEI_NMI */ |
| 1044 | +static inline void ghes_nmi_add(struct ghes *ghes) { } |
| 1045 | +static inline void ghes_nmi_remove(struct ghes *ghes) { } |
| 1046 | +#endif /* CONFIG_HAVE_ACPI_APEI_NMI */ |
| 1022 | 1047 | |
| 1023 | 1048 | static void ghes_nmi_init_cxt(void) |
| 1024 | 1049 | { |
| 1025 | 1050 | init_irq_work(&ghes_proc_irq_work, ghes_proc_in_irq); |
| 1026 | 1051 | } |
| 1027 | | −#else /* CONFIG_HAVE_ACPI_APEI_NMI */ |
| 1028 | | −static inline void ghes_nmi_add(struct ghes *ghes) { } |
| 1029 | | −static inline void ghes_nmi_remove(struct ghes *ghes) { } |
| 1030 | | −static inline void ghes_nmi_init_cxt(void) { } |
| 1031 | | −#endif /* CONFIG_HAVE_ACPI_APEI_NMI */ |
| 1052 | + |
| 1053 | +static int __ghes_sdei_callback(struct ghes *ghes, |
| 1054 | + enum fixed_addresses fixmap_idx) |
| 1055 | +{ |
| 1056 | + if (!ghes_in_nmi_queue_one_entry(ghes, fixmap_idx)) { |
| 1057 | + irq_work_queue(&ghes_proc_irq_work); |
| 1058 | + |
| 1059 | + return 0; |
| 1060 | + } |
| 1061 | + |
| 1062 | + return -ENOENT; |
| 1063 | +} |
| 1064 | + |
| 1065 | +static int ghes_sdei_normal_callback(u32 event_num, struct pt_regs *regs, |
| 1066 | + void *arg) |
| 1067 | +{ |
| 1068 | + static DEFINE_RAW_SPINLOCK(ghes_notify_lock_sdei_normal); |
| 1069 | + struct ghes *ghes = arg; |
| 1070 | + int err; |
| 1071 | + |
| 1072 | + raw_spin_lock(&ghes_notify_lock_sdei_normal); |
| 1073 | + err = __ghes_sdei_callback(ghes, FIX_APEI_GHES_SDEI_NORMAL); |
| 1074 | + raw_spin_unlock(&ghes_notify_lock_sdei_normal); |
| 1075 | + |
| 1076 | + return err; |
| 1077 | +} |
| 1078 | + |
| 1079 | +static int ghes_sdei_critical_callback(u32 event_num, struct pt_regs *regs, |
| 1080 | + void *arg) |
| 1081 | +{ |
| 1082 | + static DEFINE_RAW_SPINLOCK(ghes_notify_lock_sdei_critical); |
| 1083 | + struct ghes *ghes = arg; |
| 1084 | + int err; |
| 1085 | + |
| 1086 | + raw_spin_lock(&ghes_notify_lock_sdei_critical); |
| 1087 | + err = __ghes_sdei_callback(ghes, FIX_APEI_GHES_SDEI_CRITICAL); |
| 1088 | + raw_spin_unlock(&ghes_notify_lock_sdei_critical); |
| 1089 | + |
| 1090 | + return err; |
| 1091 | +} |
| 1092 | + |
| 1093 | +static int apei_sdei_register_ghes(struct ghes *ghes) |
| 1094 | +{ |
| 1095 | + if (!IS_ENABLED(CONFIG_ARM_SDE_INTERFACE)) |
| 1096 | + return -EOPNOTSUPP; |
| 1097 | + |
| 1098 | + return sdei_register_ghes(ghes, ghes_sdei_normal_callback, |
| 1099 | + ghes_sdei_critical_callback); |
| 1100 | +} |
| 1101 | + |
| 1102 | +static int apei_sdei_unregister_ghes(struct ghes *ghes) |
| 1103 | +{ |
| 1104 | + if (!IS_ENABLED(CONFIG_ARM_SDE_INTERFACE)) |
| 1105 | + return -EOPNOTSUPP; |
| 1106 | + |
| 1107 | + return sdei_unregister_ghes(ghes); |
| 1108 | +} |
| 1032 | 1109 | |
| 1033 | 1110 | static int ghes_probe(struct platform_device *ghes_dev) |
| 1034 | 1111 | { |
| 1035 | 1112 | struct acpi_hest_generic *generic; |
| 1036 | 1113 | struct ghes *ghes = NULL; |
| 1114 | + unsigned long flags; |
| 1037 | 1115 | |
| 1038 | 1116 | int rc = -EINVAL; |
| 1039 | 1117 | |
| @@ -1064,6 +1142,13 @@ static int ghes_probe(struct platform_device *ghes_dev) · 24 unmodified lines |
| 1064 | 1142 | goto err; |
| 1065 | 1143 | } |
| 1066 | 1144 | break; |
| 1145 | + case ACPI_HEST_NOTIFY_SOFTWARE_DELEGATED: |
| 1146 | + if (!IS_ENABLED(CONFIG_ARM_SDE_INTERFACE)) { |
| 1147 | + pr_warn(GHES_PFX "Generic hardware error source: %d notified via SDE Interface is not supported!\n", |
| 1148 | + generic->header.source_id); |
| 1149 | + goto err; |
| 1150 | + } |
| 1151 | + break; |
| 1067 | 1152 | case ACPI_HEST_NOTIFY_LOCAL: |
| 1068 | 1153 | pr_warning(GHES_PFX "Generic hardware error source: %d notified via local interrupt is not supported!\n", |
| 1069 | 1154 | generic->header.source_id); |
| @@ -1127,6 +1212,11 @@ static int ghes_probe(struct platform_device *ghes_dev) · 57 unmodified lines |
| 1127 | 1212 | case ACPI_HEST_NOTIFY_NMI: |
| 1128 | 1213 | ghes_nmi_add(ghes); |
| 1129 | 1214 | break; |
| 1215 | + case ACPI_HEST_NOTIFY_SOFTWARE_DELEGATED: |
| 1216 | + rc = apei_sdei_register_ghes(ghes); |
| 1217 | + if (rc) |
| 1218 | + goto err; |
| 1219 | + break; |
| 1130 | 1220 | default: |
| 1131 | 1221 | BUG(); |
| 1132 | 1222 | } |
| @@ -1136,7 +1226,9 @@ static int ghes_probe(struct platform_device *ghes_dev) · 3 unmodified lines |
| 1136 | 1226 | ghes_edac_register(ghes, &ghes_dev->dev); |
| 1137 | 1227 | |
| 1138 | 1228 | /* Handle any pending errors right away */ |
| 1229 | + spin_lock_irqsave(&ghes_notify_lock_irq, flags); |
| 1139 | 1230 | ghes_proc(ghes); |
| 1231 | + spin_unlock_irqrestore(&ghes_notify_lock_irq, flags); |
| 1140 | 1232 | |
| 1141 | 1233 | return 0; |
| 1142 | 1234 | |
| @@ -1150,6 +1242,7 @@ err: · 7 unmodified lines |
| 1150 | 1242 | |
| 1151 | 1243 | static int ghes_remove(struct platform_device *ghes_dev) |
| 1152 | 1244 | { |
| 1245 | + int rc; |
| 1153 | 1246 | struct ghes *ghes; |
| 1154 | 1247 | struct acpi_hest_generic *generic; |
| 1155 | 1248 | |
| @@ -1182,6 +1275,11 @@ static int ghes_remove(struct platform_device *ghes_dev) · 26 unmodified lines |
| 1182 | 1275 | case ACPI_HEST_NOTIFY_NMI: |
| 1183 | 1276 | ghes_nmi_remove(ghes); |
| 1184 | 1277 | break; |
| 1278 | + case ACPI_HEST_NOTIFY_SOFTWARE_DELEGATED: |
| 1279 | + rc = apei_sdei_unregister_ghes(ghes); |
| 1280 | + if (rc) |
| 1281 | + return rc; |
| 1282 | + break; |
| 1185 | 1283 | default: |
| 1186 | 1284 | BUG(); |
| 1187 | 1285 | break; |
| @@ -1230,18 +1328,9 @@ static int __init ghes_init(void) · 42 unmodified lines |
| 1230 | 1328 | |
| 1231 | 1329 | ghes_nmi_init_cxt(); |
| 1232 | 1330 | |
| 1233 | | − rc = ghes_estatus_pool_init(); |
| 1234 | | − if (rc) |
| 1235 | | − goto err; |
| 1236 | | − |
| 1237 | | − rc = ghes_estatus_pool_expand(GHES_ESTATUS_CACHE_AVG_SIZE * |
| 1238 | | − GHES_ESTATUS_CACHE_ALLOCED_MAX); |
| 1239 | | − if (rc) |
| 1240 | | − goto err_pool_exit; |
| 1241 | | − |
| 1242 | 1331 | rc = platform_driver_register(&ghes_platform_driver); |
| 1243 | 1332 | if (rc) |
| 1244 | | − goto err_pool_exit; |
| 1333 | + goto err; |
| 1245 | 1334 | |
| 1246 | 1335 | rc = apei_osc_setup(); |
| 1247 | 1336 | if (rc == 0 && osc_sb_apei_support_acked) |
| @@ -1254,8 +1343,6 @@ static int __init ghes_init(void) · 6 unmodified lines |
| 1254 | 1343 | pr_info(GHES_PFX "Failed to enable APEI firmware first mode.\n"); |
| 1255 | 1344 | |
| 1256 | 1345 | return 0; |
| 1257 | | −err_pool_exit: |
| 1258 | | − ghes_estatus_pool_exit(); |
| 1259 | 1346 | err: |
| 1260 | 1347 | return rc; |
| 1261 | 1348 | } |