summaryrefslogtreecommitdiffstats
path: root/target/linux/ps3/patches-2.6.28/0010-mtd-ps3vram-Cleanup-ps3vram-driver-messages.patch
blob: 91eb765724c6920404d7ba6d594963d809138e7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
From f259d74e030faab15b95fb4bb56d7f424773c278 Mon Sep 17 00:00:00 2001
From: Geoff Levand <geoffrey.levand@am.sony.com>
Date: Tue, 6 Jan 2009 11:32:21 +0000
Subject: [PATCH] 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>
---
 drivers/mtd/devices/ps3vram.c |  116 ++++++++++++++++++++++++-----------------
 1 files changed, 68 insertions(+), 48 deletions(-)

diff --git a/drivers/mtd/devices/ps3vram.c b/drivers/mtd/devices/ps3vram.c
index 18ca521..f5cc290 100644
--- a/drivers/mtd/devices/ps3vram.c
+++ b/drivers/mtd/devices/ps3vram.c
@@ -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_info *mtd, int timeout)
 		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 mtd_info *mtd)
 					   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;
 }
@@ -201,11 +201,13 @@ static void ps3vram_fire_ring(struct mtd_info *mtd)
 					   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);
 	}
@@ -258,7 +260,8 @@ static int ps3vram_upload(struct mtd_info *mtd, unsigned int src_offset,
 	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;
 	}
 
@@ -289,7 +292,8 @@ static int ps3vram_download(struct mtd_info *mtd, unsigned int src_offset,
 	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;
 	}
 
@@ -302,16 +306,17 @@ static void ps3vram_cache_evict(struct mtd_info *mtd, int entry)
 	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;
 	}
@@ -323,16 +328,16 @@ static void ps3vram_cache_load(struct mtd_info *mtd, int entry,
 	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;
@@ -346,7 +351,7 @@ static void ps3vram_cache_flush(struct mtd_info *mtd)
 	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;
@@ -369,15 +374,15 @@ static unsigned int ps3vram_cache_match(struct mtd_info *mtd, loff_t address)
 	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_info *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_info *mtd, struct erase_info *instr)
 	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;
@@ -463,8 +469,9 @@ static int ps3vram_read(struct mtd_info *mtd, loff_t from, size_t len,
 		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 *mtd, loff_t to, size_t len,
 		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(struct ps3_system_bus_device *dev)
 	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(struct ps3_system_bus_device *dev)
 
 	/* 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(struct ps3_system_bus_device *dev)
 		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(struct ps3_system_bus_device *dev)
 		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(struct ps3_system_bus_device *dev)
 					  &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(struct ps3_system_bus_device *dev)
 				       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;
 	}
@@ -661,7 +677,8 @@ static int __devinit ps3vram_probe(struct ps3_system_bus_device *dev)
 	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(struct ps3_system_bus_device *dev)
 	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:
-- 
1.6.0.4