From patchwork Wed Jul 19 01:28:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Axtens X-Patchwork-Id: 9850235 X-Patchwork-Delegate: bhelgaas@google.com 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 78FD5601C8 for ; Wed, 19 Jul 2017 01:29:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69103285CD for ; Wed, 19 Jul 2017 01:29:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5DD3B285D4; Wed, 19 Jul 2017 01:29:29 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E31C9285CD for ; Wed, 19 Jul 2017 01:29:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752072AbdGSB3Z (ORCPT ); Tue, 18 Jul 2017 21:29:25 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:33616 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751906AbdGSB3Y (ORCPT ); Tue, 18 Jul 2017 21:29:24 -0400 Received: by mail-pg0-f68.google.com with SMTP id z1so4870690pgs.0 for ; Tue, 18 Jul 2017 18:29:24 -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=rSS2eipgv9pIXzYYfw3XVFzRsORq4uNuyG7CP1C5huE=; b=mQ7jRE86VrwmzkxBIv5BG0JLsk7BKsvfLlVv0f98g+qjDLML9OL4qVRrSeeoVFUh8t ICj17sLIGHHtyz//37CD9mLNagYowtHv31LEoSOnrbFXKp/4dljb8FGQgAcr2PEJYG7o 8a8uJAqsHLsOWtlh5fa+5MFe3u6HNo6mh62Bw= 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=rSS2eipgv9pIXzYYfw3XVFzRsORq4uNuyG7CP1C5huE=; b=g+a/dKmGjGmFFI7E9wlx0cgb/Ty7ugzr0tT3WyqCkzkmGUe1WNxdTLbVo+chhcUMUu u8bYEg4ZJBtHkgTukNoeMhai/lFcCMDXQ09Aqa5N1HrCYL4HUitfqfM+wOpXgVzdC1E0 q0Q+RX14fiY1tt19saW34pQqhbl0LQjI0Szi4cqK+om30xYwhSOVAoKwAa4MLpCjQUZb e/d4r5uerlRjm1C7Z9pg5gpc9GxI50vq3j+cLXmAv9jt5Ph7EaVPdY4UfesOyqTFEozk d1vybwJYdqycG+CEdEaPZI/MyplppKULMTmqpGct9CdtclF6fO2NOjJe+r8Rw+qVxu3H +oaw== X-Gm-Message-State: AIVw113RCFu7FSOfekdtLAnAVAhDPGyc0dI68WA4EA4F/CvKjZQUUCwK 8d502N5wPefi4nYZxuLkAQ== X-Received: by 10.84.170.67 with SMTP id i61mr518489plb.114.1500427764054; Tue, 18 Jul 2017 18:29:24 -0700 (PDT) Received: from localhost.localdomain (203-59-51-51.dyn.iinet.net.au. [203.59.51.51]) by smtp.gmail.com with ESMTPSA id n90sm7582401pfk.105.2017.07.18.18.29.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Jul 2017 18:29:23 -0700 (PDT) From: Daniel Axtens To: linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Cc: benh@kernel.crashing.org, z.liuxinliang@hisilicon.com, zourongrong@gmail.com, catalin.marinas@arm.com, will.deacon@arm.com, gabriele.paoloni@huawei.com, helgass@kernel.org, airlied@linux.ie, daniel.vetter@intel.com, alex.williamson@redhat.com, Daniel Axtens , Brian King Subject: [PATCH 1/4] powerpc: simplify and fix VGA default device behaviour Date: Wed, 19 Jul 2017 11:28:34 +1000 Message-Id: <20170719012839.20124-2-dja@axtens.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170719012839.20124-1-dja@axtens.net> References: <20170719012839.20124-1-dja@axtens.net> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.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. --- 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); }