ps3: Support more than the OtherOS lpar
Subsystems (6)
cover ps3: Support more than the OtherOS lpar
This series addresses various issues and extends support when running in lpars like GameOS. Included are some patches from Hector Martin, which I found useful.
The ps3disk driver now creates multiple block devices instead of just one. On the GameOS lpar we have access to all regions, and - depending on the customizable layout - the linux partitions are likely not on the first. The device names look similar the bsd slices, a bit unusual, but the best I could think of. Better suggestions?
There're 2 new drivers: ps3vflash and ps3nflash. These are just modified copies of the ps3disk driver:
diff -u drivers/block/ps3disk.c drivers/block/ps3vflash.c
and "worse":
diff -u drivers/block/ps3vflash.c drivers/block/ps3nflash.c
I'm not sure what the desired way to handle these similarities are. Should that be merged to avoid code duplication? If so, how?
Patches are based on 2.6.39 since master doesn't boot with smp on my console. I wasn't able to pinpoint the cause so far (not that I tried too hard). If anything get accepted I'll rebase :)
All patches were tested with the AsbestOS bootloader from Hector Martin (http://git.marcansoft.com/?p=asbestos.git) on a PS3 slim.
Note: There are various patches floating around from anonymous developers. None of those are signed-off and had various issues. While some of those do contain simliar changes, I redid everything in this series from scratch (except the patches from Hector).
Please let me know If there're any issues!
Thanks,
Andre
Andre Heider (12):
ps3: MEMORY_HOTPLUG is not a requirement anymore
ps3: Detect the current lpar environment
ps3flash: Fix region align checks
ps3flash: Refuse to work in lpars other than OtherOS
ps3: Only prealloc the flash bounce buffer for the OtherOS lpar
ps3: Limit the number of regions per storage device
ps3stor_lib: Add support for multiple regions
ps3disk: Provide a gendisk per accessible region
ps3stor_lib: Add support for storage access flags
ps3disk: Use region flags
ps3: Add a vflash driver for lpars other than OtherOS
ps3: Add a NOR FLASH driver for PS3s without NAND
Hector Martin (3):
[PS3] Add udbg driver using the PS3 gelic Ethernet device [PS3] Get lv1 high memory region from devtree [PS3] Add region 1 memory early
arch/powerpc/Kconfig.debug | 8 + arch/powerpc/include/asm/ps3.h | 9 + arch/powerpc/include/asm/ps3stor.h | 11 +- arch/powerpc/include/asm/udbg.h | 1 + arch/powerpc/kernel/udbg.c | 2 + arch/powerpc/platforms/ps3/Kconfig | 43 +++- arch/powerpc/platforms/ps3/Makefile | 1 + arch/powerpc/platforms/ps3/device-init.c | 16 + arch/powerpc/platforms/ps3/gelic_udbg.c | 272 ++++++++++++++++ arch/powerpc/platforms/ps3/mm.c | 91 ++++--- arch/powerpc/platforms/ps3/platform.h | 5 + arch/powerpc/platforms/ps3/repository.c | 19 ++ arch/powerpc/platforms/ps3/setup.c | 27 ++- arch/powerpc/platforms/ps3/system-bus.c | 2 + drivers/block/Makefile | 2 + drivers/block/ps3disk.c | 136 ++++++--- drivers/block/ps3nflash.c | 473 +++++++++++++++++++++++++++ drivers/block/ps3vflash.c | 508 ++++++++++++++++++++++++++++++ drivers/char/ps3flash.c | 56 +++-- drivers/net/ps3_gelic_net.c | 3 + drivers/net/ps3_gelic_net.h | 6 + drivers/ps3/ps3stor_lib.c | 30 +- drivers/scsi/ps3rom.c | 11 +- 23 files changed, 1617 insertions(+), 115 deletions(-) create mode 100644 arch/powerpc/platforms/ps3/gelic_udbg.c create mode 100644 drivers/block/ps3nflash.c create mode 100644 drivers/block/ps3vflash.c
Signature · 1 line
1.7.5.4
PATCH 1/15 Add udbg driver using the PS3 gelic Ethernet device
From: Hector Martin <[email protected]>
--- arch/powerpc/Kconfig.debug | 8 + arch/powerpc/include/asm/udbg.h | 1 + arch/powerpc/kernel/udbg.c | 2 + arch/powerpc/platforms/ps3/Kconfig | 12 ++ arch/powerpc/platforms/ps3/Makefile | 1 + arch/powerpc/platforms/ps3/gelic_udbg.c | 272 +++++++++++++++++++++++++++++++ drivers/net/ps3_gelic_net.c | 3 + drivers/net/ps3_gelic_net.h | 6 + 8 files changed, 305 insertions(+), 0 deletions(-) create mode 100644 arch/powerpc/platforms/ps3/gelic_udbg.c
arch/powerpc/Kconfig.debug +8 -0
@@ -267,6 +267,14 @@ config PPC_EARLY_DEBUG_USBGECKO Select this to enable early debugging for Nintendo GameCube/Wii consoles via an external USB Gecko adapter. +config PPC_EARLY_DEBUG_PS3GELIC + bool "Early debugging through the PS3 Ethernet port" + depends on PPC_PS3 + select PS3GELIC_UDBG + help + Select this to enable early debugging for the PlayStation3 via + UDP broadcasts sent out through the Ethernet port. + endchoice config PPC_EARLY_DEBUG_44x_PHYSLOW
arch/powerpc/include/asm/udbg.h +1 -0
@@ -52,6 +52,7 @@ extern void __init udbg_init_44x_as1(void);extern void __init udbg_init_40x_realmode (void );extern void __init udbg_init_cpm (void );extern void __init udbg_init_usbgecko (void ); +extern void __init udbg_init_ps3gelic (void );#endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_UDBG_H */
arch/powerpc/kernel/udbg.c +2 -0
@@ -62,6 +62,8 @@ void __init udbg_early_init(void)udbg_init_cpm ();#elif defined(CONFIG_PPC_EARLY_DEBUG_USBGECKO )udbg_init_usbgecko (); +#elif defined(CONFIG_PPC_EARLY_DEBUG_PS3GELIC ) +udbg_init_ps3gelic ();#endif #ifdef CONFIG_PPC_EARLY_DEBUG
arch/powerpc/platforms/ps3/Kconfig +12 -0
@@ -148,4 +148,16 @@ config PS3_LPM profiling support of the Cell processor with programs like oprofile and perfmon2, then say Y or M, otherwise say N. +config PS3GELIC_UDBG + bool "PS3 udbg output via UDP broadcasts on Ethernet" + depends on PPC_PS3 + help + Enables udbg early debugging output by sending broadcast UDP + via the Ethernet port (UDP port number 18194). + + This driver uses a trivial implementation and is independent + from the main network driver. + + If in doubt, say N here. + endmenu
arch/powerpc/platforms/ps3/Makefile +1 -0
@@ -2,6 +2,7 @@ obj-y += setup.o mm.o time.o hvcall.o htab.o repository.o obj-y += interrupt.o exports.o os-area.o obj-y += system-bus.o +obj-$(CONFIG_PS3GELIC_UDBG) += gelic_udbg.o obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_SPU_BASE) += spu.o obj-y += device-init.o
arch/powerpc/platforms/ps3/gelic_udbg.c new file +272 -0
272 lines not on this page · raw message
drivers/net/ps3_gelic_net.c +3 -0
@@ -1688,6 +1688,9 @@ static int __devinit ps3_gelic_driver_probe(struct ps3_system_bus_device *dev)int result;pr_debug ("%s: called\n" , __func__); + +udbg_shutdown_ps3gelic (); + result =ps3_open_hv_device (dev);if (result) {
drivers/net/ps3_gelic_net.h +6 -0
@@ -360,6 +360,12 @@ static inline void *port_priv(struct gelic_port *port)return port->priv; } +#ifdef CONFIG_PPC_EARLY_DEBUG_PS3GELIC +extern void udbg_shutdown_ps3gelic (void ); +#else +static inline void udbg_shutdown_ps3gelic (void ) {} +#endif +extern int gelic_card_set_irq_mask (struct gelic_card *card,u64 mask);/* shared netdev ops */ extern void gelic_card_up (struct gelic_card *card);
Signature · 1 line
1.7.5.4
Geoff Levand
maintainerRe: [PATCH 01/15] [PS3] Add udbg driver using the PS3 gelic Ethernet device
arch/powerpc/platforms/ps3/gelic_udbg.c line 2
Quoted 5 lines · Andre Heider
arch/powerpc/platforms/ps3/gelic_udbg.c new file +2
-0@@ -0,0 +1,272 @@ +/* +* arch/powerpc/platforms/ps3/gelic_udbg.c
Don't put file names in files. When the file gets moved, then this will no longer be correct.
arch/powerpc/platforms/ps3/gelic_udbg.c line 6
Quoted 4 lines
arch/powerpc/platforms/ps3/gelic_udbg.c new file +4
-0+* +* udbg debug output routine via GELIC UDP broadcasts +* Copyright (C) 2010 Hector Martin <[email protected]> +* Copyright (C) 2011 Andre Heider <[email protected]>
Some of this seems to be taken from the gelic driver, so shouldn't the copyright info from there be included here?
Quoted 25 lines
arch/powerpc/platforms/ps3/gelic_udbg.c new file +25
-0+* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +*/ + +#include <asm/io.h> +#include <asm/udbg.h> +#include <asm/lv1call.h> + +#define GELIC_BUS_ID 1 +#define GELIC_DEVICE_ID 0 +#define GELIC_DEBUG_PORT 18194 +#define GELIC_MAX_MESSAGE_SIZE 1000 + +#define GELIC_LV1_GET_MAC_ADDRESS 1 +#define GELIC_LV1_GET_VLAN_ID 4 +#define GELIC_LV1_VLAN_TX_ETHERNET_0 2 + +#define GELIC_DESCR_DMA_STAT_MASK 0xf0000000 +#define GELIC_DESCR_DMA_CARDOWNED 0xa0000000 + +#define GELIC_DESCR_TX_DMA_IKE 0x00080000 +#define GELIC_DESCR_TX_DMA_NO_CHKSUM 0x00000000
arch/powerpc/platforms/ps3/gelic_udbg.c line 42
Quoted 10 lines
arch/powerpc/platforms/ps3/gelic_udbg.c new file +10
-0+#define GELIC_DESCR_TX_DMA_FRAME_TAIL 0x00040000 + +#define GELIC_DESCR_DMA_CMD_NO_CHKSUM (GELIC_DESCR_DMA_CARDOWNED | \ + GELIC_DESCR_TX_DMA_IKE | \ + GELIC_DESCR_TX_DMA_NO_CHKSUM) + +static u64 bus_addr; + +struct gelic_descr { +/* as defined by the hardware */
These are BE from the hardware, so should be __beXX types.
Quoted 9 lines
arch/powerpc/platforms/ps3/gelic_udbg.c new file +9
-0+u32 buf_addr; +u32 buf_size; +u32 next_descr_addr; +u32 dmac_cmd_status; +u32 result_size; +u32 valid_size;/* all zeroes for tx */ +u32 data_status; +u32 data_error;/* all zeroes for tx */ +} __attribute__((aligned(32)));
...
Quoted 2 lines
arch/powerpc/platforms/ps3/gelic_udbg.c new file +2
-0+static void gelic_debug_init (void ) +{
...
arch/powerpc/platforms/ps3/gelic_udbg.c line 184
Quoted 5 lines
arch/powerpc/platforms/ps3/gelic_udbg.c new file +5
-0+ result =lv1_net_control (GELIC_BUS_ID ,GELIC_DEVICE_ID , +GELIC_LV1_GET_VLAN_ID , +GELIC_LV1_VLAN_TX_ETHERNET_0 ,0 ,0 , + &vlan_id, &v2); +if (result ==0 ) {
This should be 'if (!result)'
-Geoff
Re: [PATCH 01/15] [PS3] Add udbg driver using the PS3 gelic Ethernet device
Quoted 8 lines · Geoff Levand
arch/powerpc/platforms/ps3/gelic_udbg.c line 2
Quoted 5 lines · Andre Heider
arch/powerpc/platforms/ps3/gelic_udbg.c new file +2
-0@@ -0,0 +1,272 @@ +/* +* arch/powerpc/platforms/ps3/gelic_udbg.c Don't put file names in files. =A0When the file gets moved, then this wil=
l
Quoted 31 lines
no longer be correct.
arch/powerpc/platforms/ps3/gelic_udbg.c line 6
Quoted 4 lines
arch/powerpc/platforms/ps3/gelic_udbg.c new file +4
-0+* +* udbg debug output routine via GELIC UDP broadcasts +* Copyright (C) 2010 Hector Martin <[email protected]> +* Copyright (C) 2011 Andre Heider <[email protected]> Some of this seems to be taken from the gelic driver, so shouldn't the copyright info from there be included here?
Quoted 21 lines
arch/powerpc/platforms/ps3/gelic_udbg.c new file +21
-0+* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +*/ + +#include <asm/io.h> +#include <asm/udbg.h> +#include <asm/lv1call.h> + +#define GELIC_BUS_ID 1 +#define GELIC_DEVICE_ID 0 +#define GELIC_DEBUG_PORT 18194 +#define GELIC_MAX_MESSAGE_SIZE 1000 + +#define GELIC_LV1_GET_MAC_ADDRESS 1 +#define GELIC_LV1_GET_VLAN_ID 4 +#define GELIC_LV1_VLAN_TX_ETHERNET_0 2 + +#define GELIC_DESCR_DMA_STAT_MASK 0xf0000000
Quoted 8 lines
arch/powerpc/platforms/ps3/gelic_udbg.c
Quoted 8 lines
arch/powerpc/platforms/ps3/gelic_udbg.c new file +8
-0+#define GELIC_DESCR_DMA_CARDOWNED 0xa0000000 + +#define GELIC_DESCR_TX_DMA_IKE 0x00080000 +#define GELIC_DESCR_TX_DMA_NO_CHKSUM 0x00000000 +#define GELIC_DESCR_TX_DMA_FRAME_TAIL 0x00040000 + +#define GELIC_DESCR_DMA_CMD_NO_CHKSUM (GELIC_DESCR_DMA_CARDOWNED | \ + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0GELIC_DESCR_TX_DMA_IKE | \
Quoted 1 line
arch/powerpc/platforms/ps3/gelic_udbg.c line 36
Quoted 1 line
arch/powerpc/platforms/ps3/gelic_udbg.c new file +1
-0+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0GELIC_DESCR_TX_DMA_NO_CHKSUM)
Quoted 18 lines
arch/powerpc/platforms/ps3/gelic_udbg.c
Quoted 5 lines
arch/powerpc/platforms/ps3/gelic_udbg.c new file +5
-0+ +static u64 bus_addr; + +struct gelic_descr { + =A0 =A0 /* as defined by the hardware */These are BE from the hardware, so should be
__beXXtypes.arch/powerpc/platforms/ps3/gelic_udbg.c line 50
Quoted 9 lines
arch/powerpc/platforms/ps3/gelic_udbg.c new file +9
-0+ =A0 =A0 u32 buf_addr; + =A0 =A0 u32 buf_size; + =A0 =A0 u32 next_descr_addr; + =A0 =A0 u32 dmac_cmd_status; + =A0 =A0 u32 result_size; + =A0 =A0 u32 valid_size; /* all zeroes for tx */ + =A0 =A0 u32 data_status; + =A0 =A0 u32 data_error; /* all zeroes for tx */ +} __attribute__((aligned(32)));
Quoted 9 lines
...
Quoted 2 lines
arch/powerpc/platforms/ps3/gelic_udbg.c new file +2
-0+static void gelic_debug_init (void ) +{...
Quoted 2 lines
+ =A0 =A0 result =3D lv1_net_control(GELIC_BUS_ID,
GELIC_DEVICE_ID,
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0GELIC_LV1_G=
ET_VLAN_ID,
Quoted 1 line
Quoted 1 line
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0GELIC_LV1_V=
LAN_TX_ETHERNET_0, 0, 0,
Quoted 1 line
Quoted 1 line
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0&vlan_id, &=
v2);
Quoted 3 lines
Quoted 1 line
+ =A0 =A0 if (result =3D=3D 0) {
This should be 'if (!result)'
Ack on all points.
Arnd Bergmann
maintainerRe: [Cbe-oss-dev] [PATCH 01/15] [PS3] Add udbg driver using the PS3 gelic Ethernet device
In reply to Geoff LevandQuoted 7 lines · Geoff Levand
Quoted 4 lines
+ *
+ * udbg debug output routine via GELIC UDP broadcasts
+ * Copyright (C) 2010 Hector Martin <[email protected]>
+ * Copyright (C) 2011 Andre Heider <[email protected]>Some of this seems to be taken from the gelic driver, so shouldn't the copyright info from there be included here?
Moreover, if there is a significant amount of code duplication between this driver and gelic, I would expect to actually share the code instead, either by integrating the udbg code into the gelic driver in form of netconsole support, or by moving the common parts into a separate module.
Arnd
Re: [Cbe-oss-dev] [PATCH 01/15] [PS3] Add udbg driver using the PS3 gelic Ethernet device
Quoted 6 lines · Arnd Bergmann
Quoted 5 lines · Geoff Levand
Quoted 4 lines
+ *
+ * udbg debug output routine via GELIC UDP broadcasts
+ * Copyright (C) 2010 Hector Martin <[email protected]>
+ * Copyright (C) 2011 Andre Heider <[email protected]>
Quoted 8 lines
Quoted 2 lines
Some of this seems to be taken from the gelic driver, so shouldn't the copyright info from there be included here?
Moreover, if there is a significant amount of code duplication between this driver and gelic, I would expect to actually share the code instead, either by integrating the udbg code into the gelic driver in form of netconsole support, or by moving the common parts into a separate module.
No, thankfully there is no significant code duplication :) It contains a few structs and defines found elsewhere, but that's because it's not a real netdev. It just prepares the eth/ip/udp header once for its single purpose, then uses the hypervisor to send and poll
- in contrast to the gelic driver, which reuses its irqhandler for netconsole support.
Re: [Cbe-oss-dev] [PATCH 01/15] [PS3] Add udbg driver using the PS3 gelic Ethernet device
Quoted 16 lines · Andre Heider
Quoted 6 lines · Arnd Bergmann
Quoted 5 lines · Geoff Levand
Quoted 4 lines
+ *
+ * udbg debug output routine via GELIC UDP broadcasts
+ * Copyright (C) 2010 Hector Martin <[email protected]>
+ * Copyright (C) 2011 Andre Heider <[email protected]>Quoted 8 lines
Quoted 2 lines
Some of this seems to be taken from the gelic driver, so shouldn't the copyright info from there be included here?
Moreover, if there is a significant amount of code duplication between this driver and gelic, I would expect to actually share the code instead, either by integrating the udbg code into the gelic driver in form of netconsole support, or by moving the common parts into a separate module.
Quoted 6 lines
No, thankfully there is no significant code duplication :) It contains a few structs and defines found elsewhere, but that's because it's not a real netdev. It just prepares the eth/ip/udp header once for its single purpose, then uses the hypervisor to send and poll
- in contrast to the gelic driver, which reuses its irqhandler for netconsole support.
Ack. As long as it's not enabled by default and understood to be what it is, ie, a tool to debug really early boot code before a more "proper" console is available, I have no objection. There is really no code dup, just a couple of struct definitions and it's not a big deal.
I'll merge it.
Cheers,
Ben.
PATCH 2/15 Get lv1 high memory region from devtree
In reply to Andre HeiderFrom: Hector Martin <[email protected]>
This lets the bootloader preallocate the high lv1 region and pass its location to the kernel through the devtree. Thus, it can be used to hold the initrd. If the property doesn't exist, the kernel retains the old behavior and attempts to allocate the region itself.
--- arch/powerpc/platforms/ps3/mm.c | 61 +++++++++++++++++++++++++++++++++++++- 1 files changed, 59 insertions(+), 2 deletions(-)
arch/powerpc/platforms/ps3/mm.c +59 -2
@@ -110,6 +110,7 @@ struct map {u64 htab_size;struct mem_region rm;struct mem_region r1; +int destroy_r1; };#define debug_dump_map (x) _debug_dump_map(x, __func__, __LINE__)
@@ -287,6 +288,49 @@ static void ps3_mm_region_destroy(struct mem_region *r) } } +static int ps3_mm_scan_memory (unsigned long node,const char *uname, +int depth,void *data) +{ +struct mem_region *r = data; +void *p; +u64 prop[2 ]; +unsigned long l; +char *type =of_get_flat_dt_prop (node,"device_type" ,NULL ); + +if (type ==NULL ) +return 0 ; +if (strcmp (type,"memory" ) !=0 ) +return 0 ; + + p =of_get_flat_dt_prop (node,"sony,lv1-highmem" , &l); +if (p ==NULL ) +return 0 ; + +BUG_ON (l !=sizeof (prop)); +memcpy (prop, p,sizeof (prop)); + + r->base = prop[0 ]; + r->size = prop[1 ]; + r->offset = r->base - map.rm.size; + +return -1 ; +} + +static int ps3_mm_get_devtree_highmem (struct mem_region *r) +{ + r->size = r->base = r->offset =0 ; +of_scan_flat_dt (ps3_mm_scan_memory, r); + +if (r->base && r->size) { +DBG ("%s:%d got high region from devtree: %llxh %llxh\n" , + __func__, __LINE__, r->base, r->size); +return 0 ; + }else { +DBG ("%s:%d no high region in devtree...\n" , __func__, __LINE__); +return -1 ; + } +} +/** * ps3_mm_add_memory - hot add memory */
@@ -303,6 +347,12 @@ static int __init ps3_mm_add_memory(void)BUG_ON (!mem_init_done); +if (!map.r1.size) { +DBG ("%s:%d: no region 1, not adding memory\n" , + __func__, __LINE__); +return 0 ; + } + start_addr = map.rm.size; start_pfn = start_addr >>PAGE_SHIFT ; nr_pages = (map.r1.size +PAGE_SIZE -1 ) >>PAGE_SHIFT ;
@@ -1219,7 +1269,13 @@ void __init ps3_mm_init(void)/* arrange to do this in ps3_mm_add_memory */ -ps3_mm_region_create (&map.r1, map.total - map.rm.size); + +if (ps3_mm_get_devtree_highmem (&map.r1) ==0 ) { + map.destroy_r1 =0 ; + }else { +ps3_mm_region_create (&map.r1, map.total - map.rm.size); + map.destroy_r1 =1 ; + }/* correct map.total for the real total amount of memory we use */ map.total = map.rm.size + map.r1.size;
@@ -1233,5 +1289,6 @@ void __init ps3_mm_init(void)void ps3_mm_shutdown (void ) { -ps3_mm_region_destroy (&map.r1); +if (map.destroy_r1) +ps3_mm_region_destroy (&map.r1); }
Signature · 1 line
1.7.5.4
Geoff Levand
maintainerRe: [PATCH 02/15] [PS3] Get lv1 high memory region from devtree
Quoted 5 lines · Andre Heider
This lets the bootloader preallocate the high lv1 region and pass its location to the kernel through the devtree. Thus, it can be used to hold the initrd. If the property doesn't exist, the kernel retains the old behavior and attempts to allocate the region itself.
With this mechanism how is the address of the initrd passed to the new kernel, in the DT?
How would a kexec based bootloader work? If it's kernel were to allocate high mem and the bootloader program uses the high mem, how could it tell that kernel not to destroy the region on shutdown?
If arch/powerpc/boot/ps3.c allocated the mem and added a DT entry then other OSes that don't know about the Linux device tree won't be able to use that allocated memory. Other OSes could do a test to see if the allocation was already done. Another option that might work is to write info into the LV1 repository then have boot code look there for allocated hig mem.
Quoted 12 lines
Signed-off-by Hector Martin <[email protected]>[a.heider: Various cleanups to make checkpatch.pl happy]Signed-off-by Andre Heider <[email protected]>--- arch/powerpc/platforms/ps3/mm.c | 61 +++++++++++++++++++++++++++++++++++++- 1 files changed, 59 insertions(+), 2 deletions(-)arch/powerpc/platforms/ps3/mm.c +0
-0
arch/powerpc/platforms/ps3/mm.c struct map { · line 113
Quoted 4 lines
arch/powerpc/platforms/ps3/mm.c +1
-0@@ -110,6 +110,7 @@ struct map {u64 htab_size;struct mem_region rm;struct mem_region r1; +int destroy_r1;
In the general case we could have multiple high mem regions, and each could need to be destroyed, so I think struct mem_region should have a destroy flag.
arch/powerpc/platforms/ps3/mm.c static void ps3_mm_region_destroy(struct mem_region *r) · line 293
Quoted 10 lines
arch/powerpc/platforms/ps3/mm.c +3
-0};#define debug_dump_map (x) _debug_dump_map(x, __func__, __LINE__)@@ -287,6 +288,49 @@ static void ps3_mm_region_destroy(struct mem_region *r) } } +static int ps3_mm_scan_memory (unsigned long node,const char *uname, +int depth,void *data) +{
Something like 'ps3_mm_dt_scan_highmem() is more descriptive.
arch/powerpc/platforms/ps3/mm.c static void ps3_mm_region_destroy(struct mem_region *r) · line 302
Quoted 9 lines
arch/powerpc/platforms/ps3/mm.c +9
-0+struct mem_region *r = data; +void *p; +u64 prop[2 ]; +unsigned long l; +char *type =of_get_flat_dt_prop (node,"device_type" ,NULL ); + +if (type ==NULL ) +return 0 ; +if (strcmp (type,"memory" ) !=0 )
Should this be 'if (strcmp(type, "memory"))'?
Quoted 35 lines
arch/powerpc/platforms/ps3/mm.c +31
-0+return 0 ; + + p =of_get_flat_dt_prop (node,"sony,lv1-highmem" , &l); +if (p ==NULL ) +return 0 ; + +BUG_ON (l !=sizeof (prop)); +memcpy (prop, p,sizeof (prop)); + + r->base = prop[0 ]; + r->size = prop[1 ]; + r->offset = r->base - map.rm.size; + +return -1 ; +} + +static int ps3_mm_get_devtree_highmem (struct mem_region *r) +{ + r->size = r->base = r->offset =0 ; +of_scan_flat_dt (ps3_mm_scan_memory, r); + +if (r->base && r->size) { +DBG ("%s:%d got high region from devtree: %llxh %llxh\n" , + __func__, __LINE__, r->base, r->size); +return 0 ; + }else { +DBG ("%s:%d no high region in devtree...\n" , __func__, __LINE__); +return -1 ; + } +} +/** * ps3_mm_add_memory - hot add memory */
arch/powerpc/platforms/ps3/mm.c static int __init ps3_mm_add_memory(void) · line 354
Quoted 8 lines
arch/powerpc/platforms/ps3/mm.c +5
-0@@ -303,6 +347,12 @@ static int __init ps3_mm_add_memory(void)BUG_ON (!mem_init_done); +if (!map.r1.size) { +DBG ("%s:%d: no region 1, not adding memory\n" , + __func__, __LINE__); +return 0 ; + }
Did you find this to be hit? Also, in the general case, there could be more than one high mem region, but I don't know of any current systems that do.
arch/powerpc/platforms/ps3/mm.c void __init ps3_mm_init(void) · line 1275
Quoted 13 lines
arch/powerpc/platforms/ps3/mm.c +5
-1+ start_addr = map.rm.size; start_pfn = start_addr >>PAGE_SHIFT ; nr_pages = (map.r1.size +PAGE_SIZE -1 ) >>PAGE_SHIFT ;@@ -1219,7 +1269,13 @@ void __init ps3_mm_init(void)/* arrange to do this in ps3_mm_add_memory */ -ps3_mm_region_create (&map.r1, map.total - map.rm.size); + +if (ps3_mm_get_devtree_highmem (&map.r1) ==0 ) { + map.destroy_r1 =0 ; + }else {
This should be
if (!ps3_mm_get_devtree_highmem(&map.r1))
map.destroy_r1 = 0;
else {Quoted 7 lines
arch/powerpc/platforms/ps3/mm.c +3
-0+ps3_mm_region_create (&map.r1, map.total - map.rm.size); + map.destroy_r1 =1 ; + }/* correct map.total for the real total amount of memory we use */ map.total = map.rm.size + map.r1.size;
arch/powerpc/platforms/ps3/mm.c void __init ps3_mm_init(void) · line 1294
Quoted 7 lines
arch/powerpc/platforms/ps3/mm.c +2
-1@@ -1233,5 +1289,6 @@ void __init ps3_mm_init(void)void ps3_mm_shutdown (void ) { -ps3_mm_region_destroy (&map.r1); +if (map.destroy_r1) +ps3_mm_region_destroy (&map.r1); }
-Geoff
Re: [PATCH 02/15] [PS3] Get lv1 high memory region from devtree
Quoted 2 lines · Geoff Levand
With this mechanism how is the address of the initrd passed to the new kernel, in the DT?
Using the /chosen linux,initrd-{start,end} properties. The bootloader knows about the Linux trick of sticking together bootmem and highmem and precalculates the linux "physical" address. Yeah, that's a hack, it should probably be done in the kernel so the bootloader doesn't have to know or care about how Linux decides to lay out its physical address space. Do you have any suggestion as to how we would do this sanely? Right now early_init_dt_setup_initrd_arch in arch/powerpc/kernel/prom.c is generic and doesn't know anything about platform specifics.
Quoted 3 lines
How would a kexec based bootloader work? If it's kernel were to allocate high mem and the bootloader program uses the high mem, how could it tell that kernel not to destroy the region on shutdown?
The current code contemplates the case where a non-kexec based bootloader is the first stage and allocates highmem (and knows how to tell the kernel about it), possibly followed by kexec stages that just keep that allocation. To support a kexec bootloader as the first bootloader using this mechanism would indeed require extra support to tell that kernel to retain its allocation, preferably something that can be decided from userland. Of course the current kexec bootloader behavior where highmem isn't handed over to the child kernel will still work.
Quoted 6 lines
If
arch/powerpc/boot/ps3.callocated the mem and added a DT entry then other OSes that don't know about the Linux device tree won't be able to use that allocated memory. Other OSes could do a test to see if the allocation was already done. Another option that might work is to write info into the LV1 repository then have boot code look there for allocated hig mem.
If you're booting another OS that isn't Linux then it also has no use for a Linux-specific ramdisk (linux,initrd-start) and thus no use for preallocated highmem and should be booted as such (maybe make the userland tools tell the kernel to release highmem if there's no initrd defined).
Using the lv1 repo is an option, but does it make sense? It's even less standard than a FDT and we'd have to put both the region1 location and the initrd location in there (there's no point to maintaining highmem if you aren't going to use it).
FWIW, the lv1 repo writing hypercalls are unused and undocumented.
Quoted 9 lines
arch/powerpc/platforms/ps3/mm.c static int __init ps3_mm_add_memory(void) · line 354
Quoted 5 lines
arch/powerpc/platforms/ps3/mm.c +5
-0+if (!map.r1.size) { +DBG ("%s:%d: no region 1, not adding memory\n" , + __func__, __LINE__); +return 0 ; + }Did you find this to be hit? Also, in the general case, there could be more than one high mem region, but I don't know of any current systems that do.
Probably only during debugging, but it doesn't sound like a bad idea anyway (e.g. bootloader allocated highmem but didn't tell the kernel so the kernel couldn't allocate it).
As for multiple regions, well, currently it only supports one and that is hardcoded in the phys->lpar translation, so I see no point in worrying about that now.
ACK on the other code comments.
Signature · 2 lines
Hector Martin ([email protected]) Public Key: http://www.marcansoft.com/marcan.asc
Geoff Levand
maintainerRe: [PATCH 02/15] [PS3] Get lv1 high memory region from devtree
Quoted 22 lines · Hector Martin
Quoted 3 lines · Geoff Levand
How would a kexec based bootloader work? If it's kernel were to allocate high mem and the bootloader program uses the high mem, how could it tell that kernel not to destroy the region on shutdown?
The current code contemplates the case where a non-kexec based bootloader is the first stage and allocates highmem (and knows how to tell the kernel about it), possibly followed by kexec stages that just keep that allocation. To support a kexec bootloader as the first bootloader using this mechanism would indeed require extra support to tell that kernel to retain its allocation, preferably something that can be decided from userland. Of course the current kexec bootloader behavior where highmem isn't handed over to the child kernel will still work.
Quoted 6 lines
If
arch/powerpc/boot/ps3.callocated the mem and added a DT entry then other OSes that don't know about the Linux device tree won't be able to use that allocated memory. Other OSes could do a test to see if the allocation was already done. Another option that might work is to write info into the LV1 repository then have boot code look there for allocated hig mem.
Quoted 5 lines
If you're booting another OS that isn't Linux then it also has no use for a Linux-specific ramdisk (linux,initrd-start) and thus no use for preallocated highmem and should be booted as such (maybe make the userland tools tell the kernel to release highmem if there's no initrd defined).
This sounds complicated, user programs managing memory regions.
Also, it needs to be considered that a lot of kernels are out there will be confused if started with high mem already allocated.
Quoted 6 lines
Using the lv1 repo is an option, but does it make sense? It's even less standard than a FDT and we'd have to put both the region1 location and the initrd location in there (there's no point to maintaining highmem if you aren't going to use it).
FWIW, the lv1 repo writing hypercalls are unused and undocumented.
The hcalls to create, write, and delete nodes are known, but I don't recall if I verified they work:
#92 should be named lv1_write_repository_node.
You can only modify the repo for your lpar, so:
lv1_{create,write}_repository_node(n1, n2, n3, n4, v1, v2);
lv1_delete_repository_node(n1, n2, n3, n4);-Geoff
Re: [PATCH 02/15] [PS3] Get lv1 high memory region from devtree
Quoted 2 lines · Geoff Levand
Also, it needs to be considered that a lot of kernels are out there will be confused if started with high mem already allocated.
True, but is there anything we can do about that?
Isn't is okay to tell users of first stage boot loaders utilizing this mechanism that whatever steps their boot chain contains has to support this highmem pass over? As far as I can tell all current loaders won't be affected by this patch.
When a user wants to chain a loader with this mechanism with petitboot, he needs a petitboot coming with a kernel containing this feature, and can then kexec whatever contains it too.
Quoted 11 lines
Quoted 6 lines
Using the lv1 repo is an option, but does it make sense? It's even less standard than a FDT and we'd have to put both the region1 location and the initrd location in there (there's no point to maintaining highmem if you aren't going to use it).
FWIW, the lv1 repo writing hypercalls are unused and undocumented.
The hcalls to create, write, and delete nodes are known, but I don't recall if I verified they work:
=A0http://git.kernel.org/?p=3Dlinux/kernel/git/torvalds/linux-2.6.git;a=
=3Dblob;f=3Darch/powerpc/include/asm/lv1call.h;hb=3DHEAD#l265
Quoted 7 lines
#92 should be named
lv1_write_repository_node.You can only modify the repo for your lpar, so:
=A0lv1_{create,write}_repository_node(n1, n2, n3, n4, v1, v2); =A0lv1_delete_repository_node(n1, n2, n3, n4);
I tried this and it indeed works - I can pass over the highmem info just fine using repository nodes.
If there is a chance that another OS might require this highmem pass over then I agree that using the repository makes more sense.
I can prepare a patch for that, replacing this one. Any suggestions on which nodes to use?
For a test run I used:
FIELD_FIRST("bi", 0),
FIELD("highmem", 0),
FIELD("address", 0),
0
and
FIELD_FIRST("bi", 0),
FIELD("highmem", 0),
FIELD("size", 0),
0
Regards,
Andre
PATCH 3/15 Add region 1 memory early
In reply to Andre HeiderFrom: Hector Martin <[email protected]>
--- arch/powerpc/platforms/ps3/mm.c | 62 +++++++-------------------------------- 1 files changed, 11 insertions(+), 51 deletions(-)
arch/powerpc/platforms/ps3/mm.c +11 -51
@@ -331,57 +331,6 @@ static int ps3_mm_get_devtree_highmem(struct mem_region *r) } } -/** -* ps3_mm_add_memory - hot add memory -*/ - -static int __init ps3_mm_add_memory (void ) -{ -int result; -unsigned long start_addr; -unsigned long start_pfn; -unsigned long nr_pages; - -if (!firmware_has_feature (FW_FEATURE_PS3_LV1 )) -return -ENODEV ; - -BUG_ON (!mem_init_done); - -if (!map.r1.size) { -DBG ("%s:%d: no region 1, not adding memory\n" , - __func__, __LINE__); -return 0 ; - } - - start_addr = map.rm.size; - start_pfn = start_addr >>PAGE_SHIFT ; - nr_pages = (map.r1.size +PAGE_SIZE -1 ) >>PAGE_SHIFT ; - -DBG ("%s:%d: start_addr %lxh, start_pfn %lxh, nr_pages %lxh\n" , - __func__, __LINE__, start_addr, start_pfn, nr_pages); - - result =add_memory (0 , start_addr, map.r1.size); - -if (result) { -pr_err ("%s:%d: add_memory failed: (%d)\n" , - __func__, __LINE__, result); -return result; - } - -memblock_add (start_addr, map.r1.size); -memblock_analyze (); - - result =online_pages (start_pfn, nr_pages); - -if (result) -pr_err ("%s:%d: online_pages failed: (%d)\n" , - __func__, __LINE__, result); - -return result; -} - -device_initcall (ps3_mm_add_memory); -/*============================================================================*/ /* dma routines */ /*============================================================================*/
@@ -1280,6 +1229,17 @@ void __init ps3_mm_init(void)/* correct map.total for the real total amount of memory we use */ map.total = map.rm.size + map.r1.size; +if (!map.r1.size) { +DBG ("%s:%d: no region 1, not adding memory\n" , + __func__, __LINE__); + }else { +DBG ("%s:%d: adding memory: start %llxh, size %llxh\n" , + __func__, __LINE__, map.rm.size, map.r1.size); + +memblock_add (map.rm.size, map.r1.size); +memblock_analyze (); + } +DBG (" <- %s:%d\n" , __func__, __LINE__); }
Signature · 1 line
1.7.5.4
Geoff Levand
maintainerRe: [PATCH 03/15] [PS3] Add region 1 memory early
Quoted 1 line · Andre Heider
From: Hector Martin <[email protected]>
We need an explanation of this change.
Quoted 6 lines
Signed-off-by Hector Martin <[email protected]>[a.heider: Various cleanups to make checkpatch.pl happy]Signed-off-by Andre Heider <[email protected]>--- arch/powerpc/platforms/ps3/mm.c | 62 +++++++-------------------------------- 1 files changed, 11 insertions(+), 51 deletions(-)
Re: [PATCH 03/15] [PS3] Add region 1 memory early
Quoted 1 line · Geoff Levand
We need an explanation of this change.
I actually have a hard time understanding the reason for the existing behavior of hot-adding memory halfway through the boot process. Maybe you can shed some light on this?
The reason for the change is that under the default GameOS LPAR, real mode memory is 16MB which is already tight for a kernel (under certain conditions) and runs out quickly as memory is allocated during kernel startup. Having region1 available sooner fixes this.
Though, reviewing the code, I think I found a bug (that should already have a chance of happening as things stand now, though this patch might make it more likely): if storage bounce buffers or the ps3fb xdr happen to straddle the boundary between the regions, bad things will happen since they're not actually contiguous in LPAR space. This won't happen right now for ps3flash or ps3fb since those are allocated early out of bootmem, but it can currently happen for the other buffers (ps3disk, ps3vram, etc.) AFAICT.
Maybe we should introduce a reserved or nonexistent page gap at the beginning of region1 to ensure that nothing will ever allocate contiguous memory across the boundary. That will probably prevent bootmem from grabbing region1 due to the gap, so early on memory will be tight. Can we get rid of the ps3flash and ps3fb preallocations to save bootmem and just allocate them during device init like the other drivers do? What is the reason for preallocating these?
Signature · 2 lines
Hector Martin ([email protected]) Public Key: http://www.marcansoft.com/marcan.asc
Re: [PATCH 03/15] [PS3] Add region 1 memory early
Quoted 3 lines · Hector Martin
tight. Can we get rid of the ps3flash and ps3fb preallocations to save bootmem and just allocate them during device init like the other drivers do? What is the reason for preallocating these?
The reason for that is to make sure the allocations will succeed. Chances are very
slim you can allocate a contiguous 9 MiB buffer at any arbitrary time.
Gr{oetje,eeting}s,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k= .org
In personal conversations with technical people, I call myself a hacker. Bu= t
when I'm talking to journalists I just say "programmer" or something like t= hat.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0=C2=A0 =C2=A0=C2=A0 -- Linus Torvalds
Re: [PATCH 03/15] [PS3] Add region 1 memory early
Quoted 3 lines · Geert Uytterhoeven
The reason for that is to make sure the allocations will succeed. Chances are very
slim you can allocate a contiguous 9 MiB buffer at any arbitrary time.
Fair enough, but then they don't need to happen as early as they do now; any time during kernel startup should work (as long as they aren't freed with the drivers if they're unloaded). How about switching to __get_free_pages and doing the allocation inside an arch_initcall or similar?
Signature · 2 lines
Hector Martin ([email protected]) Public Key: http://www.marcansoft.com/marcan.asc
Geoff Levand
maintainerRe: [PATCH 03/15] [PS3] Add region 1 memory early
In reply to Hector MartinHi Hector,
Quoted 2 lines · Hector Martin
Quoted 1 line · Geoff Levand
We need an explanation of this change.
Sorry for such a terse request. What I meant was that this is a significant change to how high mem is managed, so the patch needs a comment explaining the change.
Quoted 3 lines
I actually have a hard time understanding the reason for the existing behavior of hot-adding memory halfway through the boot process. Maybe you can shed some light on this?
LV1 was intended to be a generic hypervisor for the Cell processor. It was imagined that it could be used on machines which could be running many lpars. Around the same time I was doing the high mem support the hot plug memory support was being developed. I thought at some point there would be hot-unplug, which could be used to move memory between lpars.
At the present time this change make sense, since it is simpler and more flexible.
-Geoff
PATCH 4/15 ps3: MEMORY_HOTPLUG is not a requirement anymore
In reply to Andre Heider--- arch/powerpc/platforms/ps3/Kconfig | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
arch/powerpc/platforms/ps3/Kconfig +0 -1
@@ -7,7 +7,6 @@ config PPC_PS3 select USB_OHCI_BIG_ENDIAN_MMIO select USB_ARCH_HAS_EHCI select USB_EHCI_BIG_ENDIAN_MMIO - select MEMORY_HOTPLUG select PPC_PCI_CHOICE help This option enables support for the Sony PS3 game console
Signature · 1 line
1.7.5.4
PATCH 5/15 ps3: Detect the current lpar environment
In reply to Andre HeiderThere is more than the OtherOS lpar the kernel can be launched in. Detect it by reading the ss laid repository node, and be verbose about it.
--- arch/powerpc/include/asm/ps3.h | 7 +++++++ arch/powerpc/platforms/ps3/platform.h | 4 ++++ arch/powerpc/platforms/ps3/repository.c | 19 +++++++++++++++++++ arch/powerpc/platforms/ps3/setup.c | 22 ++++++++++++++++++++++ 4 files changed, 52 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/ps3.h +7 -0
@@ -39,6 +39,13 @@ union ps3_firmware_version {void ps3_get_firmware_version (union ps3_firmware_version *v);int ps3_compare_firmware_version (u16 major,u16 minor,u16 rev); +enum ps3_ss_laid { +PS3_SS_LAID_GAMEOS =0x1070000002000001UL , +PS3_SS_LAID_OTHEROS =0x1080000004000001UL , +}; + +enum ps3_ss_laid ps3_get_ss_laid (void ); +/* 'Other OS' area */ enum ps3_param_av_multi_out {
arch/powerpc/platforms/ps3/platform.h +4 -0
@@ -232,4 +232,8 @@ int ps3_repository_read_spu_resource_id(unsigned int res_index,int ps3_repository_read_vuart_av_port (unsigned int *port);int ps3_repository_read_vuart_sysmgr_port (unsigned int *port); +/* repository ss info */ + +int ps3_repository_read_ss_laid (enum ps3_ss_laid *laid); +#endif
arch/powerpc/platforms/ps3/repository.c +19 -0
@@ -1002,6 +1002,25 @@ int ps3_repository_read_lpm_privileges(unsigned int be_index, u64 *lpar, lpar, rights); } +/** +* ps3_repository_read_ss_laid - Read the lpar auth id +*/ + +int ps3_repository_read_ss_laid (enum ps3_ss_laid *laid) +{ +int result; +u64 id, v1; + +lv1_get_logical_partition_id (&id); + result =read_node (PS3_LPAR_ID_PME , +make_first_field ("ss" ,0 ), +make_field ("laid" ,0 ), + id,0 , + &v1,NULL ); + *laid = v1; +return result; +} +#if defined(DEBUG )int ps3_repository_dump_resource_info (const struct ps3_repository_device *repo)
arch/powerpc/platforms/ps3/setup.c +22 -0
@@ -47,6 +47,7 @@ DEFINE_MUTEX(ps3_gpu_mutex);EXPORT_SYMBOL_GPL (ps3_gpu_mutex);static union ps3_firmware_version ps3_firmware_version; +static enum ps3_ss_laid ps3_ss_laid;void ps3_get_firmware_version (union ps3_firmware_version *v) {
@@ -68,6 +69,12 @@ int ps3_compare_firmware_version(u16 major, u16 minor, u16 rev) }EXPORT_SYMBOL_GPL (ps3_compare_firmware_version); +enum ps3_ss_laid ps3_get_ss_laid (void ) +{ +return ps3_ss_laid; +} +EXPORT_SYMBOL_GPL (ps3_get_ss_laid); +static void ps3_power_save (void ) {/*
@@ -192,6 +199,7 @@ static int ps3_set_dabr(unsigned long dabr)static void __init ps3_setup_arch (void ) { +const char *laid_str;DBG (" -> %s:%d\n" , __func__, __LINE__);
@@ -200,6 +208,20 @@ static void __init ps3_setup_arch(void) ps3_firmware_version.major, ps3_firmware_version.minor, ps3_firmware_version.rev); +ps3_repository_read_ss_laid (&ps3_ss_laid); +switch (ps3_ss_laid) { +case PS3_SS_LAID_GAMEOS : + laid_str ="GameOS" ; +break ; +case PS3_SS_LAID_OTHEROS : + laid_str ="OtherOS" ; +break ; +default : + laid_str ="unknown" ; +break ; + } +printk (KERN_INFO "Running in %s lpar\n" , laid_str); +ps3_spu_set_platform ();#ifdef CONFIG_SMP
Signature · 1 line
1.7.5.4
Geoff Levand
maintainerRe: [PATCH 05/15] ps3: Detect the current lpar environment
Quoted 12 lines · Andre Heider
--- arch/powerpc/include/asm/ps3.h | 7 +++++++ arch/powerpc/platforms/ps3/platform.h | 4 ++++ arch/powerpc/platforms/ps3/repository.c | 19 +++++++++++++++++++ arch/powerpc/platforms/ps3/setup.c | 22 ++++++++++++++++++++++ 4 files changed, 52 insertions(+), 0 deletions(-)arch/powerpc/include/asm/ps3.h +0
-0
arch/powerpc/include/asm/ps3.h union ps3_firmware_version { · line 44
Quoted 6 lines
arch/powerpc/include/asm/ps3.h +3
-0@@ -39,6 +39,13 @@ union ps3_firmware_version {void ps3_get_firmware_version (union ps3_firmware_version *v);int ps3_compare_firmware_version (u16 major,u16 minor,u16 rev); +enum ps3_ss_laid { +PS3_SS_LAID_GAMEOS =0x1070000002000001UL , +PS3_SS_LAID_OTHEROS =0x1080000004000001UL ,
Only PS3_SS_LAID_OTHEROS is used for anything outside ps3_setup_arch(), so I think it makes sense to split this into two patches with one adding just PS3_SS_LAID_OTHEROS and ps3_get_ss_laid() with a comment that it adds the ps3_get_ss_laid routine.
Quoted 104 lines
arch/powerpc/include/asm/ps3.h +4
-0+}; + +enum ps3_ss_laid ps3_get_ss_laid (void ); +/* 'Other OS' area */ enum ps3_param_av_multi_out {arch/powerpc/platforms/ps3/platform.h +4
-0@@ -232,4 +232,8 @@ int ps3_repository_read_spu_resource_id(unsigned int res_index,int ps3_repository_read_vuart_av_port (unsigned int *port);int ps3_repository_read_vuart_sysmgr_port (unsigned int *port); +/* repository ss info */ + +int ps3_repository_read_ss_laid (enum ps3_ss_laid *laid); +#endif arch/powerpc/platforms/ps3/repository.c +19
-0@@ -1002,6 +1002,25 @@ int ps3_repository_read_lpm_privileges(unsigned int be_index, u64 *lpar, lpar, rights); } +/** +* ps3_repository_read_ss_laid - Read the lpar auth id +*/ + +int ps3_repository_read_ss_laid (enum ps3_ss_laid *laid) +{ +int result; +u64 id, v1; + +lv1_get_logical_partition_id (&id); + result =read_node (PS3_LPAR_ID_PME , +make_first_field ("ss" ,0 ), +make_field ("laid" ,0 ), + id,0 , + &v1,NULL ); + *laid = v1; +return result; +} +#if defined(DEBUG )int ps3_repository_dump_resource_info (const struct ps3_repository_device *repo)arch/powerpc/platforms/ps3/setup.c +22
-0@@ -47,6 +47,7 @@ DEFINE_MUTEX(ps3_gpu_mutex);EXPORT_SYMBOL_GPL (ps3_gpu_mutex);static union ps3_firmware_version ps3_firmware_version; +static enum ps3_ss_laid ps3_ss_laid;void ps3_get_firmware_version (union ps3_firmware_version *v) {@@ -68,6 +69,12 @@ int ps3_compare_firmware_version(u16 major, u16 minor, u16 rev) }EXPORT_SYMBOL_GPL (ps3_compare_firmware_version); +enum ps3_ss_laid ps3_get_ss_laid (void ) +{ +return ps3_ss_laid; +} +EXPORT_SYMBOL_GPL (ps3_get_ss_laid); +static void ps3_power_save (void ) {/* @@ -192,6 +199,7 @@ static int ps3_set_dabr(unsigned long dabr)static void __init ps3_setup_arch (void ) { +const char *laid_str;DBG (" -> %s:%d\n" , __func__, __LINE__);@@ -200,6 +208,20 @@ static void __init ps3_setup_arch(void) ps3_firmware_version.major, ps3_firmware_version.minor, ps3_firmware_version.rev); +ps3_repository_read_ss_laid (&ps3_ss_laid); +switch (ps3_ss_laid) { +case PS3_SS_LAID_GAMEOS : + laid_str ="GameOS" ; +break ; +case PS3_SS_LAID_OTHEROS : + laid_str ="OtherOS" ; +break ; +default : + laid_str ="unknown" ; +break ; + } +printk (KERN_INFO "Running in %s lpar\n" , laid_str); +ps3_spu_set_platform ();#ifdef CONFIG_SMP
Re: [PATCH 05/15] ps3: Detect the current lpar environment
Quoted 6 lines · Geoff Levand
Quoted 5 lines · Andre Heider
---
=A0arch/powerpc/include/asm/ps3.h =A0 =A0 =A0 =A0 =A0| =A0 =A07 +++++++ =A0arch/powerpc/platforms/ps3/platform.h =A0 | =A0 =A04 ++++ =A0arch/powerpc/platforms/ps3/repository.c | =A0 19 +++++++++++++++++++ =A0arch/powerpc/platforms/ps3/setup.c =A0 =A0 =A0| =A0 22 ++++++++++++++=
++++++++
Quoted 3 lines
arch/powerpc/include/asm/p=
Quoted 3 lines
=A04 files changed, 52 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/p= renamed from arch/powerpc/include/asm/ps3.h +0
-0
s3.h
Quoted 7 lines
Quoted 7 lines
index 7f065e1..136354a 100644
arch/powerpc/include/asm/ps3.h +0
-0@@ -39,6 +39,13 @@ union ps3_firmware_version { =A0void ps3_get_firmware_version(union ps3_firmware_version *v); =A0int ps3_compare_firmware_version(u16 major, u16 minor, u16 rev);
Quoted 8 lines
arch/powerpc/include/asm/ps3.h union ps3_firmware_version { · line 44
Quoted 3 lines
arch/powerpc/include/asm/ps3.h +3
-0+enum ps3_ss_laid { + =A0 =A0 PS3_SS_LAID_GAMEOS =3D 0x1070000002000001UL, + =A0 =A0 PS3_SS_LAID_OTHEROS =3D 0x1080000004000001UL,Only
PS3_SS_LAID_OTHEROSis used for anything outsideps3_setup_arch(), so I think it makes sense to split this into two patches with one adding justPS3_SS_LAID_OTHEROSandps3_get_ss_laid()with a comment that it adds theps3_get_ss_laidroutine.
Sounds reasonable, I will split that into two patches then.
PATCH 6/15 ps3flash: Fix region align checks
In reply to Andre HeiderThe region fields used by the align checks are set in ps3stor_setup(), so move those after that call.
--- drivers/char/ps3flash.c | 30 +++++++++++++++--------------- 1 files changed, 15 insertions(+), 15 deletions(-)
drivers/char/ps3flash.c +15 -15
@@ -360,21 +360,6 @@ static int __devinit ps3flash_probe(struct ps3_system_bus_device *_dev)int error;unsigned long tmp; - tmp = dev->regions[dev->region_idx].start*dev->blk_size; -if (tmp %FLASH_BLOCK_SIZE ) { -dev_err (&dev->sbd.core, -"%s:%u region start %lu is not aligned\n" , __func__, - __LINE__, tmp); -return -EINVAL ; - } - tmp = dev->regions[dev->region_idx].size*dev->blk_size; -if (tmp %FLASH_BLOCK_SIZE ) { -dev_err (&dev->sbd.core, -"%s:%u region size %lu is not aligned\n" , __func__, - __LINE__, tmp); -return -EINVAL ; - } -/* use static buffer, kmalloc cannot allocate 256 KiB */ if (!ps3flash_bounce_buffer.address)return -ENODEV ;
@@ -405,6 +390,21 @@ static int __devinit ps3flash_probe(struct ps3_system_bus_device *_dev)if (error) goto fail_free_priv; + tmp = dev->regions[dev->region_idx].start*dev->blk_size; +if (tmp %FLASH_BLOCK_SIZE ) { +dev_err (&dev->sbd.core, +"%s:%u region start %lu is not aligned\n" , __func__, + __LINE__, tmp); +return -EINVAL ; + } + tmp = dev->regions[dev->region_idx].size*dev->blk_size; +if (tmp %FLASH_BLOCK_SIZE ) { +dev_err (&dev->sbd.core, +"%s:%u region size %lu is not aligned\n" , __func__, + __LINE__, tmp); +return -EINVAL ; + } + ps3flash_misc.parent = &dev->sbd.core; error =misc_register (&ps3flash_misc);if (error) {
Signature · 1 line
1.7.5.4
Re: [Cbe-oss-dev] [PATCH 06/15] ps3flash: Fix region align checks
Quoted 2 lines · Andre Heider
The region fields used by the align checks are set in
ps3stor_setup(), so move those after that call.
Are you sure?
Aren't they set in arch/powerpc/platforms/ps3/device-init.c:ps3_setup_storage_dev()?
drivers/char/ps3flash.c static int __devinit ps3flash_probe(struct ps3_syste=
Quoted 10 lines
Signed-off-by Andre Heider <[email protected]>---
=C2=A0drivers/char/ps3flash.c | =C2=A0 30 +++++++++++++++--------------- =C2=A01 files changed, 15 insertions(+), 15 deletions(-)drivers/char/ps3flash.c +0
-0@@ -360,21 +360,6 @@ static int __devinit ps3flash_probe(struct ps3_syste=
m_bus_device *_dev)
drivers/char/ps3flash.c static int __devinit ps3flash_probe(struct ps3_syste= · line 363
Quoted 4 lines
drivers/char/ps3flash.c +0
-1=C2=A0 =C2=A0 =C2=A0 =C2=A0int error; =C2=A0 =C2=A0 =C2=A0 =C2=A0unsigned long tmp; - =C2=A0 =C2=A0 =C2=A0 tmp =3D dev->regions[dev->region_idx].start*dev->b=
lk_size;
drivers/char/ps3flash.c static int __devinit ps3flash_probe(struct ps3_syste= · line 365
Quoted 2 lines
drivers/char/ps3flash.c +0
-2- =C2=A0 =C2=A0 =C2=A0 if (tmp % FLASH_BLOCK_SIZE) { - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 dev_err(&dev->sbd.core=
,
drivers/char/ps3flash.c static int __devinit ps3flash_probe(struct ps3_syste= · line 366
Quoted 1 line
drivers/char/ps3flash.c +0
-1- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 "%s:%u region start %lu is not aligned\n", __func__,
drivers/char/ps3flash.c static int __devinit ps3flash_probe(struct ps3_syste= · line 367
Quoted 1 line
drivers/char/ps3flash.c +0
-1- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 __LINE__, tmp);
drivers/char/ps3flash.c static int __devinit ps3flash_probe(struct ps3_syste= · line 370
Quoted 3 lines
drivers/char/ps3flash.c +0
-3- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return -EINVAL; - =C2=A0 =C2=A0 =C2=A0 } - =C2=A0 =C2=A0 =C2=A0 tmp =3D dev->regions[dev->region_idx].size*dev->bl=
k_size;
drivers/char/ps3flash.c static int __devinit ps3flash_probe(struct ps3_syste= · line 372
Quoted 2 lines
drivers/char/ps3flash.c +0
-2- =C2=A0 =C2=A0 =C2=A0 if (tmp % FLASH_BLOCK_SIZE) { - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 dev_err(&dev->sbd.core=
,
drivers/char/ps3flash.c static int __devinit ps3flash_probe(struct ps3_syste= · line 373
Quoted 1 line
drivers/char/ps3flash.c +0
-1- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 "%s:%u region size %lu is not aligned\n", __func__,
drivers/char/ps3flash.c static int __devinit ps3flash_probe(struct ps3_syste= · line 374
Quoted 1 line
drivers/char/ps3flash.c +0
-1- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 __LINE__, tmp);
Quoted 4 lines
drivers/char/ps3flash.c +0
-3- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return -EINVAL; - =C2=A0 =C2=A0 =C2=A0 } -=C2=A0 =C2=A0 =C2=A0 =C2=A0/* use static buffer, kmalloc cannot allocate =
256 KiB */
drivers/char/ps3flash.c static int __devinit ps3flash_probe(struct ps3_syste=
Quoted 3 lines
=C2=A0 =C2=A0 =C2=A0 =C2=A0if (!ps3flash_bounce_buffer.address) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return
-ENODEV;drivers/char/ps3flash.c +0
-0@@ -405,6 +390,21 @@ static int __devinit ps3flash_probe(struct ps3_syste=
m_bus_device *_dev)
Quoted 2 lines
drivers/char/ps3flash.c +0
-0=C2=A0 =C2=A0 =C2=A0 =C2=A0if (error)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0goto fail_free_pri=
v;
Quoted 2 lines
+ =C2=A0 =C2=A0 =C2=A0 tmp =3D dev->regions[dev->region_idx].start*dev->b=
lk_size;
Quoted 2 lines
+ =C2=A0 =C2=A0 =C2=A0 if (tmp %
FLASH_BLOCK_SIZE) {
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 dev_err(&dev->sbd.core=
,
Quoted 1 line
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 "%s:%u region start %lu is not aligned\n", __func__,
Quoted 1 line
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 __LINE__, tmp);
Quoted 3 lines
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return
-EINVAL;
+ =C2=A0 =C2=A0 =C2=A0 }
+ =C2=A0 =C2=A0 =C2=A0 tmp =3D dev->regions[dev->region_idx].size*dev->bl=
k_size;
Quoted 2 lines
+ =C2=A0 =C2=A0 =C2=A0 if (tmp %
FLASH_BLOCK_SIZE) {
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 dev_err(&dev->sbd.core=
,
Quoted 1 line
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 "%s:%u region size %lu is not aligned\n", __func__,
Quoted 1 line
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 __LINE__, tmp);
Quoted 6 lines
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return
-EINVAL;
+ =C2=A0 =C2=A0 =C2=A0 }
+
=C2=A0 =C2=A0 =C2=A0 =C2=A0ps3flash_misc.parent =3D&dev->sbd.core; =C2=A0 =C2=A0 =C2=A0 =C2=A0error =3Dmisc_register(&ps3flash_misc); =C2=A0 =C2=A0 =C2=A0 =C2=A0if (error) {
Gr{oetje,eeting}s,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k= .org
In personal conversations with technical people, I call myself a hacker. Bu= t
when I'm talking to journalists I just say "programmer" or something like t= hat.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0=C2=A0 =C2=A0=C2=A0 -- Linus Torvalds
Re: [Cbe-oss-dev] [PATCH 06/15] ps3flash: Fix region align checks
Quoted 7 lines · Geert Uytterhoeven
Quoted 2 lines · Andre Heider
The region fields used by the align checks are set in
ps3stor_setup(), so move those after that call.Are you sure?
Aren't they set in arch/powerpc/platforms/ps3/device-init.c:ps3_setup_storage_dev()?
Hm right, unfortunate commit message... :)dev->region_idx is set in ps3stor_probe_access(), which is called from ps3stor_setup().
So the code always checked the first region, where it should check the one beeing used.
Will fix the commit message.
Thanks
Re: [Cbe-oss-dev] [PATCH 06/15] ps3flash: Fix region align checks
Quoted 10 lines · Andre Heider
Quoted 7 lines · Geert Uytterhoeven
Quoted 2 lines · Andre Heider
The region fields used by the align checks are set in
ps3stor_setup(), so move those after that call.Are you sure?
Aren't they set in arch/powerpc/platforms/ps3/device-init.c:ps3_setup_storage_dev()?
Quoted 5 lines
Hm right, unfortunate commit message... :)
dev->region_idxis set inps3stor_probe_access(), which is called fromps3stor_setup().
So the code always checked the first region, where it should check the one beeing used.
IC. You're right. That's indeed a bug.
Gr{oetje,eeting}s,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k= .org
In personal conversations with technical people, I call myself a hacker. Bu= t
when I'm talking to journalists I just say "programmer" or something like t= hat.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0=C2=A0 =C2=A0=C2=A0 -- Linus Torvalds
PATCH 7/15 ps3flash: Refuse to work in lpars other than OtherOS
In reply to Andre HeiderThe driver implements a character and misc device, meant for the axed OtherOS to exchange various settings with GameOS. Since Firmware 3.21 there is no GameOS support anymore to write these settings, so limit the driver to the OtherOS environment.
--- arch/powerpc/platforms/ps3/Kconfig | 1 + drivers/char/ps3flash.c | 7 +++++++ 2 files changed, 8 insertions(+), 0 deletions(-)
arch/powerpc/platforms/ps3/Kconfig +1 -0
@@ -121,6 +121,7 @@ config PS3_FLASH This support is required to access the PS3 FLASH ROM, which contains the boot loader and some boot options. + This driver only supports the deprecated OtherOS LPAR. In general, all users will say Y or M. As this driver needs a fixed buffer of 256 KiB of memory, it can
drivers/char/ps3flash.c +7 -0
@@ -25,6 +25,7 @@#include <asm/lv1call.h> #include <asm/ps3stor.h> +#include <asm/firmware.h> #define DEVICE_NAME "ps3flash"
@@ -455,6 +456,12 @@ static struct ps3_system_bus_driver ps3flash = {static int __init ps3flash_init (void ) { +if (!firmware_has_feature (FW_FEATURE_PS3_LV1 )) +return -ENODEV ; + +if (ps3_get_ss_laid () !=PS3_SS_LAID_OTHEROS ) +return -ENODEV ; +return ps3_system_bus_driver_register (&ps3flash); }
Signature · 1 line
1.7.5.4
Geoff Levand
maintainerRe: [PATCH 07/15] ps3flash: Refuse to work in lpars other than OtherOS
Quoted 4 lines · Andre Heider
The driver implements a character and misc device, meant for the axed OtherOS to exchange various settings with GameOS. Since Firmware 3.21 there is no GameOS support anymore to write these settings, so limit the driver to the OtherOS environment.
This is really a test if running on the PS3 OtherOS, so this comment should state that.
Quoted 12 lines
Signed-off-by Andre Heider <[email protected]>--- arch/powerpc/platforms/ps3/Kconfig | 1 + drivers/char/ps3flash.c | 7 +++++++ 2 files changed, 8 insertions(+), 0 deletions(-)arch/powerpc/platforms/ps3/Kconfig +0
-0
arch/powerpc/platforms/ps3/Kconfig config PS3_FLASH · line 124
Quoted 4 lines
arch/powerpc/platforms/ps3/Kconfig +1
-0@@ -121,6 +121,7 @@ config PS3_FLASH This support is required to access the PS3 FLASH ROM, which contains the boot loader and some boot options. + This driver only supports the deprecated OtherOS LPAR.
This will be confusing for OtherOS users, so should be removed.
arch/powerpc/platforms/ps3/Kconfig config PS3_FLASH · line 125
Quoted 1 line
arch/powerpc/platforms/ps3/Kconfig +0
-0In general, all users will say Y or M.
This could be changed to: 'In general, all PS3 OtherOS users will say Y or M.'
Quoted 15 lines
arch/powerpc/platforms/ps3/Kconfig +0
-0As this driver needs a fixed buffer of 256 KiB of memory, it candrivers/char/ps3flash.c +1
-0@@ -25,6 +25,7 @@#include <asm/lv1call.h> #include <asm/ps3stor.h> +#include <asm/firmware.h> #define DEVICE_NAME "ps3flash"
drivers/char/ps3flash.c static struct ps3_system_bus_driver ps3flash = { · line 460
Quoted 5 lines
drivers/char/ps3flash.c +2
-0@@ -455,6 +456,12 @@ static struct ps3_system_bus_driver ps3flash = {static int __init ps3flash_init (void ) { +if (!firmware_has_feature (FW_FEATURE_PS3_LV1 )) +return -ENODEV ;
Is this needed? Won't this driver only be loaded on PS3 hardware?
drivers/char/ps3flash.c static struct ps3_system_bus_driver ps3flash = { · line 467
Quoted 7 lines
drivers/char/ps3flash.c +4
-0+ +if (ps3_get_ss_laid () !=PS3_SS_LAID_OTHEROS ) +return -ENODEV ; +return ps3_system_bus_driver_register (&ps3flash); }
-Geoff
Re: [PATCH 07/15] ps3flash: Refuse to work in lpars other than OtherOS
Quoted 8 lines · Geoff Levand
Quoted 4 lines · Andre Heider
The driver implements a character and misc device, meant for the axed OtherOS to exchange various settings with GameOS. Since Firmware 3.21 there is no GameOS support anymore to write these settings, so limit the driver to the OtherOS environment.
This is really a test if running on the PS3 OtherOS, so this comment should state that.
Ok.
Quoted 9 lines
arch/powerpc/platforms=
Quoted 9 lines
Signed-off-by Andre Heider <[email protected]>---
=A0arch/powerpc/platforms/ps3/Kconfig | =A0 =A01 + =A0drivers/char/ps3flash.c =A0 =A0 =A0 =A0 =A0 =A0| =A0 =A07 +++++++ =A02 files changed, 8 insertions(+), 0 deletions(-)arch/powerpc/platforms= renamed from arch/powerpc/platforms/ps3/Kconfig +0
-0
/ps3/Kconfig
Quoted 6 lines
Quoted 6 lines
index 84df5c8..5eb956a 100644
arch/powerpc/platforms/ps3/Kconfig +0
-0@@ -121,6 +121,7 @@ config PS3_FLASH=A0 =A0 =A0 =A0 This support is required to access the PS3 FLASH ROM, wh=
ich
Quoted 4 lines
Quoted 2 lines
=A0 =A0 =A0 =A0 contains the boot loader and some boot options.
+ =A0 =A0 =A0 This driver only supports the deprecated OtherOS LPAR.This will be confusing for OtherOS users, so should be removed.
Ok.
Quoted 5 lines
Quoted 2 lines
=A0 =A0 =A0 =A0 In general, all users will say Y or M.
This could be changed to: 'In general, all PS3 OtherOS users will say Y o=
r M.'
Yeah, you're right, that's much better
Quoted 3 lines
Quoted 3 lines
=A0 =A0 =A0 =A0 As this driver needs a fixed buffer of 256 KiB of memory=
, it can
Quoted 14 lines
Quoted 14 lines
drivers/char/ps3flash.c +0
-0@@ -25,6 +25,7 @@=A0#include <
asm/lv1call.h>
=A0#include <asm/ps3stor.h>
+#include <asm/firmware.h>=A0#define
DEVICE_NAME=A0 =A0 =A0 =A0 =A0"ps3flash"drivers/char/ps3flash.c +0
-0@@ -455,6 +456,12 @@ static struct ps3_system_bus_driver ps3flash =3D {
Quoted 7 lines
drivers/char/ps3flash.c static struct ps3_system_bus_driver ps3flash =3D { · line 460
Quoted 4 lines
drivers/char/ps3flash.c +2
-0=A0static int __init ps3flash_init(void) =A0{ + =A0 =A0 if (!firmware_has_feature(FW_FEATURE_PS3_LV1)) + =A0 =A0 =A0 =A0 =A0 =A0 return -ENODEV;Is this needed? =A0Won't this driver only be loaded on PS3 hardware?
The same code is in drivers/block/ps3disk.c, I wasn't sure if it is missing here or redundant there.
Should I remove it here?
Quoted 11 lines
drivers/char/ps3flash.c static struct ps3_system_bus_driver ps3flash =3D { · line 467
Quoted 7 lines
drivers/char/ps3flash.c +4
-0+ + =A0 =A0 if (ps3_get_ss_laid() !=3D PS3_SS_LAID_OTHEROS) + =A0 =A0 =A0 =A0 =A0 =A0 return -ENODEV; + =A0 =A0 =A0 return ps3_system_bus_driver_register(&ps3flash); =A0}-Geoff
Re: [Cbe-oss-dev] [PATCH 07/15] ps3flash: Refuse to work in lpars other than OtherOS
Quoted 1 line · Andre Heider
On Thu, Aug 4, 2011 at 12:34 AM, Geoff Levand <[email protected]> wrote=
:
Quoted 25 lines
Quoted 13 lines · Andre Heider
Quoted 12 lines
drivers/char/ps3flash.c +0
-0@@ -25,6 +25,7 @@=C2=A0#include <
asm/lv1call.h>
=C2=A0#include <asm/ps3stor.h>
+#include <asm/firmware.h>=C2=A0#define
DEVICE_NAME=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"ps3flash"drivers/char/ps3flash.c +0
-0@@ -455,6 +456,12 @@ static struct ps3_system_bus_driver ps3flash =3D {Quoted 7 lines
drivers/char/ps3flash.c static struct ps3_system_bus_driver ps3flash =3D { · line 460
Quoted 4 lines
drivers/char/ps3flash.c +2
-0=C2=A0static int __init ps3flash_init(void) =C2=A0{ + =C2=A0 =C2=A0 if (!firmware_has_feature(FW_FEATURE_PS3_LV1)) + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return -ENODEV;Is this needed? =C2=A0Won't this driver only be loaded on PS3 hardware?
The same code is in
drivers/block/ps3disk.c, I wasn't sure if it is missing here or redundant there.
Should I remove it here?
Quoted 6 lines
Quoted 6 lines
drivers/char/ps3flash.c static struct ps3_system_bus_driver ps3flash =3D { · line 466
Quoted 6 lines
drivers/char/ps3flash.c +4
-0+ + =C2=A0 =C2=A0 if (ps3_get_ss_laid() !=3D PS3_SS_LAID_OTHEROS) + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return -ENODEV; + =C2=A0 =C2=A0 =C2=A0 return ps3_system_bus_driver_register(&ps3flash); =C2=A0}
ps3flash_init() is called straight from module_init(), so it could be called on non-PS3.ps3_system_bus_driver_register() has the firmware_has_feature_check(), so it will
reject non-PS3.
But if your *_init() does any processing before calling ps3_system_bus_driver_register()
(like ps3disk_init() does, and ps3flash_init() now does due to your patch), you have to
do the check yourself, to make sure it returns early on non-PS3.
Gr{oetje,eeting}s,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k= .org
In personal conversations with technical people, I call myself a hacker. Bu= t
when I'm talking to journalists I just say "programmer" or something like t= hat.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0=C2=A0 =C2=A0=C2=A0 -- Linus Torvalds
Re: [Cbe-oss-dev] [PATCH 07/15] ps3flash: Refuse to work in lpars other than OtherOS
On Thu, Aug 4, 2011 at 9:27 PM, Geert Uytterhoeven <[email protected]> w= rote:
Quoted 2 lines · Andre Heider
Quoted 1 line
On Thu, Aug 4, 2011 at 12:34 AM, Geoff Levand <[email protected]> wrot=
e:
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines · Andre Heider
Quoted 4 lines
drivers/char/ps3flash.c +0
-0@@ -25,6 +25,7 @@
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/char/ps3flash.c static struct ps3_system_bus_driver ps3flash =3D =
Quoted 7 lines
=A0#include <
asm/lv1call.h>
=A0#include <asm/ps3stor.h>
+#include <asm/firmware.h>=A0#define
DEVICE_NAME=A0 =A0 =A0 =A0 =A0"ps3flash"drivers/char/ps3flash.c +0
-0@@ -455,6 +456,12 @@ static struct ps3_system_bus_driver ps3flash =3D =
{
Quoted 26 lines
Quoted 13 lines
Quoted 8 lines
drivers/char/ps3flash.c static struct ps3_system_bus_driver ps3flash =3D = · line 459
Quoted 5 lines
drivers/char/ps3flash.c +2
-0=A0static int __init ps3flash_init(void) =A0{ + =A0 =A0 if (!firmware_has_feature(FW_FEATURE_PS3_LV1)) + =A0 =A0 =A0 =A0 =A0 =A0 return -ENODEV;Is this needed? =A0Won't this driver only be loaded on PS3 hardware?
The same code is in
drivers/block/ps3disk.c, I wasn't sure if it is missing here or redundant there.
Should I remove it here?Quoted 6 lines
Quoted 6 lines
drivers/char/ps3flash.c static struct ps3_system_bus_driver ps3flash =3D = · line 465
Quoted 6 lines
drivers/char/ps3flash.c +4
-0+ + =A0 =A0 if (ps3_get_ss_laid() !=3D PS3_SS_LAID_OTHEROS) + =A0 =A0 =A0 =A0 =A0 =A0 return -ENODEV; + =A0 =A0 =A0 return ps3_system_bus_driver_register(&ps3flash); =A0}
ps3flash_init()is called straight frommodule_init(), so it could be called on non-PS3.ps3_system_bus_driver_register()has thefirmware_has_feature_check(), so it will
reject non-PS3.
Quoted 5 lines
But if your
*_init()does any processing before callingps3_system_bus_driver_register()
(likeps3disk_init()does, andps3flash_init()now does due to your patch), you have to
do the check yourself, to make sure it returns early on non-PS3.
Aha, makes perfect sense.
Thanks Geert
PATCH 8/15 ps3: Only prealloc the flash bounce buffer for the OtherOS lpar
In reply to Andre HeiderIt's only used by the ps3flash driver, which only supports the OtherOS lpar.
--- arch/powerpc/platforms/ps3/setup.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
arch/powerpc/platforms/ps3/setup.c +4 -1
@@ -233,7 +233,10 @@ static void __init ps3_setup_arch(void)#endif prealloc_ps3fb_videomemory (); -prealloc_ps3flash_bounce_buffer (); + +/* the ps3flash driver only works for OtherOS */ +if (ps3_get_ss_laid () ==PS3_SS_LAID_OTHEROS ) +prealloc_ps3flash_bounce_buffer (); ppc_md.power_save = ps3_power_save;ps3_os_area_init ();
Signature · 1 line
1.7.5.4
PATCH 9/15 ps3: Limit the number of regions per storage device
In reply to Andre HeiderThere can be only 8 regions, add a sanity check
--- arch/powerpc/include/asm/ps3stor.h | 1 + arch/powerpc/platforms/ps3/device-init.c | 8 ++++++++ 2 files changed, 9 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/ps3stor.h +1 -0
@@ -25,6 +25,7 @@#include <asm/ps3.h> +#define PS3_STORAGE_MAX_REGIONS (8)struct ps3_storage_region {unsigned int id;
arch/powerpc/platforms/ps3/device-init.c +8 -0
@@ -349,6 +349,14 @@ static int ps3_setup_storage_dev(const struct ps3_repository_device *repo,return -ENODEV ; } +if (num_regions >PS3_STORAGE_MAX_REGIONS ) { +pr_warning ("%s:%u: device %u:%u reported %u regions, " +"limiting to %u\n" , __func__, __LINE__, + num_regions, repo->bus_index, repo->dev_index, +PS3_STORAGE_MAX_REGIONS ); + num_regions =PS3_STORAGE_MAX_REGIONS ; + } + pr_debug("%s:%u: (%u:%u:%u): port %llu blk_size %llu num_blocks %llu " "num_regions %u\n", __func__, __LINE__, repo->bus_index, repo->dev_index, repo->dev_type, port, blk_size, num_blocks,
Signature · 1 line
1.7.5.4
Re: [Cbe-oss-dev] [PATCH 09/15] ps3: Limit the number of regions per storage device
Quoted 1 line · Andre Heider
There can be only 8 regions, add a sanity check
Why can there be only 8 regions?
Quoted 3 lines
Signed-off-by Andre Heider <[email protected]>---
=C2=A0arch/powerpc/include/asm/ps3stor.h =C2=A0 =C2=A0 =C2=A0 | =C2=A0 =
=C2=A01 +
arch/powerpc/include/as=
Quoted 4 lines
=C2=A0arch/powerpc/platforms/ps3/device-init.c | =C2=A0 =C2=A08 ++++++++ =C2=A02 files changed, 9 insertions(+), 0 deletions(-)
arch/powerpc/include/as= renamed from arch/powerpc/include/asm/ps3stor.h +0
-0
m/ps3stor.h
Quoted 8 lines
index 6fcaf71..d51e53c 100644
arch/powerpc/include/asm/ps3stor.h +0
-0@@ -25,6 +25,7 @@=C2=A0#include <
asm/ps3.h>+#define
PS3_STORAGE_MAX_REGIONS=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0(8)
arch/powerpc/plat=
Quoted 4 lines
=C2=A0struct
ps3_storage_region{
=C2=A0 =C2=A0 =C2=A0 =C2=A0unsigned int id;arch/powerpc/plat= renamed from arch/powerpc/platforms/ps3/device-init.c +0
-0
forms/ps3/device-init.c
arch/powerpc/platforms/ps3/device-init.c static int ps3_setup_storage_dev(const struct ps3_re=
Quoted 4 lines
index 6c4b583..830d741 100644
arch/powerpc/platforms/ps3/device-init.c +0
-0@@ -349,6 +349,14 @@ static int ps3_setup_storage_dev(const struct ps3_re=
pository_device *repo,
arch/powerpc/platforms/ps3/device-init.c static int ps3_setup_storage_dev(const struct ps3_re= · line 353
Quoted 5 lines
arch/powerpc/platforms/ps3/device-init.c +2
-0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return -ENODEV; =C2=A0 =C2=A0 =C2=A0 =C2=A0} + =C2=A0 =C2=A0 =C2=A0 if (num_regions > PS3_STORAGE_MAX_REGIONS) { + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 pr_warning("%s:%u: dev=
ice %u:%u reported %u regions, "
arch/powerpc/platforms/ps3/device-init.c static int ps3_setup_storage_dev(const struct ps3_re= · line 354
Quoted 1 line
arch/powerpc/platforms/ps3/device-init.c +1
-0+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0"limiting to %u\n", __func__, __LINE__,
arch/powerpc/platforms/ps3/device-init.c static int ps3_setup_storage_dev(const struct ps3_re= · line 355
Quoted 1 line
arch/powerpc/platforms/ps3/device-init.c +1
-0+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0num_regions, repo->bus_index, repo->dev_index,
arch/powerpc/platforms/ps3/device-init.c static int ps3_setup_storage_dev(const struct ps3_re= · line 356
Quoted 1 line
arch/powerpc/platforms/ps3/device-init.c +1
-0+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0PS3_STORAGE_MAX_REGIONS);
arch/powerpc/platforms/ps3/device-init.c static int ps3_setup_storage_dev(const struct ps3_re= · line 357
Quoted 1 line
arch/powerpc/platforms/ps3/device-init.c +1
-0+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 num_regions =3D PS3_ST=
ORAGE_MAX_REGIONS;
Quoted 3 lines
arch/powerpc/platforms/ps3/device-init.c +2
-0+ =C2=A0 =C2=A0 =C2=A0 } +=C2=A0 =C2=A0 =C2=A0 =C2=A0pr_debug("%s:%u: (%u:%u:%u): port %llu blk_siz=
e %llu num_blocks %llu "
Quoted 1 line
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "
num_regions%u\n=
", __func__, __LINE__, repo->bus_index,
Quoted 1 line
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0
repo->dev_index, =
repo->dev_type, port, blk_size, num_blocks,
Gr{oetje,eeting}s,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k= .org
In personal conversations with technical people, I call myself a hacker. Bu= t
when I'm talking to journalists I just say "programmer" or something like t= hat.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0=C2=A0 =C2=A0=C2=A0 -- Linus Torvalds
Re: [Cbe-oss-dev] [PATCH 09/15] ps3: Limit the number of regions per storage device
Quoted 4 lines · Geert Uytterhoeven
Quoted 1 line · Andre Heider
There can be only 8 regions, add a sanity check
Why can there be only 8 regions?
I believe lv1 limits it to 8? I might be mistaken here, it mostly is a check for the patches after this one
Re: [Cbe-oss-dev] [PATCH 09/15] ps3: Limit the number of regions per storage device
Quoted 9 lines · Andre Heider
Quoted 4 lines · Geert Uytterhoeven
Quoted 1 line · Andre Heider
There can be only 8 regions, add a sanity check
Why can there be only 8 regions?
I believe lv1 limits it to 8? I might be mistaken here, it mostly is a check for the patches after this one
Small follow-up:
While the repository contains ("bus", "dev", "n_regs") to describe the actual number of regions, it also contains ("bus", "dev", "region", [ "id" | "start" | "size" ]) for always exactly 8 regions (with a value of 0xdeadbeef for invalid regions).
I added this check for the storage drivers, which contain:
for (region_idx = 0; region_idx < dev->num_regions; region_idx++) {
...
gendisk->first_minor = devidx * PS3DISK_MINORS + region_idx;But that limit might be raised in future hypervisor versions. Maybe a
BUG_ON(dev->num_regions <= PS3DISK_MINORS);
is more appropriate?
Re: [Cbe-oss-dev] [PATCH 09/15] ps3: Limit the number of regions per storage device
Quoted 22 lines · Andre Heider
Quoted 9 lines · Andre Heider
Quoted 4 lines · Geert Uytterhoeven
Quoted 1 line · Andre Heider
There can be only 8 regions, add a sanity check
Why can there be only 8 regions?
I believe lv1 limits it to 8? I might be mistaken here, it mostly is a check for the patches after this one
Small follow-up:
While the repository contains ("bus", "dev", "n_regs") to describe the actual number of regions, it also contains ("bus", "dev", "region", [ "id" | "start" | "size" ]) for always exactly 8 regions (with a value of0xdeadbeeffor invalid regions).I added this check for the storage drivers, which contain:
=A0for (region_idx=3D 0;region_idx<dev->num_regions; region_idx++) { =A0 =A0...
=A0 =A0gendisk->first_minor =3D devidx *PS3DISK_MINORS+region_idx;
Quoted 4 lines
But that limit might be raised in future hypervisor versions. Maybe a
=A0BUG_ON(dev->num_regions <=3DPS3DISK_MINORS);
is more appropriate?
Of course I meant the exact opposite, heh:
=A0BUG_ON(dev->num_regions > PS3DISK_MINORS);
PATCH 10/15 ps3stor_lib: Add support for multiple regions
In reply to Andre HeiderUsers (ps3disk, ps3flash and ps3rom) retain the old behavior. That is:
they still only provide access to the first accessible region.
--- arch/powerpc/include/asm/ps3stor.h | 4 ++-- drivers/block/ps3disk.c | 15 +++++++++++++-- drivers/char/ps3flash.c | 23 +++++++++++++++++------ drivers/ps3/ps3stor_lib.c | 25 ++++++++++++------------- drivers/scsi/ps3rom.c | 11 +++++++---- 5 files changed, 51 insertions(+), 27 deletions(-)
arch/powerpc/include/asm/ps3stor.h +2 -2
@@ -51,7 +51,6 @@ struct ps3_storage_device {unsigned int num_regions;unsigned long accessible_regions; -unsigned int region_idx;/* first accessible region */ struct ps3_storage_region regions[0 ];/* Must be last */ };
@@ -63,7 +62,8 @@ static inline struct ps3_storage_device *to_ps3_storage_device(struct device *deextern int ps3stor_setup (struct ps3_storage_device *dev,irq_handler_t handler);extern void ps3stor_teardown (struct ps3_storage_device *dev); -extern u64 ps3stor_read_write_sectors (struct ps3_storage_device *dev,u64 lpar, +extern u64 ps3stor_read_write_sectors (struct ps3_storage_device *dev, +unsigned int region_idx,u64 lpar,u64 start_sector,u64 sectors,int write); extern u64 ps3stor_send_command(struct ps3_storage_device *dev, u64 cmd,
drivers/block/ps3disk.c +13 -2
@@ -42,6 +42,7 @@ struct ps3disk_private {spinlock_t lock;/* Request queue spinlock */ struct request_queue *queue;struct gendisk *gendisk; +unsigned int region_idx;/* first accessible region */ unsigned int blocking_factor;struct request *req;u64 raw_capacity;
@@ -125,7 +126,7 @@ static int ps3disk_submit_request_sg(struct ps3_storage_device *dev,int write =rq_data_dir (req), res;const char *op = write ?"write" :"read" ;u64 start_sector, sectors; -unsigned int region_id = dev->regions[dev->region_idx].id; +unsigned int region_id = dev->regions[priv->region_idx].id;#ifdef DEBUG unsigned int n =0 ;
@@ -408,6 +409,7 @@ static int __devinit ps3disk_probe(struct ps3_system_bus_device *_dev)unsigned int devidx;struct request_queue *queue;struct gendisk *gendisk; +unsigned int region_idx;if (dev->blk_size <512 ) { dev_err(&dev->sbd.core,
@@ -482,6 +484,14 @@ static int __devinit ps3disk_probe(struct ps3_system_bus_device *_dev) } priv->gendisk = gendisk; + +/* find first accessible region */ +for (region_idx =0 ; region_idx < dev->num_regions; region_idx++) +if (test_bit (region_idx, &dev->accessible_regions)) { + priv->region_idx = region_idx; +break ; + } + gendisk->major = ps3disk_major; gendisk->first_minor = devidx *PS3DISK_MINORS ; gendisk->fops = &ps3disk_fops;
@@ -492,7 +502,8 @@ static int __devinit ps3disk_probe(struct ps3_system_bus_device *_dev) devidx+'a'); priv->blocking_factor = dev->blk_size >>9 ;set_capacity (gendisk, - dev->regions[dev->region_idx].size*priv->blocking_factor); + dev->regions[priv->region_idx].size * + priv->blocking_factor); dev_info(&dev->sbd.core, "%s is a %s (%llu MiB total, %lu MiB for OtherOS)\n",
drivers/char/ps3flash.c +17 -6
@@ -36,6 +36,7 @@struct ps3flash_private {struct mutex mutex;/* Bounce buffer mutex */ u64 chunk_sectors; +unsigned int region_idx;/* first accessible region */ int tag;/* Start sector of buffer, -1 if invalid */ bool dirty; };
@@ -46,7 +47,8 @@ static int ps3flash_read_write_sectors(struct ps3_storage_device *dev, u64 start_sector, int write) {struct ps3flash_private *priv =ps3_system_bus_get_drvdata (&dev->sbd); -u64 res =ps3stor_read_write_sectors (dev, dev->bounce_lpar, +u64 res =ps3stor_read_write_sectors (dev, priv->region_idx, + dev->bounce_lpar, start_sector, priv->chunk_sectors, write);if (res) {
@@ -98,6 +100,7 @@ static int ps3flash_fetch(struct ps3_storage_device *dev, u64 start_sector)static loff_t ps3flash_llseek (struct file *file,loff_t offset,int origin) {struct ps3_storage_device *dev = ps3flash_dev; +struct ps3flash_private *priv =ps3_system_bus_get_drvdata (&dev->sbd);loff_t res;mutex_lock (&file->f_mapping->host->i_mutex);
@@ -106,7 +109,7 @@ static loff_t ps3flash_llseek(struct file *file, loff_t offset, int origin) offset += file->f_pos;break ;case 2 : - offset += dev->regions[dev->region_idx].size*dev->blk_size; + offset += dev->regions[priv->region_idx].size*dev->blk_size;break ; }if (offset <0 ) {
@@ -136,7 +139,7 @@ static ssize_t ps3flash_read(char __user *userbuf, void *kernelbuf,"%s:%u: Reading %zu bytes at position %lld to U0x%p/K0x%p\n" , __func__, __LINE__, count, *pos, userbuf, kernelbuf); - size = dev->regions[dev->region_idx].size*dev->blk_size; + size = dev->regions[priv->region_idx].size*dev->blk_size;if (*pos >= size || !count)return 0 ;
@@ -205,7 +208,7 @@ static ssize_t ps3flash_write(const char __user *userbuf,"%s:%u: Writing %zu bytes at position %lld from U0x%p/K0x%p\n" , __func__, __LINE__, count, *pos, userbuf, kernelbuf); - size = dev->regions[dev->region_idx].size*dev->blk_size; + size = dev->regions[priv->region_idx].size*dev->blk_size;if (*pos >= size || !count)return 0 ;
@@ -359,6 +362,7 @@ static int __devinit ps3flash_probe(struct ps3_system_bus_device *_dev)struct ps3_storage_device *dev =to_ps3_storage_device (&_dev->core);struct ps3flash_private *priv;int error; +unsigned int region_idx;unsigned long tmp;/* use static buffer, kmalloc cannot allocate 256 KiB */
@@ -391,14 +395,21 @@ static int __devinit ps3flash_probe(struct ps3_system_bus_device *_dev)if (error) goto fail_free_priv; - tmp = dev->regions[dev->region_idx].start*dev->blk_size; +/* find first accessible region */ +for (region_idx =0 ; region_idx < dev->num_regions; region_idx++) +if (test_bit (region_idx, &dev->accessible_regions)) { + priv->region_idx = region_idx; +break ; + } + + tmp = dev->regions[priv->region_idx].start*dev->blk_size;if (tmp %FLASH_BLOCK_SIZE ) {dev_err (&dev->sbd.core,"%s:%u region start %lu is not aligned\n" , __func__, __LINE__, tmp);return -EINVAL ; } - tmp = dev->regions[dev->region_idx].size*dev->blk_size; + tmp = dev->regions[priv->region_idx].size*dev->blk_size;if (tmp %FLASH_BLOCK_SIZE ) { dev_err(&dev->sbd.core, "%s:%u region size %lu is not aligned\n", __func__,
drivers/ps3/ps3stor_lib.c +12 -13
@@ -101,9 +101,8 @@ static int ps3stor_probe_access(struct ps3_storage_device *dev)"%s:%u: checking accessibility of region %u\n" , __func__, __LINE__, i); - dev->region_idx = i; - res =ps3stor_read_write_sectors (dev, dev->bounce_lpar,0 ,1 , -0 ); + res =ps3stor_read_write_sectors (dev, i, dev->bounce_lpar, +0 ,1 ,0 );if (res) { dev_dbg(&dev->sbd.core, "%s:%u: read failed, " "region %u is not accessible\n", __func__,
@@ -117,6 +116,11 @@ static int ps3stor_probe_access(struct ps3_storage_device *dev)/* We can access at least one region */ error =0 ; + +dev_info (&dev->sbd.core, +"Accessible region found: #%u start %llu size %llu\n" , + i, dev->regions[i].start, dev->regions[i].size); + }if (error)return error;
@@ -124,15 +128,8 @@ static int ps3stor_probe_access(struct ps3_storage_device *dev) n =hweight_long (dev->accessible_regions);if (n >1 )dev_info (&dev->sbd.core, -"%s:%u: %lu accessible regions found. Only the first " -"one will be used\n" , +"%s:%u: %lu accessible regions found\n" , __func__, __LINE__, n); - dev->region_idx =__ffs (dev->accessible_regions); -dev_info (&dev->sbd.core, -"First accessible region has index %u start %llu size %llu\n" , - dev->region_idx, dev->regions[dev->region_idx].start, - dev->regions[dev->region_idx].size); -return 0 ; }
@@ -264,6 +261,7 @@ EXPORT_SYMBOL_GPL(ps3stor_teardown);/** * ps3stor_read_write_sectors - read/write from/to a storage device * @dev: Pointer to a struct ps3_storage_device +* @region_idx: Index of the region to access * @lpar: HV logical partition address * @start_sector: First sector to read/write * @sectors: Number of sectors to read/write
@@ -272,10 +270,11 @@ EXPORT_SYMBOL_GPL(ps3stor_teardown);* Returns 0 for success, -1 in case of failure to submit the command, or * an LV1 status value in case of other errors */ -u64 ps3stor_read_write_sectors (struct ps3_storage_device *dev,u64 lpar, +u64 ps3stor_read_write_sectors (struct ps3_storage_device *dev, +unsigned int region_idx,u64 lpar,u64 start_sector,u64 sectors,int write) { -unsigned int region_id = dev->regions[dev->region_idx].id; +unsigned int region_id = dev->regions[region_idx].id;const char *op = write ?"write" :"read" ;int res;
drivers/scsi/ps3rom.c +7 -4
@@ -39,6 +39,7 @@#define PS3ROM_MAX_SECTORS (BOUNCE_SIZE >> 9) +#define PS3ROM_REGION_IDX 0struct ps3rom_private {struct ps3_storage_device *dev;
@@ -177,8 +178,9 @@ static int ps3rom_read_request(struct ps3_storage_device *dev, __func__, __LINE__, sectors, start_sector); res =lv1_storage_read (dev->sbd.dev_id, - dev->regions[dev->region_idx].id, start_sector, - sectors,0 , dev->bounce_lpar, &dev->tag); + dev->regions[PS3ROM_REGION_IDX ].id, + start_sector, sectors,0 , + dev->bounce_lpar, &dev->tag);if (res) {dev_err (&dev->sbd.core,"%s:%u: read failed %d\n" , __func__, __LINE__, res);
@@ -200,8 +202,9 @@ static int ps3rom_write_request(struct ps3_storage_device *dev,scsi_sg_copy_to_buffer (cmd, dev->bounce_buf, dev->bounce_size); res =lv1_storage_write (dev->sbd.dev_id, - dev->regions[dev->region_idx].id, start_sector, - sectors,0 , dev->bounce_lpar, &dev->tag); + dev->regions[PS3ROM_REGION_IDX ].id, + start_sector, sectors,0 , + dev->bounce_lpar, &dev->tag);if (res) {dev_err (&dev->sbd.core,"%s:%u: write failed %d\n" , __func__, __LINE__, res);
Signature · 1 line
1.7.5.4
Re: [PATCH 10/15] ps3stor_lib: Add support for multiple regions
Quoted 7 lines · Andre Heider
Users (ps3disk, ps3flash and ps3rom) retain the old behavior. That is:
they still only provide access to the first accessible region.Signed-off-by Andre Heider <[email protected]>---
=C2=A0arch/powerpc/include/asm/ps3stor.h | =C2=A0 =C2=A04 ++-- =C2=A0drivers/block/ps3disk.c =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| =
=C2=A0 15 +++++++++++++--
Quoted 1 line
=C2=A0drivers/char/ps3flash.c =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| =
=C2=A0 23 +++++++++++++++++------
Quoted 1 line
=C2=A0drivers/ps3/ps3stor_lib.c =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| =C2=
=A0 25 ++++++++++++-------------
Quoted 1 line
=C2=A0drivers/scsi/ps3rom.c =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0| =C2=A0 11 +++++++----
arch/powerpc/include/as=
Quoted 3 lines
=C2=A05 files changed, 51 insertions(+), 27 deletions(-)
arch/powerpc/include/as= renamed from arch/powerpc/include/asm/ps3stor.h +0
-0
m/ps3stor.h
arch/powerpc/include/asm/ps3stor.h struct ps3_storage_device { · line 54
Quoted 8 lines
index d51e53c..9871c05 100644
arch/powerpc/include/asm/ps3stor.h +0
-1@@ -51,7 +51,6 @@ struct ps3_storage_device { =C2=A0 =C2=A0 =C2=A0 =C2=A0unsigned int num_regions; =C2=A0 =C2=A0 =C2=A0 =C2=A0unsigned long accessible_regions; - =C2=A0 =C2=A0 =C2=A0 unsigned int region_idx; =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* first accessible region */
Quoted 1 line
=C2=A0 =C2=A0 =C2=A0 =C2=A0struct
ps3_storage_regionregions[0]; =C2=A0 /=
* Must be last */
arch/powerpc/include/asm/ps3stor.h static inline struct ps3_storage_device *to_ps3_storage=
Quoted 3 lines
=C2=A0};
arch/powerpc/include/asm/ps3stor.h +0
-0@@ -63,7 +62,8 @@ static inline struct ps3_storage_device *to_ps3_storage=
_device(struct device *de
Quoted 2 lines
arch/powerpc/include/asm/ps3stor.h +0
-0=C2=A0extern int ps3stor_setup(struct ps3_storage_device *dev,=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 irq_handler_t handler);
Quoted 2 lines
=C2=A0extern void
ps3stor_teardown(struct ps3_storage_device *dev); -extern u64 ps3stor_read_write_sectors(structps3_storage_device*dev, u6=
4 lpar,
Quoted 2 lines
+extern u64 ps3stor_read_write_sectors(struct
ps3_storage_device*dev,
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 unsigned int region= _idx, u64 lpar,
Quoted 1 line
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0u64 start_sector= , u64 sectors,
Quoted 1 line
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0int write);
Quoted 1 line
=C2=A0extern u64 ps3stor_send_command(struct
ps3_storage_device*dev, u64=
cmd,
Quoted 6 lines
drivers/block/ps3disk.c +0
-0@@ -42,6 +42,7 @@ struct ps3disk_private {=C2=A0 =C2=A0 =C2=A0 =C2=A0spinlock_t lock; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0/* Request queue spinlock */
Quoted 3 lines
=C2=A0 =C2=A0 =C2=A0 =C2=A0struct
request_queue*queue; =C2=A0 =C2=A0 =C2=A0 =C2=A0struct gendisk *gendisk;
+ =C2=A0 =C2=A0 =C2=A0 unsigned intregion_idx; =C2=A0 =C2=A0 =C2=A0 =C2=
=A0/* first accessible region */
drivers/block/ps3disk.c static int ps3disk_submit_request_sg(struct ps3_stora=
Quoted 4 lines
=C2=A0 =C2=A0 =C2=A0 =C2=A0unsigned int
blocking_factor; =C2=A0 =C2=A0 =C2=A0 =C2=A0struct request *req; =C2=A0 =C2=A0 =C2=A0 =C2=A0u64raw_capacity;drivers/block/ps3disk.c +0
-0@@ -125,7 +126,7 @@ static int ps3disk_submit_request_sg(struct ps3_stora=
ge_device *dev,
drivers/block/ps3disk.c static int ps3disk_submit_request_sg(struct ps3_stora= · line 128
Quoted 4 lines
drivers/block/ps3disk.c +0
-1=C2=A0 =C2=A0 =C2=A0 =C2=A0int write =3D rq_data_dir(req), res; =C2=A0 =C2=A0 =C2=A0 =C2=A0const char *op =3D write ? "write" : "read"; =C2=A0 =C2=A0 =C2=A0 =C2=A0u64 start_sector, sectors; - =C2=A0 =C2=A0 =C2=A0 unsigned int region_id =3D dev->regions[dev->regio=
n_idx].id;
drivers/block/ps3disk.c static int ps3disk_submit_request_sg(struct ps3_stora= · line 129
Quoted 1 line
drivers/block/ps3disk.c +1
-0+ =C2=A0 =C2=A0 =C2=A0 unsigned int region_id =3D dev->regions[priv->regi=
on_idx].id;
drivers/block/ps3disk.c static int __devinit ps3disk_probe(struct ps3_system_=
Quoted 4 lines
=C2=A0#ifdef DEBUG
=C2=A0 =C2=A0 =C2=A0 =C2=A0unsigned int n =3D 0;drivers/block/ps3disk.c +0
-0@@ -408,6 +409,7 @@ static int __devinit ps3disk_probe(struct ps3_system_=
bus_device *_dev)
Quoted 7 lines
drivers/block/ps3disk.c +1
-0=C2=A0 =C2=A0 =C2=A0 =C2=A0unsigned int devidx; =C2=A0 =C2=A0 =C2=A0 =C2=A0struct request_queue *queue; =C2=A0 =C2=A0 =C2=A0 =C2=A0struct gendisk *gendisk; + =C2=A0 =C2=A0 =C2=A0 unsigned int region_idx; =C2=A0 =C2=A0 =C2=A0 =C2=A0if (dev->blk_size < 512) {=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0dev_err(&dev->sbd.=
core,
drivers/block/ps3disk.c static int __devinit ps3disk_probe(struct ps3_system=
Quoted 1 line
drivers/block/ps3disk.c +0
-0@@ -482,6 +484,14 @@ static int __devinit ps3disk_probe(struct ps3_system=
_bus_device *_dev)
drivers/block/ps3disk.c static int __devinit ps3disk_probe(struct ps3_system= · line 489
Quoted 6 lines
drivers/block/ps3disk.c +3
-0=C2=A0 =C2=A0 =C2=A0 =C2=A0} =C2=A0 =C2=A0 =C2=A0 =C2=A0priv->gendisk =3D gendisk; + + =C2=A0 =C2=A0 =C2=A0 /* find first accessible region */ + =C2=A0 =C2=A0 =C2=A0 for (region_idx =3D 0; region_idx < dev->num_regio=
ns; region_idx++)
drivers/block/ps3disk.c static int __devinit ps3disk_probe(struct ps3_system= · line 490
Quoted 1 line
drivers/block/ps3disk.c +1
-0+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (test_bit(region_id=
x, &dev->accessible_regions)) {
drivers/block/ps3disk.c static int __devinit ps3disk_probe(struct ps3_system= · line 491
Quoted 1 line
drivers/block/ps3disk.c +1
-0+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 priv->region_idx =3D region_idx;
drivers/block/ps3disk.c static int __devinit ps3disk_probe(struct ps3_system= · line 492
Quoted 1 line
drivers/block/ps3disk.c +1
-0+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 break;
drivers/block/ps3disk.c static int __devinit ps3disk_probe(struct ps3_system= · line 494
Quoted 2 lines
drivers/block/ps3disk.c +2
-0+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 } +
Why not
priv->region_idx =3D __ffs(dev->accessible_regions);
like the original code in ps3stor_probe_access() used? Cfr. the code you removed:
drivers/ps3/ps3stor_lib.c static int ps3stor_probe_access(struct ps3_storage_d=
Quoted 5 lines
drivers/ps3/ps3stor_lib.c +0
-0@@ -124,15 +128,8 @@ static int ps3stor_probe_access(struct ps3_storage_d=
evice *dev)
Quoted 3 lines
drivers/ps3/ps3stor_lib.c +0
-0=C2=A0 =C2=A0 =C2=A0 =C2=A0n =3D hweight_long(dev->accessible_regions); =C2=A0 =C2=A0 =C2=A0 =C2=A0if (n > 1)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0dev_info(&dev->sbd=
.core,
Quoted 1 line
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0"%s:%u: %lu accessible regions found. Only the first "
Quoted 1 line
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0"one will be used\n",
Quoted 1 line
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0"%s:%u: %lu accessible regions found\n",
Quoted 1 line
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 __func__, __LINE__, n);
Quoted 1 line
- =C2=A0 =C2=A0 =C2=A0
dev->region_idx=3D __ffs(dev->accessible_regions)=
;
Quoted 2 lines
- =C2=A0 =C2=A0 =C2=A0 dev_info(&dev->sbd.core,
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"First accessibl=
e region has index %u start %llu size %llu\n",
Quoted 1 line
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0dev->region_idx,=
dev->regions[dev->region_idx].start,
Quoted 1 line
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0dev->regions[dev=
->region_idx].size);
Quoted 4 lines
-
=C2=A0 =C2=A0 =C2=A0 =C2=A0return 0;
=C2=A0}
Same in the other drivers.
Gr{oetje,eeting}s,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k= .org
In personal conversations with technical people, I call myself a hacker. Bu= t
when I'm talking to journalists I just say "programmer" or something like t= hat.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0=C2=A0 =C2=A0=C2=A0 -- Linus Torvalds
Re: [PATCH 10/15] ps3stor_lib: Add support for multiple regions
Quoted 5 lines · Geert Uytterhoeven
Quoted 4 lines · Andre Heider
=A0 =A0 =A0 =A0priv->gendisk =3D gendisk;
+
+ =A0 =A0 =A0 /* find first accessible region */
+ =A0 =A0 =A0 for (region_idx=3D 0;region_idx<dev->num_regions; regi=
on_idx++)
Quoted 1 line
Quoted 1 line
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (test_bit(region_idx, &dev->accessible_=
regions)) {
Quoted 1 line
Quoted 1 line
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
priv->region_idx=3D regio=
n_idx;
Quoted 7 lines
Quoted 3 lines
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break;
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
+Why not
priv->region_idx=3D__ffs(dev->accessible_regions);
Right, thanks. Will change that for v2
PATCH 11/15 ps3disk: Provide a gendisk per accessible region
In reply to Andre HeiderThis changes the behavior to name the block devices for lpars other than OtherOS. Instead of a single disk with an alphanumeric suffix (/dev/ps3da), disks are now numeric, while each accessible region gets its own alphanumeric suffix:
/dev/ps3d1a/dev/ps3d1b
The old behavior for OtherOS is kept:
- only one region will be exposed as block device
- the block device name stays the same
--- drivers/block/ps3disk.c | 118 ++++++++++++++++++++++++++++++---------------- 1 files changed, 77 insertions(+), 41 deletions(-)
drivers/block/ps3disk.c +77 -41
@@ -35,18 +35,19 @@#define PS3DISK_MINORS 16 -#define PS3DISK_NAME "ps3d%c" +#define PS3DISK_NAME_OTHEROS "ps3d%c" +#define PS3DISK_NAME "ps3d%c%c"struct ps3disk_private {spinlock_t lock;/* Request queue spinlock */ struct request_queue *queue; -struct gendisk *gendisk; -unsigned int region_idx;/* first accessible region */ unsigned int blocking_factor;struct request *req; +unsigned int devidx;u64 raw_capacity;unsigned char model[ATA_ID_PROD_LEN +1 ]; +struct gendisk *gendisk[0 ];/* Must be last */ };
@@ -126,7 +127,9 @@ static int ps3disk_submit_request_sg(struct ps3_storage_device *dev,int write =rq_data_dir (req), res;const char *op = write ?"write" :"read" ;u64 start_sector, sectors; -unsigned int region_id = dev->regions[priv->region_idx].id; +unsigned int region_idx =MINOR (disk_devt (req->rq_disk)) & + (PS3DISK_MINORS -1 ); +unsigned int region_id = dev->regions[region_idx].id;#ifdef DEBUG unsigned int n =0 ;
@@ -410,6 +413,7 @@ static int __devinit ps3disk_probe(struct ps3_system_bus_device *_dev)struct request_queue *queue;struct gendisk *gendisk;unsigned int region_idx; +unsigned int otheros =ps3_get_ss_laid () ==PS3_SS_LAID_OTHEROS ;if (dev->blk_size <512 ) { dev_err(&dev->sbd.core,
@@ -430,7 +434,9 @@ static int __devinit ps3disk_probe(struct ps3_system_bus_device *_dev)__set_bit (devidx, &ps3disk_mask);mutex_unlock (&ps3disk_mask_mutex); - priv =kzalloc (sizeof (*priv),GFP_KERNEL ); + priv =kzalloc (sizeof (*priv) + + dev->num_regions *sizeof (struct gendisk ), +GFP_KERNEL );if (!priv) { error = -ENOMEM ; goto fail;
@@ -450,6 +456,7 @@ static int __devinit ps3disk_probe(struct ps3_system_bus_device *_dev)if (error) goto fail_free_bounce; + priv->devidx = devidx;ps3disk_identify (dev); queue =blk_init_queue (ps3disk_request, &priv->lock);
@@ -475,45 +482,60 @@ static int __devinit ps3disk_probe(struct ps3_system_bus_device *_dev)blk_queue_max_segments (queue,-1 );blk_queue_max_segment_size (queue, dev->bounce_size); - gendisk =alloc_disk (PS3DISK_MINORS ); -if (!gendisk) { -dev_err (&dev->sbd.core,"%s:%u: alloc_disk failed\n" , __func__, - __LINE__); - error = -ENOMEM ; - goto fail_cleanup_queue; - } +dev_info (&dev->sbd.core,"%s (%llu MiB)\n" , + priv->model, priv->raw_capacity >>11 ); - priv->gendisk = gendisk; +for (region_idx =0 ; region_idx < dev->num_regions; region_idx++) { +if (test_bit (region_idx, &dev->accessible_regions) ==0 ) +continue ; -/* find first accessible region */ -for (region_idx =0 ; region_idx < dev->num_regions; region_idx++) -if (test_bit (region_idx, &dev->accessible_regions)) { - priv->region_idx = region_idx; -break ; + gendisk =alloc_disk (PS3DISK_MINORS *PS3_STORAGE_MAX_REGIONS ); +if (!gendisk) { +dev_err (&dev->sbd.core,"%s:%u: alloc_disk failed\n" , + __func__, __LINE__); + error = -ENOMEM ; + goto fail_cleanup_queue; } - gendisk->major = ps3disk_major; - gendisk->first_minor = devidx *PS3DISK_MINORS ; - gendisk->fops = &ps3disk_fops; - gendisk->queue = queue; - gendisk->private_data = dev; - gendisk->driverfs_dev = &dev->sbd.core; -snprintf (gendisk->disk_name,sizeof (gendisk->disk_name),PS3DISK_NAME , - devidx+'a' ); - priv->blocking_factor = dev->blk_size >>9 ; -set_capacity (gendisk, - dev->regions[priv->region_idx].size * - priv->blocking_factor); - -dev_info (&dev->sbd.core, -"%s is a %s (%llu MiB total, %lu MiB for OtherOS)\n" , - gendisk->disk_name, priv->model, priv->raw_capacity >>11 , -get_capacity (gendisk) >>11 ); - -add_disk (gendisk); + priv->gendisk[region_idx] = gendisk; + gendisk->major = ps3disk_major; + gendisk->first_minor = devidx *PS3DISK_MINORS + region_idx; + gendisk->fops = &ps3disk_fops; + gendisk->queue = queue; + gendisk->private_data = dev; + gendisk->driverfs_dev = &dev->sbd.core; + +if (otheros) { +/* keep the old block device name for OtherOS */ +snprintf (gendisk->disk_name,sizeof (gendisk->disk_name), +PS3DISK_NAME_OTHEROS ,'a' + devidx); + }else { +snprintf (gendisk->disk_name,sizeof (gendisk->disk_name), +PS3DISK_NAME ,'1' + devidx,'a' + region_idx); + } + + priv->blocking_factor = dev->blk_size >>9 ; +set_capacity (gendisk, dev->regions[region_idx].size * + priv->blocking_factor); + +dev_info (&dev->sbd.core, +"%s (%lu MiB region)\n" , + gendisk->disk_name,get_capacity (gendisk) >>11 ); + +add_disk (gendisk); + +/* keep old behavior for OtherOS - only one region */ +if (otheros) +break ; + } +return 0 ; fail_cleanup_queue: +for (region_idx =0 ; region_idx < dev->num_regions; region_idx++) +if (priv->gendisk[region_idx]) +del_gendisk (priv->gendisk[region_idx]); +blk_cleanup_queue (queue); fail_teardown:ps3stor_teardown (dev);
@@ -533,14 +555,28 @@ static int ps3disk_remove(struct ps3_system_bus_device *_dev) {struct ps3_storage_device *dev =to_ps3_storage_device (&_dev->core);struct ps3disk_private *priv =ps3_system_bus_get_drvdata (&dev->sbd); +unsigned int region_idx;mutex_lock (&ps3disk_mask_mutex); -__clear_bit (MINOR (disk_devt (priv->gendisk)) /PS3DISK_MINORS , - &ps3disk_mask); +__clear_bit (priv->devidx, &ps3disk_mask);mutex_unlock (&ps3disk_mask_mutex); -del_gendisk (priv->gendisk); + +for (region_idx =0 ; region_idx < dev->num_regions; region_idx++) { +if (test_bit (region_idx, &dev->accessible_regions) ==0 ) +continue ; + +del_gendisk (priv->gendisk[region_idx]); + } +blk_cleanup_queue (priv->queue); -put_disk (priv->gendisk); + +for (region_idx =0 ; region_idx < dev->num_regions; region_idx++) { +if (test_bit (region_idx, &dev->accessible_regions) ==0 ) +continue ; + +put_disk (priv->gendisk[region_idx]); + } +dev_notice (&dev->sbd.core,"Synchronizing disk cache\n" );ps3disk_sync_cache (dev);ps3stor_teardown (dev);
Signature · 1 line
1.7.5.4
PATCH 12/15 ps3stor_lib: Add support for storage access flags
In reply to Andre HeiderUsers can now set the access flags in the region struct. This is required for accessing the first region, or selecting an alternative decryption key for the vflash partitions.
--- arch/powerpc/include/asm/ps3stor.h | 8 +++++++- arch/powerpc/platforms/ps3/device-init.c | 1 + drivers/block/ps3disk.c | 5 +++-- drivers/ps3/ps3stor_lib.c | 5 +++-- 4 files changed, 14 insertions(+), 5 deletions(-)
arch/powerpc/include/asm/ps3stor.h +7 -1
@@ -25,12 +25,18 @@#include <asm/ps3.h> -#define PS3_STORAGE_MAX_REGIONS (8) +#define PS3_STORAGE_MAX_REGIONS (8) + +#define PS3_STORAGE_FLAG_DEFAULT (0) +#define PS3_STORAGE_FLAG_SKIP_ACL (1 << 1) +#define PS3_STORAGE_FLAG_ALT_KEY (1 << 2) +#define PS3_STORAGE_FLAG_UNENCRYPTED (1 << 5)struct ps3_storage_region {unsigned int id;u64 start;u64 size; +u64 flags; };struct ps3_storage_device {
arch/powerpc/platforms/ps3/device-init.c +1 -0
@@ -409,6 +409,7 @@ static int ps3_setup_storage_dev(const struct ps3_repository_device *repo, p->regions[i].id = id; p->regions[i].start = start; p->regions[i].size = size; + p->regions[i].flags =PS3_STORAGE_FLAG_DEFAULT ; } result =ps3_system_bus_device_register (&p->sbd);
drivers/block/ps3disk.c +3 -2
@@ -130,6 +130,7 @@ static int ps3disk_submit_request_sg(struct ps3_storage_device *dev,unsigned int region_idx =MINOR (disk_devt (req->rq_disk)) & (PS3DISK_MINORS -1 );unsigned int region_id = dev->regions[region_idx].id; +u64 flags = dev->regions[region_idx].flags;#ifdef DEBUG unsigned int n =0 ;
@@ -152,11 +153,11 @@ static int ps3disk_submit_request_sg(struct ps3_storage_device *dev,ps3disk_scatter_gather (dev, req,1 ); res =lv1_storage_write (dev->sbd.dev_id, region_id, - start_sector, sectors,0 , + start_sector, sectors, flags, dev->bounce_lpar, &dev->tag); }else { res =lv1_storage_read (dev->sbd.dev_id, region_id, - start_sector, sectors,0 , + start_sector, sectors, flags, dev->bounce_lpar, &dev->tag); }if (res) {
drivers/ps3/ps3stor_lib.c +3 -2
@@ -275,6 +275,7 @@ u64 ps3stor_read_write_sectors(struct ps3_storage_device *dev, u64 start_sector, u64 sectors, int write) { unsigned int region_id = dev->regions[region_idx].id; +u64 flags = dev->regions[region_idx].flags;const char *op = write ?"write" :"read" ;int res;
@@ -283,10 +284,10 @@ u64 ps3stor_read_write_sectors(struct ps3_storage_device *dev,init_completion (&dev->done); res = write ?lv1_storage_write (dev->sbd.dev_id, region_id, - start_sector, sectors,0 , lpar, + start_sector, sectors, flags, lpar, &dev->tag) :lv1_storage_read (dev->sbd.dev_id, region_id, - start_sector, sectors,0 , lpar, + start_sector, sectors, flags, lpar, &dev->tag);if (res) { dev_dbg(&dev->sbd.core, "%s:%u: %s failed %d\n", __func__,
Signature · 1 line
1.7.5.4
PATCH 13/15 ps3disk: Use region flags
In reply to Andre HeiderProvide a set of default region flags and make them overwritable via a module parameter array.
Set PS3_STORAGE_FLAG_SKIP_ACL for region 0, so it can be accessed from the GameOS lpar.
--- drivers/block/ps3disk.c | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)
drivers/block/ps3disk.c +16 -0
@@ -39,6 +39,19 @@#define PS3DISK_NAME "ps3d%c%c" +static unsigned int region_flags[] = { +PS3_STORAGE_FLAG_SKIP_ACL ,/* raw disk */ +PS3_STORAGE_FLAG_DEFAULT ,/* core os */ +PS3_STORAGE_FLAG_DEFAULT ,/* gameos pup */ +PS3_STORAGE_FLAG_DEFAULT ,/* n/a */ +PS3_STORAGE_FLAG_DEFAULT ,/* n/a */ +PS3_STORAGE_FLAG_DEFAULT ,/* n/a */ +PS3_STORAGE_FLAG_DEFAULT ,/* n/a */ +PS3_STORAGE_FLAG_DEFAULT ,/* n/a */ +}; +module_param_array (region_flags, uint,NULL ,S_IRUGO ); +MODULE_PARM_DESC (region_flags,"Region flags" ); +struct ps3disk_private {spinlock_t lock;/* Request queue spinlock */ struct request_queue *queue;
@@ -453,6 +466,9 @@ static int __devinit ps3disk_probe(struct ps3_system_bus_device *_dev) goto fail_free_priv; } +for (region_idx =0 ; region_idx < dev->num_regions; region_idx++) + dev->regions[region_idx].flags = region_flags[region_idx]; + error =ps3stor_setup (dev, ps3disk_interrupt);if (error) goto fail_free_bounce;
Signature · 1 line
1.7.5.4
PATCH 14/15 ps3: Add a vflash driver for lpars other than OtherOS
In reply to Andre HeiderThis driver refuses to work on OtherOS, and hence complements the ps3flash driver - which only works on OtherOS.
A gendisk for each accessible region is created, and a default set of region flags is provided - overwritable via a module param array.
--- arch/powerpc/platforms/ps3/Kconfig | 16 +- drivers/block/Makefile | 1 + drivers/block/ps3vflash.c | 508 ++++++++++++++++++++++++++++++++++++ 3 files changed, 524 insertions(+), 1 deletions(-) create mode 100644 drivers/block/ps3vflash.c
arch/powerpc/platforms/ps3/Kconfig +15 -1
@@ -121,13 +121,27 @@ config PS3_FLASH This support is required to access the PS3 FLASH ROM, which contains the boot loader and some boot options. - This driver only supports the deprecated OtherOS LPAR. + This driver only supports the deprecated OtherOS LPAR, select + PS3_VFLASH below for all other LPARs. In general, all users will say Y or M. As this driver needs a fixed buffer of 256 KiB of memory, it can be disabled on the kernel command line using "ps3flash=off", to not allocate this fixed buffer. +config PS3_VFLASH + tristate "PS3 VFLASH Storage Driver" + depends on PPC_PS3 && BLOCK + select PS3_STORAGE + help + Include support for the PS3 virtual FLASH Storage. + + This support is required to access the PS3 virtual FLASH ROM, which + contains the boot loader and some boot options. + This driver only supports LPARs other than the deprecated OtherOS, + select PS3_FLASH above to add support for FLASH ROM for the + OtherOS LPAR. + config PS3_VRAM tristate "PS3 Video RAM Storage Driver" depends on FB_PS3=y && BLOCK && m
drivers/block/Makefile +1 -0
@@ -10,6 +10,7 @@ obj-$(CONFIG_BLK_DEV_SWIM) += swim_mod.o obj-$(CONFIG_BLK_DEV_FD) += floppy.o obj-$(CONFIG_AMIGA_FLOPPY) += amiflop.o obj-$(CONFIG_PS3_DISK) += ps3disk.o +obj-$(CONFIG_PS3_VFLASH) += ps3vflash.o obj-$(CONFIG_PS3_VRAM) += ps3vram.o obj-$(CONFIG_ATARI_FLOPPY) += ataflop.o obj-$(CONFIG_AMIGA_Z2RAM) += z2ram.o
drivers/block/ps3vflash.c new file +508 -0
508 lines not on this page · raw message
Signature · 1 line
1.7.5.4
PATCH 15/15 ps3: Add a NOR FLASH driver for PS3s without NAND
In reply to Andre HeiderA gendisk for each accessible region is created, and a default set of region flags is provided - overwritable via a module param array.
--- arch/powerpc/include/asm/ps3.h | 2 + arch/powerpc/platforms/ps3/Kconfig | 15 + arch/powerpc/platforms/ps3/device-init.c | 7 + arch/powerpc/platforms/ps3/platform.h | 1 + arch/powerpc/platforms/ps3/system-bus.c | 2 + drivers/block/Makefile | 1 + drivers/block/ps3nflash.c | 473 ++++++++++++++++++++++++++++++ 7 files changed, 501 insertions(+), 0 deletions(-) create mode 100644 drivers/block/ps3nflash.c
arch/powerpc/include/asm/ps3.h +2 -0
@@ -333,6 +333,7 @@ enum ps3_match_id {PS3_MATCH_ID_SOUND =9 ,PS3_MATCH_ID_GPU =10 ,PS3_MATCH_ID_LPM =11 , + PS3_MATCH_ID_STOR_NFLASH = 12, }; enum ps3_match_sub_id {
@@ -352,6 +353,7 @@ enum ps3_match_sub_id {#define PS3_MODULE_ALIAS_GPU_FB "ps3:10:1"#define PS3_MODULE_ALIAS_GPU_RAMDISK "ps3:10:2"#define PS3_MODULE_ALIAS_LPM "ps3:11:0" +#define PS3_MODULE_ALIAS_STOR_NFLASH "ps3:12:0"enum ps3_system_bus_device_type {PS3_DEVICE_TYPE_IOC0 =1 ,
arch/powerpc/platforms/ps3/Kconfig +15 -0
@@ -142,6 +142,21 @@ config PS3_VFLASH select PS3_FLASH above to add support for FLASH ROM for the OtherOS LPAR. +config PS3_NFLASH + tristate "PS3 NFLASH Storage Driver" + depends on PPC_PS3 && BLOCK && EXPERT + select PS3_STORAGE + help + Include support for the PS3 NOR FLASH Storage. + + This support is required to access the PS3 NOR flash, which can be + found on SKU models starting around October 2007. + + The NOR flash contains essential boot loaders. Damaging this area + will render the console unbootable. + + If unsure, say N. + config PS3_VRAM tristate "PS3 Video RAM Storage Driver" depends on FB_PS3=y && BLOCK && m
arch/powerpc/platforms/ps3/device-init.c +7 -0
@@ -601,6 +601,13 @@ static int ps3_setup_dynamic_device(const struct ps3_repository_device *repo) __func__, __LINE__);break ; +case PS3_DEV_TYPE_STOR_NFLASH : + result =ps3_setup_storage_dev (repo,PS3_MATCH_ID_STOR_NFLASH ); +if (result) +pr_debug ("%s:%u ps3_setup_storage_dev failed\n" , + __func__, __LINE__); +break ; +default : result =0 ; pr_debug("%s:%u: unsupported dev_type %u\n", __func__, __LINE__,
arch/powerpc/platforms/ps3/platform.h +1 -0
@@ -87,6 +87,7 @@ enum ps3_dev_type {PS3_DEV_TYPE_STOR_ROM =TYPE_ROM ,/* 5 */ PS3_DEV_TYPE_SB_GPIO =6 ,PS3_DEV_TYPE_STOR_FLASH =TYPE_RBC ,/* 14 */ + PS3_DEV_TYPE_STOR_NFLASH = 254, }; int ps3_repository_read_bus_str(unsigned int bus_index, const char *bus_str,
arch/powerpc/platforms/ps3/system-bus.c +2 -0
@@ -174,6 +174,7 @@ int ps3_open_hv_device(struct ps3_system_bus_device *dev)case PS3_MATCH_ID_STOR_DISK :case PS3_MATCH_ID_STOR_ROM :case PS3_MATCH_ID_STOR_FLASH : +case PS3_MATCH_ID_STOR_NFLASH :return ps3_open_hv_device_sb (dev);case PS3_MATCH_ID_SOUND :
@@ -212,6 +213,7 @@ int ps3_close_hv_device(struct ps3_system_bus_device *dev)case PS3_MATCH_ID_STOR_DISK :case PS3_MATCH_ID_STOR_ROM :case PS3_MATCH_ID_STOR_FLASH : +case PS3_MATCH_ID_STOR_NFLASH :return ps3_close_hv_device_sb (dev);case PS3_MATCH_ID_SOUND :
drivers/block/Makefile +1 -0
@@ -11,6 +11,7 @@ obj-$(CONFIG_BLK_DEV_FD) += floppy.o obj-$(CONFIG_AMIGA_FLOPPY) += amiflop.o obj-$(CONFIG_PS3_DISK) += ps3disk.o obj-$(CONFIG_PS3_VFLASH) += ps3vflash.o +obj-$(CONFIG_PS3_NFLASH) += ps3nflash.o obj-$(CONFIG_PS3_VRAM) += ps3vram.o obj-$(CONFIG_ATARI_FLOPPY) += ataflop.o obj-$(CONFIG_AMIGA_Z2RAM) += z2ram.o
drivers/block/ps3nflash.c new file +473 -0
473 lines not on this page · raw message
Signature · 1 line
1.7.5.4
Geoff Levand
maintainerHi Andre,
Quoted 3 lines · Andre Heider
This series addresses various issues and extends support when running in lpars like GameOS. Included are some patches from Hector Martin, which I found useful.
Much of this is just general fixups and improvements to the existing PS3 support. I think you should separate those changes out and work to get them included, then consider others. If I give some comment, then I consider that part worth pursuing at the present time.
I have limited time to review the patches, so it will take me a while to get through them.
Quoted 3 lines
Patches are based on 2.6.39 since master doesn't boot with smp on my console. I wasn't able to pinpoint the cause so far (not that I tried too hard).
I'm looking into this problem, but it will take some time.
-Geoff
Hi Geoff,
Quoted 5 lines · Geoff Levand
Hi Andre,
Quoted 2 lines · Andre Heider
This series addresses various issues and extends support when running in lpars like GameOS. Included are some patches from Hector Martin, whic=
h
Quoted 6 lines
Quoted 1 line
I found useful.
Much of this is just general fixups and improvements to the existing PS3 support. =A0I think you should separate those changes out and work to get them included, then consider others. =A0If I give some comment, then I consider that part worth pursuing at the present time.
Sounds like a good approach to me.
Quoted 2 lines
I have limited time to review the patches, so it will take me a while to get through them.
No problem at all, it will probably take some time to resolve all the details anyway.
Quoted 5 lines
Quoted 3 lines
Patches are based on 2.6.39 since master doesn't boot with smp on my console. =A0I wasn't able to pinpoint the cause so far (not that I tried too hard).
I'm looking into this problem, but it will take some time.
Just for the record: I didn't mean to push ;)
Thanks,
Andre
Arnd Bergmann
maintainerQuoted 3 lines · Andre Heider
This series addresses various issues and extends support when running in lpars like GameOS. Included are some patches from Hector Martin, which I found useful.
Hi Andre,
I've looked at the entire series and support merging it into 3.2 once the concerns from Geoff and Geert are resolved. I don't have anything to add there.
Arnd
Quoted 10 lines · Arnd Bergmann
Quoted 3 lines · Andre Heider
This series addresses various issues and extends support when running in lpars like GameOS. Included are some patches from Hector Martin, which I found useful.
Hi Andre,
I've looked at the entire series and support merging it into 3.2 once the concerns from Geoff and Geert are resolved. I don't have anything to add there.
Hi Arnd,
thanks, I'll send the first part of v2 soon
v2 cover ps3: General improvements and preparation for support more than the OtherOS lpar
In reply to Andre HeiderThis is the first part of my previous series including the discussed fixups.
I dropped the old #2 ([PS3] Get lv1 high memory region from devtree) and replaced it with 2 new patches, now #2 and #3. The latter contains the fixups mentioned on the old #2 thread.
Patches are based on today's Linus' tree.
Andre Heider (7):
ps3: Add helper functions to read highmem info from the repository
ps3: Get lv1 high memory region from the repository
ps3: MEMORY_HOTPLUG is not a requirement anymore
ps3: Detect the current lpar
ps3: Log the detected lpar on startup
ps3flash: Refuse to work in lpars other than OtherOS
ps3: Only prealloc the flash bounce buffer for the OtherOS lpar
Hector Martin (2):
Add udbg driver using the PS3 gelic Ethernet device Add region 1 memory early
arch/powerpc/Kconfig.debug | 8 + arch/powerpc/include/asm/ps3.h | 7 + arch/powerpc/include/asm/udbg.h | 1 + arch/powerpc/kernel/udbg.c | 2 + arch/powerpc/platforms/ps3/Kconfig | 15 ++- arch/powerpc/platforms/ps3/Makefile | 1 + arch/powerpc/platforms/ps3/gelic_udbg.c | 273 +++++++++++++++++++++++++++++++ arch/powerpc/platforms/ps3/mm.c | 85 +++++------ arch/powerpc/platforms/ps3/platform.h | 7 + arch/powerpc/platforms/ps3/repository.c | 55 ++++++ arch/powerpc/platforms/ps3/setup.c | 27 +++- drivers/char/ps3flash.c | 7 + drivers/net/ps3_gelic_net.c | 3 + drivers/net/ps3_gelic_net.h | 6 + 14 files changed, 447 insertions(+), 50 deletions(-) create mode 100644 arch/powerpc/platforms/ps3/gelic_udbg.c
Signature · 1 line
1.7.5.4
PATCH v2 1/9 Add udbg driver using the PS3 gelic Ethernet device
From: Hector Martin <[email protected]>
--- arch/powerpc/Kconfig.debug | 8 + arch/powerpc/include/asm/udbg.h | 1 + arch/powerpc/kernel/udbg.c | 2 + arch/powerpc/platforms/ps3/Kconfig | 12 ++ arch/powerpc/platforms/ps3/Makefile | 1 + arch/powerpc/platforms/ps3/gelic_udbg.c | 273 +++++++++++++++++++++++++++++++ drivers/net/ps3_gelic_net.c | 3 + drivers/net/ps3_gelic_net.h | 6 + 8 files changed, 306 insertions(+), 0 deletions(-) create mode 100644 arch/powerpc/platforms/ps3/gelic_udbg.c
arch/powerpc/Kconfig.debug +8 -0
@@ -258,6 +258,14 @@ config PPC_EARLY_DEBUG_WSP depends on PPC_WSP select PPC_UDBG_16550 +config PPC_EARLY_DEBUG_PS3GELIC + bool "Early debugging through the PS3 Ethernet port" + depends on PPC_PS3 + select PS3GELIC_UDBG + help + Select this to enable early debugging for the PlayStation3 via + UDP broadcasts sent out through the Ethernet port. + endchoice config PPC_EARLY_DEBUG_HVSI_VTERMNO
arch/powerpc/include/asm/udbg.h +1 -0
@@ -54,6 +54,7 @@ extern void __init udbg_init_40x_realmode(void);extern void __init udbg_init_cpm (void );extern void __init udbg_init_usbgecko (void );extern void __init udbg_init_wsp (void ); +extern void __init udbg_init_ps3gelic (void );#endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_UDBG_H */
arch/powerpc/kernel/udbg.c +2 -0
@@ -67,6 +67,8 @@ void __init udbg_early_init(void)udbg_init_usbgecko ();#elif defined(CONFIG_PPC_EARLY_DEBUG_WSP )udbg_init_wsp (); +#elif defined(CONFIG_PPC_EARLY_DEBUG_PS3GELIC ) +udbg_init_ps3gelic ();#endif #ifdef CONFIG_PPC_EARLY_DEBUG
arch/powerpc/platforms/ps3/Kconfig +12 -0
@@ -148,4 +148,16 @@ config PS3_LPM profiling support of the Cell processor with programs like oprofile and perfmon2, then say Y or M, otherwise say N. +config PS3GELIC_UDBG + bool "PS3 udbg output via UDP broadcasts on Ethernet" + depends on PPC_PS3 + help + Enables udbg early debugging output by sending broadcast UDP + via the Ethernet port (UDP port number 18194). + + This driver uses a trivial implementation and is independent + from the main network driver. + + If in doubt, say N here. + endmenu
arch/powerpc/platforms/ps3/Makefile +1 -0
@@ -2,6 +2,7 @@ obj-y += setup.o mm.o time.o hvcall.o htab.o repository.o obj-y += interrupt.o exports.o os-area.o obj-y += system-bus.o +obj-$(CONFIG_PS3GELIC_UDBG) += gelic_udbg.o obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_SPU_BASE) += spu.o obj-y += device-init.o
arch/powerpc/platforms/ps3/gelic_udbg.c new file +273 -0
273 lines not on this page · raw message
drivers/net/ps3_gelic_net.c +3 -0
@@ -1674,6 +1674,9 @@ static int __devinit ps3_gelic_driver_probe(struct ps3_system_bus_device *dev)int result;pr_debug ("%s: called\n" , __func__); + +udbg_shutdown_ps3gelic (); + result =ps3_open_hv_device (dev);if (result) {
drivers/net/ps3_gelic_net.h +6 -0
@@ -359,6 +359,12 @@ static inline void *port_priv(struct gelic_port *port)return port->priv; } +#ifdef CONFIG_PPC_EARLY_DEBUG_PS3GELIC +extern void udbg_shutdown_ps3gelic (void ); +#else +static inline void udbg_shutdown_ps3gelic (void ) {} +#endif +extern int gelic_card_set_irq_mask (struct gelic_card *card,u64 mask);/* shared netdev ops */ extern void gelic_card_up (struct gelic_card *card);
Signature · 1 line
1.7.5.4
Geoff Levand
maintainerRe: [PATCH part1 v2 1/9] Add udbg driver using the PS3 gelic Ethernet device
Hi,
We had some questions as to why we have this totally separate driver from the gelic driver, so I think it worthwhile to have an
explanation of why in the commit log. Otherwise, the code looks
OK.
-Geoff
Quoted 404 lines
From: Hector Martin <[email protected]>
Signed-off-by Hector Martin <[email protected]>[a.heider: Various cleanups to make checkpatch.pl happy]Signed-off-by Andre Heider <[email protected]>--- arch/powerpc/Kconfig.debug | 8 + arch/powerpc/include/asm/udbg.h | 1 + arch/powerpc/kernel/udbg.c | 2 + arch/powerpc/platforms/ps3/Kconfig | 12 ++ arch/powerpc/platforms/ps3/Makefile | 1 + arch/powerpc/platforms/ps3/gelic_udbg.c | 273 +++++++++++++++++++++++++++++++ drivers/net/ps3_gelic_net.c | 3 + drivers/net/ps3_gelic_net.h | 6 + 8 files changed, 306 insertions(+), 0 deletions(-) create mode 100644 arch/powerpc/platforms/ps3/gelic_udbg.carch/powerpc/Kconfig.debug +8
-0@@ -258,6 +258,14 @@ config PPC_EARLY_DEBUG_WSP depends on PPC_WSP select PPC_UDBG_16550 +config PPC_EARLY_DEBUG_PS3GELIC + bool "Early debugging through the PS3 Ethernet port" + depends on PPC_PS3 + select PS3GELIC_UDBG + help + Select this to enable early debugging for the PlayStation3 via + UDP broadcasts sent out through the Ethernet port. + endchoice config PPC_EARLY_DEBUG_HVSI_VTERMNOarch/powerpc/include/asm/udbg.h +1
-0@@ -54,6 +54,7 @@ extern void __init udbg_init_40x_realmode(void);extern void __init udbg_init_cpm (void );extern void __init udbg_init_usbgecko (void );extern void __init udbg_init_wsp (void ); +extern void __init udbg_init_ps3gelic (void );#endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_UDBG_H */ arch/powerpc/kernel/udbg.c +2
-0@@ -67,6 +67,8 @@ void __init udbg_early_init(void)udbg_init_usbgecko ();#elif defined(CONFIG_PPC_EARLY_DEBUG_WSP )udbg_init_wsp (); +#elif defined(CONFIG_PPC_EARLY_DEBUG_PS3GELIC ) +udbg_init_ps3gelic ();#endif #ifdef CONFIG_PPC_EARLY_DEBUG arch/powerpc/platforms/ps3/Kconfig +12
-0@@ -148,4 +148,16 @@ config PS3_LPM profiling support of the Cell processor with programs like oprofile and perfmon2, then say Y or M, otherwise say N. +config PS3GELIC_UDBG + bool "PS3 udbg output via UDP broadcasts on Ethernet" + depends on PPC_PS3 + help + Enables udbg early debugging output by sending broadcast UDP + via the Ethernet port (UDP port number 18194). + + This driver uses a trivial implementation and is independent + from the main network driver. + + If in doubt, say N here. + endmenuarch/powerpc/platforms/ps3/Makefile +1
-0@@ -2,6 +2,7 @@ obj-y += setup.o mm.o time.o hvcall.o htab.o repository.o obj-y += interrupt.o exports.o os-area.o obj-y += system-bus.o +obj-$(CONFIG_PS3GELIC_UDBG) += gelic_udbg.o obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_SPU_BASE) += spu.o obj-y += device-init.oarch/powerpc/platforms/ps3/gelic_udbg.c new file +273
-0@@ -0,0 +1,273 @@ +/* +* udbg debug output routine via GELIC UDP broadcasts +* +* Copyright (C) 2007 Sony Computer Entertainment Inc. +* Copyright 2006, 2007 Sony Corporation +* Copyright (C) 2010 Hector Martin <[email protected]> +* Copyright (C) 2011 Andre Heider <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +*/ + +#include <asm/io.h> +#include <asm/udbg.h> +#include <asm/lv1call.h> + +#define GELIC_BUS_ID 1 +#define GELIC_DEVICE_ID 0 +#define GELIC_DEBUG_PORT 18194 +#define GELIC_MAX_MESSAGE_SIZE 1000 + +#define GELIC_LV1_GET_MAC_ADDRESS 1 +#define GELIC_LV1_GET_VLAN_ID 4 +#define GELIC_LV1_VLAN_TX_ETHERNET_0 2 + +#define GELIC_DESCR_DMA_STAT_MASK 0xf0000000 +#define GELIC_DESCR_DMA_CARDOWNED 0xa0000000 + +#define GELIC_DESCR_TX_DMA_IKE 0x00080000 +#define GELIC_DESCR_TX_DMA_NO_CHKSUM 0x00000000 +#define GELIC_DESCR_TX_DMA_FRAME_TAIL 0x00040000 + +#define GELIC_DESCR_DMA_CMD_NO_CHKSUM (GELIC_DESCR_DMA_CARDOWNED | \ + GELIC_DESCR_TX_DMA_IKE | \ + GELIC_DESCR_TX_DMA_NO_CHKSUM) + +static u64 bus_addr; + +struct gelic_descr { +/* as defined by the hardware */ +__be32 buf_addr; +__be32 buf_size; +__be32 next_descr_addr; +__be32 dmac_cmd_status; +__be32 result_size; +__be32 valid_size;/* all zeroes for tx */ +__be32 data_status; +__be32 data_error;/* all zeroes for tx */ +} __attribute__((aligned (32 ))); + +struct debug_block { +struct gelic_descr descr; +u8 pkt[1520 ]; +} __packed; + +struct ethhdr { +u8 dest[6 ]; +u8 src[6 ]; +u16 type; +} __packed; + +struct vlantag { +u16 vlan; +u16 subtype; +} __packed; + +struct iphdr { +u8 ver_len; +u8 dscp_ecn; +u16 total_length; +u16 ident; +u16 frag_off_flags; +u8 ttl; +u8 proto; +u16 checksum; +u32 src; +u32 dest; +} __packed; + +struct udphdr { +u16 src; +u16 dest; +u16 len; +u16 checksum; +} __packed; + +static __iomem struct ethhdr *h_eth; +static __iomem struct vlantag *h_vlan; +static __iomem struct iphdr *h_ip; +static __iomem struct udphdr *h_udp; + +static __iomem char *pmsg; +static __iomem char *pmsgc; + +static __iomem struct debug_block dbg __attribute__((aligned(32))); + +static int header_size; + +static void map_dma_mem (int bus_id,int dev_id,void *start,size_t len, +u64 *real_bus_addr) +{ +s64 result; +u64 real_addr = ((u64 )start) &0x0fffffffffffffffUL ; +u64 real_end = real_addr + len; +u64 map_start = real_addr & ~0xfff ; +u64 map_end = (real_end +0xfff ) & ~0xfff ; +u64 bus_addr =0 ; + +u64 flags =0xf800000000000000UL ; + + result =lv1_allocate_device_dma_region (bus_id, dev_id, + map_end - map_start,12 ,0 , + &bus_addr); +if (result) +lv1_panic (0 ); + + result =lv1_map_device_dma_region (bus_id, dev_id, map_start, + bus_addr, map_end - map_start, + flags); +if (result) +lv1_panic (0 ); + + *real_bus_addr = bus_addr + real_addr - map_start; +} + +static int unmap_dma_mem (int bus_id,int dev_id,u64 bus_addr,size_t len) +{ +s64 result; +u64 real_bus_addr; + + real_bus_addr = bus_addr & ~0xfff ; + len += bus_addr - real_bus_addr; + len = (len +0xfff ) & ~0xfff ; + + result =lv1_unmap_device_dma_region (bus_id, dev_id, real_bus_addr, + len); +if (result) +return result; + +return lv1_free_device_dma_region (bus_id, dev_id, real_bus_addr); +} + +static void gelic_debug_init (void ) +{ +s64 result; +u64 v2; +u64 mac; +u64 vlan_id; + + result =lv1_open_device (GELIC_BUS_ID ,GELIC_DEVICE_ID ,0 ); +if (result) +lv1_panic (0 ); + +map_dma_mem (GELIC_BUS_ID ,GELIC_DEVICE_ID , &dbg,sizeof (dbg), + &bus_addr); + +memset (&dbg,0 ,sizeof (dbg)); + + dbg.descr.buf_addr = bus_addr + offsetof(struct debug_block , pkt); + +wmb (); + + result =lv1_net_control (GELIC_BUS_ID ,GELIC_DEVICE_ID , +GELIC_LV1_GET_MAC_ADDRESS ,0 ,0 ,0 , + &mac, &v2); +if (result) +lv1_panic (0 ); + + mac <<=16 ; + + h_eth = (struct ethhdr *)dbg.pkt; + +memset (&h_eth->dest,0xff ,6 ); +memcpy (&h_eth->src, &mac,6 ); + + header_size =sizeof (struct ethhdr ); + + result =lv1_net_control (GELIC_BUS_ID ,GELIC_DEVICE_ID , +GELIC_LV1_GET_VLAN_ID , +GELIC_LV1_VLAN_TX_ETHERNET_0 ,0 ,0 , + &vlan_id, &v2); +if (!result) { + h_eth->type =0x8100 ; + + header_size +=sizeof (struct vlantag ); + h_vlan = (struct vlantag *)(h_eth +1 ); + h_vlan->vlan = vlan_id; + h_vlan->subtype =0x0800 ; + h_ip = (struct iphdr *)(h_vlan +1 ); + }else { + h_eth->type =0x0800 ; + h_ip = (struct iphdr *)(h_eth +1 ); + } + + header_size +=sizeof (struct iphdr ); + h_ip->ver_len =0x45 ; + h_ip->ttl =10 ; + h_ip->proto =0x11 ; + h_ip->src =0x00000000 ; + h_ip->dest =0xffffffff ; + + header_size +=sizeof (struct udphdr ); + h_udp = (struct udphdr *)(h_ip +1 ); + h_udp->src =GELIC_DEBUG_PORT ; + h_udp->dest =GELIC_DEBUG_PORT ; + + pmsgc = pmsg = (char *)(h_udp +1 ); +} + +static void gelic_debug_shutdown (void ) +{ +if (bus_addr) +unmap_dma_mem (GELIC_BUS_ID ,GELIC_DEVICE_ID , + bus_addr,sizeof (dbg)); +lv1_close_device (GELIC_BUS_ID ,GELIC_DEVICE_ID ); +} + +static void gelic_sendbuf (int msgsize) +{ +u16 *p; +u32 sum; +int i; + + dbg.descr.buf_size = header_size + msgsize; + h_ip->total_length = msgsize +sizeof (struct udphdr ) + +sizeof (struct iphdr ); + h_udp->len = msgsize +sizeof (struct udphdr ); + + h_ip->checksum =0 ; + sum =0 ; + p = (u16 *)h_ip; +for (i =0 ; i <5 ; i++) + sum += *p++; + h_ip->checksum = ~(sum + (sum >>16 )); + + dbg.descr.dmac_cmd_status =GELIC_DESCR_DMA_CMD_NO_CHKSUM | +GELIC_DESCR_TX_DMA_FRAME_TAIL ; + dbg.descr.result_size =0 ; + dbg.descr.data_status =0 ; + +wmb (); + +lv1_net_start_tx_dma (GELIC_BUS_ID ,GELIC_DEVICE_ID , bus_addr,0 ); + +while ((dbg.descr.dmac_cmd_status &GELIC_DESCR_DMA_STAT_MASK ) == +GELIC_DESCR_DMA_CARDOWNED ) +cpu_relax (); +} + +static void ps3gelic_udbg_putc (char ch) +{ + *pmsgc++ = ch; +if (ch =='\n' || (pmsgc-pmsg) >=GELIC_MAX_MESSAGE_SIZE ) { +gelic_sendbuf (pmsgc-pmsg); + pmsgc = pmsg; + } +} + +void __init udbg_init_ps3gelic (void ) +{ +gelic_debug_init (); + udbg_putc = ps3gelic_udbg_putc; +} + +void udbg_shutdown_ps3gelic (void ) +{ + udbg_putc =NULL ; +gelic_debug_shutdown (); +} +EXPORT_SYMBOL (udbg_shutdown_ps3gelic);drivers/net/ps3_gelic_net.c +3
-0@@ -1674,6 +1674,9 @@ static int __devinit ps3_gelic_driver_probe(struct ps3_system_bus_device *dev)int result;pr_debug ("%s: called\n" , __func__); + +udbg_shutdown_ps3gelic (); + result =ps3_open_hv_device (dev);if (result) {drivers/net/ps3_gelic_net.h +6
-0@@ -359,6 +359,12 @@ static inline void *port_priv(struct gelic_port *port)return port->priv; } +#ifdef CONFIG_PPC_EARLY_DEBUG_PS3GELIC +extern void udbg_shutdown_ps3gelic (void ); +#else +static inline void udbg_shutdown_ps3gelic (void ) {} +#endif +extern int gelic_card_set_irq_mask (struct gelic_card *card,u64 mask);/* shared netdev ops */ extern void gelic_card_up (struct gelic_card *card);
Geoff Levand
maintainerPATCH 1/1 Add gelic udbg driver
From: Hector Martin <[email protected]>
Add a new udbg driver for the PS3 gelic Ehthernet device.
This driver shares only a few stucture and constant definitions with the gelic Ethernet device driver, so is implemented as a stand-alone driver with no dependencies on the gelic Ethernet device driver.
--- arch/powerpc/Kconfig.debug | 8 + arch/powerpc/include/asm/udbg.h | 1 + arch/powerpc/kernel/udbg.c | 2 + arch/powerpc/platforms/ps3/Kconfig | 12 ++ arch/powerpc/platforms/ps3/Makefile | 1 + arch/powerpc/platforms/ps3/gelic_udbg.c | 273 +++++++++++++++++++++++++++++++ drivers/net/ps3_gelic_net.c | 3 + drivers/net/ps3_gelic_net.h | 6 + 8 files changed, 306 insertions(+), 0 deletions(-) create mode 100644 arch/powerpc/platforms/ps3/gelic_udbg.c
arch/powerpc/Kconfig.debug +8 -0
@@ -258,6 +258,14 @@ config PPC_EARLY_DEBUG_WSP depends on PPC_WSP select PPC_UDBG_16550 +config PPC_EARLY_DEBUG_PS3GELIC + bool "Early debugging through the PS3 Ethernet port" + depends on PPC_PS3 + select PS3GELIC_UDBG + help + Select this to enable early debugging for the PlayStation3 via + UDP broadcasts sent out through the Ethernet port. + endchoice config PPC_EARLY_DEBUG_HVSI_VTERMNO
arch/powerpc/include/asm/udbg.h +1 -0
@@ -54,6 +54,7 @@ extern void __init udbg_init_40x_realmode(void);extern void __init udbg_init_cpm (void );extern void __init udbg_init_usbgecko (void );extern void __init udbg_init_wsp (void ); +extern void __init udbg_init_ps3gelic (void );#endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_UDBG_H */
arch/powerpc/kernel/udbg.c +2 -0
@@ -67,6 +67,8 @@ void __init udbg_early_init(void)udbg_init_usbgecko ();#elif defined(CONFIG_PPC_EARLY_DEBUG_WSP )udbg_init_wsp (); +#elif defined(CONFIG_PPC_EARLY_DEBUG_PS3GELIC ) +udbg_init_ps3gelic ();#endif #ifdef CONFIG_PPC_EARLY_DEBUG
arch/powerpc/platforms/ps3/Kconfig +12 -0
@@ -148,4 +148,16 @@ config PS3_LPM profiling support of the Cell processor with programs like oprofile and perfmon2, then say Y or M, otherwise say N. +config PS3GELIC_UDBG + bool "PS3 udbg output via UDP broadcasts on Ethernet" + depends on PPC_PS3 + help + Enables udbg early debugging output by sending broadcast UDP + via the Ethernet port (UDP port number 18194). + + This driver uses a trivial implementation and is independent + from the main network driver. + + If in doubt, say N here. + endmenu
arch/powerpc/platforms/ps3/Makefile +1 -0
@@ -2,6 +2,7 @@ obj-y += setup.o mm.o time.o hvcall.o htab.o repository.o obj-y += interrupt.o exports.o os-area.o obj-y += system-bus.o +obj-$(CONFIG_PS3GELIC_UDBG) += gelic_udbg.o obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_SPU_BASE) += spu.o obj-y += device-init.o
arch/powerpc/platforms/ps3/gelic_udbg.c new file +273 -0
273 lines not on this page · raw message
drivers/net/ps3_gelic_net.c +3 -0
@@ -1674,6 +1674,9 @@ static int __devinit ps3_gelic_driver_probe(struct ps3_system_bus_device *dev)int result;pr_debug ("%s: called\n" , __func__); + +udbg_shutdown_ps3gelic (); + result =ps3_open_hv_device (dev);if (result) {
drivers/net/ps3_gelic_net.h +6 -0
@@ -359,6 +359,12 @@ static inline void *port_priv(struct gelic_port *port)return port->priv; } +#ifdef CONFIG_PPC_EARLY_DEBUG_PS3GELIC +extern void udbg_shutdown_ps3gelic (void ); +#else +static inline void udbg_shutdown_ps3gelic (void ) {} +#endif +extern int gelic_card_set_irq_mask (struct gelic_card *card,u64 mask);/* shared netdev ops */ extern void gelic_card_up (struct gelic_card *card);
PATCH v2 2/9 ps3: Add helper functions to read highmem info from the repository
In reply to Andre HeiderAn earlier step in the boot chain can preallocate the highmem region. A boot loader doing so will place the region infos in the repository. Provide helper functions to read the required nodes.
--- arch/powerpc/platforms/ps3/platform.h | 3 ++ arch/powerpc/platforms/ps3/repository.c | 36 +++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 0 deletions(-)
arch/powerpc/platforms/ps3/platform.h +3 -0
@@ -187,6 +187,9 @@ int ps3_repository_read_rm_size(unsigned int ppe_id, u64 *rm_size);int ps3_repository_read_region_total (u64 *region_total);int ps3_repository_read_mm_info (u64 *rm_base,u64 *rm_size,u64 *region_total); +int ps3_repository_read_highmem_base (u64 *highmem_base); +int ps3_repository_read_highmem_size (u64 *highmem_size); +int ps3_repository_read_highmem_info (u64 *highmem_base,u64 *highmem_size);/* repository pme info */
arch/powerpc/platforms/ps3/repository.c +36 -0
@@ -778,6 +778,42 @@ int ps3_repository_read_mm_info(u64 *rm_base, u64 *rm_size, u64 *region_total) : ps3_repository_read_region_total(region_total); } +int ps3_repository_read_highmem_base (u64 *highmem_base) +{ +return read_node (PS3_LPAR_ID_CURRENT , +make_first_field ("bi" ,0 ), +make_field ("highmem" ,0 ), +make_field ("base" ,0 ), +0 , + highmem_base,NULL ); +} + +int ps3_repository_read_highmem_size (u64 *highmem_size) +{ +return read_node (PS3_LPAR_ID_CURRENT , +make_first_field ("bi" ,0 ), +make_field ("highmem" ,0 ), +make_field ("size" ,0 ), +0 , + highmem_size,NULL ); +} + +/** +* ps3_repository_read_highmem_info - Read high memory info +* @highmem_base: High memory base address. +* @highmem_size: High mode memory size. +*/ + +int ps3_repository_read_highmem_info (u64 *highmem_base,u64 *highmem_size) +{ +int result; + + *highmem_base =0 ; + result =ps3_repository_read_highmem_base (highmem_base); +return result ? result + :ps3_repository_read_highmem_size (highmem_size); +} +/** * ps3_repository_read_num_spu_reserved - Number of physical spus reserved. * @num_spu: Number of physical spus.
Signature · 1 line
1.7.5.4
Geoff Levand
maintainerRe: [PATCH part1 v2 2/9] ps3: Add helper functions to read highmem info from the repository
Quoted 15 lines · Andre Heider
An earlier step in the boot chain can preallocate the highmem region. A boot loader doing so will place the region infos in the repository. Provide helper functions to read the required nodes.
Signed-off-by Andre Heider <[email protected]>--- arch/powerpc/platforms/ps3/platform.h | 3 ++ arch/powerpc/platforms/ps3/repository.c | 36 +++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 0 deletions(-)arch/powerpc/platforms/ps3/platform.h +0
-0
arch/powerpc/platforms/ps3/platform.h int ps3_repository_read_rm_size(unsigned int ppe_id, u64 *rm_size); · line 192
Quoted 6 lines
arch/powerpc/platforms/ps3/platform.h +3
-0@@ -187,6 +187,9 @@ int ps3_repository_read_rm_size(unsigned int ppe_id, u64 *rm_size);int ps3_repository_read_region_total (u64 *region_total);int ps3_repository_read_mm_info (u64 *rm_base,u64 *rm_size,u64 *region_total); +int ps3_repository_read_highmem_base (u64 *highmem_base); +int ps3_repository_read_highmem_size (u64 *highmem_size); +int ps3_repository_read_highmem_info (u64 *highmem_base,u64 *highmem_size);
In the general case we could have multiple regions. If we add a region arg here we can handle that if needed. region_index would be {1..}. ps3_repository_read_highmem_info could hold how many regions, so:
int ps3_repository_read_highmem_base(unsigned int region_index, u64 *highmem_base); int ps3_repository_read_highmem_size(unsigned int region_index, u64 *highmem_size); int ps3_repository_read_highmem_region(unsigned int region_index, u64 *highmem_base, u64 *highmem_size);
Quoted 10 lines
arch/powerpc/platforms/ps3/platform.h +0
-0/* repository pme info */ arch/powerpc/platforms/ps3/repository.c +0
-0@@ -778,6 +778,42 @@ int ps3_repository_read_mm_info(u64 *rm_base, u64 *rm_size, u64 *region_total) : ps3_repository_read_region_total(region_total); }
arch/powerpc/platforms/ps3/repository.c int ps3_repository_read_mm_info(u64 *rm_base, u64 *rm_size, u64 *region_total) · line 789
Quoted 10 lines
arch/powerpc/platforms/ps3/repository.c +9
-0+int ps3_repository_read_highmem_base (u64 *highmem_base) +{ +return read_node (PS3_LPAR_ID_CURRENT , +make_first_field ("bi" ,0 ), +make_field ("highmem" ,0 ), +make_field ("base" ,0 ), +0 , + highmem_base,NULL ); +}
I think something like this seems better:
int ps3_repository_read_highmem_base(unsigned int region_index, u64 *highmem_base)
{
return read_node(PS3_LPAR_ID_CURRENT,
make_first_field("highmem", 0),
make_field("region", region_index),
make_field("base", 0),
0,
highmem_base, NULL);
}Quoted 15 lines
arch/powerpc/platforms/ps3/repository.c +15
-0+ +int ps3_repository_read_highmem_size (u64 *highmem_size) +{ +return read_node (PS3_LPAR_ID_CURRENT , +make_first_field ("bi" ,0 ), +make_field ("highmem" ,0 ), +make_field ("size" ,0 ), +0 , + highmem_size,NULL ); +} + +/** +* ps3_repository_read_highmem_info - Read high memory info +* @highmem_base: High memory base address. +* @highmem_size: High mode memory size.
arch/powerpc/platforms/ps3/repository.c int ps3_repository_read_mm_info(u64 *rm_base, u64 *rm_size, u64 *region_total) · line 814
Quoted 10 lines
arch/powerpc/platforms/ps3/repository.c +10
-0+*/ + +int ps3_repository_read_highmem_info (u64 *highmem_base,u64 *highmem_size) +{ +int result; + + *highmem_base =0 ; + result =ps3_repository_read_highmem_base (highmem_base); +return result ? result + :ps3_repository_read_highmem_size (highmem_size);
ps3_repository_read_highmem_base(1, highmem_base); ...
arch/powerpc/platforms/ps3/repository.c int ps3_repository_read_mm_info(u64 *rm_base, u64 *rm_size, u64 *region_total) · line 819
Quoted 5 lines
arch/powerpc/platforms/ps3/repository.c +2
-0+} +/** * ps3_repository_read_num_spu_reserved - Number of physical spus reserved. * @num_spu: Number of physical spus.
-Geoff
PATCH v2 3/9 ps3: Get lv1 high memory region from the repository
In reply to Andre HeiderThis lets the bootloader preallocate the high lv1 region and pass its location to the kernel through the repository. Thus, it can be used to hold the initrd. If the region info doesn't exist, the kernel retains the old behavior and attempts to allocate the region itself.
Based on the patch
"[PS3] Get lv1 high memory region from devtree"
from Hector Martin <[email protected]>
--- arch/powerpc/platforms/ps3/mm.c | 46 ++++++++++++++++++++++++++++++++++++-- 1 files changed, 43 insertions(+), 3 deletions(-)
arch/powerpc/platforms/ps3/mm.c +43 -3
@@ -78,12 +78,14 @@ enum {* @base: base address * @size: size in bytes * @offset: difference between base and rm.size +* @destroy: flag if region should be destroyed upon shutdown */ struct mem_region {u64 base;u64 size;unsigned long offset; +int destroy; };/**
@@ -261,6 +263,7 @@ static int ps3_mm_region_create(struct mem_region *r, unsigned long size) goto zero_region; } + r->destroy =1 ; r->offset = r->base - map.rm.size;return result;
@@ -279,6 +282,12 @@ static void ps3_mm_region_destroy(struct mem_region *r)int result;DBG ("%s:%d: r->base = %llxh\n" , __func__, __LINE__, r->base); + +if (!r->destroy) { +DBG ("%s:%d: not destroying region\n" , __func__, __LINE__); +return ; + } +if (r->base) { result =lv1_release_memory (r->base);BUG_ON (result);
@@ -287,6 +296,29 @@ static void ps3_mm_region_destroy(struct mem_region *r) } } +static int ps3_mm_get_repository_highmem (struct mem_region *r) +{ +int result =ps3_repository_read_highmem_info (&r->base, &r->size); + +if (result) + goto zero_region; + +if (!r->base || !r->size) { + result =-1 ; + goto zero_region; + } + + r->offset = r->base - map.rm.size; +DBG ("%s:%d got high region from repository: %llxh %llxh\n" , + __func__, __LINE__, r->base, r->size); +return 0 ; + +zero_region: +DBG ("%s:%d no high region in repository...\n" , __func__, __LINE__); + r->size = r->base = r->offset =0 ; +return result; +} +/** * ps3_mm_add_memory - hot add memory */
@@ -303,6 +335,12 @@ static int __init ps3_mm_add_memory(void)BUG_ON (!mem_init_done); +if (!map.r1.size) { +DBG ("%s:%d: no region 1, not adding memory\n" , + __func__, __LINE__); +return 0 ; + } + start_addr = map.rm.size; start_pfn = start_addr >>PAGE_SHIFT ; nr_pages = (map.r1.size +PAGE_SIZE -1 ) >>PAGE_SHIFT ;
@@ -1217,9 +1255,11 @@ void __init ps3_mm_init(void)BUG_ON (map.rm.base);BUG_ON (!map.rm.size); - -/* arrange to do this in ps3_mm_add_memory */ -ps3_mm_region_create (&map.r1, map.total - map.rm.size); +/* check if we got the highmem region from an earlier boot step */ +if (ps3_mm_get_repository_highmem (&map.r1)) { +/* arrange to do this in ps3_mm_add_memory */ +ps3_mm_region_create (&map.r1, map.total - map.rm.size); + }/* correct map.total for the real total amount of memory we use */ map.total = map.rm.size + map.r1.size;
Signature · 1 line
1.7.5.4
Geoff Levand
maintainerRe: [PATCH part1 v2 3/9] ps3: Get lv1 high memory region from the repository
Quoted 67 lines · Andre Heider
This lets the bootloader preallocate the high lv1 region and pass its location to the kernel through the repository. Thus, it can be used to hold the initrd. If the region info doesn't exist, the kernel retains the old behavior and attempts to allocate the region itself.
Based on the patch
"[PS3] Get lv1 high memory region from devtree"
from Hector Martin <[email protected]>Signed-off-by Andre Heider <[email protected]>--- arch/powerpc/platforms/ps3/mm.c | 46 ++++++++++++++++++++++++++++++++++++-- 1 files changed, 43 insertions(+), 3 deletions(-)arch/powerpc/platforms/ps3/mm.c +18
-0@@ -78,12 +78,14 @@ enum {* @base: base address * @size: size in bytes * @offset: difference between base and rm.size +* @destroy: flag if region should be destroyed upon shutdown */ struct mem_region {u64 base;u64 size;unsigned long offset; +int destroy; };/** @@ -261,6 +263,7 @@ static int ps3_mm_region_create(struct mem_region *r, unsigned long size) goto zero_region; } + r->destroy =1 ; r->offset = r->base - map.rm.size;return result;@@ -279,6 +282,12 @@ static void ps3_mm_region_destroy(struct mem_region *r)int result;DBG ("%s:%d: r->base = %llxh\n" , __func__, __LINE__, r->base); + +if (!r->destroy) { +DBG ("%s:%d: not destroying region\n" , __func__, __LINE__); +return ; + } +if (r->base) { result =lv1_release_memory (r->base);BUG_ON (result);@@ -287,6 +296,29 @@ static void ps3_mm_region_destroy(struct mem_region *r) } } +static int ps3_mm_get_repository_highmem (struct mem_region *r) +{ +int result =ps3_repository_read_highmem_info (&r->base, &r->size); + +if (result) + goto zero_region; + +if (!r->base || !r->size) { + result =-1 ;
arch/powerpc/platforms/ps3/mm.c static void ps3_mm_region_destroy(struct mem_region *r) · line 317
Quoted 10 lines
arch/powerpc/platforms/ps3/mm.c +10
-0+ goto zero_region; + } + + r->offset = r->base - map.rm.size; +DBG ("%s:%d got high region from repository: %llxh %llxh\n" , + __func__, __LINE__, r->base, r->size); +return 0 ; + +zero_region: +DBG ("%s:%d no high region in repository...\n" , __func__, __LINE__);
Three dots implies something more is on its way. I don't think we need them.
Quoted 35 lines
arch/powerpc/platforms/ps3/mm.c +15
-3+ r->size = r->base = r->offset =0 ; +return result; +} +/** * ps3_mm_add_memory - hot add memory */ @@ -303,6 +335,12 @@ static int __init ps3_mm_add_memory(void)BUG_ON (!mem_init_done); +if (!map.r1.size) { +DBG ("%s:%d: no region 1, not adding memory\n" , + __func__, __LINE__); +return 0 ; + } + start_addr = map.rm.size; start_pfn = start_addr >>PAGE_SHIFT ; nr_pages = (map.r1.size +PAGE_SIZE -1 ) >>PAGE_SHIFT ;@@ -1217,9 +1255,11 @@ void __init ps3_mm_init(void)BUG_ON (map.rm.base);BUG_ON (!map.rm.size); - -/* arrange to do this in ps3_mm_add_memory */ -ps3_mm_region_create (&map.r1, map.total - map.rm.size); +/* check if we got the highmem region from an earlier boot step */ +if (ps3_mm_get_repository_highmem (&map.r1)) { +/* arrange to do this in ps3_mm_add_memory */ +ps3_mm_region_create (&map.r1, map.total - map.rm.size); + }/* correct map.total for the real total amount of memory we use */ map.total = map.rm.size + map.r1.size;
PATCH v2 4/9 Add region 1 memory early
In reply to Andre HeiderFrom: Hector Martin <[email protected]>
Real mode memory can be limited and runs out quickly as memory is allocated during kernel startup.
Having region1 available sooner fixes this.
--- arch/powerpc/platforms/ps3/mm.c | 75 +++++++-------------------------------- 1 files changed, 13 insertions(+), 62 deletions(-)
arch/powerpc/platforms/ps3/mm.c +13 -62
@@ -20,7 +20,6 @@#include <linux/kernel.h> #include <linux/module.h> -#include <linux/memory_hotplug.h> #include <linux/memblock.h> #include <linux/slab.h>
@@ -94,10 +93,8 @@ struct mem_region {* @vas_id - HV virtual address space id * @htab_size: htab size in bytes * -* The HV virtual address space (vas) allows for hotplug memory regions. -* Memory regions can be created and destroyed in the vas at runtime. * @rm: real mode (bootmem) region -* @r1: hotplug memory region(s) +* @r1: high memory region * * ps3 addresses * virt_addr: a cpu 'translated' effective address
@@ -223,10 +220,6 @@ void ps3_mm_vas_destroy(void) } } -/*============================================================================*/ -/* memory hotplug routines */ -/*============================================================================*/ -/** * ps3_mm_region_create - create a memory region in the vas * @r: pointer to a struct mem_region to accept initialized values
@@ -319,57 +312,6 @@ zero_region:return result; } -/** -* ps3_mm_add_memory - hot add memory -*/ - -static int __init ps3_mm_add_memory (void ) -{ -int result; -unsigned long start_addr; -unsigned long start_pfn; -unsigned long nr_pages; - -if (!firmware_has_feature (FW_FEATURE_PS3_LV1 )) -return -ENODEV ; - -BUG_ON (!mem_init_done); - -if (!map.r1.size) { -DBG ("%s:%d: no region 1, not adding memory\n" , - __func__, __LINE__); -return 0 ; - } - - start_addr = map.rm.size; - start_pfn = start_addr >>PAGE_SHIFT ; - nr_pages = (map.r1.size +PAGE_SIZE -1 ) >>PAGE_SHIFT ; - -DBG ("%s:%d: start_addr %lxh, start_pfn %lxh, nr_pages %lxh\n" , - __func__, __LINE__, start_addr, start_pfn, nr_pages); - - result =add_memory (0 , start_addr, map.r1.size); - -if (result) { -pr_err ("%s:%d: add_memory failed: (%d)\n" , - __func__, __LINE__, result); -return result; - } - -memblock_add (start_addr, map.r1.size); -memblock_analyze (); - - result =online_pages (start_pfn, nr_pages); - -if (result) -pr_err ("%s:%d: online_pages failed: (%d)\n" , - __func__, __LINE__, result); - -return result; -} - -device_initcall (ps3_mm_add_memory); -/*============================================================================*/ /* dma routines */ /*============================================================================*/
@@ -1256,14 +1198,23 @@ void __init ps3_mm_init(void)BUG_ON (!map.rm.size);/* check if we got the highmem region from an earlier boot step */ -if (ps3_mm_get_repository_highmem (&map.r1)) { -/* arrange to do this in ps3_mm_add_memory */ +if (ps3_mm_get_repository_highmem (&map.r1))ps3_mm_region_create (&map.r1, map.total - map.rm.size); - }/* correct map.total for the real total amount of memory we use */ map.total = map.rm.size + map.r1.size; +if (!map.r1.size) { +DBG ("%s:%d: no region 1, not adding memory\n" , + __func__, __LINE__); + }else { +DBG ("%s:%d: adding memory: start %llxh, size %llxh\n" , + __func__, __LINE__, map.rm.size, map.r1.size); + +memblock_add (map.rm.size, map.r1.size); +memblock_analyze (); + } +DBG (" <- %s:%d\n" , __func__, __LINE__); }
Signature · 1 line
1.7.5.4
Geoff Levand
maintainerRe: [PATCH part1 v2 4/9] Add region 1 memory early
Quoted 26 lines · Andre Heider
From: Hector Martin <[email protected]>
Real mode memory can be limited and runs out quickly as memory is allocated during kernel startup.
Having region1 available sooner fixes this.Signed-off-by Hector Martin <[email protected]>[a.heider: Various cleanups to make checkpatch.pl happy]Signed-off-by Andre Heider <[email protected]>--- arch/powerpc/platforms/ps3/mm.c | 75 +++++++-------------------------------- 1 files changed, 13 insertions(+), 62 deletions(-)arch/powerpc/platforms/ps3/mm.c +0
-1@@ -20,7 +20,6 @@#include <linux/kernel.h> #include <linux/module.h> -#include <linux/memory_hotplug.h> #include <linux/memblock.h> #include <linux/slab.h>
arch/powerpc/platforms/ps3/mm.c struct mem_region { · line 98
Quoted 5 lines
arch/powerpc/platforms/ps3/mm.c +0
-2@@ -94,10 +93,8 @@ struct mem_region {* @vas_id - HV virtual address space id * @htab_size: htab size in bytes * -* The HV virtual address space (vas) allows for hotplug memory regions. -* Memory regions can be created and destroyed in the vas at runtime.
This is still true, so we should keep these comments. We are only changing the way we use the feature.
arch/powerpc/platforms/ps3/mm.c struct mem_region { · line 97
Quoted 3 lines
arch/powerpc/platforms/ps3/mm.c +1
-1* @rm: real mode (bootmem) region -* @r1: hotplug memory region(s) +* @r1: high memory region
high memory region(s)
Quoted 73 lines
arch/powerpc/platforms/ps3/mm.c +0
-55* * ps3 addresses * virt_addr: a cpu 'translated' effective address @@ -223,10 +220,6 @@ void ps3_mm_vas_destroy(void) } } -/*============================================================================*/ -/* memory hotplug routines */ -/*============================================================================*/ -/** * ps3_mm_region_create - create a memory region in the vas * @r: pointer to a struct mem_region to accept initialized values @@ -319,57 +312,6 @@ zero_region:return result; } -/** -* ps3_mm_add_memory - hot add memory -*/ - -static int __init ps3_mm_add_memory (void ) -{ -int result; -unsigned long start_addr; -unsigned long start_pfn; -unsigned long nr_pages; - -if (!firmware_has_feature (FW_FEATURE_PS3_LV1 )) -return -ENODEV ; - -BUG_ON (!mem_init_done); - -if (!map.r1.size) { -DBG ("%s:%d: no region 1, not adding memory\n" , - __func__, __LINE__); -return 0 ; - } - - start_addr = map.rm.size; - start_pfn = start_addr >>PAGE_SHIFT ; - nr_pages = (map.r1.size +PAGE_SIZE -1 ) >>PAGE_SHIFT ; - -DBG ("%s:%d: start_addr %lxh, start_pfn %lxh, nr_pages %lxh\n" , - __func__, __LINE__, start_addr, start_pfn, nr_pages); - - result =add_memory (0 , start_addr, map.r1.size); - -if (result) { -pr_err ("%s:%d: add_memory failed: (%d)\n" , - __func__, __LINE__, result); -return result; - } - -memblock_add (start_addr, map.r1.size); -memblock_analyze (); - - result =online_pages (start_pfn, nr_pages); - -if (result) -pr_err ("%s:%d: online_pages failed: (%d)\n" , - __func__, __LINE__, result); - -return result; -} - -device_initcall (ps3_mm_add_memory); -/*============================================================================*/ /* dma routines */ /*============================================================================*/
arch/powerpc/platforms/ps3/mm.c void __init ps3_mm_init(void) · line 1262
Quoted 8 lines
arch/powerpc/platforms/ps3/mm.c +1
-3@@ -1256,14 +1198,23 @@ void __init ps3_mm_init(void)BUG_ON (!map.rm.size);/* check if we got the highmem region from an earlier boot step */ -if (ps3_mm_get_repository_highmem (&map.r1)) { -/* arrange to do this in ps3_mm_add_memory */ +if (ps3_mm_get_repository_highmem (&map.r1))ps3_mm_region_create (&map.r1, map.total - map.rm.size); - }
This should be folded into patch #3.
arch/powerpc/platforms/ps3/mm.c void __init ps3_mm_init(void) · line 1210
Quoted 8 lines
arch/powerpc/platforms/ps3/mm.c +4
-0/* correct map.total for the real total amount of memory we use */ map.total = map.rm.size + map.r1.size; +if (!map.r1.size) { +DBG ("%s:%d: no region 1, not adding memory\n" , + __func__, __LINE__); + }else {
Remove brackets around a single line conditional.
Quoted 10 lines
arch/powerpc/platforms/ps3/mm.c +7
-0+DBG ("%s:%d: adding memory: start %llxh, size %llxh\n" , + __func__, __LINE__, map.rm.size, map.r1.size); + +memblock_add (map.rm.size, map.r1.size); +memblock_analyze (); + } +DBG (" <- %s:%d\n" , __func__, __LINE__); }
Re: [Cbe-oss-dev] [PATCH part1 v2 4/9] Add region 1 memory early
On Tue, 23 Aug 2011 13:53:46 -0700
Geoff Levand <[email protected]> wrote:
[...]
Quoted 8 lines
arch/powerpc/platforms/ps3/mm.c void __init ps3_mm_init(void) · line 1210
Quoted 5 lines
arch/powerpc/platforms/ps3/mm.c +4
-0+if (!map.r1.size) { +DBG ("%s:%d: no region 1, not adding memory\n" , + __func__, __LINE__); + }else {Remove brackets around a single line conditional.
Quoted 7 lines
arch/powerpc/platforms/ps3/mm.c void __init ps3_mm_init(void) · line 1217
Quoted 7 lines
arch/powerpc/platforms/ps3/mm.c +7
-0+DBG ("%s:%d: adding memory: start %llxh, size %llxh\n" , + __func__, __LINE__, map.rm.size, map.r1.size); + +memblock_add (map.rm.size, map.r1.size); +memblock_analyze (); + } +
In Documentation/CodingStyle I read that if [only] one branch is a single statement then the parenthesis are OK (and even recommended) for both branches, I guess this is for style consistency. See Chapter 3, around line 169 on my copy. I guess the wording on that paragraph can be made more explicit, I'll try to fix that up.
Regards,
Antonio
Signature · 8 lines
Antonio Ospite http://ao2.it PGP public key ID: 0x4553B001 A: Because it messes up the order in which people normally read text. See http://en.wikipedia.org/wiki/Posting_style Q: Why is top-posting such a bad thing?
Geoff Levand
maintainerRe: [Cbe-oss-dev] [PATCH part1 v2 4/9] Add region 1 memory early
Hi Antonio,
Quoted 8 lines · Antonio Ospite
Quoted 7 lines · Geoff Levand
arch/powerpc/platforms/ps3/mm.c void __init ps3_mm_init(void) · line 1210
Quoted 4 lines
arch/powerpc/platforms/ps3/mm.c +4
-0+if (!map.r1.size) { +DBG ("%s:%d: no region 1, not adding memory\n" , + __func__, __LINE__); + }else {Remove brackets around a single line conditional.
Quoted 13 lines
Quoted 7 lines
arch/powerpc/platforms/ps3/mm.c void __init ps3_mm_init(void) · line 1217
Quoted 7 lines
arch/powerpc/platforms/ps3/mm.c +7
-0+DBG ("%s:%d: adding memory: start %llxh, size %llxh\n" , + __func__, __LINE__, map.rm.size, map.r1.size); + +memblock_add (map.rm.size, map.r1.size); +memblock_analyze (); + } +In
Documentation/CodingStyleI read that if [only] one branch is a single statement then the parenthesis are OK (and even recommended) for both branches, I guess this is for style consistency. See Chapter 3, around line 169 on my copy. I guess the wording on that paragraph can be made more explicit, I'll try to fix that up.
Thanks for the comments. I don't think its such an important change, mainly for consistency of style within the PS3 files.
-Geoff
PATCH v2 5/9 ps3: MEMORY_HOTPLUG is not a requirement anymore
In reply to Andre Heider--- arch/powerpc/platforms/ps3/Kconfig | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
arch/powerpc/platforms/ps3/Kconfig +0 -1
@@ -7,7 +7,6 @@ config PPC_PS3 select USB_OHCI_BIG_ENDIAN_MMIO select USB_ARCH_HAS_EHCI select USB_EHCI_BIG_ENDIAN_MMIO - select MEMORY_HOTPLUG select PPC_PCI_CHOICE help This option enables support for the Sony PS3 game console
Signature · 1 line
1.7.5.4
Geoff Levand
maintainerRe: [PATCH part1 v2 5/9] ps3: MEMORY_HOTPLUG is not a requirement anymore
Quoted 10 lines · Andre Heider
Signed-off-by Andre Heider <[email protected]>--- arch/powerpc/platforms/ps3/Kconfig | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)arch/powerpc/platforms/ps3/Kconfig +0
-0
arch/powerpc/platforms/ps3/Kconfig config PPC_PS3 · line 10
Quoted 4 lines
arch/powerpc/platforms/ps3/Kconfig +0
-1@@ -7,7 +7,6 @@ config PPC_PS3 select USB_OHCI_BIG_ENDIAN_MMIO select USB_ARCH_HAS_EHCI select USB_EHCI_BIG_ENDIAN_MMIO - select MEMORY_HOTPLUG
This one is OK, once the others are fixed up.
-Geoff
PATCH v2 6/9 ps3: Detect the current lpar
In reply to Andre HeiderDetect it by reading the ss laid repository node, and make it accessible via ps3_get_ss_laid().
--- arch/powerpc/include/asm/ps3.h | 6 ++++++ arch/powerpc/platforms/ps3/platform.h | 4 ++++ arch/powerpc/platforms/ps3/repository.c | 19 +++++++++++++++++++ arch/powerpc/platforms/ps3/setup.c | 9 +++++++++ 4 files changed, 38 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/ps3.h +6 -0
@@ -39,6 +39,12 @@ union ps3_firmware_version {void ps3_get_firmware_version (union ps3_firmware_version *v);int ps3_compare_firmware_version (u16 major,u16 minor,u16 rev); +enum ps3_ss_laid { +PS3_SS_LAID_OTHEROS =0x1080000004000001UL , +}; + +enum ps3_ss_laid ps3_get_ss_laid (void ); +/* 'Other OS' area */ enum ps3_param_av_multi_out {
arch/powerpc/platforms/ps3/platform.h +4 -0
@@ -235,4 +235,8 @@ int ps3_repository_read_spu_resource_id(unsigned int res_index,int ps3_repository_read_vuart_av_port (unsigned int *port);int ps3_repository_read_vuart_sysmgr_port (unsigned int *port); +/* repository ss info */ + +int ps3_repository_read_ss_laid (enum ps3_ss_laid *laid); +#endif
arch/powerpc/platforms/ps3/repository.c +19 -0
@@ -1038,6 +1038,25 @@ int ps3_repository_read_lpm_privileges(unsigned int be_index, u64 *lpar, lpar, rights); } +/** +* ps3_repository_read_ss_laid - Read the lpar auth id +*/ + +int ps3_repository_read_ss_laid (enum ps3_ss_laid *laid) +{ +int result; +u64 id, v1; + +lv1_get_logical_partition_id (&id); + result =read_node (PS3_LPAR_ID_PME , +make_first_field ("ss" ,0 ), +make_field ("laid" ,0 ), + id,0 , + &v1,NULL ); + *laid = v1; +return result; +} +#if defined(DEBUG )int ps3_repository_dump_resource_info (const struct ps3_repository_device *repo)
arch/powerpc/platforms/ps3/setup.c +9 -0
@@ -47,6 +47,7 @@ DEFINE_MUTEX(ps3_gpu_mutex);EXPORT_SYMBOL_GPL (ps3_gpu_mutex);static union ps3_firmware_version ps3_firmware_version; +static enum ps3_ss_laid ps3_ss_laid;void ps3_get_firmware_version (union ps3_firmware_version *v) {
@@ -68,6 +69,12 @@ int ps3_compare_firmware_version(u16 major, u16 minor, u16 rev) }EXPORT_SYMBOL_GPL (ps3_compare_firmware_version); +enum ps3_ss_laid ps3_get_ss_laid (void ) +{ +return ps3_ss_laid; +} +EXPORT_SYMBOL_GPL (ps3_get_ss_laid); +static void ps3_power_save (void ) {/*
@@ -200,6 +207,8 @@ static void __init ps3_setup_arch(void) ps3_firmware_version.major, ps3_firmware_version.minor, ps3_firmware_version.rev); +ps3_repository_read_ss_laid (&ps3_ss_laid); +ps3_spu_set_platform ();#ifdef CONFIG_SMP
Signature · 1 line
1.7.5.4
Geoff Levand
maintainerRe: [PATCH part1 v2 6/9] ps3: Detect the current lpar
Hi,
Quoted 2 lines · Andre Heider
Detect it by reading the ss laid repository node, and make it accessible via
ps3_get_ss_laid().
I'm wondering now if we even need this. It is mainly used by your later patch 8/9 that modifies ps3flash_init() to test if we should call ps3_system_bus_driver_register(). If we don't use ps3_get_ss_laid() and just allow ps3_system_bus_driver_register() to be called, would the device probe fail and have the same result as the test?
I would prefer to not have ps3_get_ss_laid() if possible.
-Geoff
PATCH v2 7/9 ps3: Log the detected lpar on startup
In reply to Andre HeiderAdd PS3_SS_LAID_GAMEOS to enum ps3_ss_laid.
--- arch/powerpc/include/asm/ps3.h | 1 + arch/powerpc/platforms/ps3/setup.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/ps3.h +1 -0
@@ -40,6 +40,7 @@ void ps3_get_firmware_version(union ps3_firmware_version *v);int ps3_compare_firmware_version (u16 major,u16 minor,u16 rev);enum ps3_ss_laid { +PS3_SS_LAID_GAMEOS =0x1070000002000001UL ,PS3_SS_LAID_OTHEROS =0x1080000004000001UL , };
arch/powerpc/platforms/ps3/setup.c +13 -0
@@ -199,6 +199,7 @@ static int ps3_set_dabr(unsigned long dabr)static void __init ps3_setup_arch (void ) { +const char *laid_str;DBG (" -> %s:%d\n" , __func__, __LINE__);
@@ -208,6 +209,18 @@ static void __init ps3_setup_arch(void) ps3_firmware_version.rev);ps3_repository_read_ss_laid (&ps3_ss_laid); +switch (ps3_ss_laid) { +case PS3_SS_LAID_GAMEOS : + laid_str ="GameOS" ; +break ; +case PS3_SS_LAID_OTHEROS : + laid_str ="OtherOS" ; +break ; +default : + laid_str ="unknown" ; +break ; + } +printk (KERN_INFO "Running in %s LPAR\n" , laid_str);ps3_spu_set_platform ();
Signature · 1 line
1.7.5.4
PATCH v2 8/9 ps3flash: Refuse to work in lpars other than OtherOS
In reply to Andre HeiderThe driver implements a character and misc device, meant for the axed OtherOS to exchange various settings with GameOS. Since Firmware 3.21 there is no support anymore to write these settings, so test if we're running in OtherOS, and refuse to load if that is not the case.
--- arch/powerpc/platforms/ps3/Kconfig | 2 +- drivers/char/ps3flash.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletions(-)
arch/powerpc/platforms/ps3/Kconfig +1 -1
@@ -121,7 +121,7 @@ config PS3_FLASH This support is required to access the PS3 FLASH ROM, which contains the boot loader and some boot options. - In general, all users will say Y or M. + In general, all PS3 OtherOS users will say Y or M. As this driver needs a fixed buffer of 256 KiB of memory, it can be disabled on the kernel command line using "ps3flash=off", to
drivers/char/ps3flash.c +7 -0
@@ -25,6 +25,7 @@#include <asm/lv1call.h> #include <asm/ps3stor.h> +#include <asm/firmware.h> #define DEVICE_NAME "ps3flash"
@@ -464,6 +465,12 @@ static struct ps3_system_bus_driver ps3flash = {static int __init ps3flash_init (void ) { +if (!firmware_has_feature (FW_FEATURE_PS3_LV1 )) +return -ENODEV ; + +if (ps3_get_ss_laid () !=PS3_SS_LAID_OTHEROS ) +return -ENODEV ; +return ps3_system_bus_driver_register (&ps3flash); }
Signature · 1 line
1.7.5.4
Geoff Levand
maintainerRe: [PATCH part1 v2 8/9] ps3flash: Refuse to work in lpars other than OtherOS
Quoted 5 lines · Andre Heider
The driver implements a character and misc device, meant for the axed OtherOS to exchange various settings with GameOS. Since Firmware 3.21 there is no support anymore to write these settings, so test if we're running in OtherOS, and refuse to load if that is not the case.
Please see my comments to the v1 patch regarding this text.
Quoted 44 lines
Signed-off-by Andre Heider <[email protected]>--- arch/powerpc/platforms/ps3/Kconfig | 2 +- drivers/char/ps3flash.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletions(-)arch/powerpc/platforms/ps3/Kconfig +1
-1@@ -121,7 +121,7 @@ config PS3_FLASH This support is required to access the PS3 FLASH ROM, which contains the boot loader and some boot options. - In general, all users will say Y or M. + In general, all PS3 OtherOS users will say Y or M. As this driver needs a fixed buffer of 256 KiB of memory, it can be disabled on the kernel command line using "ps3flash=off", todrivers/char/ps3flash.c +7
-0@@ -25,6 +25,7 @@#include <asm/lv1call.h> #include <asm/ps3stor.h> +#include <asm/firmware.h> #define DEVICE_NAME "ps3flash"@@ -464,6 +465,12 @@ static struct ps3_system_bus_driver ps3flash = {static int __init ps3flash_init (void ) { +if (!firmware_has_feature (FW_FEATURE_PS3_LV1 )) +return -ENODEV ; + +if (ps3_get_ss_laid () !=PS3_SS_LAID_OTHEROS ) +return -ENODEV ; +return ps3_system_bus_driver_register (&ps3flash); }
PATCH v2 9/9 ps3: Only prealloc the flash bounce buffer for the OtherOS lpar
In reply to Andre HeiderIt's only used by the ps3flash driver, which only supports the OtherOS lpar.
--- arch/powerpc/platforms/ps3/setup.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
arch/powerpc/platforms/ps3/setup.c +4 -1
@@ -233,7 +233,10 @@ static void __init ps3_setup_arch(void)#endif prealloc_ps3fb_videomemory (); -prealloc_ps3flash_bounce_buffer (); + +/* the ps3flash driver only works for OtherOS */ +if (ps3_get_ss_laid () ==PS3_SS_LAID_OTHEROS ) +prealloc_ps3flash_bounce_buffer (); ppc_md.power_save = ps3_power_save;ps3_os_area_init ();
Signature · 1 line
1.7.5.4
Re: [PATCH part1 v2 0/9] ps3: General improvements and preparation for support more than the OtherOS lpar
In reply to Andre HeiderQuoted 5 lines · Andre Heider
This is the first part of my previous series including the discussed fixups.
I dropped the old #2 ([PS3] Get lv1 high memory region from devtree) and replaced it with 2 new patches, now #2 and #3. The latter contains the fixups mentioned on the old #2 thread.
Just back from vacation. I like these, good stuff. I'd like to have that in soon, can you address the remaining minor comments from Geoff ?
Cheers,
Ben.
Quoted 32 lines
Patches are based on today's Linus' tree.
Andre Heider (7):
ps3: Add helper functions to read highmem info from the repository
ps3: Get lv1 high memory region from the repository
ps3:MEMORY_HOTPLUGis not a requirement anymore
ps3: Detect the current lpar
ps3: Log the detected lpar on startup
ps3flash: Refuse to work in lpars other than OtherOS
ps3: Only prealloc the flash bounce buffer for the OtherOS lparHector Martin (2):
Add udbg driver using the PS3 gelic Ethernet device Add region 1 memory earlyarch/powerpc/Kconfig.debug | 8 + arch/powerpc/include/asm/ps3.h | 7 + arch/powerpc/include/asm/udbg.h | 1 + arch/powerpc/kernel/udbg.c | 2 + arch/powerpc/platforms/ps3/Kconfig | 15 ++- arch/powerpc/platforms/ps3/Makefile | 1 + arch/powerpc/platforms/ps3/gelic_udbg.c | 273 +++++++++++++++++++++++++++++++ arch/powerpc/platforms/ps3/mm.c | 85 +++++------ arch/powerpc/platforms/ps3/platform.h | 7 + arch/powerpc/platforms/ps3/repository.c | 55 ++++++ arch/powerpc/platforms/ps3/setup.c | 27 +++- drivers/char/ps3flash.c | 7 + drivers/net/ps3_gelic_net.c | 3 + drivers/net/ps3_gelic_net.h | 6 + 14 files changed, 447 insertions(+), 50 deletions(-) create mode 100644 arch/powerpc/platforms/ps3/gelic_udbg.c