From nobody Wed Oct 8 14:15:37 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 2F51B2F1FE2; Fri, 27 Jun 2025 04:31: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=1750998679; cv=none; b=Aqmy0bF+DTAZbAvY6aYibJxHkad1h2P1sVLTmDeeyEFaTP/4o+cW0MaFz2wr+aXvpFMkMJ92fzb+D6N84g0OD5Ck5vRKP0JFIXWQKasD3/7HdP1ZsUs7HWF2NEO58Xp/1lVl7KwlzntJLStGWphVd/QOFY7nh75eOoTRTWK/NTc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750998679; c=relaxed/simple; bh=cHj3h7hBxwKQAm75Z7A1SPHl3XQrv92gk4AeXACN+L4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=stHWkm+yuRAHfXH3ev95Ra4RegP0T8z7cT/ZBr6m9Fwelw5kOPr9fogt8a1Ve19ByRCEUjlOIgFg+AG420SF33cVdRqD7gut+pKyD7crinVe8dfZDW1rPTgyd2oqyGOG2dfVa1nNh/kw4cnUgaI0TmVJa7Rl3jIviVUBN0s5Y1c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qTTHnN9c; 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="qTTHnN9c" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B72AC4CEEB; Fri, 27 Jun 2025 04:31:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750998677; bh=cHj3h7hBxwKQAm75Z7A1SPHl3XQrv92gk4AeXACN+L4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qTTHnN9chrw/j4mMWfd8t2CBL1YUO4G9jliAghuWR2BzwFfvN56oPigNfcjSeH8WK CWIax6JRBF7elZwp8Q7E856rwen/L9iZI4tUjcy8HKAaDQ9N/uBcs1lyJjmwD/lZ8O NJvmxqEUp9ZDEkm29vvTojbKGa1HuKNITe+T8DFXivtvl9AEyfspYaHI6DBbNLDj5z Ow94RzT+U7hdw49tV/091hir179IcnYQLPKq0AsyFOpq7FMKcRnFOlHl5Cj+lYnuN7 toSXPE+fSXWoDr2VP2Y27r97jb2nUwtM5h8QNcXrFLpi4xcaVgDnBqdgP8ajOuQs61 VfGKrQrMuvPIQ== 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 v6 1/9] PCI: Add helper for checking if a PCI device is a display controller Date: Thu, 26 Jun 2025 23:31:00 -0500 Message-ID: <20250627043108.3141206-2-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250627043108.3141206-1-superm1@kernel.org> References: <20250627043108.3141206-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 Wed Oct 8 14:15:37 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 DA56D1E0DBA; Fri, 27 Jun 2025 04:31: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=1750998681; cv=none; b=buxkp6C2KdomiNk7z6O2ORoligi8vUe6OEyYNAjQeK2ezrC2F93pQR4/8Uey3KVjaGjcarSvVo9x4c4OziwelXCkDfTLbmwWE2zVt8bRi2tqJ2Jy6KDcesjZte5vYJvdK2SIXrj6yJfOrhrrDz7nu1U+bmVdzpQzXgzlu2DXO7U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750998681; c=relaxed/simple; bh=ZUEaBNdA8Lm5/HmaCro4bOIyTqXr2dVXogleY25ibLU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Lpf9IgPzxCbZt/1QZ7ObBqWRH0CnbFmplLUZ79j51AiQ3B56qL3eIWzHm+dVCKlhGCIrBitONtyAcrYeIVxrq4xeIA0tXpULdLAQP8XhBIhCOLS5Q5tqXhyH0VvTEOY2l029rn1EJ+lv09BlG87CKRZXMET3B2qkR1JTQpUm0PQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QUvTTjCG; 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="QUvTTjCG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F09FAC4CEE3; Fri, 27 Jun 2025 04:31:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750998680; bh=ZUEaBNdA8Lm5/HmaCro4bOIyTqXr2dVXogleY25ibLU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QUvTTjCGiyKuGvLJSfWCMsHnpmiYAIrCP9VPpBdOEJNMty1Vo7M0suxGFn+C9eUrl eGT4h3W/xn6pvlXv56LLXbRhk35cGzZcP46f2bqWmTRJBv6xT1VwhMCn8F2eO6fp7I thdIttX2sj70vGxc2SAo/CSPuVkUCm0j+lRmnkhiFzhOpNR+XBnGK9LbXe24KuqaAB iOLKcADTy4ULjQCAEqY9n3ODjezJucL7biN+SC9dSw7hdoNj5lm/AOLpteFsvNGUro yUYgtXFlVJdkZgx7WzyR6HUy1y1mggEwCVXaoZUYxjLWk7WcV+7XiRosdDW1o3FdHm wi16/qarUSQIg== 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 v6 2/9] vfio/pci: Use pci_is_display() Date: Thu, 26 Jun 2025 23:31:01 -0500 Message-ID: <20250627043108.3141206-3-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250627043108.3141206-1-superm1@kernel.org> References: <20250627043108.3141206-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 14:15:37 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 5B43D1EA7C4; Fri, 27 Jun 2025 04:31: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=1750998683; cv=none; b=P0vyZTSaL3JMFqhWYxzoSiGYabCzHqYEi0yZDddVmtI/jFh5vTHbUVd1IRZnRwBk215MOBP41Sw7plMXjEkoukRMEJXZmxEH/ju6SSsK8VSfUhV58ekeIGzFOaXrLbZzcPRuf07bWb4em7QgzPWYf1wXXbIym1ArtQjb6b1vMkE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750998683; c=relaxed/simple; bh=LQvOsrvAxtIF9zfBp3smdp/HiFPvr9jOTvuEZPP26Xw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AZ9ggSOwN1tfsiK+Oqf2aCUJc7CjKb6K8eYLRmzYCebp+eP+HpOUimZ1BOYTtEh7IyRAyUbAuDq1NlnNw04e4Wws47F0IEPJXqQSH8f5dDgbHsj/7iYTfz+3DrxHSJNgOvVR+wEN8ijvu063LVWORCKWUVi+S6hpHx/aoOwEyXI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fwRqJY5Y; 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="fwRqJY5Y" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DE68C4CEEB; Fri, 27 Jun 2025 04:31:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750998682; bh=LQvOsrvAxtIF9zfBp3smdp/HiFPvr9jOTvuEZPP26Xw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fwRqJY5YvonuziSm1kYuD5mQ94cJ1bUO1Q+m1Uih92TKyM9TCluYsFr4IR02+9Gyb qaPRxZwXB1w9/d19qAYWBZvGt3W1kWqENyArEldMPW7FaAV7bM2ePURMPBWw0edcgR ri3Nx2k1cKOuXJOpeP2UczpGN246lrhGZ5mFbwq5LOySJCyj8Gy5lpeP7VoqKdtrgg qbhAmJ6GwSXKLoXwFFx2Z5ZE+tmifbEgk1G52/jpLoxm1XdVUj2ZLx8Z6UpInfupWe R+G5B5KUFBNB50X9TRyZ9kAwvqaxQVdwm3NQaQm4OBZPJp3kpe03aumWR+hn/NawqI YnuSe0ZfJFCJw== 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 v6 3/9] vga_switcheroo: Use pci_is_display() Date: Thu, 26 Jun 2025 23:31:02 -0500 Message-ID: <20250627043108.3141206-4-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250627043108.3141206-1-superm1@kernel.org> References: <20250627043108.3141206-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 14:15:37 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 ED2431F419B; Fri, 27 Jun 2025 04:31: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=1750998686; cv=none; b=WLVgLPC7SB3gdZgsJ6JU9ukEiHEiIpHZsAI0v7cI6DshNlm4H3Y/XhCgilKtd5eMDRDiOOuQQPtI9j/WUfoMsardW3VdJsu+ejShyRXzgHpZo9EYrJE0uovV5v/J3/bwndrmVVNpwzJrNJMmPa91Q6kmXyvQobbkVDnGQnsqmbA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750998686; c=relaxed/simple; bh=0JY3xV5HErzsQVOruBIRg0clSTUDvYlikV8MoSsd/64=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d8kmecl+hqft8mYBKcU/nk171vUPXfCAYwmBXAs2s16e585SB8PCia1inJV/Hg+Nx7u7zYtHQdH5Ku8c+Y7j0nO+nTzT9jTt3c6IhtAeGiVL3I6B12sQnyCLz5aNx+VTigWkjRXQOtHzzY/A9nCR2H3NeWAYkD/a3DUQ/Av+vJo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dQBn0wcG; 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="dQBn0wcG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21777C4CEF0; Fri, 27 Jun 2025 04:31:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750998685; bh=0JY3xV5HErzsQVOruBIRg0clSTUDvYlikV8MoSsd/64=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dQBn0wcGkgVxz5Qdsw2JxFseySU5esBfNrutJfHvNmBtLb801AWtYpSAwHfT3DvGB KX9ZfcIUaV9oB3tk8s+RYlsD64wTT5kAAq537VOaPRlvtztqMW+UMO2aVqdlJYlM2b 78oWq+VNQInQoqrAjKbe+o8yf6e4BeWfNvWxyIOwoCRS/0NKvKuC9fjF3RIDTsLLCH DKQ9K6XufUxVgiBcYoS9tmzo5SgyFIRDFDe2GUxL0MRn011Z4ozySNuzKoQQEXigPU BsUZHEFSNwdJoMDFdx6ztk3y5Q/k2hbFeBZQZMQWZfPZVd0AJiPSEXKmGotixdya4e W3fJKenT1/bQQ== 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 v6 4/9] iommu/vt-d: Use pci_is_display() Date: Thu, 26 Jun 2025 23:31:03 -0500 Message-ID: <20250627043108.3141206-5-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250627043108.3141206-1-superm1@kernel.org> References: <20250627043108.3141206-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 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 14:15:37 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 8E0AD1FF1C7; Fri, 27 Jun 2025 04:31:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750998688; cv=none; b=pU9Tble5545YZk1OHXCeDW9vH9Qua/FuXW9+xrXfGnjqyqCDa6u/HfS+LbqXnAsQp+Gh+gkG475JbkvLtoPGK8E4qgxMojtFoEZlzkC9X2czIHwI20uys9l9PE//CXQrSEuTu0aB6abde+83Ue4a6Gqff9YmDXjMRvKMSfU7CVM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750998688; c=relaxed/simple; bh=IOGKTg8m2lLVk2BGnUQp473zWXZ7OF1rNECuXqPIWig=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PAmUfqD7WnJVtraF9xaQ3/VAW+VyesM3YIiA2l7MRKFgDip4yUlXX8hY4eFfTMJHMRIocHto5F3kvLFpGnSvpZ/mkWUnJQQ7WyI66A2ymdqQwsmoOo8iWuSRragozxV2FjROWHDVeJ4MfX6zNdY9JK/5lpmtLSEgZdKSCBNFTzc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Pz52yDph; 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="Pz52yDph" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2661C4CEF1; Fri, 27 Jun 2025 04:31:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750998688; bh=IOGKTg8m2lLVk2BGnUQp473zWXZ7OF1rNECuXqPIWig=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pz52yDph4lvxRO78/df2VuOpp1fNDNoWqYOUxhyJnuo9OirhP0CkrWu10l3S5rVyu XuFAqxFzKqMboIlA4BR+Pbv0vs/oJMEcDBqGA405UxJWnAtQW4SRY+wTRUicKNWlFK dyHMX5cDSal5TcPwzheVlN8FkGBWcBiJcFba5wlR+KmSLfi8ij/MH7wQo3RYbTFDWe xhIz3YnCPfcGTq9RBHOnX9KzVEbJxPsktL5NDRqLAE7c/UW301XfcSVTwAUKHjx4Sd bQ61w7HQyq3fVIG3TPV7S3qQOl086ZQ8dnRnjiDgHQMHsEfugU0pyVjbZBUSN+jlFu /OEA7R1YbmVaQ== 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 v6 5/9] ALSA: hda: Use pci_is_display() Date: Thu, 26 Jun 2025 23:31:04 -0500 Message-ID: <20250627043108.3141206-6-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250627043108.3141206-1-superm1@kernel.org> References: <20250627043108.3141206-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 14:15:37 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 0B39F2046B3; Fri, 27 Jun 2025 04:31:31 +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=1750998691; cv=none; b=R02ykp9IJwnpRqZW3COa4ZtJNIwtLkirwgXoOkjMSnKL7GCKV7EFd6f6VLZaqRK8P1mNuDJAT8l1z0iX8BM1gK6HuZ1EPU0pi9qZiFgKoQcuvA4s3WVMLCUSTHnRg7EJ0D3zFdcwWQQEAnAIVuNQo4QcjiA9D45k1LTik4ImpTM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750998691; c=relaxed/simple; bh=glRBi2ARDp3d+Stsv79iYRajcXAB16Ljdcta010d3iw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ViH3w3LSE0XUtIE94FAcp4Q87wU++x7MlvNRYLJtEFVKhnPTLOVFyhkV9r1HWiGdxq5336C/RqFSl/mO9IrU2Uzqlrg43ELF1a6Lji11PEmV7y6sok3vWPN84itomIWbqjCvClsz+KMnOztRbV1HdWV45VffhEi1w3ied66TiiI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QtHC7psT; 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="QtHC7psT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4F82C4CEEB; Fri, 27 Jun 2025 04:31:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750998690; bh=glRBi2ARDp3d+Stsv79iYRajcXAB16Ljdcta010d3iw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QtHC7psTvXuAm8GUu62g1Z6MfEChLwahfYsYeZ6dSSJYOtwK3DlpPOB7kJObVbICA 4A0P9crea3Ggp2CYwQPZb1hCBaJcvMiSvbMF8KPo21C0nY4yMNG4sf5rDm5F2PtFff Mg5mDNRrWQ2o+vtsUUldBtYX/mYYXRA+I2COlEW7qL7COUTDAnbBeKETUk09ObCRIm OVYNuf86cf4FFQc4PjFE8CMeHjuLhY3oJJ5es5T3n0+jSLagsdqaEptykCKtaaa4zT s5vXiY2oolEJH23+9RlT/Xg5Agsyt4aRgw+SNNDznxv3IoENJhbCzk/C2ddhUvW8ax aat4kIp9hIuNg== 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 v6 6/9] Fix access to video_is_primary_device() when compiled without CONFIG_VIDEO Date: Thu, 26 Jun 2025 23:31:05 -0500 Message-ID: <20250627043108.3141206-7-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250627043108.3141206-1-superm1@kernel.org> References: <20250627043108.3141206-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 Wed Oct 8 14:15:37 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 CB25C20E315; Fri, 27 Jun 2025 04:31:33 +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=1750998693; cv=none; b=QIM6fE5ioIOUIngup4AVoZ86Vuo2OL6NG+an+fo4eCIwmbMtdziAHictPBS1Q+B0ArfuEIgIUKAXagTZWhFLd2A97a+HplotDilPS3SE7+sybX+SbonPwqZToZvqoj6O2A5SWfjAMcHLkb0Muk5cJ1iK8pnXFBhUKKAZLA4mq4g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750998693; c=relaxed/simple; bh=hely8rCeQBZS770H5X6E0gNUH0kghs8qNa/SePVXMhs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aNtTZ/IJ47Kplhj8o8/RK+9JJBz1nUWNwIELZLrkDO1rawfMPoNWb4nK3XuhuIWHF7HOJVGGn7K+ukizJqvsdQpAfFJWvZ09IYRMZaTz7rlRyp7e4vkrjuaWc9hiORcHXJKOMZaaqaTjPvlg61l55h6GwJFtcnoA9pL5rNU15g8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BxbK4y2b; 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="BxbK4y2b" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24874C4CEF0; Fri, 27 Jun 2025 04:31:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750998693; bh=hely8rCeQBZS770H5X6E0gNUH0kghs8qNa/SePVXMhs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BxbK4y2bmsy2YViXCUY6o2vDGuBYCU2r0quU8NQl7pOc6/QE9G0rbOBBxPwkPQ3Y6 hSnESV7GxY9Nw1Q6yxevuFLHaJXtUKB4YZsOU/CSokNBq5RPdtEF5Lt6BqJHmrAmJx kV4wkeM/L3oxu9UlVoHD/LqDDlyz4ZR+JWbRucZx6xiWSt+OQVxGtZkvGNzXyL92b1 yemjBB/3PBz3vkukdfprjKe3BY2p5CaTjqcRcH4F/dSRbp2wg1IKPSZcr+NZEs2ufa bU5KZOajkpScJhalRLeI2iURnzEO7bHXp5QPDzGTXrEFG62glkh+VJahspl0b4VFtU 0b4Ca9M0ZhCjg== 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 v6 7/9] PCI/VGA: Replace vga_is_firmware_default() with a screen info check Date: Thu, 26 Jun 2025 23:31:06 -0500 Message-ID: <20250627043108.3141206-8-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250627043108.3141206-1-superm1@kernel.org> References: <20250627043108.3141206-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 Wed Oct 8 14:15:37 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 70FFC1DDC04; Fri, 27 Jun 2025 04:31:36 +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=1750998696; cv=none; b=pgCR0i8UpW6mhyTRxEj1UUrZ7qbb5OLHYv/kWBdVj0zeNu3Av7Xu9W3mqXOacFCkigmn/PNjR37lmcIK5J1Y08mV75Nq0hli7u+K24s5y3nsofqKZfFWWHRLGwc1ppRa8sdSfzPVnbvMcagGc9/+lnC8tiEkIVACHEd9+F+Vhf0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750998696; c=relaxed/simple; bh=29HKhswcd8px+N2nYcp6Yih2LctL4W2GlFxn1lIVTTA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MxDpjONrivSbQxapk6PL+w8ANEt4W8FXqlg02ND79jDLfr6jIt8/axjBr54wHs/wVnh2MLfvKecgKIRP759ZnkzoIP+ZXM/AmaiQCQWQaHTLQy6Jjq5ojdJtoLNWj/D9WTj6NAEBz2Nbb4GRhSgAs1TyOJ/9bzy0TBiDINxEaUw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mTfo0QUs; 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="mTfo0QUs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A89FBC4CEE3; Fri, 27 Jun 2025 04:31:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750998696; bh=29HKhswcd8px+N2nYcp6Yih2LctL4W2GlFxn1lIVTTA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mTfo0QUsUHtoEmWXuaeJ6AdrJ28pBSLTo/6MN1G2cX6Yj3MKalD5rA9KtkRHZZfPd iVDC29Ldy0VtPgjyf82w6kuvDmbIagIuLF3B8uuP5Ww7oE+vmptG2oR39XXXNq47oJ VBkpa+N9F38nFGPbjLmkeBnosK6yokBTH0WHF2ZSB4VMWOs/O8/tZvmCl50OYqbdXv M7yOE+paF/oeKoBS0tJ6mEc0IoxDDa8GXbJTWtrc+tQXeQMigGxU+JbYKFqxOEDJQZ m+y80IBI3zy5ZYdAP+ouz02AHh21jE2KkY/sTsS2veJnsh+LJVnWZUnMmN/aa39vIe QSvlIUkKfpK8w== 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 v6 8/9] fbcon: Use screen info to find primary device Date: Thu, 26 Jun 2025 23:31:07 -0500 Message-ID: <20250627043108.3141206-9-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250627043108.3141206-1-superm1@kernel.org> References: <20250627043108.3141206-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. Suggested-by: Thomas Zimmermann Signed-off-by: Mario Limonciello Reviewed-by: Thomas Zimmermann --- v5: * Only change video-common.c v4: * use helper --- arch/x86/video/video-common.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 --=20 2.43.0 From nobody Wed Oct 8 14:15:37 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 8EA8F1DE2D7; Fri, 27 Jun 2025 04:31:38 +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=1750998698; cv=none; b=fhRJc5H24s2nricNm5HKMnjAQNL9gi1etZ1+MwpmUK0wCS39p/Pq9fhiMRICrr5DY3C15FeAAwS9t2+Y1Cn+P5Bjewifd6MwhX11PHU1T0FB+jUR8ZSzRTYif+Z6y3DQg4wWlqlQtsHlM03CB4jPoaTxasQXbayxoyben2D4Iwk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750998698; c=relaxed/simple; bh=wM5TClw82+g+f6tTVZpsOWcLA2SCBE+v6qAmnJL26dg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E71NNGVVYD4wFnP0OCiGv9gADJDygJPl1z024DtlhrEx+9XYbIxUO/ShB8ld7Irg/IVccYrtpxxkBVPGTWLnFR56jGtvwuOV1LEzabZtRCPNZsfpISzigrkArFc3n7Ws2u1H88H2zzVSNkhaVGkz5xmsfljZeqUYOT0+Z58iqeI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TyBp7Exh; 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="TyBp7Exh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3DC04C4CEEB; Fri, 27 Jun 2025 04:31:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750998698; bh=wM5TClw82+g+f6tTVZpsOWcLA2SCBE+v6qAmnJL26dg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TyBp7Exh1zUlLHHkHOA8PkAI5rInJOVDVZwtpuqi67FZ4fdGvEHRo6GMm5D1DlpKy d1EeX3yqogTDFj0B0IYKcsxtuZDBpT8Gx5h8KaZV6k4GFtPjEmn3D+Gv80L4uS92H7 oQ3KJAPnROQReELH/VMeLqO7/fZOxgrwjBYcQ8Ckd/viHQzGw3bURRXjezKAVDmwqY SBKQBOujgECCL6MiHhRwja7T/GkmdLA4NHAm677pKzhmZXZ7+CK0DGfyToQ21grjMX pKXGUt0f4do2wBJQ5YgznQPO1zOVTqaajqY/66jnb6HG3y8StmRxs0ckNlQY+Rn85g TBj6z0uy0uHcQ== 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 v6 9/9] PCI: Add a new 'boot_display' attribute Date: Thu, 26 Jun 2025 23:31:08 -0500 Message-ID: <20250627043108.3141206-10-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250627043108.3141206-1-superm1@kernel.org> References: <20250627043108.3141206-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 Reviewed-by: Thomas Zimmermann --- 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..cc766461de1da 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) { @@ -1246,6 +1254,37 @@ static int pci_create_attr(struct pci_dev *pdev, int= num, int write_combine) return 0; } =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 +} + /** * pci_create_resource_files - create resource files in sysfs for @dev * @pdev: dev in question @@ -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