Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
raspberrypi-kernel
提交
c4c4018b
R
raspberrypi-kernel
项目概览
openeuler
/
raspberrypi-kernel
通知
13
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
raspberrypi-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c4c4018b
编写于
2月 23, 2007
作者:
R
Ralf Baechle
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[MIPS] RTLX, VPE: Make open actually atomic.
Signed-off-by:
N
Ralf Baechle
<
ralf@linux-mips.org
>
上级
cbc84135
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
28 deletion
+23
-28
arch/mips/kernel/rtlx.c
arch/mips/kernel/rtlx.c
+20
-24
arch/mips/kernel/vpe.c
arch/mips/kernel/vpe.c
+3
-4
未找到文件。
arch/mips/kernel/rtlx.c
浏览文件 @
c4c4018b
...
...
@@ -53,7 +53,7 @@ static char module_name[] = "rtlx";
static
struct
chan_waitqueues
{
wait_queue_head_t
rt_queue
;
wait_queue_head_t
lx_queue
;
in
t
in_open
;
atomic_
t
in_open
;
}
channel_wqs
[
RTLX_CHANNELS
];
static
struct
irqaction
irq
;
...
...
@@ -148,6 +148,7 @@ int rtlx_open(int index, int can_sleep)
{
volatile
struct
rtlx_info
**
p
;
struct
rtlx_channel
*
chan
;
enum
rtlx_state
state
;
int
ret
=
0
;
if
(
index
>=
RTLX_CHANNELS
)
{
...
...
@@ -155,13 +156,13 @@ int rtlx_open(int index, int can_sleep)
return
-
ENOSYS
;
}
if
(
channel_wqs
[
index
].
in_open
)
{
printk
(
KERN_DEBUG
"rtlx_open channel %d already opened
\n
"
,
index
);
return
-
EBUSY
;
if
(
atomic_inc_return
(
&
channel_wqs
[
index
].
in_open
)
>
1
)
{
printk
(
KERN_DEBUG
"rtlx_open channel %d already opened
\n
"
,
index
);
ret
=
-
EBUSY
;
goto
out_fail
;
}
channel_wqs
[
index
].
in_open
++
;
if
(
rtlx
==
NULL
)
{
if
(
(
p
=
vpe_get_shared
(
RTLX_TARG_VPE
))
==
NULL
)
{
if
(
can_sleep
)
{
...
...
@@ -173,9 +174,8 @@ int rtlx_open(int index, int can_sleep)
if
(
ret
)
goto
out_fail
;
}
else
{
printk
(
KERN_DEBUG
"No SP program loaded, and device "
printk
(
KERN_DEBUG
"No SP program loaded, and device "
"opened with O_NONBLOCK
\n
"
);
channel_wqs
[
index
].
in_open
=
0
;
ret
=
-
ENOSYS
;
goto
out_fail
;
}
...
...
@@ -193,7 +193,6 @@ int rtlx_open(int index, int can_sleep)
}
else
{
printk
(
" *vpe_get_shared is NULL. "
"Has an SP program been loaded?
\n
"
);
channel_wqs
[
index
].
in_open
=
0
;
ret
=
-
ENOSYS
;
goto
out_fail
;
}
...
...
@@ -202,31 +201,28 @@ int rtlx_open(int index, int can_sleep)
if
((
unsigned
int
)
*
p
<
KSEG0
)
{
printk
(
KERN_WARNING
"vpe_get_shared returned an invalid pointer "
"maybe an error code %d
\n
"
,
(
int
)
*
p
);
channel_wqs
[
index
].
in_open
=
0
;
ret
=
-
ENOSYS
;
goto
out_fail
;
}
if
((
ret
=
rtlx_init
(
*
p
))
<
0
)
{
channel_wqs
[
index
].
in_open
=
0
;
return
ret
;
}
if
((
ret
=
rtlx_init
(
*
p
))
<
0
)
goto
out_ret
;
}
chan
=
&
rtlx
->
channel
[
index
];
if
(
chan
->
lx_state
==
RTLX_STATE_OPENED
)
{
channel_wqs
[
index
].
in_open
=
0
;
return
-
EBUSY
;
}
chan
->
lx_state
=
RTLX_STATE_OPENED
;
channel_wqs
[
index
].
in_open
=
0
;
return
0
;
state
=
xchg
(
&
chan
->
lx_state
,
RTLX_STATE_OPENED
);
if
(
state
==
RTLX_STATE_OPENED
)
{
ret
=
-
EBUSY
;
goto
out_fail
;
}
out_fail:
channel_wqs
[
index
].
in_open
--
;
smp_mb
();
atomic_dec
(
&
channel_wqs
[
index
].
in_open
);
smp_mb
();
out_ret:
return
ret
;
}
...
...
@@ -475,7 +471,7 @@ static int rtlx_module_init(void)
for
(
i
=
0
;
i
<
RTLX_CHANNELS
;
i
++
)
{
init_waitqueue_head
(
&
channel_wqs
[
i
].
rt_queue
);
init_waitqueue_head
(
&
channel_wqs
[
i
].
lx_queue
);
channel_wqs
[
i
].
in_open
=
0
;
atomic_set
(
&
channel_wqs
[
i
].
in_open
,
0
)
;
dev
=
device_create
(
mt_class
,
NULL
,
MKDEV
(
major
,
i
),
"%s%d"
,
module_name
,
i
);
...
...
arch/mips/kernel/vpe.c
浏览文件 @
c4c4018b
...
...
@@ -1079,6 +1079,7 @@ static int getcwd(char *buff, int size)
static
int
vpe_open
(
struct
inode
*
inode
,
struct
file
*
filp
)
{
int
minor
,
ret
;
enum
vpe_state
state
;
struct
vpe
*
v
;
struct
vpe_notifications
*
not
;
...
...
@@ -1093,7 +1094,8 @@ static int vpe_open(struct inode *inode, struct file *filp)
return
-
ENODEV
;
}
if
(
v
->
state
!=
VPE_STATE_UNUSED
)
{
state
=
xchg
(
&
v
->
state
,
VPE_STATE_INUSE
);
if
(
state
!=
VPE_STATE_UNUSED
)
{
dvpe
();
printk
(
KERN_DEBUG
"VPE loader: tc in use dumping regs
\n
"
);
...
...
@@ -1108,9 +1110,6 @@ static int vpe_open(struct inode *inode, struct file *filp)
cleanup_tc
(
get_tc
(
minor
));
}
// allocate it so when we get write ops we know it's expected.
v
->
state
=
VPE_STATE_INUSE
;
/* this of-course trashes what was there before... */
v
->
pbuffer
=
vmalloc
(
P_SIZE
);
v
->
plen
=
P_SIZE
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录