Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 | |
| 3 | #include <soc/acpi.h> |
| 4 | #include <soc/numa.h> |
| 5 | #include <soc/util.h> |
| 6 | |
| 7 | unsigned long cxl_fill_srat(unsigned long current) |
| 8 | { |
| 9 | /* |
| 10 | * Create Generic Initiator Affinity structure |
| 11 | * and Memory Affinity structure for CXL memory. |
| 12 | * In the pds (Proximity Domains structure), Generic Initiator domains |
| 13 | * are after processor domains. |
| 14 | */ |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 15 | uint32_t base, size; |
| 16 | for (uint8_t i = soc_get_num_cpus(); i < pds.num_pds; i++) { |
Patrick Rudolph | 344ebf1 | 2024-01-31 11:38:38 +0100 | [diff] [blame^] | 17 | if (!pds.pds[i].dev) |
| 18 | continue; |
| 19 | |
| 20 | printk(BIOS_DEBUG, "adding srat GIA ID: %d, dev: %s\n", i, dev_path(pds.pds[i].dev)); |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 21 | /* flags: 1 (enabled) */ |
Patrick Rudolph | 344ebf1 | 2024-01-31 11:38:38 +0100 | [diff] [blame^] | 22 | current += acpi_create_srat_gia_pci((acpi_srat_gia_t *)current, i, pds.pds[i].dev, 1); |
Tim Chu | 5c19640 | 2022-12-13 12:09:44 +0000 | [diff] [blame] | 23 | base = pds.pds[i].base << 16; |
| 24 | size = pds.pds[i].size << 16; |
| 25 | printk(BIOS_DEBUG, |
| 26 | "adding srat MEM affinity domain: %d, base: 0x%x, size: 0x%x\n", i, base, |
| 27 | size); |
| 28 | current += |
| 29 | acpi_create_srat_mem((acpi_srat_mem_t *)current, i, |
| 30 | pds.pds[i].base << 16, pds.pds[i].size << 16, 1); |
| 31 | } |
| 32 | |
| 33 | return current; |
| 34 | } |
| 35 | |
| 36 | /* |
| 37 | * The current kernel does not use HMAT table. |
| 38 | */ |
| 39 | unsigned long acpi_fill_hmat(unsigned long current) |
| 40 | { |
| 41 | uint32_t pd_initiator = 0; |
| 42 | uint32_t pd_memory = 0; |
| 43 | |
| 44 | /* In CXL2.0, CXL memories attached to different sockets could be ganged |
| 45 | * to form a single CXL memory region. |
| 46 | * For now, we do not consider this case, and assume socket_bitmap has |
| 47 | * only one bit set, eg. a CXL memory region is attached to one socket. |
| 48 | */ |
| 49 | uint8_t j; |
| 50 | for (uint8_t i = soc_get_num_cpus(); i < pds.num_pds; i++) { |
| 51 | pd_memory = i; |
| 52 | /* check socket_bitmap which is type uint8_t */ |
| 53 | for (j = 0; j < 8; j++) |
| 54 | if ((pds.pds[i].socket_bitmap >> j) == 0) |
| 55 | break; |
| 56 | pd_initiator = j - 1; |
| 57 | printk(BIOS_DEBUG, "HMAT: pd_initiator = %d, pd_memory = %d\n", pd_initiator, |
| 58 | pd_memory); |
| 59 | current += acpi_create_hmat_mpda((acpi_hmat_mpda_t *)current, pd_initiator, |
| 60 | pd_memory); |
| 61 | } |
| 62 | |
| 63 | /* |
| 64 | * We created only MPDA structure. In future, we could create |
| 65 | * SLLBI structure to describe latency/bandwidth info when such info |
| 66 | * is available. |
| 67 | */ |
| 68 | |
| 69 | return current; |
| 70 | } |