diff options
| author | David S. Miller <davem@davemloft.net> | 2010-08-24 02:10:57 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2010-08-24 02:10:57 -0400 |
| commit | 25edd6946a1d74e5e77813c2324a0908c68bcf9e (patch) | |
| tree | 29afc2a7287df17776e4e2b4a6ee78b108c09f10 | |
| parent | 019408f9b89c68cd7b8ddb904960dc17ccf7e531 (diff) | |
sparc64: Get rid of indirect p1275 PROM call buffer.
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>
| -rw-r--r-- | arch/sparc/include/asm/oplib_64.h | 27 | ||||
| -rw-r--r-- | arch/sparc/prom/cif.S | 16 | ||||
| -rw-r--r-- | arch/sparc/prom/console_64.c | 48 | ||||
| -rw-r--r-- | arch/sparc/prom/devops_64.c | 36 | ||||
| -rw-r--r-- | arch/sparc/prom/misc_64.c | 314 | ||||
| -rw-r--r-- | arch/sparc/prom/p1275.c | 102 | ||||
| -rw-r--r-- | arch/sparc/prom/tree_64.c | 210 |
7 files changed, 456 insertions, 297 deletions
diff --git a/arch/sparc/include/asm/oplib_64.h b/arch/sparc/include/asm/oplib_64.h index a5db0317b5fb..3e0b2d62303d 100644 --- a/arch/sparc/include/asm/oplib_64.h +++ b/arch/sparc/include/asm/oplib_64.h | |||
| @@ -185,9 +185,8 @@ extern int prom_getunumber(int syndrome_code, | |||
| 185 | char *buf, int buflen); | 185 | char *buf, int buflen); |
| 186 | 186 | ||
| 187 | /* Retain physical memory to the caller across soft resets. */ | 187 | /* Retain physical memory to the caller across soft resets. */ |
| 188 | extern unsigned long prom_retain(const char *name, | 188 | extern int prom_retain(const char *name, unsigned long size, |
| 189 | unsigned long pa_low, unsigned long pa_high, | 189 | unsigned long align, unsigned long *paddr); |
| 190 | long size, long align); | ||
| 191 | 190 | ||
| 192 | /* Load explicit I/D TLB entries into the calling processor. */ | 191 | /* Load explicit I/D TLB entries into the calling processor. */ |
| 193 | extern long prom_itlb_load(unsigned long index, | 192 | extern long prom_itlb_load(unsigned long index, |
| @@ -287,26 +286,6 @@ extern void prom_sun4v_guest_soft_state(void); | |||
| 287 | extern int prom_ihandle2path(int handle, char *buffer, int bufsize); | 286 | extern int prom_ihandle2path(int handle, char *buffer, int bufsize); |
| 288 | 287 | ||
| 289 | /* Client interface level routines. */ | 288 | /* Client interface level routines. */ |
| 290 | extern long p1275_cmd(const char *, long, ...); | 289 | extern void p1275_cmd_direct(unsigned long *); |
| 291 | |||
| 292 | #if 0 | ||
| 293 | #define P1275_SIZE(x) ((((long)((x) / 32)) << 32) | (x)) | ||
| 294 | #else | ||
| 295 | #define P1275_SIZE(x) x | ||
| 296 | #endif | ||
| 297 | |||
| 298 | /* We support at most 16 input and 1 output argument */ | ||
| 299 | #define P1275_ARG_NUMBER 0 | ||
| 300 | #define P1275_ARG_IN_STRING 1 | ||
| 301 | #define P1275_ARG_OUT_BUF 2 | ||
| 302 | #define P1275_ARG_OUT_32B 3 | ||
| 303 | #define P1275_ARG_IN_FUNCTION 4 | ||
| 304 | #define P1275_ARG_IN_BUF 5 | ||
| 305 | #define P1275_ARG_IN_64B 6 | ||
| 306 | |||
| 307 | #define P1275_IN(x) ((x) & 0xf) | ||
| 308 | #define P1275_OUT(x) (((x) << 4) & 0xf0) | ||
| 309 | #define P1275_INOUT(i,o) (P1275_IN(i)|P1275_OUT(o)) | ||
| 310 | #define P1275_ARG(n,x) ((x) << ((n)*3 + 8)) | ||
| 311 | 290 | ||
| 312 | #endif /* !(__SPARC64_OPLIB_H) */ | 291 | #endif /* !(__SPARC64_OPLIB_H) */ |
diff --git a/arch/sparc/prom/cif.S b/arch/sparc/prom/cif.S index 5f27ad779c0c..9c86b4b7d429 100644 --- a/arch/sparc/prom/cif.S +++ b/arch/sparc/prom/cif.S | |||
| @@ -9,18 +9,18 @@ | |||
| 9 | #include <asm/thread_info.h> | 9 | #include <asm/thread_info.h> |
| 10 | 10 | ||
| 11 | .text | 11 | .text |
| 12 | .globl prom_cif_interface | 12 | .globl prom_cif_direct |
| 13 | prom_cif_interface: | 13 | prom_cif_direct: |
| 14 | sethi %hi(p1275buf), %o0 | 14 | sethi %hi(p1275buf), %o1 |
| 15 | or %o0, %lo(p1275buf), %o0 | 15 | or %o1, %lo(p1275buf), %o1 |
| 16 | ldx [%o0 + 0x010], %o1 ! prom_cif_stack | 16 | ldx [%o1 + 0x0010], %o2 ! prom_cif_stack |
| 17 | save %o1, -192, %sp | 17 | save %o2, -192, %sp |
| 18 | ldx [%i0 + 0x008], %l2 ! prom_cif_handler | 18 | ldx [%i1 + 0x0008], %l2 ! prom_cif_handler |
| 19 | mov %g4, %l0 | 19 | mov %g4, %l0 |
| 20 | mov %g5, %l1 | 20 | mov %g5, %l1 |
| 21 | mov %g6, %l3 | 21 | mov %g6, %l3 |
| 22 | call %l2 | 22 | call %l2 |
| 23 | add %i0, 0x018, %o0 ! prom_args | 23 | mov %i0, %o0 ! prom_args |
| 24 | mov %l0, %g4 | 24 | mov %l0, %g4 |
| 25 | mov %l1, %g5 | 25 | mov %l1, %g5 |
| 26 | mov %l3, %g6 | 26 | mov %l3, %g6 |
diff --git a/arch/sparc/prom/console_64.c b/arch/sparc/prom/console_64.c index f55d58a8a156..10322dc2f557 100644 --- a/arch/sparc/prom/console_64.c +++ b/arch/sparc/prom/console_64.c | |||
| @@ -21,14 +21,22 @@ extern int prom_stdin, prom_stdout; | |||
| 21 | inline int | 21 | inline int |
| 22 | prom_nbgetchar(void) | 22 | prom_nbgetchar(void) |
| 23 | { | 23 | { |
| 24 | unsigned long args[7]; | ||
| 24 | char inc; | 25 | char inc; |
| 25 | 26 | ||
| 26 | if (p1275_cmd("read", P1275_ARG(1,P1275_ARG_OUT_BUF)| | 27 | args[0] = (unsigned long) "read"; |
| 27 | P1275_INOUT(3,1), | 28 | args[1] = 3; |
| 28 | prom_stdin, &inc, P1275_SIZE(1)) == 1) | 29 | args[2] = 1; |
| 30 | args[3] = (unsigned int) prom_stdin; | ||
| 31 | args[4] = (unsigned long) &inc; | ||
| 32 | args[5] = 1; | ||
| 33 | args[6] = (unsigned long) -1; | ||
| 34 | |||
| 35 | p1275_cmd_direct(args); | ||
| 36 | |||
| 37 | if (args[6] == 1) | ||
| 29 | return inc; | 38 | return inc; |
| 30 | else | 39 | return -1; |
| 31 | return -1; | ||
| 32 | } | 40 | } |
| 33 | 41 | ||
| 34 | /* Non blocking put character to console device, returns -1 if | 42 | /* Non blocking put character to console device, returns -1 if |
| @@ -37,12 +45,22 @@ prom_nbgetchar(void) | |||
| 37 | inline int | 45 | inline int |
| 38 | prom_nbputchar(char c) | 46 | prom_nbputchar(char c) |
| 39 | { | 47 | { |
| 48 | unsigned long args[7]; | ||
| 40 | char outc; | 49 | char outc; |
| 41 | 50 | ||
| 42 | outc = c; | 51 | outc = c; |
| 43 | if (p1275_cmd("write", P1275_ARG(1,P1275_ARG_IN_BUF)| | 52 | |
| 44 | P1275_INOUT(3,1), | 53 | args[0] = (unsigned long) "write"; |
| 45 | prom_stdout, &outc, P1275_SIZE(1)) == 1) | 54 | args[1] = 3; |
| 55 | args[2] = 1; | ||
| 56 | args[3] = (unsigned int) prom_stdout; | ||
| 57 | args[4] = (unsigned long) &outc; | ||
| 58 | args[5] = 1; | ||
| 59 | args[6] = (unsigned long) -1; | ||
| 60 | |||
| 61 | p1275_cmd_direct(args); | ||
| 62 | |||
| 63 | if (args[6] == 1) | ||
| 46 | return 0; | 64 | return 0; |
| 47 | else | 65 | else |
| 48 | return -1; | 66 | return -1; |
| @@ -67,7 +85,15 @@ prom_putchar(char c) | |||
| 67 | void | 85 | void |
| 68 | prom_puts(const char *s, int len) | 86 | prom_puts(const char *s, int len) |
| 69 | { | 87 | { |
| 70 | p1275_cmd("write", P1275_ARG(1,P1275_ARG_IN_BUF)| | 88 | unsigned long args[7]; |
| 71 | P1275_INOUT(3,1), | 89 | |
| 72 | prom_stdout, s, P1275_SIZE(len)); | 90 | args[0] = (unsigned long) "write"; |
| 91 | args[1] = 3; | ||
| 92 | args[2] = 1; | ||
| 93 | args[3] = (unsigned int) prom_stdout; | ||
| 94 | args[4] = (unsigned long) s; | ||
| 95 | args[5] = len; | ||
| 96 | args[6] = (unsigned long) -1; | ||
| 97 | |||
| 98 | p1275_cmd_direct(args); | ||
| 73 | } | 99 | } |
diff --git a/arch/sparc/prom/devops_64.c b/arch/sparc/prom/devops_64.c index 9dbd803e46e1..a017119e7ef1 100644 --- a/arch/sparc/prom/devops_64.c +++ b/arch/sparc/prom/devops_64.c | |||
| @@ -18,16 +18,32 @@ | |||
| 18 | int | 18 | int |
| 19 | prom_devopen(const char *dstr) | 19 | prom_devopen(const char *dstr) |
| 20 | { | 20 | { |
| 21 | return p1275_cmd ("open", P1275_ARG(0,P1275_ARG_IN_STRING)| | 21 | unsigned long args[5]; |
| 22 | P1275_INOUT(1,1), | 22 | |
| 23 | dstr); | 23 | args[0] = (unsigned long) "open"; |
| 24 | args[1] = 1; | ||
| 25 | args[2] = 1; | ||
| 26 | args[3] = (unsigned long) dstr; | ||
| 27 | args[4] = (unsigned long) -1; | ||
| 28 | |||
| 29 | p1275_cmd_direct(args); | ||
| 30 | |||
| 31 | return (int) args[4]; | ||
| 24 | } | 32 | } |
| 25 | 33 | ||
| 26 | /* Close the device described by device handle 'dhandle'. */ | 34 | /* Close the device described by device handle 'dhandle'. */ |
| 27 | int | 35 | int |
