All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Lukas Wunner <lukas@wunner.de>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-efi@vger.kernel.org" <linux-efi@vger.kernel.org>,
	Matt Fleming <matt@codeblueprint.co.uk>,
	Peter Jones <pjones@redhat.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Hanjun Guo <hanjun.guo@linaro.org>,
	Heyi Guo <heyi.guo@linaro.org>,
	linux-pci <linux-pci@vger.kernel.org>,
	Yinghai Lu <yinghai@kernel.org>
Subject: Re: [PATCH v3] efifb: avoid reconfiguration of BAR that covers the framebuffer
Date: Thu, 23 Mar 2017 14:31:51 +0000	[thread overview]
Message-ID: <20170323143151.GA21544@red-moon> (raw)
In-Reply-To: <CAKv+Gu-J664KXaZR19nViq4o1n_x=P-trsZ0oNDiONuBpAcd7A@mail.gmail.com>

On Thu, Mar 23, 2017 at 12:25:48PM +0000, Ard Biesheuvel wrote:
> On 23 March 2017 at 10:57, Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> wrote:
> > On Thu, Mar 23, 2017 at 09:04:03AM +0000, Ard Biesheuvel wrote:
> >> On 23 March 2017 at 08:48, Lukas Wunner <lukas@wunner.de> wrote:
> >> > On Wed, Mar 22, 2017 at 07:32:43PM +0000, Ard Biesheuvel wrote:
> >> >> On 22 March 2017 at 19:31, Lukas Wunner <lukas@wunner.de> wrote:
> >> >> > On Wed, Mar 22, 2017 at 03:30:29PM +0000, Ard Biesheuvel wrote:
> >> >> >> On UEFI systems, the PCI subsystem is enumerated by the firmware,
> >> >> >> and if a graphical framebuffer is exposed by a PCI device, its base
> >> >> >> address and size are exposed to the OS via the Graphics Output
> >> >> >> Protocol (GOP).
> >> >> >>
> >> >> >> On arm64 PCI systems, the entire PCI hierarchy is reconfigured from
> >> >> >> scratch at boot. This may result in the GOP framebuffer address to
> >> >> >> become stale, if the BAR covering the framebuffer is modified. This
> >> >> >> will cause the framebuffer to become unresponsive, and may in some
> >> >> >> cases result in unpredictable behavior if the range is reassigned to
> >> >> >> another device.
> >> >> >
> >> >> > Hm, commit message seems to indicate the issue is restricted to arm64,
> >> >> > yet there's no IS_ENABLED(ARM64) to constrain the added code to that arch?
> >> >>
> >> >> True. I am eager to get some x86 coverage for this, since I would
> >> >> expect this not to do any harm. But I'm fine with making it ARM/arm64
> >> >> specific in the final version.
> >> >
> >> > I see.  IIUC, this is only a problem because pci_bus_assign_resources()
> >> > is called from arch/arm64/kernel/pci.c:pci_acpi_scan_root() (as well as
> >> > the host drivers) and x86 isn't affected because it doesn't do that.
> >> >
> >>
> >> Correct. But on x86 (or rather, on a PC), you can be sure that UEFI
> >> (or the legacy PCI bios) performed the resource assignment already.
> >> One could argue that this is equally the case when running arm64 in
> >> ACPI mode, but in general, you cannot assume the presence of firmware
> >> on ARM/arm64 that has already taken care of this, and so the state of
> >> the BARs has to be presumed invalid.
> >
> > The story is a bit more convoluted than that owing to x86 (and other
> > arches) legacy.
> >
> > x86 tries to claim all PCI resources (in two passes - first enabled
> > devices, second disabled devices) and that predates ACPI/UEFI.
> >
> > Mind, x86 reassign resources that can't be claimed too, the only
> > difference with ARM64 is that, for the better or the worse, we
> > have decided not to claim the FW PCI set-up on ARM64 even if it
> > is sane, we do not even try, it was a deliberate choice.
> >
> > This patch should be harmless on x86 since if the FB PCI BAR is set
> > up sanely, claiming it again should be a nop (to be checked).
> >
> 
> I have checked this with OVMF under QEMU. Claiming the resource early
> like we do this in this patch does not result in any diagnostic output
> or other symptoms that would suggest that anything unexpected occurs.

There is something that I do not understand on how the resource
claiming works on x86. IIUC on x86, resource claiming is done in:

arch/x86/pci/legacy.c

pci_subsys_init()
 -> pcibios_init()
  -> pcibios_resource_survey()

pci_subsys_init() is run in a subsys_initcall.

Now, how do we ensure that resource claiming is carried out _after_
the PCI root busses have been actually scanned ?

The ACPI scan handler interface (so the interface to actually scan
a PCI root bridge in ACPI) is initialized in acpi_init() (which
is a subsys_initcall), how do we guarantee that is run before
pci_subsys_init() ?

x86 implements pcibios_resource_survey_bus(), but that's called only
for hotplugged bridges (?):

drivers/acpi/pci_root.c -> acpi_pci_root_add()

>From the log below, I see two options:

- x86 pcibios_resource_survey() is called before any root bus is added
  (so it does precious little)
- x86 pcibios_resource_survey() is called after root busses are added and
  the PCI device fixup has been applied (and the additional claim in it
  succeeds silently)

I am certainly missing something here, I will grab an x86 box to add
a couple of logs and see if my assumptions are correct, I would like
to get to the bottom of this, I think that's important.

Lorenzo
 
> For the record: I applied the following hunk on top of the current
> version of this patch
> 
> diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c
> index 88f653864a01..98b7c437a448 100644
> --- a/drivers/video/fbdev/efifb.c
> +++ b/drivers/video/fbdev/efifb.c
> @@ -380,7 +380,10 @@ static void claim_efifb_bar(struct pci_dev *dev, int idx)
>                 return;
>         }
> 
> -       if (pci_claim_resource(dev, idx)) {
> +       if (dev->resource[idx].parent != NULL) {
> +               dev_info(&dev->dev, "BAR %d: resource already claimed\n", idx);
> +               while (1) { asm ("hlt"); }
> +       } else if (pci_claim_resource(dev, idx)) {
>                 pci_dev_disabled = true;
>                 dev_err(&dev->dev,
>                         "BAR %d: failed to claim resource for efifb!\n", idx);
> 
> and got the following output in the kernel log related to BDF 0/2/0 and efifb
> 
> pci 0000:00:02.0: [1234:1111] type 00 class 0x030000
> pci 0000:00:02.0: reg 0x10: [mem 0x80000000-0x80ffffff pref]
> pci 0000:00:02.0: reg 0x18: [mem 0x81020000-0x81020fff]
> pci 0000:00:02.0: reg 0x30: [mem 0xffff0000-0xffffffff pref]
> pci 0000:00:02.0: BAR 0: assigned to efifb
> pci 0000:00:02.0: can't claim BAR 6 [mem 0xffff0000-0xffffffff pref]:
> no compatible bridge window
> pci 0000:00:02.0: BAR 6: assigned [mem 0x08040000-0x0804ffff pref]
> pci 0000:00:02.0: Video device with shadowed ROM at [mem 0x000c0000-0x000dffff]
> efifb: probing for efifb
> efifb: framebuffer at 0x80000000, using 1876k, total 1875k
> efifb: mode is 800x600x32, linelength=3200, pages=1
> efifb: scrolling: redraw
> efifb: Truecolor: size=8:8:8:8, shift=24:16:8:0
> 
> whereas a kernel without this patch gives me
> 
> pci 0000:00:02.0: [1234:1111] type 00 class 0x030000
> pci 0000:00:02.0: reg 0x10: [mem 0x80000000-0x80ffffff pref]
> pci 0000:00:02.0: reg 0x18: [mem 0x81020000-0x81020fff]
> pci 0000:00:02.0: reg 0x30: [mem 0xffff0000-0xffffffff pref]
> pci 0000:00:02.0: can't claim BAR 6 [mem 0xffff0000-0xffffffff pref]:
> no compatible bridge window
> pci 0000:00:02.0: BAR 6: assigned [mem 0x08040000-0x0804ffff pref]
> pci 0000:00:02.0: Video device with shadowed ROM at [mem 0x000c0000-0x000dffff]
> efifb: probing for efifb
> efifb: framebuffer at 0x80000000, using 1876k, total 1875k
> efifb: mode is 800x600x32, linelength=3200, pages=1
> efifb: scrolling: redraw
> efifb: Truecolor: size=8:8:8:8, shift=24:16:8:0
> 
> /proc/iomem looks exactly the same.
> 
> So in summary, x86 does not seem to care.
> 
> Furthermore, I tested with this change, as suggested by Lukas
> 
> diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c
> index 88f653864a01..c72d84590343 100644
> --- a/drivers/video/fbdev/efifb.c
> +++ b/drivers/video/fbdev/efifb.c
> @@ -417,4 +417,5 @@ static void efifb_fixup_resources(struct pci_dev *dev)
>                 }
>         }
>  }
> -DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, efifb_fixup_resources);
> +DECLARE_PCI_FIXUP_CLASS_HEADER(PCI_ANY_ID, PCI_ANY_ID, PCI_BASE_CLASS_DISPLAY,
> +                              16, efifb_fixup_resources);
> 
> 
> which does appear to work fine, and thinking about it, I feel there is
> only so much we can do to sanity check the efifb against the PCI setup
> performed by the firmware, so I am inclined to fold this in.

WARNING: multiple messages have this Message-ID (diff)
From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: "linux-efi@vger.kernel.org" <linux-efi@vger.kernel.org>,
	Matt Fleming <matt@codeblueprint.co.uk>,
	linux-pci <linux-pci@vger.kernel.org>,
	Peter Jones <pjones@redhat.com>, Heyi Guo <heyi.guo@linaro.org>,
	Lukas Wunner <lukas@wunner.de>,
	Hanjun Guo <hanjun.guo@linaro.org>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Yinghai Lu <yinghai@kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v3] efifb: avoid reconfiguration of BAR that covers the framebuffer
Date: Thu, 23 Mar 2017 14:31:51 +0000	[thread overview]
Message-ID: <20170323143151.GA21544@red-moon> (raw)
In-Reply-To: <CAKv+Gu-J664KXaZR19nViq4o1n_x=P-trsZ0oNDiONuBpAcd7A@mail.gmail.com>

On Thu, Mar 23, 2017 at 12:25:48PM +0000, Ard Biesheuvel wrote:
> On 23 March 2017 at 10:57, Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> wrote:
> > On Thu, Mar 23, 2017 at 09:04:03AM +0000, Ard Biesheuvel wrote:
> >> On 23 March 2017 at 08:48, Lukas Wunner <lukas@wunner.de> wrote:
> >> > On Wed, Mar 22, 2017 at 07:32:43PM +0000, Ard Biesheuvel wrote:
> >> >> On 22 March 2017 at 19:31, Lukas Wunner <lukas@wunner.de> wrote:
> >> >> > On Wed, Mar 22, 2017 at 03:30:29PM +0000, Ard Biesheuvel wrote:
> >> >> >> On UEFI systems, the PCI subsystem is enumerated by the firmware,
> >> >> >> and if a graphical framebuffer is exposed by a PCI device, its base
> >> >> >> address and size are exposed to the OS via the Graphics Output
> >> >> >> Protocol (GOP).
> >> >> >>
> >> >> >> On arm64 PCI systems, the entire PCI hierarchy is reconfigured from
> >> >> >> scratch at boot. This may result in the GOP framebuffer address to
> >> >> >> become stale, if the BAR covering the framebuffer is modified. This
> >> >> >> will cause the framebuffer to become unresponsive, and may in some
> >> >> >> cases result in unpredictable behavior if the range is reassigned to
> >> >> >> another device.
> >> >> >
> >> >> > Hm, commit message seems to indicate the issue is restricted to arm64,
> >> >> > yet there's no IS_ENABLED(ARM64) to constrain the added code to that arch?
> >> >>
> >> >> True. I am eager to get some x86 coverage for this, since I would
> >> >> expect this not to do any harm. But I'm fine with making it ARM/arm64
> >> >> specific in the final version.
> >> >
> >> > I see.  IIUC, this is only a problem because pci_bus_assign_resources()
> >> > is called from arch/arm64/kernel/pci.c:pci_acpi_scan_root() (as well as
> >> > the host drivers) and x86 isn't affected because it doesn't do that.
> >> >
> >>
> >> Correct. But on x86 (or rather, on a PC), you can be sure that UEFI
> >> (or the legacy PCI bios) performed the resource assignment already.
> >> One could argue that this is equally the case when running arm64 in
> >> ACPI mode, but in general, you cannot assume the presence of firmware
> >> on ARM/arm64 that has already taken care of this, and so the state of
> >> the BARs has to be presumed invalid.
> >
> > The story is a bit more convoluted than that owing to x86 (and other
> > arches) legacy.
> >
> > x86 tries to claim all PCI resources (in two passes - first enabled
> > devices, second disabled devices) and that predates ACPI/UEFI.
> >
> > Mind, x86 reassign resources that can't be claimed too, the only
> > difference with ARM64 is that, for the better or the worse, we
> > have decided not to claim the FW PCI set-up on ARM64 even if it
> > is sane, we do not even try, it was a deliberate choice.
> >
> > This patch should be harmless on x86 since if the FB PCI BAR is set
> > up sanely, claiming it again should be a nop (to be checked).
> >
> 
> I have checked this with OVMF under QEMU. Claiming the resource early
> like we do this in this patch does not result in any diagnostic output
> or other symptoms that would suggest that anything unexpected occurs.

There is something that I do not understand on how the resource
claiming works on x86. IIUC on x86, resource claiming is done in:

arch/x86/pci/legacy.c

pci_subsys_init()
 -> pcibios_init()
  -> pcibios_resource_survey()

pci_subsys_init() is run in a subsys_initcall.

Now, how do we ensure that resource claiming is carried out _after_
the PCI root busses have been actually scanned ?

The ACPI scan handler interface (so the interface to actually scan
a PCI root bridge in ACPI) is initialized in acpi_init() (which
is a subsys_initcall), how do we guarantee that is run before
pci_subsys_init() ?

x86 implements pcibios_resource_survey_bus(), but that's called only
for hotplugged bridges (?):

drivers/acpi/pci_root.c -> acpi_pci_root_add()

>From the log below, I see two options:

- x86 pcibios_resource_survey() is called before any root bus is added
  (so it does precious little)
- x86 pcibios_resource_survey() is called after root busses are added and
  the PCI device fixup has been applied (and the additional claim in it
  succeeds silently)

I am certainly missing something here, I will grab an x86 box to add
a couple of logs and see if my assumptions are correct, I would like
to get to the bottom of this, I think that's important.

Lorenzo
 
> For the record: I applied the following hunk on top of the current
> version of this patch
> 
> diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c
> index 88f653864a01..98b7c437a448 100644
> --- a/drivers/video/fbdev/efifb.c
> +++ b/drivers/video/fbdev/efifb.c
> @@ -380,7 +380,10 @@ static void claim_efifb_bar(struct pci_dev *dev, int idx)
>                 return;
>         }
> 
> -       if (pci_claim_resource(dev, idx)) {
> +       if (dev->resource[idx].parent != NULL) {
> +               dev_info(&dev->dev, "BAR %d: resource already claimed\n", idx);
> +               while (1) { asm ("hlt"); }
> +       } else if (pci_claim_resource(dev, idx)) {
>                 pci_dev_disabled = true;
>                 dev_err(&dev->dev,
>                         "BAR %d: failed to claim resource for efifb!\n", idx);
> 
> and got the following output in the kernel log related to BDF 0/2/0 and efifb
> 
> pci 0000:00:02.0: [1234:1111] type 00 class 0x030000
> pci 0000:00:02.0: reg 0x10: [mem 0x80000000-0x80ffffff pref]
> pci 0000:00:02.0: reg 0x18: [mem 0x81020000-0x81020fff]
> pci 0000:00:02.0: reg 0x30: [mem 0xffff0000-0xffffffff pref]
> pci 0000:00:02.0: BAR 0: assigned to efifb
> pci 0000:00:02.0: can't claim BAR 6 [mem 0xffff0000-0xffffffff pref]:
> no compatible bridge window
> pci 0000:00:02.0: BAR 6: assigned [mem 0x08040000-0x0804ffff pref]
> pci 0000:00:02.0: Video device with shadowed ROM at [mem 0x000c0000-0x000dffff]
> efifb: probing for efifb
> efifb: framebuffer at 0x80000000, using 1876k, total 1875k
> efifb: mode is 800x600x32, linelength=3200, pages=1
> efifb: scrolling: redraw
> efifb: Truecolor: size=8:8:8:8, shift=24:16:8:0
> 
> whereas a kernel without this patch gives me
> 
> pci 0000:00:02.0: [1234:1111] type 00 class 0x030000
> pci 0000:00:02.0: reg 0x10: [mem 0x80000000-0x80ffffff pref]
> pci 0000:00:02.0: reg 0x18: [mem 0x81020000-0x81020fff]
> pci 0000:00:02.0: reg 0x30: [mem 0xffff0000-0xffffffff pref]
> pci 0000:00:02.0: can't claim BAR 6 [mem 0xffff0000-0xffffffff pref]:
> no compatible bridge window
> pci 0000:00:02.0: BAR 6: assigned [mem 0x08040000-0x0804ffff pref]
> pci 0000:00:02.0: Video device with shadowed ROM at [mem 0x000c0000-0x000dffff]
> efifb: probing for efifb
> efifb: framebuffer at 0x80000000, using 1876k, total 1875k
> efifb: mode is 800x600x32, linelength=3200, pages=1
> efifb: scrolling: redraw
> efifb: Truecolor: size=8:8:8:8, shift=24:16:8:0
> 
> /proc/iomem looks exactly the same.
> 
> So in summary, x86 does not seem to care.
> 
> Furthermore, I tested with this change, as suggested by Lukas
> 
> diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c
> index 88f653864a01..c72d84590343 100644
> --- a/drivers/video/fbdev/efifb.c
> +++ b/drivers/video/fbdev/efifb.c
> @@ -417,4 +417,5 @@ static void efifb_fixup_resources(struct pci_dev *dev)
>                 }
>         }
>  }
> -DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, efifb_fixup_resources);
> +DECLARE_PCI_FIXUP_CLASS_HEADER(PCI_ANY_ID, PCI_ANY_ID, PCI_BASE_CLASS_DISPLAY,
> +                              16, efifb_fixup_resources);
> 
> 
> which does appear to work fine, and thinking about it, I feel there is
> only so much we can do to sanity check the efifb against the PCI setup
> performed by the firmware, so I am inclined to fold this in.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: lorenzo.pieralisi@arm.com (Lorenzo Pieralisi)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3] efifb: avoid reconfiguration of BAR that covers the framebuffer
Date: Thu, 23 Mar 2017 14:31:51 +0000	[thread overview]
Message-ID: <20170323143151.GA21544@red-moon> (raw)
In-Reply-To: <CAKv+Gu-J664KXaZR19nViq4o1n_x=P-trsZ0oNDiONuBpAcd7A@mail.gmail.com>

On Thu, Mar 23, 2017 at 12:25:48PM +0000, Ard Biesheuvel wrote:
> On 23 March 2017 at 10:57, Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> wrote:
> > On Thu, Mar 23, 2017 at 09:04:03AM +0000, Ard Biesheuvel wrote:
> >> On 23 March 2017 at 08:48, Lukas Wunner <lukas@wunner.de> wrote:
> >> > On Wed, Mar 22, 2017 at 07:32:43PM +0000, Ard Biesheuvel wrote:
> >> >> On 22 March 2017 at 19:31, Lukas Wunner <lukas@wunner.de> wrote:
> >> >> > On Wed, Mar 22, 2017 at 03:30:29PM +0000, Ard Biesheuvel wrote:
> >> >> >> On UEFI systems, the PCI subsystem is enumerated by the firmware,
> >> >> >> and if a graphical framebuffer is exposed by a PCI device, its base
> >> >> >> address and size are exposed to the OS via the Graphics Output
> >> >> >> Protocol (GOP).
> >> >> >>
> >> >> >> On arm64 PCI systems, the entire PCI hierarchy is reconfigured from
> >> >> >> scratch at boot. This may result in the GOP framebuffer address to
> >> >> >> become stale, if the BAR covering the framebuffer is modified. This
> >> >> >> will cause the framebuffer to become unresponsive, and may in some
> >> >> >> cases result in unpredictable behavior if the range is reassigned to
> >> >> >> another device.
> >> >> >
> >> >> > Hm, commit message seems to indicate the issue is restricted to arm64,
> >> >> > yet there's no IS_ENABLED(ARM64) to constrain the added code to that arch?
> >> >>
> >> >> True. I am eager to get some x86 coverage for this, since I would
> >> >> expect this not to do any harm. But I'm fine with making it ARM/arm64
> >> >> specific in the final version.
> >> >
> >> > I see.  IIUC, this is only a problem because pci_bus_assign_resources()
> >> > is called from arch/arm64/kernel/pci.c:pci_acpi_scan_root() (as well as
> >> > the host drivers) and x86 isn't affected because it doesn't do that.
> >> >
> >>
> >> Correct. But on x86 (or rather, on a PC), you can be sure that UEFI
> >> (or the legacy PCI bios) performed the resource assignment already.
> >> One could argue that this is equally the case when running arm64 in
> >> ACPI mode, but in general, you cannot assume the presence of firmware
> >> on ARM/arm64 that has already taken care of this, and so the state of
> >> the BARs has to be presumed invalid.
> >
> > The story is a bit more convoluted than that owing to x86 (and other
> > arches) legacy.
> >
> > x86 tries to claim all PCI resources (in two passes - first enabled
> > devices, second disabled devices) and that predates ACPI/UEFI.
> >
> > Mind, x86 reassign resources that can't be claimed too, the only
> > difference with ARM64 is that, for the better or the worse, we
> > have decided not to claim the FW PCI set-up on ARM64 even if it
> > is sane, we do not even try, it was a deliberate choice.
> >
> > This patch should be harmless on x86 since if the FB PCI BAR is set
> > up sanely, claiming it again should be a nop (to be checked).
> >
> 
> I have checked this with OVMF under QEMU. Claiming the resource early
> like we do this in this patch does not result in any diagnostic output
> or other symptoms that would suggest that anything unexpected occurs.

There is something that I do not understand on how the resource
claiming works on x86. IIUC on x86, resource claiming is done in:

arch/x86/pci/legacy.c

pci_subsys_init()
 -> pcibios_init()
  -> pcibios_resource_survey()

pci_subsys_init() is run in a subsys_initcall.

Now, how do we ensure that resource claiming is carried out _after_
the PCI root busses have been actually scanned ?

The ACPI scan handler interface (so the interface to actually scan
a PCI root bridge in ACPI) is initialized in acpi_init() (which
is a subsys_initcall), how do we guarantee that is run before
pci_subsys_init() ?

x86 implements pcibios_resource_survey_bus(), but that's called only
for hotplugged bridges (?):

drivers/acpi/pci_root.c -> acpi_pci_root_add()

>From the log below, I see two options:

- x86 pcibios_resource_survey() is called before any root bus is added
  (so it does precious little)
- x86 pcibios_resource_survey() is called after root busses are added and
  the PCI device fixup has been applied (and the additional claim in it
  succeeds silently)

I am certainly missing something here, I will grab an x86 box to add
a couple of logs and see if my assumptions are correct, I would like
to get to the bottom of this, I think that's important.

Lorenzo
 
> For the record: I applied the following hunk on top of the current
> version of this patch
> 
> diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c
> index 88f653864a01..98b7c437a448 100644
> --- a/drivers/video/fbdev/efifb.c
> +++ b/drivers/video/fbdev/efifb.c
> @@ -380,7 +380,10 @@ static void claim_efifb_bar(struct pci_dev *dev, int idx)
>                 return;
>         }
> 
> -       if (pci_claim_resource(dev, idx)) {
> +       if (dev->resource[idx].parent != NULL) {
> +               dev_info(&dev->dev, "BAR %d: resource already claimed\n", idx);
> +               while (1) { asm ("hlt"); }
> +       } else if (pci_claim_resource(dev, idx)) {
>                 pci_dev_disabled = true;
>                 dev_err(&dev->dev,
>                         "BAR %d: failed to claim resource for efifb!\n", idx);
> 
> and got the following output in the kernel log related to BDF 0/2/0 and efifb
> 
> pci 0000:00:02.0: [1234:1111] type 00 class 0x030000
> pci 0000:00:02.0: reg 0x10: [mem 0x80000000-0x80ffffff pref]
> pci 0000:00:02.0: reg 0x18: [mem 0x81020000-0x81020fff]
> pci 0000:00:02.0: reg 0x30: [mem 0xffff0000-0xffffffff pref]
> pci 0000:00:02.0: BAR 0: assigned to efifb
> pci 0000:00:02.0: can't claim BAR 6 [mem 0xffff0000-0xffffffff pref]:
> no compatible bridge window
> pci 0000:00:02.0: BAR 6: assigned [mem 0x08040000-0x0804ffff pref]
> pci 0000:00:02.0: Video device with shadowed ROM at [mem 0x000c0000-0x000dffff]
> efifb: probing for efifb
> efifb: framebuffer at 0x80000000, using 1876k, total 1875k
> efifb: mode is 800x600x32, linelength=3200, pages=1
> efifb: scrolling: redraw
> efifb: Truecolor: size=8:8:8:8, shift=24:16:8:0
> 
> whereas a kernel without this patch gives me
> 
> pci 0000:00:02.0: [1234:1111] type 00 class 0x030000
> pci 0000:00:02.0: reg 0x10: [mem 0x80000000-0x80ffffff pref]
> pci 0000:00:02.0: reg 0x18: [mem 0x81020000-0x81020fff]
> pci 0000:00:02.0: reg 0x30: [mem 0xffff0000-0xffffffff pref]
> pci 0000:00:02.0: can't claim BAR 6 [mem 0xffff0000-0xffffffff pref]:
> no compatible bridge window
> pci 0000:00:02.0: BAR 6: assigned [mem 0x08040000-0x0804ffff pref]
> pci 0000:00:02.0: Video device with shadowed ROM at [mem 0x000c0000-0x000dffff]
> efifb: probing for efifb
> efifb: framebuffer at 0x80000000, using 1876k, total 1875k
> efifb: mode is 800x600x32, linelength=3200, pages=1
> efifb: scrolling: redraw
> efifb: Truecolor: size=8:8:8:8, shift=24:16:8:0
> 
> /proc/iomem looks exactly the same.
> 
> So in summary, x86 does not seem to care.
> 
> Furthermore, I tested with this change, as suggested by Lukas
> 
> diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c
> index 88f653864a01..c72d84590343 100644
> --- a/drivers/video/fbdev/efifb.c
> +++ b/drivers/video/fbdev/efifb.c
> @@ -417,4 +417,5 @@ static void efifb_fixup_resources(struct pci_dev *dev)
>                 }
>         }
>  }
> -DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, efifb_fixup_resources);
> +DECLARE_PCI_FIXUP_CLASS_HEADER(PCI_ANY_ID, PCI_ANY_ID, PCI_BASE_CLASS_DISPLAY,
> +                              16, efifb_fixup_resources);
> 
> 
> which does appear to work fine, and thinking about it, I feel there is
> only so much we can do to sanity check the efifb against the PCI setup
> performed by the firmware, so I am inclined to fold this in.

  reply	other threads:[~2017-03-23 14:31 UTC|newest]

Thread overview: 117+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-22 15:30 [PATCH v3] efifb: avoid reconfiguration of BAR that covers the framebuffer Ard Biesheuvel
2017-03-22 15:30 ` Ard Biesheuvel
2017-03-22 15:30 ` Ard Biesheuvel
     [not found] ` <1490196629-28088-1-git-send-email-ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2017-03-22 19:31   ` Lukas Wunner
