From nobody Tue Oct 7 03:50:39 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 C9788277037; Mon, 14 Jul 2025 21:22:03 +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=1752528123; cv=none; b=RYr01LDrFS+JIEVgfALjpbPRzIJwlMDU/yEywD4qNt5pDBhfOR+6gG02HIzFRmdVJlP3HlkXPtj6AlCvptInqwZkzer+O7tludw9SyFWrK/BBOzCgA36ICS4j827r86RunUK+jIqJALUx5L7l30PNckU3zRb6k9fAK1ScMzZMLM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752528123; c=relaxed/simple; bh=cHj3h7hBxwKQAm75Z7A1SPHl3XQrv92gk4AeXACN+L4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=km31hA8sAZwGjHz+g7XaDXrgqa7G+dVsBwHpbLb8bb+y5rSIenCHpPuL7cNX/xTNKigEQ31jCm0bCTZN1/L948Z0AsMesXTnRDpSJblvUZVb3TxONKMmxoowaj2riHd6lkPv3RROTeVaRIiXHp6SglFDnnbHmu6q7mtoqVzHDT4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KYuexU9T; 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="KYuexU9T" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16789C4CEF8; Mon, 14 Jul 2025 21:22:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752528123; bh=cHj3h7hBxwKQAm75Z7A1SPHl3XQrv92gk4AeXACN+L4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KYuexU9Td6B5gShJK768qQbiuSChZZU2RTVK+UDwHjsx5HFa3ZNAZ9fhsxzkc3Xyz EjabZ1lo6KsETDjaBR0pi/pIxH8A3tqrLMfBaglQkG7Yb8SzkcATNsNhVjd1CHHBR1 5VxbbrcgIgarU9YS6nUyCT2NR0kr9QPRL9jrYGy2s2+s09ER4+0sFRjMuPU9Luykrg DmBErzHpGymCx+lfihO0NbL4AYl7C+jncR6bE81Dm3e/OAPqWF/PFuQNEVODwINvvW 46z8YrfI3dffe6yHI2EFnZz8hM8aXV5kJLnUOBgnCMHEmG2t6H94QHEWaCxCAOIsiV LP5pNSxywu1hA== From: Mario Limonciello To: David Airlie , Bjorn Helgaas Cc: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , 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 v8 1/9] PCI: Add helper for checking if a PCI device is a display controller Date: Mon, 14 Jul 2025 16:21:38 -0500 Message-ID: <20250714212147.2248039-2-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250714212147.2248039-1-superm1@kernel.org> References: <20250714212147.2248039-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. Acked-by: Bjorn Helgaas 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 Tue Oct 7 03:50:39 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 6ACD3242D67; Mon, 14 Jul 2025 21:22:06 +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=1752528126; cv=none; b=N89yvHd2/pg6gmgnv84hLMCpAENRVeD5jStQgPffTbVYPV+k7Tk4n9d7ctvkVHmloEw1iMiH7u5HGefzTwFHfTqQh4EbZCvwd8UZsUpt9UNcbKChJSEVdWQUzrwyc+zJqSvzVk02g0b1KmMjMcJ2Ok4wfImKdAwCGTzZrzwiZeA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752528126; c=relaxed/simple; bh=ZUEaBNdA8Lm5/HmaCro4bOIyTqXr2dVXogleY25ibLU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jozI0rlfVAYJVUwlF8ef4+w44ZdoVS+L6qFKKD+fHmkVW2zIfMGHPv1DbalH94xv5UZu1ijiPSAq6J74TC93hFgniX2uZAi6EjoR+o7jCRyrrzAvAfr70XFJljF0qlr7kN1gtl8CKOOmA456Y93GuperJKb4t/MXw8kL+ND+YEQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QxInUYNt; 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="QxInUYNt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94314C4CEF9; Mon, 14 Jul 2025 21:22:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752528125; bh=ZUEaBNdA8Lm5/HmaCro4bOIyTqXr2dVXogleY25ibLU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QxInUYNtOP3+leGGV3WIafPIhZhV4WyoQeb/CyFqCdXm0qfcS6DL0/2K46M/hs1wV ual0zSWlZH3rn9H8sLsFUYXKWlyI8PGTeEDPEeU7zKfKXc0UyMYJeeybup9QKrE0Jn p84jdP47vcHnp6Zsk254AEQmg4qST6nfzS0iL8lMUX2d3ZDNNXfzsqSj36ZM5qHuHz pusFXZRyXZd5qIsvUEtZkD0UqDpzqVYS/BKK6FLzZLpwd2mqdRNipGWycVyD+vnMvL rFLxc1zlvYrPhP6+/SiGeqaaafTTRhoFl9fh5SsYNC+UGjJ0i2DBanpg299+TkTUfx /h5LiFtDh8sqw== From: Mario Limonciello To: David Airlie , Bjorn Helgaas Cc: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , 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 v8 2/9] vfio/pci: Use pci_is_display() Date: Mon, 14 Jul 2025 16:21:39 -0500 Message-ID: <20250714212147.2248039-3-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250714212147.2248039-1-superm1@kernel.org> References: <20250714212147.2248039-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 Tue Oct 7 03:50:39 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 1826C279DC9; Mon, 14 Jul 2025 21:22:08 +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=1752528129; cv=none; b=OftDLTCgZFcJOtUCsxW76w5W963kRUGsqvfiq4DZUpHRVsgqRUNRfbCgeaQ2sQPDoHPJNhC/PzFWsjNvmJD8hJtniCZWf5Uyw/hHSrtO9SeXIKIU0WEUN8XexHQitPvfz4fu28+j6LD+7/GuMy4gftbd7+9wOqGZUeTKdOHs0tI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752528129; c=relaxed/simple; bh=LQvOsrvAxtIF9zfBp3smdp/HiFPvr9jOTvuEZPP26Xw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Nv+ylRI20CWnvDMAqTR4p5090h6fcm7slDax0QCZ5JMUjTCYLaDoUc1LML0CkCxpBYiqN+2Fk6mDa1NsDMcuY8oCS5saOS1zlvScAViJWpg29knOmy30DGs8t0MDw7gPT1BiExIQqrkPNF7l1hPUCl/3Ll4RmXbULHLdOZhUcBA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fFxrHXIh; 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="fFxrHXIh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3161BC4CEF7; Mon, 14 Jul 2025 21:22:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752528128; bh=LQvOsrvAxtIF9zfBp3smdp/HiFPvr9jOTvuEZPP26Xw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fFxrHXIhXWSit6zoSyP5HbSpqeoFQLvCY6cAcY8edNeGJnyL6TNwFLQm3cEOEtN8G PaEThGc3Az//xOsalkp8b53bZQvBWNKLXBxUlohyIpP654musJtOHlFeDCaPO3WVS1 px9EkL7Tkm9eUOdqHfF3P1q1WlYTOQNrlX3zM0C5Qrd9v7XJKYL9sMYn7DIcVs3jGj hL1sV7eaOcT5Ufm4+fRrMMnq+qvdV4rOYqJLiiyWYLDpsbolLzEJ6Vy59PaZ0s1xUY CEITadHSMSTyjEqApmSezfDYDZLuOJcIdeWr50Rsk4ALuCqoGpaAA/fOOPEnpZdrAy ItNJ3JnaxeMeg== From: Mario Limonciello To: David Airlie , Bjorn Helgaas Cc: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , 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 v8 3/9] vga_switcheroo: Use pci_is_display() Date: Mon, 14 Jul 2025 16:21:40 -0500 Message-ID: <20250714212147.2248039-4-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250714212147.2248039-1-superm1@kernel.org> References: <20250714212147.2248039-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 Tue Oct 7 03:50:39 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 985DE27F18F; Mon, 14 Jul 2025 21:22:11 +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=1752528131; cv=none; b=oWLnKmr8IEmsAgo30Z874VqORPEdmxat+VHb/xXi4z/zQhq2QKfj8wVlg/qRuPv32rf4xKwT8L5nmp+q+oqv/crusUNK7tWPWU7w49XVy3D6Xmu6KyY/pV2/yJZXifgm5S87ia191D7sJDaAovuUb9aNxTpQMIBMKV3ccFrRobE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752528131; c=relaxed/simple; bh=wZDfgswU2/pwcpS3H3uILO4jDTDnQH15cewPVoii5Es=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QR8ROKKoWNLlRkR0Gw/Ci0wi/B6RGkPAx8KSIG+A0yime65cGzw7htvQ7u4hON5fomw+CDxFpbJov0MM5zjLXXSaUdRwoS45Wo7M+BTThTyms6uidgwnt4Lrc246w9sg+OIzh5rbtl9BgUrZsRbMRqCH4PZ4/4/VNPUTzMQNHRY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LLuzYvcj; 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="LLuzYvcj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6CAFC4CEF0; Mon, 14 Jul 2025 21:22:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752528131; bh=wZDfgswU2/pwcpS3H3uILO4jDTDnQH15cewPVoii5Es=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LLuzYvcjG1bWqK2FxVDyS7x6p59I3loyCe4uOPnY9U47CAaEThr1YdegxP/ldkp7A RBAe0rxuWdIBzbthzUDS7oWsQDo0q/ghG15/dQmFyovSOfmH6BLaqYPnXY2WP4CZ4S 5DzWJDZ0aEX0bu8COxbzLKms0EgZIb4FH2TnaphH6hLUnWDzRrtKFhE72E32ORHuG2 qRi6G/E250/z0MbjuMYiImSdJDvKY91jcqNSb8h03VJ4103K+UTy5SL6/WcxQUobGN DkNf5uXoyWuCzcY0rbKIDG8sYo0kgNiukFwFfh/DOk3ZrjOuc003E58jceBJj2AMwa FTWvLHqqj/M9Q== From: Mario Limonciello To: David Airlie , Bjorn Helgaas Cc: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , 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 v8 4/9] iommu/vt-d: Use pci_is_display() Date: Mon, 14 Jul 2025 16:21:41 -0500 Message-ID: <20250714212147.2248039-5-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250714212147.2248039-1-superm1@kernel.org> References: <20250714212147.2248039-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: Lu Baolu Reviewed-by: Daniel Dadap Reviewed-by: Simona Vetter 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 148b944143b81..cad9ed1016cfc 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 Tue Oct 7 03:50:39 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 57855283FF7; Mon, 14 Jul 2025 21:22:13 +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=1752528134; cv=none; b=WUMe/wWXgBQmIk2pDEPjg8wpnB32z3f35Xp+s0+VyblOsTJ7+Fims3fJaXu+NzNvZaNRrhzhCjpLHVseQ9M2ZOj2oEHU8WGd22m6FcRQMH50AkL94kp5zWCeMRAS8BmoO/fMVEA0CeNGpOypPMwMVvvWb4Kci2UStm9EoNQnrkk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752528134; c=relaxed/simple; bh=IOGKTg8m2lLVk2BGnUQp473zWXZ7OF1rNECuXqPIWig=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BAAkUm85LjUgJudhRJq0O5fjBGQcUdP/1YH9ANapmP3bvLo//dKCEqqa1Rbz7QqfEJhivjhxMb+vHQxsAtT5x8F2/nxoCORlSmJ0OZBoVh1+yTQ8nZztHpx+zw/imlVWZ6LauZ2OnHODNln5/8RNbcIMci+p3MqS7dCIZSjixpM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gy2qXNG+; 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="gy2qXNG+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C88CC4CEED; Mon, 14 Jul 2025 21:22:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752528133; bh=IOGKTg8m2lLVk2BGnUQp473zWXZ7OF1rNECuXqPIWig=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gy2qXNG+WX9619YErVTK34n6+SwFCzSxIL/vfVLF7ZifTynwnIAXwEsAjcEmAqUWg PHbBlZs6sC0XX6H2O+66EGjs+jBEQsFXvTNtTBY6dSamkxbXlB+gqHXPod7cUIpQn7 zRU328hOdf+0z7dRfUCehI1iIEi/fH0Y49JAhXAfop0bZwSQsnHtBC9p+QW70bsjAq utSnwnNxTVxh7ifP4vy1mjsegdPVtOIkv/CXb2Cx/NcREGPf9IINq61textVOzvEyO FJegHUhNYrziF7NOUzv6Lv4b9Ii4JZkGKmp7vFzFmBOlCxpFprq39dIpIZ6DN+F2dC JIckicffgz7tA== From: Mario Limonciello To: David Airlie , Bjorn Helgaas Cc: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , 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 v8 5/9] ALSA: hda: Use pci_is_display() Date: Mon, 14 Jul 2025 16:21:42 -0500 Message-ID: <20250714212147.2248039-6-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250714212147.2248039-1-superm1@kernel.org> References: <20250714212147.2248039-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 Tue Oct 7 03:50:39 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 D7E5F285C96; Mon, 14 Jul 2025 21:22:16 +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=1752528137; cv=none; b=Y+8kVNiiRHjl35a7wBz66eI8j7Ux0kUHoKgI9RsRdUvURF69xcuSh3E65Af8kVaSbuj+mZWHX2t7sNDnHHW2S0v/29b0SfZdbniZHz+hL9pLM9KjfO3H0S+V05Zo+0X0V/tQLmvl6IRtNJHX8iJe5oYy85yoCJpS5LjFxj4WCtE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752528137; c=relaxed/simple; bh=glRBi2ARDp3d+Stsv79iYRajcXAB16Ljdcta010d3iw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CodT6bR+2mgnvj3I/Q7/hS4+Lg8gk5xLBR+fGnj8wFCb+6ABcW9K8MZRWj4oU9p2O3YVk/cFzRhtIoCFcrPqGKfIpNH6ym88YneZUrrt6a/Yncv1Mao7LTSDKZla3CfC++xLUp0ILCHqVAjWIBG0dbXhj014ISl/W72V2xPQXkc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jDlD09Q1; 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="jDlD09Q1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D6C0C4CEF6; Mon, 14 Jul 2025 21:22:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752528136; bh=glRBi2ARDp3d+Stsv79iYRajcXAB16Ljdcta010d3iw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jDlD09Q1Bajsz4OelYaq682tFqXjnkQTUFJ34AwjC3CGfRzd8jJDJJtLKs5vB2GFa Dxmb7g84wBJYTyelhdXUA0SbjrC0YnH14jtaTbjoJq3OuNjE5IMOBCxovflT0Xlcto X3XZ0HawdGE9exnfyUVicKh4y3kJj5zSCQY4XSQIwbAVeRNETKwPfjcjiVI2YBiNBO VFnNKMM6esQwvxmok4aVgefmha+tIcXvkxVFnFb7qfxBV3O/cQ3bEM+ClCSPgjo0H3 kmsd6oBYer/SEfTPuI5ogxihRGwIuCG8JN0r1Yx/VB2YaPx8/weEfJZT5jBj65PiQo R3526j+upLKxg== From: Mario Limonciello To: David Airlie , Bjorn Helgaas Cc: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , 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 v8 6/9] Fix access to video_is_primary_device() when compiled without CONFIG_VIDEO Date: Mon, 14 Jul 2025 16:21:43 -0500 Message-ID: <20250714212147.2248039-7-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250714212147.2248039-1-superm1@kernel.org> References: <20250714212147.2248039-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. Acked-by: Thomas Zimmermann Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202506221312.49Fy1aNA-lkp@int= el.com/ Signed-off-by: Mario Limonciello --- v5: * add tag 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 Tue Oct 7 03:50:39 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 E4231287502; Mon, 14 Jul 2025 21:22:18 +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=1752528139; cv=none; b=t8IULMKBH9owrfcxLBuIR5QivjRDOOsxBYX6T94sdzEzekx3addl9vMQoVorqt/Zl4Qs/Aj5XNCNpTve3ruuAofvQEUKT6u1MlGTVwLESVpavX3IpjLz9k9MlSMHq6PpiA8GR+y+aA6N0EijqYJ+rVsYjyZM1mnFcK1QzkIsSPI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752528139; c=relaxed/simple; bh=hely8rCeQBZS770H5X6E0gNUH0kghs8qNa/SePVXMhs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZD1WC58RGOKtmD4f+sk6HTHfYMOvmrO0h+j87aLy9S2Uth2R/C4kyGqIF5ImOn1ml8v79T4QC2cYmEgQlwbNB6SO4/vf8sMqOjtqzZoE68E53dipWWrlPKrG+Vx+LkOm+IrfBiTFTPpIOXVCiWYh58XWSziN2LcWUO7fBbfXTWI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bK1qtt3S; 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="bK1qtt3S" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A15A7C4CEED; Mon, 14 Jul 2025 21:22:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752528138; bh=hely8rCeQBZS770H5X6E0gNUH0kghs8qNa/SePVXMhs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bK1qtt3S3B9DqhtoxgdwRnROw8gB73afSe9f+vjMN27gxPjtfn9l3b0ckWLQJyPtv YIMrsOrqOCW1I0Rmr7jombvoe/S3S+uwd82lcKLCRi4ZbqTJFTB3NHCELxIZCS4n/k qlfwnC1/3zJEMNAQxoE/EQkcpHSFAfPDCJfDWhLnQBHmyGc2cpXBYq5aHglHJ5a5B9 r8IWZMtbVI5K1D9clvR+oI5sEDUX7YUIQi06tUsnk1JUGghkn0T6kj1Py69JHp/OGW vMOAyOn4KZNQjdjtPewKM5WyordJnCrxyPj5Uw9dbdfKzi3aGF2xzZPdFL0W66xXEH IYXXbqC39eM3A== From: Mario Limonciello To: David Airlie , Bjorn Helgaas Cc: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , 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 v8 7/9] PCI/VGA: Replace vga_is_firmware_default() with a screen info check Date: Mon, 14 Jul 2025 16:21:44 -0500 Message-ID: <20250714212147.2248039-8-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250714212147.2248039-1-superm1@kernel.org> References: <20250714212147.2248039-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 vga_is_firmware_default() checks firmware resources to find the owner framebuffer resources to find the firmware PCI device. This is an open coded implementation of screen_info_pci_dev(). Switch to using screen_info_pci_dev() instead. Acked-by: Bjorn Helgaas Suggested-by: Thomas Zimmermann Signed-off-by: Mario Limonciello --- v6: * fix lkp robot error v5: * split from next patch --- drivers/pci/vgaarb.c | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c index 78748e8d2dbae..b58f94ee48916 100644 --- a/drivers/pci/vgaarb.c +++ b/drivers/pci/vgaarb.c @@ -556,34 +556,13 @@ 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; +#ifdef CONFIG_SCREEN_INFO + struct screen_info *si =3D &screen_info; =20 - /* 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 pdev =3D=3D screen_info_pci_dev(si); +#else return false; +#endif } =20 static bool vga_arb_integrated_gpu(struct device *dev) --=20 2.43.0 From nobody Tue Oct 7 03:50:39 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 603A6276058; Mon, 14 Jul 2025 21:22:21 +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=1752528141; cv=none; b=FvsPDvXoWpLNBPsGeBdpGd9gDUn/lOpiY/QVUHY+wChMf338gAsIphLBFjgpqr5A6A1b/ydoLlzjvEoptRWEjWOWJ4/AI3zfBLneRPpw8g8RtTGtBvDu3/dokuL8rY7e2PMh3Lx8vK679g552jc/oha/7bKQOGiPl0YLY0M5kgs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752528141; c=relaxed/simple; bh=qH+nP7l6aO/IuqqbAQWnlb+L+ux6ugVAwetscoen+88=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G36V+oS1HTW1Z3ixPpZS8jDdCtLbrkyrqdquBjTBjtsGkbuBZV4DrczpePIPraB54O7pk2Dxt8OB6Ct6oIuGFvdZgJ337IBrC2plwNovPwC5x5IMs7Q5i2e8kUqOa5rB3gceFuGNQyniFubmX2tHx/5oGZRnxaqSXjwlXduj5wc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IvZs3O44; 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="IvZs3O44" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 135E8C4CEF6; Mon, 14 Jul 2025 21:22:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752528141; bh=qH+nP7l6aO/IuqqbAQWnlb+L+ux6ugVAwetscoen+88=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IvZs3O44p7tmoIZb3GY57LVIsVIBKAI4pBVbYywJ/+QIuBtDhGRmvlAU1KRtuZIOS RvcR3dN21vYvxsi8I60Jx76yVakJsvYSm5UmVEgjVU5d0zia0Vby3Lzzyhi01HlCYF pnvJU9RM9H5FHyhsSvhKijPD5n/twfH7FegQAh2B/BVjI0hCteMoq5V/lWTYrrV1pQ qmT8InPp6HSWfkMCXjIopbDaWMYzyeAXqj1+eYGQXYFjpQx7IHNlQ9hu7mfOTFNjrY 0nqOYUbph1gBRxdf9Kf9VgqYIGab2lN9CDoHUPInw8Vz5etkLdzj3A4GgIl6G3NbpP RKPG+7FSf71PQ== From: Mario Limonciello To: David Airlie , Bjorn Helgaas Cc: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , 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 v8 8/9] fbcon: Use screen info to find primary device Date: Mon, 14 Jul 2025 16:21:45 -0500 Message-ID: <20250714212147.2248039-9-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250714212147.2248039-1-superm1@kernel.org> References: <20250714212147.2248039-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 non VGA GPUs fbcon can't find the primary GPU because video_is_primary_device() only checks the VGA arbiter. Add a screen info check to video_is_primary_device() so that callers can get accurate data on such systems. Reviewed-by: Thomas Zimmermann Suggested-by: Thomas Zimmermann Signed-off-by: Mario Limonciello --- v8: * add guards for the non CONFIG_SCREEN_INFO case v5: * Only change video-common.c v4: * use helper --- arch/x86/video/video-common.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/arch/x86/video/video-common.c b/arch/x86/video/video-common.c index 81fc97a2a837a..4bbfffec4b640 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,9 @@ EXPORT_SYMBOL(pgprot_framebuffer); =20 bool video_is_primary_device(struct device *dev) { +#ifdef CONFIG_SCREEN_INFO + struct screen_info *si =3D &screen_info; +#endif struct pci_dev *pdev; =20 if (!dev_is_pci(dev)) @@ -34,7 +38,18 @@ 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; + +#ifdef CONFIG_SCREEN_INFO + if (pdev =3D=3D screen_info_pci_dev(si)) + return true; +#endif + + return false; } EXPORT_SYMBOL(video_is_primary_device); =20 --=20 2.43.0 From nobody Tue Oct 7 03:50:39 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 CDCF9288CB5; Mon, 14 Jul 2025 21:22: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=1752528143; cv=none; b=YSEVT8r8+JMaVyah6SE3x6hYipRNQFaFm4NvKSWP+5wv74LpQfAjijsH6v0KLEhiJGXfbVWHUOMlh7aJa1gwsNdlyhNbNEOGo/w03/1q5JviZk2PHjCE+2XJmM5+M16CuhYKtY4xsQLl8JIDnE4ClWro1vYYuIh+0sxAyMHRth4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752528143; c=relaxed/simple; bh=mA7SFMfHy8OinIxgtmu9yWbldbYt6k6q8NSeQegNnJA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OCSYecmlY8HzZxLqc4HQvwsIbgm9JmJgohj6c4s55AIhhEgXzowTahaUE6tYtzx5qdlD7VylCHrdhAk//UU5yjNrQ30UZd1SvONsueHynK6RnGL7xhpIs3TeJ+RAIAaQ0aAhOcZBHr6KknEhW6j/VwZ03QQM+ecRMfcLIK+qORY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Q60MisbD; 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="Q60MisbD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7EECFC4CEF8; Mon, 14 Jul 2025 21:22:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752528143; bh=mA7SFMfHy8OinIxgtmu9yWbldbYt6k6q8NSeQegNnJA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q60MisbD95FOBih0G/23vPpGal83ekgZ28SJ47/I5DIL4UoRV88m/T9aZ8dmOHcei 35usRcp9gpNMuI7D6ihW86QYi+XVSRPRYGdyxIwCtDFiQpKqHpKgltuHzKQ0uRoSmE z1l4hyF1P2U/5OXyyfn84zPyOOT3cNGZTvkejh/bj1N2eLoiXaqDMPeKw9OJTsoIh+ Q8XuewUUT+SMBoeZZadI6UXPxPFzh1BYd6Ey1YZoRM5BfoD3jzblmHSzhRTwarIhRy wRecydRGnKsvGt9GLPXwt886zRekRUsGdU9KQ5iq4mjItwreKavGRZA0zx2QGnOdpD ajlVFOtxieMUQ== From: Mario Limonciello To: David Airlie , Bjorn Helgaas Cc: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , 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 v8 9/9] PCI: Add a new 'boot_display' attribute Date: Mon, 14 Jul 2025 16:21:46 -0500 Message-ID: <20250714212147.2248039-10-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250714212147.2248039-1-superm1@kernel.org> References: <20250714212147.2248039-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. Reviewed-by: Thomas Zimmermann Signed-off-by: Mario Limonciello --- v7: * fix lkp failure * Add tag v6: * Only show for the device that is boot display * Only create after PCI device sysfs files are initialized to ensure that resources are ready. v4: * new patch --- Documentation/ABI/testing/sysfs-bus-pci | 8 +++++ drivers/pci/pci-sysfs.c | 46 +++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-pci b/Documentation/ABI/te= sting/sysfs-bus-pci index 69f952fffec72..8b455b1a58852 100644 --- a/Documentation/ABI/testing/sysfs-bus-pci +++ b/Documentation/ABI/testing/sysfs-bus-pci @@ -612,3 +612,11 @@ 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 the device was used as a boot + display. If the device was used as the boot display, the file + will be present and contain "1". diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 268c69daa4d57..6b1a0ae254d3a 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, "1\n"); +} +static DEVICE_ATTR_RO(boot_display); + static ssize_t boot_vga_show(struct device *dev, struct device_attribute *= attr, char *buf) { @@ -1051,6 +1059,37 @@ void pci_remove_legacy_files(struct pci_bus *b) } #endif /* HAVE_PCI_LEGACY */ =20 +/** + * pci_create_boot_display_file - create a file in sysfs for @dev + * @pdev: dev in question + * + * Creates a file `boot_display` in sysfs for the PCI device @pdev + * if it is the boot display device. + */ +static int pci_create_boot_display_file(struct pci_dev *pdev) +{ +#ifdef CONFIG_VIDEO + if (video_is_primary_device(&pdev->dev)) + return sysfs_create_file(&pdev->dev.kobj, &dev_attr_boot_display.attr); +#endif + return 0; +} + +/** + * pci_remove_boot_display_file - remove the boot display file for @dev + * @pdev: dev in question + * + * Removes the file `boot_display` in sysfs for the PCI device @pdev + * if it is the boot display device. + */ +static void pci_remove_boot_display_file(struct pci_dev *pdev) +{ +#ifdef CONFIG_VIDEO + if (video_is_primary_device(&pdev->dev)) + sysfs_remove_file(&pdev->dev.kobj, &dev_attr_boot_display.attr); +#endif +} + #if defined(HAVE_PCI_MMAP) || defined(ARCH_GENERIC_PCI_MMAP_RESOURCE) /** * pci_mmap_resource - map a PCI resource into user memory space @@ -1654,9 +1693,15 @@ static const struct attribute_group pci_dev_resource= _resize_group =3D { =20 int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev) { + int retval; + if (!sysfs_initialized) return -EACCES; =20 + retval =3D pci_create_boot_display_file(pdev); + if (retval) + return retval; + return pci_create_resource_files(pdev); } =20 @@ -1671,6 +1716,7 @@ void pci_remove_sysfs_dev_files(struct pci_dev *pdev) if (!sysfs_initialized) return; =20 + pci_remove_boot_display_file(pdev); pci_remove_resource_files(pdev); } =20 --=20 2.43.0