Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1801216pxb; Fri, 5 Feb 2021 01:35:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJxfebn/H7MalzHPU17kAwE53JMHiEuaj8qzsT35Cs7k741B77CJAKZMS29xW49TfKMd7G5T X-Received: by 2002:a50:858a:: with SMTP id a10mr2721956edh.122.1612517710499; Fri, 05 Feb 2021 01:35:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612517710; cv=none; d=google.com; s=arc-20160816; b=iOkcT9ebiXMeyHaRQLcukMoNP5Pv/R5syRiyW57KInLpSKdSX55Te7eO+DuKJtX6c1 dnG/w23WvprSpOw6qqC1D8GGvmupsGNQGTAJQKDXhoXbnEWYCxddExTKfh90yjIBzK3i 5wvkDG50abJRkjc8nwrrnfpHet/LNA7kUUu921FYJEQI9IhvknVtI4WASjV3Zgwdmzhr xihGTXwLX7rxOKSI4GiHXlF4qNctQZhSuLf+S2vkdUPxxA5lSsn7gQWvFSQXdt3EMYvC fODqVaF8H94RdHxnIeSDRHi20DJLd78/IKPb9zmnAR5eklurZZ4QiMFzufcVv8S9z9lb eobw== 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=sS/Xd09oO/Yz7Hj4c1pMXiQx4PAyc9TbJHEWESq/zdk=; b=hn+SCdtl/Pasv7EhYaxeIe1FJaTdEByLPS4++nr/uIdY2eOwGtm2QfV5Ipy519Fw/X Z4v/p/HzHwcHbXK4rSj2Xy1l9Pk0vVvm0JvRqoVeA9dW8xpAWnyEHKc9nQaRi1bV4Sr+ mSZTfb0jVY7zNqIDJBwttbb56MeKV0zwxKdmlOehKkm5XTUeWOb61tatYjSxDlmKyU+R iNMg5qFFKLYqKYbeumSTWWX7/9hZxBzx8yQMs7NDhDnz5EDI2btHNZ55HUuuWmGp9l0c C5ptkdAWti7B/rHoxi8CeNy486x+RcaQ9uUi4Xk3W40bYuDxvErQQkU1zDyrHtKAlbYc Wvcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=F2M9IQ0M; 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 g9si4842831ejj.456.2021.02.05.01.34.45; Fri, 05 Feb 2021 01:35:10 -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=F2M9IQ0M; 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 S229777AbhBEJc5 (ORCPT + 99 others); Fri, 5 Feb 2021 04:32:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230131AbhBEJYB (ORCPT ); Fri, 5 Feb 2021 04:24:01 -0500 Received: from mail-ot1-x332.google.com (mail-ot1-x332.google.com [IPv6:2607:f8b0:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A02DC06178A for ; Fri, 5 Feb 2021 01:23:21 -0800 (PST) Received: by mail-ot1-x332.google.com with SMTP id o12so6213612ote.12 for ; Fri, 05 Feb 2021 01:23:21 -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=sS/Xd09oO/Yz7Hj4c1pMXiQx4PAyc9TbJHEWESq/zdk=; b=F2M9IQ0Mcwqf9L0EvHG8jvCxSS3P6nZN7xpdji0YW2Vb0bIMHJ0EICfSmJXH13+OEm krPXGvlWcY44Pt7pUr/D3V+F0v5YY7w63OxZE08ttweY89J8zqB7lHIAILmCZ9ny2YqN 9zo+EbKF4hd8YpcfyTU2+f4zh7/eT3IqgIEvo= 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=sS/Xd09oO/Yz7Hj4c1pMXiQx4PAyc9TbJHEWESq/zdk=; b=oyYPCpV16cIWoSwYqLqn5SPEsI559wvm2Qwa6yy7HibvtOYsdt9rA0q2+bC6EpO4SE PhP7G7LNhNqxq/EpJRCnqYxmoh+M+IGNWzMSEZzl4+wRTuOA7JDQF0ypAtIQUfpYDdc9 xbGsZ0D3cJ0xIYrEsGWyYCtwARqN1m+fS+pUOSzwIzk1hDWZAACqJ/sjSdXfjOWEYNbG mfzWuODGtDRtkZ7/Nabur5qQSE1KvF0Mnc7MgVDg7F+Qk/00145ifqQmBDm4iR9wKNv5 U7tBnC5lFw+FuGL8wxAbuo66mu+7GxCwSmSRjG03m+lYmq5spCAyjMtwxhsjro/2vbQ7 j/OA== X-Gm-Message-State: AOAM53308mHfcFTT7M0SF6kmKFJijzfpirl7DXPrbNOTOMiZIimLz0C+ k71pzlji4cSP/JulwA0+4iBsvp2+831t0sNvBOwspA== X-Received: by 2002:a9d:6c96:: with SMTP id c22mr2681535otr.303.1612517000615; Fri, 05 Feb 2021 01:23:20 -0800 (PST) MIME-Version: 1.0 References: <20210204165831.2703772-2-daniel.vetter@ffwll.ch> <20210204215019.GA104698@bjorn-Precision-5520> In-Reply-To: <20210204215019.GA104698@bjorn-Precision-5520> From: Daniel Vetter Date: Fri, 5 Feb 2021 10:23:09 +0100 Message-ID: Subject: Re: [PATCH 1/2] 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" , "Oliver O'Halloran" , =?UTF-8?Q?Pali_Roh=C3=A1r?= , =?UTF-8?Q?Krzysztof_Wilczy=C5=84ski?= 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 Thu, Feb 4, 2021 at 10:50 PM Bjorn Helgaas wrote: > > [+cc Oliver, Pali, Krzysztof] > > s/also/Also/ in subject > > On Thu, Feb 04, 2021 at 05:58:30PM +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 > > now problem, but in the next patch I want to wire up iomem revoke > > support. That needs the vfs up an running already to make so that > > iomem_get_mapping() works. > > s/now problem/no problem/ > s/an running/and running/ > s/so that/sure that/ ? > > iomem_get_mapping() doesn't exist; I don't know what that should be. Series is based on top of linux-next, where iomem_get_mapping exists. This patch fixes the 2nd patch in this series, which I had to take out of my branch because it failed. > > Wire it up exactly like the existing code. Note that > > pci_remove_legacy_files() doesn't need a check since the one for > > pci_bus->legacy_io is sufficient. > > I'm not sure exactly what you mean by "the existing code." I could > probably figure it out, but it would save time to mention the existing > function here. Sorry, I meant the existing code in pci_create_sysfs_dev_files(). > This looks like another instance where we should really apply Oliver's > idea of converting these to attribute_groups [1]. > > The cover letter mentions options discussed with Greg in [2], but I > don't think the "sysfs_initialized" hack vs attribute_groups was part > of that discussion. Hm not sure the attribute_groups works. The problem is that I cant set up the attributes before the vfs layer is initialized, because before that point the iomem_get_mapping function doesn't return anything useful (well it crashes), because it needs to have an inode available. So if you want to set up the attributes earlier, we'd need some kind of callback, which Greg didn't like. > It's not absolutely a show-stopper, but it *is* a shame to extend the > sysfs_initialized hack if attribute_groups could do this more cleanly > and help solve more than one issue. So I think I have yet another init ordering problem here, but not sure. -Daniel > > Bjorn > > [1] https://lore.kernel.org/r/CAOSf1CHss03DBSDO4PmTtMp0tCEu5kScn704ZEwLKG= XQzBfqaA@mail.gmail.com > [2] https://lore.kernel.org/dri-devel/CAKMK7uGrdDrbtj0OyzqQc0CGrQwc2F3tFJ= U9vLfm2jjufAZ5YQ@mail.gmail.com/ > > > 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 *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