From nobody Wed Oct 8 22:16:22 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 540282D4B6D; Mon, 23 Jun 2025 18:48:10 +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=1750704490; cv=none; b=AAt/e33zqAUL0H6kStB31DeK1JxC7j1i4+OcNNokEVbEA4HKlQAwausl9Ew97akgENiokDC3xCYndzLzZQijqLL2AdeEm04Rrpgh6krlmmyK91oubLcGXHpQr6o8frpNjCeZkPBSjQqMqsHm7xWcVWJuC07mPi7HzWRm9VIDH8E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750704490; c=relaxed/simple; bh=dwUS0NNQBo6ioFvBv9MvL8ShjmESObZeByXZvWYMJKk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EGEDAxoCKixS+Bv42C/p6S8Gzr/qr/bK4c6oxO6WJZfQCBBOzn6mGtVz/z7fdODYgVGR/ofk05xmc63T4uJzi88mmyuX8OU1HwkeMXkEsD5HgcJqyPZ+rt9B91Nz013F+P1hlHvkUX6iVWZArIHPpAwVLOqLQk30YeiHFfYePqw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pylZT/OV; 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="pylZT/OV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3FA9C4CEF2; Mon, 23 Jun 2025 18:48:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750704490; bh=dwUS0NNQBo6ioFvBv9MvL8ShjmESObZeByXZvWYMJKk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pylZT/OVCLCi6RJn7QTBfnx2WAFKQzZk4Mcjc5wojbJBYRmkQ7IDDLkJvfjXNV2AQ mWtFTIAAw/8SywfhcVoT13CZIrqn7aUXT/Q6WCEZs0/EF+PAiTr5qQRnKi1CA0liM3 PpQ06PFg5g9FI6UWPs8tHkIsbY52vLzyqnSqIVSTRlQC3AE79OzijPFwKKkJfMsTNe RQ56Lwxbk6KUeSMrXW3CFOQZOfpifrDN+z8VCt/b52TjN1DsX7GGt9QtfJEkzl7lqr 2Nzeb64ztct0TpB80hGaBjGwXxu747gIWaKY/52gM8UkCE0y3tr7R1C21GkUgfBvB2 bMwM/R+xvzj8g== 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 , Simona Vetter Subject: [PATCH v4 1/8] PCI: Add helper for checking if a PCI device is a display controller Date: Mon, 23 Jun 2025 13:47:50 -0500 Message-ID: <20250623184757.3774786-2-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250623184757.3774786-1-superm1@kernel.org> References: <20250623184757.3774786-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. Reviewed-by: Daniel Dadap Reviewed-by: Simona Vetter 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 Wed Oct 8 22:16:22 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 037292D543A; Mon, 23 Jun 2025 18:48:12 +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=1750704493; cv=none; b=o6/RUtjFNRkGXVWvW6wVByHxStH5aH9qHrgdQ5JBYlc2WLy5/NGTdD8KsNfS+oq4FimwEUMyF9OHfG97JondRSWJ61Bks6BjpZbtHM9CCFH0+b4A6UGvDKoySP5H5us4pQ0r8POx9jLHY6Zjn6ODDgPGC3cna6TFBxFgq/bs4OA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750704493; c=relaxed/simple; bh=ZUEaBNdA8Lm5/HmaCro4bOIyTqXr2dVXogleY25ibLU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ds7PD106HTU9SwhxtTvVaI9mteEf3FO1giPqWW82EHF7PJzFP/O3ZB6WJi5Tuggq+/Y+lFgX5TEOxQsWzRf0isEY9FNRh0P3ucAWZVZgBSUHSQnTSNz0W4iiJER/n99rPgnfOnn3ox7WuDHaMKqLpikitOcJYITF79bjvmy1BhU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NuZPlIS3; 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="NuZPlIS3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34F64C4CEF1; Mon, 23 Jun 2025 18:48:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750704492; bh=ZUEaBNdA8Lm5/HmaCro4bOIyTqXr2dVXogleY25ibLU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NuZPlIS3+MqP3MIau7+yCJ42hgpmBbZDjjaBRBBdew65kV/nPrKd+Tp+u3ATVaIGU EIw1wIevqjbE3MWSCwrioq7iug7BrrDv6aTtmrx/OrgnseN68HYVEt9w+MnMRF/E/k XbIiPN/LRAS6GVB9Ufl90cENBryTWA4oG9t1f46eTLruk9JSqAX5tCmRM2vjcMUNHd I41Bugw57lQocjEAfcl99t9xPeyLfPyGcuq+lQkZA/JdtQPojquaccQpwu2TTQzMZU 8761P5eHA8Eun3hMxnCm46WVH0HDukNUKhbxZzSXeQvcmeAHP7FBGQ6enAhfcXC3Sj pX6mM1Zf4tENQ== 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 , Simona Vetter , Bjorn Helgaas Subject: [PATCH v4 2/8] vfio/pci: Use pci_is_display() Date: Mon, 23 Jun 2025 13:47:51 -0500 Message-ID: <20250623184757.3774786-3-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250623184757.3774786-1-superm1@kernel.org> References: <20250623184757.3774786-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. Acked-by: Alex Williamson Reviewed-by: Daniel Dadap Reviewed-by: Simona Vetter Suggested-by: Bjorn Helgaas Signed-off-by: Mario Limonciello --- 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 Wed Oct 8 22:16:22 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 816B42D543A; Mon, 23 Jun 2025 18:48:15 +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=1750704496; cv=none; b=Nn2ec3krCp3CQco1WSqRtXVHMosOdviM0PS75tbZvN26BfXpkXcS3jx/We8piEDPugL7bNLJXWoEhFgo2ObYsfx/6ACazHGl+weU+QfDWxz92GkOoYihKQyc4cBM5Z1KCt8azfu4ttXokwG+lLghG1hrOdMWG61cFG9qFoyrddY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750704496; c=relaxed/simple; bh=LQvOsrvAxtIF9zfBp3smdp/HiFPvr9jOTvuEZPP26Xw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jn2gvYLVtcLpzQRAKbfGPO8ZsEK0XtjR+6ACBf09rhdpGJngdiw9Ru8LxYXC9GioF4TobijNhISKwkzV2j9f50J4kd1MeIi3jUPZKBOybtrnL1XEDL8mP7fm+aBOMPYWno9q5jc+aFayUNc1wqPSlxSdHaABY8ZG4EUSsQ03Iyo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JS75Q9Mf; 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="JS75Q9Mf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BDAB4C4CEEA; Mon, 23 Jun 2025 18:48:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750704495; bh=LQvOsrvAxtIF9zfBp3smdp/HiFPvr9jOTvuEZPP26Xw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JS75Q9MfbQfoHA5DAb5JNukDtcuHrGxfcafNkpLiX14PNqg5XVuoHJ4DkyEmAOQsu 2CWHKd09v5vLoAQ4Ob2WS5Mg/FzhIbHYL5ZTKzERsRiB71XeEK+fqTRCWZMc+XwzbC L2OlSU2ilTw9s67vcEMuBqHZANl7uVIhx5iIL77IgkiXSmClDYu8gAU/U9UdQlZaWJ 55CkUA6zy4Q6bWmupa3bBt8xpTBzdlgvyTuzY7w0c3tDyE0t7ITjUNg/sxU9j2p26T 6XHEwDgKgsxlDSJtjRSqKNRYzEqyYiJYnyp0K8n6IYRt+mbXmiyzsXtB5VyMROFVLu XmlA8rK3OBGeg== 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 , Simona Vetter , Bjorn Helgaas Subject: [PATCH v4 3/8] vga_switcheroo: Use pci_is_display() Date: Mon, 23 Jun 2025 13:47:52 -0500 Message-ID: <20250623184757.3774786-4-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250623184757.3774786-1-superm1@kernel.org> References: <20250623184757.3774786-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. Reviewed-by: Daniel Dadap Reviewed-by: Simona Vetter 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 Wed Oct 8 22:16:22 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 005602D661D; Mon, 23 Jun 2025 18:48:17 +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=1750704498; cv=none; b=ObhoSQkQlDzUrDJ/z6BZVQdKhlNBDGix4+mRb6AZreuZ4rxYTWmOQPy62vx8+gAQx9n18n/xikPAkiIRoZ4YpQQL92cknv1vOBbjmUc38QDxmlIqA4ba3uwd/eauJ5biK88j2/kuPNprrTkdQZGy93g6i5H71M9Wtqa6Lzfd+NE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750704498; c=relaxed/simple; bh=Ih+h2iwqvMjgBNiHK36GhUh+ba0wYl7IY7LdJr3tFyA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GBkTt5NjNVAw1p9qkgC5A6/HkyIKE9SE/HrWNfErv4igzE2s8wdgcPjh5dgHJuzAUH3d4cXv6fQtCK+2E1G2eTztotcwb/47GgVe0K+cCZf+zJePsXJJq5SJ7llfHFp2Rii+GmpS/mXV77CrOr+2ibI4DPbOyPOA5N97s+AMtHA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ARRQtSP8; 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="ARRQtSP8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4EA65C4CEF2; Mon, 23 Jun 2025 18:48:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750704497; bh=Ih+h2iwqvMjgBNiHK36GhUh+ba0wYl7IY7LdJr3tFyA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ARRQtSP8ZSmE90wy6kFOBo+Bb3ljCUXPzdD7jCO7dJQ56QBkmsLhD0yw8K8o8cxPA b949RwyLjreR8NKA5csNISUkfGyTECdrZ01XZ4aA6gtIA4Ze5PVikx9RsYWNRCKVbE NaDBwPGULrN/4miaU/g/dk2SEuOzX3QMzFubKhqZxs3KsUk8Hdv/QUokQ4qYzphjTt mL2kuDgCBDvljcD4H7NZwUHYr6ooI2VgiCsZki+wi0bIPKU0X7h3iX/hWbV1VdLhbl V0gjNkupGP7bigP/XzweE4xc/ETrnVKxR0tKz7RwF2WpUIQfBvVgWaT9ZCRW0RYc52 qT7E2dxT1MGaQ== 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 , Simona Vetter , Bjorn Helgaas Subject: [PATCH v4 4/8] iommu/vt-d: Use pci_is_display() Date: Mon, 23 Jun 2025 13:47:53 -0500 Message-ID: <20250623184757.3774786-5-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250623184757.3774786-1-superm1@kernel.org> References: <20250623184757.3774786-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. Reviewed-by: Daniel Dadap Reviewed-by: Simona Vetter Suggested-by: Bjorn Helgaas Signed-off-by: Mario Limonciello Reviewed-by: Lu Baolu --- 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 Wed Oct 8 22:16:22 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 6E55F2D8777; Mon, 23 Jun 2025 18:48: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=1750704500; cv=none; b=IVBcmFsZ2Shje3ZBMT0mKNiC7z3Rsd/WD5qJKAVcfrdM+HIcmbmiPGFBEbOliZBCIeCsqkbywhZlIXhRYPYj6m1PA3I+XLloFZHM0d7fOpJxCIcJHsFl3X4uduF456hMkSCrIaSOyC/9cLpmfwztUscgUpXpKIH3wM7DYQC1uv8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750704500; c=relaxed/simple; bh=IOGKTg8m2lLVk2BGnUQp473zWXZ7OF1rNECuXqPIWig=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PBQGjTc26AIeloDtmldzorutsOkCL+cfAv2k7Ulhkxl6E5GZkPMMr8vAF3CuJHhiynhIo/pRcl9q+HuJN79CKQ+5/Jh5iFDEGC/JWYEQUsl1yq9AbBmDA09NDoSbQReyPBO2MxjOPYPF0eGKQj3nGIvx8V3EAX6pnr7CpPDqeFM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZjXThHPQ; 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="ZjXThHPQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8EA8C4CEF0; Mon, 23 Jun 2025 18:48:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750704500; bh=IOGKTg8m2lLVk2BGnUQp473zWXZ7OF1rNECuXqPIWig=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZjXThHPQiTiXi+zsrBvsZmX+0Sp9MtTaUTgOhkh+egnC/uoncNIoNTngQisfmGuXb UN6plahBmtfG0QAuIrolPo5YAxsJfN6ECO3chuFgrA6mm1pG/ull7kdkbcMAeDry9n VdneEWwMBdPwhV6teAb5DFTmEKt0eHb38H9pc1cKq52ge5VFpGkphe6m1Y0Whk4H+Q M2q/pDy3mmntYhJtChQG5jgDsXlheb8CataDwEB6rWEmfJN+plays4DY+ZvmiLeGdX ke9CTDjuMyHw3VrW4/EkVH/+7889RjmzQiuK7qUjznjYAipXQ6f7WG8DaRU/zz8tIo NEToyQTJDfNDg== 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 , Takashi Iwai , Simona Vetter , Bjorn Helgaas Subject: [PATCH v4 5/8] ALSA: hda: Use pci_is_display() Date: Mon, 23 Jun 2025 13:47:54 -0500 Message-ID: <20250623184757.3774786-6-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250623184757.3774786-1-superm1@kernel.org> References: <20250623184757.3774786-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. Reviewed-by: Takashi Iwai Reviewed-by: Daniel Dadap Reviewed-by: Simona Vetter Suggested-by: Bjorn Helgaas Signed-off-by: Mario Limonciello --- 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 439cf1bda6e66..75badb5c69b8e 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 Wed Oct 8 22:16:22 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 47A482D8DAE; Mon, 23 Jun 2025 18:48:22 +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=1750704503; cv=none; b=QPQS00WH0aDmz+DLyyX6Z9ZcxYa5NBMxdzbOcfdTcVRu6nhvMi5k+k0SKt/RdxECD2NrpiwpLj3jbqKWeb3Fm4ITnSRsTFgQi9TGsCgai/KUiVAb0ItBWtxewqrCya79IyfxVotHk6++xwqfNW0DYo7Ls84Fc9mrXpH7njA3+v0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750704503; c=relaxed/simple; bh=O8zZOJp1T/m8wGoflAg6DuuJRg/DFUwc5cbjqmgw5TE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Fwax90WHrg+CA1L8Kmo1/vlHyFy3XyFt5KH14mHGezlfnzEy0UbxMaW76uze4aQRvifhpA7MZpLPYnf+uYJC3D63MRsFhIfXxYSgtIXIreEu/FYq4MMStHjQc7T4z7ResZS1PUt5v4Ipx3M5eNewuRWT2STezbiqUAv+jro4Xok= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ik15Q7US; 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="ik15Q7US" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8546DC4CEEA; Mon, 23 Jun 2025 18:48:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750704502; bh=O8zZOJp1T/m8wGoflAg6DuuJRg/DFUwc5cbjqmgw5TE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ik15Q7USxVRhizymNRxiL/16DD3Nf1q78QUQ/59H9Y8XJPZzb4mGfb3Vy5iWmsNY1 q8aTS0eM4i0lF9pc48zpAuBnRnduy0swZdTPEU8Ye1KpMB1XT3KFpuxrLKv2Yu2H/B D4hz2sGMw8hUML88ymuVcUPT9BN1qMNXiuciRYR+/2rIG29/xFCaFQk+mCtyaUcY6H 6rPcvV2/ZDnbO2ojaX8/ukeiklTk+ZPOnBpYbxjsIwsDSmIOzmA147aRMmI6kIhJ5Q mBon7Qvr8vOSA6cpSQcG3WW9MpGqZ31DHpnTY6DYYww0hjWHzt1/kSwQp30Fv5fsbr hGbE/g9cL44pw== 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 , kernel test robot Subject: [PATCH v4 6/8] Fix access to video_is_primary_device() when compiled without CONFIG_VIDEO Date: Mon, 23 Jun 2025 13:47:55 -0500 Message-ID: <20250623184757.3774786-7-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250623184757.3774786-1-superm1@kernel.org> References: <20250623184757.3774786-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 When compiled without CONFIG_VIDEO the architecture specific implementations of video_is_primary_device() include prototypes and assume that video-common.c will be linked. Guard against this so that the fallback inline implementation that returns false will be used when compiled without CONFIG_VIDEO. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202506221312.49Fy1aNA-lkp@int= el.com/ Signed-off-by: Mario Limonciello --- v4: * new patch --- arch/parisc/include/asm/video.h | 2 +- arch/sparc/include/asm/video.h | 2 ++ arch/x86/include/asm/video.h | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/parisc/include/asm/video.h b/arch/parisc/include/asm/vide= o.h index c5dff3223194a..a9d50ebd6e769 100644 --- a/arch/parisc/include/asm/video.h +++ b/arch/parisc/include/asm/video.h @@ -6,7 +6,7 @@ =20 struct device; =20 -#if defined(CONFIG_STI_CORE) +#if defined(CONFIG_STI_CORE) && defined(CONFIG_VIDEO) bool video_is_primary_device(struct device *dev); #define video_is_primary_device video_is_primary_device #endif diff --git a/arch/sparc/include/asm/video.h b/arch/sparc/include/asm/video.h index a6f48f52db584..773717b6d4914 100644 --- a/arch/sparc/include/asm/video.h +++ b/arch/sparc/include/asm/video.h @@ -19,8 +19,10 @@ static inline pgprot_t pgprot_framebuffer(pgprot_t prot, #define pgprot_framebuffer pgprot_framebuffer #endif =20 +#ifdef CONFIG_VIDEO bool video_is_primary_device(struct device *dev); #define video_is_primary_device video_is_primary_device +#endif =20 static inline void fb_memcpy_fromio(void *to, const volatile void __iomem = *from, size_t n) { diff --git a/arch/x86/include/asm/video.h b/arch/x86/include/asm/video.h index 0950c9535fae9..08ec328203ef8 100644 --- a/arch/x86/include/asm/video.h +++ b/arch/x86/include/asm/video.h @@ -13,8 +13,10 @@ pgprot_t pgprot_framebuffer(pgprot_t prot, unsigned long offset); #define pgprot_framebuffer pgprot_framebuffer =20 +#ifdef CONFIG_VIDEO bool video_is_primary_device(struct device *dev); #define video_is_primary_device video_is_primary_device +#endif =20 #include =20 --=20 2.43.0 From nobody Wed Oct 8 22:16:22 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 991652D9ED2; Mon, 23 Jun 2025 18:48: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=1750704505; cv=none; b=uqqaNprzY3zfx6IcPSGw3VKbNIIVCS8CiPcOpBvo6vAaVZOlA0xJ5OxtAoKfqI3SRHzqkJJnpCmBnfmivGVH+JQSVoJtSTWB04uoJYLAymOVsMiiRtIhJdAyWbPUfXtfhVEFeY6pNBpebQA+2aHaTXayI2QHqsuX3/Nqpd8yDyA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750704505; c=relaxed/simple; bh=8DZ4LPdmiF/gLNoKEzQdv+iJ3v6IKz46G7ZkKiM2lpY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TbNX10pWbRt99/fSGud0PG8mBt6kTkMYK8JBA8oflX6P0/eN8KXl3PXtNeas9+kEvni9Q42Ej4YL7Traj3RgHLifkd3ci54EJ02BEi3Gr9QeBNhkb4dzmo7xTSr/lp1hLd0+B/dGXeHsIQEKStHKjLmPb/qvGbyIs4+YeLud9ww= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Rps3YcCN; 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="Rps3YcCN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0250DC4CEF1; Mon, 23 Jun 2025 18:48:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750704505; bh=8DZ4LPdmiF/gLNoKEzQdv+iJ3v6IKz46G7ZkKiM2lpY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rps3YcCNhFObZ+uHXTrt8NnX3veByCmkmSEK5DoJkCaNpVTQWSM0DWKw+J8bGl/D/ 7oCdDh5sVekIWe59LTqYsX7ofi5VL7bvrdErWtqpuctLBdHGDyt3l70ufAvIEh+Iav LXWd0IX4/SqGHz8LOWZxiVwMO6dGELCjRYAEXmc0mmSrMBiuLAGuPSiUVuJuFD4qcb b8q/1Su/ND2c37r9DG0Newzrxcgzmnfg4cf3/d2QRc2p+WoYBMKUsCYxjjrLve2G1M Kf8TUlE3sejrS5mvOOnhM3fTNJ19t44H7i21k3fdfcIETH6t3IYPVCTTu1FhbBw/Jh 8dY7X0pRaG9JA== 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 v4 7/8] PCI/VGA: Move check for firmware default out of VGA arbiter Date: Mon, 23 Jun 2025 13:47:56 -0500 Message-ID: <20250623184757.3774786-8-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250623184757.3774786-1-superm1@kernel.org> References: <20250623184757.3774786-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 x86 specific check for whether a framebuffer belongs to a device works for display devices as well as VGA devices. Callers to video_is_primary_device() can benefit from checking non-VGA display devices. Move the x86 specific check into x86 specific code, and adjust VGA arbiter to call that code as well. This allows fbcon to find the right PCI device on systems that don't have VGA devices. Suggested-by: Thomas Zimmermann Signed-off-by: Mario Limonciello --- v4: * use helper --- arch/x86/video/video-common.c | 13 ++++++++++++- drivers/pci/vgaarb.c | 36 ++--------------------------------- 2 files changed, 14 insertions(+), 35 deletions(-) diff --git a/arch/x86/video/video-common.c b/arch/x86/video/video-common.c index 81fc97a2a837a..917568e4d7fb1 100644 --- a/arch/x86/video/video-common.c +++ b/arch/x86/video/video-common.c @@ -9,6 +9,7 @@ =20 #include #include +#include #include =20 #include @@ -27,6 +28,7 @@ EXPORT_SYMBOL(pgprot_framebuffer); =20 bool video_is_primary_device(struct device *dev) { + struct screen_info *si =3D &screen_info; struct pci_dev *pdev; =20 if (!dev_is_pci(dev)) @@ -34,7 +36,16 @@ bool video_is_primary_device(struct device *dev) =20 pdev =3D to_pci_dev(dev); =20 - return (pdev =3D=3D vga_default_device()); + if (!pci_is_display(pdev)) + return false; + + if (pdev =3D=3D vga_default_device()) + return true; + + if (pdev =3D=3D screen_info_pci_dev(si)) + return true; + + return false; } EXPORT_SYMBOL(video_is_primary_device); =20 diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c index 78748e8d2dbae..15ab58c70b016 100644 --- a/drivers/pci/vgaarb.c +++ b/drivers/pci/vgaarb.c @@ -26,12 +26,12 @@ #include #include #include -#include #include #include #include #include #include +#include =20 static void vga_arbiter_notify_clients(void); =20 @@ -554,38 +554,6 @@ void vga_put(struct pci_dev *pdev, unsigned int rsrc) } EXPORT_SYMBOL(vga_put); =20 -static bool vga_is_firmware_default(struct pci_dev *pdev) -{ -#if defined(CONFIG_X86) - u64 base =3D screen_info.lfb_base; - u64 size =3D screen_info.lfb_size; - struct resource *r; - u64 limit; - - /* Select the device owning the boot framebuffer if there is one */ - - if (screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE) - base |=3D (u64)screen_info.ext_lfb_base << 32; - - limit =3D base + size; - - /* Does firmware framebuffer belong to us? */ - pci_dev_for_each_resource(pdev, r) { - if (resource_type(r) !=3D IORESOURCE_MEM) - continue; - - if (!r->start || !r->end) - continue; - - if (base < r->start || limit >=3D r->end) - continue; - - return true; - } -#endif - return false; -} - static bool vga_arb_integrated_gpu(struct device *dev) { #if defined(CONFIG_ACPI) @@ -623,7 +591,7 @@ static bool vga_is_boot_device(struct vga_device *vgade= v) if (boot_vga && boot_vga->is_firmware_default) return false; =20 - if (vga_is_firmware_default(pdev)) { + if (video_is_primary_device(&pdev->dev)) { vgadev->is_firmware_default =3D true; return true; } --=20 2.43.0 From nobody Wed Oct 8 22:16:22 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 9DA912DA753; Mon, 23 Jun 2025 18:48:27 +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=1750704507; cv=none; b=sUuYHmXuWyyDZC5Skx7NPBEoHibpSFXzHgIODYRik45rYutBYarAChMJDG1Sj2n/uICDabVKN9YPozXYonAOaxy0I7uyyoBfNG5sC++yIFGrZ96FTSPWufh8RQlJfiZsa/hR3HxJD9vwP1p+F2tUcRt4noHBH55Mp81IiIFxrow= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750704507; c=relaxed/simple; bh=g0M2DgNSBrZnHKAamPsJaiVPp+me19vm+3rXOtUbK/k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c4d/Zj7R85zM8lreUOECRQUGLNH8fE1G04p/SuNreqYqkqeafSfHzCWvhuYUCwvsoqq4XqZKj6Ay6DcSiipZ0ARPe2p2lpS+614gED0kk25TNKLrf+Ikdw2Nqfg+BPAUIjTnI8CPLzFOr8/ttjOxcDeJqxuUhmpe/Qfqc0JoXfM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FlkMMZKx; 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="FlkMMZKx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67266C4CEF2; Mon, 23 Jun 2025 18:48:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750704507; bh=g0M2DgNSBrZnHKAamPsJaiVPp+me19vm+3rXOtUbK/k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FlkMMZKxXH4xc4d/NdzCCYVUetE3wjUW1moJk+VXz2ScXAxwhw4X/eBTRPOEUiySb xpMzQsa5eZBih7XLT6A+uzq868tEhMg39SD3aOBE2tB91mCIeTvz47jq3DkqOonftl CnMa/QMh/IU4uJlRZhEKFUj4Q8XAOfQ83FBfEJadeNboHj/cZSbv6w0L89rcqiMT1D lBTSaQfCUP/Uq75Q1KyiENvNd166/Bx8SPFKoWsV4VOIvt6ARbV0keyauZrrPSYECw Dga5ESJrQILf4NHNBcXkHLYpJ6B8VrSDgL6l9ttNg5FJhtQ2/Pj5d/Jxk7tDR2UbWZ h3MyOb0LfkFJw== 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 v4 8/8] PCI: Add a new 'boot_display' attribute Date: Mon, 23 Jun 2025 13:47:57 -0500 Message-ID: <20250623184757.3774786-9-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250623184757.3774786-1-superm1@kernel.org> References: <20250623184757.3774786-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 systems with multiple GPUs there can be uncertainty which GPU is the primary one used to drive the display at bootup. In order to disambiguate this add a new sysfs attribute 'boot_display' that uses the output of video_is_primary_device() to populate whether a PCI device was used for driving the display. Signed-off-by: Mario Limonciello --- v4: * new patch --- Documentation/ABI/testing/sysfs-bus-pci | 9 +++++++++ drivers/pci/pci-sysfs.c | 14 ++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-pci b/Documentation/ABI/te= sting/sysfs-bus-pci index 69f952fffec72..2e6f85fbe2e2e 100644 --- a/Documentation/ABI/testing/sysfs-bus-pci +++ b/Documentation/ABI/testing/sysfs-bus-pci @@ -612,3 +612,12 @@ Description: =20 # ls doe_features 0001:01 0001:02 doe_discovery + +What: /sys/bus/pci/devices/.../boot_display +Date: October 2025 +Contact: Linux PCI developers +Description: + This file indicates whether the device was used as a boot + display. If the device was used as the boot display, the file + will contain "1". If the device is a display device but wasn't + used as a boot display, the file will contain "0". diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 268c69daa4d57..5bbf79b1b953d 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "pci.h" =20 #ifndef ARCH_PCI_DEV_GROUPS @@ -679,6 +680,13 @@ const struct attribute_group *pcibus_groups[] =3D { NULL, }; =20 +static ssize_t boot_display_show(struct device *dev, struct device_attribu= te *attr, + char *buf) +{ + return sysfs_emit(buf, "%u\n", video_is_primary_device(dev)); +} +static DEVICE_ATTR_RO(boot_display); + static ssize_t boot_vga_show(struct device *dev, struct device_attribute *= attr, char *buf) { @@ -1698,6 +1706,7 @@ late_initcall(pci_sysfs_init); =20 static struct attribute *pci_dev_dev_attrs[] =3D { &dev_attr_boot_vga.attr, + &dev_attr_boot_display.attr, NULL, }; =20 @@ -1710,6 +1719,11 @@ static umode_t pci_dev_attrs_are_visible(struct kobj= ect *kobj, if (a =3D=3D &dev_attr_boot_vga.attr && pci_is_vga(pdev)) return a->mode; =20 +#ifdef CONFIG_VIDEO + if (a =3D=3D &dev_attr_boot_display.attr && pci_is_display(pdev)) + return a->mode; +#endif + return 0; } =20 --=20 2.43.0