From patchwork Fri Aug 4 10:20:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Axtens X-Patchwork-Id: 9880943 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 496B1602B8 for ; Fri, 4 Aug 2017 10:25:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36C02289D0 for ; Fri, 4 Aug 2017 10:25:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 25D98289D2; Fri, 4 Aug 2017 10:25:31 +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,RCVD_IN_DNSWL_NONE autolearn=unavailable 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 B5419289CB for ; Fri, 4 Aug 2017 10:25:30 +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:References: In-Reply-To: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:List-Owner; bh=RrHCrt9dMnDL1K7/b42imTK4cBSRoRYM0vK2dpIS7Sg=; b=gFiMkL2drAwKYOmBn+Gi6oneSO QttJH/qzU1qWKYX7F+Q2efW7K81p4A0Qlntf586thgg7Lyarx6mb5QbR1lq4eVeo+u8eHY980Ivfo HdMACDvo8DYVEvmbsXchWRSY6BXHIBP6VB8mudUiBCA6NXqjXfWnkOpblUkoG11ZBFoHoSacXxH6+ brHE9M6z2owsQQfZewjLNYr95T9OossNT5L0rm6mPKqzzOHeTuXadv3nzoTjgrtU40nY2ZCGsNnJR /WwaeNBs+N31kk6G4D0TSNqkRh5Lw+1eu0AABJfM/Kqq1Os5RA4MTnYfkxavUI7aC672V9hqCVbdJ oPMnR2nA==; 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 1ddZnL-0008MJ-9X; Fri, 04 Aug 2017 10:25:27 +0000 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ddZjk-00069F-QP for linux-arm-kernel@lists.infradead.org; Fri, 04 Aug 2017 10:21:49 +0000 Received: by mail-wr0-x243.google.com with SMTP id 12so2691954wrb.4 for ; Fri, 04 Aug 2017 03:21:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axtens.net; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Scsd74WtFBJpi4iyYSxTjztxbXvT9tnVa+uNXrMItY8=; b=fNZl8CLjV6udUxC8TAo7er1TCwA/c0ZGMl6aQGyunLFIVP80tjPY99cFJW7RbahI6x FIGiqNACaopOK46loeo6vOwsMvPArRD7PDEIzqtbsE/TlnrUiFrdcmVt6806LSRkBv7P xPzTtglbk8WUc/nDvOSyr6bi7W4of84JWWDQU= 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:in-reply-to :references; bh=Scsd74WtFBJpi4iyYSxTjztxbXvT9tnVa+uNXrMItY8=; b=qonFj0f0pm2LrFwyD6J8enFDELtzgFTKhvOaBUeWXWZIbIkSiJ1twXTRFi9FGfFvDb XUiIfZUydOjjFMA0A0p3/O2+aKC/0eN8xJMzFaqsr9RadaFrbNEG8sC+ZFrow79IXuZ2 Q4yKw8fgvmUc2gyRtGvUmg911EyD5eCE3gpOXskb7BJi4JyU3qZmoEB87i2sssGVy2D7 0+wabj2JoS5tcj514An/aCe5BMULhoZjOD+KkaXf+zTyYh2oapwWv6HMIIizBYk1Vlxl Jq8L2bGLxMgbX4v2oe+uD5vC5O561Bf1uBe8U3XfJVyKGeYWRL7wzIlOxXnmhFqPPEa0 pOfw== X-Gm-Message-State: AIVw1127Fz0N5LXYIjv3zzKokfcll2+zp8cRbw9Gn6I0q9p3tMJ54UmR 8XKFF/TAjdWFmoOa X-Received: by 10.223.175.5 with SMTP id z5mr1217531wrc.11.1501842087950; Fri, 04 Aug 2017 03:21:27 -0700 (PDT) Received: from localhost.localdomain (uk.sesame.canonical.com. [91.189.88.154]) by smtp.gmail.com with ESMTPSA id g93sm4037467wrd.11.2017.08.04.03.21.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Aug 2017 03:21:27 -0700 (PDT) From: Daniel Axtens To: linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/3] powerpc: simplify and fix VGA default device behaviour Date: Fri, 4 Aug 2017 20:20:31 +1000 Message-Id: <20170804102033.27731-2-dja@axtens.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170804102033.27731-1-dja@axtens.net> References: <20170804102033.27731-1-dja@axtens.net> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170804_032145_449418_6AD32089 X-CRM114-Status: GOOD ( 15.75 ) 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: gabriele.paoloni@huawei.com, airlied@linux.ie, benh@kernel.crashing.org, Brian King , will.deacon@arm.com, z.liuxinliang@hisilicon.com, bhelgaas@google.com, alex.williamson@redhat.com, catalin.marinas@arm.com, zourongrong@gmail.com, daniel.vetter@intel.com, Daniel Axtens 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 Some powerpc devices provide a PCI display that isn't picked up by the VGA arbiter, presumably because it doesn't support the PCI legacy VGA ranges. Commit c2e1d84523ad ("powerpc: Set default VGA device") introduced an arch quirk to mark these devices as default to fix X autoconfig. The commit message stated that the patch: Ensures a default VGA is always set if a graphics adapter is present, even if firmware did not initialize it. If more than one graphics adapter is present, ensure the one initialized by firmware is set as the default VGA device. The patch used the following test to decide whether or not to mark a device as default: pci_read_config_word(pdev, PCI_COMMAND, &cmd); if ((cmd & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) || !vga_default_device()) vga_set_default_device(pdev); This doesn't seem like it works quite as intended. Because of the logical OR, the default device will be set in 2 cases: 1) if there is no default device OR 2) if this device has normal memory/IO decoding turned on This will work as intended if there is only one device, but if there are multiple devices, we may override the device the VGA arbiter picked. Instead, set a device as default if there is no default device AND this device decodes. This will not change behaviour on single-headed systems. Cc: Brian King Signed-off-by: Daniel Axtens --- Tested in TCG (the card provided by qemu doesn't automatically register with vgaarb, so the relevant code path has been tested) but I would appreciate any tests on real hardware. Informal benh ack: https://patchwork.kernel.org/patch/9850235/ --- arch/powerpc/kernel/pci-common.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 341a7469cab8..c95fdda3a2dc 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -1746,8 +1746,11 @@ static void fixup_vga(struct pci_dev *pdev) { u16 cmd; + if (vga_default_device()) + return; + pci_read_config_word(pdev, PCI_COMMAND, &cmd); - if ((cmd & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) || !vga_default_device()) + if (cmd & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) vga_set_default_device(pdev); }