[MIPS] MT: Functional fixes and a little reformatting of APRP support
Signed-off-by: Kevin D. Kissell <kevink@mips.com> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
This commit is contained in:
parent
9f2546aded
commit
1928cc84a0
|
@ -56,9 +56,9 @@ obj-$(CONFIG_MIPS_MT_SMP) += smp-mt.o
|
||||||
obj-$(CONFIG_MIPS_CMP) += smp-cmp.o
|
obj-$(CONFIG_MIPS_CMP) += smp-cmp.o
|
||||||
obj-$(CONFIG_CPU_MIPSR2) += spram.o
|
obj-$(CONFIG_CPU_MIPSR2) += spram.o
|
||||||
|
|
||||||
obj-$(CONFIG_MIPS_APSP_KSPD) += kspd.o
|
|
||||||
obj-$(CONFIG_MIPS_VPE_LOADER) += vpe.o
|
obj-$(CONFIG_MIPS_VPE_LOADER) += vpe.o
|
||||||
obj-$(CONFIG_MIPS_VPE_APSP_API) += rtlx.o
|
obj-$(CONFIG_MIPS_VPE_APSP_API) += rtlx.o
|
||||||
|
obj-$(CONFIG_MIPS_APSP_KSPD) += kspd.o
|
||||||
|
|
||||||
obj-$(CONFIG_I8259) += i8259.o
|
obj-$(CONFIG_I8259) += i8259.o
|
||||||
obj-$(CONFIG_IRQ_CPU) += irq_cpu.o
|
obj-$(CONFIG_IRQ_CPU) += irq_cpu.o
|
||||||
|
|
|
@ -257,7 +257,7 @@ void sp_work_handle_request(void)
|
||||||
|
|
||||||
vcwd = vpe_getcwd(tclimit);
|
vcwd = vpe_getcwd(tclimit);
|
||||||
|
|
||||||
/* change to the cwd of the process that loaded the SP program */
|
/* change to cwd of the process that loaded the SP program */
|
||||||
old_fs = get_fs();
|
old_fs = get_fs();
|
||||||
set_fs(KERNEL_DS);
|
set_fs(KERNEL_DS);
|
||||||
sys_chdir(vcwd);
|
sys_chdir(vcwd);
|
||||||
|
@ -323,6 +323,9 @@ static void sp_cleanup(void)
|
||||||
set >>= 1;
|
set >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Put daemon cwd back to root to avoid umount problems */
|
||||||
|
sys_chdir("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int channel_open = 0;
|
static int channel_open = 0;
|
||||||
|
|
|
@ -72,6 +72,15 @@ static void rtlx_dispatch(void)
|
||||||
static irqreturn_t rtlx_interrupt(int irq, void *dev_id)
|
static irqreturn_t rtlx_interrupt(int irq, void *dev_id)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
unsigned int flags, vpeflags;
|
||||||
|
|
||||||
|
/* Ought not to be strictly necessary for SMTC builds */
|
||||||
|
local_irq_save(flags);
|
||||||
|
vpeflags = dvpe();
|
||||||
|
set_c0_status(0x100 << MIPS_CPU_RTLX_IRQ);
|
||||||
|
irq_enable_hazard();
|
||||||
|
evpe(vpeflags);
|
||||||
|
local_irq_restore(flags);
|
||||||
|
|
||||||
for (i = 0; i < RTLX_CHANNELS; i++) {
|
for (i = 0; i < RTLX_CHANNELS; i++) {
|
||||||
wake_up(&channel_wqs[i].lx_queue);
|
wake_up(&channel_wqs[i].lx_queue);
|
||||||
|
@ -108,7 +117,8 @@ static void __used dump_rtlx(void)
|
||||||
static int rtlx_init(struct rtlx_info *rtlxi)
|
static int rtlx_init(struct rtlx_info *rtlxi)
|
||||||
{
|
{
|
||||||
if (rtlxi->id != RTLX_ID) {
|
if (rtlxi->id != RTLX_ID) {
|
||||||
printk(KERN_ERR "no valid RTLX id at 0x%p 0x%lx\n", rtlxi, rtlxi->id);
|
printk(KERN_ERR "no valid RTLX id at 0x%p 0x%lx\n",
|
||||||
|
rtlxi, rtlxi->id);
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,18 +172,17 @@ int rtlx_open(int index, int can_sleep)
|
||||||
|
|
||||||
if (rtlx == NULL) {
|
if (rtlx == NULL) {
|
||||||
if( (p = vpe_get_shared(tclimit)) == NULL) {
|
if( (p = vpe_get_shared(tclimit)) == NULL) {
|
||||||
if (can_sleep) {
|
if (can_sleep) {
|
||||||
__wait_event_interruptible(channel_wqs[index].lx_queue,
|
__wait_event_interruptible(channel_wqs[index].lx_queue,
|
||||||
(p = vpe_get_shared(tclimit)),
|
(p = vpe_get_shared(tclimit)), ret);
|
||||||
ret);
|
if (ret)
|
||||||
if (ret)
|
|
||||||
goto out_fail;
|
|
||||||
} else {
|
|
||||||
printk(KERN_DEBUG "No SP program loaded, and device "
|
|
||||||
"opened with O_NONBLOCK\n");
|
|
||||||
ret = -ENOSYS;
|
|
||||||
goto out_fail;
|
goto out_fail;
|
||||||
}
|
} else {
|
||||||
|
printk(KERN_DEBUG "No SP program loaded, and device "
|
||||||
|
"opened with O_NONBLOCK\n");
|
||||||
|
ret = -ENOSYS;
|
||||||
|
goto out_fail;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
smp_rmb();
|
smp_rmb();
|
||||||
|
@ -182,7 +191,9 @@ int rtlx_open(int index, int can_sleep)
|
||||||
DEFINE_WAIT(wait);
|
DEFINE_WAIT(wait);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
prepare_to_wait(&channel_wqs[index].lx_queue, &wait, TASK_INTERRUPTIBLE);
|
prepare_to_wait(
|
||||||
|
&channel_wqs[index].lx_queue,
|
||||||
|
&wait, TASK_INTERRUPTIBLE);
|
||||||
smp_rmb();
|
smp_rmb();
|
||||||
if (*p != NULL)
|
if (*p != NULL)
|
||||||
break;
|
break;
|
||||||
|
@ -195,7 +206,7 @@ int rtlx_open(int index, int can_sleep)
|
||||||
}
|
}
|
||||||
finish_wait(&channel_wqs[index].lx_queue, &wait);
|
finish_wait(&channel_wqs[index].lx_queue, &wait);
|
||||||
} else {
|
} else {
|
||||||
printk(" *vpe_get_shared is NULL. "
|
pr_err(" *vpe_get_shared is NULL. "
|
||||||
"Has an SP program been loaded?\n");
|
"Has an SP program been loaded?\n");
|
||||||
ret = -ENOSYS;
|
ret = -ENOSYS;
|
||||||
goto out_fail;
|
goto out_fail;
|
||||||
|
@ -203,8 +214,9 @@ int rtlx_open(int index, int can_sleep)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((unsigned int)*p < KSEG0) {
|
if ((unsigned int)*p < KSEG0) {
|
||||||
printk(KERN_WARNING "vpe_get_shared returned an invalid pointer "
|
printk(KERN_WARNING "vpe_get_shared returned an "
|
||||||
"maybe an error code %d\n", (int)*p);
|
"invalid pointer maybe an error code %d\n",
|
||||||
|
(int)*p);
|
||||||
ret = -ENOSYS;
|
ret = -ENOSYS;
|
||||||
goto out_fail;
|
goto out_fail;
|
||||||
}
|
}
|
||||||
|
@ -232,6 +244,10 @@ out_ret:
|
||||||
|
|
||||||
int rtlx_release(int index)
|
int rtlx_release(int index)
|
||||||
{
|
{
|
||||||
|
if (rtlx == NULL) {
|
||||||
|
pr_err("rtlx_release() with null rtlx\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
rtlx->channel[index].lx_state = RTLX_STATE_UNUSED;
|
rtlx->channel[index].lx_state = RTLX_STATE_UNUSED;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -251,8 +267,8 @@ unsigned int rtlx_read_poll(int index, int can_sleep)
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
__wait_event_interruptible(channel_wqs[index].lx_queue,
|
__wait_event_interruptible(channel_wqs[index].lx_queue,
|
||||||
chan->lx_read != chan->lx_write || sp_stopping,
|
(chan->lx_read != chan->lx_write) ||
|
||||||
ret);
|
sp_stopping, ret);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -282,7 +298,9 @@ static inline int write_spacefree(int read, int write, int size)
|
||||||
unsigned int rtlx_write_poll(int index)
|
unsigned int rtlx_write_poll(int index)
|
||||||
{
|
{
|
||||||
struct rtlx_channel *chan = &rtlx->channel[index];
|
struct rtlx_channel *chan = &rtlx->channel[index];
|
||||||
return write_spacefree(chan->rt_read, chan->rt_write, chan->buffer_size);
|
|
||||||
|
return write_spacefree(chan->rt_read, chan->rt_write,
|
||||||
|
chan->buffer_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t rtlx_read(int index, void __user *buff, size_t count)
|
ssize_t rtlx_read(int index, void __user *buff, size_t count)
|
||||||
|
@ -344,8 +362,8 @@ ssize_t rtlx_write(int index, const void __user *buffer, size_t count)
|
||||||
rt_read = rt->rt_read;
|
rt_read = rt->rt_read;
|
||||||
|
|
||||||
/* total number of bytes to copy */
|
/* total number of bytes to copy */
|
||||||
count = min(count,
|
count = min(count, (size_t)write_spacefree(rt_read, rt->rt_write,
|
||||||
(size_t)write_spacefree(rt_read, rt->rt_write, rt->buffer_size));
|
rt->buffer_size));
|
||||||
|
|
||||||
/* first bit from write pointer to the end of the buffer, or count */
|
/* first bit from write pointer to the end of the buffer, or count */
|
||||||
fl = min(count, (size_t) rt->buffer_size - rt->rt_write);
|
fl = min(count, (size_t) rt->buffer_size - rt->rt_write);
|
||||||
|
@ -514,6 +532,11 @@ static int __init rtlx_module_init(void)
|
||||||
|
|
||||||
if (cpu_has_vint)
|
if (cpu_has_vint)
|
||||||
set_vi_handler(MIPS_CPU_RTLX_IRQ, rtlx_dispatch);
|
set_vi_handler(MIPS_CPU_RTLX_IRQ, rtlx_dispatch);
|
||||||
|
else {
|
||||||
|
pr_err("APRP RTLX init on non-vectored-interrupt processor\n");
|
||||||
|
err = -ENODEV;
|
||||||
|
goto out_chrdev;
|
||||||
|
}
|
||||||
|
|
||||||
rtlx_irq.dev_id = rtlx;
|
rtlx_irq.dev_id = rtlx;
|
||||||
setup_irq(rtlx_irq_num, &rtlx_irq);
|
setup_irq(rtlx_irq_num, &rtlx_irq);
|
||||||
|
|
|
@ -29,13 +29,13 @@ extern unsigned int rtlx_read_poll(int index, int can_sleep);
|
||||||
extern unsigned int rtlx_write_poll(int index);
|
extern unsigned int rtlx_write_poll(int index);
|
||||||
|
|
||||||
enum rtlx_state {
|
enum rtlx_state {
|
||||||
RTLX_STATE_UNUSED,
|
RTLX_STATE_UNUSED = 0,
|
||||||
RTLX_STATE_INITIALISED,
|
RTLX_STATE_INITIALISED,
|
||||||
RTLX_STATE_REMOTE_READY,
|
RTLX_STATE_REMOTE_READY,
|
||||||
RTLX_STATE_OPENED
|
RTLX_STATE_OPENED
|
||||||
};
|
};
|
||||||
|
|
||||||
#define RTLX_BUFFER_SIZE 1024
|
#define RTLX_BUFFER_SIZE 2048
|
||||||
|
|
||||||
/* each channel supports read and write.
|
/* each channel supports read and write.
|
||||||
linux (vpe0) reads lx_buffer and writes rt_buffer
|
linux (vpe0) reads lx_buffer and writes rt_buffer
|
||||||
|
|
Loading…
Reference in New Issue