Remi Pommarel | 07e1e9e | 2019-07-14 20:49:12 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2019 Repk repk@triplefau.lt |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * https://spdx.org/licenses |
| 6 | */ |
Scott Branden | e5dcf98 | 2020-08-25 13:49:32 -0700 | [diff] [blame] | 7 | |
| 8 | #include <inttypes.h> |
| 9 | #include <stdint.h> |
| 10 | |
Remi Pommarel | 07e1e9e | 2019-07-14 20:49:12 +0200 | [diff] [blame] | 11 | #include <common/bl_common.h> |
| 12 | #include <common/debug.h> |
| 13 | #include <arch_helpers.h> |
Pali Rohár | c36e97f | 2021-06-21 17:22:27 +0200 | [diff] [blame] | 14 | #include <plat/common/platform.h> |
Pali Rohár | 8383db2 | 2021-06-26 16:26:56 +0200 | [diff] [blame] | 15 | #include <bl31/ea_handle.h> |
Remi Pommarel | 07e1e9e | 2019-07-14 20:49:12 +0200 | [diff] [blame] | 16 | |
Pali Rohár | 8383db2 | 2021-06-26 16:26:56 +0200 | [diff] [blame] | 17 | #define A53_SERR_INT_AXI_SLVERR_ON_EXTERNAL_ACCESS 0xbf000002 |
| 18 | |
Pali Rohár | 76f3849 | 2021-07-09 15:10:27 +0200 | [diff] [blame] | 19 | /* |
| 20 | * This source file with custom plat_ea_handler function is compiled only when |
Manish Pandey | 0e3379d | 2022-10-10 11:43:08 +0100 | [diff] [blame] | 21 | * building TF-A with compile option HANDLE_EA_EL3_FIRST_NS=1 |
Pali Rohár | 76f3849 | 2021-07-09 15:10:27 +0200 | [diff] [blame] | 22 | */ |
Remi Pommarel | 07e1e9e | 2019-07-14 20:49:12 +0200 | [diff] [blame] | 23 | void plat_ea_handler(unsigned int ea_reason, uint64_t syndrome, void *cookie, |
| 24 | void *handle, uint64_t flags) |
| 25 | { |
Pali Rohár | 8383db2 | 2021-06-26 16:26:56 +0200 | [diff] [blame] | 26 | unsigned int level = (unsigned int)GET_EL(read_spsr_el3()); |
| 27 | |
| 28 | /* |
| 29 | * Asynchronous External Abort with syndrome 0xbf000002 on Cortex A53 |
| 30 | * core means SError interrupt caused by AXI SLVERR on external access. |
| 31 | * |
| 32 | * In most cases this indicates a bug in U-Boot or Linux kernel driver |
| 33 | * pci-aardvark.c which implements access to A3700 PCIe config space. |
| 34 | * Driver does not wait for PCIe PIO transfer completion and try to |
| 35 | * start a new PCIe PIO transfer while previous has not finished yet. |
| 36 | * A3700 PCIe controller in this case sends SLVERR via AXI which results |
| 37 | * in a fatal Asynchronous SError interrupt on Cortex A53 CPU. |
| 38 | * |
| 39 | * Following patches fix that bug in U-Boot and Linux kernel drivers: |
| 40 | * https://source.denx.de/u-boot/u-boot/-/commit/eccbd4ad8e4e182638eafbfb87ac139c04f24a01 |
| 41 | * https://git.kernel.org/stable/c/f18139966d072dab8e4398c95ce955a9742e04f7 |
| 42 | * |
| 43 | * As a hacky workaround for unpatched U-Boot and Linux kernel drivers |
| 44 | * ignore all asynchronous aborts with that syndrome value received on |
| 45 | * CPU from level lower than EL3. |
| 46 | * |
| 47 | * Because these aborts are delivered on CPU asynchronously, they are |
| 48 | * imprecise and we cannot check the real reason of abort and neither |
| 49 | * who and why sent this abort. We expect that on A3700 it is always |
| 50 | * PCIe controller. |
| 51 | * |
| 52 | * Hence ignoring all aborts with this syndrome value is just a giant |
| 53 | * hack that we need only because of bugs in old U-Boot and Linux kernel |
| 54 | * versions and because it was decided that TF-A would implement this |
| 55 | * hack for U-Boot and Linux kernel it in this way. New patched U-Boot |
| 56 | * and kernel versions do not need it anymore. |
| 57 | * |
| 58 | * Links to discussion about this workaround: |
| 59 | * https://lore.kernel.org/linux-pci/20190316161243.29517-1-repk@triplefau.lt/ |
| 60 | * https://lore.kernel.org/linux-pci/971be151d24312cc533989a64bd454b4@www.loen.fr/ |
| 61 | * https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/1541 |
| 62 | */ |
| 63 | if (level < MODE_EL3 && ea_reason == ERROR_EA_ASYNC && |
| 64 | syndrome == A53_SERR_INT_AXI_SLVERR_ON_EXTERNAL_ACCESS) { |
| 65 | ERROR_NL(); |
| 66 | ERROR("Ignoring Asynchronous External Abort with" |
Scott Branden | e5dcf98 | 2020-08-25 13:49:32 -0700 | [diff] [blame] | 67 | " syndrome 0x%" PRIx64 " received on 0x%lx from %s\n", |
Pali Rohár | 8383db2 | 2021-06-26 16:26:56 +0200 | [diff] [blame] | 68 | syndrome, read_mpidr_el1(), get_el_str(level)); |
| 69 | ERROR("SError interrupt: AXI SLVERR on external access\n"); |
| 70 | ERROR("This indicates a bug in pci-aardvark.c driver\n"); |
| 71 | ERROR("Please update U-Boot/Linux to the latest version\n"); |
| 72 | ERROR_NL(); |
| 73 | console_flush(); |
Pali Rohár | c36e97f | 2021-06-21 17:22:27 +0200 | [diff] [blame] | 74 | return; |
Pali Rohár | 8383db2 | 2021-06-26 16:26:56 +0200 | [diff] [blame] | 75 | } |
Pali Rohár | c36e97f | 2021-06-21 17:22:27 +0200 | [diff] [blame] | 76 | |
| 77 | plat_default_ea_handler(ea_reason, syndrome, cookie, handle, flags); |
Remi Pommarel | 07e1e9e | 2019-07-14 20:49:12 +0200 | [diff] [blame] | 78 | } |