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.8 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 9F017C433E0 for ; Wed, 10 Feb 2021 17:43:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 187D964ECF for ; Wed, 10 Feb 2021 17:43:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 187D964ECF 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 7863C6B0006; Wed, 10 Feb 2021 12:43:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7353E6B006C; Wed, 10 Feb 2021 12:43:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5D4FF6B006E; Wed, 10 Feb 2021 12:43:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0118.hostedemail.com [216.40.44.118]) by kanga.kvack.org (Postfix) with ESMTP id BD1306B0006 for ; Wed, 10 Feb 2021 12:43:13 -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 793A818103F3E for ; Wed, 10 Feb 2021 17:43:13 +0000 (UTC) X-FDA: 77803079466.23.71E2A19 Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) by imf15.hostedemail.com (Postfix) with ESMTP id 90938A0009D1 for ; Wed, 10 Feb 2021 17:43:12 +0000 (UTC) Received: by mail-ot1-f50.google.com with SMTP id q4so2563034otm.9 for ; Wed, 10 Feb 2021 09:43:12 -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=LOwEXRdvVMZvfZEaxMVJf2OldGo/hEkLnws83/gy1v0=; b=aSVQeyO4q1SyZ99Fx7g8reh4zcI1aH3PnMoub+qk1TikH0aJexvkhIzg4srOUi51Pr b+AAPUlkcwrzbLD4NYqC4amBaspRGlM01Vo4Fkjax6nExQQ/Znn0hckIUG3tLzxeKD8V xFUNFSxUmoaeOlJbCq1EzPzfPxhFV3+GCpZZo= 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=LOwEXRdvVMZvfZEaxMVJf2OldGo/hEkLnws83/gy1v0=; b=eEFJ+E91VUxks23BY+NdzwOnbeX3ySIAau5B5M7ZkbJxVGTskD02HYdF6STP0PrV7S Pz+sDMyLhtDmi4MuXaRtAuUDKoMd3an1b9nZYVoODnNy/ujZE2lL0Wg1VbgzKdgbbKDc Pg8nVJZeazg6mdT9xb2mJ2Vlt3vM7gCqI4HRjMbSTDHHTSjrQQa9Js1YLtnvcMR4XgX/ r0gE3CG/o0k12LRKwsPK/efs97ryHXVCn5UZmYF0FhWc6lfuuhVRRXK1rY4wlMguNn84 AZoyEshCGsDu3x5HaxXqx23+bDF2lsbJhziEpb7tFZbvNSmy6Z1k6Si6ot1CkGx81U/I lNiw== X-Gm-Message-State: AOAM530UlSsrwoDadGFH+NDNxRNYdWd4nidXQB2SFNxMrF0ECkUFZ7fT gGXEJHD8vlFY/Z6vte8H1tSuZeT0OSP67scdHp4G2g== X-Google-Smtp-Source: ABdhPJyf0c/kQbPLFv9k7KYsyYq25CZR3JWicuNJgZ3n4s/yKoff44lu/fP6XuJ5GLjcgeB2grbmGucW3joUFNL7tbI= X-Received: by 2002:a9d:2270:: with SMTP id o103mr2896760ota.303.1612978991821; Wed, 10 Feb 2021 09:43:11 -0800 (PST) MIME-Version: 1.0 References: <20210205133632.2827730-1-daniel.vetter@ffwll.ch> In-Reply-To: <20210205133632.2827730-1-daniel.vetter@ffwll.ch> From: Daniel Vetter Date: Wed, 10 Feb 2021 18:43:00 +0100 Message-ID: Subject: Re: [PATCH] PCI: Also set up legacy files only after sysfs init To: LKML Cc: DRI Development , Daniel Vetter , Stephen Rothwell , Jason Gunthorpe , Kees Cook , Dan Williams , Andrew Morton , John Hubbard , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Jan Kara , Greg Kroah-Hartman , Linux MM , Linux ARM , linux-samsung-soc , "open list:DMA BUFFER SHARING FRAMEWORK" , Bjorn Helgaas , Linux PCI Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 90938A0009D1 X-Stat-Signature: fqy1tmxwx3qae1sts4em81ubdf69h1cg Received-SPF: none (ffwll.ch>: No applicable sender policy available) receiver=imf15; identity=mailfrom; envelope-from=""; helo=mail-ot1-f50.google.com; client-ip=209.85.210.50 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1612978992-21897 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: Hi Bjorn, Can you ack this for merging through my topic branch with the other follow_pfn/iomem revoke fixes for 5.12? If not, what's the plan for getting this (or equivalent functionality) in for 5.13? I have more of these follow_pfn/iomem revoke patches on top, so I'd like to get the first cut merged sooner than later if possible. And the other prep work has been in -next since -rc1. Thanks, Daniel On Fri, Feb 5, 2021 at 2:36 PM 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 > 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 *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 > --=20 Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch