From nobody Mon Oct 6 11:53:55 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 8836B28C5B4; Tue, 22 Jul 2025 04:10:57 +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=1753157457; cv=none; b=Q0WgATTRKmgQGhKv4Nw3JxPlYhmr1aWT4nFKBhqI+bBOMIlIck0SnVJ7zK2Rpal2xntqtTZClchr/Z8dr74QcWK9nSxyJwpqmKGImj4i9AyzFRUjr5koQZDhwoWM+haS1IDb1BgLN+fEGN5c6ypHctYdf0gDt+AQFHQgva/K82s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753157457; c=relaxed/simple; bh=SO48SSCClsG29iB6kfZExF+7QC9O2KIYl8N/lhW/E3E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LDfqd8WBndP/SrQvW+OV1lCjTUPZHYVKKpQCUSH3RH9dIUNbPA39YjIBTxae/FtT3pUqeMytWi3sMYKz6+BuvyZrJudf67VBuSObRPKZ6nFDt8BLR42TAkshZdD1qxHmlk8k0qJbMNgAYgW1d0+wUOffZ7MRQ43BD1l9tLaiwLo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Zm37Brpw; 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="Zm37Brpw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43952C4CEEB; Tue, 22 Jul 2025 04:10:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753157457; bh=SO48SSCClsG29iB6kfZExF+7QC9O2KIYl8N/lhW/E3E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zm37BrpwNNJGZf7gdSZ7nb4nX5sBFrgvk543/IQLqHvVXizjVJtPpv8ABkBhAkOfY 4cS4vYR5s8mRTGGHYSG/7EVVvZt5CgWjyHKes7xXj1Ajmm3NI2MYrhXLKJZ+s+WpQI bAEk5d9Q/EHBdrDC8Db62c/qYgPYbfEC0AE/pDxtwv2uQkTMeClBnt48MkTHLryodw 3m8DUwzm0pQ9Qe0KXUQAjoY6bGN3/S4sh2aSlOWWjVb4r9fvwTbD1ZdkmjKARfJ0Kb n2h6eaypw5/TJlm1bvp86GcpQ0eJEAAdCz4U6ym9TTAAOOZPgGj5u8obeSdEEv+TCw mnvWDDDWfVv0Q== From: Mario Limonciello 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 Subject: [PATCH v5 1/2] fbcon: Stop using screen_info_pci_dev() Date: Mon, 21 Jul 2025 23:10:50 -0500 Message-ID: <20250722041051.3354121-2-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250722041051.3354121-1-superm1@kernel.org> References: <20250722041051.3354121-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 screen_info_pci_dev() relies upon resources being set up for devices before walking and thus isn't a good candidate for video_is_primary_device() when called as part of PCI device initialization. The device argument passed to video_is_primary_device() already has the necessary information. Check that directly instead. Suggested-by: Bjorn Helgaas Signed-off-by: Mario Limonciello --- arch/x86/video/video-common.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/x86/video/video-common.c b/arch/x86/video/video-common.c index 4bbfffec4b640..e0aeee99bc99e 100644 --- a/arch/x86/video/video-common.c +++ b/arch/x86/video/video-common.c @@ -30,6 +30,8 @@ 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 @@ -45,8 +47,14 @@ bool video_is_primary_device(struct device *dev) return true; =20 #ifdef CONFIG_SCREEN_INFO - if (pdev =3D=3D screen_info_pci_dev(si)) - return true; + 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 =20 return false; --=20 2.48.1 From nobody Mon Oct 6 11:53:55 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 13C8E287261; Tue, 22 Jul 2025 04:10:59 +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=1753157459; cv=none; b=sPaOMfdMKN3mkW0xwF+2R0aoLoOZl1rRWIoxxaFKky+BTJVpV2+xMYAEqTp1gspc1rZm9SveFPRjf8Yj2VEZR3r1nOI3baMyGReSLQFfZ4DHGvtIO/myBZNNZT12BOKjbMzwRxpdv7UlrsgN3NNktxpaipiqZ41S53LWZbibCJE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753157459; c=relaxed/simple; bh=5pRINa2Uw1HJ6EfpIJKtL5DXahUnPGMFtESCs6BNIqk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sL6EIhDBKb+nzpskXh7CiuwnWalSFcVDs7lHgajf/jp8uJA9+T/agKtvo18DafqcxwSJxX48CUvHnKVIgICEdV8mGC9KRrkGD5aKm+QAJgj3o9gNcsdMU6lHy0X6hoWznIjc3ZCju9uTVonl0HxsQ+M560jrhEpwUbXTqM+PrSM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=buD7Ak1k; 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="buD7Ak1k" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A58EEC4CEF1; Tue, 22 Jul 2025 04:10:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753157458; bh=5pRINa2Uw1HJ6EfpIJKtL5DXahUnPGMFtESCs6BNIqk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=buD7Ak1k7SYer/ngoEjMz6g9j9J2Lrb6uOlA4vixmgTpJl6hj8FNeY4DCyHovW0Ze 8FQkMj/zZw3iVjlBz4gtk32WTb37m7LFfw0ozc8AQDQ34cqUXyBjid1f6/y09lM0Mk I9+GvWDSZ+g7zD7FuLvJftEmXNw/coA2FgWDLMTZKtYGPxJ3F/17pGsRN1z8ov7w37 kmT9LEchVbHDohgI50JMCr3OFvxycA9l2NiPmM3oU5eZo9O7bhP46RU4Odn+PPtYuR 11SJgYW1wk55SlprO8YYrg61/ytmBwjRuawljxXuKdUQ6UaxQSZTY7Myht1uGc/uPJ 5L0mPcG7e74Qw== From: Mario Limonciello 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 , Stephen Rothwell Subject: [PATCH v5 2/2] PCI: Adjust visibility of boot_display attribute instead of creation Date: Mon, 21 Jul 2025 23:10:51 -0500 Message-ID: <20250722041051.3354121-3-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250722041051.3354121-1-superm1@kernel.org> References: <20250722041051.3354121-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 There is a desire to avoid creating new sysfs files late, so instead of dynamically deciding to create the boot_display attribute, make it static. This also fixes a compilation failure when compiled without CONFIG_VIDEO on sparc. Reported-by: Stephen Rothwell Closes: https://lore.kernel.org/linux-next/20250718224118.5b3f22b0@canb.auu= g.org.au/ Signed-off-by: Mario Limonciello --- v5 * Fixups for comma and CONFIG_VIDEO * Drop sysfs_update_group() as it's no longer needed * Drop pointers in pci_boot_display_visible() v3: * Move to pci_sysfs_init() v2: * Change to sysfs_update_group() instead --- drivers/pci/pci-sysfs.c | 58 ++++++++++++++--------------------------- 1 file changed, 20 insertions(+), 38 deletions(-) diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 6b1a0ae254d3a..f5d98795a12fe 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -1059,37 +1059,6 @@ 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 @@ -1691,17 +1660,30 @@ static const struct attribute_group pci_dev_resourc= e_resize_group =3D { .is_visible =3D resource_resize_is_visible, }; =20 -int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev) +static struct attribute *pci_display_attrs[] =3D { + &dev_attr_boot_display.attr, + NULL +}; + +static umode_t pci_boot_display_visible(struct kobject *kobj, + struct attribute *a, int n) { - int retval; + if (video_is_primary_device(kobj_to_dev(kobj))) + return a->mode; =20 + return 0; +} + +static const struct attribute_group pci_display_attr_group =3D { + .attrs =3D pci_display_attrs, + .is_visible =3D pci_boot_display_visible, +}; + +int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev) +{ 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 @@ -1716,7 +1698,6 @@ 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 @@ -1845,6 +1826,7 @@ static const struct attribute_group pcie_dev_attr_gro= up =3D { =20 const struct attribute_group *pci_dev_attr_groups[] =3D { &pci_dev_attr_group, + &pci_display_attr_group, &pci_dev_hp_attr_group, #ifdef CONFIG_PCI_IOV &sriov_pf_dev_attr_group, --=20 2.48.1