#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;
uint32_t *fifo_base;
uint32_t *fifo_ptr;
+ struct device *dev;
struct ps3vram_cache cache;
/* Used to serialize cache/DMA operations */
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;
}
L1GPU_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;
}
L1GPU_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);
}
ps3vram_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;
}
ps3vram_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;
}
struct 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;
}
struct 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;
struct 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;
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);
{
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;
}
return 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;
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;
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;
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;
}
/* 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;
}
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;
}
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,
&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;
}
ps3_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;
}
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;
}
ps3vram_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: