[brcm63xx] fix typo, INT_MASK is writable, INT_STATUS is not
[openwrt.git] / target / linux / ps3 / patches-2.6.28 / 0010-mtd-ps3vram-Cleanup-ps3vram-driver-messages.patch
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
5
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.
8 where appropriate.
9
10 Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>
11 Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12 ---
13 drivers/mtd/devices/ps3vram.c | 116 ++++++++++++++++++++++++-----------------
14 1 files changed, 68 insertions(+), 48 deletions(-)
15
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
23
24 -#define dbg(fmt, args...) \
25 - pr_debug("%s:%d " fmt "\n", __func__, __LINE__, ## args)
26 -
27 struct ps3vram_tag {
28 unsigned int address;
29 unsigned int flags;
30 @@ -78,6 +75,7 @@ struct ps3vram_priv {
31 uint32_t *fifo_base;
32 uint32_t *fifo_ptr;
33
34 + struct device *dev;
35 struct ps3vram_cache cache;
36
37 /* Used to serialize cache/DMA operations */
38 @@ -148,8 +146,9 @@ static int ps3vram_wait_ring(struct mtd_info *mtd, int timeout)
39 udelay(1);
40 }
41 if (timeout == 0) {
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]);
47 return -ETIMEDOUT;
48 }
49
50 @@ -181,7 +180,8 @@ static void ps3vram_rewind_ring(struct mtd_info *mtd)
51 L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT,
52 0, 0, 0, 0);
53 if (status)
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__);
57
58 priv->fifo_ptr = priv->fifo_base;
59 }
60 @@ -201,11 +201,13 @@ static void ps3vram_fire_ring(struct mtd_info *mtd)
61 L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT,
62 0, 0, 0, 0);
63 if (status)
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__);
67
68 if ((priv->fifo_ptr - priv->fifo_base) * sizeof(uint32_t) >
69 FIFO_SIZE - 1024) {
70 - dbg("fifo full, rewinding");
71 + dev_dbg(priv->dev, "%s:%d: fifo full, rewinding\n", __func__,
72 + __LINE__);
73 ps3vram_wait_ring(mtd, 200);
74 ps3vram_rewind_ring(mtd);
75 }
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__,
82 + __LINE__);
83 return -1;
84 }
85
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__,
92 + __LINE__);
93 return -1;
94 }
95
96 @@ -302,16 +306,17 @@ static void ps3vram_cache_evict(struct mtd_info *mtd, int entry)
97 struct ps3vram_cache *cache = &priv->cache;
98
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,
106 DMA_PAGE_SIZE,
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,
111 - cache->page_size);
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);
116 }
117 cache->tags[entry].flags &= ~CACHE_PAGE_DIRTY;
118 }
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;
122
123 - dbg("fetching %d : 0x%08x", entry, address);
124 + dev_dbg(priv->dev, "%s:%d: fetching %d : 0x%08x\n", __func__, __LINE__,
125 + entry, address);
126 if (ps3vram_download(mtd,
127 address,
128 CACHE_OFFSET + entry * cache->page_size,
129 DMA_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",
132 - address,
133 - entry * cache->page_size,
134 - 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);
138 }
139
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;
143 int i;
144
145 - dbg("FLUSH");
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);
158 return i;
159 }
160 }
161
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);
166
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)
170 {
171 struct ps3vram_priv *priv = mtd->priv;
172
173 - pr_info("creating cache: %d entries, %d bytes pages\n",
174 - CACHE_PAGE_COUNT, CACHE_PAGE_SIZE);
175 -
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__);
184 return -ENOMEM;
185 }
186
187 + dev_info(priv->dev, "created ram cache: %d entries, %d KiB each\n",
188 + CACHE_PAGE_COUNT, CACHE_PAGE_SIZE / 1024);
189 +
190 return 0;
191 }
192
193 @@ -434,14 +440,14 @@ static int ps3vram_erase(struct mtd_info *mtd, struct erase_info *instr)
194 return 0;
195 }
196
197 -
198 static int ps3vram_read(struct mtd_info *mtd, loff_t from, size_t len,
199 size_t *retlen, u_char *buf)
200 {
201 struct ps3vram_priv *priv = mtd->priv;
202 unsigned int cached, count;
203
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);
207
208 if (from >= mtd->size)
209 return -EINVAL;
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;
213
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);
219
220 if (avail > count)
221 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;
225
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);
231
232 if (avail > count)
233 avail = count;
234 @@ -544,12 +552,14 @@ static int __devinit ps3vram_probe(struct ps3_system_bus_device *dev)
235 priv = ps3vram_mtd.priv;
236
237 mutex_init(&priv->lock);
238 + priv->dev = &dev->core;
239
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__);
247 ret = -ENOMEM;
248 goto out_free_priv;
249 }
250 @@ -560,7 +570,8 @@ static int __devinit ps3vram_probe(struct ps3_system_bus_device *dev)
251
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__);
257 ret = -EAGAIN;
258 goto out_close_gpu;
259 }
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);
263 if (ddr_size <= 0) {
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__);
267 ret = -EINVAL;
268 goto out_close_gpu;
269 }
270 @@ -586,12 +598,11 @@ static int __devinit ps3vram_probe(struct ps3_system_bus_device *dev)
271 ddr_size -= 1024*1024;
272 }
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__);
277 ret = -ENOMEM;
278 goto out_free_xdr_buf;
279 }
280 - pr_info("ps3vram: allocated %u MiB of DDR memory\n",
281 - (unsigned int) (ddr_size / 1024 / 1024));
282
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)
286 &reports_lpar,
287 &reports_size);
288 if (status) {
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__);
292 ret = -ENOMEM;
293 goto out_free_memory;
294 }
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)),
297 XDR_BUF_SIZE, 0);
298 if (status) {
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__);
302 ret = -ENOMEM;
303 goto out_free_context;
304 }
305
306 priv->base = ioremap(ddr_lpar, ddr_size);
307 if (!priv->base) {
308 - pr_err("ps3vram: ioremap failed\n");
309 + dev_err(&dev->core, "%s:%d: ioremap failed\n", __func__,
310 + __LINE__);
311 ret = -ENOMEM;
312 goto out_free_context;
313 }
314
315 priv->ctrl = ioremap(ctrl_lpar, 64 * 1024);
316 if (!priv->ctrl) {
317 - pr_err("ps3vram: ioremap failed\n");
318 + dev_err(&dev->core, "%s:%d: ioremap failed\n", __func__,
319 + __LINE__);
320 ret = -ENOMEM;
321 goto out_unmap_vram;
322 }
323
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__,
328 + __LINE__);
329 ret = -ENOMEM;
330 goto out_unmap_ctrl;
331 }
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);
335 if (ret < 0) {
336 - pr_err("failed to initialize channels\n");
337 + dev_err(&dev->core, "%s:%d: failed to initialize channels\n",
338 + __func__, __LINE__);
339 ret = -ETIMEDOUT;
340 goto out_unmap_reports;
341 }
342 @@ -669,12 +686,15 @@ static int __devinit ps3vram_probe(struct ps3_system_bus_device *dev)
343 ps3vram_cache_init(&ps3vram_mtd);
344
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__);
349 ret = -EAGAIN;
350 goto out_cache_cleanup;
351 }
352
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));
356 +
357 return 0;
358
359 out_cache_cleanup:
360 --
361 1.6.0.4
362
This page took 0.062927 seconds and 5 git commands to generate.