Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2227539pxb; Thu, 11 Feb 2021 07:26:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJzFWs7/22wt4IBtJVZkEM8FnRq4cw5453LvnVeUcdGq68fpw9SOpxBZm5E8MUBwqfyuEles X-Received: by 2002:a17:907:7781:: with SMTP id ky1mr8792891ejc.255.1613057210772; Thu, 11 Feb 2021 07:26:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613057210; cv=none; d=google.com; s=arc-20160816; b=p/6Qf/c2qo58Hk2sn7tzLqWQz58I+KI5zoR+ZvwuZndTkcM2W0DJsEmCBMMsGmZ2Jh 8TwzNmW0yNO/ximlsXaC7OXuF1Q7jYZo0plb1XIATkHflIofd1SsP76xxbRIskxs6K1V 2mBu0ywINKwo47FePHjo5qHcJlud4OgRBKCQRB7RR5oxIGPT/I1eJUbL0sZtnNWaWTT/ Tqr1mS0jeETD/K9KcRH3QeHLZPvoJqCpRCsUbWYzY+chy8uID6eHS2K9yHg7moWtM2xx oyO8ec7jMblPoMWGxCGrq06AFcO2DyIhEMDxfcT2rZee4ENvTPmSLQvEe5zU1MPHnOrR QZaQ== 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=RmVDQyx+Ndcv5SeblotXpQRe27Egv2RqGDvlo6R5U8w=; b=GgYFe6O8j9RS/vCbrMSM2JTxcgyAC2p2mW7eq93CCPzLJd2G5sImagFjZnTZF/yfan Pn7WUBVn+GoTg7Xa21OKHomcxkeAcAbtW3f9Q7s0wpvc2VIxF37i1GTeJTrm+kmyA8rP 5l+KkuZv07qIWjlpZTUrLS6PI2vBsXXVen7SesXMWydfj1dIyzgnw62vn9ep5G78Q12c buteJAnHCoKulGFzaxrbjLGWrFOfDjZllbr0olIx5aeDdfXJFeAj8FV1cn5TKx7earw1 KQbVkPP2WOX/pXCITkjGLg3yDbuZOD8LVECZ3pMQm1m/I0EQQ6YXy7fNvKyPNr+fOH6h ti7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=E2yi8Dzo; 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 h24si4477128ejt.89.2021.02.11.07.26.26; Thu, 11 Feb 2021 07:26:50 -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=E2yi8Dzo; 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 S230288AbhBKPZV (ORCPT + 99 others); Thu, 11 Feb 2021 10:25:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230521AbhBKO50 (ORCPT ); Thu, 11 Feb 2021 09:57:26 -0500 Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BCDEC061786 for ; Thu, 11 Feb 2021 06:56:44 -0800 (PST) Received: by mail-ot1-x32b.google.com with SMTP id d7so5360652otq.6 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=PTUzjI6Norom6hatYhsAi1HyLKrsR997LEEMwuOGQslWMrMDVLJKf71yxvZPCFBANf LI+hzYtZy3uwx9Dh7Rl4fllVy4YvNSuhEHNxUgqN2/OSFT92VGHRaPAbTFYWGlSmGNTj ns0F8CRFwNMrx+tIdZkRsv9JW/ZjIevTW1dC9aWpz2kFwAvCdZl6wOhidEg+P8Z9XBJ0 q3q8O7iTFJPBnHwJsZq/4Z7o6uqoaH0AwWvj1I1l1wRM5qyR22NPMQOlWyqJ84+7T1gU 4a5SRQyBIUdEN8hJ/kGRgH+fT6a4k6oZFVPgDPqlnuXtH4wihpQBmKqX+rqkYp3TFcHx iNQQ== X-Gm-Message-State: AOAM533b3+6ULrPzRZK2tf5ENBPZUpioqLLBlISUBz4HY6PALm6Sp1Z+ SW4U3UKagN8FYrRJUvGyufuCe44oIVxN4L0p/LJxWA== 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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