Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Simple PCIe FMC carrier SPEC
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
50
Issues
50
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Simple PCIe FMC carrier SPEC
Commits
aa01b719
Commit
aa01b719
authored
Jun 30, 2020
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sw:drv: unaligned accesses are not supported
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
54242b66
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
12 deletions
+37
-12
test_dma.py
pytest/test_dma.py
+34
-12
spec-core-fpga.c
software/kernel/spec-core-fpga.c
+3
-0
No files found.
pytest/test_dma.py
View file @
aa01b719
...
...
@@ -71,31 +71,53 @@ class TestDma(object):
assert
count
==
buffer_size
spec
.
dma_stop
()
@
pytest
.
mark
.
parametrize
(
"ddr_offset"
,
[
2
**
i
for
i
in
range
(
2
,
int
(
math
.
log2
(
PySPEC
.
DDR_SIZE
)))])
@
pytest
.
mark
.
parametrize
(
"unaligned"
,
range
(
1
,
PySPEC
.
DDR_ALIGN
))
def
test_dma_unaligned_offset_read
(
self
,
spec
,
ddr_offset
,
unaligned
):
"""
The DDR access is 4byte aligned.
"""
spec
.
dma_start
()
with
pytest
.
raises
(
OSError
)
as
error
:
spec
.
dma_read
(
ddr_offset
+
unaligned
,
16
)
spec
.
dma_stop
()
@
pytest
.
mark
.
parametrize
(
"buffer_size"
,
[
1
,
2
,
3
])
def
test_dma_invalid_size_read
(
self
,
spec
,
buffer_size
):
@
pytest
.
mark
.
parametrize
(
"ddr_offset"
,
[
2
**
i
for
i
in
range
(
2
,
int
(
math
.
log2
(
PySPEC
.
DDR_SIZE
)))])
@
pytest
.
mark
.
parametrize
(
"unaligned"
,
range
(
1
,
PySPEC
.
DDR_ALIGN
))
def
test_dma_unaligned_offset_write
(
self
,
spec
,
ddr_offset
,
unaligned
):
"""
The HDL engine masks the 2 least significant bits. For small transfers
this translates into a zero length transfer which is not supported.
Also 0 is an invalid size, but read/write returns immediatly because
there is nothing to transfer.
The DDR access is 4byte aligned.
"""
spec
.
dma_start
()
with
pytest
.
raises
(
OSError
)
as
error
:
spec
.
dma_
read
(
0
,
buffer_size
)
spec
.
dma_
write
(
ddr_offset
+
unaligned
,
b
"
\x00
"
*
16
)
spec
.
dma_stop
()
@
pytest
.
mark
.
parametrize
(
"buffer_size"
,
[
1
,
2
,
3
])
def
test_dma_invalid_size_write
(
self
,
spec
,
buffer_size
):
@
pytest
.
mark
.
parametrize
(
"ddr_offset"
,
[
2
**
i
for
i
in
range
(
2
,
int
(
math
.
log2
(
PySPEC
.
DDR_SIZE
)))])
@
pytest
.
mark
.
parametrize
(
"unaligned"
,
range
(
1
,
PySPEC
.
DDR_ALIGN
))
def
test_dma_unaligned_size_read
(
self
,
spec
,
ddr_offset
,
unaligned
):
"""
The HDL engine masks the 2 least significant bits. For small transfers
this translates into a zero length transfer which is not supported.
The DDR access is 4byte aligned.
"""
spec
.
dma_start
()
with
pytest
.
raises
(
OSError
)
as
error
:
spec
.
dma_
write
(
0
,
b
"
\x00
"
*
buffer_size
)
spec
.
dma_
read
(
ddr_offset
+
unaligned
,
(
16
+
unaligned
)
)
spec
.
dma_stop
()
@
pytest
.
mark
.
parametrize
(
"ddr_offset"
,
[
2
**
i
for
i
in
range
(
2
,
int
(
math
.
log2
(
PySPEC
.
DDR_SIZE
)))])
@
pytest
.
mark
.
parametrize
(
"unaligned"
,
range
(
1
,
PySPEC
.
DDR_ALIGN
))
def
test_dma_unaligned_size_write
(
self
,
spec
,
ddr_offset
,
unaligned
):
"""
The DDR access is 4byte aligned.
"""
spec
.
dma_start
()
with
pytest
.
raises
(
OSError
)
as
error
:
spec
.
dma_write
(
ddr_offset
+
unaligned
,
b
"
\x00
"
*
(
16
+
unaligned
))
spec
.
dma_stop
()
@
pytest
.
mark
.
parametrize
(
"dma_offset"
,
[
0x0
])
@
pytest
.
mark
.
parametrize
(
"dma_size"
,
...
...
software/kernel/spec-core-fpga.c
View file @
aa01b719
...
...
@@ -161,6 +161,9 @@ static int spec_fpga_dbg_dma_transfer(struct spec_fpga_dbg_dma *dbgdma,
struct
scatterlist
*
sg
;
int
i
;
if
(
count
&
0x3
||
offset
&
0x3
)
return
-
EINVAL
;
max_segment
=
dma_get_max_seg_size
(
dbgdma
->
dchan
->
device
->
dev
)
&
PAGE_MASK
;
err
=
sg_alloc_table
(
&
sgt
,
(
count
/
max_segment
)
+
1
,
GFP_KERNEL
);
if
(
err
)
...
...
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