Skip to content

Commit fd4f172

Browse files
raoqsgmrphilcox
authored andcommitted
tcc: parse PTCT table and record pesudo sram ranges
BugLink: https://bugs.launchpad.net/bugs/1929903 ([EHL][TGL][ADL][ICX] Enable Time Coordinated Compute interface driver (LP: #1929903)) ACPI may include PTCT table. If PTCT is included, this table need to be parsed and records all pesudo SRAM ranges indicated in the table. These pesudo SRAM should be marked as cacheable for the tcc feature. If PTCT is not found in ACPI, nothing will be changed. Signed-off-by: Qiang Rao <qiang.rao@intel.com> Signed-off-by: Brad Figg <brad.figg@canonical.com> (cherry picked from commit 7a465b625598db178ea03b77f2c9197bd43fd8d0/linux-intel-5.13) Signed-off-by: Philip Cox <philip.cox@canonical.com>
1 parent 1d04d92 commit fd4f172

File tree

2 files changed

+149
-0
lines changed

2 files changed

+149
-0
lines changed

arch/x86/kernel/acpi/boot.c

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,6 +1218,96 @@ static inline int acpi_parse_madt_ioapic_entries(void)
12181218
}
12191219
#endif /* !CONFIG_X86_IO_APIC */
12201220

