Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp1466568rdg; Sat, 12 Aug 2023 02:22:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF5jj1KkiJO+ohQni+HGt8/8Oai9PuufFCIB/IXJSP+c1hLMaYosk/JbSHll8X6pFeQHkFj X-Received: by 2002:a05:6871:5d3:b0:1be:e4ae:ac8a with SMTP id v19-20020a05687105d300b001bee4aeac8amr5625767oan.35.1691832146792; Sat, 12 Aug 2023 02:22:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691832146; cv=none; d=google.com; s=arc-20160816; b=VR947oiX4Qw5gyVKYZBFucy8TrGrpjwuqxi9asuTdyTRM8olf0LTkUT7VAYIWEZuDf Z/EjxNHDpANpUZKc2xm3eXj1pHz6REDDcJ3B/JLEuvGf7SIcSK4jJjynZYftl+ufEZIP C0V+DuxYwfvJPD3MBIIR6jVhfhWErcG4HXpWIIztS9m8w3Rn+LwX4Yba+dIeVJo5bQ3B ifLdmzu3YuLoTa9mxXrvRtMUfw3ZY4v2XQzFeRb/he9dp6diK/B+dWxoMbFypyS8P4sD icoqzQPecKG52gEfBzjPRaA8HhdTppY65+vGSWfW4anXaM3oVGIQ/DckMl++jsE/gM44 W2cA== 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 :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ocMvcx9c7JU8lQT2zJHc325Tt8GGtGm0dFu6Nv0K2nI=; fh=cnxqj9Zsx/TUS3zcqM2pWDwbkQtxmcf1RXP/kZFbcoI=; b=JuTHY0jDS/Of/jaXbMJo+nIAF+6wt8XqkJdl9FpxYcsObWnUD0ydBne5afIv3olcDg C4vMwhGjwnZHCQIZFYF/W5iLvpZTZ+wlFkSB3Un0c+rJasBCt+OJXdDtFmQnVRn3xIs9 60kZC9WOKLIteHqXYRMB/CFypu3X4yPL2TrfDB/rwO6Z1cu2Eol/4FtGHCiw6KBIM48n U7vakaDROz8/6Os47nuQMhHOmJMOqenLHofMfX78y2/MYT6/+R1H6Sbd0w8wdWKKBkl5 VPHyDkMFVEE318PV1cldDJ2XfD+qnBi2hGcBJD34IWRobrAHqz/EtdcU0yMMMku/ixmT DFZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MiLzYoIW; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l2-20020a17090ad10200b00263d0beafafsi6614312pju.181.2023.08.12.02.22.14; Sat, 12 Aug 2023 02:22:26 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MiLzYoIW; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235924AbjHLI0e (ORCPT + 99 others); Sat, 12 Aug 2023 04:26:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235175AbjHLI0d (ORCPT ); Sat, 12 Aug 2023 04:26:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DDD6270E; Sat, 12 Aug 2023 01:26:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 293EB602FB; Sat, 12 Aug 2023 08:26:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3E10C433C7; Sat, 12 Aug 2023 08:26:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1691828795; bh=ZvU+Ji3lEtuChDKihxuZBn05RJ9fLwG7X3gfqnGgG/g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MiLzYoIWsPw9lXFle737i8jKOA2d1j8tVQaPJiVoDDrQIKfCgX0Gdm1SMasl//pXa vNl+cpaetVg1KINPFmTvA2AfCAkkpm5OtPiLACyamHfFkDdM6FB+oJkKtPXWtGPVuU 6NsSLQvSsGxNXzoG2omiB/z4yJdq18pUXbiMkjpQ= Date: Sat, 12 Aug 2023 10:26:32 +0200 From: Greg KH 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, logang@deltatee.com, linux-kernel@vger.kernel.org, Alistair Francis Subject: Re: [PATCH v3] PCI/DOE: Expose the DOE protocols via sysfs Message-ID: <2023081224-famished-devotion-6e0e@gregkh> References: <20230809232851.1004023-1-alistair.francis@wdc.com> <20230810073457.GA26246@wunner.de> <20230812081526.GC9469@wunner.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230812081526.GC9469@wunner.de> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 Sat, Aug 12, 2023 at 10:15:26AM +0200, Lukas Wunner wrote: > On Thu, Aug 10, 2023 at 11:34:11AM -0400, Alistair Francis wrote: > > On Thu, Aug 10, 2023 at 3:34???AM Lukas Wunner wrote: > > > 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/ > > > > The is_visible doen't seem to work in this case. > > > > AFAIK is_visible only applies to the attributes under the group. Which > > means that every PCIe device will see a `doe_protos` directory, no > > matter if DOE is supported. > > internal_create_group() in fs/sysfs/group.c does this: > > if (grp->name) { > ... > kn = kernfs_create_dir_ns(kobj->sd, grp->name, ... > > So I'm under the impression that if you set the ->name member of > struct attribute_group, the attributes in that group appear under > a directory of that name. > > In fact, the kernel-doc for struct attribute_group claims as much: > > * struct attribute_group - data structure used to declare an attribute group. > * @name: Optional: Attribute group name > * If specified, the attribute group will be created in > * a new subdirectory with this name. > > So I don't quite understand why you think that "every PCIe device will > see a `doe_protos` directory, no matter if DOE is supported"? > > Am I missing something? I think the issue might be that the directory will be created even if no attributes are present in it due to the is_visable() check not returning any valid files? If so, I had a patch somewhere around here where I was trying to fix that up: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git/commit/?h=debugfs_cleanup&id=f670945dfbaf353fe068544c31e3fa45575da5b5 but it didn't seem to work properly and kept crashing. I didn't spend much time on looking into it, but if this is an issue, I can work on fixing this properly. thanks, greg k-h