* [PATCH v2] fpga: altera-cvp: fix probing for multiple FPGAs on the bus
@ 2018-11-07 22:20 Anatolij Gustschin
2018-11-08 17:13 ` Alan Tull
0 siblings, 1 reply; 2+ messages in thread
From: Anatolij Gustschin @ 2018-11-07 22:20 UTC (permalink / raw)
To: linux-fpga; +Cc: atull, mdf
Currently registering CvP managers works only for first probed CvP
device, for all other devices it is refused due to duplicated chkcfg
sysfs entry:
fpga_manager fpga3: Altera CvP FPGA Manager @0000:0c:00.0 registered
sysfs: cannot create duplicate filename '/bus/pci/drivers/altera-cvp/chkcfg'
CPU: 0 PID: 3808 Comm: bash Tainted: G O 4.19.0-custom+ #5
Call Trace:
dump_stack+0x46/0x5b
sysfs_warn_dup+0x53/0x60
sysfs_add_file_mode_ns+0x16d/0x180
sysfs_create_file_ns+0x51/0x60
altera_cvp_probe+0x16f/0x2a0 [altera_cvp]
local_pci_probe+0x3f/0xa0
? pci_match_device+0xb1/0xf0
pci_device_probe+0x116/0x170
really_probe+0x21b/0x2c0
driver_probe_device+0x4b/0xe0
bind_store+0xcb/0x130
kernfs_fop_write+0xfd/0x180
__vfs_write+0x21/0x150
? selinux_file_permission+0xdc/0x130
vfs_write+0xa8/0x1a0
? find_vma+0xd/0x60
ksys_write+0x3d/0x90
do_syscall_64+0x44/0xf0
entry_SYSCALL_64_after_hwframe+0x44/0xa9
...
altera-cvp 0000:0c:00.0: Can't create sysfs chkcfg file
fpga_manager fpga3: fpga_mgr_unregister Altera CvP FPGA Manager @0000:0c:00.0
Move chkcfg creation to module init as suggested by Alan.
Signed-off-by: Anatolij Gustschin <agust@denx.de>
---
Changes in v2:
- don't add a counter, move sysfs entry creation to module init instead
drivers/fpga/altera-cvp.c | 34 ++++++++++++++++++++++++----------
1 file changed, 24 insertions(+), 10 deletions(-)
diff --git a/drivers/fpga/altera-cvp.c b/drivers/fpga/altera-cvp.c
index 144fa2a4d4cc..74bf1e8ff616 100644
--- a/drivers/fpga/altera-cvp.c
+++ b/drivers/fpga/altera-cvp.c
@@ -466,14 +466,6 @@ static int altera_cvp_probe(struct pci_dev *pdev,
if (ret)
goto err_unmap;
- ret = driver_create_file(&altera_cvp_driver.driver,
- &driver_attr_chkcfg);
- if (ret) {
- dev_err(&pdev->dev, "Can't create sysfs chkcfg file\n");
- fpga_mgr_unregister(mgr);
- goto err_unmap;
- }
-
return 0;
err_unmap:
@@ -492,7 +484,6 @@ static void altera_cvp_remove(struct pci_dev *pdev)
struct altera_cvp_conf *conf = mgr->priv;
u16 cmd;
- driver_remove_file(&altera_cvp_driver.driver, &driver_attr_chkcfg);
fpga_mgr_unregister(mgr);
if (conf->map)
pci_iounmap(pdev, conf->map);
@@ -502,7 +493,30 @@ static void altera_cvp_remove(struct pci_dev *pdev)
pci_write_config_word(pdev, PCI_COMMAND, cmd);
}
-module_pci_driver(altera_cvp_driver);
+static int __init altera_cvp_init(void)
+{
+ int ret;
+
+ ret = pci_register_driver(&altera_cvp_driver);
+ if (ret)
+ return ret;
+
+ ret = driver_create_file(&altera_cvp_driver.driver,
+ &driver_attr_chkcfg);
+ if (ret)
+ pr_warn("Can't create sysfs chkcfg file\n");
+
+ return 0;
+}
+
+static void __exit altera_cvp_exit(void)
+{
+ driver_remove_file(&altera_cvp_driver.driver, &driver_attr_chkcfg);
+ pci_unregister_driver(&altera_cvp_driver);
+}
+
+module_init(altera_cvp_init);
+module_exit(altera_cvp_exit);
MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Anatolij Gustschin <agust@denx.de>");
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] fpga: altera-cvp: fix probing for multiple FPGAs on the bus
2018-11-07 22:20 [PATCH v2] fpga: altera-cvp: fix probing for multiple FPGAs on the bus Anatolij Gustschin
@ 2018-11-08 17:13 ` Alan Tull
0 siblings, 0 replies; 2+ messages in thread
From: Alan Tull @ 2018-11-08 17:13 UTC (permalink / raw)
To: Anatolij Gustschin; +Cc: linux-fpga, Moritz Fischer
On Wed, Nov 7, 2018 at 4:20 PM Anatolij Gustschin <agust@denx.de> wrote:
Hi Anatolij,
Looks good!
>
> Currently registering CvP managers works only for first probed CvP
> device, for all other devices it is refused due to duplicated chkcfg
> sysfs entry:
>
> fpga_manager fpga3: Altera CvP FPGA Manager @0000:0c:00.0 registered
> sysfs: cannot create duplicate filename '/bus/pci/drivers/altera-cvp/chkcfg'
> CPU: 0 PID: 3808 Comm: bash Tainted: G O 4.19.0-custom+ #5
> Call Trace:
> dump_stack+0x46/0x5b
> sysfs_warn_dup+0x53/0x60
> sysfs_add_file_mode_ns+0x16d/0x180
> sysfs_create_file_ns+0x51/0x60
> altera_cvp_probe+0x16f/0x2a0 [altera_cvp]
> local_pci_probe+0x3f/0xa0
> ? pci_match_device+0xb1/0xf0
> pci_device_probe+0x116/0x170
> really_probe+0x21b/0x2c0
> driver_probe_device+0x4b/0xe0
> bind_store+0xcb/0x130
> kernfs_fop_write+0xfd/0x180
> __vfs_write+0x21/0x150
> ? selinux_file_permission+0xdc/0x130
> vfs_write+0xa8/0x1a0
> ? find_vma+0xd/0x60
> ksys_write+0x3d/0x90
> do_syscall_64+0x44/0xf0
> entry_SYSCALL_64_after_hwframe+0x44/0xa9
> ...
> altera-cvp 0000:0c:00.0: Can't create sysfs chkcfg file
> fpga_manager fpga3: fpga_mgr_unregister Altera CvP FPGA Manager @0000:0c:00.0
>
> Move chkcfg creation to module init as suggested by Alan.
>
> Signed-off-by: Anatolij Gustschin <agust@denx.de>
Acked-by: Alan Tull <atull@kernel.org>
> ---
> Changes in v2:
> - don't add a counter, move sysfs entry creation to module init instead
>
> drivers/fpga/altera-cvp.c | 34 ++++++++++++++++++++++++----------
> 1 file changed, 24 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/fpga/altera-cvp.c b/drivers/fpga/altera-cvp.c
> index 144fa2a4d4cc..74bf1e8ff616 100644
> --- a/drivers/fpga/altera-cvp.c
> +++ b/drivers/fpga/altera-cvp.c
> @@ -466,14 +466,6 @@ static int altera_cvp_probe(struct pci_dev *pdev,
> if (ret)
> goto err_unmap;
>
> - ret = driver_create_file(&altera_cvp_driver.driver,
> - &driver_attr_chkcfg);
> - if (ret) {
> - dev_err(&pdev->dev, "Can't create sysfs chkcfg file\n");
> - fpga_mgr_unregister(mgr);
> - goto err_unmap;
> - }
> -
> return 0;
>
> err_unmap:
> @@ -492,7 +484,6 @@ static void altera_cvp_remove(struct pci_dev *pdev)
> struct altera_cvp_conf *conf = mgr->priv;
> u16 cmd;
>
> - driver_remove_file(&altera_cvp_driver.driver, &driver_attr_chkcfg);
> fpga_mgr_unregister(mgr);
> if (conf->map)
> pci_iounmap(pdev, conf->map);
> @@ -502,7 +493,30 @@ static void altera_cvp_remove(struct pci_dev *pdev)
> pci_write_config_word(pdev, PCI_COMMAND, cmd);
> }
>
> -module_pci_driver(altera_cvp_driver);
> +static int __init altera_cvp_init(void)
> +{
> + int ret;
> +
> + ret = pci_register_driver(&altera_cvp_driver);
> + if (ret)
> + return ret;
> +
> + ret = driver_create_file(&altera_cvp_driver.driver,
> + &driver_attr_chkcfg);
> + if (ret)
> + pr_warn("Can't create sysfs chkcfg file\n");
> +
> + return 0;
> +}
> +
> +static void __exit altera_cvp_exit(void)
> +{
> + driver_remove_file(&altera_cvp_driver.driver, &driver_attr_chkcfg);
> + pci_unregister_driver(&altera_cvp_driver);
> +}
> +
> +module_init(altera_cvp_init);
> +module_exit(altera_cvp_exit);
>
> MODULE_LICENSE("GPL v2");
> MODULE_AUTHOR("Anatolij Gustschin <agust@denx.de>");
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-11-08 17:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-07 22:20 [PATCH v2] fpga: altera-cvp: fix probing for multiple FPGAs on the bus Anatolij Gustschin
2018-11-08 17:13 ` Alan Tull
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).