Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/pseries/lpar: convert to papr_sysparm API

Convert the TLB block invalidate characteristics discovery to the new
papr_sysparm API. This occurs too early in boot to use
papr_sysparm_buf_alloc(), so use a static buffer.

Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20230125-b4-powerpc-rtas-queue-v3-18-26929c8cce78@linux.ibm.com

authored by

Nathan Lynch and committed by
Michael Ellerman
e58d9e17 69b9f5a5

+9 -28
+9 -28
arch/powerpc/platforms/pseries/lpar.c
··· 32 32 #include <asm/iommu.h> 33 33 #include <asm/tlb.h> 34 34 #include <asm/cputable.h> 35 + #include <asm/papr-sysparm.h> 35 36 #include <asm/udbg.h> 36 37 #include <asm/smp.h> 37 38 #include <asm/trace.h> ··· 1470 1469 } 1471 1470 } 1472 1471 1473 - #define SPLPAR_TLB_BIC_TOKEN 50 1474 - 1475 1472 /* 1476 1473 * The size of the TLB Block Invalidate Characteristics is variable. But at the 1477 1474 * maximum it will be the number of possible page sizes *2 + 10 bytes. ··· 1480 1481 1481 1482 void __init pseries_lpar_read_hblkrm_characteristics(void) 1482 1483 { 1483 - const s32 token = rtas_token("ibm,get-system-parameter"); 1484 - unsigned char local_buffer[SPLPAR_TLB_BIC_MAXLENGTH]; 1485 - int call_status, len, idx, bpsize; 1484 + static struct papr_sysparm_buf buf __initdata; 1485 + int len, idx, bpsize; 1486 1486 1487 1487 if (!firmware_has_feature(FW_FEATURE_BLOCK_REMOVE)) 1488 1488 return; 1489 1489 1490 - do { 1491 - spin_lock(&rtas_data_buf_lock); 1492 - memset(rtas_data_buf, 0, RTAS_DATA_BUF_SIZE); 1493 - call_status = rtas_call(token, 3, 1, NULL, SPLPAR_TLB_BIC_TOKEN, 1494 - __pa(rtas_data_buf), RTAS_DATA_BUF_SIZE); 1495 - memcpy(local_buffer, rtas_data_buf, SPLPAR_TLB_BIC_MAXLENGTH); 1496 - local_buffer[SPLPAR_TLB_BIC_MAXLENGTH - 1] = '\0'; 1497 - spin_unlock(&rtas_data_buf_lock); 1498 - } while (rtas_busy_delay(call_status)); 1499 - 1500 - if (call_status != 0) { 1501 - pr_warn("%s %s Error calling get-system-parameter (0x%x)\n", 1502 - __FILE__, __func__, call_status); 1490 + if (papr_sysparm_get(PAPR_SYSPARM_TLB_BLOCK_INVALIDATE_ATTRS, &buf)) 1503 1491 return; 1504 - } 1505 1492 1506 - /* 1507 - * The first two (2) bytes of the data in the buffer are the length of 1508 - * the returned data, not counting these first two (2) bytes. 1509 - */ 1510 - len = be16_to_cpu(*((u16 *)local_buffer)) + 2; 1493 + len = be16_to_cpu(buf.len); 1511 1494 if (len > SPLPAR_TLB_BIC_MAXLENGTH) { 1512 1495 pr_warn("%s too large returned buffer %d", __func__, len); 1513 1496 return; 1514 1497 } 1515 1498 1516 - idx = 2; 1499 + idx = 0; 1517 1500 while (idx < len) { 1518 - u8 block_shift = local_buffer[idx++]; 1501 + u8 block_shift = buf.val[idx++]; 1519 1502 u32 block_size; 1520 1503 unsigned int npsize; 1521 1504 ··· 1506 1525 1507 1526 block_size = 1 << block_shift; 1508 1527 1509 - for (npsize = local_buffer[idx++]; 1528 + for (npsize = buf.val[idx++]; 1510 1529 npsize > 0 && idx < len; npsize--) 1511 - check_lp_set_hblkrm((unsigned int) local_buffer[idx++], 1530 + check_lp_set_hblkrm((unsigned int)buf.val[idx++], 1512 1531 block_size); 1513 1532 } 1514 1533