From patchwork Wed May 19 13:57:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai-Heng Feng X-Patchwork-Id: 12267403 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27229C433ED for ; Wed, 19 May 2021 13:57:40 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D9E1E6100C for ; Wed, 19 May 2021 13:57:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D9E1E6100C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=canonical.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 12C106EDC2; Wed, 19 May 2021 13:57:39 +0000 (UTC) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by gabe.freedesktop.org (Postfix) with ESMTPS id 91C0A6EDC2 for ; Wed, 19 May 2021 13:57:37 +0000 (UTC) Received: from 1-171-221-38.dynamic-ip.hinet.net ([1.171.221.38] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1ljMhX-0005vU-6q; Wed, 19 May 2021 13:57:31 +0000 From: Kai-Heng Feng To: airlied@linux.ie, daniel@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de Subject: [PATCH] vgaarb: Use ACPI HID name to find integrated GPU Date: Wed, 19 May 2021 21:57:23 +0800 Message-Id: <20210519135723.525997-1-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alexander.deucher@amd.com, Kai-Heng Feng , open list , "open list:DRM DRIVERS" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Commit 3d42f1ddc47a ("vgaarb: Keep adding VGA device in queue") assumes the first device is an integrated GPU. However, on AMD platforms an integrated GPU can have higher PCI device number than a discrete GPU. Integrated GPU on ACPI platform generally has _DOD and _DOS method, so use that as predicate to find integrated GPU. If the new strategy doesn't work, fallback to use the first device as boot VGA. Signed-off-by: Kai-Heng Feng Reviewed-by: Alex Deucher --- drivers/gpu/vga/vgaarb.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/vga/vgaarb.c b/drivers/gpu/vga/vgaarb.c index 5180c5687ee5..949fde433ea2 100644 --- a/drivers/gpu/vga/vgaarb.c +++ b/drivers/gpu/vga/vgaarb.c @@ -50,6 +50,7 @@ #include #include #include +#include #include @@ -1450,9 +1451,23 @@ static struct miscdevice vga_arb_device = { MISC_DYNAMIC_MINOR, "vga_arbiter", &vga_arb_device_fops }; +#if defined(CONFIG_ACPI) +static bool vga_arb_integrated_gpu(struct device *dev) +{ + struct acpi_device *adev = ACPI_COMPANION(dev); + + return adev && !strcmp(acpi_device_hid(adev), ACPI_VIDEO_HID); +} +#else +static bool vga_arb_integrated_gpu(struct device *dev) +{ + return false; +} +#endif + static void __init vga_arb_select_default_device(void) { - struct pci_dev *pdev; + struct pci_dev *pdev, *found = NULL; struct vga_device *vgadev; #if defined(CONFIG_X86) || defined(CONFIG_IA64) @@ -1505,20 +1520,26 @@ static void __init vga_arb_select_default_device(void) #endif if (!vga_default_device()) { - list_for_each_entry(vgadev, &vga_list, list) { + list_for_each_entry_reverse(vgadev, &vga_list, list) { struct device *dev = &vgadev->pdev->dev; u16 cmd; pdev = vgadev->pdev; pci_read_config_word(pdev, PCI_COMMAND, &cmd); if (cmd & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) { - vgaarb_info(dev, "setting as boot device (VGA legacy resources not available)\n"); - vga_set_default_device(pdev); - break; + found = pdev; + if (vga_arb_integrated_gpu(dev)) + break; } } } + if (found) { + vgaarb_info(&found->dev, "setting as boot device (VGA legacy resources not available)\n"); + vga_set_default_device(found); + return; + } + if (!vga_default_device()) { vgadev = list_first_entry_or_null(&vga_list, struct vga_device, list);