1 From f259d74e030faab15b95fb4bb56d7f424773c278 Mon Sep 17 00:00:00 2001
2 From: Geoff Levand <geoffrey.levand@am.sony.com>
3 Date: Tue, 6 Jan 2009 11:32:21 +0000
4 Subject: [PATCH] mtd/ps3vram: Cleanup ps3vram driver messages
6 Cleanup the ps3vram driver messages. Add a new struct device pointer
7 variable dev to struct ps3vram_priv and use dev_dbg(), pr_dbg(), etc.
10 Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>
11 Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
13 drivers/mtd/devices/ps3vram.c | 116 ++++++++++++++++++++++++-----------------
14 1 files changed, 68 insertions(+), 48 deletions(-)
16 diff --git a/drivers/mtd/devices/ps3vram.c b/drivers/mtd/devices/ps3vram.c
17 index 18ca521..f5cc290 100644
18 --- a/drivers/mtd/devices/ps3vram.c
19 +++ b/drivers/mtd/devices/ps3vram.c
20 @@ -53,9 +53,6 @@ struct mtd_info ps3vram_mtd;
21 #define CACHE_PAGE_PRESENT 1
22 #define CACHE_PAGE_DIRTY 2
24 -#define dbg(fmt, args...) \
25 - pr_debug("%s:%d " fmt "\n", __func__, __LINE__, ## args)
30 @@ -78,6 +75,7 @@ struct ps3vram_priv {
35 struct ps3vram_cache cache;
37 /* Used to serialize cache/DMA operations */
38 @@ -148,8 +146,9 @@ static int ps3vram_wait_ring(struct mtd_info *mtd, int timeout)
42 - pr_err("FIFO timeout (%08x/%08x/%08x)\n", priv->ctrl[CTRL_PUT],
43 - priv->ctrl[CTRL_GET], priv->ctrl[CTRL_TOP]);
44 + dev_dbg(priv->dev, "%s:%d: FIFO timeout (%08x/%08x/%08x)\n",
45 + __func__, __LINE__, priv->ctrl[CTRL_PUT],
46 + priv->ctrl[CTRL_GET], priv->ctrl[CTRL_TOP]);
50 @@ -181,7 +180,8 @@ static void ps3vram_rewind_ring(struct mtd_info *mtd)
51 L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT,
54 - pr_err("ps3vram: lv1_gpu_context_attribute FB_BLIT failed\n");
55 + dev_err(priv->dev, "%s:%d: lv1_gpu_context_attribute failed\n",
56 + __func__, __LINE__);
58 priv->fifo_ptr = priv->fifo_base;
60 @@ -201,11 +201,13 @@ static void ps3vram_fire_ring(struct mtd_info *mtd)
61 L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT,
64 - pr_err("ps3vram: lv1_gpu_context_attribute FB_BLIT failed\n");
65 + dev_err(priv->dev, "%s:%d: lv1_gpu_context_attribute failed\n",
66 + __func__, __LINE__);
68 if ((priv->fifo_ptr - priv->fifo_base) * sizeof(uint32_t) >
70 - dbg("fifo full, rewinding");
71 + dev_dbg(priv->dev, "%s:%d: fifo full, rewinding\n", __func__,
73 ps3vram_wait_ring(mtd, 200);
74 ps3vram_rewind_ring(mtd);
76 @@ -258,7 +260,8 @@ static int ps3vram_upload(struct mtd_info *mtd, unsigned int src_offset,
77 ps3vram_out_ring(priv, 0);
78 ps3vram_fire_ring(mtd);
79 if (ps3vram_notifier_wait(mtd, 200) < 0) {
80 - pr_err("notifier timeout\n");
81 + dev_dbg(priv->dev, "%s:%d: notifier timeout\n", __func__,
86 @@ -289,7 +292,8 @@ static int ps3vram_download(struct mtd_info *mtd, unsigned int src_offset,
87 ps3vram_out_ring(priv, 0);
88 ps3vram_fire_ring(mtd);
89 if (ps3vram_notifier_wait(mtd, 200) < 0) {
90 - pr_err("notifier timeout\n");
91 + dev_dbg(priv->dev, "%s:%d: notifier timeout\n", __func__,
96 @@ -302,16 +306,17 @@ static void ps3vram_cache_evict(struct mtd_info *mtd, int entry)
97 struct ps3vram_cache *cache = &priv->cache;
99 if (cache->tags[entry].flags & CACHE_PAGE_DIRTY) {
100 - dbg("flushing %d : 0x%08x", entry, cache->tags[entry].address);
101 + dev_dbg(priv->dev, "%s:%d: flushing %d : 0x%08x\n", __func__,
102 + __LINE__, entry, cache->tags[entry].address);
103 if (ps3vram_upload(mtd,
104 CACHE_OFFSET + entry * cache->page_size,
105 cache->tags[entry].address,
107 cache->page_size / DMA_PAGE_SIZE) < 0) {
108 - pr_err("failed to upload from 0x%x to 0x%x size 0x%x\n",
109 - entry * cache->page_size,
110 - cache->tags[entry].address,
112 + dev_dbg(priv->dev, "%s:%d: failed to upload from "
113 + "0x%x to 0x%x size 0x%x\n", __func__, __LINE__,
114 + entry * cache->page_size,
115 + cache->tags[entry].address, cache->page_size);
117 cache->tags[entry].flags &= ~CACHE_PAGE_DIRTY;
119 @@ -323,16 +328,16 @@ static void ps3vram_cache_load(struct mtd_info *mtd, int entry,
120 struct ps3vram_priv *priv = mtd->priv;
121 struct ps3vram_cache *cache = &priv->cache;
123 - dbg("fetching %d : 0x%08x", entry, address);
124 + dev_dbg(priv->dev, "%s:%d: fetching %d : 0x%08x\n", __func__, __LINE__,
126 if (ps3vram_download(mtd,
128 CACHE_OFFSET + entry * cache->page_size,
130 cache->page_size / DMA_PAGE_SIZE) < 0) {
131 - pr_err("failed to download from 0x%x to 0x%x size 0x%x\n",
133 - entry * cache->page_size,
135 + dev_err(priv->dev, "%s:%d: failed to download from "
136 + "0x%x to 0x%x size 0x%x\n", __func__, __LINE__, address,
137 + entry * cache->page_size, cache->page_size);
140 cache->tags[entry].address = address;
141 @@ -346,7 +351,7 @@ static void ps3vram_cache_flush(struct mtd_info *mtd)
142 struct ps3vram_cache *cache = &priv->cache;
146 + dev_dbg(priv->dev, "%s:%d: FLUSH\n", __func__, __LINE__);
147 for (i = 0; i < cache->page_count; i++) {
148 ps3vram_cache_evict(mtd, i);
149 cache->tags[i].flags = 0;
150 @@ -369,15 +374,15 @@ static unsigned int ps3vram_cache_match(struct mtd_info *mtd, loff_t address)
151 for (i = 0; i < cache->page_count; i++) {
152 if ((cache->tags[i].flags & CACHE_PAGE_PRESENT) &&
153 cache->tags[i].address == base) {
154 - dbg("found entry %d : 0x%08x",
155 - i, cache->tags[i].address);
156 + dev_dbg(priv->dev, "%s:%d: found entry %d : 0x%08x\n",
157 + __func__, __LINE__, i, cache->tags[i].address);
162 /* choose a random entry */
163 i = (jiffies + (counter++)) % cache->page_count;
164 - dbg("using cache entry %d", i);
165 + dev_dbg(priv->dev, "%s:%d: using entry %d\n", __func__, __LINE__, i);
167 ps3vram_cache_evict(mtd, i);
168 ps3vram_cache_load(mtd, i, base);
169 @@ -389,18 +394,19 @@ static int ps3vram_cache_init(struct mtd_info *mtd)
171 struct ps3vram_priv *priv = mtd->priv;
173 - pr_info("creating cache: %d entries, %d bytes pages\n",
174 - CACHE_PAGE_COUNT, CACHE_PAGE_SIZE);
176 priv->cache.page_count = CACHE_PAGE_COUNT;
177 priv->cache.page_size = CACHE_PAGE_SIZE;
178 priv->cache.tags = kzalloc(sizeof(struct ps3vram_tag) *
179 CACHE_PAGE_COUNT, GFP_KERNEL);
180 if (priv->cache.tags == NULL) {
181 - pr_err("could not allocate cache tags\n");
182 + dev_err(priv->dev, "%s:%d: could not allocate cache tags\n",
183 + __func__, __LINE__);
187 + dev_info(priv->dev, "created ram cache: %d entries, %d KiB each\n",
188 + CACHE_PAGE_COUNT, CACHE_PAGE_SIZE / 1024);
193 @@ -434,14 +440,14 @@ static int ps3vram_erase(struct mtd_info *mtd, struct erase_info *instr)
198 static int ps3vram_read(struct mtd_info *mtd, loff_t from, size_t len,
199 size_t *retlen, u_char *buf)
201 struct ps3vram_priv *priv = mtd->priv;
202 unsigned int cached, count;
204 - dbg("from = 0x%08x len = 0x%zx", (unsigned int) from, len);
205 + dev_dbg(priv->dev, "%s:%d: from=0x%08x len=0x%zx\n", __func__, __LINE__,
206 + (unsigned int)from, len);
208 if (from >= mtd->size)
210 @@ -463,8 +469,9 @@ static int ps3vram_read(struct mtd_info *mtd, loff_t from, size_t len,
211 entry = ps3vram_cache_match(mtd, from);
212 cached = CACHE_OFFSET + entry * priv->cache.page_size + offset;
214 - dbg("from=%08x cached=%08x offset=%08x avail=%08x count=%08x",
215 - (unsigned)from, cached, offset, avail, count);
216 + dev_dbg(priv->dev, "%s:%d: from=%08x cached=%08x offset=%08x "
217 + "avail=%08x count=%08x\n", __func__, __LINE__,
218 + (unsigned int)from, cached, offset, avail, count);
222 @@ -507,8 +514,9 @@ static int ps3vram_write(struct mtd_info *mtd, loff_t to, size_t len,
223 entry = ps3vram_cache_match(mtd, to);
224 cached = CACHE_OFFSET + entry * priv->cache.page_size + offset;
226 - dbg("to=%08x cached=%08x offset=%08x avail=%08x count=%08x",
227 - (unsigned) to, cached, offset, avail, count);
228 + dev_dbg(priv->dev, "%s:%d: to=%08x cached=%08x offset=%08x "
229 + "avail=%08x count=%08x\n", __func__, __LINE__,
230 + (unsigned int)to, cached, offset, avail, count);
234 @@ -544,12 +552,14 @@ static int __devinit ps3vram_probe(struct ps3_system_bus_device *dev)
235 priv = ps3vram_mtd.priv;
237 mutex_init(&priv->lock);
238 + priv->dev = &dev->core;
240 /* Allocate XDR buffer (1MiB aligned) */
241 priv->xdr_buf = (uint8_t *) __get_free_pages(GFP_KERNEL,
242 get_order(XDR_BUF_SIZE));
243 if (priv->xdr_buf == NULL) {
244 - pr_err("ps3vram: could not allocate XDR buffer\n");
245 + dev_dbg(&dev->core, "%s:%d: could not allocate XDR buffer\n",
246 + __func__, __LINE__);
250 @@ -560,7 +570,8 @@ static int __devinit ps3vram_probe(struct ps3_system_bus_device *dev)
252 /* XXX: Need to open GPU, in case ps3fb or snd_ps3 aren't loaded */
253 if (ps3_open_hv_device(dev)) {
254 - pr_err("ps3vram: ps3_open_hv_device failed\n");
255 + dev_err(&dev->core, "%s:%d: ps3_open_hv_device failed\n",
256 + __func__, __LINE__);
260 @@ -572,7 +583,8 @@ static int __devinit ps3vram_probe(struct ps3_system_bus_device *dev)
261 ddr_size -= ps3fb_videomemory.size;
262 ddr_size = ALIGN(ddr_size, 1024*1024);
264 - printk(KERN_ERR "ps3vram: specified size is too small\n");
265 + dev_err(&dev->core, "%s:%d: specified size is too small\n",
266 + __func__, __LINE__);
270 @@ -586,12 +598,11 @@ static int __devinit ps3vram_probe(struct ps3_system_bus_device *dev)
271 ddr_size -= 1024*1024;
273 if (status != 0 || ddr_size <= 0) {
274 - pr_err("ps3vram: lv1_gpu_memory_allocate failed\n");
275 + dev_err(&dev->core, "%s:%d: lv1_gpu_memory_allocate failed\n",
276 + __func__, __LINE__);
278 goto out_free_xdr_buf;
280 - pr_info("ps3vram: allocated %u MiB of DDR memory\n",
281 - (unsigned int) (ddr_size / 1024 / 1024));
283 /* Request context */
284 status = lv1_gpu_context_allocate(priv->memory_handle,
285 @@ -602,7 +613,8 @@ static int __devinit ps3vram_probe(struct ps3_system_bus_device *dev)
289 - pr_err("ps3vram: lv1_gpu_context_allocate failed\n");
290 + dev_err(&dev->core, "%s:%d: lv1_gpu_context_allocate failed\n",
291 + __func__, __LINE__);
293 goto out_free_memory;
295 @@ -612,28 +624,32 @@ static int __devinit ps3vram_probe(struct ps3_system_bus_device *dev)
296 ps3_mm_phys_to_lpar(__pa(priv->xdr_buf)),
299 - pr_err("ps3vram: lv1_gpu_context_iomap failed\n");
300 + dev_err(&dev->core, "%s:%d: lv1_gpu_context_iomap failed\n",
301 + __func__, __LINE__);
303 goto out_free_context;
306 priv->base = ioremap(ddr_lpar, ddr_size);
308 - pr_err("ps3vram: ioremap failed\n");
309 + dev_err(&dev->core, "%s:%d: ioremap failed\n", __func__,
312 goto out_free_context;
315 priv->ctrl = ioremap(ctrl_lpar, 64 * 1024);
317 - pr_err("ps3vram: ioremap failed\n");
318 + dev_err(&dev->core, "%s:%d: ioremap failed\n", __func__,
324 priv->reports = ioremap(reports_lpar, reports_size);
325 if (!priv->reports) {
326 - pr_err("ps3vram: ioremap failed\n");
327 + dev_err(&dev->core, "%s:%d: ioremap failed\n", __func__,
332 @@ -661,7 +677,8 @@ static int __devinit ps3vram_probe(struct ps3_system_bus_device *dev)
333 ret = ps3vram_wait_ring(&ps3vram_mtd, 100);
334 mutex_unlock(&ps3_gpu_mutex);
336 - pr_err("failed to initialize channels\n");
337 + dev_err(&dev->core, "%s:%d: failed to initialize channels\n",
338 + __func__, __LINE__);
340 goto out_unmap_reports;
342 @@ -669,12 +686,15 @@ static int __devinit ps3vram_probe(struct ps3_system_bus_device *dev)
343 ps3vram_cache_init(&ps3vram_mtd);
345 if (add_mtd_device(&ps3vram_mtd)) {
346 - pr_err("ps3vram: failed to register device\n");
347 + dev_err(&dev->core, "%s:%d: add_mtd_device failed\n",
348 + __func__, __LINE__);
350 goto out_cache_cleanup;
353 - pr_info("ps3vram mtd device registered, %lu bytes\n", ddr_size);
354 + dev_info(&dev->core, "reserved %u MiB of gpu memory\n",
355 + (unsigned int)(ddr_size / 1024 / 1024));