From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DAD8C433E0 for ; Wed, 10 Feb 2021 21:42:14 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2CA0364EE0 for ; Wed, 10 Feb 2021 21:42:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2CA0364EE0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Message-ID:Subject:To:From: Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References:List-Owner; bh=tDoZAueVhw1oPRl2vVkrtrypyypEj9Ds0p7C2fGfFoc=; b=ABa0S5tiISlBumm+oIWggx4kj zU1HkEQOYMZiFr5oNAP+JNxkTjCS6rXI3MeF9ckydR/ytnG4p2iJEpdHH1dgu7tahFIPJcio5fJW2 Ru9GKRwE0xOfPn5JBEkLxi/QnF7IDQ0zC2sPcTMIeL+1clYD1Pq/gu5B442Pd8T6T+wARrz1Gw2jB 3Hr4tytKxxDX+ywUKsSb+yr9SR7oj8nHbwOSpO4h4ZMhc1BDjBda1ekVntlKZFJlBfh4+K5cqxcSK zbAZvLnRw2+8mJlQLTmDP7WatlVdPjbRaG+wX+qwGHveewFWZTcYmOPkYqNcbuLmwndoLDgNvebMn lTen8kOTw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l9xEJ-0007gb-VZ; Wed, 10 Feb 2021 21:41:01 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l9xEG-0007eL-7B for linux-arm-kernel@lists.infradead.org; Wed, 10 Feb 2021 21:40:58 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 567E564EDF; Wed, 10 Feb 2021 21:40:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612993254; bh=f44NPsIKdvVz4sgR73Jy/yomvy3TJguxverZulfIkv8=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=LDqSvUKK/dUgih+SoexCs2NpBSymHqLD605AiZy5maqEI/6AXrW+0vdTCv29oBcMY YCFOw/3wWb5caauRzNrqcxwD3sCdCJqnzWaAH63oGNWvDmcMwvcbp1ctcxDIx58LX3 uYloZZbhn4lEJKGkImgCuUFSGFdF/tLpU9VsdRNoacSf8dmHkmo0BKK7UNh4w4lkJu /XENEBx69/iQ83muLFq1rWDQ9od8Owbknpii8zdqtmgbKMkvaJXWRb5syq+u/1u2rS ZCC/XOr8dUuEvj/3xCBcOgyFQxtUgHARvza/bW3yo2UMR9/W7LVDY0BaJBHaMhQIgN OY6ZR9sRLKOqg== Date: Wed, 10 Feb 2021 15:40:53 -0600 From: Bjorn Helgaas To: Daniel Vetter Subject: Re: [PATCH] PCI: Also set up legacy files only after sysfs init Message-ID: <20210210214053.GA610964@bjorn-Precision-5520> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210205133632.2827730-1-daniel.vetter@ffwll.ch> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210210_164056_457511_E7070213 X-CRM114-Status: GOOD ( 27.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stephen Rothwell , linux-samsung-soc@vger.kernel.org, Jan Kara , Kees Cook , John Hubbard , Jason Gunthorpe , Greg Kroah-Hartman , LKML , DRI Development , linux-mm@kvack.org, =?iso-8859-1?B?Suly9G1l?= Glisse , linux-pci@vger.kernel.org, Bjorn Helgaas , Daniel Vetter , Dan Williams , Andrew Morton , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Feb 05, 2021 at 02:36:32PM +0100, Daniel Vetter wrote: > We are already doing this for all the regular sysfs files on PCI > devices, but not yet on the legacy io files on the PCI buses. Thus far > no problem, but in the next patch I want to wire up iomem revoke > support. That needs the vfs up and running already to make sure that > iomem_get_mapping() works. > = > Wire it up exactly like the existing code in > pci_create_sysfs_dev_files(). Note that pci_remove_legacy_files() > doesn't need a check since the one for pci_bus->legacy_io is > sufficient. > = > An alternative solution would be to implement a callback in sysfs to > set up the address space from iomem_get_mapping() when userspace calls > mmap(). This also works, but Greg didn't really like that just to work > around an ordering issue when the kernel loads initially. > = > v2: Improve commit message (Bjorn) > = > Signed-off-by: Daniel Vetter Acked-by: Bjorn Helgaas I wish we weren't extending a known-racy mechanism to do this, but at least we're not *adding* a brand new race. > Cc: Stephen Rothwell > Cc: Jason Gunthorpe > Cc: Kees Cook > Cc: Dan Williams > Cc: Andrew Morton > Cc: John Hubbard > Cc: J=E9r=F4me Glisse > Cc: Jan Kara > Cc: Dan Williams > Cc: Greg Kroah-Hartman > Cc: linux-mm@kvack.org > Cc: linux-arm-kernel@lists.infradead.org > Cc: linux-samsung-soc@vger.kernel.org > Cc: linux-media@vger.kernel.org > Cc: Bjorn Helgaas > Cc: linux-pci@vger.kernel.org > --- > drivers/pci/pci-sysfs.c | 7 +++++++ > 1 file changed, 7 insertions(+) > = > diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c > index fb072f4b3176..0c45b4f7b214 100644 > --- a/drivers/pci/pci-sysfs.c > +++ b/drivers/pci/pci-sysfs.c > @@ -927,6 +927,9 @@ void pci_create_legacy_files(struct pci_bus *b) > { > int error; > = > + if (!sysfs_initialized) > + return; > + > b->legacy_io =3D kcalloc(2, sizeof(struct bin_attribute), > GFP_ATOMIC); > if (!b->legacy_io) > @@ -1448,6 +1451,7 @@ void pci_remove_sysfs_dev_files(struct pci_dev *pde= v) > static int __init pci_sysfs_init(void) > { > struct pci_dev *pdev =3D NULL; > + struct pci_bus *pbus =3D NULL; > int retval; > = > sysfs_initialized =3D 1; > @@ -1459,6 +1463,9 @@ static int __init pci_sysfs_init(void) > } > } > = > + while ((pbus =3D pci_find_next_bus(pbus))) > + pci_create_legacy_files(pbus); > + > return 0; > } > late_initcall(pci_sysfs_init); > -- = > 2.30.0 > = > = > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel