From mboxrd@z Thu Jan 1 00:00:00 1970 From: lorenzo.pieralisi@arm.com (Lorenzo Pieralisi) Date: Wed, 22 Mar 2017 11:35:00 +0000 Subject: [PATCH v2] efifb: avoid reconfiguration of BAR that covers the framebuffer In-Reply-To: <35F65528-FC1F-4813-A0C6-641CF864212A@linaro.org> References: <1490123810-12383-1-git-send-email-ard.biesheuvel@linaro.org> <20170322102939.GB3519@red-moon> <35F65528-FC1F-4813-A0C6-641CF864212A@linaro.org> Message-ID: <20170322113500.GA3940@red-moon> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org [+Yinghai] On Wed, Mar 22, 2017 at 11:08:48AM +0000, Ard Biesheuvel wrote: > > > On 22 Mar 2017, at 10:29, Lorenzo Pieralisi wrote: > > > >> On Tue, Mar 21, 2017 at 07:16:50PM +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. > >> > >> So add a quirk to the EFI fb driver to find the BAR associated with > >> the GOP base address, and set the IORESOURCE_PCI_FIXED attribute so > >> that the PCI core will leave it alone. > >> > >> Signed-off-by: Ard Biesheuvel > >> --- > >> As it turns out, setting the IORESOURCE_PCI_FIXED flag is not sufficient > >> to make the PCI core leave the BARs alone, so instead, the BAR resource > >> is claimed in the quirk handler. > >> > >> As suggested by Lorenzo, a check is added that the device has memory > >> decoding enabled, and if it doesn't, no attempt is made to use the > >> EFI framebuffer. > >> > >> drivers/video/fbdev/efifb.c | 58 +++++++++++++++++++- > >> 1 file changed, 57 insertions(+), 1 deletion(-) > >> > >> diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c > >> index 8c4dc1e1f94f..eeeaf78c4a5b 100644 > >> --- a/drivers/video/fbdev/efifb.c > >> +++ b/drivers/video/fbdev/efifb.c > >> @@ -10,6 +10,7 @@ > >> #include > >> #include > >> #include > >> +#include > >> #include > >> #include > >> #include