Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1681374pxb; Wed, 9 Feb 2022 02:03:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJy2jH85oK0Qya6nNiSFuUzYdq6JqKxfnLMBLIFGLIoor7ZZuSDouNeMbQZwxGmjA0jh8o6q X-Received: by 2002:a63:2a86:: with SMTP id q128mr1282749pgq.53.1644401001304; Wed, 09 Feb 2022 02:03:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644401001; cv=none; d=google.com; s=arc-20160816; b=X019VKcf8bVAku+LDs7LlCGCsPxtrPxZu9Ed3TSd7+FywS1oTCPrSWYU34D+Vw4YKF lE7IFFC9oW3JxMKiEEVW+FGM9kxMxjdTQuT6MHGaeFRehiMXw0q8oUN9ytXRK+rOaVQe c2hinHnprQ5eeMhOyDCZ4q88Em4hdcXBKCd6sAZhPwV8+0sZxJoMd7logbxZzONZHOib 1RcC+sp8uuIMA/8MOXVMg6tiD8PAwhCvcG46w7rZvWmJZdGm9S+Nz0guwvlXKQ1E28K7 lRqWwDbNbDSvSE9GFufc/55sD5hHe7YB1Llo4mYUDTlxLkRbPXI/IvFXepVg0Hkj0MFV Ew1Q== 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-transfer-encoding :content-disposition:mime-version:message-id:subject:cc:to:from:date :dkim-signature; bh=2xe5NxCbBdbOOqZ7DGrCmHygGQLUVc44HJskb1R0Wns=; b=EYe5y4m7baEzLmcRNUYjrq8ZyYkdsTdpJwzpElnZz5El7eKPhXufISGj/Ak/gvZ2sO 164JGi9gZY6I8tGsD2RVw3oehvA0PDzBAReDnnmPPSW86NXWQV2eO13Km65tc4ORY4AQ YvNNahupCuieAFguxqpZWKSTk4tJyT5XKG0Kg/FIWYeTkxM5J4Vp03P11bjzExFtVxL4 IWx+jWNYRyWxBxd7X8/ejzued389IIZ4bwE8JNEkHrt98kxGsQrclgSegHvPM7UR+AEm Z0XTp3UG3Lzn707Azrjr2pjzZQiZCnQ5GwD2Eb62p5SufyDTKezS7og+cuZihxq5bvP8 4Iiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=r2ZYtAp5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p19si4610285pjo.120.2022.02.09.02.03.07; Wed, 09 Feb 2022 02:03:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=r2ZYtAp5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237726AbiBHXkb (ORCPT + 99 others); Tue, 8 Feb 2022 18:40:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237592AbiBHXk2 (ORCPT ); Tue, 8 Feb 2022 18:40:28 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1668C061577; Tue, 8 Feb 2022 15:40:27 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8822CB81DAE; Tue, 8 Feb 2022 23:40:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D523C004E1; Tue, 8 Feb 2022 23:40:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644363625; bh=tTPrvW+Dj9qlw2hawH8KNeZdwB7ywT5DEp3AnZQYYas=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=r2ZYtAp5LY9NOVd2QTojCHSKJyHaCFJAHN134jhrTbUWahI6A68xI7guspXyv7w7o cG+Wuo8HmRRMLqSQBbusqueYWr04h/MQzEZaB06LO1ZCD1z95WO80iALgKTH8aTR+b DjIAOIhK1jLscZ9Zp4mnzYqmNxeoEZY9IZ6EsHWmVlXmLje1nszSjyjkpN2V0Xslif 1XUTnWixsC9RKRCJOQac0eF5uUOzkDl3hA2N7b8Sd0WopLstcpJ20VC6Lwk+zQDcLa HxkLjNE7GYKLjAE6RxiJbUC7+w3QoxCJ9jeou6OS4VYoA0spDnbkGB8rh+VDsD+z1/ Cfy1fhref5yWw== Date: Tue, 8 Feb 2022 17:40:23 -0600 From: Bjorn Helgaas To: Krzysztof =?utf-8?Q?Ha=C5=82asa?= Cc: Pali =?iso-8859-1?Q?Roh=E1r?= , Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Lorenzo Pieralisi , Gregory Clement , Andrew Lunn , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Koen Vandeputte , Dexuan Cui Subject: Re: PCI: Race condition in pci_create_sysfs_dev_files (can't boot) Message-ID: <20220208234023.GA505306@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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,T_SCC_BODY_TEXT_LINE 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 [+cc Koen, Dexuan from this old thread: https://lore.kernel.org/all/20200716110423.xtfyb3n6tn5ixedh@pali/] On Mon, Jan 31, 2022 at 12:56:18PM +0100, Krzysztof HaƂasa wrote: > Bjorn Helgaas writes: > > > Thanks. e1d3f3268b0e and related patches converted individual files > > ("config", "rom", "vpd", etc) to static attributes, but since the > > problem you're seeing is with a directory, it's likely different. > > > > I opened this bugzilla report to try to keep this from getting lost: > > https://bugzilla.kernel.org/show_bug.cgi?id=215515 > > Ok, thanks. Koen collected some interesting logs at https://lore.kernel.org/all/cd4812f0-1de3-0582-936c-ba30906595af@citymesh.com/ They're from v5.10, which was before all of Krzysztof W's nice work converting to static attributes, but Koen's log shows the error happening in the pci_sysfs_init() initcall, which is *after* imx6_pcie_probe(): imx6_pcie_probe # probably device initcall (level 6) ... pci_create_sysfs_dev_files pci_sysfs_init # late initcall (level 7) pci_create_sysfs_dev_files "sysfs: cannot create duplicate filename" Krzysztof, you're running v5.14, which includes Krzysztof W's work, but that shouldn't affect the imx6_pcie_probe()/pci_sysfs_init() ordering. Your log shows the error in imx6_pcie_probe(). Would you mind adding the patch below and attaching a complete dmesg log to the bugzilla? Bjorn diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 7bbf2673c7f2..6a2b62fe7704 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -1200,6 +1200,9 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine) res_attr->attr.mode = 0600; res_attr->size = pci_resource_len(pdev, num); res_attr->private = (void *)(unsigned long)num; + pci_info(pdev, "pci_create_attr:"); + print_hex_dump(KERN_INFO, "", DUMP_PREFIX_OFFSET, 16, 1, + res_attr, 64, true); retval = sysfs_create_bin_file(&pdev->dev.kobj, res_attr); if (retval) kfree(res_attr); @@ -1380,6 +1383,9 @@ static const struct attribute_group pci_dev_reset_attr_group = { int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev) { + pci_info(pdev, "pci_create_sysfs_dev_files\n"); + dump_stack(); + if (!sysfs_initialized) return -EACCES;