Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
67e2ccce
Commit
67e2ccce
authored
Feb 22, 2007
by
Ralf Baechle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[MIPS] RTLX: Handle signals when sleeping.
Signed-off-by:
Ralf Baechle
<
ralf@linux-mips.org
>
parent
cc39cb15
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
80 deletions
+42
-80
arch/mips/kernel/rtlx.c
arch/mips/kernel/rtlx.c
+42
-80
No files found.
arch/mips/kernel/rtlx.c
View file @
67e2ccce
...
@@ -146,9 +146,9 @@ static void stopping(int vpe)
...
@@ -146,9 +146,9 @@ static void stopping(int vpe)
int
rtlx_open
(
int
index
,
int
can_sleep
)
int
rtlx_open
(
int
index
,
int
can_sleep
)
{
{
int
ret
;
struct
rtlx_channel
*
chan
;
volatile
struct
rtlx_info
**
p
;
volatile
struct
rtlx_info
**
p
;
struct
rtlx_channel
*
chan
;
int
ret
=
0
;
if
(
index
>=
RTLX_CHANNELS
)
{
if
(
index
>=
RTLX_CHANNELS
)
{
printk
(
KERN_DEBUG
"rtlx_open index out of range
\n
"
);
printk
(
KERN_DEBUG
"rtlx_open index out of range
\n
"
);
...
@@ -165,65 +165,37 @@ int rtlx_open(int index, int can_sleep)
...
@@ -165,65 +165,37 @@ int rtlx_open(int index, int can_sleep)
if
(
rtlx
==
NULL
)
{
if
(
rtlx
==
NULL
)
{
if
(
(
p
=
vpe_get_shared
(
RTLX_TARG_VPE
))
==
NULL
)
{
if
(
(
p
=
vpe_get_shared
(
RTLX_TARG_VPE
))
==
NULL
)
{
if
(
can_sleep
)
{
if
(
can_sleep
)
{
DECLARE_WAITQUEUE
(
wait
,
current
);
int
ret
=
0
;
/* go to sleep */
add_wait_queue
(
&
channel_wqs
[
index
].
lx_queue
,
&
wait
);
set_current_state
(
TASK_INTERRUPTIBLE
);
while
((
p
=
vpe_get_shared
(
RTLX_TARG_VPE
))
==
NULL
)
{
schedule
();
set_current_state
(
TASK_INTERRUPTIBLE
);
}
set_current_state
(
TASK_RUNNING
);
__wait_event_interruptible
(
channel_wqs
[
index
].
lx_queue
,
remove_wait_queue
(
&
channel_wqs
[
index
].
lx_queue
,
&
wait
);
(
p
=
vpe_get_shared
(
RTLX_TARG_VPE
)),
ret
);
/* back running */
if
(
ret
)
goto
out_fail
;
}
else
{
}
else
{
printk
(
KERN_DEBUG
"No SP program loaded, and device "
printk
(
KERN_DEBUG
"No SP program loaded, and device "
"opened with O_NONBLOCK
\n
"
);
"opened with O_NONBLOCK
\n
"
);
channel_wqs
[
index
].
in_open
=
0
;
channel_wqs
[
index
].
in_open
=
0
;
return
-
ENOSYS
;
ret
=
-
ENOSYS
;
goto
out_fail
;
}
}
}
}
if
(
*
p
==
NULL
)
{
if
(
*
p
==
NULL
)
{
if
(
can_sleep
)
{
if
(
can_sleep
)
{
DECLARE_WAITQUEUE
(
wait
,
current
);
int
ret
=
0
;
/* go to sleep */
add_wait_queue
(
&
channel_wqs
[
index
].
lx_queue
,
&
wait
);
set_current_state
(
TASK_INTERRUPTIBLE
);
while
(
*
p
==
NULL
)
{
schedule
();
/* reset task state to interruptable otherwise
__wait_event_interruptible
(
channel_wqs
[
index
].
lx_queue
,
we'll whizz round here like a very fast loopy
*
p
!=
NULL
,
thing. schedule() appears to return with state
ret
);
set to TASK_RUNNING.
if
(
ret
)
goto
out_fail
;
If the loaded SP program, for whatever reason,
}
else
{
doesn't set up the shared structure *p will never
become true. So whoever connected to either /dev/rt?
or if it was kspd, will then take up rather a lot of
processor cycles.
*/
set_current_state
(
TASK_INTERRUPTIBLE
);
}
set_current_state
(
TASK_RUNNING
);
remove_wait_queue
(
&
channel_wqs
[
index
].
lx_queue
,
&
wait
);
/* back running */
}
else
{
printk
(
" *vpe_get_shared is NULL. "
printk
(
" *vpe_get_shared is NULL. "
"Has an SP program been loaded?
\n
"
);
"Has an SP program been loaded?
\n
"
);
channel_wqs
[
index
].
in_open
=
0
;
channel_wqs
[
index
].
in_open
=
0
;
return
-
ENOSYS
;
ret
=
-
ENOSYS
;
goto
out_fail
;
}
}
}
}
...
@@ -231,7 +203,8 @@ int rtlx_open(int index, int can_sleep)
...
@@ -231,7 +203,8 @@ int rtlx_open(int index, int can_sleep)
printk
(
KERN_WARNING
"vpe_get_shared returned an invalid pointer "
printk
(
KERN_WARNING
"vpe_get_shared returned an invalid pointer "
"maybe an error code %d
\n
"
,
(
int
)
*
p
);
"maybe an error code %d
\n
"
,
(
int
)
*
p
);
channel_wqs
[
index
].
in_open
=
0
;
channel_wqs
[
index
].
in_open
=
0
;
return
-
ENOSYS
;
ret
=
-
ENOSYS
;
goto
out_fail
;
}
}
if
((
ret
=
rtlx_init
(
*
p
))
<
0
)
{
if
((
ret
=
rtlx_init
(
*
p
))
<
0
)
{
...
@@ -250,6 +223,11 @@ int rtlx_open(int index, int can_sleep)
...
@@ -250,6 +223,11 @@ int rtlx_open(int index, int can_sleep)
chan
->
lx_state
=
RTLX_STATE_OPENED
;
chan
->
lx_state
=
RTLX_STATE_OPENED
;
channel_wqs
[
index
].
in_open
=
0
;
channel_wqs
[
index
].
in_open
=
0
;
return
0
;
return
0
;
out_fail:
channel_wqs
[
index
].
in_open
--
;
return
ret
;
}
}
int
rtlx_release
(
int
index
)
int
rtlx_release
(
int
index
)
...
@@ -270,30 +248,17 @@ unsigned int rtlx_read_poll(int index, int can_sleep)
...
@@ -270,30 +248,17 @@ unsigned int rtlx_read_poll(int index, int can_sleep)
/* data available to read? */
/* data available to read? */
if
(
chan
->
lx_read
==
chan
->
lx_write
)
{
if
(
chan
->
lx_read
==
chan
->
lx_write
)
{
if
(
can_sleep
)
{
if
(
can_sleep
)
{
DECLARE_WAITQUEUE
(
wait
,
current
)
;
int
ret
=
0
;
/* go to sleep */
__wait_event_interruptible
(
channel_wqs
[
index
].
lx_queue
,
add_wait_queue
(
&
channel_wqs
[
index
].
lx_queue
,
&
wait
);
chan
->
lx_read
!=
chan
->
lx_write
||
sp_stopping
,
ret
);
set_current_state
(
TASK_INTERRUPTIBLE
);
if
(
ret
)
while
(
chan
->
lx_read
==
chan
->
lx_write
)
{
return
ret
;
schedule
();
set_current_state
(
TASK_INTERRUPTIBLE
);
if
(
sp_stopping
)
{
if
(
sp_stopping
)
set_current_state
(
TASK_RUNNING
);
remove_wait_queue
(
&
channel_wqs
[
index
].
lx_queue
,
&
wait
);
return
0
;
return
0
;
}
}
else
}
set_current_state
(
TASK_RUNNING
);
remove_wait_queue
(
&
channel_wqs
[
index
].
lx_queue
,
&
wait
);
/* back running */
}
else
return
0
;
return
0
;
}
}
...
@@ -454,25 +419,22 @@ static ssize_t file_write(struct file *file, const char __user * buffer,
...
@@ -454,25 +419,22 @@ static ssize_t file_write(struct file *file, const char __user * buffer,
{
{
int
minor
;
int
minor
;
struct
rtlx_channel
*
rt
;
struct
rtlx_channel
*
rt
;
DECLARE_WAITQUEUE
(
wait
,
current
);
minor
=
iminor
(
file
->
f_path
.
dentry
->
d_inode
);
minor
=
iminor
(
file
->
f_path
.
dentry
->
d_inode
);
rt
=
&
rtlx
->
channel
[
minor
];
rt
=
&
rtlx
->
channel
[
minor
];
/* any space left... */
/* any space left... */
if
(
!
rtlx_write_poll
(
minor
))
{
if
(
!
rtlx_write_poll
(
minor
))
{
int
ret
=
0
;
if
(
file
->
f_flags
&
O_NONBLOCK
)
if
(
file
->
f_flags
&
O_NONBLOCK
)
return
-
EAGAIN
;
return
-
EAGAIN
;
add_wait_queue
(
&
channel_wqs
[
minor
].
rt_queue
,
&
wait
);
__wait_event_interruptible
(
channel_wqs
[
minor
].
rt_queue
,
set_current_state
(
TASK_INTERRUPTIBLE
);
rtlx_write_poll
(
minor
),
ret
);
while
(
!
rtlx_write_poll
(
minor
))
if
(
ret
)
schedule
();
return
ret
;
set_current_state
(
TASK_RUNNING
);
remove_wait_queue
(
&
channel_wqs
[
minor
].
rt_queue
,
&
wait
);
}
}
return
rtlx_write
(
minor
,
(
void
*
)
buffer
,
count
,
1
);
return
rtlx_write
(
minor
,
(
void
*
)
buffer
,
count
,
1
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment