aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/linux/linux-omap-pm/dss2/0119-DSS2-OMAPFB-remove-unneeded-locks.patch
blob: 2b0ba2da78130ab87aad8f4d74b60aa662a033c9 (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
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
From 995d5a236d8b1f7fe24da9dcacb1e89c214afdba Mon Sep 17 00:00:00 2001
From: Tomi Valkeinen <tomi.valkeinen@nokia.com>
Date: Tue, 16 Jun 2009 14:33:07 +0300
Subject: [PATCH 119/146] DSS2: OMAPFB: remove unneeded locks

omapfb_lock() locks the whole omapfb device, meaning all framebuffers.
Usually it is enough to lock only the framebuffer that is being
manipulated, and for IOCTLs the fb framework does this already.

Thus, we can remove many omapfb_lock()s totally, and change some
to lock_fb_info().

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@nokia.com>
---
 drivers/video/omap2/omapfb/omapfb-ioctl.c |   47 ++--------------------------
 drivers/video/omap2/omapfb/omapfb-main.c  |    5 ---
 drivers/video/omap2/omapfb/omapfb-sysfs.c |   32 ++++++++++++-------
 3 files changed, 24 insertions(+), 60 deletions(-)

diff --git a/drivers/video/omap2/omapfb/omapfb-ioctl.c b/drivers/video/omap2/omapfb/omapfb-ioctl.c
index c513fe0..91308c2 100644
--- a/drivers/video/omap2/omapfb/omapfb-ioctl.c
+++ b/drivers/video/omap2/omapfb/omapfb-ioctl.c
@@ -44,8 +44,6 @@ static int omapfb_setup_plane(struct fb_info *fbi, struct omapfb_plane_info *pi)
 
 	DBG("omapfb_setup_plane\n");
 
-	omapfb_lock(fbdev);
-
 	if (ofbi->num_overlays != 1) {
 		r = -EINVAL;
 		goto out;
@@ -94,7 +92,6 @@ static int omapfb_setup_plane(struct fb_info *fbi, struct omapfb_plane_info *pi)
 	}
 
 out:
-	omapfb_unlock(fbdev);
 	if (r)
 		dev_err(fbdev->dev, "setup_plane failed\n");
 	return r;
@@ -103,9 +100,6 @@ out:
 static int omapfb_query_plane(struct fb_info *fbi, struct omapfb_plane_info *pi)
 {
 	struct omapfb_info *ofbi = FB2OFB(fbi);
-	struct omapfb2_device *fbdev = ofbi->fbdev;
-
-	omapfb_lock(fbdev);
 
 	if (ofbi->num_overlays != 1) {
 		memset(pi, 0, sizeof(*pi));
@@ -125,8 +119,6 @@ static int omapfb_query_plane(struct fb_info *fbi, struct omapfb_plane_info *pi)
 		pi->out_height = ovli->out_height;
 	}
 
-	omapfb_unlock(fbdev);
-
 	return 0;
 }
 
@@ -145,43 +137,32 @@ static int omapfb_setup_mem(struct fb_info *fbi, struct omapfb_mem_info *mi)
 
 	rg = &ofbi->region;
 
-	omapfb_lock(fbdev);
-
 	for (i = 0; i < ofbi->num_overlays; i++) {
-		if (ofbi->overlays[i]->info.enabled) {
-			r = -EBUSY;
-			goto out;
-		}
+		if (ofbi->overlays[i]->info.enabled)
+			return -EBUSY;
 	}
 
 	if (rg->size != size || rg->type != mi->type) {
 		r = omapfb_realloc_fbmem(fbi, size, mi->type);
 		if (r) {
 			dev_err(fbdev->dev, "realloc fbmem failed\n");
-			goto out;
+			return r;
 		}
 	}
 
-	r = 0;
-out:
-	omapfb_unlock(fbdev);
-
-	return r;
+	return 0;
 }
 
 static int omapfb_query_mem(struct fb_info *fbi, struct omapfb_mem_info *mi)
 {
 	struct omapfb_info *ofbi = FB2OFB(fbi);
-	struct omapfb2_device *fbdev = ofbi->fbdev;
 	struct omapfb2_mem_region *rg;
 
 	rg = &ofbi->region;
 	memset(mi, 0, sizeof(*mi));
 
-	omapfb_lock(fbdev);
 	mi->size = rg->size;
 	mi->type = rg->type;
-	omapfb_unlock(fbdev);
 
 	return 0;
 }
