From patchwork Tue Mar 21 19:16:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 9637409 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0EED96020B for ; Tue, 21 Mar 2017 19:17:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF00527165 for ; Tue, 21 Mar 2017 19:17:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E14712840E; Tue, 21 Mar 2017 19:17:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0070427165 for ; Tue, 21 Mar 2017 19:17:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=niybUNZ+hpz2LThpZcI1LimTIY436CSgUx5/ZqL6pXM=; b=q0D K+0RaOnPjQEmo10z6z8leuco3DAK8lIpW9nEEUFSIO6cWkUnHfrD1/jKaywWffR53L140N0vAYuvU v+zSuYMZMSxOaLz5rhxYW9lN/T1R5xbn1/8UYOcJfkGxJ1uWQBGQU/WwIQn780dseoz37hTmkJi4b uw2FWQyrDnAT/STIuM7yxLHpzKOS8C6Brb9w9jVXYXiNIVix/bo5yhEpZXyJoEtnpwamfSe2ZgCko jjKIl+h+FxLcnetmYmCGLmV5O04QdaVC+bZV6wAlInEzLC8DLSk4jDuTlzC+f7EWlf721dtL0TdnW eVYKGeIlcUrXzN046LlmKAGsPAFb66w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cqPHW-0006JC-JA; Tue, 21 Mar 2017 19:17:22 +0000 Received: from mail-wr0-x233.google.com ([2a00:1450:400c:c0c::233]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cqPHS-0006ID-2Z for linux-arm-kernel@lists.infradead.org; Tue, 21 Mar 2017 19:17:20 +0000 Received: by mail-wr0-x233.google.com with SMTP id u108so118032529wrb.3 for ; Tue, 21 Mar 2017 12:16:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=nEPkurv0NyPvqnkMeMhcrNy8s7tltNatgxF3JSgerE8=; b=JwlofGHCrOxRgKWeUhQvNFkfA6rtAKRtCk+gwOHkfMfIJ1x+Y91Cw4Up4OcdrExdAk kGCR2ITvyn85zbrKomPtAggGJ2sUIIboalko0fu2SsB8zbVrPITT0YrYbZiadPpnNyFM BY5he7M22L6mzHE/xjnE/sIqr3OzeeGRobRCY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=nEPkurv0NyPvqnkMeMhcrNy8s7tltNatgxF3JSgerE8=; b=lZXjWk5s45uLpyfbNIRFYlI7A2WDS4/2Q54r2ANz+g6N2WoRUTacLN5kwUxcD4h+EZ ABHgvzaQYJ3Rqpd4PgdmKt93z+f6sR4yD+ltWThG59QQlbkrdeXw1LwQiXtVJyk0ocGI RdjYbjwsYgFNvvIFGdhUBYY9Lp456pWobFwyPntYXJEKj6ycvh8X9ToSPJDN46yarkLQ 3LaN9RQRB1ydXZkxCf0DMCUtX6JwbCJ7vvatgNsR1yyWQU+mXfVfxWGf8QV7w7lV8kU9 YjX0wmpCNr/PyEOMLGiJDljPayvLW0TxyVHyt+aXFQHcrsfHiQSYS3NzvG1gCTgFbb7f kX1Q== X-Gm-Message-State: AFeK/H3LXq1ZrFk8Z9LOwa5750ZAXnHYUYjG+Ajmx6/WmZjYQdlxjGd9uVXa8cWRqLzX1qDp X-Received: by 10.223.131.3 with SMTP id 3mr32821306wrd.153.1490123816274; Tue, 21 Mar 2017 12:16:56 -0700 (PDT) Received: from localhost.localdomain ([105.144.191.163]) by smtp.gmail.com with ESMTPSA id j24sm20662938wrd.36.2017.03.21.12.16.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Mar 2017 12:16:55 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH v2] efifb: avoid reconfiguration of BAR that covers the framebuffer Date: Tue, 21 Mar 2017 19:16:50 +0000 Message-Id: <1490123810-12383-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170321_121718_416494_CE661FD4 X-CRM114-Status: GOOD ( 18.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lorenzo.pieralisi@arm.com, Ard Biesheuvel , matt@codeblueprint.co.uk, linux-pci@vger.kernel.org, heyi.guo@linaro.org, pjones@redhat.com, hanjun.guo@linaro.org, bhelgaas@google.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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