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
5f7187a0
Commit
5f7187a0
authored
Jul 09, 2019
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sw:drv: map memory only when necessary
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
2d24d3ed
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
36 deletions
+12
-36
spec-core-fpga.c
software/kernel/spec-core-fpga.c
+11
-4
spec-core.c
software/kernel/spec-core.c
+1
-30
spec.h
software/kernel/spec.h
+0
-2
No files found.
software/kernel/spec-core-fpga.c
View file @
5f7187a0
...
...
@@ -617,13 +617,17 @@ static const struct device_type spec_dev_type = {
*/
int
spec_fpga_init
(
struct
spec_dev
*
spec
)
{
struct
resource
*
r0
=
&
spec
->
pdev
->
resource
[
0
];
int
err
;
spec
->
fpga
=
spec
->
remap
[
0
];
spec
->
fpga
=
ioremap
(
r0
->
start
,
resource_size
(
r0
));
if
(
!
spec
->
fpga
)
return
-
ENOMEM
;
spec
->
meta
=
spec
->
fpga
+
SPEC_META_BASE
;
if
(
!
spec_fpga_is_valid
(
spec
))
return
-
EINVAL
;
if
(
!
spec_fpga_is_valid
(
spec
))
{
err
=
-
EINVAL
;
goto
err_valid
;
}
memset
(
&
spec
->
dev
,
0
,
sizeof
(
spec
->
dev
));
spec
->
dev
.
parent
=
&
spec
->
pdev
->
dev
;
...
...
@@ -693,6 +697,8 @@ err_vic:
device_unregister
(
&
spec
->
dev
);
err_dev:
err_name:
err_valid:
iounmap
(
spec
->
fpga
);
return
err
;
}
...
...
@@ -704,6 +710,7 @@ int spec_fpga_exit(struct spec_dev *spec)
spec_fpga_devices_exit
(
spec
);
spec_fpga_vic_exit
(
spec
);
device_unregister
(
&
spec
->
dev
);
iounmap
(
spec
->
fpga
);
return
0
;
}
software/kernel/spec-core.c
View file @
5f7187a0
...
...
@@ -230,7 +230,7 @@ static int spec_probe(struct pci_dev *pdev,
const
struct
pci_device_id
*
id
)
{
struct
spec_dev
*
spec
;
int
err
,
i
;
int
err
;
spec
=
kzalloc
(
sizeof
(
*
spec
),
GFP_KERNEL
);
if
(
!
spec
)
...
...
@@ -248,26 +248,6 @@ static int spec_probe(struct pci_dev *pdev,
}
pci_set_master
(
pdev
);
/* Remap our 3 bars */
for
(
i
=
err
=
0
;
i
<
3
;
i
++
)
{
struct
resource
*
r
=
pdev
->
resource
+
(
2
*
i
);
if
(
!
r
->
start
)
continue
;
if
(
r
->
flags
&
IORESOURCE_MEM
)
{
spec
->
remap
[
i
]
=
ioremap
(
r
->
start
,
r
->
end
+
1
-
r
->
start
);
if
(
!
spec
->
remap
[
i
])
err
=
-
ENOMEM
;
}
}
if
(
err
)
{
dev_err
(
&
pdev
->
dev
,
"Failed to remap memory (%d)
\n
"
,
err
);
goto
err_remap
;
}
err
=
mfd_add_devices
(
&
pdev
->
dev
,
mfd_id
++
,
spec_mfd_devs
,
ARRAY_SIZE
(
spec_mfd_devs
),
...
...
@@ -304,11 +284,6 @@ err_sysfs:
err_sgpio:
mfd_remove_devices
(
&
pdev
->
dev
);
err_mfd:
for
(
i
=
0
;
i
<
3
;
i
++
)
{
if
(
spec
->
remap
[
i
])
iounmap
(
spec
->
remap
[
i
]);
}
err_remap:
pci_disable_device
(
pdev
);
err_enable:
kfree
(
spec
);
...
...
@@ -319,7 +294,6 @@ err_enable:
static
void
spec_remove
(
struct
pci_dev
*
pdev
)
{
struct
spec_dev
*
spec
=
pci_get_drvdata
(
pdev
);
int
i
;
spec_dbg_exit
(
spec
);
spec_fpga_exit
(
spec
);
...
...
@@ -327,9 +301,6 @@ static void spec_remove(struct pci_dev *pdev)
spec_gpio_exit
(
spec
);
mfd_remove_devices
(
&
pdev
->
dev
);
for
(
i
=
0
;
i
<
3
;
i
++
)
if
(
spec
->
remap
[
i
])
iounmap
(
spec
->
remap
[
i
]);
pci_disable_device
(
pdev
);
kfree
(
spec
);
}
...
...
software/kernel/spec.h
View file @
5f7187a0
...
...
@@ -104,7 +104,6 @@ struct spec_meta_id {
* @dev Linux device instance descriptor
* @mtx: protect bootselect usage, fpga device load
* @flags collection of bit flags
* @remap ioremap of PCI bar 0, 2, 4
* @slot_info: information about FMC slot
* @i2c_pdev: platform device for I2C master
* @i2c_adapter: the I2C master device to be used
...
...
@@ -114,7 +113,6 @@ struct spec_dev {
struct
device
dev
;
DECLARE_BITMAP
(
flags
,
SPEC_FLAG_BITS
);
void
__iomem
*
remap
[
3
];
/* ioremap of bar 0, 2, 4 */
void
__iomem
*
fpga
;
struct
spec_meta_id
__iomem
*
meta
;
...
...
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