]>
Commit | Line | Data |
---|---|---|
2cb7cef9 BS |
1 | From: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com> |
2 | Subject: Introduce ps3_gpu_mutex | |
3 | ||
4 | Introduce ps3_gpu_mutex to synchronizes GPU-related operations, like: | |
5 | - invoking the L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT command using the | |
6 | lv1_gpu_context_attribute() hypervisor call, | |
7 | - handling the PS3AV_CID_AVB_PARAM packet in the PS3 A/V Settings driver. | |
8 | ||
9 | Signed-off-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com> | |
10 | Signed-off-by: Stefan Assmann <sassmann@suse.de> | |
11 | --- | |
12 | arch/powerpc/include/asm/ps3.h | 3 +++ | |
13 | arch/powerpc/include/asm/ps3av.h | 3 --- | |
14 | arch/powerpc/platforms/ps3/setup.c | 4 ++++ | |
15 | drivers/ps3/ps3av.c | 20 -------------------- | |
16 | drivers/ps3/ps3av_cmd.c | 4 ++-- | |
17 | drivers/video/ps3fb.c | 17 +++++------------ | |
18 | 6 files changed, 14 insertions(+), 37 deletions(-) | |
19 | ||
20 | --- a/arch/powerpc/include/asm/ps3.h | |
21 | +++ b/arch/powerpc/include/asm/ps3.h | |
22 | @@ -516,4 +516,7 @@ void ps3_sync_irq(int node); | |
23 | u32 ps3_get_hw_thread_id(int cpu); | |
24 | u64 ps3_get_spe_id(void *arg); | |
25 | ||
26 | +/* mutex synchronizing GPU accesses and video mode changes */ | |
27 | +extern struct mutex ps3_gpu_mutex; | |
28 | + | |
29 | #endif | |
30 | --- a/arch/powerpc/include/asm/ps3av.h | |
31 | +++ b/arch/powerpc/include/asm/ps3av.h | |
32 | @@ -740,8 +740,5 @@ extern int ps3av_audio_mute(int); | |
33 | extern int ps3av_audio_mute_analog(int); | |
34 | extern int ps3av_dev_open(void); | |
35 | extern int ps3av_dev_close(void); | |
36 | -extern void ps3av_register_flip_ctl(void (*flip_ctl)(int on, void *data), | |
37 | - void *flip_data); | |
38 | -extern void ps3av_flip_ctl(int on); | |
39 | ||
40 | #endif /* _ASM_POWERPC_PS3AV_H_ */ | |
41 | --- a/arch/powerpc/platforms/ps3/setup.c | |
42 | +++ b/arch/powerpc/platforms/ps3/setup.c | |
43 | @@ -42,6 +42,10 @@ | |
44 | #define DBG pr_debug | |
45 | #endif | |
46 | ||
47 | +/* mutex synchronizing GPU accesses and video mode changes */ | |
48 | +DEFINE_MUTEX(ps3_gpu_mutex); | |
49 | +EXPORT_SYMBOL_GPL(ps3_gpu_mutex); | |
50 | + | |
51 | #if !defined(CONFIG_SMP) | |
52 | static void smp_send_stop(void) {} | |
53 | #endif | |
54 | --- a/drivers/ps3/ps3av.c | |
55 | +++ b/drivers/ps3/ps3av.c | |
56 | @@ -59,8 +59,6 @@ static struct ps3av { | |
57 | struct ps3av_reply_hdr reply_hdr; | |
58 | u8 raw[PS3AV_BUF_SIZE]; | |
59 | } recv_buf; | |
60 | - void (*flip_ctl)(int on, void *data); | |
61 | - void *flip_data; | |
62 | } *ps3av; | |
63 | ||
64 | /* color space */ | |
65 | @@ -939,24 +937,6 @@ int ps3av_audio_mute(int mute) | |
66 | ||
67 | EXPORT_SYMBOL_GPL(ps3av_audio_mute); | |
68 | ||
69 | -void ps3av_register_flip_ctl(void (*flip_ctl)(int on, void *data), | |
70 | - void *flip_data) | |
71 | -{ | |
72 | - mutex_lock(&ps3av->mutex); | |
73 | - ps3av->flip_ctl = flip_ctl; | |
74 | - ps3av->flip_data = flip_data; | |
75 | - mutex_unlock(&ps3av->mutex); | |
76 | -} | |
77 | -EXPORT_SYMBOL_GPL(ps3av_register_flip_ctl); | |
78 | - | |
79 | -void ps3av_flip_ctl(int on) | |
80 | -{ | |
81 | - mutex_lock(&ps3av->mutex); | |
82 | - if (ps3av->flip_ctl) | |
83 | - ps3av->flip_ctl(on, ps3av->flip_data); | |
84 | - mutex_unlock(&ps3av->mutex); | |
85 | -} | |
86 | - | |
87 | static int ps3av_probe(struct ps3_system_bus_device *dev) | |
88 | { | |
89 | int res; | |
90 | --- a/drivers/ps3/ps3av_cmd.c | |
91 | +++ b/drivers/ps3/ps3av_cmd.c | |
92 | @@ -864,7 +864,7 @@ int ps3av_cmd_avb_param(struct ps3av_pkt | |
93 | { | |
94 | int res; | |
95 | ||
96 | - ps3av_flip_ctl(0); /* flip off */ | |
97 | + mutex_lock(&ps3_gpu_mutex); | |
98 | ||
99 | /* avb packet */ | |
100 | res = ps3av_do_pkt(PS3AV_CID_AVB_PARAM, send_len, sizeof(*avb), | |
101 | @@ -878,7 +878,7 @@ int ps3av_cmd_avb_param(struct ps3av_pkt | |
102 | res); | |
103 | ||
104 | out: | |
105 | - ps3av_flip_ctl(1); /* flip on */ | |
106 | + mutex_unlock(&ps3_gpu_mutex); | |
107 | return res; | |
108 | } | |
109 | ||
110 | --- a/drivers/video/ps3fb.c | |
111 | +++ b/drivers/video/ps3fb.c | |
112 | @@ -460,12 +460,16 @@ static void ps3fb_sync_image(struct devi | |
113 | line_length |= (u64)src_line_length << 32; | |
114 | ||
115 | src_offset += GPU_FB_START; | |
116 | + | |
117 | + mutex_lock(&ps3_gpu_mutex); | |
118 | status = lv1_gpu_context_attribute(ps3fb.context_handle, | |
119 | L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT, | |
120 | dst_offset, GPU_IOIF + src_offset, | |
121 | L1GPU_FB_BLIT_WAIT_FOR_COMPLETION | | |
122 | (width << 16) | height, | |
123 | line_length); | |
124 | + mutex_unlock(&ps3_gpu_mutex); | |
125 | + | |
126 | if (status) | |
127 | dev_err(dev, | |
128 | "%s: lv1_gpu_context_attribute FB_BLIT failed: %d\n", | |
129 | @@ -784,15 +788,6 @@ static int ps3fb_wait_for_vsync(u32 crtc | |
130 | return 0; | |
131 | } | |
132 | ||
133 | -static void ps3fb_flip_ctl(int on, void *data) | |
134 | -{ | |
135 | - struct ps3fb_priv *priv = data; | |
136 | - if (on) | |
137 | - atomic_dec_if_positive(&priv->ext_flip); | |
138 | - else | |
139 | - atomic_inc(&priv->ext_flip); | |
140 | -} | |
141 | - | |
142 | ||
143 | /* | |
144 | * ioctl | |
145 | @@ -1228,7 +1223,6 @@ static int __devinit ps3fb_probe(struct | |
146 | } | |
147 | ||
148 | ps3fb.task = task; | |
149 | - ps3av_register_flip_ctl(ps3fb_flip_ctl, &ps3fb); | |
150 | ||
151 | return 0; | |
152 | ||
153 | @@ -1258,10 +1252,9 @@ static int ps3fb_shutdown(struct ps3_sys | |
154 | ||
155 | dev_dbg(&dev->core, " -> %s:%d\n", __func__, __LINE__); | |
156 | ||
157 | - ps3fb_flip_ctl(0, &ps3fb); /* flip off */ | |
158 | + atomic_inc(&ps3fb.ext_flip); /* flip off */ | |
159 | ps3fb.dinfo->irq.mask = 0; | |
160 | ||
161 | - ps3av_register_flip_ctl(NULL, NULL); | |
162 | if (ps3fb.task) { | |
163 | struct task_struct *task = ps3fb.task; | |
164 | ps3fb.task = NULL; |