aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/devices
diff options
context:
space:
mode:
authorGeoff Levand <geoffrey.levand@am.sony.com>2009-01-06 06:32:21 -0500
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2009-01-08 00:25:15 -0500
commitf259d74e030faab15b95fb4bb56d7f424773c278 (patch)
treee3cbd7ed4d604604dcb6d7ac47616c60268dc682 /drivers/mtd/devices
parente7dd54cf17714c22665ad74b720f40fb64b3c565 (diff)
mtd/ps3vram: Cleanup ps3vram driver messages
Cleanup 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. Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'drivers/mtd/devices')
-rw-r--r--drivers/mtd/devices/ps3vram.c116
1 files changed, 68 insertions, 48 deletions
diff --git a/drivers/mtd/devices/ps3vram.c b/drivers/mtd/devices/ps3vram.c
index 18ca5219a982..f5cc2908bdca 100644
--- a/drivers/mtd/devices/ps3vram.c
+++ b/drivers/mtd/devices/ps3vram.c
@@ -53,9 +53,6 @@ struct mtd_info ps3vram_mtd;
53#define CACHE_PAGE_PRESENT 1 53#define CACHE_PAGE_PRESENT 1
54#define CACHE_PAGE_DIRTY 2 54#define CACHE_PAGE_DIRTY 2
55 55
56#define dbg(fmt, args...) \
57 pr_debug("%s:%d " fmt "\n", __func__, __LINE__, ## args)
58
59struct ps3vram_tag { 56struct ps3vram_tag {
60 unsigned int address; 57 unsigned int address;
61 unsigned int flags; 58 unsigned int flags;
@@ -78,6 +75,7 @@ struct ps3vram_priv {
78 uint32_t *fifo_base; 75 uint32_t *fifo_base;
79 uint32_t *fifo_ptr; 76 uint32_t *fifo_ptr;
80 77
78 struct device *dev;
81 struct ps3vram_cache cache; 79 struct ps3vram_cache cache;
82 80
83 /* Used to serialize cache/DMA operations */ 81 /* Used to serialize cache/DMA operations */
@@ -148,8 +146,9 @@ static int ps3vram_wait_ring(struct mtd_info *mtd, int timeout)
148 udelay(1); 146 udelay(1);
149 } 147 }
150 if (timeout == 0) { 148 if (timeout == 0) {
151 pr_err("FIFO timeout (%08x/%08x/%08x)\n", priv->ctrl[CTRL_PUT], 149 dev_dbg(priv->dev, "%s:%d: FIFO timeout (%08x/%08x/%08x)\n",
152 priv->ctrl[CTRL_GET], priv->ctrl[CTRL_TOP]); 150 __func__, __LINE__, priv->ctrl[CTRL_PUT],
151 priv->ctrl[CTRL_GET], priv->ctrl[CTRL_TOP]);
153 return -ETIMEDOUT; 152 return -ETIMEDOUT;
154 } 153 }
155 154
@@ -181,7 +180,8 @@ static void ps3vram_rewind_ring(struct mtd_info *mtd)
181 L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT, 180 L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT,
182 0, 0, 0, 0); 181 0, 0, 0, 0);
183 if (status) 182 if (status)
184 pr_err("ps3vram: lv1_gpu_context_attribute FB_BLIT failed\n"); 183 dev_err(priv->dev, "%s:%d: lv1_gpu_context_attribute failed\n",
184 __func__, __LINE__);
185 185
186 priv->fifo_ptr = priv->fifo_base; 186 priv->fifo_ptr = priv->fifo_base;
187} 187}
@@ -201,11 +201,13 @@ static void ps3vram_fire_ring(struct mtd_info *mtd)
201 L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT, 201 L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT,
202 0, 0, 0, 0); 202 0, 0, 0, 0);
203 if (status) 203 if (status)
204 pr_err("ps3vram: lv1_gpu_context_attribute FB_BLIT failed\n"); 204 dev_err(priv->dev, "%s:%d: lv1_gpu_context_attribute failed\n",
205 __func__, __LINE__);
205 206
206 if ((priv->fifo_ptr - priv->fifo_base) * sizeof(uint32_t) > 207 if ((priv->fifo_ptr - priv->fifo_base) * sizeof(uint32_t) >
207 FIFO_SIZE - 1024) { 208 FIFO_SIZE - 1024) {
208 dbg("fifo full, rewinding"); 209 dev_dbg(priv->dev, "%s:%d: fifo full, rewinding\n", __func__,
210 __LINE__);
209 ps3vram_wait_ring(mtd, 200); 211 ps3vram_wait_ring(mtd, 200);
210 ps3vram_rewind_ring(mtd); 212 ps3vram_rewind_ring(mtd);
211 } 213 }
@@ -258,7 +260,8 @@ static int ps3vram_upload(struct mtd_info *mtd, unsigned int src_offset,
258 ps3vram_out_ring(priv, 0); 260 ps3vram_out_ring(priv, 0);
259 ps3vram_fire_ring(mtd); 261 ps3vram_fire_ring(mtd);
260 if (ps3vram_notifier_wait(mtd, 200) < 0) { 262 if (ps3vram_notifier_wait(mtd, 200) < 0) {
261 pr_err("notifier timeout\n"); 263 dev_dbg(priv->dev, "%s:%d: notifier timeout\n", __func__,
264 __LINE__);
262 return -1; 265 return -1;
263 } 266 }
264 267
@@ -289,7 +292,8 @@ static int ps3vram_download(struct mtd_info *mtd, unsigned int src_offset,
289 ps3vram_out_ring(priv, 0); 292 ps3vram_out_ring(priv, 0);
290 ps3vram_fire_ring(mtd); 293 ps3vram_fire_ring(mtd);
291 if (ps3vram_notifier_wait(mtd, 200) < 0) { 294 if (ps3vram_notifier_wait(mtd, 200) < 0) {
292 pr_err("notifier timeout\n"); 295 dev_dbg(priv->dev, "%s:%d: notifier timeout\n", __func__,
296 __LINE__);
293 return -1; 297 return -1;
294 } 298 }
295 299
@@ -302,16 +306,17 @@ static void ps3vram_cache_evict(struct mtd_info *mtd, int entry)
302 struct ps3vram_cache *cache = &priv->cache; 306 struct ps3vram_cache *cache = &priv->cache;
303 307
304 if (cache->tags[entry].flags & CACHE_PAGE_DIRTY) { 308 if (cache->tags[entry].flags & CACHE_PAGE_DIRTY) {
305 dbg("flushing %d : 0x%08x", entry, cache->tags[entry].address); 309 dev_dbg(priv->dev, "%s:%d: flushing %d : 0x%08x\n", __func__,
310 __LINE__, entry, cache->tags[entry].address);
306 if (ps3vram_upload(mtd, 311 if (ps3vram_upload(mtd,
307 CACHE_OFFSET + entry * cache->page_size, 312 CACHE_OFFSET + entry * cache->page_size,
308 cache->tags[entry].address, 313 cache->tags[entry].address,
309 DMA_PAGE_SIZE, 314 DMA_PAGE_SIZE,
310 cache->page_size / DMA_PAGE_SIZE) < 0) { 315 cache->page_size / DMA_PAGE_SIZE) < 0) {
311 pr_err("failed to upload from 0x%x to 0x%x size 0x%x\n", 316 dev_dbg(priv->dev, "%s:%d: failed to upload from "
312 entry * cache->page_size, 317 "0x%x to 0x%x size 0x%x\n", __func__, __LINE__,
313 cache->tags[entry].address, 318 entry * cache->page_size,
314 cache->page_size); 319 cache->tags[entry].address, cache->page_size);
315 } 320 }
316 cache->tags[entry].flags &= ~CACHE_PAGE_DIRTY; 321 cache->tags[entry].flags &= ~CACHE_PAGE_DIRTY;
317 } 322 }
@@ -323,16 +328,16 @@ static void ps3vram_cache_load(struct mtd_info *mtd, int entry,
323 struct ps3vram_priv *priv = mtd->priv; 328 struct ps3vram_priv *priv = mtd->priv;
324 struct ps3vram_cache *cache = &priv->cache; 329 struct ps3vram_cache *cache = &priv->cache;
325 330
326 dbg("fetching %d : 0x%08x", entry, address); 331 dev_dbg(priv->dev, "%s:%d: fetching %d : 0x%08x\n", __func__, __LINE__,
332 entry, address);
327 if (ps3vram_download(mtd, 333 if (ps3vram_download(mtd,
328 address, 334 address,
329 CACHE_OFFSET + entry * cache->page_size, 335 CACHE_OFFSET + entry * cache->page_size,
330 DMA_PAGE_SIZE, 336 DMA_PAGE_SIZE,
331 cache->page_size / DMA_PAGE_SIZE) < 0) { 337 cache->page_size / DMA_PAGE_SIZE) < 0) {
332 pr_err("failed to download from 0x%x to 0x%x size 0x%x\n", 338 dev_err(priv->dev, "%s:%d: failed to download from "
333 address, 339 "0x%x to 0x%x size 0x%x\n", __func__, __LINE__, address,
334 entry * cache->page_size, 340 entry * cache->page_size, cache->page_size);
335 cache->page_size);
336 } 341 }
337 342
338 cache->tags[entry].address = address; 343 cache->tags[entry].address = address;
@@ -346,7 +351,7 @@ static void ps3vram_cache_flush(struct mtd_info *mtd)
346 struct ps3vram_cache *cache = &priv->cache; 351 struct ps3vram_cache *cache = &priv->cache;
347 int i; 352 int i;
348 353
349 dbg("FLUSH"); 354 dev_dbg(priv->dev, "%s:%d: FLUSH\n", __func__, __LINE__);
350 for (i = 0; i < cache->page_count; i++) { 355 for (i = 0; i < cache->page_count; i++) {
351 ps3vram_cache_evict(mtd, i); 356 ps3vram_cache_evict(mtd, i);
352 cache->tags[i].flags = 0; 357 cache->tags[i].flags = 0;
@@ -369,15 +374,15 @@ static unsigned int ps3vram_cache_match(struct mtd_info *mtd, loff_t address)
369 for (i = 0; i < cache->page_count; i++) { 374 for (i = 0; i < cache->page_count; i++) {
370 if ((cache->tags[i].flags & CACHE_PAGE_PRESENT) && 375 if ((cache->tags[i].flags & CACHE_PAGE_PRESENT) &&
371 cache->tags[i].address == base) { 376 cache->tags[i].address == base) {
372 dbg("found entry %d : 0x%08x", 377 dev_dbg(priv->dev, "%s:%d: found entry %d : 0x%08x\n",
373 i, cache->tags[i].address); 378 __func__, __LINE__, i, cache->tags[i].address);
374 return i; 379 return i;
375 } 380 }
376 } 381 }
377 382
378 /* choose a random entry */ 383 /* choose a random entry */
379 i = (jiffies + (counter++)) % cache->page_count; 384 i = (jiffies + (counter++)) % cache->page_count;
380 dbg("using cache entry %d", i); 385 dev_dbg(priv->dev, "%s:%d: using entry %d\n", __func__, __LINE__, i);
381 386
382 ps3vram_cache_evict(mtd, i); 387 ps3vram_cache_evict(mtd, i);
383 ps3vram_cache_load(mtd, i, base); 388 ps3vram_cache_load(mtd, i, base);
@@ -389,18 +394,19 @@ static int ps3vram_cache_init(struct mtd_info *mtd)
389{ 394{
390 struct ps3vram_priv *priv = mtd->priv; 395 struct ps3vram_priv *priv = mtd->priv;
391 396
392 pr_info("creating cache: %d entries, %d bytes pages\n",
393 CACHE_PAGE_COUNT, CACHE_PAGE_SIZE);
394
395 priv->cache.page_count = CACHE_PAGE_COUNT; 397 priv->cache.page_count = CACHE_PAGE_COUNT;
396 priv->cache.page_size = CACHE_PAGE_SIZE; 398 priv->cache.page_size = CACHE_PAGE_SIZE;
397 priv->cache.tags = kzalloc(sizeof(struct ps3vram_tag) * 399 priv->cache.tags = kzalloc(sizeof(struct ps3vram_tag) *
398 CACHE_PAGE_COUNT, GFP_KERNEL); 400 CACHE_PAGE_COUNT, GFP_KERNEL);
399 if (priv->cache.tags == NULL) { 401 if (priv->cache.tags == NULL) {
400 pr_err("could not allocate cache tags\n"); 402 dev_err(priv->dev, "%s:%d: could not allocate cache tags\n",
403 __func__, __LINE__);
401 return -ENOMEM; 404 return -ENOMEM;
402 } 405 }
403 406
407 dev_info(priv->dev, "created ram cache: %d entries, %d KiB each\n",
408 CACHE_PAGE_COUNT, CACHE_PAGE_SIZE / 1024);
409
404 return 0; 410 return 0;
405} 411}
406 412
@@ -434,14 +440,14 @@ static int ps3vram_erase(struct mtd_info *mtd, struct erase_info *instr)
434 return 0; 440 return 0;
435} 441}
436 442
437
438static int ps3vram_read(struct mtd_info *mtd, loff_t from, size_t len, 443static int ps3vram_read(struct mtd_info *mtd, loff_t from, size_t len,
439 size_t *retlen, u_char *buf) 444 size_t *retlen, u_char *buf)
440{ 445{
441 struct ps3vram_priv *priv = mtd->priv; 446 struct ps3vram_priv *priv = mtd->priv;
442 unsigned int cached, count; 447 unsigned int cached, count;
443 448
444 dbg("from = 0x%08x len = 0x%zx", (unsigned int) from, len); 449 dev_dbg(priv->dev, "%s:%d: from=0x%08x len=0x%zx\n", __func__, __LINE__,
450 (unsigned int)from, len);
445 451
446 if (from >= mtd->size) 452 if (from >= mtd->size)
447 return -EINVAL; 453 return -EINVAL;
@@ -463,8 +469,9 @@ static int ps3vram_read(struct mtd_info *mtd, loff_t from, size_t len,
463 entry = ps3vram_cache_match(mtd, from); 469 entry = ps3vram_cache_match(mtd, from);
464 cached = CACHE_OFFSET + entry * priv->cache.page_size + offset; 470 cached = CACHE_OFFSET + entry * priv->cache.page_size + offset;
465 471
466 dbg("from=%08x cached=%08x offset=%08x avail=%08x count=%08x", 472 dev_dbg(priv->dev, "%s:%d: from=%08x cached=%08x offset=%08x "
467 (unsigned)from, cached, offset, avail, count); 473 "avail=%08x count=%08x\n", __func__, __LINE__,
474 (unsigned int)from, cached, offset, avail, count);
468 475
469 if (avail > count) 476 if (avail > count)
470 avail = count; 477 avail = count;
@@ -507,8 +514,9 @@ static int ps3vram_write(struct mtd_info *mtd, loff_t to, size_t len,
507 entry = ps3vram_cache_match(mtd, to); 514 entry = ps3vram_cache_match(mtd, to);
508 cached = CACHE_OFFSET + entry * priv->cache.page_size + offset; 515 cached = CACHE_OFFSET + entry * priv->cache.page_size + offset;
509 516
510 dbg("to=%08x cached=%08x offset=%08x avail=%08x count=%08x", 517 dev_dbg(priv->dev, "%s:%d: to=%08x cached=%08x offset=%08x "
511 (unsigned) to, cached, offset, avail, count); 518 "avail=%08x count=%08x\n", __func__, __LINE__,
519 (unsigned int)to, cached, offset, avail, count);
512 520
513 if (avail > count) 521 if (avail > count)
514 avail = count; 522 avail = count;
@@ -544,12 +552,14 @@ static int __devinit ps3vram_probe(struct ps3_system_bus_device *dev)
544 priv = ps3vram_mtd.priv; 552 priv = ps3vram_mtd.priv;
545 553
546 mutex_init(&priv->lock); 554 mutex_init(&priv->lock);
555 priv->dev = &dev->core;
547 556
548 /* Allocate XDR buffer (1MiB aligned) */ 557 /* Allocate XDR buffer (1MiB aligned) */
549 priv->xdr_buf = (uint8_t *) __get_free_pages(GFP_KERNEL, 558 priv->xdr_buf = (uint8_t *) __get_free_pages(GFP_KERNEL,
550 get_order(XDR_BUF_SIZE)); 559 get_order(XDR_BUF_SIZE));
551 if (priv->xdr_buf == NULL) { 560 if (priv->xdr_buf == NULL) {
552 pr_err("ps3vram: could not allocate XDR buffer\n"); 561 dev_dbg(&dev->core, "%s:%d: could not allocate XDR buffer\n",
562 __func__, __LINE__);
553 ret = -ENOMEM; 563 ret = -ENOMEM;
554 goto out_free_priv; 564 goto out_free_priv;
555 } 565 }
@@ -560,7 +570,8 @@ static int __devinit ps3vram_probe(struct ps3_system_bus_device *dev)
560 570
561 /* XXX: Need to open GPU, in case ps3fb or snd_ps3 aren't loaded */ 571 /* XXX: Need to open GPU, in case ps3fb or snd_ps3 aren't loaded */
562 if (ps3_open_hv_device(dev)) { 572 if (ps3_open_hv_device(dev)) {
563 pr_err("ps3vram: ps3_open_hv_device failed\n"); 573 dev_err(&dev->core, "%s:%d: ps3_open_hv_device failed\n",
574 __func__, __LINE__);
564 ret = -EAGAIN; 575 ret = -EAGAIN;
565 goto out_close_gpu; 576 goto out_close_gpu;
566 } 577 }
@@ -572,7 +583,8 @@ static int __devinit ps3vram_probe(struct ps3_system_bus_device *dev)
572 ddr_size -= ps3fb_videomemory.size; 583 ddr_size -= ps3fb_videomemory.size;
573 ddr_size = ALIGN(ddr_size, 1024*1024); 584 ddr_size = ALIGN(ddr_size, 1024*1024);
574 if (ddr_size <= 0) { 585 if (ddr_size <= 0) {
575 printk(KERN_ERR "ps3vram: specified size is too small\n"); 586 dev_err(&dev->core, "%s:%d: specified size is too small\n",
587 __func__, __LINE__);
576 ret = -EINVAL; 588 ret = -EINVAL;
577 goto out_close_gpu; 589 goto out_close_gpu;
578 } 590 }
@@ -586,12 +598,11 @@ static int __devinit ps3vram_probe(struct ps3_system_bus_device *dev)
586 ddr_size -= 1024*1024; 598 ddr_size -= 1024*1024;
587 } 599 }
588 if (status != 0 || ddr_size <= 0) { 600 if (status != 0 || ddr_size <= 0) {
589 pr_err("ps3vram: lv1_gpu_memory_allocate failed\n"); 601 dev_err(&dev->core, "%s:%d: lv1_gpu_memory_allocate failed\n",
602 __func__, __LINE__);
590 ret = -ENOMEM; 603 ret = -ENOMEM;
591 goto out_free_xdr_buf; 604 goto out_free_xdr_buf;
592 } 605 }
593 pr_info("ps3vram: allocated %u MiB of DDR memory\n",
594 (unsigned int) (ddr_size / 1024 / 1024));
595 606
596 /* Request context */ 607 /* Request context */
597 status = lv1_gpu_context_allocate(priv->memory_handle, 608 status = lv1_gpu_context_allocate(priv->memory_handle,
@@ -602,7 +613,8 @@ static int __devinit ps3vram_probe(struct ps3_system_bus_device *dev)
602 &reports_lpar, 613 &reports_lpar,
603 &reports_size); 614 &reports_size);
604 if (status) { 615 if (status) {
605 pr_err("ps3vram: lv1_gpu_context_allocate failed\n"); 616 dev_err(&dev->core, "%s:%d: lv1_gpu_context_allocate failed\n",
617 __func__, __LINE__);
606 ret = -ENOMEM; 618 ret = -ENOMEM;
607 goto out_free_memory; 619 goto out_free_memory;
608 } 620 }
@@ -612,28 +624,32 @@ static int __devinit ps3vram_probe(struct ps3_system_bus_device *dev)
612 ps3_mm_phys_to_lpar(__pa(priv->xdr_buf)), 624 ps3_mm_phys_to_lpar(__pa(priv->xdr_buf)),
613 XDR_BUF_SIZE, 0); 625 XDR_BUF_SIZE, 0);
614 if (status) { 626 if (status) {
615 pr_err("ps3vram: lv1_gpu_context_iomap failed\n"); 627 dev_err(&dev->core, "%s:%d: lv1_gpu_context_iomap failed\n",
628 __func__, __LINE__);
616 ret = -ENOMEM; 629 ret = -ENOMEM;
617 goto out_free_context; 630 goto out_free_context;
618 } 631 }
619 632
620 priv->base = ioremap(ddr_lpar, ddr_size); 633 priv->base = ioremap(ddr_lpar, ddr_size);
621 if (!priv->base) { 634 if (!priv->base) {
622 pr_err("ps3vram: ioremap failed\n"); 635 dev_err(&dev->core, "%s:%d: ioremap failed\n", __func__,
636 __LINE__);
623 ret = -ENOMEM; 637 ret = -ENOMEM;
624 goto out_free_context; 638 goto out_free_context;
625 } 639 }
626 640
627 priv->ctrl = ioremap(ctrl_lpar, 64 * 1024); 641 priv->ctrl = ioremap(ctrl_lpar, 64 * 1024);
628 if (!priv->ctrl) { 642 if (!priv->ctrl) {
629 pr_err("ps3vram: ioremap failed\n"); 643 dev_err(&dev->core, "%s:%d: ioremap failed\n", __func__,
644 __LINE__);
630 ret = -ENOMEM; 645 ret = -ENOMEM;
631 goto out_unmap_vram; 646 goto out_unmap_vram;
632 } 647 }
633 648
634 priv->reports = ioremap(reports_lpar, reports_size); 649 priv->reports = ioremap(reports_lpar, reports_size);
635 if (!priv->reports) { 650 if (!priv->reports) {
636 pr_err("ps3vram: ioremap failed\n"); 651 dev_err(&dev->core, "%s:%d: ioremap failed\n", __func__,
652 __LINE__);
637 ret = -ENOMEM; 653 ret = -ENOMEM;
638 goto out_unmap_ctrl; 654 goto out_unmap_ctrl;
639 } 655 }
@@ -661,7 +677,8 @@ static int __devinit ps3vram_probe(struct ps3_system_bus_device *dev)
661 ret = ps3vram_wait_ring(&ps3vram_mtd, 100); 677 ret = ps3vram_wait_ring(&ps3vram_mtd, 100);
662 mutex_unlock(&ps3_gpu_mutex); 678 mutex_unlock(&ps3_gpu_mutex);
663 if (ret < 0) { 679 if (ret < 0) {
664 pr_err("failed to initialize channels\n"); 680 dev_err(&dev->core, "%s:%d: failed to initialize channels\n",
681 __func__, __LINE__);
665 ret = -ETIMEDOUT; 682 ret = -ETIMEDOUT;
666 goto out_unmap_reports; 683 goto out_unmap_reports;
667 } 684 }
@@ -669,12 +686,15 @@ static int __devinit ps3vram_probe(struct ps3_system_bus_device *dev)
669 ps3vram_cache_init(&ps3vram_mtd); 686 ps3vram_cache_init(&ps3vram_mtd);
670 687
671 if (add_mtd_device(&ps3vram_mtd)) { 688 if (add_mtd_device(&ps3vram_mtd)) {
672 pr_err("ps3vram: failed to register device\n"); 689 dev_err(&dev->core, "%s:%d: add_mtd_device failed\n",
690 __func__, __LINE__);
673 ret = -EAGAIN; 691 ret = -EAGAIN;
674 goto out_cache_cleanup; 692 goto out_cache_cleanup;
675 } 693 }
676 694
677 pr_info("ps3vram mtd device registered, %lu bytes\n", ddr_size); 695 dev_info(&dev->core, "reserved %u MiB of gpu memory\n",
696 (unsigned int)(ddr_size / 1024 / 1024));
697
678 return 0; 698 return 0;
679 699
680out_cache_cleanup: 700out_cache_cleanup: