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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 01832C433E0 for ; Thu, 11 Feb 2021 14:56:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1E90764E8B for ; Thu, 11 Feb 2021 14:56:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1E90764E8B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 634CB6B00FB; Thu, 11 Feb 2021 09:56:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 60DEA6B00FC; Thu, 11 Feb 2021 09:56:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 549E56B00FD; Thu, 11 Feb 2021 09:56:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0218.hostedemail.com [216.40.44.218]) by kanga.kvack.org (Postfix) with ESMTP id 3EB5C6B00FB for ; Thu, 11 Feb 2021 09:56:45 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 029C5181AEF0B for ; Thu, 11 Feb 2021 14:56:45 +0000 (UTC) X-FDA: 77806288770.23.print90_3a0f47a27619 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id D722437606 for ; Thu, 11 Feb 2021 14:56:44 +0000 (UTC) X-HE-Tag: print90_3a0f47a27619 X-Filterd-Recvd-Size: 6819 Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) by imf43.hostedemail.com (Postfix) with ESMTP for ; Thu, 11 Feb 2021 14:56:43 +0000 (UTC) Received: by mail-ot1-f41.google.com with SMTP id e5so5332620otb.11 for ; Thu, 11 Feb 2021 06:56:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=RmVDQyx+Ndcv5SeblotXpQRe27Egv2RqGDvlo6R5U8w=; b=E2yi8Dzo7qq3E3/flljC3xH7tiHdegmynb0SA7JlYIz5EM1sj6y32R7tM/aX9DYRic K+hqQA0/ECrgtm5QdSQmTLpcu8HZWUSLZuquZhonvDmxHXsor2V3Ekd730+4qyLBylcH 5EHSAuBOoS1VnBHeezqtR3TIZEBKmUAZXQNaQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=RmVDQyx+Ndcv5SeblotXpQRe27Egv2RqGDvlo6R5U8w=; b=HopaYx0XK+lYnfPMqUkJ3UwXAbrC9FCDFrw1jjvihZPkXRHZpyNjeAiXCxqywsqkOS GuvJsGvlz//PbcCqZcSFbWJ5Z3oOjcZQ3vmCy/xanQfz+8AtIwQ4S9HSqLzCSvTXuVlX KMKTuqBt+K709U45vI7LT2mZU8WFOPEHELLKy/DNQh8F3uwoMzBe5BGQuF7fvjtyHb/D OucNwUlU0/wc7O/N/Afh3J4LIOV/3KUwUnVORKJoWhUw022gIyVLydxGeIzMtEJvXZwX 4CUdyEahBga1E7mFKHb7B7tKefBhCVLmbpXgkIMHNGxyjtLwZM84OKjSktRZ3Mvl9smE LmLA== X-Gm-Message-State: AOAM532BoPKfe7XuuFab1k5XDl/D3mLPHbSJHAjelzjeRri8PVL12/JK f1XNqQICmooPWou3qKjN6rcjonNPB/QgD9VMxgSyCA== X-Google-Smtp-Source: ABdhPJw3fjkRP9gLP7q/RDjMJ5TKsouRdxxZLHu0I2VLcTiQg1aD1zxxpNTCk8c6mMpxWvFuDBl3KNzaOyf4zVs07lM= X-Received: by 2002:a9d:2270:: with SMTP id o103mr5794245ota.303.1613055403311; Thu, 11 Feb 2021 06:56:43 -0800 (PST) MIME-Version: 1.0 References: <20210205133632.2827730-1-daniel.vetter@ffwll.ch> <20210210214053.GA610964@bjorn-Precision-5520> In-Reply-To: <20210210214053.GA610964@bjorn-Precision-5520> From: Daniel Vetter Date: Thu, 11 Feb 2021 15:56:30 +0100 Message-ID: Subject: Re: [PATCH] PCI: Also set up legacy files only after sysfs init To: Bjorn Helgaas Cc: LKML , Stephen Rothwell , linux-samsung-soc , Jan Kara , Kees Cook , Greg Kroah-Hartman , Linux PCI , DRI Development , Linux MM , Jason Gunthorpe , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , John Hubbard , Bjorn Helgaas , Daniel Vetter , Dan Williams , Andrew Morton , Linux ARM , "open list:DMA BUFFER SHARING FRAMEWORK" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Feb 10, 2021 at 10:40 PM Bjorn Helgaas wrote: > > 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. Yeah it's not great. Thanks for looking at both again, I'll fix up the typos on the 2nd one and merge them both. Cheers, Daniel > > > Cc: Stephen Rothwell > > Cc: Jason Gunthorpe > > Cc: Kees Cook > > Cc: Dan Williams > > Cc: Andrew Morton > > Cc: John Hubbard > > Cc: J=C3=A9r=C3=B4me 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 *p= dev) > > 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 --=20 Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch