From nobody Thu Oct 9 11:02:24 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E38A927703C; Tue, 17 Jun 2025 17:59:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750183161; cv=none; b=SIufsVD4LKMhFyxuZKgnImowMb1we10VtFwMz2jhp60jqrGL2Tg1sQ1caCBFH55sDZAGI1LcBwlktzcDH42ynnoH0OEL+8nUduj2qxKjPbR9ORZPhCvpVd1PhIOGYp3HKHuT+MoSwt/48V07dIjHX3ZqCn++NEKaN+aV2Q0oNms= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750183161; c=relaxed/simple; bh=guzSVFa4kwHai9EZMK8+P7TeBT5zm7vwCIz/+uGdD5o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d5gVOcIkLBnMAVe14zsR1/nXHy1wRoa4K1ZaGmM8S+VbTHzXudna+F30toXiac/M/y05JXrWgOPLVqJG3ZsU/Zyu0yZh0gH4mdx1q4G0rjbHNvXW8cKZ0Un01NKW0ThL/CZRpxGbRBKSDl5UTcHUqtyr0aVlvxXpL//bUs5Ng+4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SMAx7yhu; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SMAx7yhu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F19ADC4CEF2; Tue, 17 Jun 2025 17:59:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750183160; bh=guzSVFa4kwHai9EZMK8+P7TeBT5zm7vwCIz/+uGdD5o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SMAx7yhuA28BYQvwArliGoV3yuWcx5cJN5pyKXWKNMXwxMZiLy8mnBJhPKqheazTl WaTD1JZpn4HgNmXP6xrXDqTQ8T2aZOgVG/y15CbZVYG5PpMBdpGy4VocI20M+H8dO7 KFq5sMI7BkgJnwb2xyj8hKh5qAi1nGRLG5RpCouM6aJVvCZRUx2hymsiI9vO41Q8/N DpXuoO0qRis9A38gAAqG40bazMRa5RvuzO8dVGUelKGlwsZHcP+fF2aTkdt8hswZPo VXL0ibNhW+1WKJaqpnCxfk8E1JYsHUyWZ3zRgDMEQm43lQl80XCWfLGtaqUcvc9ZaU /BHuTK+gUkGnQ== From: Mario Limonciello To: Bjorn Helgaas Cc: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , David Airlie , Simona Vetter , Lukas Wunner , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Woodhouse , Lu Baolu , Joerg Roedel , Will Deacon , Robin Murphy , Alex Williamson , Jaroslav Kysela , Takashi Iwai , dri-devel@lists.freedesktop.org (open list:DRM DRIVERS), linux-kernel@vger.kernel.org (open list), iommu@lists.linux.dev (open list:INTEL IOMMU (VT-d)), linux-pci@vger.kernel.org (open list:PCI SUBSYSTEM), kvm@vger.kernel.org (open list:VFIO DRIVER), linux-sound@vger.kernel.org (open list:SOUND), Daniel Dadap , Mario Limonciello Subject: [PATCH v2 1/6] PCI: Add helper for checking if a PCI device is a display controller Date: Tue, 17 Jun 2025 12:59:05 -0500 Message-ID: <20250617175910.1640546-2-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250617175910.1640546-1-superm1@kernel.org> References: <20250617175910.1640546-1-superm1@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Mario Limonciello Several places in the kernel do class shifting to match whether a PCI device is display class. Introduce a helper for those places to use. Signed-off-by: Mario Limonciello --- include/linux/pci.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/linux/pci.h b/include/linux/pci.h index 05e68f35f3923..e77754e43c629 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -744,6 +744,21 @@ static inline bool pci_is_vga(struct pci_dev *pdev) return false; } =20 +/** + * pci_is_display - Check if a PCI device is a display controller + * @pdev: Pointer to the PCI device structure + * + * This function determines whether the given PCI device corresponds + * to a display controller. Display controllers are typically used + * for graphical output and are identified based on their class code. + * + * Return: true if the PCI device is a display controller, false otherwise. + */ +static inline bool pci_is_display(struct pci_dev *pdev) +{ + return (pdev->class >> 16) =3D=3D PCI_BASE_CLASS_DISPLAY; +} + #define for_each_pci_bridge(dev, bus) \ list_for_each_entry(dev, &bus->devices, bus_list) \ if (!pci_is_bridge(dev)) {} else --=20 2.43.0 From nobody Thu Oct 9 11:02:24 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 618B1278143; Tue, 17 Jun 2025 17:59:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750183163; cv=none; b=ihhLgMlSps33jZZEwIBQLSxgGQxhoaocmGgPj9PlgAvnTTq93AmchLnpf7hrWC5J4KX1qsFKKj3pmJ6//9x2XGHyvy85oNhG8kwwZPN1nvas1TYI1+mUIcdv8iWJ/BuaKSRxKyAhCCFDVZX2gQJNRUEbBVDeywOphxoHAIbENsQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750183163; c=relaxed/simple; bh=B2FqUgZDEIDRlLyoS0B3XrTjH48AtuNlz8x59tWs8Po=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R//iQ42RYRncF9zDi4bmUyWBATfxWXODPutzEDxOfM2R6R8AithkqPMRLvtUPwrlD7fnNMLOc0AcRTnFjud2HX8EVWP1m4dOO34ezIrfjtzXJCfunumMJlfsd2ezWIbyE3ovlpAiRQOniRhVScesDXihV6ifauEKSsXSoCE5/+c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bMnXfgCK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bMnXfgCK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B23ADC4CEE7; Tue, 17 Jun 2025 17:59:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750183163; bh=B2FqUgZDEIDRlLyoS0B3XrTjH48AtuNlz8x59tWs8Po=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bMnXfgCKWH7ZHJPyONokxGJ0RFN0/TbVOSyc/TMGOiOgz5VuUCzU65y7xACwEzMGi Ioy1oZBgygLGt4yhtjO77Da9Zwkd9mEfdIVSJu9hNhu4beHBcC/0VZFtuyZ9wUV7OX +F/q0gqEM8jJTZLnUsCYrPuD50ILPCRNt8D2NtEhD2rYemvdms1A2EjcIwr0p/l5US UNSPekpvY9VaSb8tSP2V7mUnxHAcD8m1QBUObGoNMLEdNgR0hV/Hxy6evno3gUIt8Z O7iofwWYsvsllYDU3wt/ZVOSANez/+k4kofEVBlKp95i0FBYrD8+rEQjL9TvGRxaAg /rVNldiLppkXg== From: Mario Limonciello To: Bjorn Helgaas Cc: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , David Airlie , Simona Vetter , Lukas Wunner , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Woodhouse , Lu Baolu , Joerg Roedel , Will Deacon , Robin Murphy , Alex Williamson , Jaroslav Kysela , Takashi Iwai , dri-devel@lists.freedesktop.org (open list:DRM DRIVERS), linux-kernel@vger.kernel.org (open list), iommu@lists.linux.dev (open list:INTEL IOMMU (VT-d)), linux-pci@vger.kernel.org (open list:PCI SUBSYSTEM), kvm@vger.kernel.org (open list:VFIO DRIVER), linux-sound@vger.kernel.org (open list:SOUND), Daniel Dadap , Mario Limonciello , Bjorn Helgaas Subject: [PATCH v2 2/6] vfio/pci: Use pci_is_display() Date: Tue, 17 Jun 2025 12:59:06 -0500 Message-ID: <20250617175910.1640546-3-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250617175910.1640546-1-superm1@kernel.org> References: <20250617175910.1640546-1-superm1@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Mario Limonciello The inline pci_is_display() helper does the same thing. Use it. Suggested-by: Bjorn Helgaas Signed-off-by: Mario Limonciello Acked-by: Alex Williamson --- drivers/vfio/pci/vfio_pci_igd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci_igd.c b/drivers/vfio/pci/vfio_pci_ig= d.c index ef490a4545f48..988b6919c2c31 100644 --- a/drivers/vfio/pci/vfio_pci_igd.c +++ b/drivers/vfio/pci/vfio_pci_igd.c @@ -437,8 +437,7 @@ static int vfio_pci_igd_cfg_init(struct vfio_pci_core_d= evice *vdev) =20 bool vfio_pci_is_intel_display(struct pci_dev *pdev) { - return (pdev->vendor =3D=3D PCI_VENDOR_ID_INTEL) && - ((pdev->class >> 16) =3D=3D PCI_BASE_CLASS_DISPLAY); + return (pdev->vendor =3D=3D PCI_VENDOR_ID_INTEL) && pci_is_display(pdev); } =20 int vfio_pci_igd_init(struct vfio_pci_core_device *vdev) --=20 2.43.0 From nobody Thu Oct 9 11:02:24 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D4A33278E60; Tue, 17 Jun 2025 17:59:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750183166; cv=none; b=TU5G9JL2XCQBpvv3Oo7INipO/MFS47krY3Lst59p34BarjHVpcUuo9x3BSbz/6gw2fI57rey+H+Z3cIG0OM2QraPm7gQWH9Yq/lIadn4tsY3IHNUfYHZ6qLhyW3c7+yh1ik/R6BZsSmNtMEwOAioaX2J46hOs6BauR1MbHZH7Zo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750183166; c=relaxed/simple; bh=M+G2okprc7+csSbyn38orLtA+o98910c7qxr3mrgQiw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ASU+b7bcre7vzD6JSOONH9msj6IDZLEwUxMDO6Yijvn8I77bJu5MxAbX5fYN8dd1mkIBYnX8qKVEdEQfoGr3yduTw9QnXWuRT+KDM0i/6SA6CFhd+j9NYdYLEOOhNlgyPxYi2TB5yuAfUOS5ahzkMwjs+3Ogu9i3M1XUjAURuS4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rl6veiUA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rl6veiUA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3850BC4CEE3; Tue, 17 Jun 2025 17:59:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750183165; bh=M+G2okprc7+csSbyn38orLtA+o98910c7qxr3mrgQiw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rl6veiUAib3xReD7XXP9/zLBFitwjhmyJXERFXpRFXnhu58yR13sVv7nZkHU153tJ iA9l1o37CB2gms2CnYwsP3Y0WUa86pgo00i4UlsVWAnTdV6CrPf8aCZWvLXhDX2qJO rUAiPjErGsVj7SBIB++oozmLZmUhMH0VfvvR76IOw1sfA/lCJ/nkUa8WyeJZykj/wT I3oTLAJK1/SACScCH1DbJINI4brngZ7/FdDGvrlWOPtzzdy1UpmJEAIW8zk6lz5ttQ lLrr8kFbteuoamIOyXkcK88md4djWrNKGRBCYDZWWqLYsLZG+FPCZXkveA8DEqxpXg uZK6uUeJguEnw== From: Mario Limonciello To: Bjorn Helgaas Cc: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , David Airlie , Simona Vetter , Lukas Wunner , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Woodhouse , Lu Baolu , Joerg Roedel , Will Deacon , Robin Murphy , Alex Williamson , Jaroslav Kysela , Takashi Iwai , dri-devel@lists.freedesktop.org (open list:DRM DRIVERS), linux-kernel@vger.kernel.org (open list), iommu@lists.linux.dev (open list:INTEL IOMMU (VT-d)), linux-pci@vger.kernel.org (open list:PCI SUBSYSTEM), kvm@vger.kernel.org (open list:VFIO DRIVER), linux-sound@vger.kernel.org (open list:SOUND), Daniel Dadap , Mario Limonciello , Bjorn Helgaas Subject: [PATCH v2 3/6] vga_switcheroo: Use pci_is_display() Date: Tue, 17 Jun 2025 12:59:07 -0500 Message-ID: <20250617175910.1640546-4-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250617175910.1640546-1-superm1@kernel.org> References: <20250617175910.1640546-1-superm1@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Mario Limonciello The inline pci_is_display() helper does the same thing. Use it. Suggested-by: Bjorn Helgaas Signed-off-by: Mario Limonciello --- drivers/gpu/vga/vga_switcheroo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switche= roo.c index 18f2c92beff8e..68e45a26e85f7 100644 --- a/drivers/gpu/vga/vga_switcheroo.c +++ b/drivers/gpu/vga/vga_switcheroo.c @@ -437,7 +437,7 @@ find_active_client(struct list_head *head) */ bool vga_switcheroo_client_probe_defer(struct pci_dev *pdev) { - if ((pdev->class >> 16) =3D=3D PCI_BASE_CLASS_DISPLAY) { + if (pci_is_display(pdev)) { /* * apple-gmux is needed on pre-retina MacBook Pro * to probe the panel if pdev is the inactive GPU. --=20 2.43.0 From nobody Thu Oct 9 11:02:24 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 563002797AB; Tue, 17 Jun 2025 17:59:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750183168; cv=none; b=O27xdMB/OJo4nh7aS7uip3U/4xQ6xiEmH/51gv4AmWvXXnDhVfzdv4xspIz7as/ZcTjlrtjzWCHGaIqaESYwor+9D4cliXbiLUL5vzNKhDkjoJ8AEFP6BdX2hkAf2d9Z/A5yMcCl+Khz+YG2ee3XtPxCX/gW9/+EWH8lgAJBJCc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750183168; c=relaxed/simple; bh=77/gxLtAPvAxa1AK1aJlDnuTAAm2yyps4mDMdQg/RYQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WeceGsZQKQAKCHUihSCkPkqkiS8FU8rw9WnNx+8zNeytORTiwZereztJt/oTf/d/6TyWmRQyA84jftzyqGOo3B8618S3EbXaN899pEVAqCE59F+a62VtvKU2deo6AtHGwjvQK8MgBAk+exhQUGHv9dgmbEGylqROa+sqTHJCpXY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Rl9eUy7n; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Rl9eUy7n" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0AA1C4CEF1; Tue, 17 Jun 2025 17:59:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750183168; bh=77/gxLtAPvAxa1AK1aJlDnuTAAm2yyps4mDMdQg/RYQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rl9eUy7nE0GLjzybBSBdoGe0tK6HHsbNwXjhbhSHdMi83sHIyJPrwQWCzIo4lXatr qcM7Wl9KAeFOVLCmjIOJq1LJQeyZm0DX3jx3kNGnU4PJtlM8BRvIp/qOpSd/naPSj/ 2z7XGSsGn0kTMcnJarNi6QMNJsMwvPvtwiUuGPjrwL4az4IybB1mTivJNfoA0W5XV0 FBpszsr7WNq/gfUM3VUdkPKbYCV8ojZ7X5K9XctDkTZdqaJR+D8xhXlsh9PlIbYjIO OW+TVbOeWPXGM+g3cE8BxXmlpUqa2o1A9ZLRX6ZnbipjdAvxtYM0wir9mH7O8LNDEJ fl4ko+kSitVhQ== From: Mario Limonciello To: Bjorn Helgaas Cc: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , David Airlie , Simona Vetter , Lukas Wunner , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Woodhouse , Lu Baolu , Joerg Roedel , Will Deacon , Robin Murphy , Alex Williamson , Jaroslav Kysela , Takashi Iwai , dri-devel@lists.freedesktop.org (open list:DRM DRIVERS), linux-kernel@vger.kernel.org (open list), iommu@lists.linux.dev (open list:INTEL IOMMU (VT-d)), linux-pci@vger.kernel.org (open list:PCI SUBSYSTEM), kvm@vger.kernel.org (open list:VFIO DRIVER), linux-sound@vger.kernel.org (open list:SOUND), Daniel Dadap , Mario Limonciello , Bjorn Helgaas Subject: [PATCH v2 4/6] iommu/vt-d: Use pci_is_display() Date: Tue, 17 Jun 2025 12:59:08 -0500 Message-ID: <20250617175910.1640546-5-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250617175910.1640546-1-superm1@kernel.org> References: <20250617175910.1640546-1-superm1@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Mario Limonciello The inline pci_is_display() helper does the same thing. Use it. Suggested-by: Bjorn Helgaas Signed-off-by: Mario Limonciello --- drivers/iommu/intel/iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 7aa3932251b2f..17267cd476ce7 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -34,7 +34,7 @@ #define ROOT_SIZE VTD_PAGE_SIZE #define CONTEXT_SIZE VTD_PAGE_SIZE =20 -#define IS_GFX_DEVICE(pdev) ((pdev->class >> 16) =3D=3D PCI_BASE_CLASS_DIS= PLAY) +#define IS_GFX_DEVICE(pdev) pci_is_display(pdev) #define IS_USB_DEVICE(pdev) ((pdev->class >> 8) =3D=3D PCI_CLASS_SERIAL_US= B) #define IS_ISA_DEVICE(pdev) ((pdev->class >> 8) =3D=3D PCI_CLASS_BRIDGE_IS= A) #define IS_AZALIA(pdev) ((pdev)->vendor =3D=3D 0x8086 && (pdev)->device = =3D=3D 0x3a3e) --=20 2.43.0 From nobody Thu Oct 9 11:02:24 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F26127991E; Tue, 17 Jun 2025 17:59:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750183170; cv=none; b=Uki/VVeKkrtg28+aXtx4+kVtJ03WbpfTxxRhnyPCrwHUVe/6l4n8GC7/gmlBIUqJzCrcoS1zhTjbTfngqkwB9fkslidfv0kzgZXY1mvdxXkrprcSueLP35RUbCZvssu04k/5rOivglwz0RySPm9HrITHbTUjsVcpRXEe9ZapN8Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750183170; c=relaxed/simple; bh=7UZGrblneAtFey369IMyzZF/udvRe/m3MafrVy9aQVg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rrmeJXejLGMrL1cM8KA0nY+iuySwHb0UCgR5ndSZEcIY3iKC/+migCGfL7plri3leq+h0CMIr7bSsgSTQcPVU6L6xs5Fi4OEOcQp1jGxiG4zn58hr3t46NgbwYEppr3X1keNsI8ezolPBtq0rUmj1SD0WwLIr8XLgn/sM015DMY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DJyEf2oc; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DJyEf2oc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33C51C4CEE7; Tue, 17 Jun 2025 17:59:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750183170; bh=7UZGrblneAtFey369IMyzZF/udvRe/m3MafrVy9aQVg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DJyEf2oc+Mu+ag8PcFekljMuzR1hwylZlTEtwPiy6tb3X4dNQgDD9Jf5EnwaLG8i5 9LwFWjBxWLi9ifSe9I+8Iz3wX7ICzMDfh2/hg1VrCzeH3XDlwkbtdMkOZkZ+yY9n5I 3Lq1mogn3jjDGe9Rd1I3oTDJkCehnVRyITTXDVLunW8gRCautJP1gOWjiB6BP8ZU+S y1iexDbE+ZSmmFjlZ4lS3aZPC90kxI2FpibS54PUi2/PnIGNqbxS4mJOxtCRsS4K9j WBb02/8p3FuGu05xLzsT4oZR1tTx+P0RcxnzGaC+F2CYDeFNQYyI4dNBD3eNjkwLR7 4q22JkK9np3CA== From: Mario Limonciello To: Bjorn Helgaas Cc: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , David Airlie , Simona Vetter , Lukas Wunner , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Woodhouse , Lu Baolu , Joerg Roedel , Will Deacon , Robin Murphy , Alex Williamson , Jaroslav Kysela , Takashi Iwai , dri-devel@lists.freedesktop.org (open list:DRM DRIVERS), linux-kernel@vger.kernel.org (open list), iommu@lists.linux.dev (open list:INTEL IOMMU (VT-d)), linux-pci@vger.kernel.org (open list:PCI SUBSYSTEM), kvm@vger.kernel.org (open list:VFIO DRIVER), linux-sound@vger.kernel.org (open list:SOUND), Daniel Dadap , Mario Limonciello , Bjorn Helgaas Subject: [PATCH v2 5/6] ALSA: hda: Use pci_is_display() Date: Tue, 17 Jun 2025 12:59:09 -0500 Message-ID: <20250617175910.1640546-6-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250617175910.1640546-1-superm1@kernel.org> References: <20250617175910.1640546-1-superm1@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Mario Limonciello The inline pci_is_display() helper does the same thing. Use it. Suggested-by: Bjorn Helgaas Signed-off-by: Mario Limonciello Reviewed-by: Simona Vetter --- sound/hda/hdac_i915.c | 2 +- sound/pci/hda/hda_intel.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/hda/hdac_i915.c b/sound/hda/hdac_i915.c index e9425213320ea..44438c799f957 100644 --- a/sound/hda/hdac_i915.c +++ b/sound/hda/hdac_i915.c @@ -155,7 +155,7 @@ static int i915_gfx_present(struct pci_dev *hdac_pci) =20 for_each_pci_dev(display_dev) { if (display_dev->vendor !=3D PCI_VENDOR_ID_INTEL || - (display_dev->class >> 16) !=3D PCI_BASE_CLASS_DISPLAY) + !pci_is_display(display_dev)) continue; =20 if (pci_match_id(denylist, display_dev)) diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index e5210ed48ddf1..a165c44b43940 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -1465,7 +1465,7 @@ static struct pci_dev *get_bound_vga(struct pci_dev *= pci) * the dGPU is the one who is involved in * vgaswitcheroo. */ - if (((p->class >> 16) =3D=3D PCI_BASE_CLASS_DISPLAY) && + if (pci_is_display(p) && (atpx_present() || apple_gmux_detect(NULL, NULL))) return p; pci_dev_put(p); @@ -1477,7 +1477,7 @@ static struct pci_dev *get_bound_vga(struct pci_dev *= pci) p =3D pci_get_domain_bus_and_slot(pci_domain_nr(pci->bus), pci->bus->number, 0); if (p) { - if ((p->class >> 16) =3D=3D PCI_BASE_CLASS_DISPLAY) + if (pci_is_display(p)) return p; pci_dev_put(p); } --=20 2.43.0 From nobody Thu Oct 9 11:02:24 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 55950277814; Tue, 17 Jun 2025 17:59:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750183173; cv=none; b=FIq61bvh28UEoV5GzExsCTnsANKCAwby0Zj+gNUFfrp0kCHcBM/3XsNf5rXBklIH6fKt5UiGX0UKJAlF79bYrZR5lsEcX3Sa5O5i+Q5ztNwfCSLMPpBEvWh34Hn8gyfp7gsePxwK9ImxfSwFlkC0SrBPoW3LL5B0+/gadtF2ccY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750183173; c=relaxed/simple; bh=7syN+VGWAq1nVYbtNhebxuTb7b5k+6al9zHWrp5oKB4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A2qEQLs67l0gTnl6VQcycgvERPSiSHy+mt3Rs5Zdm6hflGkAWEZY/etLma67pTvW9hYAwAU5jH7d1CpeuGK64vhhB7CaDK9UwNUy8+P7T+gCDqSLSKMB+kJDx3ETZ0AMlhkzXDmjJ+bmLl7Fvx9tHE0lAKWLP5mOoLJfD1PTAJU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UwHew9lW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UwHew9lW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC524C4CEF1; Tue, 17 Jun 2025 17:59:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750183172; bh=7syN+VGWAq1nVYbtNhebxuTb7b5k+6al9zHWrp5oKB4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UwHew9lWylxUDH4E7K0yq7jCjZRraVLumM+ZA1jiaOqySEHkDs1UdMIeO94w9HzIg YvlFjXEIEHIO0sd4309vR5tVaHCTHkFBZ/K21VTSeiJbWNdry+vBV/w7sKPNTIvVwh bzWVUTSxSLzn3d7Q+jTaz8W2Ix72tD3Xf/HVEVNRKp/rle8kjqxgl2DiLjhPMn4oMD EFg0gO9Bz3PP1DKCN8QE5rc5Uh7rTJiVtfeKRvfjV3d1LoDX34xLFuwRZ9CHZ4qZLR C3cAn1ZSTBaXOrGxe9ijkLM6omGEZWPwpJoWXkMTXLhroNpqq2bCMWFOvHsVxiuSe6 K1OUptgkmKoOA== From: Mario Limonciello To: Bjorn Helgaas Cc: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , David Airlie , Simona Vetter , Lukas Wunner , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Woodhouse , Lu Baolu , Joerg Roedel , Will Deacon , Robin Murphy , Alex Williamson , Jaroslav Kysela , Takashi Iwai , dri-devel@lists.freedesktop.org (open list:DRM DRIVERS), linux-kernel@vger.kernel.org (open list), iommu@lists.linux.dev (open list:INTEL IOMMU (VT-d)), linux-pci@vger.kernel.org (open list:PCI SUBSYSTEM), kvm@vger.kernel.org (open list:VFIO DRIVER), linux-sound@vger.kernel.org (open list:SOUND), Daniel Dadap , Mario Limonciello Subject: [PATCH v2 6/6] vgaarb: Look at all PCI display devices in VGA arbiter Date: Tue, 17 Jun 2025 12:59:10 -0500 Message-ID: <20250617175910.1640546-7-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250617175910.1640546-1-superm1@kernel.org> References: <20250617175910.1640546-1-superm1@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Mario Limonciello On a mobile system with an AMD integrated GPU + NVIDIA discrete GPU the AMD GPU is not being selected by some desktop environments for any rendering tasks. This is because neither GPU is being treated as "boot_vga" but that is what some environments use to select a GPU [1]. The VGA arbiter driver only looks at devices that report as PCI display VGA class devices. Neither GPU on the system is a PCI display VGA class device: c5:00.0 3D controller: NVIDIA Corporation Device 2db9 (rev a1) c6:00.0 Display controller: Advanced Micro Devices, Inc. [AMD/ATI] Device 1= 50e (rev d1) If the GPUs were looked at the vga_is_firmware_default() function actually does do a good job at recognizing the case from the device used for the firmware framebuffer. Modify the VGA arbiter code and matching sysfs file entries to examine all PCI display class devices. The existing logic stays the same. This will cause all GPUs to gain a `boot_vga` file, but the correct device (AMD GPU in this case) will now show `1` and the incorrect device shows `0`. Userspace then picks the right device as well. Link: https://github.com/robherring/libpciaccess/commit/b2838fb61c3542f1070= 14b285cbda097acae1e12 [1] Suggested-by: Daniel Dadap Acked-by: Thomas Zimmermann Signed-off-by: Mario Limonciello --- drivers/pci/pci-sysfs.c | 2 +- drivers/pci/vgaarb.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 268c69daa4d57..c314ee1b3f9ac 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -1707,7 +1707,7 @@ static umode_t pci_dev_attrs_are_visible(struct kobje= ct *kobj, struct device *dev =3D kobj_to_dev(kobj); struct pci_dev *pdev =3D to_pci_dev(dev); =20 - if (a =3D=3D &dev_attr_boot_vga.attr && pci_is_vga(pdev)) + if (a =3D=3D &dev_attr_boot_vga.attr && pci_is_display(pdev)) return a->mode; =20 return 0; diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c index 78748e8d2dbae..63216e5787d73 100644 --- a/drivers/pci/vgaarb.c +++ b/drivers/pci/vgaarb.c @@ -1499,8 +1499,8 @@ static int pci_notify(struct notifier_block *nb, unsi= gned long action, =20 vgaarb_dbg(dev, "%s\n", __func__); =20 - /* Only deal with VGA class devices */ - if (!pci_is_vga(pdev)) + /* Only deal with PCI display class devices */ + if (!pci_is_display(pdev)) return 0; =20 /* @@ -1546,12 +1546,12 @@ static int __init vga_arb_device_init(void) =20 bus_register_notifier(&pci_bus_type, &pci_notifier); =20 - /* Add all VGA class PCI devices by default */ + /* Add all PCI display class devices by default */ pdev =3D NULL; while ((pdev =3D pci_get_subsys(PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, pdev)) !=3D NULL) { - if (pci_is_vga(pdev)) + if (pci_is_display(pdev)) vga_arbiter_add_pci_device(pdev); } =20 --=20 2.43.0