1 From 9b82f3e61758ed897200f0244b63a77c1791bcba Mon Sep 17 00:00:00 2001
2 From: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
3 Date: Thu, 30 Oct 2008 08:12:58 +0000
4 Subject: [PATCH] powerpc/ps3: Replace the flip_ctl logic in ps3av and ps3fb by a mutex
6 Introduce ps3_gpu_mutex to synchronizes GPU-related operations, like:
7 - invoking the L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT command using the
8 lv1_gpu_context_attribute() hypervisor call,
9 - handling the PS3AV_CID_AVB_PARAM packet in the PS3 A/V Settings driver.
11 Signed-off-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
12 Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>
13 Signed-off-by: Paul Mackerras <paulus@samba.org>
15 arch/powerpc/include/asm/ps3.h | 3 +++
16 arch/powerpc/include/asm/ps3av.h | 4 ----
17 arch/powerpc/platforms/ps3/setup.c | 4 ++++
18 drivers/ps3/ps3av.c | 20 --------------------
19 drivers/ps3/ps3av_cmd.c | 4 ++--
20 drivers/video/ps3fb.c | 17 +++++------------
21 6 files changed, 14 insertions(+), 38 deletions(-)
23 diff --git a/arch/powerpc/include/asm/ps3.h b/arch/powerpc/include/asm/ps3.h
24 index f9e34c4..4299365 100644
25 --- a/arch/powerpc/include/asm/ps3.h
26 +++ b/arch/powerpc/include/asm/ps3.h
27 @@ -516,4 +516,7 @@ void ps3_sync_irq(int node);
28 u32 ps3_get_hw_thread_id(int cpu);
29 u64 ps3_get_spe_id(void *arg);
31 +/* mutex synchronizing GPU accesses and video mode changes */
32 +extern struct mutex ps3_gpu_mutex;
35 diff --git a/arch/powerpc/include/asm/ps3av.h b/arch/powerpc/include/asm/ps3av.h
36 index 5aa22cf..cd24ac1 100644
37 --- a/arch/powerpc/include/asm/ps3av.h
38 +++ b/arch/powerpc/include/asm/ps3av.h
39 @@ -740,8 +740,4 @@ extern int ps3av_audio_mute(int);
40 extern int ps3av_audio_mute_analog(int);
41 extern int ps3av_dev_open(void);
42 extern int ps3av_dev_close(void);
43 -extern void ps3av_register_flip_ctl(void (*flip_ctl)(int on, void *data),
45 -extern void ps3av_flip_ctl(int on);
47 #endif /* _ASM_POWERPC_PS3AV_H_ */
48 diff --git a/arch/powerpc/platforms/ps3/setup.c b/arch/powerpc/platforms/ps3/setup.c
49 index 77bc330..bfc33fb 100644
50 --- a/arch/powerpc/platforms/ps3/setup.c
51 +++ b/arch/powerpc/platforms/ps3/setup.c
56 +/* mutex synchronizing GPU accesses and video mode changes */
57 +DEFINE_MUTEX(ps3_gpu_mutex);
58 +EXPORT_SYMBOL_GPL(ps3_gpu_mutex);
60 #if !defined(CONFIG_SMP)
61 static void smp_send_stop(void) {}
63 diff --git a/drivers/ps3/ps3av.c b/drivers/ps3/ps3av.c
64 index 06848b2..5324978 100644
65 --- a/drivers/ps3/ps3av.c
66 +++ b/drivers/ps3/ps3av.c
67 @@ -59,8 +59,6 @@ static struct ps3av {
68 struct ps3av_reply_hdr reply_hdr;
69 u8 raw[PS3AV_BUF_SIZE];
71 - void (*flip_ctl)(int on, void *data);
76 @@ -939,24 +937,6 @@ int ps3av_audio_mute(int mute)
78 EXPORT_SYMBOL_GPL(ps3av_audio_mute);
80 -void ps3av_register_flip_ctl(void (*flip_ctl)(int on, void *data),
83 - mutex_lock(&ps3av->mutex);
84 - ps3av->flip_ctl = flip_ctl;
85 - ps3av->flip_data = flip_data;
86 - mutex_unlock(&ps3av->mutex);
88 -EXPORT_SYMBOL_GPL(ps3av_register_flip_ctl);
90 -void ps3av_flip_ctl(int on)
92 - mutex_lock(&ps3av->mutex);
93 - if (ps3av->flip_ctl)
94 - ps3av->flip_ctl(on, ps3av->flip_data);
95 - mutex_unlock(&ps3av->mutex);
98 static int ps3av_probe(struct ps3_system_bus_device *dev)
101 diff --git a/drivers/ps3/ps3av_cmd.c b/drivers/ps3/ps3av_cmd.c
102 index 11eb503..716596e 100644
103 --- a/drivers/ps3/ps3av_cmd.c
104 +++ b/drivers/ps3/ps3av_cmd.c
105 @@ -864,7 +864,7 @@ int ps3av_cmd_avb_param(struct ps3av_pkt_avb_param *avb, u32 send_len)
109 - ps3av_flip_ctl(0); /* flip off */
110 + mutex_lock(&ps3_gpu_mutex);
113 res = ps3av_do_pkt(PS3AV_CID_AVB_PARAM, send_len, sizeof(*avb),
114 @@ -878,7 +878,7 @@ int ps3av_cmd_avb_param(struct ps3av_pkt_avb_param *avb, u32 send_len)
118 - ps3av_flip_ctl(1); /* flip on */
119 + mutex_unlock(&ps3_gpu_mutex);
123 diff --git a/drivers/video/ps3fb.c b/drivers/video/ps3fb.c
124 index 4b5d807..bd3e39b 100644
125 --- a/drivers/video/ps3fb.c
126 +++ b/drivers/video/ps3fb.c
127 @@ -460,12 +460,16 @@ static void ps3fb_sync_image(struct device *dev, u64 frame_offset,
128 line_length |= (u64)src_line_length << 32;
130 src_offset += GPU_FB_START;
132 + mutex_lock(&ps3_gpu_mutex);
133 status = lv1_gpu_context_attribute(ps3fb.context_handle,
134 L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT,
135 dst_offset, GPU_IOIF + src_offset,
136 L1GPU_FB_BLIT_WAIT_FOR_COMPLETION |
137 (width << 16) | height,
139 + mutex_unlock(&ps3_gpu_mutex);
143 "%s: lv1_gpu_context_attribute FB_BLIT failed: %d\n",
144 @@ -784,15 +788,6 @@ static int ps3fb_wait_for_vsync(u32 crtc)
148 -static void ps3fb_flip_ctl(int on, void *data)
150 - struct ps3fb_priv *priv = data;
152 - atomic_dec_if_positive(&priv->ext_flip);
154 - atomic_inc(&priv->ext_flip);
160 @@ -1228,7 +1223,6 @@ static int __devinit ps3fb_probe(struct ps3_system_bus_device *dev)
164 - ps3av_register_flip_ctl(ps3fb_flip_ctl, &ps3fb);
168 @@ -1258,10 +1252,9 @@ static int ps3fb_shutdown(struct ps3_system_bus_device *dev)
170 dev_dbg(&dev->core, " -> %s:%d\n", __func__, __LINE__);
172 - ps3fb_flip_ctl(0, &ps3fb); /* flip off */
173 + atomic_inc(&ps3fb.ext_flip); /* flip off */
174 ps3fb.dinfo->irq.mask = 0;
176 - ps3av_register_flip_ctl(NULL, NULL);
178 struct task_struct *task = ps3fb.task;