* [PATCH v3 0/3] fbdev: kyro: Convert to managed device resources
@ 2025-07-09 9:53 Giovanni Di Santi
2025-07-09 9:53 ` [PATCH v3 1/3] fbdev: kyro: Add missing PCI memory region request Giovanni Di Santi
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Giovanni Di Santi @ 2025-07-09 9:53 UTC (permalink / raw)
To: tzimmermann, deller
Cc: linux-fbdev, dri-devel, linux-kernel, Giovanni Di Santi
This series aims to address the TODO item "Request memory regions in all
fbdev drivers" from Documentation/gpu/todo.rst.
Additionally, it also converts the kyro framebuffer driver to use managed device
functions.
In summary, it converts the driver to use:
1. Managed PCI device enable and region request functions
2. Managed ioremap for MMIO registers
3. Managed ioremap_wc for screen memory
This simplifies error handling and removes the need for manual cleanup
in the remove function.
Changes in v3:
- Split into a patch series as suggested by Thomas Zimmermann [1]
- Convert ioremap calls to devm_ variants
Changes in v2:
- Use pcim_enable_device() instead of pci_enable_device()
- Use pcim_request_all_regions() instead of pci_request_regions()
- Removed manual cleanup code as it's now automatic
[1] https://lore.kernel.org/lkml/fd6403d7-93f4-4fa4-ad0d-3ab91cba8183@suse.de/
Giovanni Di Santi (3):
fbdev: kyro: Add missing PCI memory region request
fbdev: kyro: Use devm_ioremap() for mmio registers
fbdev: kyro: Use devm_ioremap_wc() for screen mem
drivers/video/fbdev/kyro/fbdev.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3 1/3] fbdev: kyro: Add missing PCI memory region request
2025-07-09 9:53 [PATCH v3 0/3] fbdev: kyro: Convert to managed device resources Giovanni Di Santi
@ 2025-07-09 9:53 ` Giovanni Di Santi
2025-07-09 9:53 ` [PATCH v3 2/3] fbdev: kyro: Use devm_ioremap() for mmio registers Giovanni Di Santi
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Giovanni Di Santi @ 2025-07-09 9:53 UTC (permalink / raw)
To: tzimmermann, deller
Cc: linux-fbdev, dri-devel, linux-kernel, Giovanni Di Santi
The kyro framebuffer driver did not request its PCI memory regions,
which could lead to conflicts with other drivers. This change
addresses the task "Request memory regions in all fbdev drivers"
from the file Documentation/gpu/todo.rst.
This is addressed by using the managed device functions pcim_enable_device()
and pcim_request_all_regions(). This simplifies the code by making error
handling and driver removal cleanup automatic for these resources.
Signed-off-by: Giovanni Di Santi <giovanni.disanti.lkl@gmail.com>
---
drivers/video/fbdev/kyro/fbdev.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/video/fbdev/kyro/fbdev.c b/drivers/video/fbdev/kyro/fbdev.c
index 08ee8baa79f8..86e5d60ed0ff 100644
--- a/drivers/video/fbdev/kyro/fbdev.c
+++ b/drivers/video/fbdev/kyro/fbdev.c
@@ -679,7 +679,8 @@ static int kyrofb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (err)
return err;
- if ((err = pci_enable_device(pdev))) {
+ err = pcim_enable_device(pdev);
+ if (err) {
printk(KERN_WARNING "kyrofb: Can't enable pdev: %d\n", err);
return err;
}
@@ -688,6 +689,10 @@ static int kyrofb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (!info)
return -ENOMEM;
+ err = pcim_request_all_regions(pdev, "kyrofb");
+ if (err)
+ goto out_free_fb;
+
currentpar = info->par;
kyro_fix.smem_start = pci_resource_start(pdev, 0);
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 2/3] fbdev: kyro: Use devm_ioremap() for mmio registers
2025-07-09 9:53 [PATCH v3 0/3] fbdev: kyro: Convert to managed device resources Giovanni Di Santi
2025-07-09 9:53 ` [PATCH v3 1/3] fbdev: kyro: Add missing PCI memory region request Giovanni Di Santi
@ 2025-07-09 9:53 ` Giovanni Di Santi
2025-07-09 9:53 ` [PATCH v3 3/3] fbdev: kyro: Use devm_ioremap_wc() for screen mem Giovanni Di Santi
2025-07-27 17:57 ` [PATCH v3 0/3] fbdev: kyro: Convert to managed device resources Helge Deller
3 siblings, 0 replies; 5+ messages in thread
From: Giovanni Di Santi @ 2025-07-09 9:53 UTC (permalink / raw)
To: tzimmermann, deller
Cc: linux-fbdev, dri-devel, linux-kernel, Giovanni Di Santi
Replace the manual ioremap() call for the MMIO registers with the
device-managed devm_ioremap() variant.
This simplifies the driver's resource management by ensuring the memory is
automatically unmapped when the driver detaches from the device.
Signed-off-by: Giovanni Di Santi <giovanni.disanti.lkl@gmail.com>
---
drivers/video/fbdev/kyro/fbdev.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/video/fbdev/kyro/fbdev.c b/drivers/video/fbdev/kyro/fbdev.c
index 86e5d60ed0ff..ddc241f508b1 100644
--- a/drivers/video/fbdev/kyro/fbdev.c
+++ b/drivers/video/fbdev/kyro/fbdev.c
@@ -701,13 +701,14 @@ static int kyrofb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
kyro_fix.mmio_len = pci_resource_len(pdev, 1);
currentpar->regbase = deviceInfo.pSTGReg =
- ioremap(kyro_fix.mmio_start, kyro_fix.mmio_len);
+ devm_ioremap(&pdev->dev, kyro_fix.mmio_start,
+ kyro_fix.mmio_len);
if (!currentpar->regbase)
goto out_free_fb;
info->screen_base = pci_ioremap_wc_bar(pdev, 0);
if (!info->screen_base)
- goto out_unmap_regs;
+ goto out_free_fb;
if (!nomtrr)
currentpar->wc_cookie = arch_phys_wc_add(kyro_fix.smem_start,
@@ -755,8 +756,6 @@ static int kyrofb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
out_unmap:
iounmap(info->screen_base);
-out_unmap_regs:
- iounmap(currentpar->regbase);
out_free_fb:
framebuffer_release(info);
@@ -779,7 +778,6 @@ static void kyrofb_remove(struct pci_dev *pdev)
deviceInfo.ulOverlayOffset = 0;
iounmap(info->screen_base);
- iounmap(par->regbase);
arch_phys_wc_del(par->wc_cookie);
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 3/3] fbdev: kyro: Use devm_ioremap_wc() for screen mem
2025-07-09 9:53 [PATCH v3 0/3] fbdev: kyro: Convert to managed device resources Giovanni Di Santi
2025-07-09 9:53 ` [PATCH v3 1/3] fbdev: kyro: Add missing PCI memory region request Giovanni Di Santi
2025-07-09 9:53 ` [PATCH v3 2/3] fbdev: kyro: Use devm_ioremap() for mmio registers Giovanni Di Santi
@ 2025-07-09 9:53 ` Giovanni Di Santi
2025-07-27 17:57 ` [PATCH v3 0/3] fbdev: kyro: Convert to managed device resources Helge Deller
3 siblings, 0 replies; 5+ messages in thread
From: Giovanni Di Santi @ 2025-07-09 9:53 UTC (permalink / raw)
To: tzimmermann, deller
Cc: linux-fbdev, dri-devel, linux-kernel, Giovanni Di Santi
Replace the manual pci_ioremap_wc() call for mapping screen memory with the
device-managed devm_ioremap_wc() variant.
This simplifies the driver's resource management by ensuring the memory is
automatically unmapped when the driver detaches from the device.
Signed-off-by: Giovanni Di Santi <giovanni.disanti.lkl@gmail.com>
---
drivers/video/fbdev/kyro/fbdev.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/video/fbdev/kyro/fbdev.c b/drivers/video/fbdev/kyro/fbdev.c
index ddc241f508b1..c8b1dfa456a3 100644
--- a/drivers/video/fbdev/kyro/fbdev.c
+++ b/drivers/video/fbdev/kyro/fbdev.c
@@ -706,7 +706,8 @@ static int kyrofb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (!currentpar->regbase)
goto out_free_fb;
- info->screen_base = pci_ioremap_wc_bar(pdev, 0);
+ info->screen_base = devm_ioremap_wc(&pdev->dev, kyro_fix.smem_start,
+ kyro_fix.smem_len);
if (!info->screen_base)
goto out_free_fb;
@@ -743,7 +744,7 @@ static int kyrofb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
fb_memset_io(info->screen_base, 0, size);
if (register_framebuffer(info) < 0)
- goto out_unmap;
+ goto out_free_fb;
fb_info(info, "%s frame buffer device, at %dx%d@%d using %ldk/%ldk of VRAM\n",
info->fix.id,
@@ -754,8 +755,6 @@ static int kyrofb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
return 0;
-out_unmap:
- iounmap(info->screen_base);
out_free_fb:
framebuffer_release(info);
@@ -777,8 +776,6 @@ static void kyrofb_remove(struct pci_dev *pdev)
deviceInfo.ulNextFreeVidMem = 0;
deviceInfo.ulOverlayOffset = 0;
- iounmap(info->screen_base);
-
arch_phys_wc_del(par->wc_cookie);
unregister_framebuffer(info);
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v3 0/3] fbdev: kyro: Convert to managed device resources
2025-07-09 9:53 [PATCH v3 0/3] fbdev: kyro: Convert to managed device resources Giovanni Di Santi
` (2 preceding siblings ...)
2025-07-09 9:53 ` [PATCH v3 3/3] fbdev: kyro: Use devm_ioremap_wc() for screen mem Giovanni Di Santi
@ 2025-07-27 17:57 ` Helge Deller
3 siblings, 0 replies; 5+ messages in thread
From: Helge Deller @ 2025-07-27 17:57 UTC (permalink / raw)
To: Giovanni Di Santi, tzimmermann; +Cc: linux-fbdev, dri-devel, linux-kernel
On 7/9/25 11:53, Giovanni Di Santi wrote:
> This series aims to address the TODO item "Request memory regions in all
> fbdev drivers" from Documentation/gpu/todo.rst.
> Additionally, it also converts the kyro framebuffer driver to use managed device
> functions.
>
> In summary, it converts the driver to use:
> 1. Managed PCI device enable and region request functions
> 2. Managed ioremap for MMIO registers
> 3. Managed ioremap_wc for screen memory
>
> This simplifies error handling and removes the need for manual cleanup
> in the remove function.
>
> Changes in v3:
> - Split into a patch series as suggested by Thomas Zimmermann [1]
> - Convert ioremap calls to devm_ variants
>
> Changes in v2:
> - Use pcim_enable_device() instead of pci_enable_device()
> - Use pcim_request_all_regions() instead of pci_request_regions()
> - Removed manual cleanup code as it's now automatic
>
> [1] https://lore.kernel.org/lkml/fd6403d7-93f4-4fa4-ad0d-3ab91cba8183@suse.de/
>
> Giovanni Di Santi (3):
> fbdev: kyro: Add missing PCI memory region request
> fbdev: kyro: Use devm_ioremap() for mmio registers
> fbdev: kyro: Use devm_ioremap_wc() for screen mem
>
> drivers/video/fbdev/kyro/fbdev.c | 24 ++++++++++++------------
> 1 file changed, 12 insertions(+), 12 deletions(-)
series applied to fbdev git tree.
Thanks!
Helge
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-07-27 16:06 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-09 9:53 [PATCH v3 0/3] fbdev: kyro: Convert to managed device resources Giovanni Di Santi
2025-07-09 9:53 ` [PATCH v3 1/3] fbdev: kyro: Add missing PCI memory region request Giovanni Di Santi
2025-07-09 9:53 ` [PATCH v3 2/3] fbdev: kyro: Use devm_ioremap() for mmio registers Giovanni Di Santi
2025-07-09 9:53 ` [PATCH v3 3/3] fbdev: kyro: Use devm_ioremap_wc() for screen mem Giovanni Di Santi
2025-07-27 17:57 ` [PATCH v3 0/3] fbdev: kyro: Convert to managed device resources Helge Deller
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).