1221+
/*
1222+
* Parse pSRAM entry in PTCT
1223+
* Update PAT cache attribute configuration range
1224+
*/
1225+
static struct ptct_psram_region ptct_psram_regions[MAX_PSRAM_REGIONS];
1226+
static u32 total_psram_region;
1227+
1228+
static inline bool is_TCC_range(u64 start, u64 end)
1229+
{
1230+
int i;
1231+
1232+
if (!ptct_psram_regions)
1233+
return false;
1234+
1235+
for (i = 0; i < total_psram_region; i++) {
1236+
if ((start >= ptct_psram_regions[i].phyaddr_start) &&
1237+
(end <= ptct_psram_regions[i].phyaddr_end))
1238+
return true;
1239+
}
1240+
return false;
1241+
}
1242+
1243+
static bool tcc_is_untracked_pat_range(u64 start, u64 end)
1244+
{
1245+
return is_ISA_range(start, end) || is_TCC_range(start, end);
1246+
}
1247+
1248+
static int __init acpi_parse_ptct(struct acpi_table_header *table)
1249+
{
1250+
u32 total_length = 0;
1251+
u32 offset = 0;
1252+
u8 *ptr;
1253+
u32 id = 0;
1254+
1255+
struct acpi_ptct_entry_header *entry;
1256+
struct acpi_ptct_psram *psram;
1257+
1258+
if (!table)
1259+
return -EINVAL;
1260+
1261+
total_length = table->length;
1262+
1263+
/* Parse PTCT table for the first round to get number of regions*/
1264+
1265+
ptr = (u8 *)table;
1266+
ptr += PTCT_ACPI_HEADER_SIZE;
1267+
1268+
for (offset = PTCT_ACPI_HEADER_SIZE; offset < total_length;) {
1269+
entry = (struct acpi_ptct_entry_header *)(ptr);
1270+
offset += entry->size;
1271+
1272+
if (entry->type == ACPI_PTCT_ENTRY_PSEUDO_SRAM)
1273+
total_psram_region++;
1274+
1275+
ptr += entry->size;
1276+
}
1277+
if (total_psram_region > MAX_PSRAM_REGIONS)
1278+
return -EINVAL;
1279+
1280+
/* Parse for the second round to record address for each regions */
1281+
1282+
ptr = (u8 *)table;
1283+
ptr += PTCT_ACPI_HEADER_SIZE;
1284+
1285+
for (offset = PTCT_ACPI_HEADER_SIZE; offset < total_length;) {
1286+
entry = (struct acpi_ptct_entry_header *)(ptr);
1287+
offset += entry->size;
1288+
1289+
if ((entry->type == ACPI_PTCT_ENTRY_PSEUDO_SRAM) && (id < total_psram_region)) {
1290+
psram = (struct acpi_ptct_psram *)(ptr+PTCT_ENTRY_HEADER_SIZE);
1291+
ptct_psram_regions[id].phyaddr_start = ((u64)(psram->phyaddr_lo))|((u64)(psram->phyaddr_hi)<<32);
1292+
ptct_psram_regions[id].phyaddr_end = ptct_psram_regions[id].phyaddr_start + psram->size - 1;
1293+
id++;
1294+
}
1295+
ptr += entry->size;
1296+
}
1297+
1298+
return 0;
1299+
}
1300+
1301+
static void __init acpi_process_ptct(void)
1302+
{
1303+
if (!acpi_table_parse(ACPI_SIG_PTCT, acpi_parse_ptct))
1304+
x86_platform.is_untracked_pat_range = tcc_is_untracked_pat_range;
1305+
}
1306+
1307+
/*
1308+
*
1309+
*/
1310+
12211311
static void __init early_acpi_process_madt(void)
12221312
{
12231313
#ifdef CONFIG_X86_LOCAL_APIC
@@ -1624,6 +1714,11 @@ int __init acpi_boot_init(void)
16241714
if (IS_ENABLED(CONFIG_ACPI_BGRT) && !acpi_nobgrt)
16251715
acpi_table_parse(ACPI_SIG_BGRT, acpi_parse_bgrt);
16261716

1717+
/*
1718+
* Process the Platform Tuning Configuration Table (PTCT), if present
1719+
*/
1720+
acpi_process_ptct();
1721+
16271722
if (!acpi_noirq)
16281723
x86_init.pci.init = pci_acpi_init;
16291724

include/acpi/actbl2.h

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#define ACPI_SIG_PMTT "PMTT" /* Platform Memory Topology Table */
4242
#define ACPI_SIG_PPTT "PPTT" /* Processor Properties Topology Table */
4343
#define ACPI_SIG_PRMT "PRMT" /* Platform Runtime Mechanism Table */
44+
#define ACPI_SIG_PTCT "PTCT" /* Platform Tuning Configuration Table */
4445
#define ACPI_SIG_RASF "RASF" /* RAS Feature table */
4546
#define ACPI_SIG_RGRT "RGRT" /* Regulatory Graphics Resource Table */
4647
#define ACPI_SIG_SBST "SBST" /* Smart Battery Specification Table */
@@ -1923,6 +1924,59 @@ struct acpi_prmt_handler_info {
19231924
u64 acpi_param_buffer_address;
19241925
};
19251926

1927+
/*******************************************************************************
1928+
*
1929+
* PTCT - Platform Tuning Configuration Table
1930+
* Version 1
1931+
*
1932+
******************************************************************************/
1933+
1934+
struct acpi_table_ptct {
1935+
struct acpi_table_header header; /* Common ACPI table header */
1936+
};
1937+
1938+
/* Values for Type field above */
1939+
1940+
enum acpi_ptct_entry {
1941+
ACPI_PTCT_ENTRY_PTCD_LIMITS = 1,
1942+
ACPI_PTCT_ENTRY_PTCM_BINARY = 2,
1943+
ACPI_PTCT_ENTRY_WRC_L3_WAY_MASKS = 3,
1944+
ACPI_PTCT_ENTRY_GT_L3_WAY_MASKS = 4,
1945+
ACPI_PTCT_ENTRY_PSEUDO_SRAM = 5,
1946+
ACPI_PTCT_ENTRY_STREAM_DATA_PATH = 6,
1947+
ACPI_PTCT_ENTRY_TIME_AWARE_SUBSYSTEMS = 7,
1948+
ACPI_PTCT_ENTRY_REALTIME_IOMMU = 8,
1949+
ACPI_PTCT_ENTRY_MEMORY_HIERARCHY_LATENCY = 9,
1950+
1951+
ACPI_PTCT_ENTRY_RESERVED
1952+
};
1953+
1954+
struct acpi_ptct_entry_header {
1955+
u16 size;
1956+
u16 format;
1957+
u32 type;
1958+
};
1959+
1960+
struct acpi_ptct_psram {
1961+
u32 cache_level;
1962+
u32 phyaddr_lo;
1963+
u32 phyaddr_hi;
1964+
u32 cache_ways;
1965+
u32 size;
1966+
u32 apic_id;
1967+
};
1968+
1969+
struct ptct_psram_region {
1970+
u64 phyaddr_start;
1971+
u64 phyaddr_end;
1972+
};
1973+
1974+
#define PTCT_ENTRY_HEADER_SIZE sizeof(struct acpi_ptct_entry_header)
1975+
#define PTCT_ENTRY_PSRAM_SIZE sizeof(struct acpi_ptct_psram)
1976+
#define PTCT_ACPI_HEADER_SIZE sizeof(struct acpi_table_header)
1977+
#define PSRAM_REGION_INFO_SIZE sizeof(struct ptct_psram_region)
1978+
#define MAX_PSRAM_REGIONS 20
1979+
19261980
/*******************************************************************************
19271981
*
19281982
* RASF - RAS Feature Table (ACPI 5.0)

0 commit comments

Comments
 (0)