Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1761086pxj; Wed, 19 May 2021 13:18:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyI5WoRXbxqF2bzzfQcnFuvU/xaKNtWAwpnCNs+LGTZJ1q0fGm8s/vbVSb4Ez4xbQxp9ErK X-Received: by 2002:a17:906:1e44:: with SMTP id i4mr902525ejj.61.1621455492800; Wed, 19 May 2021 13:18:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621455492; cv=none; d=google.com; s=arc-20160816; b=fDMVBG/PcZe+A0rjIk/JYhUXRAHFcCqhWOGhHZBCm93lHicxgyGuIQsHG63QXW/ERv uipqk/rrY+qGwGdTFedarQPlaLpjq2bdwfIpsp+CprUL4ZjWQuNTNzX+g8QJ1zMQqsv9 Kg1GLpo6QeDCy1XpYHsRP2s5GMIpEmABFLk62AenokazLyWMnXiQYrgSO6xQ80rh9Ja9 Uxh0KTBf2O4yFlEWo+DvLPOQdzxAWOKSpoh1XSxDxkI8kwiARzGRXuOtPFpxH6harytW 5U6EXsruTrpQ/Tdft4pkPfFsjTtrZhl030cf7BGjxOcN8vdjKgs3oTJzTK4jv3c0hQHm ZKXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=n3nslXd1oDD6z2dYKaP2twlQcbfdSGmidNT7OePlUG4=; b=qsOJP/O+JM73hFUHw5R06BS2KjBpHg4vn+hvz570z9VemxpFcm5nq7jg7iTwTy0WTA 5Tz8r5pVtaggpiFlPNCzMjwGLu+5QKo/rHm2idFk2kYbpAD8lyqYpy2V9HvLBGx00ODr V8rm/k83Y8elP+zXH+Gq66f9+tzant+SexNB8mcPYz+lD9i2MpdH3yVmxRVTMauYjnsB eKmap71x5MUXFWKP3fJ8IbyAPoacCkmwoK6MrvDx9bcXRovJCm+WDk2jtnLYZWxZjJn8 qc+bDTseSHv0jcf7CwyyO96kXi1xL0K6mQZhh/pBkD2sbboNFQAxJjZdRyqSwEEFSZRU Kk7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WGm4Ynaz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m21si384592ejo.633.2021.05.19.13.17.48; Wed, 19 May 2021 13:18:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WGm4Ynaz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355375AbhESQqx (ORCPT + 99 others); Wed, 19 May 2021 12:46:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355366AbhESQqu (ORCPT ); Wed, 19 May 2021 12:46:50 -0400 Received: from mail-oi1-x230.google.com (mail-oi1-x230.google.com [IPv6:2607:f8b0:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AF2DC06175F for ; Wed, 19 May 2021 09:45:30 -0700 (PDT) Received: by mail-oi1-x230.google.com with SMTP id j75so13653310oih.10 for ; Wed, 19 May 2021 09:45:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=n3nslXd1oDD6z2dYKaP2twlQcbfdSGmidNT7OePlUG4=; b=WGm4Ynazm/+VSRaGLZFfQ+wqW8Rr5++iJ695Ek/3bbhik4AClKj5GYpCdUh8UkiHHi eyjurn9ygPiTVsBIPtYAEWjkXkRLc73SeBT2Espv26XwdPbA6X11rm0OPKWcfuDh57zN geAdKtd+ALWfRAw+c6AXdfjJ5AK31jWb2ojc2d418c/jR42A6GmzS9dMbUUM8+Pqn2+C JXOnZeWGZVxzDa10iML0VnB3WvJZBQEi+4qbh+vG4LAent7mib0PQy3b/DPhrbQsXUy1 MlIrNYFTTxIuWUjJU6ztDcAXa0KI2hHvyY1U29jz+POWjz8FyWOIqhUyCgbITYX1YI3T VfHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=n3nslXd1oDD6z2dYKaP2twlQcbfdSGmidNT7OePlUG4=; b=heDH2TIArvl4FdGAKLLb7xXvSkaShcvm9YAhdQjgXQxW8EiXm4P64FwnwJdCLPJ0aD bdOz3Dtn3zIFajNF78//mJRoPr3kEWYuSLhfUtqCv0MWwlLz+hGvbCypZCJWNckd0H07 AZDsvWzDawF0CccCRGXOeXn20Wnbu4qRtoUtT9yNlyWelXsZQmyUdMdTTmwmrzUXMT4k Zo6+wXxMOuTTxfxAvNvQJLEWh+M9rHzn1PJDW5ZovbBIK0+pmC6GkkjH6wVD6GDM2s78 rE8hhLFlNPhw/bqR1YvAKR7ckFyv2MHFdWElOFkQm3ANszxsLJuEFokjJMxzDHc39cFC UPzw== X-Gm-Message-State: AOAM531Sr6H2cEgFf4/qhSUrvE5PVyqr7RAhUzAArGZk5aXyTazO7hZ2 YTKyprXUwNeT408whWoHDCTcYDYb0dpR5DLX0LM= X-Received: by 2002:aca:fc50:: with SMTP id a77mr27090oii.123.1621442729658; Wed, 19 May 2021 09:45:29 -0700 (PDT) MIME-Version: 1.0 References: <20210519135723.525997-1-kai.heng.feng@canonical.com> In-Reply-To: <20210519135723.525997-1-kai.heng.feng@canonical.com> From: Alex Deucher Date: Wed, 19 May 2021 12:45:18 -0400 Message-ID: Subject: Re: [PATCH] vgaarb: Use ACPI HID name to find integrated GPU To: Kai-Heng Feng Cc: Dave Airlie , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , "Deucher, Alexander" , open list , "open list:DRM DRIVERS" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 19, 2021 at 9:57 AM Kai-Heng Feng wrote: > > 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 Unless there are any other comments, I'll apply it tomorrow. Alex > --- > 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); > -- > 2.31.1 >