Commit 49e2bab0 authored by Paul Mundt's avatar Paul Mundt Committed by Tony Lindgren

[PATCH] ARM: OMAP: dspgateway sem2mutex conversion

This has been lagging behind a bit, primarily due to the fact that the
OMAP tree has gotten a bit out of sync with the DSP gateway updates
(we'll leave that for another patch).

This is a quick and simple sem2mutex conversion, after this dspgateway is
essentially down to a single rwsem for the exmap cases, and that will
remain as it is.

Against current git.
Signed-off-by: default avatarPaul Mundt <paul.mundt@nokia.com>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent 6a033b86
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/mutex.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/tlbflush.h> #include <asm/tlbflush.h>
#include <asm/irq.h> #include <asm/irq.h>
...@@ -45,7 +46,7 @@ unsigned long dspmem_base, dspmem_size, ...@@ -45,7 +46,7 @@ unsigned long dspmem_base, dspmem_size,
saram_base, saram_size; saram_base, saram_size;
struct cpustat { struct cpustat {
struct semaphore sem; struct mutex lock;
enum e_cpustat stat; enum e_cpustat stat;
enum e_cpustat req; enum e_cpustat req;
unsigned short icrmask; unsigned short icrmask;
...@@ -58,7 +59,7 @@ struct cpustat { ...@@ -58,7 +59,7 @@ struct cpustat {
void (*mem_rel_cb)(void); void (*mem_rel_cb)(void);
}; };
struct cpustat cpustat = { struct cpustat cpustat = {
.sem = __SEMAPHORE_INIT(cpustat.sem, 1), .lock = __MUTEX_INITIALIZER(cpustat.lock),
.stat = CPUSTAT_RESET, .stat = CPUSTAT_RESET,
.icrmask = 0xffff, .icrmask = 0xffff,
}; };
...@@ -364,10 +365,10 @@ static void dsp_cpustat_update(void) ...@@ -364,10 +365,10 @@ static void dsp_cpustat_update(void)
void dsp_cpustat_request(enum e_cpustat req) void dsp_cpustat_request(enum e_cpustat req)
{ {
down(&cpustat.sem); mutex_lock(&cpustat.lock);
cpustat.req = req; cpustat.req = req;
dsp_cpustat_update(); dsp_cpustat_update();
up(&cpustat.sem); mutex_unlock(&cpustat.lock);
} }
enum e_cpustat dsp_cpustat_get_stat(void) enum e_cpustat dsp_cpustat_get_stat(void)
...@@ -382,23 +383,23 @@ unsigned short dsp_cpustat_get_icrmask(void) ...@@ -382,23 +383,23 @@ unsigned short dsp_cpustat_get_icrmask(void)
void dsp_cpustat_set_icrmask(unsigned short mask) void dsp_cpustat_set_icrmask(unsigned short mask)
{ {
down(&cpustat.sem); mutex_lock(&cpustat.lock);
cpustat.icrmask = mask; cpustat.icrmask = mask;
dsp_cpustat_update(); dsp_cpustat_update();
up(&cpustat.sem); mutex_unlock(&cpustat.lock);
} }
void omap_dsp_request_mpui(void) void omap_dsp_request_mpui(void)
{ {
down(&cpustat.sem); mutex_lock(&cpustat.lock);
if (cpustat.usecount.mpui++ == 0) if (cpustat.usecount.mpui++ == 0)
dsp_cpustat_update(); dsp_cpustat_update();
up(&cpustat.sem); mutex_unlock(&cpustat.lock);
} }
void omap_dsp_release_mpui(void) void omap_dsp_release_mpui(void)
{ {
down(&cpustat.sem); mutex_lock(&cpustat.lock);
if (cpustat.usecount.mpui-- == 0) { if (cpustat.usecount.mpui-- == 0) {
printk(KERN_ERR printk(KERN_ERR
"omapdsp: unbalanced mpui request/release detected.\n" "omapdsp: unbalanced mpui request/release detected.\n"
...@@ -408,14 +409,14 @@ void omap_dsp_release_mpui(void) ...@@ -408,14 +409,14 @@ void omap_dsp_release_mpui(void)
} }
if (cpustat.usecount.mpui == 0) if (cpustat.usecount.mpui == 0)
dsp_cpustat_update(); dsp_cpustat_update();
up(&cpustat.sem); mutex_unlock(&cpustat.lock);
} }
int omap_dsp_request_mem(void) int omap_dsp_request_mem(void)
{ {
int ret = 0; int ret = 0;
down(&cpustat.sem); mutex_lock(&cpustat.lock);
if ((cpustat.usecount.mem++ == 0) && if ((cpustat.usecount.mem++ == 0) &&
(cpustat.usecount.mem_delayed == 0)) { (cpustat.usecount.mem_delayed == 0)) {
if (cpustat.mem_req_cb) { if (cpustat.mem_req_cb) {
...@@ -427,7 +428,7 @@ int omap_dsp_request_mem(void) ...@@ -427,7 +428,7 @@ int omap_dsp_request_mem(void)
dsp_cpustat_update(); dsp_cpustat_update();
} }
out: out:
up(&cpustat.sem); mutex_unlock(&cpustat.lock);
return ret; return ret;
} }
...@@ -435,22 +436,23 @@ out: ...@@ -435,22 +436,23 @@ out:
/* /*
* release_mem will be delayed. * release_mem will be delayed.
*/ */
static void do_release_mem(void) { static void do_release_mem(void)
down(&cpustat.sem); {
mutex_lock(&cpustat.lock);
cpustat.usecount.mem_delayed = 0; cpustat.usecount.mem_delayed = 0;
if (cpustat.usecount.mem == 0) { if (cpustat.usecount.mem == 0) {
dsp_cpustat_update(); dsp_cpustat_update();
if (cpustat.mem_rel_cb) if (cpustat.mem_rel_cb)
cpustat.mem_rel_cb(); cpustat.mem_rel_cb();
} }
up(&cpustat.sem); mutex_unlock(&cpustat.lock);
} }
static DECLARE_WORK(mem_rel_work, (void (*)(void *))do_release_mem, NULL); static DECLARE_WORK(mem_rel_work, (void (*)(void *))do_release_mem, NULL);
int omap_dsp_release_mem(void) int omap_dsp_release_mem(void)
{ {
down(&cpustat.sem); mutex_lock(&cpustat.lock);
/* cancel previous release work */ /* cancel previous release work */
cancel_delayed_work(&mem_rel_work); cancel_delayed_work(&mem_rel_work);
...@@ -468,14 +470,14 @@ int omap_dsp_release_mem(void) ...@@ -468,14 +470,14 @@ int omap_dsp_release_mem(void)
schedule_delayed_work(&mem_rel_work, HZ); schedule_delayed_work(&mem_rel_work, HZ);
} }
up(&cpustat.sem); mutex_unlock(&cpustat.lock);
return 0; return 0;
} }
void dsp_register_mem_cb(int (*req_cb)(void), void (*rel_cb)(void)) void dsp_register_mem_cb(int (*req_cb)(void), void (*rel_cb)(void))
{ {
down(&cpustat.sem); mutex_lock(&cpustat.lock);
cpustat.mem_req_cb = req_cb; cpustat.mem_req_cb = req_cb;
cpustat.mem_rel_cb = rel_cb; cpustat.mem_rel_cb = rel_cb;
...@@ -485,15 +487,15 @@ void dsp_register_mem_cb(int (*req_cb)(void), void (*rel_cb)(void)) ...@@ -485,15 +487,15 @@ void dsp_register_mem_cb(int (*req_cb)(void), void (*rel_cb)(void))
*/ */
BUG_ON(cpustat.usecount.mem == 0); BUG_ON(cpustat.usecount.mem == 0);
up(&cpustat.sem); mutex_unlock(&cpustat.lock);
} }
void dsp_unregister_mem_cb(void) void dsp_unregister_mem_cb(void)
{ {
down(&cpustat.sem); mutex_lock(&cpustat.lock);
cpustat.mem_req_cb = NULL; cpustat.mem_req_cb = NULL;
cpustat.mem_rel_cb = NULL; cpustat.mem_rel_cb = NULL;
up(&cpustat.sem); mutex_unlock(&cpustat.lock);
} }
/* /*
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/mutex.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/signal.h> #include <asm/signal.h>
...@@ -248,7 +249,7 @@ int __mbcmd_send(struct mbcmd *mb) ...@@ -248,7 +249,7 @@ int __mbcmd_send(struct mbcmd *mb)
*/ */
int __dsp_mbcmd_send(struct mbcmd *mb, struct mb_exarg *arg, int recovery_flag) int __dsp_mbcmd_send(struct mbcmd *mb, struct mb_exarg *arg, int recovery_flag)
{ {
static DECLARE_MUTEX(mbsend_sem); static DEFINE_MUTEX(mbsend_lock);
int ret = 0; int ret = 0;
/* /*
...@@ -260,7 +261,7 @@ int __dsp_mbcmd_send(struct mbcmd *mb, struct mb_exarg *arg, int recovery_flag) ...@@ -260,7 +261,7 @@ int __dsp_mbcmd_send(struct mbcmd *mb, struct mb_exarg *arg, int recovery_flag)
return -1; return -1;
} }
if (down_interruptible(&mbsend_sem) < 0) if (mutex_lock_interruptible(&mbsend_lock) < 0)
return -1; return -1;
if (arg) { /* we have extra argument */ if (arg) { /* we have extra argument */
...@@ -291,7 +292,7 @@ int __dsp_mbcmd_send(struct mbcmd *mb, struct mb_exarg *arg, int recovery_flag) ...@@ -291,7 +292,7 @@ int __dsp_mbcmd_send(struct mbcmd *mb, struct mb_exarg *arg, int recovery_flag)
ret = __mbcmd_send(mb); ret = __mbcmd_send(mb);
out: out:
up(&mbsend_sem); mutex_unlock(&mbsend_lock);
return ret; return ret;
} }
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/mutex.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/ioctls.h> #include <asm/ioctls.h>
...@@ -56,7 +57,7 @@ static enum cfgstat { ...@@ -56,7 +57,7 @@ static enum cfgstat {
int mbx_revision; int mbx_revision;
static DECLARE_WAIT_QUEUE_HEAD(ioctl_wait_q); static DECLARE_WAIT_QUEUE_HEAD(ioctl_wait_q);
static unsigned short ioctl_wait_cmd; static unsigned short ioctl_wait_cmd;
static DECLARE_MUTEX(ioctl_sem); static DEFINE_MUTEX(ioctl_lock);
static unsigned char n_stask; static unsigned char n_stask;
...@@ -71,7 +72,7 @@ static int dsp_regread(unsigned short cmd_l, unsigned short adr, ...@@ -71,7 +72,7 @@ static int dsp_regread(unsigned short cmd_l, unsigned short adr,
struct mbcmd mb; struct mbcmd mb;
int ret = 0; int ret = 0;
if (down_interruptible(&ioctl_sem)) if (mutex_lock_interruptible(&ioctl_lock))
return -ERESTARTSYS; return -ERESTARTSYS;
ioctl_wait_cmd = MBCMD(REGRW); ioctl_wait_cmd = MBCMD(REGRW);
...@@ -87,7 +88,7 @@ static int dsp_regread(unsigned short cmd_l, unsigned short adr, ...@@ -87,7 +88,7 @@ static int dsp_regread(unsigned short cmd_l, unsigned short adr,
*val = varread_val[0]; *val = varread_val[0];
up_out: up_out:
up(&ioctl_sem); mutex_unlock(&ioctl_lock);
return ret; return ret;
} }
...@@ -111,7 +112,7 @@ static int dsp_getvar(unsigned char varid, unsigned short *val, int sz) ...@@ -111,7 +112,7 @@ static int dsp_getvar(unsigned char varid, unsigned short *val, int sz)
struct mbcmd mb; struct mbcmd mb;
int ret = 0; int ret = 0;
if (down_interruptible(&ioctl_sem)) if (mutex_lock_interruptible(&ioctl_lock))
return -ERESTARTSYS; return -ERESTARTSYS;
ioctl_wait_cmd = MBCMD(GETVAR); ioctl_wait_cmd = MBCMD(GETVAR);
...@@ -127,7 +128,7 @@ static int dsp_getvar(unsigned char varid, unsigned short *val, int sz) ...@@ -127,7 +128,7 @@ static int dsp_getvar(unsigned char varid, unsigned short *val, int sz)
memcpy(val, varread_val, sz * sizeof(short)); memcpy(val, varread_val, sz * sizeof(short));
up_out: up_out:
up(&ioctl_sem); mutex_unlock(&ioctl_lock);
return ret; return ret;
} }
...@@ -142,7 +143,7 @@ static int dspcfg(void) ...@@ -142,7 +143,7 @@ static int dspcfg(void)
struct mbcmd mb; struct mbcmd mb;
int ret = 0; int ret = 0;
if (down_interruptible(&ioctl_sem)) if (mutex_lock_interruptible(&ioctl_lock))
return -ERESTARTSYS; return -ERESTARTSYS;
if (cfgstat != CFG_ERR) { if (cfgstat != CFG_ERR) {
...@@ -192,7 +193,7 @@ static int dspcfg(void) ...@@ -192,7 +193,7 @@ static int dspcfg(void)
#endif #endif
if ((ret = dsp_task_config_all(n_stask)) < 0) { if ((ret = dsp_task_config_all(n_stask)) < 0) {
up(&ioctl_sem); mutex_unlock(&ioctl_lock);
dspuncfg(); dspuncfg();
dsp_mem_disable((void *)dspmem_base); dsp_mem_disable((void *)dspmem_base);
return -EINVAL; return -EINVAL;
...@@ -211,7 +212,7 @@ static int dspcfg(void) ...@@ -211,7 +212,7 @@ static int dspcfg(void)
up_out: up_out:
dsp_mem_disable((void *)dspmem_base); dsp_mem_disable((void *)dspmem_base);
up(&ioctl_sem); mutex_unlock(&ioctl_lock);
return ret; return ret;
} }
...@@ -222,7 +223,7 @@ int dspuncfg(void) ...@@ -222,7 +223,7 @@ int dspuncfg(void)
return -EBUSY; return -EBUSY;
} }
if (down_interruptible(&ioctl_sem)) if (mutex_lock_interruptible(&ioctl_lock))
return -ERESTARTSYS; return -ERESTARTSYS;
/* FIXME: lock task module */ /* FIXME: lock task module */
...@@ -240,7 +241,7 @@ int dspuncfg(void) ...@@ -240,7 +241,7 @@ int dspuncfg(void)
ipbuf_stop(); ipbuf_stop();
cfgstat = CFG_ERR; cfgstat = CFG_ERR;
up(&ioctl_sem); mutex_unlock(&ioctl_lock);
return 0; return 0;
} }
...@@ -257,7 +258,7 @@ int dsp_poll(void) ...@@ -257,7 +258,7 @@ int dsp_poll(void)
struct mbcmd mb; struct mbcmd mb;
int ret = 0; int ret = 0;
if (down_interruptible(&ioctl_sem)) if (mutex_lock_interruptible(&ioctl_lock))
return -ERESTARTSYS; return -ERESTARTSYS;
ioctl_wait_cmd = MBCMD(POLL); ioctl_wait_cmd = MBCMD(POLL);
...@@ -271,7 +272,7 @@ int dsp_poll(void) ...@@ -271,7 +272,7 @@ int dsp_poll(void)
} }
up_out: up_out:
up(&ioctl_sem); mutex_unlock(&ioctl_lock);
return ret; return ret;
} }
...@@ -301,7 +302,7 @@ int dsp_suspend(void) ...@@ -301,7 +302,7 @@ int dsp_suspend(void)
return -EINVAL; return -EINVAL;
} }
if (down_interruptible(&ioctl_sem)) if (mutex_lock_interruptible(&ioctl_lock))
return -ERESTARTSYS; return -ERESTARTSYS;
cfgstat_save_suspend = cfgstat; cfgstat_save_suspend = cfgstat;
...@@ -330,7 +331,7 @@ int dsp_suspend(void) ...@@ -330,7 +331,7 @@ int dsp_suspend(void)
transition: transition:
cfgstat = CFG_SUSPEND; cfgstat = CFG_SUSPEND;
up_out: up_out:
up(&ioctl_sem); mutex_unlock(&ioctl_lock);
return ret; return ret;
} }
...@@ -356,7 +357,7 @@ static int dsp_fbctl_disable(void) ...@@ -356,7 +357,7 @@ static int dsp_fbctl_disable(void)
int ret = 0; int ret = 0;
struct mbcmd mb; struct mbcmd mb;
if (down_interruptible(&ioctl_sem)) if (mutex_lock_interruptible(&ioctl_lock))
return -ERESTARTSYS; return -ERESTARTSYS;
ioctl_wait_cmd = MBCMD(KFUNC); ioctl_wait_cmd = MBCMD(KFUNC);
...@@ -367,7 +368,7 @@ static int dsp_fbctl_disable(void) ...@@ -367,7 +368,7 @@ static int dsp_fbctl_disable(void)
printk(KERN_ERR "omapdsp: fb disable error!\n"); printk(KERN_ERR "omapdsp: fb disable error!\n");
ret = -EINVAL; ret = -EINVAL;
} }
up(&ioctl_sem); mutex_unlock(&ioctl_lock);
return ret; return ret;
} }
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/mutex.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/signal.h> #include <asm/signal.h>
...@@ -91,18 +92,18 @@ struct taskdev { ...@@ -91,18 +92,18 @@ struct taskdev {
/* read stuff */ /* read stuff */
wait_queue_head_t read_wait_q; wait_queue_head_t read_wait_q;
struct semaphore read_sem; struct mutex read_mutex;
/* write stuff */ /* write stuff */
wait_queue_head_t write_wait_q; wait_queue_head_t write_wait_q;
struct semaphore write_sem; struct mutex write_mutex;
/* ioctl stuff */ /* ioctl stuff */
wait_queue_head_t ioctl_wait_q; wait_queue_head_t ioctl_wait_q;
struct semaphore ioctl_sem; struct mutex ioctl_mutex;
/* device lock */ /* device lock */
struct semaphore lock_sem; struct mutex lock;
pid_t lock_pid; pid_t lock_pid;
}; };
...@@ -206,7 +207,7 @@ static struct bus_type dsptask_bus = { ...@@ -206,7 +207,7 @@ static struct bus_type dsptask_bus = {
static struct class *dsp_task_class; static struct class *dsp_task_class;
static struct taskdev *taskdev[TASKDEV_MAX]; static struct taskdev *taskdev[TASKDEV_MAX];
static struct dsptask *dsptask[TASKDEV_MAX]; static struct dsptask *dsptask[TASKDEV_MAX];
static DECLARE_MUTEX(cfg_sem); static DEFINE_MUTEX(cfg_lock);
static unsigned short cfg_cmd; static unsigned short cfg_cmd;
static unsigned char cfg_tid; static unsigned char cfg_tid;
static DECLARE_WAIT_QUEUE_HEAD(cfg_wait_q); static DECLARE_WAIT_QUEUE_HEAD(cfg_wait_q);
...@@ -256,19 +257,19 @@ static __inline__ void devstate_unlock(struct taskdev *dev) ...@@ -256,19 +257,19 @@ static __inline__ void devstate_unlock(struct taskdev *dev)
spin_unlock(&dev->state_lock); spin_unlock(&dev->state_lock);
} }
static __inline__ int down_tasksem_interruptible(struct taskdev *dev, static inline int taskdev_lock_interruptible(struct taskdev *dev,
struct semaphore *sem) struct mutex *lock)
{ {
int ret; int ret;
if (dev->lock_pid == current->pid) { if (dev->lock_pid == current->pid) {
/* this process has lock */ /* this process has lock */
ret = down_interruptible(sem); ret = mutex_lock_interruptible(lock);
} else { } else {
if ((ret = down_interruptible(&dev->lock_sem)) != 0) if ((ret = mutex_lock_interruptible(&dev->lock)) != 0)
return ret; return ret;
ret = down_interruptible(sem); ret = mutex_lock_interruptible(lock);
up(&dev->lock_sem); mutex_unlock(&dev->lock);
} }
return ret; return ret;
} }
...@@ -358,7 +359,7 @@ static int dsp_task_set_fifosz(struct dsptask *task, unsigned long sz) ...@@ -358,7 +359,7 @@ static int dsp_task_set_fifosz(struct dsptask *task, unsigned long sz)
static int taskdev_lock(struct taskdev *dev) static int taskdev_lock(struct taskdev *dev)
{ {
if (down_interruptible(&dev->lock_sem)) if (mutex_lock_interruptible(&dev->lock))
return -ERESTARTSYS; return -ERESTARTSYS;
dev->lock_pid = current->pid; dev->lock_pid = current->pid;
return 0; return 0;
...@@ -373,7 +374,7 @@ static int taskdev_unlock(struct taskdev *dev) ...@@ -373,7 +374,7 @@ static int taskdev_unlock(struct taskdev *dev)
return -EINVAL; return -EINVAL;
} }
dev->lock_pid = 0; dev->lock_pid = 0;
up(&dev->lock_sem); mutex_unlock(&dev->lock);
return 0; return 0;
} }
...@@ -388,7 +389,7 @@ static int dsp_task_config(struct dsptask *task, unsigned char tid) ...@@ -388,7 +389,7 @@ static int dsp_task_config(struct dsptask *task, unsigned char tid)
/* TCFG request */ /* TCFG request */
task->state = TASK_STATE_CFGREQ; task->state = TASK_STATE_CFGREQ;
if (down_interruptible(&cfg_sem)) { if (mutex_lock_interruptible(&cfg_lock)) {
ret = -ERESTARTSYS; ret = -ERESTARTSYS;
goto fail_out; goto fail_out;
} }
...@@ -396,7 +397,7 @@ static int dsp_task_config(struct dsptask *task, unsigned char tid) ...@@ -396,7 +397,7 @@ static int dsp_task_config(struct dsptask *task, unsigned char tid)
mbcmd_set(mb, MBCMD(TCFG), tid, 0); mbcmd_set(mb, MBCMD(TCFG), tid, 0);
dsp_mbcmd_send_and_wait(&mb, &cfg_wait_q); dsp_mbcmd_send_and_wait(&mb, &cfg_wait_q);
cfg_cmd = 0; cfg_cmd = 0;
up(&cfg_sem); mutex_unlock(&cfg_lock);
if (task->state != TASK_STATE_READY) { if (task->state != TASK_STATE_READY) {
printk(KERN_ERR "omapdsp: task %d configuration error!\n", tid); printk(KERN_ERR "omapdsp: task %d configuration error!\n", tid);
...@@ -652,7 +653,7 @@ static ssize_t dsp_task_read_wd_acv(struct file *file, char *buf, size_t count, ...@@ -652,7 +653,7 @@ static ssize_t dsp_task_read_wd_acv(struct file *file, char *buf, size_t count,
return -EINVAL; return -EINVAL;
} }
if (down_tasksem_interruptible(dev, &dev->read_sem)) if (taskdev_lock_interruptible(dev, &dev->read_mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
if (devstate_lock(dev, OMAP_DSP_DEVSTATE_ATTACHED) < 0) { if (devstate_lock(dev, OMAP_DSP_DEVSTATE_ATTACHED) < 0) {
ret = -ERESTARTSYS; ret = -ERESTARTSYS;
...@@ -693,7 +694,7 @@ static ssize_t dsp_task_read_wd_acv(struct file *file, char *buf, size_t count, ...@@ -693,7 +694,7 @@ static ssize_t dsp_task_read_wd_acv(struct file *file, char *buf, size_t count,
up_out: up_out:
if (have_devstate_lock) if (have_devstate_lock)
devstate_unlock(dev); devstate_unlock(dev);
up(&dev->read_sem); mutex_unlock(&dev->read_mutex);
return ret; return ret;
} }
...@@ -719,7 +720,7 @@ static ssize_t dsp_task_read_bk_acv(struct file *file, char *buf, size_t count, ...@@ -719,7 +720,7 @@ static ssize_t dsp_task_read_bk_acv(struct file *file, char *buf, size_t count,
return -EINVAL; return -EINVAL;
} }
if (down_tasksem_interruptible(dev, &dev->read_sem)) if (taskdev_lock_interruptible(dev, &dev->read_mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
if (devstate_lock(dev, OMAP_DSP_DEVSTATE_ATTACHED) < 0) { if (devstate_lock(dev, OMAP_DSP_DEVSTATE_ATTACHED) < 0) {
ret = -ERESTARTSYS; ret = -ERESTARTSYS;
...@@ -851,7 +852,7 @@ gb_out: ...@@ -851,7 +852,7 @@ gb_out:
up_out: up_out:
if (have_devstate_lock) if (have_devstate_lock)
devstate_unlock(dev); devstate_unlock(dev);
up(&dev->read_sem); mutex_unlock(&dev->read_mutex);
return ret; return ret;
} }
...@@ -875,7 +876,7 @@ static ssize_t dsp_task_read_wd_psv(struct file *file, char *buf, size_t count, ...@@ -875,7 +876,7 @@ static ssize_t dsp_task_read_wd_psv(struct file *file, char *buf, size_t count,
count = 2; count = 2;
} }
if (down_tasksem_interruptible(dev, &dev->read_sem)) if (taskdev_lock_interruptible(dev, &dev->read_mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
if (devstate_lock(dev, OMAP_DSP_DEVSTATE_ATTACHED) < 0) { if (devstate_lock(dev, OMAP_DSP_DEVSTATE_ATTACHED) < 0) {
ret = -ERESTARTSYS; ret = -ERESTARTSYS;
...@@ -903,7 +904,7 @@ static ssize_t dsp_task_read_wd_psv(struct file *file, char *buf, size_t count, ...@@ -903,7 +904,7 @@ static ssize_t dsp_task_read_wd_psv(struct file *file, char *buf, size_t count,
unlock_out: unlock_out:
devstate_unlock(dev); devstate_unlock(dev);
up_out: up_out:
up(&dev->read_sem); mutex_unlock(&dev->read_mutex);
return ret; return ret;
} }
...@@ -930,7 +931,7 @@ static ssize_t dsp_task_read_bk_psv(struct file *file, char *buf, size_t count, ...@@ -930,7 +931,7 @@ static ssize_t dsp_task_read_bk_psv(struct file *file, char *buf, size_t count,
return -EINVAL; return -EINVAL;
} }
if (down_tasksem_interruptible(dev, &dev->read_sem)) if (taskdev_lock_interruptible(dev, &dev->read_mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
if (devstate_lock(dev, OMAP_DSP_DEVSTATE_ATTACHED) < 0) { if (devstate_lock(dev, OMAP_DSP_DEVSTATE_ATTACHED) < 0) {
ret = -ERESTARTSYS; ret = -ERESTARTSYS;
...@@ -1023,7 +1024,7 @@ gb_out: ...@@ -1023,7 +1024,7 @@ gb_out:
unlock_out: unlock_out:
devstate_unlock(dev); devstate_unlock(dev);
up_out: up_out:
up(&dev->read_sem); mutex_unlock(&dev->read_mutex);
return ret; return ret;
} }
...@@ -1047,7 +1048,7 @@ static ssize_t dsp_task_write_wd(struct file *file, const char *buf, ...@@ -1047,7 +1048,7 @@ static ssize_t dsp_task_write_wd(struct file *file, const char *buf,
count = 2; count = 2;
} }
if (down_tasksem_interruptible(dev, &dev->write_sem)) if (taskdev_lock_interruptible(dev, &dev->write_mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
if (devstate_lock(dev, OMAP_DSP_DEVSTATE_ATTACHED) < 0) { if (devstate_lock(dev, OMAP_DSP_DEVSTATE_ATTACHED) < 0) {
ret = -ERESTARTSYS; ret = -ERESTARTSYS;
...@@ -1102,7 +1103,7 @@ static ssize_t dsp_task_write_wd(struct file *file, const char *buf, ...@@ -1102,7 +1103,7 @@ static ssize_t dsp_task_write_wd(struct file *file, const char *buf,
up_out: up_out:
if (have_devstate_lock) if (have_devstate_lock)
devstate_unlock(dev); devstate_unlock(dev);
up(&dev->write_sem); mutex_unlock(&dev->write_mutex);
return ret; return ret;
} }
...@@ -1127,7 +1128,7 @@ static ssize_t dsp_task_write_bk(struct file *file, const char *buf, ...@@ -1127,7 +1128,7 @@ static ssize_t dsp_task_write_bk(struct file *file, const char *buf,
return -EINVAL; return -EINVAL;
} }
if (down_tasksem_interruptible(dev, &dev->write_sem)) if (taskdev_lock_interruptible(dev, &dev->write_mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
if (devstate_lock(dev, OMAP_DSP_DEVSTATE_ATTACHED) < 0) { if (devstate_lock(dev, OMAP_DSP_DEVSTATE_ATTACHED) < 0) {
ret = -ERESTARTSYS; ret = -ERESTARTSYS;
...@@ -1239,7 +1240,7 @@ gb_out: ...@@ -1239,7 +1240,7 @@ gb_out:
up_out: up_out:
if (have_devstate_lock) if (have_devstate_lock)
devstate_unlock(dev); devstate_unlock(dev);
up(&dev->write_sem); mutex_unlock(&dev->write_mutex);
return ret; return ret;
} }
...@@ -1288,9 +1289,9 @@ static int dsp_task_ioctl(struct inode *inode, struct file *file, ...@@ -1288,9 +1289,9 @@ static int dsp_task_ioctl(struct inode *inode, struct file *file,
/* /*
* actually only interractive commands need to lock * actually only interractive commands need to lock
* the semaphore, but here all commands do it for simplicity. * the mutex, but here all commands do it for simplicity.
*/ */
if (down_tasksem_interruptible(dev, &dev->ioctl_sem)) if (taskdev_lock_interruptible(dev, &dev->ioctl_mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
if (devstate_lock(dev, OMAP_DSP_DEVSTATE_ATTACHED) < 0) { if (devstate_lock(dev, OMAP_DSP_DEVSTATE_ATTACHED) < 0) {
ret = -ERESTARTSYS; ret = -ERESTARTSYS;
...@@ -1417,7 +1418,7 @@ static int dsp_task_ioctl(struct inode *inode, struct file *file, ...@@ -1417,7 +1418,7 @@ static int dsp_task_ioctl(struct inode *inode, struct file *file,
unlock_out: unlock_out:
devstate_unlock(dev); devstate_unlock(dev);
up_out: up_out:
up(&dev->ioctl_sem); mutex_unlock(&dev->ioctl_mutex);
return ret; return ret;
} }
...@@ -1755,10 +1756,10 @@ static int taskdev_init(struct taskdev *dev, char *name, unsigned char minor) ...@@ -1755,10 +1756,10 @@ static int taskdev_init(struct taskdev *dev, char *name, unsigned char minor)
init_waitqueue_head(&dev->read_wait_q); init_waitqueue_head(&dev->read_wait_q);
init_waitqueue_head(&dev->write_wait_q); init_waitqueue_head(&dev->write_wait_q);
init_waitqueue_head(&dev->ioctl_wait_q); init_waitqueue_head(&dev->ioctl_wait_q);
init_MUTEX(&dev->read_sem); mutex_init(&dev->read_mutex);
init_MUTEX(&dev->write_sem); mutex_init(&dev->write_mutex);
init_MUTEX(&dev->ioctl_sem); mutex_init(&dev->ioctl_mutex);
init_MUTEX(&dev->lock_sem); mutex_init(&dev->lock);
dev->lock_pid = 0; dev->lock_pid = 0;
strncpy(dev->name, name, OMAP_DSP_TNM_LEN); strncpy(dev->name, name, OMAP_DSP_TNM_LEN);
...@@ -1901,7 +1902,7 @@ int dsp_tadd(unsigned char minor, unsigned long adr) ...@@ -1901,7 +1902,7 @@ int dsp_tadd(unsigned char minor, unsigned long adr)
argv[0] = adr >> 16; /* addrh */ argv[0] = adr >> 16; /* addrh */
argv[1] = adr & 0xffff; /* addrl */ argv[1] = adr & 0xffff; /* addrl */
if (down_interruptible(&cfg_sem)) { if (mutex_lock_interruptible(&cfg_lock)) {
ret = -ERESTARTSYS; ret = -ERESTARTSYS;
goto fail_out; goto fail_out;
} }
...@@ -1918,7 +1919,7 @@ int dsp_tadd(unsigned char minor, unsigned long adr) ...@@ -1918,7 +1919,7 @@ int dsp_tadd(unsigned char minor, unsigned long adr)
tid = cfg_tid; tid = cfg_tid;
cfg_tid = OMAP_DSP_TID_ANON; cfg_tid = OMAP_DSP_TID_ANON;
cfg_cmd = 0; cfg_cmd = 0;
up(&cfg_sem); mutex_unlock(&cfg_lock);
if (tid == OMAP_DSP_TID_ANON) { if (tid == OMAP_DSP_TID_ANON) {
printk(KERN_ERR "omapdsp: tadd failed!\n"); printk(KERN_ERR "omapdsp: tadd failed!\n");
...@@ -1962,7 +1963,7 @@ del_out: ...@@ -1962,7 +1963,7 @@ del_out:
dev->state = OMAP_DSP_DEVSTATE_DELING; dev->state = OMAP_DSP_DEVSTATE_DELING;
if (down_interruptible(&cfg_sem)) { if (mutex_lock_interruptible(&cfg_lock)) {
printk(KERN_ERR "omapdsp: aborting tdel process. " printk(KERN_ERR "omapdsp: aborting tdel process. "
"DSP side could be corrupted.\n"); "DSP side could be corrupted.\n");
goto fail_out; goto fail_out;
...@@ -1974,7 +1975,7 @@ del_out: ...@@ -1974,7 +1975,7 @@ del_out:
tid_response = cfg_tid; tid_response = cfg_tid;
cfg_tid = OMAP_DSP_TID_ANON; cfg_tid = OMAP_DSP_TID_ANON;
cfg_cmd = 0; cfg_cmd = 0;
up(&cfg_sem); mutex_unlock(&cfg_lock);
if (tid_response != tid) if (tid_response != tid)
printk(KERN_ERR "omapdsp: tdel failed. " printk(KERN_ERR "omapdsp: tdel failed. "
...@@ -2043,7 +2044,7 @@ static int dsp_tdel_bh(unsigned char minor, unsigned short type) ...@@ -2043,7 +2044,7 @@ static int dsp_tdel_bh(unsigned char minor, unsigned short type)
task = dev->task; task = dev->task;
tid = task->tid; tid = task->tid;
if (down_interruptible(&cfg_sem)) { if (mutex_lock_interruptible(&cfg_lock)) {
if (type == OMAP_DSP_MBCMD_TDEL_SAFE) { if (type == OMAP_DSP_MBCMD_TDEL_SAFE) {
dev->state = OMAP_DSP_DEVSTATE_DELREQ; dev->state = OMAP_DSP_DEVSTATE_DELREQ;
return -ERESTARTSYS; return -ERESTARTSYS;
...@@ -2060,7 +2061,7 @@ static int dsp_tdel_bh(unsigned char minor, unsigned short type) ...@@ -2060,7 +2061,7 @@ static int dsp_tdel_bh(unsigned char minor, unsigned short type)
tid_response = cfg_tid; tid_response = cfg_tid;
cfg_tid = OMAP_DSP_TID_ANON; cfg_tid = OMAP_DSP_TID_ANON;
cfg_cmd = 0; cfg_cmd = 0;
up(&cfg_sem); mutex_unlock(&cfg_lock);
detach_out: detach_out:
taskdev_detach_task(dev); taskdev_detach_task(dev);
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <linux/poll.h> #include <linux/poll.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/mutex.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/arch/dsp.h> #include <asm/arch/dsp.h>
...@@ -111,10 +112,10 @@ static unsigned int dsp_twch_poll(struct file *file, poll_table *wait) ...@@ -111,10 +112,10 @@ static unsigned int dsp_twch_poll(struct file *file, poll_table *wait)
static int dsp_twch_ioctl(struct inode *inode, struct file *file, static int dsp_twch_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
static DECLARE_MUTEX(ioctl_sem); static DEFINE_MUTEX(ioctl_lock);
int ret; int ret;
if (down_interruptible(&ioctl_sem)) if (mutex_lock_interruptible(&ioctl_lock))
return -ERESTARTSYS; return -ERESTARTSYS;
switch (cmd) { switch (cmd) {
...@@ -166,7 +167,7 @@ static int dsp_twch_ioctl(struct inode *inode, struct file *file, ...@@ -166,7 +167,7 @@ static int dsp_twch_ioctl(struct inode *inode, struct file *file,
} }
up_out: up_out:
up(&ioctl_sem); mutex_unlock(&ioctl_lock);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment