Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp576587rdb; Thu, 19 Oct 2023 12:33:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGLdXGDovtbWHuVy3C/WRk1RNtpBNvFwpdFeDBlwJkTcH4aTadW+tRHkeFRynRS7NK0iyw5 X-Received: by 2002:a92:d289:0:b0:34f:b9e8:a431 with SMTP id p9-20020a92d289000000b0034fb9e8a431mr3336613ilp.22.1697743983590; Thu, 19 Oct 2023 12:33:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697743983; cv=none; d=google.com; s=arc-20160816; b=vU7LkYAzWNbXBuDlsPVAjFeNnIDCNTL2/pA+cy8sWHt6QXZAzmkeRLpx9Jyxlv7GLp U3ZvjFzodHlxaaQE0wEO/JCSswYO3FCF0n8r7iB7XVasyNf2p9lR4CpZN1vGmi7eyU9y cBgahswBzGLAarkJj/bNtdYgjCRHCWx1FLW4pM0RHP0z+uThHQDOMccvBOmsk4jw3vJJ ff1KZwrj1PVQGucom6ObP7qIbFTipSMQKJVq104jqwkfSC3/MivwJ2qz5z6NYLPn35d4 0MOdF+UT4RhHmYyj3bRoaLyhzXMRJWfx8RhnSYaPjlMWaww86OiiQmplmCw2LS7yJhLU Mdpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=KviIu8D9Tj5y12Ezpy9AcLtgPA6T3vAMuFl6g83mUJw=; fh=XFCISx7/96JUOJY2zXaUBTRNhcGCZ6QtVlWvmGbo2xk=; b=vA6RwvdLT6+7GMlG9PDYi8r01nxwezQAbWtHen1PbW0F1vY3I0QAvKP6CH13zU/9Qw t/GBHcmbvUl+uZdf6cpndZVPPDLzNgRcad1n/xGxGB1xYQ7kY/SpWMJ33te+euvCMnqt ycQsrOzKnFp2CCvK8XyWkJiSq02DQdg4HgpOG2b3vicmajgIhMVK9ycRUEae71HGoPLI 0WS8dbVxeA3fxtmJps4ZjPXRqXdI96eK5pPAzo7MrZNhKB9dt3S3oJcnCjLzN4eNMxez 1RETk4Uaq2mARKkA0Q6W5VoTIX52YGuDZPP20SYdAUuPzgK/jezjrV0yKJzElyn+zLiW CJFw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id a1-20020aa794a1000000b006bd9ff6dab2si266958pfl.377.2023.10.19.12.33.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 12:33:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 6C0708270DE6; Thu, 19 Oct 2023 12:33:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346513AbjJSTcz (ORCPT + 99 others); Thu, 19 Oct 2023 15:32:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346117AbjJSTcx (ORCPT ); Thu, 19 Oct 2023 15:32:53 -0400 Received: from bmailout3.hostsharing.net (bmailout3.hostsharing.net [IPv6:2a01:4f8:150:2161:1:b009:f23e:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC1D9132 for ; Thu, 19 Oct 2023 12:32:51 -0700 (PDT) Received: from h08.hostsharing.net (h08.hostsharing.net [IPv6:2a01:37:1000::53df:5f1c:0]) (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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "*.hostsharing.net", Issuer "RapidSSL Global TLS RSA4096 SHA256 2022 CA1" (verified OK)) by bmailout3.hostsharing.net (Postfix) with ESMTPS id CC462100E5F4B; Thu, 19 Oct 2023 21:32:46 +0200 (CEST) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 9C9FC5A98A; Thu, 19 Oct 2023 21:32:46 +0200 (CEST) Date: Thu, 19 Oct 2023 21:32:46 +0200 From: Lukas Wunner To: Bjorn Helgaas Cc: Alistair Francis , bhelgaas@google.com, linux-pci@vger.kernel.org, Jonathan.Cameron@huawei.com, alex.williamson@redhat.com, christian.koenig@amd.com, kch@nvidia.com, gregkh@linuxfoundation.org, logang@deltatee.com, linux-kernel@vger.kernel.org, chaitanyak@nvidia.com, rdunlap@infradead.org, Alistair Francis Subject: Re: [PATCH v9 2/3] PCI/DOE: Expose the DOE features via sysfs Message-ID: <20231019193246.GA16112@wunner.de> References: <20231013034158.2745127-2-alistair.francis@wdc.com> <20231019165829.GA1381099@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231019165829.GA1381099@bhelgaas> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 19 Oct 2023 12:33:02 -0700 (PDT) On Thu, Oct 19, 2023 at 11:58:29AM -0500, Bjorn Helgaas wrote: > On Fri, Oct 13, 2023 at 01:41:57PM +1000, Alistair Francis wrote: > > + xa_for_each(&pdev->doe_mbs, index, doe_mb) { > > + xa_for_each(&doe_mb->feats, j, entry) > > + return a->mode; > > + } > > + > > + return 0; > > The nested loops that don't test anything look a little weird and > maybe I'm missing something, but this looks like it returns a->mode if > any mailbox with a feature exists, and 0 otherwise. > > Is that the same as this: > > if (pdev->doe_mbs) > return a->mode; > > return 0; > > since it sounds like a mailbox must support at least one feature? In theory it's the same, in practice there *might* be non-compliant devices which lack support for the discovery feature. > > + attrs[i].attr.name = kasprintf(GFP_KERNEL, > > + "0x%04lX:%02lX", vid, type); > > What's the rationale for using "0x" on the vendor ID but not on the > type? "0x1234:10" hints that the "10" might be decimal since it lacks > "0x". > > Suggest lower-case "%04lx:%02lx" either way. > > FWIW, there's no "0x" prefix on the hex vendor IDs in "lspci -n" > output and dmesg messages like this: > > pci 0000:01:00.0: [10de:13b6] type 00 The existing attributes "vendor", "device" etc do emit the "0x". From drivers/pci/pci-sysfs.c: pci_config_attr(vendor, "0x%04x\n"); pci_config_attr(device, "0x%04x\n"); pci_config_attr(subsystem_vendor, "0x%04x\n"); pci_config_attr(subsystem_device, "0x%04x\n"); pci_config_attr(revision, "0x%02x\n"); pci_config_attr(class, "0x%06x\n"); > I try hard to avoid calling *anything* from the > pci_create_sysfs_dev_files() path because it has the nasty > "sysfs_initialized" check and the associated pci_sysfs_init() > initcall. What's the purpose of sysfs_initialized anyway? It was introduced by this historic commit: https://git.kernel.org/tglx/history/c/f6d553444da2 Can PCI_ROM_RESOURCEs appear after device enumeration but before the late_initcall stage? If sysfs_initialized is only needed for PCI_ROM_RESOURCEs, can we constrain pci_sysfs_init() to those and avoid creating all the other runtime sysfs attributes in the initcall? Thanks, Lukas