From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 1431222F762 for ; Wed, 2 Jul 2025 07:49:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751442581; cv=none; b=ZYwJPSH2FydQN0rk0uA3UGw4Zrk3S72K5Bl7oWwzDwAz5q15BinnCeWY0wD/iRqYBoiOZR/S4n/QVIKqS3Rd8+K5r3QWFuiAYZjyL/okskqWtptfQ+B8baUJjuxBCwMXOF1hhqKUu+qoKmKYb3REXIHVM3CsxrmgHjXmS1oXxoU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751442581; c=relaxed/simple; bh=90eOtoDZR87XEjTT5OSrKcgQ+qlNMG8Uc+U/vnDdH1w=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=CwwL8muaSjZaa1cZzxqA6xxLSncavHuvs1Fp8yi9aMDRRaxAN9/m7oaw/T36ed9dayiW3QQZazM0oJKg1YoyXaZraNgcCLxvdpx2p+GiieIKo7JovuxbdMbbzPCQxITR/eXdkdwxp5hXj4QIQtWY20er0xEd1FxNjsfELGYdBZg= 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=oz3WEWgg; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=c6+OnuAK; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=oz3WEWgg; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=c6+OnuAK; arc=none smtp.client-ip=195.135.223.130 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="oz3WEWgg"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="c6+OnuAK"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="oz3WEWgg"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="c6+OnuAK" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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-out1.suse.de (Postfix) with ESMTPS id 31CD62111F; Wed, 2 Jul 2025 07:49:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1751442577; 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=5qgNZZo+UhrOw0qZY5yzCbxyS0sZdhvhyBwDFlNZPn0=; b=oz3WEWggc4R2HbV+0+aBPK1Y4RXZcIi7eBbXCZ3EUjcEJYUISWyZOfEEQKRlJzF2QYtVtm ZTzk4NmRlRThEsLY2ImfBhTn7L9aGgH6w0ndqs1uKk+QtPrRToWYrRK0yN8VZJlQuSeif6 YgR6+CZfcXqmuC5EkymSxi0yMWnlxEY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1751442577; 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=5qgNZZo+UhrOw0qZY5yzCbxyS0sZdhvhyBwDFlNZPn0=; b=c6+OnuAKYY9awBdfeywvmh/5Gc+JIqt5Hl6RyTduPv+ZgHTefqJqPsT5+irWeoLvJHFmYs U82NN1d5cKdzJ3Dg== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=oz3WEWgg; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=c6+OnuAK DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1751442577; 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=5qgNZZo+UhrOw0qZY5yzCbxyS0sZdhvhyBwDFlNZPn0=; b=oz3WEWggc4R2HbV+0+aBPK1Y4RXZcIi7eBbXCZ3EUjcEJYUISWyZOfEEQKRlJzF2QYtVtm ZTzk4NmRlRThEsLY2ImfBhTn7L9aGgH6w0ndqs1uKk+QtPrRToWYrRK0yN8VZJlQuSeif6 YgR6+CZfcXqmuC5EkymSxi0yMWnlxEY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1751442577; 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=5qgNZZo+UhrOw0qZY5yzCbxyS0sZdhvhyBwDFlNZPn0=; b=c6+OnuAKYY9awBdfeywvmh/5Gc+JIqt5Hl6RyTduPv+ZgHTefqJqPsT5+irWeoLvJHFmYs U82NN1d5cKdzJ3Dg== 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 956D213A24; Wed, 2 Jul 2025 07:49:36 +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 s2TeIpDkZGjoQQAAD6G6ig (envelope-from ); Wed, 02 Jul 2025 07:49:36 +0000 Message-ID: Date: Wed, 2 Jul 2025 09:49:36 +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 , David Airlie Cc: Alex Deucher , =?UTF-8?Q?Christian_K=C3=B6nig?= , 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 , Bjorn Helgaas 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> <732aeb75-71e7-49e7-a5f2-2080ee94a273@suse.de> <8f9efe23-c774-477d-97ad-8e22532ad6b2@kernel.org> Content-Language: en-US From: Thomas Zimmermann Autocrypt: addr=tzimmermann@suse.de; keydata= xsBNBFs50uABCADEHPidWt974CaxBVbrIBwqcq/WURinJ3+2WlIrKWspiP83vfZKaXhFYsdg XH47fDVbPPj+d6tQrw5lPQCyqjwrCPYnq3WlIBnGPJ4/jreTL6V+qfKRDlGLWFjZcsrPJGE0 BeB5BbqP5erN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EQEAAcLAdgQYAQgAIAIbDBYhBHIX+6yM6c9jRKFo5WgNwR1TC3ojBQJftOH6AAoJEGgNwR1T C3ojVSkIALpAPkIJPQoURPb1VWjh34l0HlglmYHvZszJWTXYwavHR8+k6Baa6H7ufXNQtThR yIxJrQLW6rV5lm7TjhffEhxVCn37+cg0zZ3j7zIsSS0rx/aMwi6VhFJA5hfn3T0TtrijKP4A SAQO9xD1Zk9/61JWk8OysuIh7MXkl0fxbRKWE93XeQBhIJHQfnc+YBLprdnxR446Sh8Wn/2D Ya8cavuWf2zrB6cZurs048xe0UbSW5AOSo4V9M0jzYI4nZqTmPxYyXbm30Kvmz0rYVRaitYJ 4kyYYMhuULvrJDMjZRvaNe52tkKAvMevcGdt38H4KSVXAylqyQOW5zvPc4/sq9c= In-Reply-To: <8f9efe23-c774-477d-97ad-8e22532ad6b2@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_TO(0.00)[kernel.org,gmail.com]; FUZZY_BLOCKED(0.00)[rspamd.com]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCPT_COUNT_TWELVE(0.00)[25]; TO_DN_ALL(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:106:10:150:64:167:received,2a07:de40:b281:104:10:150:64:97:from]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; MID_RHS_MATCH_FROM(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[amd.com:email,suse.de:dkim,suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns] X-Spam-Level: X-Spam-Flag: NO X-Rspamd-Queue-Id: 31CD62111F X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Score: -4.51 Hi Am 30.06.25 um 20:37 schrieb Mario Limonciello: > On 6/30/2025 2:24 AM, Thomas Zimmermann wrote: >> 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 > > Thanks, I've got a fix locally for it. >> >> I guess that interface also needs some sort of OK from user-space devs? >> > > Who needs to OK it?  I do have MR's for matching userspace > implementations mentioned in the cover letter already. The MRs are the right place. Maybe ask Dave Airlie for a comment. He was most outspoken against the original approach. Best regards Thomas > >> 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)