@@ -189,8 +170,6 @@ static int omapfb_query_mem(struct fb_info *fbi, struct omapfb_mem_info *mi)
 static int omapfb_update_window(struct fb_info *fbi,
 		u32 x, u32 y, u32 w, u32 h)
 {
-	struct omapfb_info *ofbi = FB2OFB(fbi);
-	struct omapfb2_device *fbdev = ofbi->fbdev;
 	struct omap_dss_device *display = fb2display(fbi);
 	u16 dw, dh;
 
@@ -205,9 +184,7 @@ static int omapfb_update_window(struct fb_info *fbi,
 	if (x + w > dw || y + h > dh)
 		return -EINVAL;
 
-	omapfb_lock(fbdev);
 	display->update(display, x, y, w, h);
-	omapfb_unlock(fbdev);
 
 	return 0;
 }
@@ -215,8 +192,6 @@ static int omapfb_update_window(struct fb_info *fbi,
 static int omapfb_set_update_mode(struct fb_info *fbi,
 				   enum omapfb_update_mode mode)
 {
-	struct omapfb_info *ofbi = FB2OFB(fbi);
-	struct omapfb2_device *fbdev = ofbi->fbdev;
 	struct omap_dss_device *display = fb2display(fbi);
 	enum omap_dss_update_mode um;
 	int r;
@@ -241,9 +216,7 @@ static int omapfb_set_update_mode(struct fb_info *fbi,
 		return -EINVAL;
 	}
 
-	omapfb_lock(fbdev);
 	r = display->set_update_mode(display, um);
-	omapfb_unlock(fbdev);
 
 	return r;
 }
@@ -251,17 +224,13 @@ static int omapfb_set_update_mode(struct fb_info *fbi,
 static int omapfb_get_update_mode(struct fb_info *fbi,
 		enum omapfb_update_mode *mode)
 {
-	struct omapfb_info *ofbi = FB2OFB(fbi);
-	struct omapfb2_device *fbdev = ofbi->fbdev;
 	struct omap_dss_device *display = fb2display(fbi);
 	enum omap_dss_update_mode m;
 
 	if (!display || !display->get_update_mode)
 		return -EINVAL;
 
-	omapfb_lock(fbdev);
 	m = display->get_update_mode(display);
-	omapfb_unlock(fbdev);
 
 	switch (m) {
 	case OMAP_DSS_UPDATE_DISABLED:
@@ -396,8 +365,6 @@ static int omapfb_memory_read(struct fb_info *fbi,
 		struct omapfb_memory_read *mr)
 {
 	struct omap_dss_device *display = fb2display(fbi);
-	struct omapfb_info *ofbi = FB2OFB(fbi);
-	struct omapfb2_device *fbdev = ofbi->fbdev;
 	void *buf;
 	int r;
 
@@ -416,8 +383,6 @@ static int omapfb_memory_read(struct fb_info *fbi,
 		return -ENOMEM;
 	}
 
-	omapfb_lock(fbdev);
-
 	r = display->memory_read(display, buf, mr->buffer_size,
 			mr->x, mr->y, mr->w, mr->h);
 
@@ -428,8 +393,6 @@ static int omapfb_memory_read(struct fb_info *fbi,
 
 	vfree(buf);
 
-	omapfb_unlock(fbdev);
-
 	return r;
 }
 
@@ -509,9 +472,7 @@ int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg)
 			break;
 		}
 
-		omapfb_lock(fbdev);
 		r = display->sync(display);
-		omapfb_unlock(fbdev);
 		break;
 
 	case OMAPFB_UPDATE_WINDOW_OLD:
diff --git a/drivers/video/omap2/omapfb/omapfb-main.c b/drivers/video/omap2/omapfb/omapfb-main.c
index dc9c06c..1473581 100644
--- a/drivers/video/omap2/omapfb/omapfb-main.c
+++ b/drivers/video/omap2/omapfb/omapfb-main.c
@@ -848,13 +848,10 @@ static int omapfb_pan_display(struct fb_var_screeninfo *var,
 		struct fb_info *fbi)
 {
 	struct omapfb_info *ofbi = FB2OFB(fbi);
-	struct omapfb2_device *fbdev = ofbi->fbdev;
 	int r = 0;
 
 	DBG("pan_display(%d)\n", ofbi->id);
 
-	omapfb_lock(fbdev);
-
 	if (var->xoffset != fbi->var.xoffset ||
 	    var->yoffset != fbi->var.yoffset) {
 		struct fb_var_screeninfo new_var;
@@ -872,8 +869,6 @@ static int omapfb_pan_display(struct fb_var_screeninfo *var,
 		}
 	}
 
-	omapfb_unlock(fbdev);
-
 	return r;
 }
 
diff --git a/drivers/video/omap2/omapfb/omapfb-sysfs.c b/drivers/video/omap2/omapfb/omapfb-sysfs.c
index a00f61a..ef30e0e 100644
--- a/drivers/video/omap2/omapfb/omapfb-sysfs.c
+++ b/drivers/video/omap2/omapfb/omapfb-sysfs.c
@@ -49,7 +49,6 @@ static ssize_t store_rotate_type(struct device *dev,
 {
 	struct fb_info *fbi = dev_get_drvdata(dev);
 	struct omapfb_info *ofbi = FB2OFB(fbi);
-	struct omapfb2_device *fbdev = ofbi->fbdev;
 	enum omap_dss_rotation_type rot_type;
 	int r;
 
@@ -58,7 +57,7 @@ static ssize_t store_rotate_type(struct device *dev,
 	if (rot_type != OMAP_DSS_ROT_DMA && rot_type != OMAP_DSS_ROT_VRFB)
 		return -EINVAL;
 
-	omapfb_lock(fbdev);
+	lock_fb_info(fbi);
 
 	r = 0;
 	if (rot_type == ofbi->rotation_type)
@@ -76,7 +75,7 @@ static ssize_t store_rotate_type(struct device *dev,
 	 * need to do any further parameter checking at this point.
 	 */
 out:
-	omapfb_unlock(fbdev);
+	unlock_fb_info(fbi);
 
 	return r ? r : count;
 }
@@ -97,7 +96,6 @@ static ssize_t store_mirror(struct device *dev,
 {
 	struct fb_info *fbi = dev_get_drvdata(dev);
 	struct omapfb_info *ofbi = FB2OFB(fbi);
-	struct omapfb2_device *fbdev = ofbi->fbdev;
 	bool mirror;
 	int r;
 	struct fb_var_screeninfo new_var;
@@ -107,7 +105,7 @@ static ssize_t store_mirror(struct device *dev,
 	if (mirror != 0 && mirror != 1)
 		return -EINVAL;
 
-	omapfb_lock(fbdev);
+	lock_fb_info(fbi);
 
 	ofbi->mirror = mirror;
 
@@ -125,7 +123,7 @@ static ssize_t store_mirror(struct device *dev,
 
 	r = count;
 out:
-	omapfb_unlock(fbdev);
+	unlock_fb_info(fbi);
 
 	return r;
 }
@@ -139,6 +137,9 @@ static ssize_t show_overlays(struct device *dev,
 	ssize_t l = 0;
 	int t;
 
+	omapfb_lock(fbdev);
+	lock_fb_info(fbi);
+
 	for (t = 0; t < ofbi->num_overlays; t++) {
 		struct omap_overlay *ovl = ofbi->overlays[t];
 		int ovlnum;
@@ -153,6 +154,9 @@ static ssize_t show_overlays(struct device *dev,
 
 	l += snprintf(buf + l, PAGE_SIZE - l, "\n");
 
+	unlock_fb_info(fbi);
+	omapfb_unlock(fbdev);
+
 	return l;
 }
 
@@ -192,6 +196,7 @@ static ssize_t store_overlays(struct device *dev, struct device_attribute *attr,
 		len = len - 1;
 
 	omapfb_lock(fbdev);
+	lock_fb_info(fbi);
 
 	if (len > 0) {
 		char *p = (char *)buf;
@@ -298,6 +303,7 @@ static ssize_t store_overlays(struct device *dev, struct device_attribute *attr,
 
 	r = count;
 out:
+	unlock_fb_info(fbi);
 	omapfb_unlock(fbdev);
 
 	return r;
@@ -311,6 +317,8 @@ static ssize_t show_overlays_rotate(struct device *dev,
 	ssize_t l = 0;
 	int t;
 
+	lock_fb_info(fbi);
+
 	for (t = 0; t < ofbi->num_overlays; t++) {
 		l += snprintf(buf + l, PAGE_SIZE - l, "%s%d",
 				t == 0 ? "" : ",", ofbi->rotation[t]);
@@ -318,6 +326,8 @@ static ssize_t show_overlays_rotate(struct device *dev,
 
 	l += snprintf(buf + l, PAGE_SIZE - l, "\n");
 
+	unlock_fb_info(fbi);
+
 	return l;
 }
 
@@ -326,7 +336,6 @@ static ssize_t store_overlays_rotate(struct device *dev,
 {
 	struct fb_info *fbi = dev_get_drvdata(dev);
 	struct omapfb_info *ofbi = FB2OFB(fbi);
-	struct omapfb2_device *fbdev = ofbi->fbdev;
 	int num_ovls = 0, r, i;
 	int len;
 	bool changed = false;
@@ -336,7 +345,7 @@ static ssize_t store_overlays_rotate(struct device *dev,
 	if (buf[len - 1] == '\n')
 		len = len - 1;
 
-	omapfb_lock(fbdev);
+	lock_fb_info(fbi);
 
 	if (len > 0) {
 		char *p = (char *)buf;
@@ -382,7 +391,7 @@ static ssize_t store_overlays_rotate(struct device *dev,
 
 	r = count;
 out:
-	omapfb_unlock(fbdev);
+	unlock_fb_info(fbi);
 
 	return r;
 }
@@ -401,14 +410,13 @@ static ssize_t store_size(struct device *dev, struct device_attribute *attr,
 {
 	struct fb_info *fbi = dev_get_drvdata(dev);
 	struct omapfb_info *ofbi = FB2OFB(fbi);
-	struct omapfb2_device *fbdev = ofbi->fbdev;
 	unsigned long size;
 	int r;
 	int i;
 
 	size = PAGE_ALIGN(simple_strtoul(buf, NULL, 0));
 
-	omapfb_lock(fbdev);
+	lock_fb_info(fbi);
 
 	for (i = 0; i < ofbi->num_overlays; i++) {
 		if (ofbi->overlays[i]->info.enabled) {
@@ -427,7 +435,7 @@ static ssize_t store_size(struct device *dev, struct device_attribute *attr,
 
 	r = count;
 out:
-	omapfb_unlock(fbdev);
+	unlock_fb_info(fbi);
 
 	return r;
 }
-- 
1.6.2.4