From nobody Fri Sep 5 18:07:48 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 0E71C1A9FAA; Mon, 11 Aug 2025 16:26:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754929574; cv=none; b=bhlaLApf/TbvAAk5/ETtBVALfthJg3g9qJH21gn6iXtwjf/pe35oTm7nMbc1l9Fy9yExRAsPnUTKJQMRKBgUw+/ory5rGOYWN3BlHmw/lpnAuAu7T0X60Y4Ewk0ijUquGEh+I5RM+nuwiqa2WtkZrSS+mqD2mFA+o/a6UQsQdls= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754929574; c=relaxed/simple; bh=uFYe+G36sd4L7j61HsBQZ7yPuWGZRAjmRmKIjuj/FEM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SLf9w2y3TM0x48ThEhQdSTiHPjaYONXN/Bl/o6rclb6SHbj9c8NmU/Jfc/6z0ov+Nbq9b3Qub46ZiIsCi5HVsIB9GaJ69eVkKA1EgBcVFKHjiJYYu6i09dSb9moft/h44fF8YJ5ui4nowtO0uTT79QX1rLl/HnRQY71chhPXFRg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dLawpBrg; 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="dLawpBrg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54BD7C4CEF4; Mon, 11 Aug 2025 16:26:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1754929573; bh=uFYe+G36sd4L7j61HsBQZ7yPuWGZRAjmRmKIjuj/FEM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dLawpBrgoiOKtfh3SIlQtUgQLdnoyaOslY3yx2+bBBD9L2BUoNc0eK6W7A4mFItmR NwPyFT8A8TrAoEGCybsGx9q9slb+Fj3EdaRwRVHnVF+4lkQkJg77Am/kMk7EIeXHeA e1JXknwxu6ffHq7rb2UQlRhVG0qY/fUFZVtMTgAS4PNaPxLxzixun879GJ31tzrxJA xslpItQbqzGV1aEqzXlup/oukASsjeenHFPakvVxtUaBX1RLv9rxuekB+57g34q4ei yxEhdio5t741m2+r2DHqFhilO+j3/ts/P7KKGo9Zu3rGnWf6Nn7QRYiyTmEF0BZCzw /PymKN3kKgDiQ== From: "Mario Limonciello (AMD)" To: David Airlie , Bjorn Helgaas Cc: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , dri-devel@lists.freedesktop.org (open list:DRM DRIVERS), linux-kernel@vger.kernel.org (open list), linux-pci@vger.kernel.org (open list:PCI SUBSYSTEM), Daniel Dadap , "Mario Limonciello (AMD)" , kernel test robot Subject: [PATCH v10 1/4] Fix access to video_is_primary_device() when compiled without CONFIG_VIDEO Date: Mon, 11 Aug 2025 11:26:03 -0500 Message-ID: <20250811162606.587759-2-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250811162606.587759-1-superm1@kernel.org> References: <20250811162606.587759-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" 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 (AMD) --- v10: * Rebase on 6.17-rc1 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 Fri Sep 5 18:07:48 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 77AA42475F7; Mon, 11 Aug 2025 16:26:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754929575; cv=none; b=R38OKQY2fgbBgPDh+F3oALG8+t9xmeWqGVF1OXZ+TUVx6Q2hxFSx+AD9hXlA1uI2/8j6E7PUZ4XBx8mTmnNWzfZtxUF8BMazZO0MDDfX04Fe1oT/3Pl9FNrjX9827ZlDjJ+H0Uq46G4+/AiNO82RGS0RbPBhMGbmmYxMIzuYOXE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754929575; c=relaxed/simple; bh=3qWKQM0HeorWqsuGJKtJ97sthSR1l4jtNX1BHSpBD1E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d2PDCanTojlx5UnJ13tq3r/926uK4qKNnQKaYG+7CMafWjyRivrdeQ/FivtQluCYjbk0DWFPyp4jJOJP/c0O4JNidU4Ertg0HSl97I8GhP6U/43n63MXyRoVrQkgI9o94oIsC7hDAMg9tFYmkRDDQw+WslrwjysBIqRjB6E/eX0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YOk9zvjI; 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="YOk9zvjI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E26C9C4CEF8; Mon, 11 Aug 2025 16:26:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1754929575; bh=3qWKQM0HeorWqsuGJKtJ97sthSR1l4jtNX1BHSpBD1E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YOk9zvjI403VpTO2HOJ64iKT6OeNpu0nCB2AK2EvA4q+UAc/taaEHbm6M0S8r/Asn ESm1wZ8m8CcBIe3RCrFuk5taAeBXUPia44525IAPKom/B5NemGwFXe6fsSxxV+0ayZ dpPbn+a8rTgfnwh6myX/LjYwa+bRBXr9Q99SBdGOJptXd4XaVdTAl68fOEDWGJgHdK GziqtMtCCXkFMa3ubGoAxbWUcUJvcY6VWIJxvwUbd1MFLTRREcmZTHlHLC1+azKeYp fdugt0DypSFz5eKM1CUN42LST8V26IrqWmq/J1j4Mqy9t3hMMS4XDIxnEWAIwUclL7 Bu1R/3Y6IL3Lw== From: "Mario Limonciello (AMD)" To: David Airlie , Bjorn Helgaas Cc: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , dri-devel@lists.freedesktop.org (open list:DRM DRIVERS), linux-kernel@vger.kernel.org (open list), linux-pci@vger.kernel.org (open list:PCI SUBSYSTEM), Daniel Dadap , "Mario Limonciello (AMD)" Subject: [PATCH v10 2/4] PCI/VGA: Replace vga_is_firmware_default() with a screen info check Date: Mon, 11 Aug 2025 11:26:04 -0500 Message-ID: <20250811162606.587759-3-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250811162606.587759-1-superm1@kernel.org> References: <20250811162606.587759-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" 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 (AMD) --- v10: * Rebase on 6.17-rc1 --- 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 Fri Sep 5 18:07:48 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 E242B296BC1; Mon, 11 Aug 2025 16:26:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754929577; cv=none; b=egxaeAUyvkDGjh4I/LbH5ku9+w77Mx1Q2zexrjpPiq4lTNZvbFEfdVW07WHNVnrU1wEiEHpfAoG2M/6CWpdnkseK8i4oLCjgB8KVMPNxX2HSzPzrWNc2alMSZOL08aNYDo4fn7yMadWwwCEyPtcev7atB2j31myGLs+NSgsMRlk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754929577; c=relaxed/simple; bh=Uy45rFF3sSENBdoxYFFYHSypKn6OdyziyptjHlCs8G8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mjj1EHA/S3o8TCs3I34XDS0Epoq/M6uIAJb11Fnwa3glTiXO7RoOOGo2WaVhpAlfP4I2c9ON5H6Dho++d1FppWyLcjGG5wOc8Xlsirb7jw1Opby0pKz+G+ZRzfxkzWBzDRKyG2HxrUNm0EevLG6c1/7Jfd38JqgpsnFuoKM/zvs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dy9ekQLR; 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="dy9ekQLR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4EEE6C116D0; Mon, 11 Aug 2025 16:26:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1754929576; bh=Uy45rFF3sSENBdoxYFFYHSypKn6OdyziyptjHlCs8G8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dy9ekQLR6mkD5W85Bjo49dz/1HO73Li7IDAC8Ly4zTqjn6w5SMXnS3h65k4ymMQ8P GQzfcTHFRNfz+FdAC0Som2Dvz4XPWPqrIGi4M1/SM3jRER3FaLRKF+79TAwCn8DZma GuoltQeoSQU6uaFnh9gGrCvarsLTcfyX7z0Go2a1x0/MRPCTvhocHdWmttL5yi8lD4 oGY8ECiolEWrqtLXNhIb2jvsGE/yWDOWWDMkTvjcjw7yG33snK6UqxhEsWP/aLIVLP rwMfXb/mny/Z+cZQAVSOYRik8mqtkQF+6AAoDiDIkTZSGjSpJoUURU5KdqDodD+15s wWMpDmV8auuVA== From: "Mario Limonciello (AMD)" To: David Airlie , Bjorn Helgaas Cc: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , dri-devel@lists.freedesktop.org (open list:DRM DRIVERS), linux-kernel@vger.kernel.org (open list), linux-pci@vger.kernel.org (open list:PCI SUBSYSTEM), Daniel Dadap , "Mario Limonciello (AMD)" Subject: [PATCH v10 3/4] fbcon: Use screen info to find primary device Date: Mon, 11 Aug 2025 11:26:05 -0500 Message-ID: <20250811162606.587759-4-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250811162606.587759-1-superm1@kernel.org> References: <20250811162606.587759-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" 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 Suggested-by: Bjorn Helgaas Signed-off-by: Mario Limonciello (AMD) Reviewed-by: Bjorn Helgaas --- v10: * Rebase on 6.17-rc1 * Squash 'fbcon: Stop using screen_info_pci_dev()' --- arch/x86/video/video-common.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/arch/x86/video/video-common.c b/arch/x86/video/video-common.c index 81fc97a2a837a..e0aeee99bc99e 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,11 @@ EXPORT_SYMBOL(pgprot_framebuffer); =20 bool video_is_primary_device(struct device *dev) { +#ifdef CONFIG_SCREEN_INFO + struct screen_info *si =3D &screen_info; + struct resource res[SCREEN_INFO_MAX_RESOURCES]; + ssize_t i, numres; +#endif struct pci_dev *pdev; =20 if (!dev_is_pci(dev)) @@ -34,7 +40,24 @@ 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 + numres =3D screen_info_resources(si, res, ARRAY_SIZE(res)); + for (i =3D 0; i < numres; ++i) { + if (!(res[i].flags & IORESOURCE_MEM)) + continue; + + if (pci_find_resource(pdev, &res[i])) + return true; + } +#endif + + return false; } EXPORT_SYMBOL(video_is_primary_device); =20 --=20 2.43.0 From nobody Fri Sep 5 18:07:48 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 80317296BD2; Mon, 11 Aug 2025 16:26:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754929579; cv=none; b=mi6Zn8u2bZFjp+6xR4svV1bUhXKTJ0ovw7NMqImZiCt7QxDfdKwlLr9OcZuVAkZGlH1HVT/kYja1aSO0v6ToSIEr5peIJktbQ8N3qWC2ESltxcA0Em97NbxlkUyADOM4KLJr7m3LLmkvELjHolFJjzZFKEAtgqTlbER/3s72cVc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754929579; c=relaxed/simple; bh=8oRjOADqIdvBLd9hq9nnySSZk2IXEYoBELHbgdaVSds=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lbFD8mPfWfJEobJryZ6cp0sELGU05bo4OFuf8h+35K+hygeCyUi/WiuMROWMYQCPJK92tWQY++qetwnn9YTjsfchiLu2pi1APTUX7PzkbsYI0/G5fies2j4wXSDe9p3+jfB/GTs+Pk3+ANpMqInwSZXQeqphiJKYkfdiycdfPRM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JA8t82pJ; 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="JA8t82pJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD920C4CEF5; Mon, 11 Aug 2025 16:26:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1754929578; bh=8oRjOADqIdvBLd9hq9nnySSZk2IXEYoBELHbgdaVSds=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JA8t82pJkPjKwB+BlXaucrt1METmOINHLzIeCi5xMpoqQNjpu407Y4+1s1PVvGv2V LNyfzFvh9geK+9rERIb7bSQ0nja/LGjn9o+0grASJUUUkVWHORObFrmNYRMpYwqpYH xvEbIAxj0YmfIow5lZPs/mH5fvq/62BdgqocYSzg2ofgoN3YmefAAlj1PUGXp+1GZc OthtooKItDvn584oVD62xdZ5LVZYkeAqk1Sk8k9HJxDbM7OheAEODvrZjd9bt//ZNT OdlC5VBSSB3H/H8aA5PfwXNJPEA4dl/f4sUeCZEZZkGhd7uaDVjlLX8G6xozUJjEgV KcKLzbiFqD56Q== From: "Mario Limonciello (AMD)" To: David Airlie , Bjorn Helgaas Cc: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , dri-devel@lists.freedesktop.org (open list:DRM DRIVERS), linux-kernel@vger.kernel.org (open list), linux-pci@vger.kernel.org (open list:PCI SUBSYSTEM), Daniel Dadap , "Mario Limonciello (AMD)" , Manivannan Sadhasivam Subject: [PATCH v10 4/4] DRM: Add a new 'boot_display' attribute Date: Mon, 11 Aug 2025 11:26:06 -0500 Message-ID: <20250811162606.587759-5-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250811162606.587759-1-superm1@kernel.org> References: <20250811162606.587759-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" 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 the PCI device was used for driving the display. Suggested-by: Manivannan Sadhasivam Acked-by: Manivannan Sadhasivam Link: https://gitlab.freedesktop.org/xorg/lib/libpciaccess/-/issues/23 Signed-off-by: Mario Limonciello (AMD) --- v10: * Rebase on 6.17-rc1 * Drop Thomas' tag, as this is now in a totally different subsystem (although same code) * Squash "Adjust visibility of boot_display attribute instead of creation" * Squash "PCI: Move boot display attribute to DRM" --- Documentation/ABI/testing/sysfs-class-drm | 8 +++++ drivers/gpu/drm/drm_sysfs.c | 41 +++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-drm diff --git a/Documentation/ABI/testing/sysfs-class-drm b/Documentation/ABI/= testing/sysfs-class-drm new file mode 100644 index 0000000000000..d23fed5e29a74 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-class-drm @@ -0,0 +1,8 @@ +What: /sys/class/drm/.../boot_display +Date: January 2026 +Contact: Linux DRI 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/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c index a455c56dbbeb7..b01ffa4d65098 100644 --- a/drivers/gpu/drm/drm_sysfs.c +++ b/drivers/gpu/drm/drm_sysfs.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include =20 @@ -30,6 +31,8 @@ #include #include =20 +#include + #include "drm_internal.h" #include "drm_crtc_internal.h" =20 @@ -508,6 +511,43 @@ void drm_sysfs_connector_property_event(struct drm_con= nector *connector, } EXPORT_SYMBOL(drm_sysfs_connector_property_event); =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 struct attribute *display_attrs[] =3D { + &dev_attr_boot_display.attr, + NULL +}; + +static umode_t boot_display_visible(struct kobject *kobj, + struct attribute *a, int n) +{ + struct device *dev =3D kobj_to_dev(kobj)->parent; + + if (dev_is_pci(dev)) { + struct pci_dev *pdev =3D to_pci_dev(dev); + + if (video_is_primary_device(&pdev->dev)) + return a->mode; + } + + return 0; +} + +static const struct attribute_group display_attr_group =3D { + .attrs =3D display_attrs, + .is_visible =3D boot_display_visible, +}; + +static const struct attribute_group *card_dev_groups[] =3D { + &display_attr_group, + NULL +}; + struct device *drm_sysfs_minor_alloc(struct drm_minor *minor) { const char *minor_str; @@ -531,6 +571,7 @@ struct device *drm_sysfs_minor_alloc(struct drm_minor *= minor) =20 kdev->devt =3D MKDEV(DRM_MAJOR, minor->index); kdev->class =3D drm_class; + kdev->groups =3D card_dev_groups; kdev->type =3D &drm_sysfs_device_minor; } =20 --=20 2.43.0