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=unavailable 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 11068C433DB for ; Thu, 11 Feb 2021 15:05:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DCDF264F0D for ; Thu, 11 Feb 2021 15:05:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229517AbhBKPEf (ORCPT ); Thu, 11 Feb 2021 10:04:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230525AbhBKO5a (ORCPT ); Thu, 11 Feb 2021 09:57:30 -0500 Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [IPv6:2607:f8b0:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B217C0613D6 for ; Thu, 11 Feb 2021 06:56:44 -0800 (PST) Received: by mail-ot1-x32f.google.com with SMTP id l23so5343608otn.10 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=iZNKVhEDp4zCUrhpiQfeiHpeLPc/dxZMBjzeqtNRsUZoryVgd1qpagnYRKn9+Iftmk 3UTjCwPW3naw0SocQ6dMFV0CA7cQDhMZ7zUjLX4yURE1hmMCnwimoyRW2QdtTWpY5p9P r/EU99n6Wq8XhMeG0aYqEEHnjLd5d7UH7E4ngDqXRCcp8JjDx8kWsL6EqwSOLj5fhtZ9 zSJ1VNoam7IcbtOGEqjoP1Er1lQtLNFlu3QW6e4Qyl0CgtUUeaz4fm4LRzZJsEUO9Q1g UC8faDaRN8A3mIs0eckRnXb7V1MCdLDLaSXNzOM0IlpD9H02S2mIeQCF0dz3m48k/lKQ u7LA== X-Gm-Message-State: AOAM532DKzM3ydbW23Gv3C6QtLgtmwxcp5zLRubHuO23dIsZU/ML8eh7 bl/PVeDDnejpMo2zRDIK+YtLZdkkBUL0Qt4TUUiBsA== 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 Precedence: bulk List-ID: X-Mailing-List: linux-pci@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