Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
cd8c79f1
K
Kernel
项目概览
openeuler
/
Kernel
1 年多 前同步成功
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
cd8c79f1
编写于
8月 09, 2008
作者:
S
Stefan Richter
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ieee1394: sbp2: check for DMA mapping failures
Signed-off-by:
N
Stefan Richter
<
stefanr@s5r6.in-berlin.de
>
上级
0a77b17c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
59 addition
and
35 deletion
+59
-35
drivers/ieee1394/sbp2.c
drivers/ieee1394/sbp2.c
+59
-35
未找到文件。
drivers/ieee1394/sbp2.c
浏览文件 @
cd8c79f1
...
...
@@ -526,26 +526,41 @@ static void sbp2util_write_doorbell(struct work_struct *work)
static
int
sbp2util_create_command_orb_pool
(
struct
sbp2_lu
*
lu
)
{
struct
sbp2_fwhost_info
*
hi
=
lu
->
hi
;
struct
sbp2_command_info
*
cmd
;
struct
device
*
dmadev
=
lu
->
hi
->
host
->
device
.
parent
;
int
i
,
orbs
=
sbp2_serialize_io
?
2
:
SBP2_MAX_CMDS
;
for
(
i
=
0
;
i
<
orbs
;
i
++
)
{
cmd
=
kzalloc
(
sizeof
(
*
cmd
),
GFP_KERNEL
);
if
(
!
cmd
)
return
-
ENOMEM
;
cmd
->
command_orb_dma
=
dma_map_single
(
hi
->
host
->
device
.
parent
,
&
cmd
->
command_orb
,
sizeof
(
struct
sbp2_command_orb
),
DMA_TO_DEVICE
);
cmd
->
sge_dma
=
dma_map_single
(
hi
->
host
->
device
.
parent
,
&
cmd
->
scatter_gather_element
,
sizeof
(
cmd
->
scatter_gather_element
),
DMA_TO_DEVICE
);
goto
failed_alloc
;
cmd
->
command_orb_dma
=
dma_map_single
(
dmadev
,
&
cmd
->
command_orb
,
sizeof
(
struct
sbp2_command_orb
),
DMA_TO_DEVICE
);
if
(
dma_mapping_error
(
dmadev
,
cmd
->
command_orb_dma
))
goto
failed_orb
;
cmd
->
sge_dma
=
dma_map_single
(
dmadev
,
&
cmd
->
scatter_gather_element
,
sizeof
(
cmd
->
scatter_gather_element
),
DMA_TO_DEVICE
);
if
(
dma_mapping_error
(
dmadev
,
cmd
->
sge_dma
))
goto
failed_sge
;
INIT_LIST_HEAD
(
&
cmd
->
list
);
list_add_tail
(
&
cmd
->
list
,
&
lu
->
cmd_orb_completed
);
}
return
0
;
failed_sge:
dma_unmap_single
(
dmadev
,
cmd
->
command_orb_dma
,
sizeof
(
struct
sbp2_command_orb
),
DMA_TO_DEVICE
);
failed_orb:
kfree
(
cmd
);
failed_alloc:
return
-
ENOMEM
;
}
static
void
sbp2util_remove_command_orb_pool
(
struct
sbp2_lu
*
lu
,
...
...
@@ -1494,14 +1509,16 @@ static int sbp2_agent_reset(struct sbp2_lu *lu, int wait)
return
0
;
}
static
void
sbp2_prep_command_orb_sg
(
struct
sbp2_command_orb
*
orb
,
struct
sbp2_fwhost_info
*
hi
,
struct
sbp2_command_info
*
cmd
,
unsigned
int
scsi_use_sg
,
struct
scatterlist
*
sg
,
u32
orb_direction
,
enum
dma_data_direction
dma_dir
)
static
int
sbp2_prep_command_orb_sg
(
struct
sbp2_command_orb
*
orb
,
struct
sbp2_fwhost_info
*
hi
,
struct
sbp2_command_info
*
cmd
,
unsigned
int
scsi_use_sg
,
struct
scatterlist
*
sg
,
u32
orb_direction
,
enum
dma_data_direction
dma_dir
)
{
struct
device
*
dmadev
=
hi
->
host
->
device
.
parent
;
cmd
->
dma_dir
=
dma_dir
;
orb
->
data_descriptor_hi
=
ORB_SET_NODE_ID
(
hi
->
host
->
node_id
);
orb
->
misc
|=
ORB_SET_DIRECTION
(
orb_direction
);
...
...
@@ -1511,9 +1528,12 @@ static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb,
cmd
->
dma_size
=
sg
->
length
;
cmd
->
dma_type
=
CMD_DMA_PAGE
;
cmd
->
cmd_dma
=
dma_map_page
(
hi
->
host
->
device
.
parent
,
sg_page
(
sg
),
sg
->
offset
,
cmd
->
cmd_dma
=
dma_map_page
(
dmadev
,
sg_page
(
sg
),
sg
->
offset
,
cmd
->
dma_size
,
cmd
->
dma_dir
);
if
(
dma_mapping_error
(
dmadev
,
cmd
->
cmd_dma
))
{
cmd
->
cmd_dma
=
0
;
return
-
ENOMEM
;
}
orb
->
data_descriptor_lo
=
cmd
->
cmd_dma
;
orb
->
misc
|=
ORB_SET_DATA_SIZE
(
cmd
->
dma_size
);
...
...
@@ -1523,8 +1543,7 @@ static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb,
&
cmd
->
scatter_gather_element
[
0
];
u32
sg_count
,
sg_len
;
dma_addr_t
sg_addr
;
int
i
,
count
=
dma_map_sg
(
hi
->
host
->
device
.
parent
,
sg
,
scsi_use_sg
,
dma_dir
);
int
i
,
count
=
dma_map_sg
(
dmadev
,
sg
,
scsi_use_sg
,
dma_dir
);
cmd
->
dma_size
=
scsi_use_sg
;
cmd
->
sge_buffer
=
sg
;
...
...
@@ -1533,7 +1552,7 @@ static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb,
orb
->
misc
|=
ORB_SET_PAGE_TABLE_PRESENT
(
0x1
);
orb
->
data_descriptor_lo
=
cmd
->
sge_dma
;
dma_sync_single_for_cpu
(
hi
->
host
->
device
.
parent
,
cmd
->
sge_dma
,
dma_sync_single_for_cpu
(
dmadev
,
cmd
->
sge_dma
,
sizeof
(
cmd
->
scatter_gather_element
),
DMA_TO_DEVICE
);
...
...
@@ -1564,22 +1583,23 @@ static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb,
(
sizeof
(
struct
sbp2_unrestricted_page_table
))
*
sg_count
);
dma_sync_single_for_device
(
hi
->
host
->
device
.
parent
,
cmd
->
sge_dma
,
dma_sync_single_for_device
(
dmadev
,
cmd
->
sge_dma
,
sizeof
(
cmd
->
scatter_gather_element
),
DMA_TO_DEVICE
);
}
return
0
;
}
static
void
sbp2_create_command_orb
(
struct
sbp2_lu
*
lu
,
struct
sbp2_command_info
*
cmd
,
struct
scsi_cmnd
*
SCpnt
)
static
int
sbp2_create_command_orb
(
struct
sbp2_lu
*
lu
,
struct
sbp2_command_info
*
cmd
,
struct
scsi_cmnd
*
SCpnt
)
{
struct
device
*
dmadev
=
lu
->
hi
->
host
->
device
.
parent
;
struct
sbp2_command_orb
*
orb
=
&
cmd
->
command_orb
;
u32
orb_direction
;
unsigned
int
scsi_request_bufflen
=
scsi_bufflen
(
SCpnt
);
enum
dma_data_direction
dma_dir
=
SCpnt
->
sc_data_direction
;
u32
orb_direction
;
int
ret
;
dma_sync_single_for_cpu
(
dmadev
,
cmd
->
command_orb_dma
,
sizeof
(
struct
sbp2_command_orb
),
DMA_TO_DEVICE
);
...
...
@@ -1613,11 +1633,13 @@ static void sbp2_create_command_orb(struct sbp2_lu *lu,
orb
->
data_descriptor_hi
=
0x0
;
orb
->
data_descriptor_lo
=
0x0
;
orb
->
misc
|=
ORB_SET_DIRECTION
(
1
);
}
else
sbp2_prep_command_orb_sg
(
orb
,
lu
->
hi
,
cmd
,
scsi_sg_count
(
SCpnt
),
scsi_sglist
(
SCpnt
),
orb_direction
,
dma_dir
);
ret
=
0
;
}
else
{
ret
=
sbp2_prep_command_orb_sg
(
orb
,
lu
->
hi
,
cmd
,
scsi_sg_count
(
SCpnt
),
scsi_sglist
(
SCpnt
),
orb_direction
,
dma_dir
);
}
sbp2util_cpu_to_be32_buffer
(
orb
,
sizeof
(
*
orb
));
memset
(
orb
->
cdb
,
0
,
sizeof
(
orb
->
cdb
));
...
...
@@ -1625,6 +1647,7 @@ static void sbp2_create_command_orb(struct sbp2_lu *lu,
dma_sync_single_for_device
(
dmadev
,
cmd
->
command_orb_dma
,
sizeof
(
struct
sbp2_command_orb
),
DMA_TO_DEVICE
);
return
ret
;
}
static
void
sbp2_link_orb_command
(
struct
sbp2_lu
*
lu
,
...
...
@@ -1705,9 +1728,10 @@ static int sbp2_send_command(struct sbp2_lu *lu, struct scsi_cmnd *SCpnt,
if
(
!
cmd
)
return
-
EIO
;
sbp2_create_command_orb
(
lu
,
cmd
,
SCpnt
);
sbp2_link_orb_command
(
lu
,
cmd
)
;
if
(
sbp2_create_command_orb
(
lu
,
cmd
,
SCpnt
))
return
-
ENOMEM
;
sbp2_link_orb_command
(
lu
,
cmd
);
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录