162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci#ifndef _ASM_POWERPC_PLPAR_WRAPPERS_H 362306a36Sopenharmony_ci#define _ASM_POWERPC_PLPAR_WRAPPERS_H 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci#ifdef CONFIG_PPC_PSERIES 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci#include <linux/string.h> 862306a36Sopenharmony_ci#include <linux/irqflags.h> 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#include <asm/hvcall.h> 1162306a36Sopenharmony_ci#include <asm/paca.h> 1262306a36Sopenharmony_ci#include <asm/lppaca.h> 1362306a36Sopenharmony_ci#include <asm/page.h> 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_cistatic inline long poll_pending(void) 1662306a36Sopenharmony_ci{ 1762306a36Sopenharmony_ci return plpar_hcall_norets(H_POLL_PENDING); 1862306a36Sopenharmony_ci} 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_cistatic inline u8 get_cede_latency_hint(void) 2162306a36Sopenharmony_ci{ 2262306a36Sopenharmony_ci return get_lppaca()->cede_latency_hint; 2362306a36Sopenharmony_ci} 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_cistatic inline void set_cede_latency_hint(u8 latency_hint) 2662306a36Sopenharmony_ci{ 2762306a36Sopenharmony_ci get_lppaca()->cede_latency_hint = latency_hint; 2862306a36Sopenharmony_ci} 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_cistatic inline long cede_processor(void) 3162306a36Sopenharmony_ci{ 3262306a36Sopenharmony_ci /* 3362306a36Sopenharmony_ci * We cannot call tracepoints inside RCU idle regions which 3462306a36Sopenharmony_ci * means we must not trace H_CEDE. 3562306a36Sopenharmony_ci */ 3662306a36Sopenharmony_ci return plpar_hcall_norets_notrace(H_CEDE); 3762306a36Sopenharmony_ci} 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_cistatic inline long extended_cede_processor(unsigned long latency_hint) 4062306a36Sopenharmony_ci{ 4162306a36Sopenharmony_ci long rc; 4262306a36Sopenharmony_ci u8 old_latency_hint = get_cede_latency_hint(); 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ci set_cede_latency_hint(latency_hint); 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_ci rc = cede_processor(); 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ci /* Ensure that H_CEDE returns with IRQs on */ 4962306a36Sopenharmony_ci if (WARN_ON(IS_ENABLED(CONFIG_PPC_IRQ_SOFT_MASK_DEBUG) && !(mfmsr() & MSR_EE))) 5062306a36Sopenharmony_ci __hard_irq_enable(); 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_ci set_cede_latency_hint(old_latency_hint); 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci return rc; 5562306a36Sopenharmony_ci} 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_cistatic inline long vpa_call(unsigned long flags, unsigned long cpu, 5862306a36Sopenharmony_ci unsigned long vpa) 5962306a36Sopenharmony_ci{ 6062306a36Sopenharmony_ci flags = flags << H_VPA_FUNC_SHIFT; 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci return plpar_hcall_norets(H_REGISTER_VPA, flags, cpu, vpa); 6362306a36Sopenharmony_ci} 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_cistatic inline long unregister_vpa(unsigned long cpu) 6662306a36Sopenharmony_ci{ 6762306a36Sopenharmony_ci return vpa_call(H_VPA_DEREG_VPA, cpu, 0); 6862306a36Sopenharmony_ci} 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_cistatic inline long register_vpa(unsigned long cpu, unsigned long vpa) 7162306a36Sopenharmony_ci{ 7262306a36Sopenharmony_ci return vpa_call(H_VPA_REG_VPA, cpu, vpa); 7362306a36Sopenharmony_ci} 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_cistatic inline long unregister_slb_shadow(unsigned long cpu) 7662306a36Sopenharmony_ci{ 7762306a36Sopenharmony_ci return vpa_call(H_VPA_DEREG_SLB, cpu, 0); 7862306a36Sopenharmony_ci} 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_cistatic inline long register_slb_shadow(unsigned long cpu, unsigned long vpa) 8162306a36Sopenharmony_ci{ 8262306a36Sopenharmony_ci return vpa_call(H_VPA_REG_SLB, cpu, vpa); 8362306a36Sopenharmony_ci} 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_cistatic inline long unregister_dtl(unsigned long cpu) 8662306a36Sopenharmony_ci{ 8762306a36Sopenharmony_ci return vpa_call(H_VPA_DEREG_DTL, cpu, 0); 8862306a36Sopenharmony_ci} 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_cistatic inline long register_dtl(unsigned long cpu, unsigned long vpa) 9162306a36Sopenharmony_ci{ 9262306a36Sopenharmony_ci return vpa_call(H_VPA_REG_DTL, cpu, vpa); 9362306a36Sopenharmony_ci} 9462306a36Sopenharmony_ci 9562306a36Sopenharmony_ciextern void vpa_init(int cpu); 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_cistatic inline long plpar_pte_enter(unsigned long flags, 9862306a36Sopenharmony_ci unsigned long hpte_group, unsigned long hpte_v, 9962306a36Sopenharmony_ci unsigned long hpte_r, unsigned long *slot) 10062306a36Sopenharmony_ci{ 10162306a36Sopenharmony_ci long rc; 10262306a36Sopenharmony_ci unsigned long retbuf[PLPAR_HCALL_BUFSIZE]; 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_ci rc = plpar_hcall(H_ENTER, retbuf, flags, hpte_group, hpte_v, hpte_r); 10562306a36Sopenharmony_ci 10662306a36Sopenharmony_ci *slot = retbuf[0]; 10762306a36Sopenharmony_ci 10862306a36Sopenharmony_ci return rc; 10962306a36Sopenharmony_ci} 11062306a36Sopenharmony_ci 11162306a36Sopenharmony_cistatic inline long plpar_pte_remove(unsigned long flags, unsigned long ptex, 11262306a36Sopenharmony_ci unsigned long avpn, unsigned long *old_pteh_ret, 11362306a36Sopenharmony_ci unsigned long *old_ptel_ret) 11462306a36Sopenharmony_ci{ 11562306a36Sopenharmony_ci long rc; 11662306a36Sopenharmony_ci unsigned long retbuf[PLPAR_HCALL_BUFSIZE]; 11762306a36Sopenharmony_ci 11862306a36Sopenharmony_ci rc = plpar_hcall(H_REMOVE, retbuf, flags, ptex, avpn); 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_ci *old_pteh_ret = retbuf[0]; 12162306a36Sopenharmony_ci *old_ptel_ret = retbuf[1]; 12262306a36Sopenharmony_ci 12362306a36Sopenharmony_ci return rc; 12462306a36Sopenharmony_ci} 12562306a36Sopenharmony_ci 12662306a36Sopenharmony_ci/* plpar_pte_remove_raw can be called in real mode. It calls plpar_hcall_raw */ 12762306a36Sopenharmony_cistatic inline long plpar_pte_remove_raw(unsigned long flags, unsigned long ptex, 12862306a36Sopenharmony_ci unsigned long avpn, unsigned long *old_pteh_ret, 12962306a36Sopenharmony_ci unsigned long *old_ptel_ret) 13062306a36Sopenharmony_ci{ 13162306a36Sopenharmony_ci long rc; 13262306a36Sopenharmony_ci unsigned long retbuf[PLPAR_HCALL_BUFSIZE]; 13362306a36Sopenharmony_ci 13462306a36Sopenharmony_ci rc = plpar_hcall_raw(H_REMOVE, retbuf, flags, ptex, avpn); 13562306a36Sopenharmony_ci 13662306a36Sopenharmony_ci *old_pteh_ret = retbuf[0]; 13762306a36Sopenharmony_ci *old_ptel_ret = retbuf[1]; 13862306a36Sopenharmony_ci 13962306a36Sopenharmony_ci return rc; 14062306a36Sopenharmony_ci} 14162306a36Sopenharmony_ci 14262306a36Sopenharmony_cistatic inline long plpar_pte_read(unsigned long flags, unsigned long ptex, 14362306a36Sopenharmony_ci unsigned long *old_pteh_ret, unsigned long *old_ptel_ret) 14462306a36Sopenharmony_ci{ 14562306a36Sopenharmony_ci long rc; 14662306a36Sopenharmony_ci unsigned long retbuf[PLPAR_HCALL_BUFSIZE]; 14762306a36Sopenharmony_ci 14862306a36Sopenharmony_ci rc = plpar_hcall(H_READ, retbuf, flags, ptex); 14962306a36Sopenharmony_ci 15062306a36Sopenharmony_ci *old_pteh_ret = retbuf[0]; 15162306a36Sopenharmony_ci *old_ptel_ret = retbuf[1]; 15262306a36Sopenharmony_ci 15362306a36Sopenharmony_ci return rc; 15462306a36Sopenharmony_ci} 15562306a36Sopenharmony_ci 15662306a36Sopenharmony_ci/* plpar_pte_read_raw can be called in real mode. It calls plpar_hcall_raw */ 15762306a36Sopenharmony_cistatic inline long plpar_pte_read_raw(unsigned long flags, unsigned long ptex, 15862306a36Sopenharmony_ci unsigned long *old_pteh_ret, unsigned long *old_ptel_ret) 15962306a36Sopenharmony_ci{ 16062306a36Sopenharmony_ci long rc; 16162306a36Sopenharmony_ci unsigned long retbuf[PLPAR_HCALL_BUFSIZE]; 16262306a36Sopenharmony_ci 16362306a36Sopenharmony_ci rc = plpar_hcall_raw(H_READ, retbuf, flags, ptex); 16462306a36Sopenharmony_ci 16562306a36Sopenharmony_ci *old_pteh_ret = retbuf[0]; 16662306a36Sopenharmony_ci *old_ptel_ret = retbuf[1]; 16762306a36Sopenharmony_ci 16862306a36Sopenharmony_ci return rc; 16962306a36Sopenharmony_ci} 17062306a36Sopenharmony_ci 17162306a36Sopenharmony_ci/* 17262306a36Sopenharmony_ci * ptes must be 8*sizeof(unsigned long) 17362306a36Sopenharmony_ci */ 17462306a36Sopenharmony_cistatic inline long plpar_pte_read_4(unsigned long flags, unsigned long ptex, 17562306a36Sopenharmony_ci unsigned long *ptes) 17662306a36Sopenharmony_ci 17762306a36Sopenharmony_ci{ 17862306a36Sopenharmony_ci long rc; 17962306a36Sopenharmony_ci unsigned long retbuf[PLPAR_HCALL9_BUFSIZE]; 18062306a36Sopenharmony_ci 18162306a36Sopenharmony_ci rc = plpar_hcall9(H_READ, retbuf, flags | H_READ_4, ptex); 18262306a36Sopenharmony_ci 18362306a36Sopenharmony_ci memcpy(ptes, retbuf, 8*sizeof(unsigned long)); 18462306a36Sopenharmony_ci 18562306a36Sopenharmony_ci return rc; 18662306a36Sopenharmony_ci} 18762306a36Sopenharmony_ci 18862306a36Sopenharmony_ci/* 18962306a36Sopenharmony_ci * plpar_pte_read_4_raw can be called in real mode. 19062306a36Sopenharmony_ci * ptes must be 8*sizeof(unsigned long) 19162306a36Sopenharmony_ci */ 19262306a36Sopenharmony_cistatic inline long plpar_pte_read_4_raw(unsigned long flags, unsigned long ptex, 19362306a36Sopenharmony_ci unsigned long *ptes) 19462306a36Sopenharmony_ci 19562306a36Sopenharmony_ci{ 19662306a36Sopenharmony_ci long rc; 19762306a36Sopenharmony_ci unsigned long retbuf[PLPAR_HCALL9_BUFSIZE]; 19862306a36Sopenharmony_ci 19962306a36Sopenharmony_ci rc = plpar_hcall9_raw(H_READ, retbuf, flags | H_READ_4, ptex); 20062306a36Sopenharmony_ci 20162306a36Sopenharmony_ci memcpy(ptes, retbuf, 8*sizeof(unsigned long)); 20262306a36Sopenharmony_ci 20362306a36Sopenharmony_ci return rc; 20462306a36Sopenharmony_ci} 20562306a36Sopenharmony_ci 20662306a36Sopenharmony_cistatic inline long plpar_pte_protect(unsigned long flags, unsigned long ptex, 20762306a36Sopenharmony_ci unsigned long avpn) 20862306a36Sopenharmony_ci{ 20962306a36Sopenharmony_ci return plpar_hcall_norets(H_PROTECT, flags, ptex, avpn); 21062306a36Sopenharmony_ci} 21162306a36Sopenharmony_ci 21262306a36Sopenharmony_cistatic inline long plpar_resize_hpt_prepare(unsigned long flags, 21362306a36Sopenharmony_ci unsigned long shift) 21462306a36Sopenharmony_ci{ 21562306a36Sopenharmony_ci return plpar_hcall_norets(H_RESIZE_HPT_PREPARE, flags, shift); 21662306a36Sopenharmony_ci} 21762306a36Sopenharmony_ci 21862306a36Sopenharmony_cistatic inline long plpar_resize_hpt_commit(unsigned long flags, 21962306a36Sopenharmony_ci unsigned long shift) 22062306a36Sopenharmony_ci{ 22162306a36Sopenharmony_ci return plpar_hcall_norets(H_RESIZE_HPT_COMMIT, flags, shift); 22262306a36Sopenharmony_ci} 22362306a36Sopenharmony_ci 22462306a36Sopenharmony_cistatic inline long plpar_tce_get(unsigned long liobn, unsigned long ioba, 22562306a36Sopenharmony_ci unsigned long *tce_ret) 22662306a36Sopenharmony_ci{ 22762306a36Sopenharmony_ci long rc; 22862306a36Sopenharmony_ci unsigned long retbuf[PLPAR_HCALL_BUFSIZE]; 22962306a36Sopenharmony_ci 23062306a36Sopenharmony_ci rc = plpar_hcall(H_GET_TCE, retbuf, liobn, ioba); 23162306a36Sopenharmony_ci 23262306a36Sopenharmony_ci *tce_ret = retbuf[0]; 23362306a36Sopenharmony_ci 23462306a36Sopenharmony_ci return rc; 23562306a36Sopenharmony_ci} 23662306a36Sopenharmony_ci 23762306a36Sopenharmony_cistatic inline long plpar_tce_put(unsigned long liobn, unsigned long ioba, 23862306a36Sopenharmony_ci unsigned long tceval) 23962306a36Sopenharmony_ci{ 24062306a36Sopenharmony_ci return plpar_hcall_norets(H_PUT_TCE, liobn, ioba, tceval); 24162306a36Sopenharmony_ci} 24262306a36Sopenharmony_ci 24362306a36Sopenharmony_cistatic inline long plpar_tce_put_indirect(unsigned long liobn, 24462306a36Sopenharmony_ci unsigned long ioba, unsigned long page, unsigned long count) 24562306a36Sopenharmony_ci{ 24662306a36Sopenharmony_ci return plpar_hcall_norets(H_PUT_TCE_INDIRECT, liobn, ioba, page, count); 24762306a36Sopenharmony_ci} 24862306a36Sopenharmony_ci 24962306a36Sopenharmony_cistatic inline long plpar_tce_stuff(unsigned long liobn, unsigned long ioba, 25062306a36Sopenharmony_ci unsigned long tceval, unsigned long count) 25162306a36Sopenharmony_ci{ 25262306a36Sopenharmony_ci return plpar_hcall_norets(H_STUFF_TCE, liobn, ioba, tceval, count); 25362306a36Sopenharmony_ci} 25462306a36Sopenharmony_ci 25562306a36Sopenharmony_ci/* Set various resource mode parameters */ 25662306a36Sopenharmony_cistatic inline long plpar_set_mode(unsigned long mflags, unsigned long resource, 25762306a36Sopenharmony_ci unsigned long value1, unsigned long value2) 25862306a36Sopenharmony_ci{ 25962306a36Sopenharmony_ci return plpar_hcall_norets(H_SET_MODE, mflags, resource, value1, value2); 26062306a36Sopenharmony_ci} 26162306a36Sopenharmony_ci 26262306a36Sopenharmony_ci/* 26362306a36Sopenharmony_ci * Enable relocation on exceptions on this partition 26462306a36Sopenharmony_ci * 26562306a36Sopenharmony_ci * Note: this call has a partition wide scope and can take a while to complete. 26662306a36Sopenharmony_ci * If it returns H_LONG_BUSY_* it should be retried periodically until it 26762306a36Sopenharmony_ci * returns H_SUCCESS. 26862306a36Sopenharmony_ci */ 26962306a36Sopenharmony_cistatic inline long enable_reloc_on_exceptions(void) 27062306a36Sopenharmony_ci{ 27162306a36Sopenharmony_ci /* mflags = 3: Exceptions at 0xC000000000004000 */ 27262306a36Sopenharmony_ci return plpar_set_mode(3, H_SET_MODE_RESOURCE_ADDR_TRANS_MODE, 0, 0); 27362306a36Sopenharmony_ci} 27462306a36Sopenharmony_ci 27562306a36Sopenharmony_ci/* 27662306a36Sopenharmony_ci * Disable relocation on exceptions on this partition 27762306a36Sopenharmony_ci * 27862306a36Sopenharmony_ci * Note: this call has a partition wide scope and can take a while to complete. 27962306a36Sopenharmony_ci * If it returns H_LONG_BUSY_* it should be retried periodically until it 28062306a36Sopenharmony_ci * returns H_SUCCESS. 28162306a36Sopenharmony_ci */ 28262306a36Sopenharmony_cistatic inline long disable_reloc_on_exceptions(void) { 28362306a36Sopenharmony_ci return plpar_set_mode(0, H_SET_MODE_RESOURCE_ADDR_TRANS_MODE, 0, 0); 28462306a36Sopenharmony_ci} 28562306a36Sopenharmony_ci 28662306a36Sopenharmony_ci/* 28762306a36Sopenharmony_ci * Take exceptions in big endian mode on this partition 28862306a36Sopenharmony_ci * 28962306a36Sopenharmony_ci * Note: this call has a partition wide scope and can take a while to complete. 29062306a36Sopenharmony_ci * If it returns H_LONG_BUSY_* it should be retried periodically until it 29162306a36Sopenharmony_ci * returns H_SUCCESS. 29262306a36Sopenharmony_ci */ 29362306a36Sopenharmony_cistatic inline long enable_big_endian_exceptions(void) 29462306a36Sopenharmony_ci{ 29562306a36Sopenharmony_ci /* mflags = 0: big endian exceptions */ 29662306a36Sopenharmony_ci return plpar_set_mode(0, H_SET_MODE_RESOURCE_LE, 0, 0); 29762306a36Sopenharmony_ci} 29862306a36Sopenharmony_ci 29962306a36Sopenharmony_ci/* 30062306a36Sopenharmony_ci * Take exceptions in little endian mode on this partition 30162306a36Sopenharmony_ci * 30262306a36Sopenharmony_ci * Note: this call has a partition wide scope and can take a while to complete. 30362306a36Sopenharmony_ci * If it returns H_LONG_BUSY_* it should be retried periodically until it 30462306a36Sopenharmony_ci * returns H_SUCCESS. 30562306a36Sopenharmony_ci */ 30662306a36Sopenharmony_cistatic inline long enable_little_endian_exceptions(void) 30762306a36Sopenharmony_ci{ 30862306a36Sopenharmony_ci /* mflags = 1: little endian exceptions */ 30962306a36Sopenharmony_ci return plpar_set_mode(1, H_SET_MODE_RESOURCE_LE, 0, 0); 31062306a36Sopenharmony_ci} 31162306a36Sopenharmony_ci 31262306a36Sopenharmony_cistatic inline long plpar_set_ciabr(unsigned long ciabr) 31362306a36Sopenharmony_ci{ 31462306a36Sopenharmony_ci return plpar_set_mode(0, H_SET_MODE_RESOURCE_SET_CIABR, ciabr, 0); 31562306a36Sopenharmony_ci} 31662306a36Sopenharmony_ci 31762306a36Sopenharmony_cistatic inline long plpar_set_watchpoint0(unsigned long dawr0, unsigned long dawrx0) 31862306a36Sopenharmony_ci{ 31962306a36Sopenharmony_ci return plpar_set_mode(0, H_SET_MODE_RESOURCE_SET_DAWR0, dawr0, dawrx0); 32062306a36Sopenharmony_ci} 32162306a36Sopenharmony_ci 32262306a36Sopenharmony_cistatic inline long plpar_set_watchpoint1(unsigned long dawr1, unsigned long dawrx1) 32362306a36Sopenharmony_ci{ 32462306a36Sopenharmony_ci return plpar_set_mode(0, H_SET_MODE_RESOURCE_SET_DAWR1, dawr1, dawrx1); 32562306a36Sopenharmony_ci} 32662306a36Sopenharmony_ci 32762306a36Sopenharmony_cistatic inline long plpar_signal_sys_reset(long cpu) 32862306a36Sopenharmony_ci{ 32962306a36Sopenharmony_ci return plpar_hcall_norets(H_SIGNAL_SYS_RESET, cpu); 33062306a36Sopenharmony_ci} 33162306a36Sopenharmony_ci 33262306a36Sopenharmony_cistatic inline long plpar_get_cpu_characteristics(struct h_cpu_char_result *p) 33362306a36Sopenharmony_ci{ 33462306a36Sopenharmony_ci unsigned long retbuf[PLPAR_HCALL_BUFSIZE]; 33562306a36Sopenharmony_ci long rc; 33662306a36Sopenharmony_ci 33762306a36Sopenharmony_ci rc = plpar_hcall(H_GET_CPU_CHARACTERISTICS, retbuf); 33862306a36Sopenharmony_ci if (rc == H_SUCCESS) { 33962306a36Sopenharmony_ci p->character = retbuf[0]; 34062306a36Sopenharmony_ci p->behaviour = retbuf[1]; 34162306a36Sopenharmony_ci } 34262306a36Sopenharmony_ci 34362306a36Sopenharmony_ci return rc; 34462306a36Sopenharmony_ci} 34562306a36Sopenharmony_ci 34662306a36Sopenharmony_ci/* 34762306a36Sopenharmony_ci * Wrapper to H_RPT_INVALIDATE hcall that handles return values appropriately 34862306a36Sopenharmony_ci * 34962306a36Sopenharmony_ci * - Returns H_SUCCESS on success 35062306a36Sopenharmony_ci * - For H_BUSY return value, we retry the hcall. 35162306a36Sopenharmony_ci * - For any other hcall failures, attempt a full flush once before 35262306a36Sopenharmony_ci * resorting to BUG(). 35362306a36Sopenharmony_ci * 35462306a36Sopenharmony_ci * Note: This hcall is expected to fail only very rarely. The correct 35562306a36Sopenharmony_ci * error recovery of killing the process/guest will be eventually 35662306a36Sopenharmony_ci * needed. 35762306a36Sopenharmony_ci */ 35862306a36Sopenharmony_cistatic inline long pseries_rpt_invalidate(u32 pid, u64 target, u64 type, 35962306a36Sopenharmony_ci u64 page_sizes, u64 start, u64 end) 36062306a36Sopenharmony_ci{ 36162306a36Sopenharmony_ci long rc; 36262306a36Sopenharmony_ci unsigned long all; 36362306a36Sopenharmony_ci 36462306a36Sopenharmony_ci while (true) { 36562306a36Sopenharmony_ci rc = plpar_hcall_norets(H_RPT_INVALIDATE, pid, target, type, 36662306a36Sopenharmony_ci page_sizes, start, end); 36762306a36Sopenharmony_ci if (rc == H_BUSY) { 36862306a36Sopenharmony_ci cpu_relax(); 36962306a36Sopenharmony_ci continue; 37062306a36Sopenharmony_ci } else if (rc == H_SUCCESS) 37162306a36Sopenharmony_ci return rc; 37262306a36Sopenharmony_ci 37362306a36Sopenharmony_ci /* Flush request failed, try with a full flush once */ 37462306a36Sopenharmony_ci if (type & H_RPTI_TYPE_NESTED) 37562306a36Sopenharmony_ci all = H_RPTI_TYPE_NESTED | H_RPTI_TYPE_NESTED_ALL; 37662306a36Sopenharmony_ci else 37762306a36Sopenharmony_ci all = H_RPTI_TYPE_ALL; 37862306a36Sopenharmony_ciretry: 37962306a36Sopenharmony_ci rc = plpar_hcall_norets(H_RPT_INVALIDATE, pid, target, 38062306a36Sopenharmony_ci all, page_sizes, 0, -1UL); 38162306a36Sopenharmony_ci if (rc == H_BUSY) { 38262306a36Sopenharmony_ci cpu_relax(); 38362306a36Sopenharmony_ci goto retry; 38462306a36Sopenharmony_ci } else if (rc == H_SUCCESS) 38562306a36Sopenharmony_ci return rc; 38662306a36Sopenharmony_ci 38762306a36Sopenharmony_ci BUG(); 38862306a36Sopenharmony_ci } 38962306a36Sopenharmony_ci} 39062306a36Sopenharmony_ci 39162306a36Sopenharmony_ci#else /* !CONFIG_PPC_PSERIES */ 39262306a36Sopenharmony_ci 39362306a36Sopenharmony_cistatic inline long plpar_set_ciabr(unsigned long ciabr) 39462306a36Sopenharmony_ci{ 39562306a36Sopenharmony_ci return 0; 39662306a36Sopenharmony_ci} 39762306a36Sopenharmony_ci 39862306a36Sopenharmony_cistatic inline long plpar_pte_read_4(unsigned long flags, unsigned long ptex, 39962306a36Sopenharmony_ci unsigned long *ptes) 40062306a36Sopenharmony_ci{ 40162306a36Sopenharmony_ci return 0; 40262306a36Sopenharmony_ci} 40362306a36Sopenharmony_ci 40462306a36Sopenharmony_cistatic inline long pseries_rpt_invalidate(u32 pid, u64 target, u64 type, 40562306a36Sopenharmony_ci u64 page_sizes, u64 start, u64 end) 40662306a36Sopenharmony_ci{ 40762306a36Sopenharmony_ci return 0; 40862306a36Sopenharmony_ci} 40962306a36Sopenharmony_ci 41062306a36Sopenharmony_ci#endif /* CONFIG_PPC_PSERIES */ 41162306a36Sopenharmony_ci 41262306a36Sopenharmony_ci#endif /* _ASM_POWERPC_PLPAR_WRAPPERS_H */ 413