2017-03-22 19:31     ` Lukas Wunner
2017-03-22 19:31     ` Lukas Wunner
2017-03-22 19:32     ` Ard Biesheuvel
2017-03-22 19:32       ` Ard Biesheuvel
2017-03-22 19:32       ` Ard Biesheuvel
     [not found]       ` <CAKv+Gu_X-SEnz7h9J8boqqjOQGHQawwdSAq4haH-OGu8zdfNfA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-23  8:48         ` Lukas Wunner
2017-03-23  8:48           ` Lukas Wunner
2017-03-23  8:48           ` Lukas Wunner
2017-03-23  9:04           ` Ard Biesheuvel
2017-03-23  9:04             ` Ard Biesheuvel
2017-03-23  9:04             ` Ard Biesheuvel
     [not found]             ` <CAKv+Gu93eJ-js3g7M6Jdm6XGMaWMswFmzBG2qNT4rn+3=1+EyA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-23 10:57               ` Lorenzo Pieralisi
2017-03-23 10:57                 ` Lorenzo Pieralisi
2017-03-23 10:57                 ` Lorenzo Pieralisi
2017-03-23 12:25                 ` Ard Biesheuvel
2017-03-23 12:25                   ` Ard Biesheuvel
2017-03-23 12:25                   ` Ard Biesheuvel
2017-03-23 14:31                   ` Lorenzo Pieralisi [this message]
2017-03-23 14:31                     ` Lorenzo Pieralisi
2017-03-23 14:31                     ` Lorenzo Pieralisi
2017-03-23 15:15                     ` Ard Biesheuvel
2017-03-23 15:15                       ` Ard Biesheuvel
2017-03-23 15:15                       ` Ard Biesheuvel
2017-03-27 15:37                       ` Ard Biesheuvel
2017-03-27 15:37                         ` Ard Biesheuvel
2017-03-27 15:37                         ` Ard Biesheuvel
2017-03-28 21:27                 ` Sinan Kaya
2017-03-28 21:27                   ` Sinan Kaya
2017-03-28 21:27                   ` Sinan Kaya
2017-03-28 21:39                   ` Ard Biesheuvel
2017-03-28 21:39                     ` Ard Biesheuvel
2017-03-28 21:39                     ` Ard Biesheuvel
     [not found]                     ` <CAKv+Gu9LbwpnJNi1OL25MWvYPxEOfKRHcs2jA2121BPaQWPzow-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-28 21:49                       ` Sinan Kaya
2017-03-28 21:49                         ` Sinan Kaya
2017-03-28 21:49                         ` Sinan Kaya
     [not found]                         ` <27f50de3-721e-e8ec-00c8-b7a9d3cff0d6-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2017-03-30  8:46                           ` Ard Biesheuvel
2017-03-30  8:46                             ` Ard Biesheuvel
2017-03-30  8:46                             ` Ard Biesheuvel
     [not found]                             ` <CAKv+Gu-qRg8-YRCairppKrEfeLcW+OwVF8qZHp7vxXJA_AwPOw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-30 10:05                               ` Lorenzo Pieralisi
2017-03-30 10:05                                 ` Lorenzo Pieralisi
2017-03-30 10:05                                 ` Lorenzo Pieralisi
2017-03-30 10:09                                 ` Ard Biesheuvel
2017-03-30 10:09                                   ` Ard Biesheuvel
2017-03-30 10:09                                   ` Ard Biesheuvel
2017-03-30 11:42                                   ` okaya
2017-03-30 11:42                                     ` okaya at codeaurora.org
2017-03-30 11:42                                     ` okaya
2017-03-30 13:38                                   ` Ard Biesheuvel
2017-03-30 13:38                                     ` Ard Biesheuvel
2017-03-30 13:38                                     ` Ard Biesheuvel
2017-03-30 13:50                                     ` Sinan Kaya
2017-03-30 13:50                                       ` Sinan Kaya
2017-03-30 13:50                                       ` Sinan Kaya
     [not found]                                       ` <ae87ae28-f50d-095f-576e-f3fd7f96dea2-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2017-04-02 15:16                                         ` Ard Biesheuvel
2017-04-02 15:16                                           ` Ard Biesheuvel
2017-04-02 15:16                                           ` Ard Biesheuvel
     [not found]                                           ` <CAKv+Gu8x0rQUnTUorknW-mW9LFgrxFYsXyy4LU_w9JbA-m_sjA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-04-10 15:28                                             ` Ard Biesheuvel
