From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03DB7125D6 for ; Mon, 30 Jun 2025 06:24:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751264667; cv=none; b=uMCEyLZkUnqwKMF+BeDrPsNa+9drIJKAx94LyjEiEodyH3YjkCV7kVZcPOw3WaGd8ac8rSmf5ds8sxS7vnR3pYSV/L+iVxQ0GW2+G4UBocQregR5du1MkC/FUA4O9CHy7diWgBTn2U6+i1c1zzOt2atVHYLlNu9rfewnxscoAPw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751264667; c=relaxed/simple; bh=oIU0nlGeVkImkEVtE9FV85Qh8TUxliMwVa0aurlyVic=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=l+MOK1ehnlTNnBnOqDhMDiq7G6/mRIJ+7I2d5wNrvt3zvZiItcMP2BC3thcIrBRztepYygthrdjyKGHeNj+mFecrB4RgUctUbsbtcd2n1OzCP8Fh9jn8vZ0GcRkS2aVaDZQckbd+XfJiBT9CBtA7oINyRfY+o3lIYIY2n2eREdo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=JekC85cB; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=GGwRzyBi; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=JekC85cB; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=GGwRzyBi; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="JekC85cB"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="GGwRzyBi"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="JekC85cB"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="GGwRzyBi" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 43F2B1F38C; Mon, 30 Jun 2025 06:24:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1751264663; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=PJyKYbqfUL2wuHqkoQTXa/2DpfteGgypmUTFXMIUHEE=; b=JekC85cBCcHb3DEaAnCwMMACuYvXv0XARsQOlldGFLIsFkXSclY3qWwtQqnB6XYQEAYbfD j7V4NqbWPRF6E+FErOimaVZt27sMaF5Uy8dQuyokPkO/qxm0t2CzY3ezdk/3sKwywVzj7F gMOYpGve7HcD7sr8H2hkOtgyb6psutQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1751264663; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=PJyKYbqfUL2wuHqkoQTXa/2DpfteGgypmUTFXMIUHEE=; b=GGwRzyBir+mjkzaB6HZuN97WHsuDsbZHQboPp33uC56cilryUX3S8vfROKa8qTRlmD9cJI wbPyOQqIB6DDOtCw== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1751264663; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=PJyKYbqfUL2wuHqkoQTXa/2DpfteGgypmUTFXMIUHEE=; b=JekC85cBCcHb3DEaAnCwMMACuYvXv0XARsQOlldGFLIsFkXSclY3qWwtQqnB6XYQEAYbfD j7V4NqbWPRF6E+FErOimaVZt27sMaF5Uy8dQuyokPkO/qxm0t2CzY3ezdk/3sKwywVzj7F gMOYpGve7HcD7sr8H2hkOtgyb6psutQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1751264663; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=PJyKYbqfUL2wuHqkoQTXa/2DpfteGgypmUTFXMIUHEE=; b=GGwRzyBir+mjkzaB6HZuN97WHsuDsbZHQboPp33uC56cilryUX3S8vfROKa8qTRlmD9cJI wbPyOQqIB6DDOtCw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id A55F813983; Mon, 30 Jun 2025 06:24:22 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id lSErJ5YtYmiLVgAAD6G6ig (envelope-from ); Mon, 30 Jun 2025 06:24:22 +0000 Message-ID: <732aeb75-71e7-49e7-a5f2-2080ee94a273@suse.de> Date: Mon, 30 Jun 2025 08:24:22 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 9/9] PCI: Add a new 'boot_display' attribute To: Mario Limonciello , Bjorn Helgaas Cc: Alex Deucher , =?UTF-8?Q?Christian_K=C3=B6nig?= , David Airlie , Simona Vetter , Lukas Wunner , Maarten Lankhorst , Maxime Ripard , David Woodhouse , Lu Baolu , Joerg Roedel , Will Deacon , Robin Murphy , Alex Williamson , Jaroslav Kysela , Takashi Iwai , "open list:DRM DRIVERS" , open list , "open list:INTEL IOMMU (VT-d)" , "open list:PCI SUBSYSTEM" , "open list:VFIO DRIVER" , "open list:SOUND" , Daniel Dadap , Mario Limonciello References: <20250627043108.3141206-1-superm1@kernel.org> <20250627043108.3141206-10-superm1@kernel.org> <41587824-4a05-4ead-b24c-4729007cd663@suse.de> <8878af70-3eb8-495b-b8df-43a10285c4f5@kernel.org> Content-Language: en-US From: Thomas Zimmermann Autocrypt: addr=tzimmermann@suse.de; keydata= xsBNBFs50uABCADEHPidWt974CaxBVbrIBwqcq/WURinJ3+2WlIrKWspiP83vfZKaXhFYsdg XH47fDVbPPj+d6tQrw5lPQCyqjwrCPYnq3WlIBnGPJ4/jreTL6V+qfKRDlGLWFjZcsrPJGE0 BeB5BbqP5erN1qylK9i3gPoQjXGhpBpQYwRrEyQyjuvk+Ev0K1Jc5tVDeJAuau3TGNgah4Yc hdHm3bkPjz9EErV85RwvImQ1dptvx6s7xzwXTgGAsaYZsL8WCwDaTuqFa1d1jjlaxg6+tZsB 9GluwvIhSezPgnEmimZDkGnZRRSFiGP8yjqTjjWuf0bSj5rUnTGiyLyRZRNGcXmu6h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fn3T0TtrijKP4A SAQO9xD1Zk9/61JWk8OysuIh7MXkl0fxbRKWE93XeQBhIJHQfnc+YBLprdnxR446Sh8Wn/2D Ya8cavuWf2zrB6cZurs048xe0UbSW5AOSo4V9M0jzYI4nZqTmPxYyXbm30Kvmz0rYVRaitYJ 4kyYYMhuULvrJDMjZRvaNe52tkKAvMevcGdt38H4KSVXAylqyQOW5zvPc4/sq9c= In-Reply-To: <8878af70-3eb8-495b-b8df-43a10285c4f5@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; FREEMAIL_CC(0.00)[amd.com,gmail.com,ffwll.ch,wunner.de,linux.intel.com,kernel.org,infradead.org,8bytes.org,arm.com,redhat.com,perex.cz,suse.com,lists.freedesktop.org,vger.kernel.org,lists.linux.dev,nvidia.com]; RCPT_COUNT_TWELVE(0.00)[25]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_DN_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[amd.com:email,imap1.dmz-prg2.suse.org:helo] X-Spam-Level: X-Spam-Flag: NO X-Spam-Score: -4.30 Hi Am 27.06.25 um 17:37 schrieb Mario Limonciello: > On 6/27/2025 2:07 AM, Thomas Zimmermann wrote: >> Hi >> >> Am 27.06.25 um 06:31 schrieb Mario Limonciello: >>> 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 >>> --- >>> 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 >>> +++++++++++++++++++++++++ >> >> The code looks good. Just one more question: could this be added >> independently from the PCI bus (at a reasonable cost)? There are >> other busses that can host the boot display. Alternatively, we'd add >> this attribute per bus as needed. > > It depends upon the underlying hardware implementation.  On x86 it's > always PCI and so I realized there is a requirement that PCI resources > are setup before screen_info event works. > > That is the v5 version of this patch would have had a potential race > condition with userspace where boot_display didn't always show '1' if > userspace read it too quickly. > > Other architecture's hardware implementation might have similar problem. > > So in summary I think it would be better to do it per-bus.  If we > realize there is indeed code duplication we can always move this to a > common helper at that point. Ok, makes sense. With the kernel test robot's issues fixed: Reviewed-by: Thomas Zimmermann I guess that interface also needs some sort of OK from user-space devs? Best regards Thomas > >> >> Best regards >> Thomas >> >>>   2 files changed, 54 insertions(+) >>> >>> diff --git a/Documentation/ABI/testing/sysfs-bus-pci >>> b/Documentation/ ABI/testing/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: >>>             # 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" >>>   #ifndef ARCH_PCI_DEV_GROUPS >>> @@ -679,6 +680,13 @@ const struct attribute_group *pcibus_groups[] = { >>>       NULL, >>>   }; >>> +static ssize_t boot_display_show(struct device *dev, struct >>> device_attribute *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; >>>   } >>> +/** >>> + * 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 = { >>>   int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev) >>>   { >>> +    int retval; >>> + >>>       if (!sysfs_initialized) >>>           return -EACCES; >>> +    retval = pci_create_boot_display_file(pdev); >>> +    if (retval) >>> +        return retval; >>> + >>>       return pci_create_resource_files(pdev); >>>   } >>> @@ -1671,6 +1716,7 @@ void pci_remove_sysfs_dev_files(struct pci_dev >>> *pdev) >>>       if (!sysfs_initialized) >>>           return; >>> +    pci_remove_boot_display_file(pdev); >>>       pci_remove_resource_files(pdev); >>>   } >> > -- -- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)