From nobody Tue Oct 7 21:03:06 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 960C42882CC; Sun, 6 Jul 2025 14:36: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=1751812587; cv=none; b=c7GJu2795mJSXWjmCG2dk5HS7coLA7T59BdZzHTkOnxGM1yUgLDRTnE9r5xyEK90haeMCdpT3kY7UjShZD4IU6FTxlkjzTM7NcPzZL9KehlcDit93BX1PCBwkIS4PV9yuHZalQIISXlwfxD83wuXkUkVGOBVZ84nI6hmoycqXlU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751812587; c=relaxed/simple; bh=cHj3h7hBxwKQAm75Z7A1SPHl3XQrv92gk4AeXACN+L4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FwZf4qBxt9BFk3W+paExURrVwrLmZ4y8+o4lB+5yrNuUtq9X2ZotrkVK+nq5r+U3ZYvLioaTHrwngD/fMbsmoNb93EVPxE7zWZBaDrgYTImnsB4o1V/iNnE4jTzJdCzNwkk/4RBrzY4AVcpMDF0lbgZbJ0EpK+pnDicxSpMjV6g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JNYFRdFb; 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="JNYFRdFb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48EB7C4CEF2; Sun, 6 Jul 2025 14:36:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751812587; bh=cHj3h7hBxwKQAm75Z7A1SPHl3XQrv92gk4AeXACN+L4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JNYFRdFbZLPlrxrLcJpa0aqDgcQ2fSj3DmHsG6nlCya2qlDPB0nVCccXOIv+rWPCR zPZGAa2GXCgT8tEYhhjI3KkLSloAvV19s0VtCTVDVjtts1FZvlsWPexJZvPBCQcIGQ GT1tAVBxqXVCGe8sVTkc9KMFlxTT1mvqW98oRt8W/CaprbdSlmXmEcJOpNP+APRabu 0e1bIbzSO4UrRDT+G8M2yl5SOjUwfFanW4wSJD0iMN7kcR7yPSx8Kg5N2dSi8HBpwk FYQwPRP0tHqvCdOWiAX5R8v+DAzY32KUlzW2lkJV8d0O4cfupVoIX/8HRWx0tuVH20 4arc047AOc2Dw== 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 v7 1/9] PCI: Add helper for checking if a PCI device is a display controller Date: Sun, 6 Jul 2025 09:36:05 -0500 Message-ID: <20250706143613.1972252-2-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250706143613.1972252-1-superm1@kernel.org> References: <20250706143613.1972252-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 21:03:06 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 011932153ED; Sun, 6 Jul 2025 14:36:29 +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=1751812590; cv=none; b=qD2CJvWbkZvJT9kWAaSaM2bJFaS59x3LJpfhS9uXCPfBw93n/86hwfceMpr02pNZeVLzxE8RK5Y/ChIlXmj03RF7Lvnqkoimn0ZgUM+yX00ywvzAS6H43aKkRDkGuRIl5yD1JQrrwGzXd4VytIKbjVPXm7V9qk+m1HrwQLomX10= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751812590; c=relaxed/simple; bh=ZUEaBNdA8Lm5/HmaCro4bOIyTqXr2dVXogleY25ibLU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MlfcXbjoQZGH4uT8IutdzaCddZq+NCP+vQ/aGy/2xDL4xjBr5N8Lu/JwiVmKLhllsbi2CmW5YO08MIB5zBRydrmN+TBBdTTReQOcBU7W4qnxaCouclY9OqQggsaid37LHTxK41WtsebPFRWNre+VHY/UteIaTohYjOk0knK/EOo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rWYhboOf; 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="rWYhboOf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A91EBC4CEF3; Sun, 6 Jul 2025 14:36:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751812589; bh=ZUEaBNdA8Lm5/HmaCro4bOIyTqXr2dVXogleY25ibLU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rWYhboOfm4hkgucypjjyYIr06tsPDejkxLGKBru0wLpFyDoJhtB/bOFE8wwB0591p THDon1pArnhPzLCPtRYpqBrANQjnR05oEGnNXdL/RuD/7kUXv1r610eP/w3x7g4oLX mW5kz3t3PypUtdOxn7CMY3zWHUBjKfsjc0lAgyQMyA/nN+UxqZ3bxX6rs+2Gyeht/0 ArlIdc1+f8sEPYsZ4+uWuBKo9wRNHEgDnTP5YuwkOj0N+lIdGSvqJdMRPc0W7QRBBD Qt6n1rczDIOgG+AlQSOcNpPUcjqaD7neyKld9mP68fEiUb9h6gn4Did+K22q4e/EmL 6WKCg0Q9deVjw== 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 v7 2/9] vfio/pci: Use pci_is_display() Date: Sun, 6 Jul 2025 09:36:06 -0500 Message-ID: <20250706143613.1972252-3-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250706143613.1972252-1-superm1@kernel.org> References: <20250706143613.1972252-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 21:03:06 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 6BD18288C3A; Sun, 6 Jul 2025 14:36: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=1751812592; cv=none; b=brQZyad2p0bs0IQiiFKE8a7YU75GTgrE5AS0IpYOGi0CAr2oHtT1LIjQ4hIqGrT/aBb9vS/Gd9KHT7qpGPxmd3wGuGreC8dVYRWxwYyUyopECcN8jcnS1YZ1JuHUb8AEJ17RTmOBg7S2/6TxeBruLL3WDTmqvIIKo3/tU5+5ngs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751812592; c=relaxed/simple; bh=LQvOsrvAxtIF9zfBp3smdp/HiFPvr9jOTvuEZPP26Xw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c+N16brjGx5iSO8nhSRSkCR7NNanrmqR8z3uyyLhi9ZvCxzi44X1CnJmnfBT6IuLtgUsNvUzfizfZ1m0PbgCBoH1lVF51xc6ku8dE1jOKopWIvbmCmnk+7pYAfC9ueMBmQ/kiISclmawEBgkTZZNPQ9ZiaBwQdCAs1sYqLoBkFA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rFvLJZHc; 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="rFvLJZHc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C696C116B1; Sun, 6 Jul 2025 14:36:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751812592; bh=LQvOsrvAxtIF9zfBp3smdp/HiFPvr9jOTvuEZPP26Xw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rFvLJZHcU29O0N3LGnbtxWxip20YjNqI8oyhqdO0sYhjqsj7lTGgiv+R5o3LI5UUc +179CqJfuBWah9qpMn9Wi8YeSrbVF/6LhBghNhADHlnV54hWbDAtxYYTaE5wOyYJcx dXgb6DlCZYOdwY0H7GyH6S4dLae8azwQfDaFswhN8Vu2kEc/h+thqGkp4gPGCJhLnd zjJ7RXzw87ONI8D9EUG3NVe3sdAgPbEZs1EK26TLBNCe5AX7qr1eRICotXm9MCDs5J AmgC4HsP8/KDVxz1TrBTc7vsOpD9dkFaPl6MGczb2lZqBoCAiViGtL33hMIr2oC9BH JxljwFndWfVlQ== 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 v7 3/9] vga_switcheroo: Use pci_is_display() Date: Sun, 6 Jul 2025 09:36:07 -0500 Message-ID: <20250706143613.1972252-4-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250706143613.1972252-1-superm1@kernel.org> References: <20250706143613.1972252-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 21:03:06 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 2AFD028936D; Sun, 6 Jul 2025 14:36:34 +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=1751812595; cv=none; b=XkPTmEnddd/zybYIr8ATEhAxzKMc9S0u0qis5XQOvjgz+ST1w6XmPgkTvKSigk9dofbMGg6Pm0SdREuUWNyYO6CIGp7aygqBJ/bvZWCTRpnHbl8TphPgb8oCQiCg3jvwZcWpDciUZ1272I2tMY0U3hnlYaS09NryBujvkP3DBIg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751812595; c=relaxed/simple; bh=wZDfgswU2/pwcpS3H3uILO4jDTDnQH15cewPVoii5Es=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hvoMLMyc4AQkY7bLiJoc5c3UIYqsl81eNB0q8YPPCRt6aVxLqW89rf9NMFBdDAb99/tjDAemSbyBxo99mTPzs7SE/bdxVmMaJ8FhnJcXv+u+7YbOUweMKKwF7VOoWTUwnIu5lYWtp4k5mkmill8DHyix0zR8vOcui71j6cnMzDE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fQM1EHR/; 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="fQM1EHR/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8658AC4CEF2; Sun, 6 Jul 2025 14:36:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751812594; bh=wZDfgswU2/pwcpS3H3uILO4jDTDnQH15cewPVoii5Es=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fQM1EHR/Z6qlacJYO5f2mvPCgC/6Fn3imKN60fStl6psZyMt9HfrGYOUhGzOimMhO +aKDUzLY2xJ77mzchgd8zkODC5dLmpuPUCuQEpM1j/kWqSX9WK7+gZ5Ti5g559UHEr thdwk8qAm0e9duaHbknA0s3kBRSfvelucYGWADbJPVxyh+KaCKVNctOHRChdsUD1mC shkiVSFCjjs90TTLgZMEXC5ZU1cZlPorDQy3v4cCxjEf6d6Ua2bFzepf4qFYNvsf2I neWCRvtqI/BCPnxCRqL+0b39erPFgbhcR/fdSkQzJAN/PBSl3RHOvv2JOwfMN3I+un RYW+sPWyHkqZA== 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 v7 4/9] iommu/vt-d: Use pci_is_display() Date: Sun, 6 Jul 2025 09:36:08 -0500 Message-ID: <20250706143613.1972252-5-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250706143613.1972252-1-superm1@kernel.org> References: <20250706143613.1972252-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 21:03:06 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 B78D4289E3C; Sun, 6 Jul 2025 14:36: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=1751812597; cv=none; b=bwbE6Fa0ZwUY6HlyzsHRrx1CFqXN+lQmqtuBXStbgIF0pYRut775DjvEmUQGyu08S50hge5SbdhjPongQWwTRh1RwST+pl4qMj62STh0r5Tl+z4qEHW/jC04H56lgsR7VPYtuy4VkemtU82o8Gd2qA1j0STNRF5/8lGbl7UJrHc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751812597; c=relaxed/simple; bh=IOGKTg8m2lLVk2BGnUQp473zWXZ7OF1rNECuXqPIWig=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UKVL6QQnUJZEymjnEf700zCrXez58PyHGhi51dhVo+T24G05psCRM8z5uY12uI6qJ0737I4oLo1vLtCegLFRx64rzJ0Ottv/oHKG3I612AOUAw0MdzcVG9wTc8zqTGlfJ0LZ4zOef9+HMpZDrPURxnhJdSSZSP85oYpXJaUmuG0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YxWfi23s; 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="YxWfi23s" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3204C4CEF3; Sun, 6 Jul 2025 14:36:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751812597; bh=IOGKTg8m2lLVk2BGnUQp473zWXZ7OF1rNECuXqPIWig=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YxWfi23sDAy9X7cXgFuSlqj7s43zWSmUz8rZTQl9H4vYetTG6ItJoNAZnqHXytTrS Hq8oROP4hF0ik2x3lScFmRDpj/wyFeeNuBS5n1Vyz+QTV3dmRYh1FlyPJbAXiHwTvF pFqeraxEhkrY2yRJBSIUEnmw3VANCy+RAnbDKTjCB1bxKbybzxh9A4ED9cS8f+deqs 55SAL9cF1KqoNadNJfH1TD9NRTf3xl7bdfv3Oo9flBlz/22Vdg2oHRL+ZPtcnIqAqB S8GLDIjDTCOFStl0yx5oW4DpDRgkHyn/zI793fO4Jh+4rFKVygOqzCgOn+z2XkVq9n bAvjTJuCjkhow== 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 v7 5/9] ALSA: hda: Use pci_is_display() Date: Sun, 6 Jul 2025 09:36:09 -0500 Message-ID: <20250706143613.1972252-6-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250706143613.1972252-1-superm1@kernel.org> References: <20250706143613.1972252-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 21:03:06 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 1BDA628A3FC; Sun, 6 Jul 2025 14:36:39 +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=1751812600; cv=none; b=NOJSO0CkoW1F/wBdStEveqGAoTClMvTCvnBNoRj1WLncSAay42t0jR7O0h56yG+NiDNaNgFqCdUOtnVwK/RQ0nAKVQDfWiOAHcK7Abzn6mUMwS7/TY0XG+TDPhxQ4o8ypy0EJoPdBZF+J/xJp6A2wq7wRNuht8aLsD4RuiKG2Kk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751812600; c=relaxed/simple; bh=glRBi2ARDp3d+Stsv79iYRajcXAB16Ljdcta010d3iw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y+bzwQmCiNh40dpbIyNNoWvYwhIMthpcxfloSwKHl1iVczQmohj2Xeu8dK3jqznMxllB0Sc4ZrTZr14sDQYGZtFYweUmXfd+l8OMPYsgvru6HM7urJW95JI4Cpz73+qa+Q2nBnooqsDSaAhBpFRM7g2TdDSPB1oByWrPdBB5ACM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Rb39vlJC; 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="Rb39vlJC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82A09C4CEED; Sun, 6 Jul 2025 14:36:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751812599; bh=glRBi2ARDp3d+Stsv79iYRajcXAB16Ljdcta010d3iw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rb39vlJCKeQwVdPoO/bdw5hvXKkd3cqPAyVwOMlpGBCHBuAbkPjUuOFF+Skkg3SHw Qi/4h8679eEnUCSbDGbPx5CFn6ScV+cHOdhFEdR+mGgndyfLMrRkOKalzZ0lv6D83g fHa6CLIWd0av4S4LyFmJUFDTz+kfEQuDYQLK4pPOphpNNsYQgj2L0xNSv6oXxuNCJ6 EkYNmBpK8wuvMc7GfoyeZ8iX8bRMjusJk2gCyhsON+kFJ0rQmPVMVgvw0oXhBIVKR7 xvGoboZXv3412PwIrJB/CVcAcuoDOTPljmwRv/EZDLpGR3KvDmgvVSO0/SwQR2oq87 0C44YUNKj4r8A== 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 v7 6/9] Fix access to video_is_primary_device() when compiled without CONFIG_VIDEO Date: Sun, 6 Jul 2025 09:36:10 -0500 Message-ID: <20250706143613.1972252-7-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250706143613.1972252-1-superm1@kernel.org> References: <20250706143613.1972252-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 21:03:06 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 4F77E28AAFE; Sun, 6 Jul 2025 14:36: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=1751812602; cv=none; b=ps9t8qI9Vcx3gLe+cMk+ukSGN1w7DNA/4wh3OuGL3cbB0thcubLx162mA+KPoASuzWG6sVbjoYYgODk47w4a5w9+ujaM8Cn6bDHQ3i9LI6RgGm/WwFrP97jgyKMQBAt+r69F9YSZfKEsZ/XJsodlr5tI+a/C7TJPM/jtfV0dWS8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751812602; c=relaxed/simple; bh=hely8rCeQBZS770H5X6E0gNUH0kghs8qNa/SePVXMhs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V8OivHlijofE3jEa8wpSSnh1V1TmTSZD0Mghb0hftlMU7lWNdGwOQinTehysvzrPBgVvKlMUOcvx8g7kYu924vn5+3quxE4F2Xl1zPFq5CQDBb5N+mSboBS07Ar5qz8s0ta+CMzJbh+lFmdUf4qSeOyl1iEhTQ03r3WMN3OXkcE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=N0ZgnBp9; 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="N0ZgnBp9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE09FC4CEF5; Sun, 6 Jul 2025 14:36:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751812602; bh=hely8rCeQBZS770H5X6E0gNUH0kghs8qNa/SePVXMhs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N0ZgnBp9YJ0UPchsvkNm4Jl8YLOp3FgQq3vRwPImT8zZTiwUzKbkm61vMgG44uuUp Bw6wcv+tkgc0SMhw+205GtPxxKjIixNrNNH1pZDki24F8mHiQFO7K/8AXbqBhb0YMy RR3Xsa8FB4MFQe6wKLrCzaH5u9Pnb40v0E6IdAQSO6IEnrrKVva31tS3ETN3R9eXkj VISu+08ZhhW5aPP7k12X0jDcTu4dgf6CuOwWx8qBwsuMAT7SfPCY1MHth0X886q7q/ T4c+3Ee8KmK2VfytHViGO2UxV2hYD2bQgmBULGo6JGYpTK0gTCiM/ShN4NPkmlTgRZ CmglaNfB+AmmA== 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 v7 7/9] PCI/VGA: Replace vga_is_firmware_default() with a screen info check Date: Sun, 6 Jul 2025 09:36:11 -0500 Message-ID: <20250706143613.1972252-8-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250706143613.1972252-1-superm1@kernel.org> References: <20250706143613.1972252-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 21:03:06 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 6AA57230BC9; Sun, 6 Jul 2025 14:36:44 +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=1751812604; cv=none; b=BKZHCPPCI7Uq6oNExfPQyCHxympLlEmiCSDXGTLjp6AsqjYnSCpOAxEHBzw7YfWJIbQIWXs2YGqy5OLvZbW3/mEJXaVnCwY5RD/jAzcv4/f3QLB1Pd5JqoXXSRiqlY/AukbxTHyu0joghkB18oZbU4fghys4/OFlJS/RNW/8H34= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751812604; c=relaxed/simple; bh=qucJBD1l7cekJwkkW3sSPDQAFelB6SpfdgNHX+7KrGs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e0cxjz0iGzgAdWREOEspNTpjzombqbu1+vDoVBdyY6twTkwV2fYuhPP1CfP4qkzLf24Tn0xOlFxHRio2530q4rkYop/PNOPf2kBgr7D6Z7BS7OzaHVBXXqcdznmhAnCZYRy0RxrqeN84zhz6FN2OsbrYGIm/MqWA7vtUOHOT7s8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PpbWlYDR; 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="PpbWlYDR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 341F7C4CEEF; Sun, 6 Jul 2025 14:36:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751812604; bh=qucJBD1l7cekJwkkW3sSPDQAFelB6SpfdgNHX+7KrGs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PpbWlYDRkCuGunmFT9sTtHbxSwd/gVVaMktE59Av5bQNJlpIpRWWnBMwON8LQkbBW 6gXenJkP+sbVWehgc9Qa4LZngn4VzayvaKyP4D/gf5ASSXZlb5Nr869RaVew8OnB/6 kE61VerYy9vnazyRtGJxRv8MDOupgCzJ6JB3k+P2jlvgUjPkMUX7fXh4EBt5sp4/pE O9W0Z/s5Q9iKMr63iqMxPUUSFuSKz5F64qsgf9NdYhX1RBfEbnOplk9TaDJlRXdfRx zuNEX/u0VqDtrmTAtzX598+shxngHQGeh+kFXhAikczUIzAiLs53PC4Fj2CNbZC1nW i0MO8mX+JbXqg== 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 v7 8/9] fbcon: Use screen info to find primary device Date: Sun, 6 Jul 2025 09:36:12 -0500 Message-ID: <20250706143613.1972252-9-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250706143613.1972252-1-superm1@kernel.org> References: <20250706143613.1972252-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 --- 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 Tue Oct 7 21:03:06 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 EBE7128C2DC; Sun, 6 Jul 2025 14:36:46 +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=1751812607; cv=none; b=kFNLa8c0KMm4fDcvPES1CozCYZuwtwRfM3RlI01J4FH4e0em82wFoLtGdo3EdSGNbww7Mn6BLUsweLCFD6Ym/oappIDeceegKrzoBRf3lxAUhX9Bo//NF05OKquhpkhxa0jm7IRmZKa+hM4Vd+AF+xt5S6f2jblPBM7SvYkd5SU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751812607; c=relaxed/simple; bh=mA7SFMfHy8OinIxgtmu9yWbldbYt6k6q8NSeQegNnJA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rjwmW3d+zmb44h1qe9P7JWlotp93BpNvVkho1kl7iXDCgP5ksNWONugjnP2XiV73FO86YxyIqBQJhkNWNsx2vgFNCOagQMN4aUMkaqFDtQqIdcHHiaYRaO7UvwE5imtn54z8FbIcWEhyzLX84y8RcEWkUCyXD8rfkRYtV4Q4Z8U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sYVYeC+6; 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="sYVYeC+6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7BA94C4CEF4; Sun, 6 Jul 2025 14:36:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751812606; bh=mA7SFMfHy8OinIxgtmu9yWbldbYt6k6q8NSeQegNnJA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sYVYeC+6e5OzGIchOu7GvaySxrAMZ+Bls0YeuisZup4XCUIRLsoBGtO+yoGMLuEbz BWzz0dfPhCzA6rCFKmi8QdDoeOhV3mmLqLskqGGhMFiVKHcEBvAvYWfBgNlI8N+fdI lpPH3flaG6PJJbHwr5ae62YYTCuxr5XkC2nLmfi0BP+InVH4+f3b9ETwE4p91f5LtX NXL01QEjUR0etWMbpJqif9KssgNkjfwwUywJYxEd6XRvZKTeMewbJbFfifB9L2wE1a IxlMW4hX3ZO+lWVzAAsGmTojyQt4cE9AOSC39/BlHNEPVXvwresJ6XINXMYLST9anZ 6cS53xc8Tkymg== 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 v7 9/9] PCI: Add a new 'boot_display' attribute Date: Sun, 6 Jul 2025 09:36:13 -0500 Message-ID: <20250706143613.1972252-10-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250706143613.1972252-1-superm1@kernel.org> References: <20250706143613.1972252-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