Skip to content

Commit

Permalink
[POWERPC] clean up pseries hcall interfaces
Browse files Browse the repository at this point in the history
Our pseries hcall interfaces are out of control:

	plpar_hcall_norets
	plpar_hcall
	plpar_hcall_8arg_2ret
	plpar_hcall_4out
	plpar_hcall_7arg_7ret
	plpar_hcall_9arg_9ret

Create 3 interfaces to cover all cases:

	plpar_hcall_norets:	7 arguments no returns
	plpar_hcall:		6 arguments 4 returns
	plpar_hcall9:		9 arguments 9 returns

There are only 2 cases in the kernel that need plpar_hcall9, hopefully
we can keep it that way.

Pass in a buffer to stash return parameters so we avoid the &dummy1,
&dummy2 madness.

Signed-off-by: Anton Blanchard <anton@samba.org>
--
Signed-off-by: Paul Mackerras <paulus@samba.org>
  • Loading branch information
Anton Blanchard authored and Paul Mackerras committed Aug 1, 2006
1 parent 57cad80 commit b9377ff
Show file tree
Hide file tree
Showing 10 changed files with 184 additions and 313 deletions.
18 changes: 14 additions & 4 deletions arch/powerpc/kernel/lparcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,14 @@ static unsigned int h_get_ppp(unsigned long *entitled,
unsigned long *resource)
{
unsigned long rc;
rc = plpar_hcall_4out(H_GET_PPP, 0, 0, 0, 0, entitled, unallocated,
aggregation, resource);
unsigned long retbuf[PLPAR_HCALL_BUFSIZE];

rc = plpar_hcall(H_GET_PPP, retbuf);

*entitled = retbuf[0];
*unallocated = retbuf[1];
*aggregation = retbuf[2];
*resource = retbuf[3];

log_plpar_hcall_return(rc, "H_GET_PPP");

Expand All @@ -193,8 +199,12 @@ static unsigned int h_get_ppp(unsigned long *entitled,
static void h_pic(unsigned long *pool_idle_time, unsigned long *num_procs)
{
unsigned long rc;
unsigned long dummy;
rc = plpar_hcall(H_PIC, 0, 0, 0, 0, pool_idle_time, num_procs, &dummy);
unsigned long retbuf[PLPAR_HCALL_BUFSIZE];

rc = plpar_hcall(H_PIC, retbuf);

*pool_idle_time = retbuf[0];
*num_procs = retbuf[1];

if (rc != H_AUTHORITY)
log_plpar_hcall_return(rc, "H_PIC");
Expand Down
11 changes: 5 additions & 6 deletions arch/powerpc/kernel/rtas.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,15 +668,14 @@ static int rtas_ibm_suspend_me(struct rtas_args *args)
int i;
long state;
long rc;
unsigned long dummy;

unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
struct rtas_suspend_me_data data;

/* Make sure the state is valid */
rc = plpar_hcall(H_VASI_STATE,
((u64)args->args[0] << 32) | args->args[1],
0, 0, 0,
&state, &dummy, &dummy);
rc = plpar_hcall(H_VASI_STATE, retbuf,
((u64)args->args[0] << 32) | args->args[1]);

state = retbuf[0];

if (rc) {
printk(KERN_ERR "rtas_ibm_suspend_me: vasi_state returned %ld\n",rc);
Expand Down
207 changes: 35 additions & 172 deletions arch/powerpc/platforms/pseries/hvCall.S
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*
* This file contains the generic code to perform a call to the
* pSeries LPAR hypervisor.
* NOTE: this file will go away when we move to inline this work.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Expand All @@ -16,42 +15,6 @@

.text

/* long plpar_hcall(unsigned long opcode, R3
unsigned long arg1, R4
unsigned long arg2, R5
unsigned long arg3, R6
unsigned long arg4, R7
unsigned long *out1, R8
unsigned long *out2, R9
unsigned long *out3); R10
*/
_GLOBAL(plpar_hcall)
HMT_MEDIUM

mfcr r0

std r8,STK_PARM(r8)(r1) /* Save out ptrs */
std r9,STK_PARM(r9)(r1)
std r10,STK_PARM(r10)(r1)

stw r0,8(r1)

HVSC /* invoke the hypervisor */

lwz r0,8(r1)

ld r8,STK_PARM(r8)(r1) /* Fetch r4-r6 ret args */
ld r9,STK_PARM(r9)(r1)
ld r10,STK_PARM(r10)(r1)
std r4,0(r8)
std r5,0(r9)
std r6,0(r10)

mtcrf 0xff,r0
blr /* return r3 = status */


/* Simple interface with no output values (other than status) */
_GLOBAL(plpar_hcall_norets)
HMT_MEDIUM

Expand All @@ -64,164 +27,64 @@ _GLOBAL(plpar_hcall_norets)
mtcrf 0xff,r0
blr /* return r3 = status */


/* long plpar_hcall_8arg_2ret(unsigned long opcode, R3
unsigned long arg1, R4
unsigned long arg2, R5
unsigned long arg3, R6
unsigned long arg4, R7
unsigned long arg5, R8
unsigned long arg6, R9
unsigned long arg7, R10
unsigned long arg8, 112(R1)
unsigned long *out1); 120(R1)
*/
_GLOBAL(plpar_hcall_8arg_2ret)
_GLOBAL(plpar_hcall)
HMT_MEDIUM

mfcr r0
ld r11,STK_PARM(r11)(r1) /* put arg8 in R11 */
stw r0,8(r1)

HVSC /* invoke the hypervisor */

lwz r0,8(r1)
ld r10,STK_PARM(r12)(r1) /* Fetch r4 ret arg */
std r4,0(r10)
mtcrf 0xff,r0
blr /* return r3 = status */


/* long plpar_hcall_4out(unsigned long opcode, R3
unsigned long arg1, R4
unsigned long arg2, R5
unsigned long arg3, R6
unsigned long arg4, R7
unsigned long *out1, R8
unsigned long *out2, R9
unsigned long *out3, R10
unsigned long *out4); 112(R1)
*/
_GLOBAL(plpar_hcall_4out)
HMT_MEDIUM

mfcr r0
stw r0,8(r1)
std r4,STK_PARM(r4)(r1) /* Save ret buffer */

std r8,STK_PARM(r8)(r1) /* Save out ptrs */
std r9,STK_PARM(r9)(r1)
std r10,STK_PARM(r10)(r1)
mr r4,r5
mr r5,r6
mr r6,r7
mr r7,r8
mr r8,r9
mr r9,r10

HVSC /* invoke the hypervisor */

lwz r0,8(r1)

ld r8,STK_PARM(r8)(r1) /* Fetch r4-r7 ret args */
ld r9,STK_PARM(r9)(r1)
ld r10,STK_PARM(r10)(r1)
ld r11,STK_PARM(r11)(r1)
std r4,0(r8)
std r5,0(r9)
std r6,0(r10)
std r7,0(r11)

mtcrf 0xff,r0
blr /* return r3 = status */

/* plpar_hcall_7arg_7ret(unsigned long opcode, R3
unsigned long arg1, R4
unsigned long arg2, R5
unsigned long arg3, R6
unsigned long arg4, R7
unsigned long arg5, R8
unsigned long arg6, R9
unsigned long arg7, R10
unsigned long *out1, 112(R1)
unsigned long *out2, 110(R1)
unsigned long *out3, 108(R1)
unsigned long *out4, 106(R1)
unsigned long *out5, 104(R1)
unsigned long *out6, 102(R1)
unsigned long *out7); 100(R1)
*/
_GLOBAL(plpar_hcall_7arg_7ret)
HMT_MEDIUM

mfcr r0
stw r0,8(r1)

HVSC /* invoke the hypervisor */
ld r12,STK_PARM(r4)(r1)
std r4, 0(r12)
std r5, 8(r12)
std r6, 16(r12)
std r7, 24(r12)

lwz r0,8(r1)

ld r11,STK_PARM(r11)(r1) /* Fetch r4 ret arg */
std r4,0(r11)
ld r11,STK_PARM(r12)(r1) /* Fetch r5 ret arg */
std r5,0(r11)
ld r11,STK_PARM(r13)(r1) /* Fetch r6 ret arg */
std r6,0(r11)
ld r11,STK_PARM(r14)(r1) /* Fetch r7 ret arg */
std r7,0(r11)
ld r11,STK_PARM(r15)(r1) /* Fetch r8 ret arg */
std r8,0(r11)
ld r11,STK_PARM(r16)(r1) /* Fetch r9 ret arg */
std r9,0(r11)
ld r11,STK_PARM(r17)(r1) /* Fetch r10 ret arg */
std r10,0(r11)

mtcrf 0xff,r0

blr /* return r3 = status */

/* plpar_hcall_9arg_9ret(unsigned long opcode, R3
unsigned long arg1, R4
unsigned long arg2, R5
unsigned long arg3, R6
unsigned long arg4, R7
unsigned long arg5, R8
unsigned long arg6, R9
unsigned long arg7, R10
unsigned long arg8, 112(R1)
unsigned long arg9, 110(R1)
unsigned long *out1, 108(R1)
unsigned long *out2, 106(R1)
unsigned long *out3, 104(R1)
unsigned long *out4, 102(R1)
unsigned long *out5, 100(R1)
unsigned long *out6, 98(R1)
unsigned long *out7); 96(R1)
unsigned long *out8, 94(R1)
unsigned long *out9, 92(R1)
*/
_GLOBAL(plpar_hcall_9arg_9ret)
_GLOBAL(plpar_hcall9)
HMT_MEDIUM

mfcr r0
stw r0,8(r1)

ld r11,STK_PARM(r11)(r1) /* put arg8 in R11 */
ld r12,STK_PARM(r12)(r1) /* put arg9 in R12 */
std r4,STK_PARM(r4)(r1) /* Save ret buffer */

mr r4,r5
mr r5,r6
mr r6,r7
mr r7,r8
mr r8,r9
mr r9,r10
ld r10,STK_PARM(r11)(r1) /* put arg7 in R10 */
ld r11,STK_PARM(r12)(r1) /* put arg8 in R11 */
ld r12,STK_PARM(r13)(r1) /* put arg9 in R12 */

HVSC /* invoke the hypervisor */

ld r0,STK_PARM(r13)(r1) /* Fetch r4 ret arg */
stdx r4,r0,r0
ld r0,STK_PARM(r14)(r1) /* Fetch r5 ret arg */
stdx r5,r0,r0
ld r0,STK_PARM(r15)(r1) /* Fetch r6 ret arg */
stdx r6,r0,r0
ld r0,STK_PARM(r16)(r1) /* Fetch r7 ret arg */
stdx r7,r0,r0
ld r0,STK_PARM(r17)(r1) /* Fetch r8 ret arg */
stdx r8,r0,r0
ld r0,STK_PARM(r18)(r1) /* Fetch r9 ret arg */
stdx r9,r0,r0
ld r0,STK_PARM(r19)(r1) /* Fetch r10 ret arg */
stdx r10,r0,r0
ld r0,STK_PARM(r20)(r1) /* Fetch r11 ret arg */
stdx r11,r0,r0
ld r0,STK_PARM(r21)(r1) /* Fetch r12 ret arg */
stdx r12,r0,r0
ld r12,STK_PARM(r4)(r1)
std r4, 0(r12)
std r5, 8(r12)
std r6, 16(r12)
std r7, 24(r12)
std r8, 32(r12)
std r9, 40(r12)
std r10,48(r12)
std r11,56(r12)
std r12,64(r12)

lwz r0,8(r1)
mtcrf 0xff,r0
Expand Down
5 changes: 3 additions & 2 deletions arch/powerpc/platforms/pseries/hvconsole.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <linux/module.h>
#include <asm/hvcall.h>
#include <asm/hvconsole.h>
#include "plpar_wrappers.h"

/**
* hvc_get_chars - retrieve characters from firmware for denoted vterm adatper
Expand All @@ -40,9 +41,9 @@ int hvc_get_chars(uint32_t vtermno, char *buf, int count)
{
unsigned long got;

if (plpar_hcall(H_GET_TERM_CHAR, vtermno, 0, 0, 0, &got,
(unsigned long *)buf, (unsigned long *)buf+1) == H_SUCCESS)
if (plpar_get_term_char(vtermno, &got, buf) == H_SUCCESS)
return got;

return 0;
}

Expand Down
12 changes: 4 additions & 8 deletions arch/powerpc/platforms/pseries/lpar.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,11 @@
#define DBG_LOW(fmt...) do { } while(0)
#endif

/* in pSeries_hvCall.S */
/* in hvCall.S */
EXPORT_SYMBOL(plpar_hcall);
EXPORT_SYMBOL(plpar_hcall_4out);
EXPORT_SYMBOL(plpar_hcall9);
EXPORT_SYMBOL(plpar_hcall_norets);
EXPORT_SYMBOL(plpar_hcall_8arg_2ret);
EXPORT_SYMBOL(plpar_hcall_7arg_7ret);
EXPORT_SYMBOL(plpar_hcall_9arg_9ret);

extern void pSeries_find_serial_port(void);


Expand Down Expand Up @@ -277,7 +275,6 @@ long pSeries_lpar_hpte_insert(unsigned long hpte_group,
unsigned long flags;
unsigned long slot;
unsigned long hpte_v, hpte_r;
unsigned long dummy0, dummy1;

if (!(vflags & HPTE_V_BOLTED))
DBG_LOW("hpte_insert(group=%lx, va=%016lx, pa=%016lx, "
Expand All @@ -302,8 +299,7 @@ long pSeries_lpar_hpte_insert(unsigned long hpte_group,
if (rflags & (_PAGE_GUARDED|_PAGE_NO_CACHE))
hpte_r &= ~_PAGE_COHERENT;

lpar_rc = plpar_hcall(H_ENTER, flags, hpte_group, hpte_v,
hpte_r, &slot, &dummy0, &dummy1);
lpar_rc = plpar_pte_enter(flags, hpte_group, hpte_v, hpte_r, &slot);
if (unlikely(lpar_rc == H_PTEG_FULL)) {
if (!(vflags & HPTE_V_BOLTED))
DBG_LOW(" full\n");
Expand Down
Loading

0 comments on commit b9377ff

Please sign in to comment.