Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp588856rdb; Thu, 19 Oct 2023 13:01:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF0lTPHD1sBT7qOx1CMprroQqSuE9iKmCL8NdeY5jRzrKU3XCigRqTeHjcnLDYiqKCPIRWU X-Received: by 2002:a17:90b:f97:b0:27d:262b:93ae with SMTP id ft23-20020a17090b0f9700b0027d262b93aemr2932320pjb.33.1697745693066; Thu, 19 Oct 2023 13:01:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697745693; cv=none; d=google.com; s=arc-20160816; b=UpQWRCYDK38xAvU/AhhUsKKpt5H8JS9LidekPou9SfQaSTd6tZ4AAnTx5kjwvDkjwD exQhoVydoitNq6SuWCOchBQ6uxvDI1RWQvbPdJieeky+CiDksWgwwB4WJeOs7OM4X31B eCubKUtLphWYX0h4MjEb3a5mVwR4jGMhbhOz6mqYsXVVf3whNGw1r/wMV+WO/S6VexCn deNew5hn9J4mwr8SNQVd/SfWKA5rAx6NUS8HEvG6DqFf9pP90TfqMHUEiNwU+IDX97YL xiGHiZJCJroH3a4I0YNIREaMSevRuhLHS4zE4bpwKSELyExIjNxrbkYP+BcPgapB+iFG KvKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=3dgnXH08oCPCVYtO9n0Okx4zXo03gy4mHkxFRyOd598=; fh=lS9u0z9Jn+qE//Et0FREZkHoBypRyyK/aCasJRih1Qo=; b=Z6n3+N2WqoCv3Z07j2IXgHyf4lH08F5p2/ctd+6UydV6LpvGEEQp8VcIWoHbtTVmbx A3IQAtJKdAoAnFZY+wQ2QtMD7raL2TqiosFPjvtataiLRfMuByXqYBCva7xjic1OW0nn uE0FOKhMvufo4Hutq32nnmeTrT23bKxUkaXQyaGbcVKE4XLoXcnpEubTJD/7q4OeUcap HVTS1GQikauK1Erf7GV3G4iXvGmLnTmUAZBFAQoXbR+g052jL2MYsiq59Apig2LvpbwA n35IquB9zRmAijxjAHQ8afxPLEpbJFKhzhPhXmYiYgjSFmCC0OjphnayWmPu7cCpesEP 352Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fRhbRS8P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id mp2-20020a17090b190200b002632a1243dbsi2837559pjb.104.2023.10.19.13.01.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 13:01:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fRhbRS8P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 999EA819D1D9; Thu, 19 Oct 2023 13:01:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346526AbjJSUBP (ORCPT + 99 others); Thu, 19 Oct 2023 16:01:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230079AbjJSUBO (ORCPT ); Thu, 19 Oct 2023 16:01:14 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 278AF114; Thu, 19 Oct 2023 13:01:13 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F3FCC433C8; Thu, 19 Oct 2023 20:01:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697745672; bh=XskOtb4wMb4vHQ2dkKFABI8QaThcTeUIs3sr/sQXEts=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=fRhbRS8Pq6bhMFHVAeN8LfFJ1wNqJlqEDWh0zxXDNhxZkhkJfbJJZcTFgGnct2pKx v2VJ2U91+pjJO/ZfAMyUCp2FRVzQDFfZ3oHdcAeWMRiZP2mSWe+vHJsW54JrmjmwF6 COpEJCWqrC9tq7Ed0hdbILHLDlICUgX4dmlvA5m7q0TZLfhV26LEBuqv2kKnh2RLVj /fs9XSdZNznOOQwWlKLVpstTlHiAeMVrg5OHuIZSOjTK1+Rnv3r47HsuPb8vN9u6Sd dxTS1ExGIHgLyohCzcPFdPYFfzyyzrjNJoZe0dnK15CXe6Z9ppuXMCh6PXt3Z4pWc2 7fQnzYtuSkbsg== Date: Thu, 19 Oct 2023 15:01:10 -0500 From: Bjorn Helgaas To: Lukas Wunner 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: <20231019200110.GA1410324@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231019193246.GA16112@wunner.de> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Thu, 19 Oct 2023 13:01:30 -0700 (PDT) On Thu, Oct 19, 2023 at 09:32:46PM +0200, Lukas Wunner wrote: > 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. Is there any point in setting ->doe_mbs if there's no 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". This is my main question. Seems like it should be both or neither. > > 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? I think pci_sysfs_init() is already constrained to only the BARs and ROM. Constraining it to only the ROM would be an improvement, but I'd really like to get rid of it altogether. Krzysztof W. moved a lot of stuff out of pci_sysfs_init() a while ago, but the BARs are harder because of some arch/alpha wrinkles, IIRC. I think the reason for pci_sysfs_init() exists in the first place is because those resources may be assigned after pci_device_add(), and (my memory is hazy here) it seems like changing the size of binary attributes is hard, which might fit with the pci_remove_resource_files() and pci_create_resource_files() in the resource##n##_resize_store() macro: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/pci/pci-sysfs.c?id=v6.5#n1440 Bjorn