2017-04-10 15:28                                               ` Ard Biesheuvel
2017-04-10 15:28                                               ` Ard Biesheuvel
2017-04-10 16:53                                               ` Lorenzo Pieralisi
2017-04-10 16:53                                                 ` Lorenzo Pieralisi
2017-04-10 16:53                                                 ` Lorenzo Pieralisi
2017-04-10 17:06                                                 ` Sinan Kaya
2017-04-10 17:06                                                   ` Sinan Kaya
2017-04-10 17:06                                                   ` Sinan Kaya
2017-04-10 17:13                                                 ` Ard Biesheuvel
2017-04-10 17:13                                                   ` Ard Biesheuvel
2017-04-10 17:13                                                   ` Ard Biesheuvel
     [not found]                                                   ` <CAKv+Gu-AN-OwnAJG5dt0Qg4GU8HxZBowTSA0H3LhNA3nHfrsQg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-04-10 17:29                                                     ` Ard Biesheuvel
2017-04-10 17:29                                                       ` Ard Biesheuvel
2017-04-10 17:29                                                       ` Ard Biesheuvel
     [not found]                                                       ` <CAKv+Gu9dS4OhLbBw59yKYQmoJ8SpFexzk9yH=XfXnzn8NJ4mcg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-04-11 13:16                                                         ` Lorenzo Pieralisi
2017-04-11 13:16                                                           ` Lorenzo Pieralisi
2017-04-11 13:16                                                           ` Lorenzo Pieralisi
2017-04-11 16:06                                                           ` Ard Biesheuvel
2017-04-11 16:06                                                             ` Ard Biesheuvel
2017-04-11 16:06                                                             ` Ard Biesheuvel
2017-04-23  1:45                                                       ` Yinghai Lu
2017-04-23  1:45                                                         ` Yinghai Lu
2017-04-23  1:45                                                         ` Yinghai Lu
     [not found]                                                         ` <20170423014546.GA2704-HmG2f/OLMhfd32I7TRUmRQWg3BAJk+jzdezBB/11ZoCIZ3GwZIjcak9v6f1uFnsJ2SarAXORi/o@public.gmane.org>
2017-04-27 13:55                                                           ` Ard Biesheuvel
2017-04-27 13:55                                                             ` Ard Biesheuvel
2017-04-27 13:55                                                             ` Ard Biesheuvel
     [not found]                                                             ` <CAKv+Gu_n7xP-2RtF44GVzwyoMXDOeF-bR43yStwp2y+oBNs4jg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-04-28 20:51                                                               ` Yinghai Lu
2017-04-28 20:51                                                                 ` Yinghai Lu
2017-04-28 20:51                                                                 ` Yinghai Lu
2017-03-22 19:36     ` Sinan Kaya
2017-03-22 19:36       ` Sinan Kaya
2017-03-22 19:36       ` Sinan Kaya
2017-03-22 19:41       ` Ard Biesheuvel
2017-03-22 19:41         ` Ard Biesheuvel
2017-03-22 19:41         ` Ard Biesheuvel
2017-03-22 19:49         ` Sinan Kaya
2017-03-22 19:49           ` Sinan Kaya
2017-03-22 19:49           ` Sinan Kaya
2017-03-22 19:52           ` Ard Biesheuvel
2017-03-22 19:52             ` Ard Biesheuvel
2017-03-22 19:52             ` Ard Biesheuvel
2017-03-22 19:57             ` Sinan Kaya
2017-03-22 19:57               ` Sinan Kaya
2017-03-22 19:57               ` Sinan Kaya
     [not found]               ` <4ccb4d92-3830-3980-38c3-7085a3d97734-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2017-03-22 20:00                 ` Ard Biesheuvel
2017-03-22 20:00                   ` Ard Biesheuvel
2017-03-22 20:00                   ` Ard Biesheuvel
2017-05-03  3:09   ` Heyi Guo
2017-05-03  3:09     ` Heyi Guo
2017-05-03  3:09     ` Heyi Guo
2017-05-18 14:01     ` Bjorn Helgaas
2017-05-18 14:01       ` Bjorn Helgaas
2017-05-18 14:01       ` Bjorn Helgaas
     [not found]       ` <20170518140154.GA24324-1RhO1Y9PlrlHTL0Zs8A6p5iNqAH0jzoTYJqu5kTmcBRl57MIdRCFDg@public.gmane.org>
2017-05-20  8:19         ` Heyi Guo
2017-05-20  8:19           ` Heyi Guo
2017-05-20  8:19           ` Heyi Guo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170323143151.GA21544@red-moon \
    --to=lorenzo.pieralisi@arm.com \
    --cc=ard.biesheuvel@linaro.org \
    --cc=bhelgaas@google.com \
    --cc=hanjun.guo@linaro.org \
    --cc=heyi.guo@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=matt@codeblueprint.co.uk \
    --cc=pjones@redhat.com \
    --cc=yinghai@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.