Skip to content

Commit

Permalink
sparc64: Get rid of indirect p1275 PROM call buffer.
Browse files Browse the repository at this point in the history
[ Upstream commit 25edd69 ]

This is based upon a report by Meelis Roos showing that it's possible
that we'll try to fetch a property that is 32K in size with some
devices.  With the current fixed 3K buffer we use for moving data in
and out of the firmware during PROM calls, that simply won't work.

In fact, it will scramble random kernel data during bootup.

The reasoning behind the temporary buffer is entirely historical.  It
used to be the case that we had problems referencing dynamic kernel
memory (including the stack) early in the boot process before we
explicitly told the firwmare to switch us over to the kernel trap
table.

So what we did was always give the firmware buffers that were locked
into the main kernel image.

But we no longer have problems like that, so get rid of all of this
indirect bounce buffering.

Besides fixing Meelis's bug, this also makes the kernel data about 3K
smaller.

It was also discovered during these conversions that the
implementation of prom_retain() was completely wrong, so that was
fixed here as well.  Currently that interface is not in use.

Reported-by: Meelis Roos <mroos@linux.ee>
Tested-by: Meelis Roos <mroos@linux.ee>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
davem330 authored and gregkh committed Sep 27, 2010
1 parent 1919a55 commit df7b44d
Show file tree
Hide file tree
Showing 7 changed files with 456 additions and 297 deletions.
27 changes: 3 additions & 24 deletions arch/sparc/include/asm/oplib_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,8 @@ extern int prom_getunumber(int syndrome_code,
char *buf, int buflen);

/* Retain physical memory to the caller across soft resets. */
extern unsigned long prom_retain(const char *name,
unsigned long pa_low, unsigned long pa_high,
long size, long align);
extern int prom_retain(const char *name, unsigned long size,
unsigned long align, unsigned long *paddr);

