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
01547b49
Commit
01547b49
authored
Jul 06, 2020
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sw:drv: add parameter to customize DMA allocation
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
2a10539c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
4 deletions
+23
-4
sw-driver.rst
doc/sw-driver.rst
+8
-0
PySPEC.py
software/PySPEC/PySPEC/PySPEC.py
+9
-3
spec-core-fpga.c
software/kernel/spec-core-fpga.c
+6
-1
No files found.
doc/sw-driver.rst
View file @
01547b49
...
...
@@ -238,6 +238,14 @@ attributes. Here we focus only on those.
the user can use ``lseek(2)`` to set the offset in the DDR, and
``read(2)``/``write(2)`` to start the DMA transfer.
Module Parameters
-----------------
``user_dma_coherent_size`` [RW]
It sets the maximum size for a coherent DMA memory allocation. A
change to this value is applied on ``open(2)``
(file ``<pci-id>/spec-<pci-id>/dma``).
DMA
---
...
...
software/PySPEC/PySPEC/PySPEC.py
View file @
01547b49
...
...
@@ -41,7 +41,7 @@ class PySPEC:
f
.
write
(
os
.
path
.
dirname
(
prev
))
@
contextmanager
def
dma
(
self
):
def
dma
(
self
,
dma_coherent_size
=
None
):
"""
Create a DMA context from which users can do DMA
transfers. Within this context the user can use
...
...
@@ -64,7 +64,7 @@ class PySPEC:
>>> spec_dma.close()
"""
spec_dma
=
self
.
PySPECDMA
(
self
)
spec_dma
.
request
()
spec_dma
.
request
(
dma_coherent_size
)
try
:
yield
spec_dma
finally
:
...
...
@@ -97,12 +97,18 @@ class PySPEC:
"""
self
.
spec
=
spec
def
request
(
self
):
def
request
(
self
,
dma_coherent_size
=
None
):
"""
Open a DMA file descriptor
:var dma_coherent_size: DMA coherent allocation size (in-kernel).
:raise OSError: if the open(2) or the driver fails
"""
if
dma_coherent_size
is
not
None
:
with
open
(
"/sys/module/spec_fmc_carrier/parameters/user_dma_coherent_size"
,
"w"
)
as
f
:
f
.
write
(
str
(
dma_coherent_size
))
self
.
dma_file
=
open
(
os
.
path
.
join
(
self
.
spec
.
debugfs_fpga
,
"dma"
),
"rb+"
,
buffering
=
0
)
def
release
(
self
):
...
...
software/kernel/spec-core-fpga.c
View file @
01547b49
...
...
@@ -19,11 +19,16 @@
#include <linux/completion.h>
#include <linux/jiffies.h>
#include <linux/uaccess.h>
#include <linux/moduleparam.h>
#include "linux/printk.h"
#include "spec.h"
#include "spec-compat.h"
static
int
user_dma_coherent_size
=
4
*
1024
*
1024
;
module_param
(
user_dma_coherent_size
,
int
,
0644
);
MODULE_PARM_DESC
(
user_dma_coherent_size
,
"DMA coherent allocation's size in bytes (default 4MiB)"
);
enum
spec_fpga_irq_lines
{
SPEC_FPGA_IRQ_FMC_I2C
=
0
,
...
...
@@ -320,7 +325,7 @@ static int spec_fpga_dbg_dma_open(struct inode *inode, struct file *file)
return
-
ENOMEM
;
init_completion
(
&
dbgdma
->
compl
);
dbgdma
->
spec_fpga
=
spec_fpga
;
dbgdma
->
datalen
=
4
*
1024
*
1024
;
dbgdma
->
datalen
=
user_dma_coherent_size
;
dbgdma
->
data
=
dma_alloc_coherent
(
dbgdma
->
spec_fpga
->
dev
.
parent
,
dbgdma
->
datalen
,
&
dbgdma
->
datadma
,
GFP_KERNEL
);
...
...
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