From nobody Mon Oct 6 19:10:36 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 EB37B2FEE0A; Thu, 17 Jul 2025 17:38:24 +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=1752773905; cv=none; b=Oit4KCtYb/b6vFBSyo4IbO6aUF9M4c2GOo52nqSvRbwfdVWdAYH1AiyRT5ZnHHT/z4Cie0tJh4PcgCzjIspbCvlVGKU7zvkl0HsoB3pq3zMefeD1JNMAZXDX6+wjVwTiLvt7it2GbtLmCAeS3tvICIniyt85N17PdQtUSSROcSU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752773905; c=relaxed/simple; bh=cHj3h7hBxwKQAm75Z7A1SPHl3XQrv92gk4AeXACN+L4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pOZLSBOLXJnOrW2JyAmTe/JLp0kf1IriJiCEW/IVM3FmbHOYysFJDO+xfsdFMu9IaY9ix3FXmEGf2jZHcya9uQi0NpAZrP7ynkUdbZ6qSi8oG/rvy3pRVJaGlkrBeUptLezezlt9eCyEyyn//cjRkbkAynp5tnxqz2xUJUBt+4o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MqPopQVr; 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="MqPopQVr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46F35C4CEF0; Thu, 17 Jul 2025 17:38:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752773904; bh=cHj3h7hBxwKQAm75Z7A1SPHl3XQrv92gk4AeXACN+L4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MqPopQVrVeeNhmUHNU9q1gFwPPBy3S8G4cqfCt2/qWCddAkWLCU5ctEj+5LKEabxF 7jnFn9yJ7HvQCx+6+N9t2U9D/4QxAu6bUAxd6tR6t+iATbUlqZOAzi/jp00s4N1iQB 4cyITolFpE5AXqXP/mekzeBZfSPSIzfRDApWkGvjQmjtg5v1+MBUyCIr2CBaSvPTcg F6iHw6gCsk5Z5Z1fbMPSNu4s8eJQqdc/16KbVOr60mbniCD5I8DDonG4mtjRZ7Jsbp TMZAGlGCJqd9pn/qNGC3+8EFr4JdM8La3mTyR35BRVehFZmSEgc6Pd9c22LdD9X2EC 8RlHAXSL+Esaw== 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 v9 1/9] PCI: Add helper for checking if a PCI device is a display controller Date: Thu, 17 Jul 2025 12:38:04 -0500 Message-ID: <20250717173812.3633478-2-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250717173812.3633478-1-superm1@kernel.org> References: <20250717173812.3633478-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 Mon Oct 6 19:10:36 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 9C5A72FF471; Thu, 17 Jul 2025 17:38: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=1752773907; cv=none; b=VW6YZCYW0nVSFPoZLuCUBSYQIPhaBYyeMuMcYuwMkKi2fv2rudpr8K+HuhE02wIs/MdW6UcimJnWvxT7wGrsgKWfaTgXKTLZkEHE6PXMMVS/AQsW3fqwvet1LEZQFCXWSF8nEWOMJ1b9umqlhOYqWk6rTDxWK8EDS3lMux68iSQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752773907; c=relaxed/simple; bh=ZUEaBNdA8Lm5/HmaCro4bOIyTqXr2dVXogleY25ibLU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f6FfYmZvWb4htQ62N4oEAFzBtllsqhDjk/XRABkgj+X7hhSe3vUk4sYnbEpc+ZxY3jZayrvX4S7lUxBsy+BX7Ju4hpQuc5tGGx+7dEnKtQ1foVsLntC2/vTxqIfKXM/jKNBb/JrpihJG43dCcb+3dqepWxm5hYzActPvImRcgFs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CFUWkWfg; 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="CFUWkWfg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA8D8C4CEED; Thu, 17 Jul 2025 17:38:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752773907; bh=ZUEaBNdA8Lm5/HmaCro4bOIyTqXr2dVXogleY25ibLU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CFUWkWfgMNlxap9CCDH8BbOALN7ZNEohNzab1yM3QtbK6WQKZgyDBrFjeF3kj5Ia6 5KhlGGwnRGFhBr48XWVqCAsIwLgTfjjnl1v+LJTECvu6RqauOzPDUQbNJawP6K/16O rzluCKDuczfM+OmHkUMkd17ViUR+pY7prykb3sJYCPB7JnkscfuzDtx3jlAoEjvUvX 68wFB2+h3Nyy73cj+jV+GQqu+Tq9H+a9xwnxm1P6eJpBNJ6q/HzaUxmVemL54fBX0A pIbXRdp6GEEZigXHrgQ3X27k4c7yQjAAelScjoA4Un5ivB0jaIkXBwsLOMw52pzerL FZNwSVokRZ+Dw== 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 v9 2/9] vfio/pci: Use pci_is_display() Date: Thu, 17 Jul 2025 12:38:05 -0500 Message-ID: <20250717173812.3633478-3-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250717173812.3633478-1-superm1@kernel.org> References: <20250717173812.3633478-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 Mon Oct 6 19:10:36 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 056A030112B; Thu, 17 Jul 2025 17:38: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=1752773910; cv=none; b=hhPZH5TaEow+cvwS83jHTRcZqAfVv4t7Nb3UlKqES9KHoZ/wAreY6Qtfz9mxPVKh2UMFApYRVJ7pxFhh/tPdMnpygl79PRY4jSgVbhiBi7fhtElX10cMPDhn9x8KtaRgEXKCi7oCbowA4ydlfWkCp7JhoDYhojABcXd4mUN9Pds= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752773910; c=relaxed/simple; bh=LQvOsrvAxtIF9zfBp3smdp/HiFPvr9jOTvuEZPP26Xw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=D9a1JVLLqYQJRdFI5nFDBk+IJzD+AVVsWjjkQH+f1/n7YK2LAJU4DoLIts6TaHISMcAfIX4Mp1heOiUS7kzcNt1rfHLo20zaFiLyaZ1heh0+U7+/qwQeAP1A9/crvxlhaPaxlhzkNH9MEkFi2uOaaqWM/tMXI6lzM+PRy4tfGv0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ickK1lBa; 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="ickK1lBa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70CB2C4CEE3; Thu, 17 Jul 2025 17:38:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752773909; bh=LQvOsrvAxtIF9zfBp3smdp/HiFPvr9jOTvuEZPP26Xw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ickK1lBad5bTYIvdilgPat1k8N9oKeb1NbYjhSUVYnAOFktqRVsV3Eqsxs009WcrI VD+qqU7PTnzjhRMkjHGZlC5ppIFXjV5LgDW6VbDpHRxlWy4gIEmOlwqyAlphwci7JG vol3NQ40MQLvFkWY73Jqp154KlYGzLUXdDdjdTwke35qzGbHXsGCnXpQElwsnjj+zq GWrDM0AcpRdrMq/teioONtW7MtVyDKmXgin+U/n+QY2iksKI2nZR65Hka+i60UFp6h CPjhDj4lI9RrjxtZMbaHluswv5aMPn/SYxkSyDi7tSHWPzaD0ChurH2gNk0X2jO77r lzPJ7LL1lD6Zg== 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 v9 3/9] vga_switcheroo: Use pci_is_display() Date: Thu, 17 Jul 2025 12:38:06 -0500 Message-ID: <20250717173812.3633478-4-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250717173812.3633478-1-superm1@kernel.org> References: <20250717173812.3633478-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 Mon Oct 6 19:10:36 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 D76FB30115E; Thu, 17 Jul 2025 17:38: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=1752773913; cv=none; b=AqT6IBXMT2xiw4m0FJQQo9IsULyez3gmG7Ozn4LJZkhPK1+2IApJOB6TZ5d8mxI5wvup3v0v23mez6LNsCA1zC38IkEHroD77WFeXGviBnT92fVgF+nI7xJMnaitP3qw+hzmVQbN1yxsq2KnOeMADqBM0M9N+yooopghw4CJJBM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752773913; c=relaxed/simple; bh=wZDfgswU2/pwcpS3H3uILO4jDTDnQH15cewPVoii5Es=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Hjomrt+jBcE+yGGbC+Ec4rDhkwfYmEzGFK5nrd7LArJuK3x/o/N+0AbatRP5bIZrQ9/vKBOlCmi38bagGi93XJcCUyphipJljivVXRx+1v6cktMKUYpazFNv0/xWjdtxLmAd/SwVVO4uyQzYLSP5wcjjMbSguXtOddthABJbI94= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=p+DaYnpi; 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="p+DaYnpi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2486EC4CEF5; Thu, 17 Jul 2025 17:38:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752773912; bh=wZDfgswU2/pwcpS3H3uILO4jDTDnQH15cewPVoii5Es=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p+DaYnpi70Lt2MtzM8YaWKYHHUBdCgnvhTTgtm73exhs9Mn3b+6hmFITHqv0+ZvJi pDnPOnggRnvlkChq/yGWc4+gjU5E2tZvdNha1pu3NB10GgCwnMUiSWJvsy3WUuXtEc 8orPRtp/q8m0JzErTQp3pi6guOkUUSDZ9mwa0G/pk6FOvUVW7bnYk+Eo1OauHBvmZx gVkL+J98IF7V2tyMLOJTHLgcEgR6gMsqvosTrLBYhCRwtsGain0t+7SCkbYl9UDiL4 HhNZ+NvxXnVt8PyA9oiZPkMwujUocLNZ/83t2J2iYnbB54hAcAi6xpLRDFhlJQj622 XNowdQjx0pbnA== 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 v9 4/9] iommu/vt-d: Use pci_is_display() Date: Thu, 17 Jul 2025 12:38:07 -0500 Message-ID: <20250717173812.3633478-5-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250717173812.3633478-1-superm1@kernel.org> References: <20250717173812.3633478-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 Mon Oct 6 19:10:36 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 9A77628504A; Thu, 17 Jul 2025 17:38:35 +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=1752773915; cv=none; b=fA2p6j1ttxgoUUSSz6zHnNWqx7cAtAvLYKJTow5m0iX0chh5v2CW/vGgCNIoaSCrC/oOtMyVqn2QC7FyjX9VUdVuIxU66E7mcVNfJa51gKTXnCfyC5IlKOnp+yR7tu3J6GmgS2ATkn43uSunHBbKYE+FqMZZ4Fatk7vkd9g09fs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752773915; c=relaxed/simple; bh=IOGKTg8m2lLVk2BGnUQp473zWXZ7OF1rNECuXqPIWig=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UQjTjGO75VlY9KrSSd6CrJ4UboREV0YODUNPKNN3iACLZfS3CdqRvtCqE9ZDgT8z2oZuSFmWnG47GLHmXJNmebznF9AfLE0YPTDCj4uwfpXwR+WnUNu9SD7Yif9iW9aDGjRgNTuJ3TtHj+8Da3vIMGKGvWwDw118+BfT9B52X2M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=S7k7bG+X; 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="S7k7bG+X" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BCA05C4CEED; Thu, 17 Jul 2025 17:38:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752773915; bh=IOGKTg8m2lLVk2BGnUQp473zWXZ7OF1rNECuXqPIWig=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S7k7bG+XVGbJjyMITPa/JPRu00qfyWjDajxpi0KY3FirkEVkQDkKTl6XCYEW7Bx0B Xp7HP71qQIBqAGwOpf/Gk1UOGDRm60crLysLaeJWwlPyq+Hz+08KfOK3DwTmiXMdRQ cxN9qRRho0KgF89OAcC41dVXA+/IYIGt9lUroKAgI45AhSqX1bTLUSKF6Kvf94V2pl gza6w2L5lQmFo0t4xzdOVwqw4jz/yWUkhQ+S2HfWXMySYxDqyprWHDiyiJ/ICXYRT/ pC7t7mqYBXTx91e7A1tglUnEhu+GbOYNm6iMsYZfPHEQCXgsu4JjfxxDETg57jjZf4 kGB4WL7MRx4Jg== 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 v9 5/9] ALSA: hda: Use pci_is_display() Date: Thu, 17 Jul 2025 12:38:08 -0500 Message-ID: <20250717173812.3633478-6-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250717173812.3633478-1-superm1@kernel.org> References: <20250717173812.3633478-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 Mon Oct 6 19:10:36 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 2A7FB302CB8; Thu, 17 Jul 2025 17:38:37 +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=1752773918; cv=none; b=DpcpHe9umHlWDlJM8UzLv5viO63tnVLvoJOrLO3XCFmHs6hzyEONMDx2g/6787AIWo7uVTxLLK/CtaDyKZCG7QeQJJfT3BsFd08es2RaTYruAQ9matiTiUUEgSx5KA4F78dYF1S+dp21jTbJRmrNXir5EOdlXLsMPntzVvx8uxs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752773918; c=relaxed/simple; bh=glRBi2ARDp3d+Stsv79iYRajcXAB16Ljdcta010d3iw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PQfQhQ8wIBtoE54yHq1vbMXJCpveHMwxeYUEyiewGB7taTwSvPCZ+N5N1WIgSk8dim81ugk1dTLvXqTWFVj3nVVCiPHaGf98HhyrgtC2AG8vENo7q4l1KLQz7imbEzzCkL5mprCcSQKgIqLd70iVOUbEYobuw0bpAeldSlm8OzM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oXNgsmlP; 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="oXNgsmlP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73BA9C4CEF7; Thu, 17 Jul 2025 17:38:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752773917; bh=glRBi2ARDp3d+Stsv79iYRajcXAB16Ljdcta010d3iw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oXNgsmlPc1SECUkx104tudFkiGskV4f58Ntx50l45eeDxF5h35tV87le8Cu7eZ1w4 B5eFSturPx1lcvBf30tTLT9eG7DPNXKRgrCvcaBu0a1eBh5YPT4+4dt+o4HSAUQdOJ HQ49uwZ4+BDa/ioRLE9mDX8FwJYe5zyeA29y2A3EkjAH0ARBlH/HBWAyAW1mScxy6H 1eKWxMNFbcC7jLCeyiqTsqUU17zsiUJXoxMZNIE4HUZrO3l7poUePA+dpn4TssKHbF 1Vy6yRTX2Vvvo1heat+ITWfmNwRmm4FufYTOMxZPh0so9xk2XUSpLrP8S84warsPg2 sFR/PdhKeJIiQ== 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 v9 6/9] Fix access to video_is_primary_device() when compiled without CONFIG_VIDEO Date: Thu, 17 Jul 2025 12:38:09 -0500 Message-ID: <20250717173812.3633478-7-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250717173812.3633478-1-superm1@kernel.org> References: <20250717173812.3633478-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 Mon Oct 6 19:10:36 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 69F11302CC0; Thu, 17 Jul 2025 17:38:40 +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=1752773920; cv=none; b=Ram9W0jNcre+yLKi7fHiQbOPqdp0hPs7Apr5NFnGfTI50G3lpDG6+hJFrHgOrxTHbVWSW5yqLfqwvoVTmgRnOgS85UDtHFD+BAhO1pFQd8p7UnFORJzrFT8VzbBbqw6FXVtOkIKxHLx2jPxbhT9Khzhdl57svw8+YDwX7c2rPxY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752773920; c=relaxed/simple; bh=hely8rCeQBZS770H5X6E0gNUH0kghs8qNa/SePVXMhs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U+YOPXASjHj1xtEo4a4aDK+0RTqdmhaoufD6GhrYSrGzT/LW5FiyI84xUyv6w/Bas7HMYC/wDf3xaXp5L3ghw0qIcafb5IbMXZKGVuJC9/GOpmIySVmXdIGC2ODcCRPCVxp9fGFfdoZy2i/DuSBOCFOrPbSfJz2Z3phSK3dJXQg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pGMGKGQY; 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="pGMGKGQY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08764C4CEF0; Thu, 17 Jul 2025 17:38:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752773920; bh=hely8rCeQBZS770H5X6E0gNUH0kghs8qNa/SePVXMhs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pGMGKGQYGrUumqvvHttytPFTFdVXTNijxNxv+hDUKfw5yo7oS3Rj2EuUijDYd91Sg 7dreKqpz3ufzBQhWwdUPdYO4yHenJvSL7Lm0wknc13dNVnnu+KB4F+nQBv9P1KBE3c dfCg+EVdP2OZfRSAOVR5L9FGVcU2ucUB8TBbsEuF6KwygO+l94AZV0eSIonZnThJjj eV4Z60CjWCoivwYWICbC5RlRLlNT3aJLKI1hUBGClo60dUSurA9Mt1MQvrtTMSfy8m DphycGSKXmirJCOek9kTeo90lxrh2ByUKpDxrtdEJZ8kwutfCis+b7/9kvgZfXk8/p 3iIft+2canwnQ== 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 v9 7/9] PCI/VGA: Replace vga_is_firmware_default() with a screen info check Date: Thu, 17 Jul 2025 12:38:10 -0500 Message-ID: <20250717173812.3633478-8-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250717173812.3633478-1-superm1@kernel.org> References: <20250717173812.3633478-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 Mon Oct 6 19:10:36 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 411AA303DEB; Thu, 17 Jul 2025 17:38:42 +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=1752773923; cv=none; b=oFnKsVfWzna06ompsU4A2OVaogo65iYpAOa7XXjcnwh+EzT7JjBW3Y7wkLcIX0tz0XoVIbBFyKelBlAuhVbUsFI5xr+2o1eeDcavNnWTbmy2Sz7PdGUJOB4sv+LVfjhucKZ6j0mOO0Avdw51QEtEUuhQNTI3S5zl6J2gX3qvM+8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752773923; 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=hG9c7hyER3TCmOsFV9nC7G7155PjSMT7DF/QaKfJyG0vqOQz5cpe99NCgKTyTjng+wjF6c3D4zCvzMtD8zbzilbaGsgVQfNQcdF6Y8AZyIn+DKx5FbWfy2lPuQj2uaH/ZiOfgilDVN1b4mRmP+sUGd9UvDADCWujcB+6tK4pSek= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XsgStJ3B; 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="XsgStJ3B" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8256EC4CEE3; Thu, 17 Jul 2025 17:38:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752773922; bh=qH+nP7l6aO/IuqqbAQWnlb+L+ux6ugVAwetscoen+88=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XsgStJ3BmqyPAuD/rv2rntCq4SiGgBm1p/6mfU2mQ+BWeEB10J9WVmu4kTCjIlApH QQDG0j3ka9YQMsAKJR+Qntbvq8pT9CNWvZPl+XhCZMUFXuAVPLlQTMgHg+oN0mRjr4 +iyyPV2yJMyRWZSqiAmJWq4vNRrckgCTwkjdxnzOmR/OFW9yS7cKWJyNm6iO/iVc86 pYClw/RNLC7PgbgPPRRtrV3fBIOSPOn6GPG/mnccVmuzRQ1O+UHGlbB2WR+DOYt0vf 3uLm79nQBMNLkwwfRvJEFpAN297AogRv/pG2WKayEZvVi7G9+sqsZuYoEqHM6dtcC9 JEOaNat9ylM5w== 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 v9 8/9] fbcon: Use screen info to find primary device Date: Thu, 17 Jul 2025 12:38:11 -0500 Message-ID: <20250717173812.3633478-9-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250717173812.3633478-1-superm1@kernel.org> References: <20250717173812.3633478-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 Mon Oct 6 19:10:36 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 6D197306DB2; Thu, 17 Jul 2025 17:38:45 +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=1752773925; cv=none; b=bgJYToGfYzRKSBDOn8eo+SwhAOE5wkizVxx3fYPWPHdcoIqG6eaVE6jrQAexMehZR8SWd8I+u06vq6gZGYMebGiBz6U2gWNmhIZ4odsdTT5+7Utz/FnsNsXwAFn6yz9TVkVE3mxnPP5wjsB3bVOwo1hXa3FM9JmfK9MU+MKRjXA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752773925; c=relaxed/simple; bh=yq7W2WVUEaHr/X54PhBR9VeOykW/0gdmiDQSQN/06X0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k2FJvqctypWgBdvBgs+bTvgcW1Sr8qZYyNjDMC6VCjbZMwFYAv2ttQyatpMCTmYDEPRVkNAeYx2ERgDjw5z4XmQdjbdmbbGzOhnR93/PXXCBl6EbDMinAZXeL124bs5ZaLUYw66zFUyka7fFXaM96+KDO3uZy1e7ZNymynOOG48= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dAGkJJp+; 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="dAGkJJp+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08585C4CEF0; Thu, 17 Jul 2025 17:38:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752773925; bh=yq7W2WVUEaHr/X54PhBR9VeOykW/0gdmiDQSQN/06X0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dAGkJJp+T/ru/NLo6QkFBo22cb2FjYo5QdxsSrlo4Sc4SlkcOLVB9ipQtFDTNJErp xrvoRco2SoaFcFCZ5Bec+6y6wbYL2yuByBS4xVuh7eOj34W+YCqi2DWWBf8yL4D11v 3nDN3rRUkLFenr5bqI5YqpRFEz4mLRlurN8X0YPF5rtDPAWIMSooFJp4efPAQ+xGUu xXSwH7EHHXauWHLeRUUfDV5SEHAl/KmNdJOeoJwdVXERgvqmJDf7sTPzKc7hhkuQ5x 0IieWFdbBFiWfzAB+P700iDEzeW/WgrB9xKWQ+Iv2LInkZo2MqAiClmGW6Px4vUx8o U7PciLz33cHEw== 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 v9 9/9] PCI: Add a new 'boot_display' attribute Date: Thu, 17 Jul 2025 12:38:12 -0500 Message-ID: <20250717173812.3633478-10-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250717173812.3633478-1-superm1@kernel.org> References: <20250717173812.3633478-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 some desktop environments this can lead to increased power consumption because secondary GPUs may be used for rendering and never go to a low power state. 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. Link: https://gitlab.freedesktop.org/xorg/lib/libpciaccess/-/issues/23 Reviewed-by: Thomas Zimmermann Signed-off-by: Mario Limonciello --- v8: * Add bug link * Update commit message text * Update boot_display description text 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 | 9 +++++ drivers/pci/pci-sysfs.c | 46 +++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-pci b/Documentation/ABI/te= sting/sysfs-bus-pci index 69f952fffec72..a2c74d4ebeadd 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 that displays connected to the device were + used to display the boot sequence. If a display connected to + the device was used to display the boot sequence 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