powerpc/ps3: Add modalias support to the ps3vram driver
Subsystems (3)
PATCH 2/6 powerpc/ps3: Add modalias support to the ps3vram driver
In reply to a message not in the archiveFrom: Geert Uytterhoeven <[email protected]>
Update ps3vram driver to use the new ps3 three id modalias support.
--- arch/powerpc/include/asm/ps3.h | 1 + drivers/mtd/devices/ps3vram.c | 1 + 2 files changed, 2 insertions(+)
arch/powerpc/include/asm/ps3.h +1 -0
@@ -333,6 +333,7 @@ enum ps3_match_sub_id {#define PS3_MODULE_ALIAS_STOR_FLASH "ps3:8:0"#define PS3_MODULE_ALIAS_SOUND "ps3:9:0"#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"enum ps3_system_bus_device_type {
drivers/mtd/devices/ps3vram.c +1 -0
@@ -774,3 +774,4 @@ module_exit(ps3vram_exit);MODULE_LICENSE ("GPL" );MODULE_AUTHOR ("Jim Paris <[email protected]>" );MODULE_DESCRIPTION ("MTD driver for PS3 video RAM" ); +MODULE_ALIAS (PS3_MODULE_ALIAS_GPU_RAMDISK );
PATCH 1/6 powerpc/ps3: ps3vram driver for accessing video RAM as MTD
In reply to a message not in the archiveFrom: Jim Paris <[email protected]>
Add ps3vram driver, which exposes unused video RAM on the PS3 as a MTD device suitable for storage or swap. Fast data transfer is achieved using a local cache in system RAM and DMA transfers via the GPU.
---
v1: This version has been updated to work with PS3 firmware 2.50, and
to use ps3_gpu_mutex.
v2: Updated to use new ps3 match ids.
v3: Change MB to MiB.
MAINTAINERS | 6 arch/powerpc/include/asm/ps3.h | 1 arch/powerpc/platforms/ps3/device-init.c | 37 + drivers/mtd/devices/Kconfig | 7 drivers/mtd/devices/Makefile | 1 drivers/mtd/devices/ps3vram.c | 776 +++++++++++++++++++++++++++++++ 6 files changed, 828 insertions(+) create mode 100644 drivers/mtd/devices/ps3vram.c
MAINTAINERS +6 -0
@@ -3470,6 +3470,12 @@ L: [email protected] L: [email protected] S: Supported +PS3VRAM DRIVER +P: Jim Paris +M: [email protected] +L: [email protected] +S: Maintained + PVRUSB2 VIDEO4LINUX DRIVER P: Mike Isely M: [email protected]
arch/powerpc/include/asm/ps3.h +1 -0
@@ -320,6 +320,7 @@ enum ps3_match_id {enum ps3_match_sub_id {PS3_MATCH_SUB_ID_GPU_FB =1 , +PS3_MATCH_SUB_ID_GPU_RAMDISK =2 , };#define PS3_MODULE_ALIAS_EHCI "ps3:1:0"
arch/powerpc/platforms/ps3/device-init.c +37 -0
@@ -518,6 +518,41 @@ fail_device_register:return result; } +static int __init ps3_register_ramdisk_device (void ) +{ +int result; +struct layout { +struct ps3_system_bus_device dev; + } *p; + +pr_debug (" -> %s:%d\n" , __func__, __LINE__); + + p =kzalloc (sizeof (struct layout ),GFP_KERNEL ); + +if (!p) +return -ENOMEM ; + + p->dev.match_id =PS3_MATCH_ID_GPU ; + p->dev.match_sub_id =PS3_MATCH_SUB_ID_GPU_RAMDISK ; + p->dev.dev_type =PS3_DEVICE_TYPE_IOC0 ; + + result =ps3_system_bus_device_register (&p->dev); + +if (result) { +pr_debug ("%s:%d ps3_system_bus_device_register failed\n" , + __func__, __LINE__); + goto fail_device_register; + } + +pr_debug (" <- %s:%d\n" , __func__, __LINE__); +return 0 ; + +fail_device_register: +kfree (p); +pr_debug (" <- %s:%d failed\n" , __func__, __LINE__); +return result; +} +/** * ps3_setup_dynamic_device - Setup a dynamic device from the repository */
@@ -946,6 +981,8 @@ static int __init ps3_register_devices(vps3_register_lpm_devices (); +ps3_register_ramdisk_device (); +pr_debug (" <- %s:%d\n" , __func__, __LINE__);return 0 ; }
drivers/mtd/devices/Kconfig +7 -0
@@ -120,6 +120,13 @@ config MTD_PHRAM doesn't have access to, memory beyond the mem=xxx limit, nvram, memory on the video card, etc... +config MTD_PS3VRAM + tristate "PS3 video RAM" + depends on FB_PS3 + help + This driver allows you to use excess PS3 video RAM as volatile + storage or system swap. + config MTD_LART tristate "28F160xx flash driver for LART" depends on SA1100_LART
drivers/mtd/devices/Makefile +1 -0
@@ -16,3 +16,4 @@ obj-$(CONFIG_MTD_LART) += lart.o obj-$(CONFIG_MTD_BLOCK2MTD) += block2mtd.o obj-$(CONFIG_MTD_DATAFLASH) += mtd_dataflash.o obj-$(CONFIG_MTD_M25P80) += m25p80.o +obj-$(CONFIG_MTD_PS3VRAM) += ps3vram.o
drivers/mtd/devices/ps3vram.c new file +776 -0
776 lines not on this page · raw message
PATCH 3/6 mtd/ps3vram: Remove ps3vram debug routines
In reply to a message not in the archiveRemove the ps3vram debug routines ps3vram_dump_ring() and ps3vram_dump_reports(). These routines are not needed.
--- drivers/mtd/devices/ps3vram.c | 29 ----------------------------- 1 file changed, 29 deletions(-)
drivers/mtd/devices/ps3vram.c +0 -29
@@ -87,9 +87,6 @@ struct ps3vram_priv {#define DMA_NOTIFIER_HANDLE_BASE 0x66604200/* first DMA notifier handle */ #define DMA_NOTIFIER_OFFSET_BASE 0x1000/* first DMA notifier offset */ #define DMA_NOTIFIER_SIZE 0x40 - -#define NUM_NOTIFIERS 16 -#define NOTIFIER 7/* notifier used for completion report */ /* A trailing '-' means to subtract off ps3fb_videomemory.size */
@@ -131,28 +128,6 @@ static int ps3vram_notifier_wait(structreturn -1 ; } -static void ps3vram_dump_ring (struct mtd_info *mtd) -{ -struct ps3vram_priv *priv = mtd->priv; -uint32_t *fifo; - -pr_info ("PUT = %08x GET = %08x\n" , priv->ctrl[CTRL_PUT ], - priv->ctrl[CTRL_GET ]); -for (fifo = priv->fifo_base; fifo < priv->fifo_ptr; fifo++) -pr_info ("%p: %08x\n" , fifo, *fifo); -} - -static void ps3vram_dump_reports (struct mtd_info *mtd) -{ -struct ps3vram_priv *priv = mtd->priv; -int i; - -for (i =0 ; i <NUM_NOTIFIERS ; i++) { -uint32_t *n =ps3vram_get_notifier (priv->reports, i); -pr_info ("%p: %08x\n" , n, *n); - } -} -static void ps3vram_init_ring (struct mtd_info *mtd) {struct ps3vram_priv *priv = mtd->priv;
@@ -284,8 +259,6 @@ static int ps3vram_upload(struct mtd_infps3vram_fire_ring (mtd);if (ps3vram_notifier_wait (mtd,200 ) <0 ) {pr_err ("notifier timeout\n" ); -ps3vram_dump_ring (mtd); -ps3vram_dump_reports (mtd);return -1 ; }
@@ -317,8 +290,6 @@ static int ps3vram_download(struct mtd_ips3vram_fire_ring (mtd);if (ps3vram_notifier_wait (mtd,200 ) <0 ) {pr_err ("notifier timeout\n" ); -ps3vram_dump_ring (mtd); -ps3vram_dump_reports (mtd);return -1 ; }
PATCH 4/6 mtd/ps3vram: Cleanup ps3vram driver messages
In reply to a message not in the archiveCleanup the ps3vram driver messages. Add a new struct device pointer variable dev to struct ps3vram_priv and use dev_dbg(), pr_dbg(), etc. where appropriate.
--- drivers/mtd/devices/ps3vram.c | 116 ++++++++++++++++++++++++------------------ 1 file changed, 68 insertions(+), 48 deletions(-)
drivers/mtd/devices/ps3vram.c +68 -48
@@ -53,9 +53,6 @@ struct mtd_info ps3vram_mtd;#define CACHE_PAGE_PRESENT 1#define CACHE_PAGE_DIRTY 2 -#define dbg(fmt, args...) \ - pr_debug("%s:%d " fmt "\n", __func__, __LINE__, ## args) -struct ps3vram_tag {unsigned int address;unsigned int flags;
@@ -78,6 +75,7 @@ struct ps3vram_priv {uint32_t *fifo_base;uint32_t *fifo_ptr; +struct device *dev;struct ps3vram_cache cache;/* Used to serialize cache/DMA operations */
@@ -148,8 +146,9 @@ static int ps3vram_wait_ring(struct mtd_udelay (1 ); }if (timeout ==0 ) { -pr_err ("FIFO timeout (%08x/%08x/%08x)\n" , priv->ctrl[CTRL_PUT ], - priv->ctrl[CTRL_GET ], priv->ctrl[CTRL_TOP ]); +dev_dbg (priv->dev,"%s:%d: FIFO timeout (%08x/%08x/%08x)\n" , + __func__, __LINE__, priv->ctrl[CTRL_PUT ], + priv->ctrl[CTRL_GET ], priv->ctrl[CTRL_TOP ]);return -ETIMEDOUT ; }
@@ -181,7 +180,8 @@ static void ps3vram_rewind_ring(struct mL1GPU_CONTEXT_ATTRIBUTE_FB_BLIT , 0, 0, 0, 0);if (status) -pr_err ("ps3vram: lv1_gpu_context_attribute FB_BLIT failed\n" ); +dev_err (priv->dev,"%s:%d: lv1_gpu_context_attribute failed\n" , + __func__, __LINE__); priv->fifo_ptr = priv->fifo_base; }
@@ -201,11 +201,13 @@ static void ps3vram_fire_ring(struct mtdL1GPU_CONTEXT_ATTRIBUTE_FB_BLIT , 0, 0, 0, 0);if (status) -pr_err ("ps3vram: lv1_gpu_context_attribute FB_BLIT failed\n" ); +dev_err (priv->dev,"%s:%d: lv1_gpu_context_attribute failed\n" , + __func__, __LINE__);if ((priv->fifo_ptr - priv->fifo_base) *sizeof (uint32_t ) >FIFO_SIZE -1024 ) { -dbg ("fifo full, rewinding" ); +dev_dbg (priv->dev,"%s:%d: fifo full, rewinding\n" , __func__, + __LINE__);ps3vram_wait_ring (mtd,200 );ps3vram_rewind_ring (mtd); }
@@ -258,7 +260,8 @@ static int ps3vram_upload(struct mtd_infps3vram_out_ring (priv,0 );ps3vram_fire_ring (mtd);if (ps3vram_notifier_wait (mtd,200 ) <0 ) { -pr_err ("notifier timeout\n" ); +dev_dbg (priv->dev,"%s:%d: notifier timeout\n" , __func__, + __LINE__);return -1 ; }
@@ -289,7 +292,8 @@ static int ps3vram_download(struct mtd_ips3vram_out_ring (priv,0 );ps3vram_fire_ring (mtd);if (ps3vram_notifier_wait (mtd,200 ) <0 ) { -pr_err ("notifier timeout\n" ); +dev_dbg (priv->dev,"%s:%d: notifier timeout\n" , __func__, + __LINE__);return -1 ; }
@@ -302,16 +306,17 @@ static void ps3vram_cache_evict(struct mstruct ps3vram_cache *cache = &priv->cache;if (cache->tags[entry].flags &CACHE_PAGE_DIRTY ) { -dbg ("flushing %d : 0x%08x" , entry, cache->tags[entry].address); +dev_dbg (priv->dev,"%s:%d: flushing %d : 0x%08x\n" , __func__, + __LINE__, entry, cache->tags[entry].address);if (ps3vram_upload (mtd,CACHE_OFFSET + entry * cache->page_size, cache->tags[entry].address,DMA_PAGE_SIZE , cache->page_size /DMA_PAGE_SIZE ) <0 ) { -pr_err ("failed to upload from 0x%x to 0x%x size 0x%x\n" , - entry * cache->page_size, - cache->tags[entry].address, - cache->page_size); +dev_dbg (priv->dev,"%s:%d: failed to upload from " +"0x%x to 0x%x size 0x%x\n" , __func__, __LINE__, + entry * cache->page_size, + cache->tags[entry].address, cache->page_size); } cache->tags[entry].flags &= ~CACHE_PAGE_DIRTY ; }
@@ -323,16 +328,16 @@ static void ps3vram_cache_load(struct mtstruct ps3vram_priv *priv = mtd->priv;struct ps3vram_cache *cache = &priv->cache; -dbg ("fetching %d : 0x%08x" , entry, address); +dev_dbg (priv->dev,"%s:%d: fetching %d : 0x%08x\n" , __func__, __LINE__, + entry, address);if (ps3vram_download (mtd, address,CACHE_OFFSET + entry * cache->page_size,DMA_PAGE_SIZE , cache->page_size /DMA_PAGE_SIZE ) <0 ) { -pr_err ("failed to download from 0x%x to 0x%x size 0x%x\n" , - address, - entry * cache->page_size, - cache->page_size); +dev_err (priv->dev,"%s:%d: failed to download from " +"0x%x to 0x%x size 0x%x\n" , __func__, __LINE__, address, + entry * cache->page_size, cache->page_size); } cache->tags[entry].address = address;
@@ -346,7 +351,7 @@ static void ps3vram_cache_flush(struct mstruct ps3vram_cache *cache = &priv->cache;int i; -dbg ("FLUSH" ); +dev_dbg (priv->dev,"%s:%d: FLUSH\n" , __func__, __LINE__);for (i =0 ; i < cache->page_count; i++) {ps3vram_cache_evict (mtd, i); cache->tags[i].flags =0 ;
@@ -369,15 +374,15 @@ static unsigned int ps3vram_cache_match(for (i =0 ; i < cache->page_count; i++) {if ((cache->tags[i].flags &CACHE_PAGE_PRESENT ) && cache->tags[i].address == base) { -dbg ("found entry %d : 0x%08x" , - i, cache->tags[i].address); +dev_dbg (priv->dev,"%s:%d: found entry %d : 0x%08x\n" , + __func__, __LINE__, i, cache->tags[i].address);return i; } }/* choose a random entry */ i = (jiffies + (counter++)) % cache->page_count; -dbg ("using cache entry %d" , i); +dev_dbg (priv->dev,"%s:%d: using entry %d\n" , __func__, __LINE__, i);ps3vram_cache_evict (mtd, i);ps3vram_cache_load (mtd, i, base);
@@ -389,18 +394,19 @@ static int ps3vram_cache_init(struct mtd {struct ps3vram_priv *priv = mtd->priv; -pr_info ("creating cache: %d entries, %d bytes pages\n" , -CACHE_PAGE_COUNT ,CACHE_PAGE_SIZE ); - priv->cache.page_count =CACHE_PAGE_COUNT ; priv->cache.page_size =CACHE_PAGE_SIZE ; priv->cache.tags =kzalloc (sizeof (struct ps3vram_tag ) *CACHE_PAGE_COUNT ,GFP_KERNEL );if (priv->cache.tags ==NULL ) { -pr_err ("could not allocate cache tags\n" ); +dev_err (priv->dev,"%s:%d: could not allocate cache tags\n" , + __func__, __LINE__);return -ENOMEM ; } +dev_info (priv->dev,"created ram cache: %d entries, %d KiB each\n" , +CACHE_PAGE_COUNT ,CACHE_PAGE_SIZE /1024 ); +return 0 ; }
@@ -434,14 +440,14 @@ static int ps3vram_erase(struct mtd_inforeturn 0 ; } -static int ps3vram_read (struct mtd_info *mtd,loff_t from,size_t len,size_t *retlen,u_char *buf) {struct ps3vram_priv *priv = mtd->priv;unsigned int cached, count; -dbg ("from = 0x%08x len = 0x%zx" , (unsigned int ) from, len); +dev_dbg (priv->dev,"%s:%d: from=0x%08x len=0x%zx\n" , __func__, __LINE__, + (unsigned int )from, len);if (from >= mtd->size)return -EINVAL ;
@@ -463,8 +469,9 @@ static int ps3vram_read(struct mtd_info entry =ps3vram_cache_match (mtd, from); cached =CACHE_OFFSET + entry * priv->cache.page_size + offset; -dbg ("from=%08x cached=%08x offset=%08x avail=%08x count=%08x" , - (unsigned )from, cached, offset, avail, count); +dev_dbg (priv->dev,"%s:%d: from=%08x cached=%08x offset=%08x " +"avail=%08x count=%08x\n" , __func__, __LINE__, + (unsigned int )from, cached, offset, avail, count);if (avail > count) avail = count;
@@ -507,8 +514,9 @@ static int ps3vram_write(struct mtd_info entry =ps3vram_cache_match (mtd, to); cached =CACHE_OFFSET + entry * priv->cache.page_size + offset; -dbg ("to=%08x cached=%08x offset=%08x avail=%08x count=%08x" , - (unsigned ) to, cached, offset, avail, count); +dev_dbg (priv->dev,"%s:%d: to=%08x cached=%08x offset=%08x " +"avail=%08x count=%08x\n" , __func__, __LINE__, + (unsigned int )to, cached, offset, avail, count);if (avail > count) avail = count;
@@ -544,12 +552,14 @@ static int __devinit ps3vram_probe(struc priv = ps3vram_mtd.priv;mutex_init (&priv->lock); + priv->dev = &dev->core;/* Allocate XDR buffer (1MiB aligned) */ priv->xdr_buf = (uint8_t *)__get_free_pages (GFP_KERNEL ,get_order (XDR_BUF_SIZE ));if (priv->xdr_buf ==NULL ) { -pr_err ("ps3vram: could not allocate XDR buffer\n" ); +dev_dbg (&dev->core,"%s:%d: could not allocate XDR buffer\n" , + __func__, __LINE__); ret = -ENOMEM ; goto out_free_priv; }
@@ -560,7 +570,8 @@ static int __devinit ps3vram_probe(struc/* XXX: Need to open GPU, in case ps3fb or snd_ps3 aren't loaded */ if (ps3_open_hv_device (dev)) { -pr_err ("ps3vram: ps3_open_hv_device failed\n" ); +dev_err (&dev->core,"%s:%d: ps3_open_hv_device failed\n" , + __func__, __LINE__); ret = -EAGAIN ; goto out_close_gpu; }
@@ -572,7 +583,8 @@ static int __devinit ps3vram_probe(struc ddr_size -= ps3fb_videomemory.size; ddr_size =ALIGN (ddr_size,1024 *1024 );if (ddr_size <=0 ) { -printk (KERN_ERR "ps3vram: specified size is too small\n" ); +dev_err (&dev->core,"%s:%d: specified size is too small\n" , + __func__, __LINE__); ret = -EINVAL ; goto out_close_gpu; }
@@ -586,12 +598,11 @@ static int __devinit ps3vram_probe(struc ddr_size -=1024 *1024 ; }if (status !=0 || ddr_size <=0 ) { -pr_err ("ps3vram: lv1_gpu_memory_allocate failed\n" ); +dev_err (&dev->core,"%s:%d: lv1_gpu_memory_allocate failed\n" , + __func__, __LINE__); ret = -ENOMEM ; goto out_free_xdr_buf; } -pr_info ("ps3vram: allocated %u MiB of DDR memory\n" , - (unsigned int ) (ddr_size /1024 /1024 ));/* Request context */ status = lv1_gpu_context_allocate(priv->memory_handle,
@@ -602,7 +613,8 @@ static int __devinit ps3vram_probe(struc &reports_lpar, &reports_size);if (status) { -pr_err ("ps3vram: lv1_gpu_context_allocate failed\n" ); +dev_err (&dev->core,"%s:%d: lv1_gpu_context_allocate failed\n" , + __func__, __LINE__); ret = -ENOMEM ; goto out_free_memory; }
@@ -612,28 +624,32 @@ static int __devinit ps3vram_probe(strucps3_mm_phys_to_lpar (__pa (priv->xdr_buf)), XDR_BUF_SIZE, 0);if (status) { -pr_err ("ps3vram: lv1_gpu_context_iomap failed\n" ); +dev_err (&dev->core,"%s:%d: lv1_gpu_context_iomap failed\n" , + __func__, __LINE__); ret = -ENOMEM ; goto out_free_context; } priv->base =ioremap (ddr_lpar, ddr_size);if (!priv->base) { -pr_err ("ps3vram: ioremap failed\n" ); +dev_err (&dev->core,"%s:%d: ioremap failed\n" , __func__, + __LINE__); ret = -ENOMEM ; goto out_free_context; } priv->ctrl =ioremap (ctrl_lpar,64 *1024 );if (!priv->ctrl) { -pr_err ("ps3vram: ioremap failed\n" ); +dev_err (&dev->core,"%s:%d: ioremap failed\n" , __func__, + __LINE__); ret = -ENOMEM ; goto out_unmap_vram; } priv->reports =ioremap (reports_lpar, reports_size);if (!priv->reports) { -pr_err ("ps3vram: ioremap failed\n" ); +dev_err (&dev->core,"%s:%d: ioremap failed\n" , __func__, + __LINE__); ret = -ENOMEM ; goto out_unmap_ctrl; }
@@ -661,7 +677,8 @@ static int __devinit ps3vram_probe(struc ret =ps3vram_wait_ring (&ps3vram_mtd,100 );mutex_unlock (&ps3_gpu_mutex);if (ret <0 ) { -pr_err ("failed to initialize channels\n" ); +dev_err (&dev->core,"%s:%d: failed to initialize channels\n" , + __func__, __LINE__); ret = -ETIMEDOUT ; goto out_unmap_reports; }
@@ -669,12 +686,15 @@ static int __devinit ps3vram_probe(strucps3vram_cache_init (&ps3vram_mtd);if (add_mtd_device (&ps3vram_mtd)) { -pr_err ("ps3vram: failed to register device\n" ); +dev_err (&dev->core,"%s:%d: add_mtd_device failed\n" , + __func__, __LINE__); ret = -EAGAIN ; goto out_cache_cleanup; } -pr_info ("ps3vram mtd device registered, %lu bytes\n" , ddr_size); +dev_info (&dev->core,"reserved %u MiB of gpu memory\n" , + (unsigned int )(ddr_size /1024 /1024 )); +return 0 ; out_cache_cleanup:
PATCH 5/6 mtd/ps3vram: Use kernel types
In reply to a message not in the archiveReplace the use of stdint.h types with kernel types in the ps3vram driver.
--- drivers/mtd/devices/ps3vram.c | 56 ++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 26 deletions(-)
drivers/mtd/devices/ps3vram.c +30 -26
@@ -65,15 +65,15 @@ struct ps3vram_cache { };struct ps3vram_priv { -uint64_t memory_handle; -uint64_t context_handle; -uint8_t *base; -uint32_t *ctrl; -uint32_t *reports; -uint8_t *xdr_buf; +u64 memory_handle; +u64 context_handle; +u32 *ctrl; +u32 *reports; +u8 *base; +u8 *xdr_buf; -uint32_t *fifo_base; -uint32_t *fifo_ptr; +u32 *fifo_base; +u32 *fifo_ptr;struct device *dev;struct ps3vram_cache cache;
@@ -92,7 +92,7 @@ char *size = "256M-";module_param (size, charp,0 );MODULE_PARM_DESC (size,"memory size" ); -static inline uint32_t *ps3vram_get_notifier (uint32_t *reports,int notifier) +static u32 *ps3vram_get_notifier (u32 *reports,int notifier) {return (void *) reports + DMA_NOTIFIER_OFFSET_BASE +
@@ -102,8 +102,9 @@ static inline uint32_t *ps3vram_get_notistatic void ps3vram_notifier_reset (struct mtd_info *mtd) {int i; +struct ps3vram_priv *priv = mtd->priv; -uint32_t *notify =ps3vram_get_notifier (priv->reports,NOTIFIER ); +u32 *notify =ps3vram_get_notifier (priv->reports,NOTIFIER );for (i =0 ; i <4 ; i++) notify[i] =0xffffffff ; }
@@ -111,7 +112,7 @@ static void ps3vram_notifier_reset(strucstatic int ps3vram_notifier_wait (struct mtd_info *mtd,int timeout_ms) {struct ps3vram_priv *priv = mtd->priv; -uint32_t *notify =ps3vram_get_notifier (priv->reports,NOTIFIER ); +u32 *notify =ps3vram_get_notifier (priv->reports,NOTIFIER ); timeout_ms *=1000 ;
@@ -155,13 +156,13 @@ static int ps3vram_wait_ring(struct mtd_return 0 ; } -static inline void ps3vram_out_ring (struct ps3vram_priv *priv,uint32_t data) +static void ps3vram_out_ring (struct ps3vram_priv *priv,u32 data) { *(priv->fifo_ptr)++ = data; } -static inline void ps3vram_begin_ring (struct ps3vram_priv *priv,uint32_t chan, -uint32_t tag,uint32_t size) +static void ps3vram_begin_ring (struct ps3vram_priv *priv,u32 chan, +u32 tag,u32 size) {ps3vram_out_ring (priv, (size <<18 ) | (chan <<13 ) | tag); }
@@ -194,7 +195,7 @@ static void ps3vram_fire_ring(struct mtdmutex_lock (&ps3_gpu_mutex); priv->ctrl[CTRL_PUT ] =FIFO_BASE +FIFO_OFFSET + - (priv->fifo_ptr - priv->fifo_base) *sizeof (uint32_t ); + (priv->fifo_ptr - priv->fifo_base) *sizeof (u32);/* asking the HV for a blit will kick the fifo */ status = lv1_gpu_context_attribute(priv->context_handle,
@@ -204,8 +205,8 @@ static void ps3vram_fire_ring(struct mtddev_err (priv->dev,"%s:%d: lv1_gpu_context_attribute failed\n" , __func__, __LINE__); -if ((priv->fifo_ptr - priv->fifo_base) *sizeof (uint32_t ) > -FIFO_SIZE -1024 ) { +if ((priv->fifo_ptr - priv->fifo_base) *sizeof (u32) > +FIFO_SIZE -1024 ) {dev_dbg (priv->dev,"%s:%d: fifo full, rewinding\n" , __func__, __LINE__);ps3vram_wait_ring (mtd,200 );
@@ -538,10 +539,13 @@ static int ps3vram_write(struct mtd_infostatic int __devinit ps3vram_probe (struct ps3_system_bus_device *dev) {struct ps3vram_priv *priv; -uint64_t status; -uint64_t ddr_lpar, ctrl_lpar, info_lpar, reports_lpar; -int64_t ddr_size; -uint64_t reports_size; +int status; +u64 ddr_lpar; +u64 ctrl_lpar; +u64 info_lpar; +u64 reports_lpar; +u64 ddr_size; +u64 reports_size;int ret = -ENOMEM ;char *rest;
@@ -555,8 +559,8 @@ static int __devinit ps3vram_probe(struc priv->dev = &dev->core;/* Allocate XDR buffer (1MiB aligned) */ - priv->xdr_buf = (uint8_t *)__get_free_pages (GFP_KERNEL , -get_order (XDR_BUF_SIZE )); + priv->xdr_buf = (void *)__get_free_pages (GFP_KERNEL , +get_order (XDR_BUF_SIZE ));if (priv->xdr_buf ==NULL ) {dev_dbg (&dev->core,"%s:%d: could not allocate XDR buffer\n" , __func__, __LINE__);
@@ -565,7 +569,7 @@ static int __devinit ps3vram_probe(struc }/* Put FIFO at begginning of XDR buffer */ - priv->fifo_base = (uint32_t *) (priv->xdr_buf +FIFO_OFFSET ); + priv->fifo_base = (u32 *) (priv->xdr_buf +FIFO_OFFSET ); priv->fifo_ptr = priv->fifo_base;/* XXX: Need to open GPU, in case ps3fb or snd_ps3 aren't loaded */
@@ -593,11 +597,11 @@ static int __devinit ps3vram_probe(struc status =lv1_gpu_memory_allocate (ddr_size,0 ,0 ,0 ,0 , &priv->memory_handle, &ddr_lpar); -if (status ==0 ) +if (!status)break ; ddr_size -=1024 *1024 ; } -if (status !=0 || ddr_size <=0 ) { +if (status || ddr_size <=0 ) {dev_err (&dev->core,"%s:%d: lv1_gpu_memory_allocate failed\n" , __func__, __LINE__); ret = -ENOMEM ;
PATCH 6/6 mtd/ps3vram: Use msleep in waits
In reply to a message not in the archiveReplace the use of udelay() with msleep() in the looping wait routines ps3vram_notifier_wait() and ps3vram_wait_ring().
--- drivers/mtd/devices/ps3vram.c | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-)
drivers/mtd/devices/ps3vram.c +14 -22
@@ -109,22 +109,18 @@ static void ps3vram_notifier_reset(struc notify[i] =0xffffffff ; } -static int ps3vram_notifier_wait (struct mtd_info *mtd,int timeout_ms) +static int ps3vram_notifier_wait (struct mtd_info *mtd,unsigned int timeout_ms) {struct ps3vram_priv *priv = mtd->priv;u32 *notify =ps3vram_get_notifier (priv->reports,NOTIFIER ); - timeout_ms *=1000 ; -do { -if (notify[3 ] ==0 ) +if (!notify[3 ])return 0 ; - -if (timeout_ms) -udelay (1 ); +msleep (1 ); }while (timeout_ms--); -return -1 ; +return -ETIMEDOUT ; }static void ps3vram_init_ring (struct mtd_info *mtd)
@@ -135,25 +131,21 @@ static void ps3vram_init_ring(struct mtd priv->ctrl[CTRL_GET ] =FIFO_BASE +FIFO_OFFSET ; } -static int ps3vram_wait_ring (struct mtd_info *mtd,int timeout) +static int ps3vram_wait_ring (struct mtd_info *mtd,unsigned int timeout_ms) {struct ps3vram_priv *priv = mtd->priv; -/* wait until setup commands are processed */ - timeout *=1000 ; -while (--timeout) { +do {if (priv->ctrl[CTRL_PUT ] == priv->ctrl[CTRL_GET ]) -break ; -udelay (1 ); - } -if (timeout ==0 ) { -dev_dbg (priv->dev,"%s:%d: FIFO timeout (%08x/%08x/%08x)\n" , - __func__, __LINE__, priv->ctrl[CTRL_PUT ], - priv->ctrl[CTRL_GET ], priv->ctrl[CTRL_TOP ]); -return -ETIMEDOUT ; - } +return 0 ; +msleep (1 ); + }while (timeout_ms--); -return 0 ; +dev_dbg (priv->dev,"%s:%d: FIFO timeout (%08x/%08x/%08x)\n" , __func__, + __LINE__, priv->ctrl[CTRL_PUT ], priv->ctrl[CTRL_GET ], + priv->ctrl[CTRL_TOP ]); + +return -ETIMEDOUT ; }static void ps3vram_out_ring (struct ps3vram_priv *priv,u32 data)
Re: [patch 6/6] mtd/ps3vram: Use msleep in waits
T24gVHVlc2RheSAwNiBKYW51YXJ5IDIwMDksIEdlb2ZmIExldmFuZCB3cm90ZToKPiCgoKCgoKCg oGRvIHsKPiAtoKCgoKCgoKCgoKCgoKCgaWYgKG5vdGlmeVszXSA9PSAwKQo+ICugoKCgoKCgoKCg oKCgoKBpZiAoIW5vdGlmeVszXSkKPiCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKByZXR1cm4gMDsK PiAtCj4gLaCgoKCgoKCgoKCgoKCgoGlmICh0aW1lb3V0X21zKQo+IC2goKCgoKCgoKCgoKCgoKCg oKCgoKCgoHVkZWxheSgxKTsKPiAroKCgoKCgoKCgoKCgoKCgbXNsZWVwKDEpOwo+IKCgoKCgoKCg fSB3aGlsZSAodGltZW91dF9tcy0tKTsKPiCgCgpJIGd1ZXNzIGl0J3Mgbm90IHJlYWxseSBpbXBv cnRhbnQsIGJ1dCB0aGlzIGZ1bmN0aW9uIG1pZ2h0IHdhaXQgc3Vic3RhbnRpYWxseQpsb25nZXIg dGhhbiByZXF1ZXN0ZWQuIElmIHlvdSBoYXZlIENPTkZJR19IWj0xMDAsIG1zbGVlcCgxKSB3aWxs IHNsZWVwIGZvcgphdCBsZWFzdCAxMCBtaWxpc2Vjb25kcy4gVGhlIGNvcnJlY3Qgd2F5IHRvIHNs ZWVwIGZvciB1cCB0byBhIGdpdmVuIGFtb3VudApvZiB0aW1lIGlzIHRvIGNhbGN1bGF0ZSB0aGUg ZW5kIHRpbWUgaW4gamlmZmllcywgYW5kIHVzZSB0aW1lX2JlZm9yZSgpIGluCnRoZSBsb29wIGNv bmRpdGlvbi4KCglBcm5kIDw+PAo=
PATCH v2 6/6 mtd/ps3vram: Use msleep in waits
In reply to Geoff LevandSubject: [patch] mtd/ps3vram: Use msleep in waits
Replace the use of udelay() with msleep() in the looping wait routines ps3vram_notifier_wait() and ps3vram_wait_ring().
---
v2: Use time_before() in loops.
drivers/mtd/devices/ps3vram.c | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-)
drivers/mtd/devices/ps3vram.c +17 -23
@@ -109,22 +109,19 @@ static void ps3vram_notifier_reset(struc notify[i] =0xffffffff ; } -static int ps3vram_notifier_wait (struct mtd_info *mtd,int timeout_ms) +static int ps3vram_notifier_wait (struct mtd_info *mtd,unsigned int timeout_ms) {struct ps3vram_priv *priv = mtd->priv;u32 *notify =ps3vram_get_notifier (priv->reports,NOTIFIER ); - - timeout_ms *=1000 ; +unsigned long timeout = jiffies +msecs_to_jiffies (timeout_ms);do { -if (notify[3 ] ==0 ) +if (!notify[3 ])return 0 ; +msleep (1 ); + }while (time_before (jiffies, timeout)); -if (timeout_ms) -udelay (1 ); - }while (timeout_ms--); - -return -1 ; +return -ETIMEDOUT ; }static void ps3vram_init_ring (struct mtd_info *mtd)
@@ -135,25 +132,22 @@ static void ps3vram_init_ring(struct mtd priv->ctrl[CTRL_GET ] =FIFO_BASE +FIFO_OFFSET ; } -static int ps3vram_wait_ring (struct mtd_info *mtd,int timeout) +static int ps3vram_wait_ring (struct mtd_info *mtd,unsigned int timeout_ms) {struct ps3vram_priv *priv = mtd->priv; +unsigned long timeout = jiffies +msecs_to_jiffies (timeout_ms); -/* wait until setup commands are processed */ - timeout *=1000 ; -while (--timeout) { +do {if (priv->ctrl[CTRL_PUT ] == priv->ctrl[CTRL_GET ]) -break ; -udelay (1 ); - } -if (timeout ==0 ) { -dev_dbg (priv->dev,"%s:%d: FIFO timeout (%08x/%08x/%08x)\n" , - __func__, __LINE__, priv->ctrl[CTRL_PUT ], - priv->ctrl[CTRL_GET ], priv->ctrl[CTRL_TOP ]); -return -ETIMEDOUT ; - } +return 0 ; +msleep (1 ); + }while (time_before (jiffies, timeout)); -return 0 ; +dev_dbg (priv->dev,"%s:%d: FIFO timeout (%08x/%08x/%08x)\n" , __func__, + __LINE__, priv->ctrl[CTRL_PUT ], priv->ctrl[CTRL_GET ], + priv->ctrl[CTRL_TOP ]); + +return -ETIMEDOUT ; }static void ps3vram_out_ring (struct ps3vram_priv *priv,u32 data)