Received: by 2002:a05:6358:51dd:b0:131:369:b2a3 with SMTP id 29csp781038rwl; Thu, 10 Aug 2023 01:10:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEloo/RxPlgt3bmQylgapllr5V+pe/hfErh5exXV68QraV381ZRcbp9WDeqJJkH3MGUhg/j X-Received: by 2002:a17:906:ef90:b0:99b:d178:f051 with SMTP id ze16-20020a170906ef9000b0099bd178f051mr1403165ejb.64.1691655025577; Thu, 10 Aug 2023 01:10:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691655025; cv=none; d=google.com; s=arc-20160816; b=FMcREO+S0aGGT61X6191LkpXkCTamRpax4/zpyNcyVOD8yN3Qf5i4sipk5UrABjWmr lUsMg0UYsVl1SZsvVuTT1u0RKGLrIKHvfl7W4Qz+IKT40TCYtCKqjVc1+BBvEkTeYlFn vXqo1q8Wy7rKS1GFR73z1lCiGtb0VNN5spgQj3rBGdEU54rrRt7IvH0yRq3kcDc9YZvK 75YPj512xZRE38h22OYaN+rVgq7FMZ7/K4fTEle0kLL+yROXe5JuJN8/wH8w50/VovKA 8V7TgWDBmeoKDW3oKC+R3LOpN5PvaCgGvG7h0Cm3BVGnEdoSeK8kmC3nXH/jcoHvDuot R9cw== 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=74kEd8LNOhJdARgBKBrkU+oNBAN9QgDNf+0IPky8Lmk=; fh=vt4nS14RXAem9QqVM48QhImxKJ8N/wowxrgqqZeuWns=; b=WBjWtqGxvxhZgXEUvkfuEGbieSB5lqlwaWqfaq5zl5M0c1AEmb2H2Ex/80ej/TA5EU /8Vp4+aTVPvWAvFxgaFACNuh4UQqyb+lA1ktrcwTMgizQQ19fwrsr3tNOBt+7KBpZ5Gk Q/wvcd+DEmoP4Ry1k8zVK9iCanBtwmbAiKQylP396vCdmzEUrLmmfh+hJbzokh24ughU YtaU+AvbSL1QyzByfeEp49JzqFsR96SFKGRXwvGkMKmbAMoD8xUyIBdxgDlYgrOVk/oB YmweGJ/KxDzWU3GUVAxyBwAYJI/WOf1x+HZqbS0bJ/Z4nmNdPAmV4K60Kha9d5KCU8Hn hQOQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kj22-20020a170907765600b0099bd1dc4c3fsi1085212ejc.154.2023.08.10.01.10.00; Thu, 10 Aug 2023 01:10:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233424AbjHJHfD (ORCPT + 99 others); Thu, 10 Aug 2023 03:35:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbjHJHfC (ORCPT ); Thu, 10 Aug 2023 03:35:02 -0400 Received: from bmailout2.hostsharing.net (bmailout2.hostsharing.net [IPv6:2a01:37:3000::53df:4ef0:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B75110E7; Thu, 10 Aug 2023 00:35:01 -0700 (PDT) Received: from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28]) (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 bmailout2.hostsharing.net (Postfix) with ESMTPS id 09A4B2800BBE0; Thu, 10 Aug 2023 09:34:58 +0200 (CEST) Received: by h08.hostsharing.net (Postfix, from userid 100393) id F151A2ED8B5; Thu, 10 Aug 2023 09:34:57 +0200 (CEST) Date: Thu, 10 Aug 2023 09:34:57 +0200 From: Lukas Wunner To: Alistair Francis Cc: 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, Alistair Francis Subject: Re: [PATCH v3] PCI/DOE: Expose the DOE protocols via sysfs Message-ID: <20230810073457.GA26246@wunner.de> References: <20230809232851.1004023-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230809232851.1004023-1-alistair.francis@wdc.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_NONE,SPF_NONE autolearn=no 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 On Wed, Aug 09, 2023 at 07:28:51PM -0400, Alistair Francis wrote: > --- a/drivers/pci/pci-sysfs.c > +++ b/drivers/pci/pci-sysfs.c > @@ -1226,6 +1227,12 @@ static int pci_create_resource_files(struct pci_dev *pdev) > int i; > int retval; > > +#ifdef CONFIG_PCI_DOE > + retval = doe_sysfs_init(pdev); > + if (retval) > + return retval; > +#endif > + The preferred way to expose PCI sysfs attributes nowadays is to add them to pci_dev_attr_groups[] and use the ->is_visible callback to check whether they're applicable to a particular pci_dev. The alternative via pci_create_resource_files() has race conditions which I think still haven't been fixed. Bjorn recommended the ->is_visible approach in response to the most recent attempt to fix the race: https://lore.kernel.org/linux-pci/20230427161458.GA249886@bhelgaas/ To avoid (most of) the #ifdefs, you may want to consider adding a doe-sysfs.c file like I've done for cma in this commit: https://github.com/l1k/linux/commit/b057e2fb0ee0 Thanks, Lukas