Commit 9b82f3e61758ed897200f0244b63a77c1791bcba

Authored by Geert Uytterhoeven
Committed by Paul Mackerras
1 parent 486936cd93

powerpc/ps3: Replace the flip_ctl logic in ps3av and ps3fb by a mutex

Introduce ps3_gpu_mutex to synchronizes GPU-related operations, like:
  - invoking the L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT command using the
    lv1_gpu_context_attribute() hypervisor call,
  - handling the PS3AV_CID_AVB_PARAM packet in the PS3 A/V Settings driver.

Signed-off-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>

Showing 6 changed files with 14 additions and 38 deletions Side-by-side Diff

arch/powerpc/include/asm/ps3.h
... ... @@ -516,5 +516,8 @@
516 516 u32 ps3_get_hw_thread_id(int cpu);
517 517 u64 ps3_get_spe_id(void *arg);
518 518  
  519 +/* mutex synchronizing GPU accesses and video mode changes */
  520 +extern struct mutex ps3_gpu_mutex;
  521 +
519 522 #endif
arch/powerpc/include/asm/ps3av.h
... ... @@ -740,9 +740,5 @@
740 740 extern int ps3av_audio_mute_analog(int);
741 741 extern int ps3av_dev_open(void);
742 742 extern int ps3av_dev_close(void);
743   -extern void ps3av_register_flip_ctl(void (*flip_ctl)(int on, void *data),
744   - void *flip_data);
745   -extern void ps3av_flip_ctl(int on);
746   -
747 743 #endif /* _ASM_POWERPC_PS3AV_H_ */
arch/powerpc/platforms/ps3/setup.c
... ... @@ -42,6 +42,10 @@
42 42 #define DBG pr_debug
43 43 #endif
44 44  
  45 +/* mutex synchronizing GPU accesses and video mode changes */
  46 +DEFINE_MUTEX(ps3_gpu_mutex);
  47 +EXPORT_SYMBOL_GPL(ps3_gpu_mutex);
  48 +
45 49 #if !defined(CONFIG_SMP)
46 50 static void smp_send_stop(void) {}
47 51 #endif
... ... @@ -59,8 +59,6 @@
59 59 struct ps3av_reply_hdr reply_hdr;
60 60 u8 raw[PS3AV_BUF_SIZE];
61 61 } recv_buf;
62   - void (*flip_ctl)(int on, void *data);
63   - void *flip_data;
64 62 } *ps3av;
65 63  
66 64 /* color space */
... ... @@ -938,24 +936,6 @@
938 936 }
939 937  
940 938 EXPORT_SYMBOL_GPL(ps3av_audio_mute);
941   -
942   -void ps3av_register_flip_ctl(void (*flip_ctl)(int on, void *data),
943   - void *flip_data)
944   -{
945   - mutex_lock(&ps3av->mutex);
946   - ps3av->flip_ctl = flip_ctl;
947   - ps3av->flip_data = flip_data;
948   - mutex_unlock(&ps3av->mutex);
949   -}
950   -EXPORT_SYMBOL_GPL(ps3av_register_flip_ctl);
951   -
952   -void ps3av_flip_ctl(int on)
953   -{
954   - mutex_lock(&ps3av->mutex);
955   - if (ps3av->flip_ctl)
956   - ps3av->flip_ctl(on, ps3av->flip_data);
957   - mutex_unlock(&ps3av->mutex);
958   -}
959 939  
960 940 static int ps3av_probe(struct ps3_system_bus_device *dev)
961 941 {
drivers/ps3/ps3av_cmd.c
... ... @@ -864,7 +864,7 @@
864 864 {
865 865 int res;
866 866  
867   - ps3av_flip_ctl(0); /* flip off */
  867 + mutex_lock(&ps3_gpu_mutex);
868 868  
869 869 /* avb packet */
870 870 res = ps3av_do_pkt(PS3AV_CID_AVB_PARAM, send_len, sizeof(*avb),
... ... @@ -878,7 +878,7 @@
878 878 res);
879 879  
880 880 out:
881   - ps3av_flip_ctl(1); /* flip on */
  881 + mutex_unlock(&ps3_gpu_mutex);
882 882 return res;
883 883 }
884 884  
drivers/video/ps3fb.c
... ... @@ -460,12 +460,16 @@
460 460 line_length |= (u64)src_line_length << 32;
461 461  
462 462 src_offset += GPU_FB_START;
  463 +
  464 + mutex_lock(&ps3_gpu_mutex);
463 465 status = lv1_gpu_context_attribute(ps3fb.context_handle,
464 466 L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT,
465 467 dst_offset, GPU_IOIF + src_offset,
466 468 L1GPU_FB_BLIT_WAIT_FOR_COMPLETION |
467 469 (width << 16) | height,
468 470 line_length);
  471 + mutex_unlock(&ps3_gpu_mutex);
  472 +
469 473 if (status)
470 474 dev_err(dev,
471 475 "%s: lv1_gpu_context_attribute FB_BLIT failed: %d\n",
472 476  
... ... @@ -784,16 +788,7 @@
784 788 return 0;
785 789 }
786 790  
787   -static void ps3fb_flip_ctl(int on, void *data)
788   -{
789   - struct ps3fb_priv *priv = data;
790   - if (on)
791   - atomic_dec_if_positive(&priv->ext_flip);
792   - else
793   - atomic_inc(&priv->ext_flip);
794   -}
795 791  
796   -
797 792 /*
798 793 * ioctl
799 794 */
... ... @@ -1228,7 +1223,6 @@
1228 1223 }
1229 1224  
1230 1225 ps3fb.task = task;
1231   - ps3av_register_flip_ctl(ps3fb_flip_ctl, &ps3fb);
1232 1226  
1233 1227 return 0;
1234 1228  
1235 1229  
... ... @@ -1258,10 +1252,9 @@
1258 1252  
1259 1253 dev_dbg(&dev->core, " -> %s:%d\n", __func__, __LINE__);
1260 1254  
1261   - ps3fb_flip_ctl(0, &ps3fb); /* flip off */
  1255 + atomic_inc(&ps3fb.ext_flip); /* flip off */
1262 1256 ps3fb.dinfo->irq.mask = 0;
1263 1257  
1264   - ps3av_register_flip_ctl(NULL, NULL);
1265 1258 if (ps3fb.task) {
1266 1259 struct task_struct *task = ps3fb.task;
1267 1260 ps3fb.task = NULL;