* [PATCH RESEND] mcb: mcb-pci: detect IO mapped devices before requesting resources
@ 2024-05-23 10:35 Sanjuán García, Jorge
2024-06-07 20:42 ` Andy Shevchenko
0 siblings, 1 reply; 2+ messages in thread
From: Sanjuán García, Jorge @ 2024-05-23 10:35 UTC (permalink / raw)
To: morbidrsa, gregkh
Cc: linux-kernel, jth, Rodríguez Barbarin, José Javier,
Sanjuán García, Jorge, Rodríguez Barbarin,
José Javier
If the memory region is requested with devm_request_mem_region()
for an IO mapped device it will return an error and mcb-pci will
incorrectly report it with EBUSY code.
Make sure we identify if the reosure is IO mapped and fail early
with a correct ENOTSUPP code.
Reviewed-by: Jose Javier Rodriguez Barbarin <JoseJavier.Rodriguez@duagon.com>
Signed-off-by: Jorge Sanjuan Garcia <jorge.sanjuangarcia@duagon.com>
---
drivers/mcb/mcb-pci.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/mcb/mcb-pci.c b/drivers/mcb/mcb-pci.c
index 53d9202ff9a7..3b634ea318c7 100644
--- a/drivers/mcb/mcb-pci.c
+++ b/drivers/mcb/mcb-pci.c
@@ -45,6 +45,14 @@ static int mcb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
}
pci_set_master(pdev);
+ flags = pci_resource_flags(pdev, 0);
+ if (flags & IORESOURCE_IO) {
+ ret = -ENOTSUPP;
+ dev_err(&pdev->dev,
+ "IO mapped PCI devices are not supported\n");
+ goto out_disable;
+ }
+
priv->mapbase = pci_resource_start(pdev, 0);
if (!priv->mapbase) {
dev_err(&pdev->dev, "No PCI resource\n");
@@ -68,14 +76,6 @@ static int mcb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
goto out_disable;
}
- flags = pci_resource_flags(pdev, 0);
- if (flags & IORESOURCE_IO) {
- ret = -ENOTSUPP;
- dev_err(&pdev->dev,
- "IO mapped PCI devices are not supported\n");
- goto out_disable;
- }
-
pci_set_drvdata(pdev, priv);
priv->bus = mcb_alloc_bus(&pdev->dev);
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH RESEND] mcb: mcb-pci: detect IO mapped devices before requesting resources
2024-05-23 10:35 [PATCH RESEND] mcb: mcb-pci: detect IO mapped devices before requesting resources Sanjuán García, Jorge
@ 2024-06-07 20:42 ` Andy Shevchenko
0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2024-06-07 20:42 UTC (permalink / raw)
To: Sanjuán García, Jorge
Cc: morbidrsa, gregkh, linux-kernel, jth, Rodríguez Barbarin,
José Javier
Thu, May 23, 2024 at 10:35:03AM +0000, Sanjuán García, Jorge kirjoitti:
> If the memory region is requested with devm_request_mem_region()
> for an IO mapped device it will return an error and mcb-pci will
> incorrectly report it with EBUSY code.
>
> Make sure we identify if the reosure is IO mapped and fail early
> with a correct ENOTSUPP code.
No, ENOTSUPP is incorrect code in this case. Have you run checkpatch?
Please, submit a patch to change this error code to one from the POSIX range.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-06-07 20:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-23 10:35 [PATCH RESEND] mcb: mcb-pci: detect IO mapped devices before requesting resources Sanjuán García, Jorge
2024-06-07 20:42 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®