Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 96412
b: refs/heads/master
c: 1928cc8
h: refs/heads/master
v: v3
  • Loading branch information
Kevin D. Kissell authored and Ralf Baechle committed May 12, 2008
1 parent a154929 commit 8cda971
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 26 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9f2546adedda600687bba6ef3e1546a8ecbc16eb
refs/heads/master: 1928cc84a0a937ce7042d9235996ab380f36f18a
2 changes: 1 addition & 1 deletion trunk/arch/mips/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ obj-$(CONFIG_MIPS_MT_SMP) += smp-mt.o
obj-$(CONFIG_MIPS_CMP) += smp-cmp.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_APSP_API) += rtlx.o
obj-$(CONFIG_MIPS_APSP_KSPD) += kspd.o

obj-$(CONFIG_I8259) += i8259.o
obj-$(CONFIG_IRQ_CPU) += irq_cpu.o
Expand Down
5 changes: 4 additions & 1 deletion trunk/arch/mips/kernel/kspd.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ void sp_work_handle_request(void)

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();
set_fs(KERNEL_DS);
sys_chdir(vcwd);
Expand Down Expand Up @@ -323,6 +323,9 @@ static void sp_cleanup(void)
set >>= 1;
}
}

/* Put daemon cwd back to root to avoid umount problems */
sys_chdir("/");
}

static int channel_open = 0;
Expand Down
65 changes: 44 additions & 21 deletions trunk/arch/mips/kernel/rtlx.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ static void rtlx_dispatch(void)
static irqreturn_t rtlx_interrupt(int irq, void *dev_id)
{
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++) {
wake_up(&channel_wqs[i].lx_queue);
Expand Down Expand Up @@ -108,7 +117,8 @@ static void __used dump_rtlx(void)
static int rtlx_init(struct rtlx_info *rtlxi)
{
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;
}

Expand Down Expand Up @@ -162,18 +172,17 @@ int rtlx_open(int index, int can_sleep)

if (rtlx == NULL) {
if( (p = vpe_get_shared(tclimit)) == NULL) {
if (can_sleep) {
__wait_event_interruptible(channel_wqs[index].lx_queue,
(p = vpe_get_shared(tclimit)),
ret);
if (ret)
goto out_fail;
} else {
printk(KERN_DEBUG "No SP program loaded, and device "
"opened with O_NONBLOCK\n");
ret = -ENOSYS;
if (can_sleep) {
__wait_event_interruptible(channel_wqs[index].lx_queue,
(p = vpe_get_shared(tclimit)), 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;
}
}

smp_rmb();
Expand All @@ -182,7 +191,9 @@ int rtlx_open(int index, int can_sleep)
DEFINE_WAIT(wait);

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();
if (*p != NULL)
break;
Expand All @@ -195,16 +206,17 @@ int rtlx_open(int index, int can_sleep)
}
finish_wait(&channel_wqs[index].lx_queue, &wait);
} else {
printk(" *vpe_get_shared is NULL. "
pr_err(" *vpe_get_shared is NULL. "
"Has an SP program been loaded?\n");
ret = -ENOSYS;
goto out_fail;
}
}

if ((unsigned int)*p < KSEG0) {
printk(KERN_WARNING "vpe_get_shared returned an invalid pointer "
"maybe an error code %d\n", (int)*p);
printk(KERN_WARNING "vpe_get_shared returned an "
"invalid pointer maybe an error code %d\n",
(int)*p);
ret = -ENOSYS;
goto out_fail;
}
Expand Down Expand Up @@ -232,6 +244,10 @@ int rtlx_open(int index, int can_sleep)

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;
return 0;
}
Expand All @@ -251,8 +267,8 @@ unsigned int rtlx_read_poll(int index, int can_sleep)
int ret = 0;

__wait_event_interruptible(channel_wqs[index].lx_queue,
chan->lx_read != chan->lx_write || sp_stopping,
ret);
(chan->lx_read != chan->lx_write) ||
sp_stopping, ret);
if (ret)
return ret;

Expand Down Expand Up @@ -282,7 +298,9 @@ static inline int write_spacefree(int read, int write, int size)
unsigned int rtlx_write_poll(int 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)
Expand Down Expand Up @@ -344,8 +362,8 @@ ssize_t rtlx_write(int index, const void __user *buffer, size_t count)
rt_read = rt->rt_read;

/* total number of bytes to copy */
count = min(count,
(size_t)write_spacefree(rt_read, rt->rt_write, rt->buffer_size));
count = min(count, (size_t)write_spacefree(rt_read, rt->rt_write,
rt->buffer_size));

/* first bit from write pointer to the end of the buffer, or count */
fl = min(count, (size_t) rt->buffer_size - rt->rt_write);
Expand Down Expand Up @@ -514,6 +532,11 @@ static int __init rtlx_module_init(void)

if (cpu_has_vint)
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;
setup_irq(rtlx_irq_num, &rtlx_irq);
Expand Down
4 changes: 2 additions & 2 deletions trunk/include/asm-mips/rtlx.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ extern unsigned int rtlx_read_poll(int index, int can_sleep);
extern unsigned int rtlx_write_poll(int index);

enum rtlx_state {
RTLX_STATE_UNUSED,
RTLX_STATE_UNUSED = 0,
RTLX_STATE_INITIALISED,
RTLX_STATE_REMOTE_READY,
RTLX_STATE_OPENED
};

#define RTLX_BUFFER_SIZE 1024
#define RTLX_BUFFER_SIZE 2048

/* each channel supports read and write.
linux (vpe0) reads lx_buffer and writes rt_buffer
Expand Down

0 comments on commit 8cda971

Please sign in to comment.