linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RfC PATCH] fbdev: list all memory bars as conflicting apertures
@ 2019-03-13 11:07 Gerd Hoffmann
  2019-03-14 10:37 ` Daniel Vetter
  0 siblings, 1 reply; 3+ messages in thread
From: Gerd Hoffmann @ 2019-03-13 11:07 UTC (permalink / raw)
  To: dri-devel
  Cc: Daniel Vetter, Gerd Hoffmann, Bartlomiej Zolnierkiewicz,
	open list:FRAMEBUFFER LAYER, open list

Simply add all pci memory bars to struct apertures_struct in
remove_conflicting_pci_framebuffers().  That allows to drop
the res_id parameter.

TODO: actually remove the res_id parameter.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 drivers/video/fbdev/core/fbmem.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
index cb43a2258c51..e8223c231de2 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c
@@ -1879,14 +1879,28 @@ int remove_conflicting_pci_framebuffers(struct pci_dev *pdev, int res_id, const
 {
 	struct apertures_struct *ap;
 	bool primary = false;
-	int err;
+	int err, idx, cnt, bar;
 
-	ap = alloc_apertures(1);
+	for (cnt = 0, bar = 0; bar < PCI_ROM_RESOURCE; bar++) {
+		if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM))
+			continue;
+		cnt++;
+	}
+
+	ap = alloc_apertures(cnt);
 	if (!ap)
 		return -ENOMEM;
 
-	ap->ranges[0].base = pci_resource_start(pdev, res_id);
-	ap->ranges[0].size = pci_resource_len(pdev, res_id);
+	for (idx = 0, bar = 0; bar < PCI_ROM_RESOURCE; bar++) {
+		if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM))
+			continue;
+		ap->ranges[idx].base = pci_resource_start(pdev, bar);
+		ap->ranges[idx].size = pci_resource_len(pdev, bar);
+		pci_info(pdev, "%s: bar %d: 0x%lx -> 0x%lx\n", __func__, bar,
+			 (unsigned long)pci_resource_start(pdev, bar),
+			 (unsigned long)pci_resource_end(pdev, bar));
+		idx++;
+	}
 #ifdef CONFIG_X86
 	primary = pdev->resource[PCI_ROM_RESOURCE].flags &
 					IORESOURCE_ROM_SHADOW;
-- 
2.18.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [RfC PATCH] fbdev: list all memory bars as conflicting apertures
  2019-03-13 11:07 [RfC PATCH] fbdev: list all memory bars as conflicting apertures Gerd Hoffmann
@ 2019-03-14 10:37 ` Daniel Vetter
  2019-03-14 11:30   ` Gerd Hoffmann
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Vetter @ 2019-03-14 10:37 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: dri-devel, Daniel Vetter, Bartlomiej Zolnierkiewicz,
	open list:FRAMEBUFFER LAYER, open list

On Wed, Mar 13, 2019 at 12:07:41PM +0100, Gerd Hoffmann wrote:
> Simply add all pci memory bars to struct apertures_struct in
> remove_conflicting_pci_framebuffers().  That allows to drop
> the res_id parameter.
> 
> TODO: actually remove the res_id parameter.

I think best to do that in a cleanup patch afterwards.
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  drivers/video/fbdev/core/fbmem.c | 22 ++++++++++++++++++----
>  1 file changed, 18 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
> index cb43a2258c51..e8223c231de2 100644
> --- a/drivers/video/fbdev/core/fbmem.c
> +++ b/drivers/video/fbdev/core/fbmem.c
> @@ -1879,14 +1879,28 @@ int remove_conflicting_pci_framebuffers(struct pci_dev *pdev, int res_id, const
>  {
>  	struct apertures_struct *ap;
>  	bool primary = false;
> -	int err;
> +	int err, idx, cnt, bar;
>  
> -	ap = alloc_apertures(1);
> +	for (cnt = 0, bar = 0; bar < PCI_ROM_RESOURCE; bar++) {
> +		if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM))
> +			continue;
> +		cnt++;
> +	}
> +
> +	ap = alloc_apertures(cnt);
>  	if (!ap)
>  		return -ENOMEM;
>  
> -	ap->ranges[0].base = pci_resource_start(pdev, res_id);
> -	ap->ranges[0].size = pci_resource_len(pdev, res_id);
> +	for (idx = 0, bar = 0; bar < PCI_ROM_RESOURCE; bar++) {
> +		if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM))
> +			continue;
> +		ap->ranges[idx].base = pci_resource_start(pdev, bar);
> +		ap->ranges[idx].size = pci_resource_len(pdev, bar);
> +		pci_info(pdev, "%s: bar %d: 0x%lx -> 0x%lx\n", __func__, bar,
> +			 (unsigned long)pci_resource_start(pdev, bar),
> +			 (unsigned long)pci_resource_end(pdev, bar));
> +		idx++;
> +	}

lgtm. I think this is ok to merge as-is already ...

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

Maybe if you want to be paranoid in the conversion add a check that we're
not skipping the pci bar requested in res_id. Then we could test this for
a kernel and remove the parameter later on.
-Daniel


>  #ifdef CONFIG_X86
>  	primary = pdev->resource[PCI_ROM_RESOURCE].flags &
>  					IORESOURCE_ROM_SHADOW;
> -- 
> 2.18.1
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RfC PATCH] fbdev: list all memory bars as conflicting apertures
  2019-03-14 10:37 ` Daniel Vetter
@ 2019-03-14 11:30   ` Gerd Hoffmann
  0 siblings, 0 replies; 3+ messages in thread
From: Gerd Hoffmann @ 2019-03-14 11:30 UTC (permalink / raw)
  To: dri-devel, Bartlomiej Zolnierkiewicz,
	open list:FRAMEBUFFER LAYER, open list

On Thu, Mar 14, 2019 at 11:37:13AM +0100, Daniel Vetter wrote:
> On Wed, Mar 13, 2019 at 12:07:41PM +0100, Gerd Hoffmann wrote:
> > Simply add all pci memory bars to struct apertures_struct in
> > remove_conflicting_pci_framebuffers().  That allows to drop
> > the res_id parameter.
> > 
> > TODO: actually remove the res_id parameter.
> 
> I think best to do that in a cleanup patch afterwards.

I was just lazy and didn't want update all callers for the first patch
draft.  But doing a test run ...

> Maybe if you want to be paranoid in the conversion add a check that we're
> not skipping the pci bar requested in res_id. Then we could test this for
> a kernel and remove the parameter later on.

... that way before actually dropping the parameter surely makes sense.

New version on the way,
  Gerd


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-03-14 11:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-13 11:07 [RfC PATCH] fbdev: list all memory bars as conflicting apertures Gerd Hoffmann
2019-03-14 10:37 ` Daniel Vetter
2019-03-14 11:30   ` Gerd Hoffmann

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).