* [patch 0/5] PS3 AV/FB updates
@ 2007-03-13 14:19 Geert.Uytterhoeven
2007-03-13 14:19 ` [patch 1/5] ps3fb: thread updates Geert.Uytterhoeven
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Geert.Uytterhoeven @ 2007-03-13 14:19 UTC (permalink / raw)
To: Linus Torvalds, Andrew Morton
Cc: linux-fbdev-devel, James Simmons, Antonino A. Daplas,
linuxppc-dev
These are a few updates for the PS3 Audio/Video Settings Driver and the PS3
Virtual Frame Buffer Driver:
[PATCH 1/5] ps3fb: thread updates
[PATCH 2/5] ps3fb: atomic fixes
[PATCH 3/5] ps3av: thread updates
[PATCH 4/5] ps3fb: kill superfluous zero initializations
[PATCH 5/5] ps3av: misc updates
Please apply for 2.6.21. Thx!
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- Sony Network and Software Technology Center Europe (NSCE)
Geert.Uytterhoeven@sonycom.com ------- The Corporate Village, Da Vincilaan 7-D1
Voice +32-2-7008453 Fax +32-2-7008622 ---------------- B-1935 Zaventem, Belgium
^ permalink raw reply [flat|nested] 6+ messages in thread
* [patch 1/5] ps3fb: thread updates
2007-03-13 14:19 [patch 0/5] PS3 AV/FB updates Geert.Uytterhoeven
@ 2007-03-13 14:19 ` Geert.Uytterhoeven
2007-03-13 14:19 ` [patch 2/5] ps3fb: atomic fixes Geert.Uytterhoeven
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Geert.Uytterhoeven @ 2007-03-13 14:19 UTC (permalink / raw)
To: Linus Torvalds, Andrew Morton
Cc: Geert Uytterhoeven, linux-fbdev-devel, James Simmons,
Antonino A. Daplas, linuxppc-dev
ps3fb: Replace the kernel_thread and the semaphore by a proper kthread, which is
simply woken up when the screen must be updated
Signed-off-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
---
drivers/video/ps3fb.c | 41 ++++++++++++++++++++++++++++++++---------
1 files changed, 32 insertions(+), 9 deletions(-)
--- ps3-linux-2.6.21-rc3.orig/drivers/video/ps3fb.c
+++ ps3-linux-2.6.21-rc3/drivers/video/ps3fb.c
@@ -32,6 +32,8 @@
#include <linux/ioctl.h>
#include <linux/notifier.h>
#include <linux/reboot.h>
+#include <linux/kthread.h>
+#include <linux/freezer.h>
#include <asm/uaccess.h>
#include <linux/fb.h>
@@ -129,7 +131,6 @@ struct ps3fb_priv {
u64 context_handle, memory_handle;
void *xdr_ea;
struct gpu_driver_info *dinfo;
- struct semaphore sem;
u32 res_index;
u64 vblank_count; /* frame count */
@@ -139,6 +140,8 @@ struct ps3fb_priv {
atomic_t ext_flip; /* on/off flip with vsync */
atomic_t f_count; /* fb_open count */
int is_blanked;
+ int is_kicked;
+ struct task_struct *task;
};
static struct ps3fb_priv ps3fb;
@@ -805,11 +808,14 @@ static int ps3fb_ioctl(struct fb_info *i
static int ps3fbd(void *arg)
{
- daemonize("ps3fbd");
- for (;;) {
- down(&ps3fb.sem);
- if (atomic_read(&ps3fb.ext_flip) == 0)
+ while (!kthread_should_stop()) {
+ try_to_freeze();
+ set_current_state(TASK_INTERRUPTIBLE);
+ if (ps3fb.is_kicked) {
+ ps3fb.is_kicked = 0;
ps3fb_sync(0); /* single buffer */
+ }
+ schedule();
}
return 0;
}
@@ -830,8 +836,11 @@ static irqreturn_t ps3fb_vsync_interrupt
if (v1 & (1 << GPU_INTR_STATUS_VSYNC_1)) {
/* VSYNC */
ps3fb.vblank_count = head->vblank_count;
- if (!ps3fb.is_blanked)
- up(&ps3fb.sem);
+ if (ps3fb.task && !ps3fb.is_blanked &&
+ !atomic_read(&ps3fb.ext_flip)) {
+ ps3fb.is_kicked = 1;
+ wake_up_process(ps3fb.task);
+ }
wake_up_interruptible(&ps3fb.wait_vsync);
}
@@ -968,6 +977,7 @@ static int __init ps3fb_probe(struct pla
u64 xdr_lpar;
int status;
unsigned long offset;
+ struct task_struct *task;
/* get gpu context handle */
status = lv1_gpu_memory_allocate(DDR_SIZE, 0, 0, 0, 0,
@@ -1050,9 +1060,18 @@ static int __init ps3fb_probe(struct pla
"fb%d: PS3 frame buffer device, using %ld KiB of video memory\n",
info->node, ps3fb_videomemory.size >> 10);
- kernel_thread(ps3fbd, info, CLONE_KERNEL);
+ task = kthread_run(ps3fbd, info, "ps3fbd");
+ if (IS_ERR(task)) {
+ retval = PTR_ERR(task);
+ goto err_unregister_framebuffer;
+ }
+
+ ps3fb.task = task;
+
return 0;
+err_unregister_framebuffer:
+ unregister_framebuffer(info);
err_fb_dealloc:
fb_dealloc_cmap(&info->cmap);
err_framebuffer_release:
@@ -1083,6 +1102,11 @@ void ps3fb_cleanup(void)
{
int status;
+ if (ps3fb.task) {
+ struct task_struct *task = ps3fb.task;
+ ps3fb.task = NULL;
+ kthread_stop(task);
+ }
if (ps3fb.irq_no) {
free_irq(ps3fb.irq_no, ps3fb.dev);
ps3_free_irq(ps3fb.irq_no);
@@ -1195,7 +1219,6 @@ static int __init ps3fb_init(void)
atomic_set(&ps3fb.f_count, -1); /* fbcon opens ps3fb */
atomic_set(&ps3fb.ext_flip, 0); /* for flip with vsync */
- init_MUTEX(&ps3fb.sem);
init_waitqueue_head(&ps3fb.wait_vsync);
ps3fb.num_frames = 1;
--
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- Sony Network and Software Technology Center Europe (NSCE)
Geert.Uytterhoeven@sonycom.com ------- The Corporate Village, Da Vincilaan 7-D1
Voice +32-2-7008453 Fax +32-2-7008622 ---------------- B-1935 Zaventem, Belgium
^ permalink raw reply [flat|nested] 6+ messages in thread
* [patch 2/5] ps3fb: atomic fixes
2007-03-13 14:19 [patch 0/5] PS3 AV/FB updates Geert.Uytterhoeven
2007-03-13 14:19 ` [patch 1/5] ps3fb: thread updates Geert.Uytterhoeven
@ 2007-03-13 14:19 ` Geert.Uytterhoeven
2007-03-13 14:19 ` [patch 3/5] ps3av: thread updates Geert.Uytterhoeven
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Geert.Uytterhoeven @ 2007-03-13 14:19 UTC (permalink / raw)
To: Linus Torvalds, Andrew Morton
Cc: Geert Uytterhoeven, linux-fbdev-devel, James Simmons,
Antonino A. Daplas, linuxppc-dev
ps3fb: Use atomic_dec_if_positive() instead of bogus atomic_read()/atomic_dec()
combinations
Signed-off-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
---
drivers/video/ps3fb.c | 12 ++++--------
1 files changed, 4 insertions(+), 8 deletions(-)
--- ps3-linux-2.6.21-rc3.orig/drivers/video/ps3fb.c
+++ ps3-linux-2.6.21-rc3/drivers/video/ps3fb.c
@@ -680,13 +680,10 @@ EXPORT_SYMBOL_GPL(ps3fb_wait_for_vsync);
void ps3fb_flip_ctl(int on)
{
- if (on) {
- if (atomic_read(&ps3fb.ext_flip) > 0) {
- atomic_dec(&ps3fb.ext_flip);
- }
- } else {
+ if (on)
+ atomic_dec_if_positive(&ps3fb.ext_flip);
+ else
atomic_inc(&ps3fb.ext_flip);
- }
}
EXPORT_SYMBOL_GPL(ps3fb_flip_ctl);
@@ -786,8 +783,7 @@ static int ps3fb_ioctl(struct fb_info *i
case PS3FB_IOCTL_OFF:
DPRINTK("PS3FB_IOCTL_OFF:\n");
- if (atomic_read(&ps3fb.ext_flip) > 0)
- atomic_dec(&ps3fb.ext_flip);
+ atomic_dec_if_positive(&ps3fb.ext_flip);
retval = 0;
break;
--
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- Sony Network and Software Technology Center Europe (NSCE)
Geert.Uytterhoeven@sonycom.com ------- The Corporate Village, Da Vincilaan 7-D1
Voice +32-2-7008453 Fax +32-2-7008622 ---------------- B-1935 Zaventem, Belgium
^ permalink raw reply [flat|nested] 6+ messages in thread
* [patch 3/5] ps3av: thread updates
2007-03-13 14:19 [patch 0/5] PS3 AV/FB updates Geert.Uytterhoeven
2007-03-13 14:19 ` [patch 1/5] ps3fb: thread updates Geert.Uytterhoeven
2007-03-13 14:19 ` [patch 2/5] ps3fb: atomic fixes Geert.Uytterhoeven
@ 2007-03-13 14:19 ` Geert.Uytterhoeven
2007-03-13 14:19 ` [patch 4/5] ps3fb: kill superfluous zero initializations Geert.Uytterhoeven
2007-03-13 14:19 ` [patch 5/5] ps3av: misc updates Geert.Uytterhoeven
4 siblings, 0 replies; 6+ messages in thread
From: Geert.Uytterhoeven @ 2007-03-13 14:19 UTC (permalink / raw)
To: Linus Torvalds, Andrew Morton
Cc: Geert Uytterhoeven, linux-fbdev-devel, James Simmons,
Antonino A. Daplas, linuxppc-dev
ps3av: Replace the kernel_thread and the ping pong semaphores by a singlethread
workqueue and a completion.
Signed-off-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
---
drivers/ps3/ps3av.c | 30 ++++++++++++++----------------
include/asm-powerpc/ps3av.h | 5 +++--
2 files changed, 17 insertions(+), 18 deletions(-)
--- ps3-linux-2.6.21-rc3.orig/drivers/ps3/ps3av.c
+++ ps3-linux-2.6.21-rc3/drivers/ps3/ps3av.c
@@ -440,7 +440,7 @@ static int ps3av_set_videomode(void)
ps3av_set_av_video_mute(PS3AV_CMD_MUTE_ON);
/* wake up ps3avd to do the actual video mode setting */
- up(&ps3av.ping);
+ queue_work(ps3av.wq, &ps3av.work);
return 0;
}
@@ -515,18 +515,10 @@ static void ps3av_set_videomode_cont(u32
ps3av_set_av_video_mute(PS3AV_CMD_MUTE_OFF);
}
-static int ps3avd(void *p)
+static void ps3avd(struct work_struct *work)
{
- struct ps3av *info = p;
-
- daemonize("ps3avd");
- while (1) {
- down(&info->ping);
- ps3av_set_videomode_cont(info->ps3av_mode,
- info->ps3av_mode_old);
- up(&info->pong);
- }
- return 0;
+ ps3av_set_videomode_cont(ps3av.ps3av_mode, ps3av.ps3av_mode_old);
+ complete(&ps3av.done);
}
static int ps3av_vid2table_id(int vid)
@@ -725,7 +717,7 @@ int ps3av_set_video_mode(u32 id, int boo
}
/* set videomode */
- down(&ps3av.pong);
+ wait_for_completion(&ps3av.done);
ps3av.ps3av_mode_old = ps3av.ps3av_mode;
ps3av.ps3av_mode = id;
if (ps3av_set_videomode())
@@ -881,12 +873,16 @@ static int ps3av_probe(struct ps3_vuart_
memset(&ps3av, 0, sizeof(ps3av));
init_MUTEX(&ps3av.sem);
- init_MUTEX_LOCKED(&ps3av.ping);
- init_MUTEX(&ps3av.pong);
mutex_init(&ps3av.mutex);
ps3av.ps3av_mode = 0;
ps3av.dev = dev;
- kernel_thread(ps3avd, &ps3av, CLONE_KERNEL);
+
+ INIT_WORK(&ps3av.work, ps3avd);
+ init_completion(&ps3av.done);
+ complete(&ps3av.done);
+ ps3av.wq = create_singlethread_workqueue("ps3avd");
+ if (!ps3av.wq)
+ return -ENOMEM;
ps3av.available = 1;
switch (ps3_os_area_get_av_multi_out()) {
@@ -926,6 +922,8 @@ static int ps3av_remove(struct ps3_vuart
{
if (ps3av.available) {
ps3av_cmd_fin();
+ if (ps3av.wq)
+ destroy_workqueue(ps3av.wq);
ps3av.available = 0;
}
--- ps3-linux-2.6.21-rc3.orig/include/asm-powerpc/ps3av.h
+++ ps3-linux-2.6.21-rc3/include/asm-powerpc/ps3av.h
@@ -646,8 +646,9 @@ struct ps3av_pkt_avb_param {
struct ps3av {
int available;
struct semaphore sem;
- struct semaphore ping;
- struct semaphore pong;
+ struct work_struct work;
+ struct completion done;
+ struct workqueue_struct *wq;
struct mutex mutex;
int open_count;
struct ps3_vuart_port_device *dev;
--
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- Sony Network and Software Technology Center Europe (NSCE)
Geert.Uytterhoeven@sonycom.com ------- The Corporate Village, Da Vincilaan 7-D1
Voice +32-2-7008453 Fax +32-2-7008622 ---------------- B-1935 Zaventem, Belgium
^ permalink raw reply [flat|nested] 6+ messages in thread
* [patch 4/5] ps3fb: kill superfluous zero initializations
2007-03-13 14:19 [patch 0/5] PS3 AV/FB updates Geert.Uytterhoeven
` (2 preceding siblings ...)
2007-03-13 14:19 ` [patch 3/5] ps3av: thread updates Geert.Uytterhoeven
@ 2007-03-13 14:19 ` Geert.Uytterhoeven
2007-03-13 14:19 ` [patch 5/5] ps3av: misc updates Geert.Uytterhoeven
4 siblings, 0 replies; 6+ messages in thread
From: Geert.Uytterhoeven @ 2007-03-13 14:19 UTC (permalink / raw)
To: Linus Torvalds, Andrew Morton
Cc: Geert Uytterhoeven, linux-fbdev-devel, James Simmons,
Antonino A. Daplas, linuxppc-dev
ps3fb: kill superfluous zero initializations
Signed-off-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
---
drivers/video/ps3fb.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
--- ps3-linux-2.6.21-rc3.orig/drivers/video/ps3fb.c
+++ ps3-linux-2.6.21-rc3/drivers/video/ps3fb.c
@@ -297,10 +297,10 @@ static const struct fb_videomode ps3fb_m
#define VP_OFF(i) (WIDTH(i) * Y_OFF(i) * BPP + X_OFF(i) * BPP)
#define FB_OFF(i) (GPU_OFFSET - VP_OFF(i) % GPU_OFFSET)
-static int ps3fb_mode = 0;
+static int ps3fb_mode;
module_param(ps3fb_mode, bool, 0);
-static char *mode_option __initdata = NULL;
+static char *mode_option __initdata;
static int ps3fb_get_res_table(u32 xres, u32 yres)
--
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- Sony Network and Software Technology Center Europe (NSCE)
Geert.Uytterhoeven@sonycom.com ------- The Corporate Village, Da Vincilaan 7-D1
Voice +32-2-7008453 Fax +32-2-7008622 ---------------- B-1935 Zaventem, Belgium
^ permalink raw reply [flat|nested] 6+ messages in thread
* [patch 5/5] ps3av: misc updates
2007-03-13 14:19 [patch 0/5] PS3 AV/FB updates Geert.Uytterhoeven
` (3 preceding siblings ...)
2007-03-13 14:19 ` [patch 4/5] ps3fb: kill superfluous zero initializations Geert.Uytterhoeven
@ 2007-03-13 14:19 ` Geert.Uytterhoeven
4 siblings, 0 replies; 6+ messages in thread
From: Geert.Uytterhoeven @ 2007-03-13 14:19 UTC (permalink / raw)
To: Linus Torvalds, Andrew Morton
Cc: Geert Uytterhoeven, linux-fbdev-devel, James Simmons,
Antonino A. Daplas, linuxppc-dev
ps3av:
- Move the definition of struct ps3av to ps3av.c, as it's locally used only.
- Kill ps3av.sem, use the existing ps3av.mutex instead.
- Make the 512-byte buffer in ps3av_do_pkt() static to reduce stack usage.
It's use is protected by a semaphore anyway.
Signed-off-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
---
drivers/ps3/ps3av.c | 29 ++++++++++++++++++++++-------
include/asm-powerpc/ps3av.h | 22 +---------------------
2 files changed, 23 insertions(+), 28 deletions(-)
--- ps3-linux-2.6.21-rc3.orig/drivers/ps3/ps3av.c
+++ ps3-linux-2.6.21-rc3/drivers/ps3/ps3av.c
@@ -38,7 +38,24 @@
static int timeout = 5000; /* in msec ( 5 sec ) */
module_param(timeout, int, 0644);
-static struct ps3av ps3av;
+static struct ps3av {
+ int available;
+ struct mutex mutex;
+ struct work_struct work;
+ struct completion done;
+ struct workqueue_struct *wq;
+ int open_count;
+ struct ps3_vuart_port_device *dev;
+
+ int region;
+ struct ps3av_pkt_av_get_hw_conf av_hw_conf;
+ u32 av_port[PS3AV_AV_PORT_MAX + PS3AV_OPT_PORT_MAX];
+ u32 opt_port[PS3AV_OPT_PORT_MAX];
+ u32 head[PS3AV_HEAD_MAX];
+ u32 audio_port;
+ int ps3av_mode;
+ int ps3av_mode_old;
+} ps3av;
static struct ps3_vuart_port_device ps3av_dev = {
.match_id = PS3_MATCH_ID_AV_SETTINGS
@@ -250,7 +267,7 @@ int ps3av_do_pkt(u32 cid, u16 send_len,
struct ps3av_send_hdr *buf)
{
int res = 0;
- union {
+ static union {
struct ps3av_reply_hdr reply_hdr;
u8 raw[PS3AV_BUF_SIZE];
} recv_buf;
@@ -259,8 +276,7 @@ int ps3av_do_pkt(u32 cid, u16 send_len,
BUG_ON(!ps3av.available);
- if (down_interruptible(&ps3av.sem))
- return -ERESTARTSYS;
+ mutex_lock(&ps3av.mutex);
table = ps3av_search_cmd_table(cid, PS3AV_CID_MASK);
BUG_ON(!table);
@@ -290,11 +306,11 @@ int ps3av_do_pkt(u32 cid, u16 send_len,
goto err;
}
- up(&ps3av.sem);
+ mutex_unlock(&ps3av.mutex);
return 0;
err:
- up(&ps3av.sem);
+ mutex_unlock(&ps3av.mutex);
printk(KERN_ERR "%s: failed cid:%x res:%d\n", __FUNCTION__, cid, res);
return res;
}
@@ -872,7 +888,6 @@ static int ps3av_probe(struct ps3_vuart_
memset(&ps3av, 0, sizeof(ps3av));
- init_MUTEX(&ps3av.sem);
mutex_init(&ps3av.mutex);
ps3av.ps3av_mode = 0;
ps3av.dev = dev;
--- ps3-linux-2.6.21-rc3.orig/include/asm-powerpc/ps3av.h
+++ ps3-linux-2.6.21-rc3/include/asm-powerpc/ps3av.h
@@ -18,8 +18,6 @@
#ifndef _ASM_POWERPC_PS3AV_H_
#define _ASM_POWERPC_PS3AV_H_
-#include <linux/mutex.h>
-
/** command for ioctl() **/
#define PS3AV_VERSION 0x205 /* version of ps3av command */
@@ -643,25 +641,6 @@ struct ps3av_pkt_avb_param {
u8 buf[PS3AV_PKT_AVB_PARAM_MAX_BUF_SIZE];
};
-struct ps3av {
- int available;
- struct semaphore sem;
- struct work_struct work;
- struct completion done;
- struct workqueue_struct *wq;
- struct mutex mutex;
- int open_count;
- struct ps3_vuart_port_device *dev;
-
- int region;
- struct ps3av_pkt_av_get_hw_conf av_hw_conf;
- u32 av_port[PS3AV_AV_PORT_MAX + PS3AV_OPT_PORT_MAX];
- u32 opt_port[PS3AV_OPT_PORT_MAX];
- u32 head[PS3AV_HEAD_MAX];
- u32 audio_port;
- int ps3av_mode;
- int ps3av_mode_old;
-};
/** command status **/
#define PS3AV_STATUS_SUCCESS 0x0000 /* success */
@@ -719,6 +698,7 @@ static inline void ps3av_cmd_av_monitor_
extern int ps3av_cmd_video_get_monitor_info(struct ps3av_pkt_av_get_monitor_info *,
u32);
+struct ps3_vuart_port_device;
extern int ps3av_vuart_write(struct ps3_vuart_port_device *dev,
const void *buf, unsigned long size);
extern int ps3av_vuart_read(struct ps3_vuart_port_device *dev, void *buf,
--
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- Sony Network and Software Technology Center Europe (NSCE)
Geert.Uytterhoeven@sonycom.com ------- The Corporate Village, Da Vincilaan 7-D1
Voice +32-2-7008453 Fax +32-2-7008622 ---------------- B-1935 Zaventem, Belgium
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-03-13 14:22 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-13 14:19 [patch 0/5] PS3 AV/FB updates Geert.Uytterhoeven
2007-03-13 14:19 ` [patch 1/5] ps3fb: thread updates Geert.Uytterhoeven
2007-03-13 14:19 ` [patch 2/5] ps3fb: atomic fixes Geert.Uytterhoeven
2007-03-13 14:19 ` [patch 3/5] ps3av: thread updates Geert.Uytterhoeven
2007-03-13 14:19 ` [patch 4/5] ps3fb: kill superfluous zero initializations Geert.Uytterhoeven
2007-03-13 14:19 ` [patch 5/5] ps3av: misc updates Geert.Uytterhoeven
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).