/* Load explicit I/D TLB entries into the calling processor. */
extern long prom_itlb_load(unsigned long index,
Expand Down Expand Up @@ -287,26 +286,6 @@ extern void prom_sun4v_guest_soft_state(void);
extern int prom_ihandle2path(int handle, char *buffer, int bufsize);

/* Client interface level routines. */
extern long p1275_cmd(const char *, long, ...);

#if 0
#define P1275_SIZE(x) ((((long)((x) / 32)) << 32) | (x))
#else
#define P1275_SIZE(x) x
#endif

/* We support at most 16 input and 1 output argument */
#define P1275_ARG_NUMBER 0
#define P1275_ARG_IN_STRING 1
#define P1275_ARG_OUT_BUF 2
#define P1275_ARG_OUT_32B 3
#define P1275_ARG_IN_FUNCTION 4
#define P1275_ARG_IN_BUF 5
#define P1275_ARG_IN_64B 6

#define P1275_IN(x) ((x) & 0xf)
#define P1275_OUT(x) (((x) << 4) & 0xf0)
#define P1275_INOUT(i,o) (P1275_IN(i)|P1275_OUT(o))
#define P1275_ARG(n,x) ((x) << ((n)*3 + 8))
extern void p1275_cmd_direct(unsigned long *);

#endif /* !(__SPARC64_OPLIB_H) */
16 changes: 8 additions & 8 deletions arch/sparc/prom/cif.S
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
#include <asm/thread_info.h>

.text
.globl prom_cif_interface
prom_cif_interface:
sethi %hi(p1275buf), %o0
or %o0, %lo(p1275buf), %o0
ldx [%o0 + 0x010], %o1 ! prom_cif_stack
save %o1, -192, %sp
ldx [%i0 + 0x008], %l2 ! prom_cif_handler
.globl prom_cif_direct
prom_cif_direct:
sethi %hi(p1275buf), %o1
or %o1, %lo(p1275buf), %o1
ldx [%o1 + 0x0010], %o2 ! prom_cif_stack
save %o2, -192, %sp
ldx [%i1 + 0x0008], %l2 ! prom_cif_handler
mov %g4, %l0
mov %g5, %l1
mov %g6, %l3
call %l2
add %i0, 0x018, %o0 ! prom_args
mov %i0, %o0 ! prom_args
mov %l0, %g4
mov %l1, %g5
mov %l3, %g6
Expand Down
48 changes: 37 additions & 11 deletions arch/sparc/prom/console_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,22 @@ extern int prom_stdin, prom_stdout;
inline int
prom_nbgetchar(void)
{
unsigned long args[7];
char inc;

if (p1275_cmd("read", P1275_ARG(1,P1275_ARG_OUT_BUF)|
P1275_INOUT(3,1),
prom_stdin, &inc, P1275_SIZE(1)) == 1)
args[0] = (unsigned long) "read";
args[1] = 3;
args[2] = 1;
args[3] = (unsigned int) prom_stdin;
args[4] = (unsigned long) &inc;
args[5] = 1;
args[6] = (unsigned long) -1;

p1275_cmd_direct(args);

if (args[6] == 1)
return inc;
else
return -1;
return -1;
}

/* Non blocking put character to console device, returns -1 if
Expand All @@ -37,12 +45,22 @@ prom_nbgetchar(void)
inline int
prom_nbputchar(char c)
{
unsigned long args[7];
char outc;

outc = c;
if (p1275_cmd("write", P1275_ARG(1,P1275_ARG_IN_BUF)|
P1275_INOUT(3,1),
prom_stdout, &outc, P1275_SIZE(1)) == 1)

args[0] = (unsigned long) "write";
args[1] = 3;
args[2] = 1;
args[3] = (unsigned int) prom_stdout;
args[4] = (unsigned long) &outc;
args[5] = 1;
args[6] = (unsigned long) -1;

p1275_cmd_direct(args);

if (args[6] == 1)
return 0;
else
return -1;
Expand All @@ -67,7 +85,15 @@ prom_putchar(char c)
void
prom_puts(const char *s, int len)
{
p1275_cmd("write", P1275_ARG(1,P1275_ARG_IN_BUF)|
P1275_INOUT(3,1),
prom_stdout, s, P1275_SIZE(len));
unsigned long args[7];

args[0] = (unsigned long) "write";
args[1] = 3;
args[2] = 1;
args[3] = (unsigned int) prom_stdout;
args[4] = (unsigned long) s;
args[5] = len;
args[6] = (unsigned long) -1;

p1275_cmd_direct(args);
}
36 changes: 31 additions & 5 deletions arch/sparc/prom/devops_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,32 @@
int
prom_devopen(const char *dstr)
{
return p1275_cmd ("open", P1275_ARG(0,P1275_ARG_IN_STRING)|
P1275_INOUT(1,1),
dstr);
unsigned long args[5];

args[0] = (unsigned long) "open";
args[1] = 1;
args[2] = 1;
args[3] = (unsigned long) dstr;
args[4] = (unsigned long) -1;

p1275_cmd_direct(args);

return (int) args[4];
}

/* Close the device described by device handle 'dhandle'. */
int
prom_devclose(int dhandle)
{
p1275_cmd ("close", P1275_INOUT(1,0), dhandle);
unsigned long args[4];

args[0] = (unsigned long) "close";
args[1] = 1;
args[2] = 0;
args[3] = (unsigned int) dhandle;

p1275_cmd_direct(args);

return 0;
}

Expand All @@ -37,5 +53,15 @@ prom_devclose(int dhandle)
void
prom_seek(int dhandle, unsigned int seekhi, unsigned int seeklo)
{
p1275_cmd ("seek", P1275_INOUT(3,1), dhandle, seekhi, seeklo);
unsigned long args[7];

args[0] = (unsigned long) "seek";
args[1] = 3;
args[2] = 1;
args[3] = (unsigned int) dhandle;
args[4] = seekhi;
args[5] = seeklo;
args[6] = (unsigned long) -1;

p1275_cmd_direct(args);
}
Loading

0 comments on commit df7b44d

Please sign in to comment.