Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1503852pxb; Wed, 10 Feb 2021 09:46:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJwli2ude12D1jl3VSbDyWSr0x+r1YLGhDxTiqpv0TPfxWpKplj+r9lXTRumBbt+9Ap50nhc X-Received: by 2002:a17:906:ecfb:: with SMTP id qt27mr4013477ejb.123.1612979195621; Wed, 10 Feb 2021 09:46:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612979195; cv=none; d=google.com; s=arc-20160816; b=XjzV2/vmjXAl9iKLkVd4E8lU6504uBJTiFbMP/zB7ZNuKZdUlzFRZn/jP/h76hFBCa GBPMJzRgQnGWnuZEWxwJzfCWXUxR3J25RME7hNIr+lxprq5UhT0AuEMBpfAL1oxrwXvh /1guRhqwoxrTvPbHpuo8nAlf10Kpe2deqw+cN7uTS8ckWrb96O/OOn196hxEUIu0QTy2 5ycOC+OIiTk06MOKpTA1CwhJXvHdFhJvxfHLMB2qaALhAGLVNKvS07Y771qOgV5t8IGA ZdKMMxnRAXQmv0WiwzxMbUgbaQNtQrOJbjFzdNOt+adqTypkbeSDfw8GuROyyOlCQbVi 4cEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=LOwEXRdvVMZvfZEaxMVJf2OldGo/hEkLnws83/gy1v0=; b=E4Brv6v/85uF/YgjA1e0Y0jwka8/KvbGEzCRmbNzOksWPN0MsNjdZyu785QZeBIF83 afcwGVh9wjCj/uCdLSuJJmxoPoQ8sR8I/YPb2r0SC/U3mgLmVnPr7xgFK+k9drpa4SKR Fw1uodvb2w3egRFA1e2fKezBdMGJAcSg0TTNwoMCY0zZyauLQQg7WIyLClqBQi3jLbQk sYDwecRf9O27XJsCe4QY0w55n/8G6MUlD/dC+Lm6OYX3BSAB7R94/oA2vZtWJqHEN0Ec glGI0fWfCEcXh1QZNCJQnDMpppiiAElV1YUoENZ9jvtCSjRyj4zSLlpl+yYBGipLT9hc H8dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=aSVQeyO4; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a8si2281789edj.200.2021.02.10.09.46.12; Wed, 10 Feb 2021 09:46:35 -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=@ffwll.ch header.s=google header.b=aSVQeyO4; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232976AbhBJRo2 (ORCPT + 99 others); Wed, 10 Feb 2021 12:44:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232927AbhBJRnw (ORCPT ); Wed, 10 Feb 2021 12:43:52 -0500 Received: from mail-ot1-x32c.google.com (mail-ot1-x32c.google.com [IPv6:2607:f8b0:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75C7EC0613D6 for ; Wed, 10 Feb 2021 09:43:12 -0800 (PST) Received: by mail-ot1-x32c.google.com with SMTP id a5so1416827otq.4 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=Ndh78LvZZhuqrZqKr+iLQ981atnJvhaswTEZNX07WHv1w5lkeXJtDxYOzgFeTyD+dq /RqqvKIuesyO4nFNNbFgHl4jAEB1mblfTsCjEkKq5bM92gm7y1KcUA3SCYCkaX3fQc4a TzUhAHJhjeSA+JXD3FYQ8mrGzfc459OZBFo2rYLVmc8ZN8JJjsqWNjgVfcgjNYseTvjp bvV7NhYz5XXgND/BjoZgRSTP5a/HVVwFtzKQf+12JBKNiFNA+155qW1K7a5mOUHIRonW bg/dA0LlZDo/7nIjtYS7LmNUyz5vrs4LjjHJaNe+WJCjEsZBrr1zIsA2wzuXC9G2a+GM du0w== X-Gm-Message-State: AOAM531RH8U6oUk4L7Q46PL2M5yO0ybnZ9LQzjFpAnGww/jN5MZKVjXV qAASrlEv0EXqstg+hdE+mX5pm/qbTnurqDfd97wfsqObBymhgA== 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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