Path: blob/master/arch/powerpc/platforms/pseries/lpar.c
10818 views
/*1* pSeries_lpar.c2* Copyright (C) 2001 Todd Inglett, IBM Corporation3*4* pSeries LPAR support.5*6* This program is free software; you can redistribute it and/or modify7* it under the terms of the GNU General Public License as published by8* the Free Software Foundation; either version 2 of the License, or9* (at your option) any later version.10*11* This program is distributed in the hope that it will be useful,12* but WITHOUT ANY WARRANTY; without even the implied warranty of13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14* GNU General Public License for more details.15*16* You should have received a copy of the GNU General Public License17* along with this program; if not, write to the Free Software18* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA19*/2021/* Enables debugging of low-level hash table routines - careful! */22#undef DEBUG2324#include <linux/kernel.h>25#include <linux/dma-mapping.h>26#include <linux/console.h>27#include <asm/processor.h>28#include <asm/mmu.h>29#include <asm/page.h>30#include <asm/pgtable.h>31#include <asm/machdep.h>32#include <asm/abs_addr.h>33#include <asm/mmu_context.h>34#include <asm/iommu.h>35#include <asm/tlbflush.h>36#include <asm/tlb.h>37#include <asm/prom.h>38#include <asm/cputable.h>39#include <asm/udbg.h>40#include <asm/smp.h>41#include <asm/trace.h>4243#include "plpar_wrappers.h"44#include "pseries.h"454647/* in hvCall.S */48EXPORT_SYMBOL(plpar_hcall);49EXPORT_SYMBOL(plpar_hcall9);50EXPORT_SYMBOL(plpar_hcall_norets);5152extern void pSeries_find_serial_port(void);535455static int vtermno; /* virtual terminal# for udbg */5657#define __ALIGNED__ __attribute__((__aligned__(sizeof(long))))58static void udbg_hvsi_putc(char c)59{60/* packet's seqno isn't used anyways */61uint8_t packet[] __ALIGNED__ = { 0xff, 5, 0, 0, c };62int rc;6364if (c == '\n')65udbg_hvsi_putc('\r');6667do {68rc = plpar_put_term_char(vtermno, sizeof(packet), packet);69} while (rc == H_BUSY);70}7172static long hvsi_udbg_buf_len;73static uint8_t hvsi_udbg_buf[256];7475static int udbg_hvsi_getc_poll(void)76{77unsigned char ch;78int rc, i;7980if (hvsi_udbg_buf_len == 0) {81rc = plpar_get_term_char(vtermno, &hvsi_udbg_buf_len, hvsi_udbg_buf);82if (rc != H_SUCCESS || hvsi_udbg_buf[0] != 0xff) {83/* bad read or non-data packet */84hvsi_udbg_buf_len = 0;85} else {86/* remove the packet header */87for (i = 4; i < hvsi_udbg_buf_len; i++)88hvsi_udbg_buf[i-4] = hvsi_udbg_buf[i];89hvsi_udbg_buf_len -= 4;90}91}9293if (hvsi_udbg_buf_len <= 0 || hvsi_udbg_buf_len > 256) {94/* no data ready */95hvsi_udbg_buf_len = 0;96return -1;97}9899ch = hvsi_udbg_buf[0];100/* shift remaining data down */101for (i = 1; i < hvsi_udbg_buf_len; i++) {102hvsi_udbg_buf[i-1] = hvsi_udbg_buf[i];103}104hvsi_udbg_buf_len--;105106return ch;107}108109static int udbg_hvsi_getc(void)110{111int ch;112for (;;) {113ch = udbg_hvsi_getc_poll();114if (ch == -1) {115/* This shouldn't be needed...but... */116volatile unsigned long delay;117for (delay=0; delay < 2000000; delay++)118;119} else {120return ch;121}122}123}124125static void udbg_putcLP(char c)126{127char buf[16];128unsigned long rc;129130if (c == '\n')131udbg_putcLP('\r');132133buf[0] = c;134do {135rc = plpar_put_term_char(vtermno, 1, buf);136} while(rc == H_BUSY);137}138139/* Buffered chars getc */140static long inbuflen;141static long inbuf[2]; /* must be 2 longs */142143static int udbg_getc_pollLP(void)144{145/* The interface is tricky because it may return up to 16 chars.146* We save them statically for future calls to udbg_getc().147*/148char ch, *buf = (char *)inbuf;149int i;150long rc;151if (inbuflen == 0) {152/* get some more chars. */153inbuflen = 0;154rc = plpar_get_term_char(vtermno, &inbuflen, buf);155if (rc != H_SUCCESS)156inbuflen = 0; /* otherwise inbuflen is garbage */157}158if (inbuflen <= 0 || inbuflen > 16) {159/* Catch error case as well as other oddities (corruption) */160inbuflen = 0;161return -1;162}163ch = buf[0];164for (i = 1; i < inbuflen; i++) /* shuffle them down. */165buf[i-1] = buf[i];166inbuflen--;167return ch;168}169170static int udbg_getcLP(void)171{172int ch;173for (;;) {174ch = udbg_getc_pollLP();175if (ch == -1) {176/* This shouldn't be needed...but... */177volatile unsigned long delay;178for (delay=0; delay < 2000000; delay++)179;180} else {181return ch;182}183}184}185186/* call this from early_init() for a working debug console on187* vterm capable LPAR machines188*/189void __init udbg_init_debug_lpar(void)190{191vtermno = 0;192udbg_putc = udbg_putcLP;193udbg_getc = udbg_getcLP;194udbg_getc_poll = udbg_getc_pollLP;195196register_early_udbg_console();197}198199/* returns 0 if couldn't find or use /chosen/stdout as console */200void __init find_udbg_vterm(void)201{202struct device_node *stdout_node;203const u32 *termno;204const char *name;205206/* find the boot console from /chosen/stdout */207if (!of_chosen)208return;209name = of_get_property(of_chosen, "linux,stdout-path", NULL);210if (name == NULL)211return;212stdout_node = of_find_node_by_path(name);213if (!stdout_node)214return;215name = of_get_property(stdout_node, "name", NULL);216if (!name) {217printk(KERN_WARNING "stdout node missing 'name' property!\n");218goto out;219}220221/* Check if it's a virtual terminal */222if (strncmp(name, "vty", 3) != 0)223goto out;224termno = of_get_property(stdout_node, "reg", NULL);225if (termno == NULL)226goto out;227vtermno = termno[0];228229if (of_device_is_compatible(stdout_node, "hvterm1")) {230udbg_putc = udbg_putcLP;231udbg_getc = udbg_getcLP;232udbg_getc_poll = udbg_getc_pollLP;233add_preferred_console("hvc", termno[0] & 0xff, NULL);234} else if (of_device_is_compatible(stdout_node, "hvterm-protocol")) {235vtermno = termno[0];236udbg_putc = udbg_hvsi_putc;237udbg_getc = udbg_hvsi_getc;238udbg_getc_poll = udbg_hvsi_getc_poll;239add_preferred_console("hvsi", termno[0] & 0xff, NULL);240}241out:242of_node_put(stdout_node);243}244245void vpa_init(int cpu)246{247int hwcpu = get_hard_smp_processor_id(cpu);248unsigned long addr;249long ret;250struct paca_struct *pp;251struct dtl_entry *dtl;252253if (cpu_has_feature(CPU_FTR_ALTIVEC))254lppaca_of(cpu).vmxregs_in_use = 1;255256addr = __pa(&lppaca_of(cpu));257ret = register_vpa(hwcpu, addr);258259if (ret) {260printk(KERN_ERR "WARNING: vpa_init: VPA registration for "261"cpu %d (hw %d) of area %lx returns %ld\n",262cpu, hwcpu, addr, ret);263return;264}265/*266* PAPR says this feature is SLB-Buffer but firmware never267* reports that. All SPLPAR support SLB shadow buffer.268*/269addr = __pa(&slb_shadow[cpu]);270if (firmware_has_feature(FW_FEATURE_SPLPAR)) {271ret = register_slb_shadow(hwcpu, addr);272if (ret)273printk(KERN_ERR274"WARNING: vpa_init: SLB shadow buffer "275"registration for cpu %d (hw %d) of area %lx "276"returns %ld\n", cpu, hwcpu, addr, ret);277}278279/*280* Register dispatch trace log, if one has been allocated.281*/282pp = &paca[cpu];283dtl = pp->dispatch_log;284if (dtl) {285pp->dtl_ridx = 0;286pp->dtl_curr = dtl;287lppaca_of(cpu).dtl_idx = 0;288289/* hypervisor reads buffer length from this field */290dtl->enqueue_to_dispatch_time = DISPATCH_LOG_BYTES;291ret = register_dtl(hwcpu, __pa(dtl));292if (ret)293pr_warn("DTL registration failed for cpu %d (%ld)\n",294cpu, ret);295lppaca_of(cpu).dtl_enable_mask = 2;296}297}298299static long pSeries_lpar_hpte_insert(unsigned long hpte_group,300unsigned long va, unsigned long pa,301unsigned long rflags, unsigned long vflags,302int psize, int ssize)303{304unsigned long lpar_rc;305unsigned long flags;306unsigned long slot;307unsigned long hpte_v, hpte_r;308309if (!(vflags & HPTE_V_BOLTED))310pr_devel("hpte_insert(group=%lx, va=%016lx, pa=%016lx, "311"rflags=%lx, vflags=%lx, psize=%d)\n",312hpte_group, va, pa, rflags, vflags, psize);313314hpte_v = hpte_encode_v(va, psize, ssize) | vflags | HPTE_V_VALID;315hpte_r = hpte_encode_r(pa, psize) | rflags;316317if (!(vflags & HPTE_V_BOLTED))318pr_devel(" hpte_v=%016lx, hpte_r=%016lx\n", hpte_v, hpte_r);319320/* Now fill in the actual HPTE */321/* Set CEC cookie to 0 */322/* Zero page = 0 */323/* I-cache Invalidate = 0 */324/* I-cache synchronize = 0 */325/* Exact = 0 */326flags = 0;327328/* Make pHyp happy */329if ((rflags & _PAGE_NO_CACHE) & !(rflags & _PAGE_WRITETHRU))330hpte_r &= ~_PAGE_COHERENT;331if (firmware_has_feature(FW_FEATURE_XCMO) && !(hpte_r & HPTE_R_N))332flags |= H_COALESCE_CAND;333334lpar_rc = plpar_pte_enter(flags, hpte_group, hpte_v, hpte_r, &slot);335if (unlikely(lpar_rc == H_PTEG_FULL)) {336if (!(vflags & HPTE_V_BOLTED))337pr_devel(" full\n");338return -1;339}340341/*342* Since we try and ioremap PHBs we don't own, the pte insert343* will fail. However we must catch the failure in hash_page344* or we will loop forever, so return -2 in this case.345*/346if (unlikely(lpar_rc != H_SUCCESS)) {347if (!(vflags & HPTE_V_BOLTED))348pr_devel(" lpar err %lu\n", lpar_rc);349return -2;350}351if (!(vflags & HPTE_V_BOLTED))352pr_devel(" -> slot: %lu\n", slot & 7);353354/* Because of iSeries, we have to pass down the secondary355* bucket bit here as well356*/357return (slot & 7) | (!!(vflags & HPTE_V_SECONDARY) << 3);358}359360static DEFINE_SPINLOCK(pSeries_lpar_tlbie_lock);361362static long pSeries_lpar_hpte_remove(unsigned long hpte_group)363{364unsigned long slot_offset;365unsigned long lpar_rc;366int i;367unsigned long dummy1, dummy2;368369/* pick a random slot to start at */370slot_offset = mftb() & 0x7;371372for (i = 0; i < HPTES_PER_GROUP; i++) {373374/* don't remove a bolted entry */375lpar_rc = plpar_pte_remove(H_ANDCOND, hpte_group + slot_offset,376(0x1UL << 4), &dummy1, &dummy2);377if (lpar_rc == H_SUCCESS)378return i;379BUG_ON(lpar_rc != H_NOT_FOUND);380381slot_offset++;382slot_offset &= 0x7;383}384385return -1;386}387388static void pSeries_lpar_hptab_clear(void)389{390unsigned long size_bytes = 1UL << ppc64_pft_size;391unsigned long hpte_count = size_bytes >> 4;392struct {393unsigned long pteh;394unsigned long ptel;395} ptes[4];396long lpar_rc;397int i, j;398399/* Read in batches of 4,400* invalidate only valid entries not in the VRMA401* hpte_count will be a multiple of 4402*/403for (i = 0; i < hpte_count; i += 4) {404lpar_rc = plpar_pte_read_4_raw(0, i, (void *)ptes);405if (lpar_rc != H_SUCCESS)406continue;407for (j = 0; j < 4; j++){408if ((ptes[j].pteh & HPTE_V_VRMA_MASK) ==409HPTE_V_VRMA_MASK)410continue;411if (ptes[j].pteh & HPTE_V_VALID)412plpar_pte_remove_raw(0, i + j, 0,413&(ptes[j].pteh), &(ptes[j].ptel));414}415}416}417418/*419* This computes the AVPN and B fields of the first dword of a HPTE,420* for use when we want to match an existing PTE. The bottom 7 bits421* of the returned value are zero.422*/423static inline unsigned long hpte_encode_avpn(unsigned long va, int psize,424int ssize)425{426unsigned long v;427428v = (va >> 23) & ~(mmu_psize_defs[psize].avpnm);429v <<= HPTE_V_AVPN_SHIFT;430v |= ((unsigned long) ssize) << HPTE_V_SSIZE_SHIFT;431return v;432}433434/*435* NOTE: for updatepp ops we are fortunate that the linux "newpp" bits and436* the low 3 bits of flags happen to line up. So no transform is needed.437* We can probably optimize here and assume the high bits of newpp are438* already zero. For now I am paranoid.439*/440static long pSeries_lpar_hpte_updatepp(unsigned long slot,441unsigned long newpp,442unsigned long va,443int psize, int ssize, int local)444{445unsigned long lpar_rc;446unsigned long flags = (newpp & 7) | H_AVPN;447unsigned long want_v;448449want_v = hpte_encode_avpn(va, psize, ssize);450451pr_devel(" update: avpnv=%016lx, hash=%016lx, f=%lx, psize: %d ...",452want_v, slot, flags, psize);453454lpar_rc = plpar_pte_protect(flags, slot, want_v);455456if (lpar_rc == H_NOT_FOUND) {457pr_devel("not found !\n");458return -1;459}460461pr_devel("ok\n");462463BUG_ON(lpar_rc != H_SUCCESS);464465return 0;466}467468static unsigned long pSeries_lpar_hpte_getword0(unsigned long slot)469{470unsigned long dword0;471unsigned long lpar_rc;472unsigned long dummy_word1;473unsigned long flags;474475/* Read 1 pte at a time */476/* Do not need RPN to logical page translation */477/* No cross CEC PFT access */478flags = 0;479480lpar_rc = plpar_pte_read(flags, slot, &dword0, &dummy_word1);481482BUG_ON(lpar_rc != H_SUCCESS);483484return dword0;485}486487static long pSeries_lpar_hpte_find(unsigned long va, int psize, int ssize)488{489unsigned long hash;490unsigned long i;491long slot;492unsigned long want_v, hpte_v;493494hash = hpt_hash(va, mmu_psize_defs[psize].shift, ssize);495want_v = hpte_encode_avpn(va, psize, ssize);496497/* Bolted entries are always in the primary group */498slot = (hash & htab_hash_mask) * HPTES_PER_GROUP;499for (i = 0; i < HPTES_PER_GROUP; i++) {500hpte_v = pSeries_lpar_hpte_getword0(slot);501502if (HPTE_V_COMPARE(hpte_v, want_v) && (hpte_v & HPTE_V_VALID))503/* HPTE matches */504return slot;505++slot;506}507508return -1;509}510511static void pSeries_lpar_hpte_updateboltedpp(unsigned long newpp,512unsigned long ea,513int psize, int ssize)514{515unsigned long lpar_rc, slot, vsid, va, flags;516517vsid = get_kernel_vsid(ea, ssize);518va = hpt_va(ea, vsid, ssize);519520slot = pSeries_lpar_hpte_find(va, psize, ssize);521BUG_ON(slot == -1);522523flags = newpp & 7;524lpar_rc = plpar_pte_protect(flags, slot, 0);525526BUG_ON(lpar_rc != H_SUCCESS);527}528529static void pSeries_lpar_hpte_invalidate(unsigned long slot, unsigned long va,530int psize, int ssize, int local)531{532unsigned long want_v;533unsigned long lpar_rc;534unsigned long dummy1, dummy2;535536pr_devel(" inval : slot=%lx, va=%016lx, psize: %d, local: %d\n",537slot, va, psize, local);538539want_v = hpte_encode_avpn(va, psize, ssize);540lpar_rc = plpar_pte_remove(H_AVPN, slot, want_v, &dummy1, &dummy2);541if (lpar_rc == H_NOT_FOUND)542return;543544BUG_ON(lpar_rc != H_SUCCESS);545}546547static void pSeries_lpar_hpte_removebolted(unsigned long ea,548int psize, int ssize)549{550unsigned long slot, vsid, va;551552vsid = get_kernel_vsid(ea, ssize);553va = hpt_va(ea, vsid, ssize);554555slot = pSeries_lpar_hpte_find(va, psize, ssize);556BUG_ON(slot == -1);557558pSeries_lpar_hpte_invalidate(slot, va, psize, ssize, 0);559}560561/* Flag bits for H_BULK_REMOVE */562#define HBR_REQUEST 0x4000000000000000UL563#define HBR_RESPONSE 0x8000000000000000UL564#define HBR_END 0xc000000000000000UL565#define HBR_AVPN 0x0200000000000000UL566#define HBR_ANDCOND 0x0100000000000000UL567568/*569* Take a spinlock around flushes to avoid bouncing the hypervisor tlbie570* lock.571*/572static void pSeries_lpar_flush_hash_range(unsigned long number, int local)573{574unsigned long i, pix, rc;575unsigned long flags = 0;576struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch);577int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE);578unsigned long param[9];579unsigned long va;580unsigned long hash, index, shift, hidx, slot;581real_pte_t pte;582int psize, ssize;583584if (lock_tlbie)585spin_lock_irqsave(&pSeries_lpar_tlbie_lock, flags);586587psize = batch->psize;588ssize = batch->ssize;589pix = 0;590for (i = 0; i < number; i++) {591va = batch->vaddr[i];592pte = batch->pte[i];593pte_iterate_hashed_subpages(pte, psize, va, index, shift) {594hash = hpt_hash(va, shift, ssize);595hidx = __rpte_to_hidx(pte, index);596if (hidx & _PTEIDX_SECONDARY)597hash = ~hash;598slot = (hash & htab_hash_mask) * HPTES_PER_GROUP;599slot += hidx & _PTEIDX_GROUP_IX;600if (!firmware_has_feature(FW_FEATURE_BULK_REMOVE)) {601pSeries_lpar_hpte_invalidate(slot, va, psize,602ssize, local);603} else {604param[pix] = HBR_REQUEST | HBR_AVPN | slot;605param[pix+1] = hpte_encode_avpn(va, psize,606ssize);607pix += 2;608if (pix == 8) {609rc = plpar_hcall9(H_BULK_REMOVE, param,610param[0], param[1], param[2],611param[3], param[4], param[5],612param[6], param[7]);613BUG_ON(rc != H_SUCCESS);614pix = 0;615}616}617} pte_iterate_hashed_end();618}619if (pix) {620param[pix] = HBR_END;621rc = plpar_hcall9(H_BULK_REMOVE, param, param[0], param[1],622param[2], param[3], param[4], param[5],623param[6], param[7]);624BUG_ON(rc != H_SUCCESS);625}626627if (lock_tlbie)628spin_unlock_irqrestore(&pSeries_lpar_tlbie_lock, flags);629}630631static int __init disable_bulk_remove(char *str)632{633if (strcmp(str, "off") == 0 &&634firmware_has_feature(FW_FEATURE_BULK_REMOVE)) {635printk(KERN_INFO "Disabling BULK_REMOVE firmware feature");636powerpc_firmware_features &= ~FW_FEATURE_BULK_REMOVE;637}638return 1;639}640641__setup("bulk_remove=", disable_bulk_remove);642643void __init hpte_init_lpar(void)644{645ppc_md.hpte_invalidate = pSeries_lpar_hpte_invalidate;646ppc_md.hpte_updatepp = pSeries_lpar_hpte_updatepp;647ppc_md.hpte_updateboltedpp = pSeries_lpar_hpte_updateboltedpp;648ppc_md.hpte_insert = pSeries_lpar_hpte_insert;649ppc_md.hpte_remove = pSeries_lpar_hpte_remove;650ppc_md.hpte_removebolted = pSeries_lpar_hpte_removebolted;651ppc_md.flush_hash_range = pSeries_lpar_flush_hash_range;652ppc_md.hpte_clear_all = pSeries_lpar_hptab_clear;653}654655#ifdef CONFIG_PPC_SMLPAR656#define CMO_FREE_HINT_DEFAULT 1657static int cmo_free_hint_flag = CMO_FREE_HINT_DEFAULT;658659static int __init cmo_free_hint(char *str)660{661char *parm;662parm = strstrip(str);663664if (strcasecmp(parm, "no") == 0 || strcasecmp(parm, "off") == 0) {665printk(KERN_INFO "cmo_free_hint: CMO free page hinting is not active.\n");666cmo_free_hint_flag = 0;667return 1;668}669670cmo_free_hint_flag = 1;671printk(KERN_INFO "cmo_free_hint: CMO free page hinting is active.\n");672673if (strcasecmp(parm, "yes") == 0 || strcasecmp(parm, "on") == 0)674return 1;675676return 0;677}678679__setup("cmo_free_hint=", cmo_free_hint);680681static void pSeries_set_page_state(struct page *page, int order,682unsigned long state)683{684int i, j;685unsigned long cmo_page_sz, addr;686687cmo_page_sz = cmo_get_page_size();688addr = __pa((unsigned long)page_address(page));689690for (i = 0; i < (1 << order); i++, addr += PAGE_SIZE) {691for (j = 0; j < PAGE_SIZE; j += cmo_page_sz)692plpar_hcall_norets(H_PAGE_INIT, state, addr + j, 0);693}694}695696void arch_free_page(struct page *page, int order)697{698if (!cmo_free_hint_flag || !firmware_has_feature(FW_FEATURE_CMO))699return;700701pSeries_set_page_state(page, order, H_PAGE_SET_UNUSED);702}703EXPORT_SYMBOL(arch_free_page);704705#endif706707#ifdef CONFIG_TRACEPOINTS708/*709* We optimise our hcall path by placing hcall_tracepoint_refcount710* directly in the TOC so we can check if the hcall tracepoints are711* enabled via a single load.712*/713714/* NB: reg/unreg are called while guarded with the tracepoints_mutex */715extern long hcall_tracepoint_refcount;716717/*718* Since the tracing code might execute hcalls we need to guard against719* recursion. One example of this are spinlocks calling H_YIELD on720* shared processor partitions.721*/722static DEFINE_PER_CPU(unsigned int, hcall_trace_depth);723724void hcall_tracepoint_regfunc(void)725{726hcall_tracepoint_refcount++;727}728729void hcall_tracepoint_unregfunc(void)730{731hcall_tracepoint_refcount--;732}733734void __trace_hcall_entry(unsigned long opcode, unsigned long *args)735{736unsigned long flags;737unsigned int *depth;738739local_irq_save(flags);740741depth = &__get_cpu_var(hcall_trace_depth);742743if (*depth)744goto out;745746(*depth)++;747trace_hcall_entry(opcode, args);748(*depth)--;749750out:751local_irq_restore(flags);752}753754void __trace_hcall_exit(long opcode, unsigned long retval,755unsigned long *retbuf)756{757unsigned long flags;758unsigned int *depth;759760local_irq_save(flags);761762depth = &__get_cpu_var(hcall_trace_depth);763764if (*depth)765goto out;766767(*depth)++;768trace_hcall_exit(opcode, retval, retbuf);769(*depth)--;770771out:772local_irq_restore(flags);773}774#endif775776/**777* h_get_mpp778* H_GET_MPP hcall returns info in 7 parms779*/780int h_get_mpp(struct hvcall_mpp_data *mpp_data)781{782int rc;783unsigned long retbuf[PLPAR_HCALL9_BUFSIZE];784785rc = plpar_hcall9(H_GET_MPP, retbuf);786787mpp_data->entitled_mem = retbuf[0];788mpp_data->mapped_mem = retbuf[1];789790mpp_data->group_num = (retbuf[2] >> 2 * 8) & 0xffff;791mpp_data->pool_num = retbuf[2] & 0xffff;792793mpp_data->mem_weight = (retbuf[3] >> 7 * 8) & 0xff;794mpp_data->unallocated_mem_weight = (retbuf[3] >> 6 * 8) & 0xff;795mpp_data->unallocated_entitlement = retbuf[3] & 0xffffffffffff;796797mpp_data->pool_size = retbuf[4];798mpp_data->loan_request = retbuf[5];799mpp_data->backing_mem = retbuf[6];800801return rc;802}803EXPORT_SYMBOL(h_get_mpp);804805int h_get_mpp_x(struct hvcall_mpp_x_data *mpp_x_data)806{807int rc;808unsigned long retbuf[PLPAR_HCALL9_BUFSIZE] = { 0 };809810rc = plpar_hcall9(H_GET_MPP_X, retbuf);811812mpp_x_data->coalesced_bytes = retbuf[0];813mpp_x_data->pool_coalesced_bytes = retbuf[1];814mpp_x_data->pool_purr_cycles = retbuf[2];815mpp_x_data->pool_spurr_cycles = retbuf[3];816817return rc;818}819820821