Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1391641 > unrolled thread

[PATCH v2] x86:sysfb_efi:efifb_set_system: fix miss valid address range in later BARs

Started byWang YanQing <udknight@gmail.com>
First post2016-04-30 18:30 +0200
Last post2016-05-03 17:30 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v2] x86:sysfb_efi:efifb_set_system: fix miss valid address  range in later BARs Wang YanQing <udknight@gmail.com> - 2016-04-30 18:30 +0200
    Re: [PATCH v2] x86:sysfb_efi:efifb_set_system: fix miss valid  address range in later BARs Peter Jones <pjones@redhat.com> - 2016-05-02 21:20 +0200
      Re: [PATCH v2] x86:sysfb_efi:efifb_set_system: fix miss valid  address range in later BARs Matt Fleming <matt@codeblueprint.co.uk> - 2016-05-03 17:30 +0200

#1391641 — [PATCH v2] x86:sysfb_efi:efifb_set_system: fix miss valid address range in later BARs

FromWang YanQing <udknight@gmail.com>
Date2016-04-30 18:30 +0200
Subject[PATCH v2] x86:sysfb_efi:efifb_set_system: fix miss valid address range in later BARs
Message-ID<rtFWi-2dj-17@gated-at.bofh.it>
We can't just break out when meet start is equal to zero,
this will cause we miss valid address range in later BARs.

On the other hand, it isn't enough to test start only
for below situation:
0(start) <= lfb_base < end

Note: this patch also add a trivial optimization,
      break out after we find the address range
      is valid without test later BARs.

Signed-off-by: Wang YanQing <udknight@gmail.com>
---
 Due to the BUG this patch fix, I can't use video=efifb:
 boot parameter to get efifb on my new ThinkPad E550 for
 my old linux system hard disk with 3.10 kernel. In 3.10, 
 efifb is the only choice due to DRM/I915 in it doesn't 
 support the GPU.

 Changes:
 v1-v2:
 1: Do a trivial code optimization.

 arch/x86/kernel/sysfb_efi.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/sysfb_efi.c b/arch/x86/kernel/sysfb_efi.c
index b285d4e..5da924b 100644
--- a/arch/x86/kernel/sysfb_efi.c
+++ b/arch/x86/kernel/sysfb_efi.c
@@ -106,14 +106,24 @@ static int __init efifb_set_system(const struct dmi_system_id *id)
 					continue;
 				for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
 					resource_size_t start, end;
+					unsigned long flags;
+
+					flags = pci_resource_flags(dev, i);
+					if (!(flags & IORESOURCE_MEM))
+						continue;
+
+					if (flags & IORESOURCE_UNSET)
+						continue;
+
+					if (pci_resource_len(dev, i) == 0)
+						continue;
 
 					start = pci_resource_start(dev, i);
-					if (start == 0)
-						break;
 					end = pci_resource_end(dev, i);
 					if (screen_info.lfb_base >= start &&
 					    screen_info.lfb_base < end) {
 						found_bar = 1;
+						break;
 					}
 				}
 			}
-- 
1.8.5.6.2.g3d8a54e.dirty

[toc] | [next] | [standalone]


#1392469 — Re: [PATCH v2] x86:sysfb_efi:efifb_set_system: fix miss valid address range in later BARs

FromPeter Jones <pjones@redhat.com>
Date2016-05-02 21:20 +0200
SubjectRe: [PATCH v2] x86:sysfb_efi:efifb_set_system: fix miss valid address range in later BARs
Message-ID<rurxT-SM-5@gated-at.bofh.it>
In reply to#1391641
On Sun, May 01, 2016 at 12:21:05AM +0800, Wang YanQing wrote:
> We can't just break out when meet start is equal to zero,
> this will cause we miss valid address range in later BARs.
> 
> On the other hand, it isn't enough to test start only
> for below situation:
> 0(start) <= lfb_base < end
> 
> Note: this patch also add a trivial optimization,
>       break out after we find the address range
>       is valid without test later BARs.
> 
> Signed-off-by: Wang YanQing <udknight@gmail.com>

This looks correct to me:

Reviewed-By: Peter Jones <pjones@redhat.com>

Cc'ing Matt Fleming, since this should probably go through the EFI tree.

> ---
>  Due to the BUG this patch fix, I can't use video=efifb:
>  boot parameter to get efifb on my new ThinkPad E550 for
>  my old linux system hard disk with 3.10 kernel. In 3.10, 
>  efifb is the only choice due to DRM/I915 in it doesn't 
>  support the GPU.
> 
>  Changes:
>  v1-v2:
>  1: Do a trivial code optimization.
> 
>  arch/x86/kernel/sysfb_efi.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kernel/sysfb_efi.c b/arch/x86/kernel/sysfb_efi.c
> index b285d4e..5da924b 100644
> --- a/arch/x86/kernel/sysfb_efi.c
> +++ b/arch/x86/kernel/sysfb_efi.c
> @@ -106,14 +106,24 @@ static int __init efifb_set_system(const struct dmi_system_id *id)
>  					continue;
>  				for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
>  					resource_size_t start, end;
> +					unsigned long flags;
> +
> +					flags = pci_resource_flags(dev, i);
> +					if (!(flags & IORESOURCE_MEM))
> +						continue;
> +
> +					if (flags & IORESOURCE_UNSET)
> +						continue;
> +
> +					if (pci_resource_len(dev, i) == 0)
> +						continue;
>  
>  					start = pci_resource_start(dev, i);
> -					if (start == 0)
> -						break;
>  					end = pci_resource_end(dev, i);
>  					if (screen_info.lfb_base >= start &&
>  					    screen_info.lfb_base < end) {
>  						found_bar = 1;
> +						break;
>  					}
>  				}
>  			}
> -- 
> 1.8.5.6.2.g3d8a54e.dirty

-- 
  Peter

[toc] | [prev] | [next] | [standalone]


#1393522 — Re: [PATCH v2] x86:sysfb_efi:efifb_set_system: fix miss valid address range in later BARs

FromMatt Fleming <matt@codeblueprint.co.uk>
Date2016-05-03 17:30 +0200
SubjectRe: [PATCH v2] x86:sysfb_efi:efifb_set_system: fix miss valid address range in later BARs
Message-ID<ruKqS-24h-39@gated-at.bofh.it>
In reply to#1392469
On Mon, 02 May, at 03:11:20PM, Peter Jones wrote:
> On Sun, May 01, 2016 at 12:21:05AM +0800, Wang YanQing wrote:
> > We can't just break out when meet start is equal to zero,
> > this will cause we miss valid address range in later BARs.
> > 
> > On the other hand, it isn't enough to test start only
> > for below situation:
> > 0(start) <= lfb_base < end
> > 
> > Note: this patch also add a trivial optimization,
> >       break out after we find the address range
> >       is valid without test later BARs.
> > 
> > Signed-off-by: Wang YanQing <udknight@gmail.com>
> 
> This looks correct to me:
> 
> Reviewed-By: Peter Jones <pjones@redhat.com>
> 
> Cc'ing Matt Fleming, since this should probably go through the EFI tree.

Applied, thanks.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web