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=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 7B1EFC433DB for ; Fri, 5 Feb 2021 10:00:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A718964FC8 for ; Fri, 5 Feb 2021 10:00:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A718964FC8 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 EFC806B0071; Fri, 5 Feb 2021 05:00:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EDD216B006E; Fri, 5 Feb 2021 05:00:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DEABA6B0071; Fri, 5 Feb 2021 05:00:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0233.hostedemail.com [216.40.44.233]) by kanga.kvack.org (Postfix) with ESMTP id CA6726B006C for ; Fri, 5 Feb 2021 05:00:02 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 919DD180AD815 for ; Fri, 5 Feb 2021 10:00:02 +0000 (UTC) X-FDA: 77783768244.30.0075B83 Received: from mail-ot1-f54.google.com (mail-ot1-f54.google.com [209.85.210.54]) by imf06.hostedemail.com (Postfix) with ESMTP id E1B6AC3D355D for ; Fri, 5 Feb 2021 10:00:01 +0000 (UTC) Received: by mail-ot1-f54.google.com with SMTP id k10so3980684otl.2 for ; Fri, 05 Feb 2021 02:00:01 -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=+4u7LFNcU9hMwfgLTZmVYDnd+qbrvGiQY6Ud/lubleQ=; b=Sk2sbOl/YGsWHQ642ZxGsgnlPJp90k/MEp96MZd6QxXq2XXoVszajynNlPCU1EgwIp JrYz9Rfexw9ffo4+U+GP1iNsEpA+sPVI+m3dHYB8TlTcsM12z2lC0O1i/PT8lFYQ8t+b Vh8efEXHHiw+rh5OORJRedQ8kYAW8fFgoKVIE= 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=+4u7LFNcU9hMwfgLTZmVYDnd+qbrvGiQY6Ud/lubleQ=; b=CzSN4cwUC/YUPruZvBZ8ZFUZspvNP2LUjbz2QU4uo6aYg1lDQJ10O9klq887KVhfOa /pKfIXT6J7FNF9fqEOD1+3aIyDEt32NDr8kG7YJtVBrB0Lb2tI79t/8lUaKhRhdmqFdB iWw2QLZ19kNTm1MDu6wPwkHTSIUTE6RJBrfkJvPd0UA7MZi9y+128V7E2XazrZvW5JqJ fWo7kQw46JqunCgmcamIDI6HRzeJiCGBdUmo9XVKaECELmdLT4AEJHtpSUMFmf7Mm9N0 0YQy62muJvfC19QM7ADYqKXyLkvbAidLH9UzGOvdVwEr1Sm9ccbRdtIE0FopzUEBu5d4 DVuQ== X-Gm-Message-State: AOAM531VePhmCK7DjVqGGM33k6vculZdF7bVdaT2MbJX8BXYkTgZU69j QqpapXkHPSd0iKABIFmngpfQ82gxXFnSPW4EBRGGGA== X-Google-Smtp-Source: ABdhPJzbngQ5SL0u3GVHbNMBJfQkQH0+gaX2wZqa80FFqtPMKC8sUU8IKX94LyS+DWVU6cSU7N0JCdCRKNzsiegRDCc= X-Received: by 2002:a9d:b85:: with SMTP id 5mr2898890oth.281.1612519201295; Fri, 05 Feb 2021 02:00:01 -0800 (PST) MIME-Version: 1.0 References: <20210204165831.2703772-2-daniel.vetter@ffwll.ch> <20210204215019.GA104698@bjorn-Precision-5520> <20210204222407.pkx7wvmcvugdwqdd@pali> In-Reply-To: <20210204222407.pkx7wvmcvugdwqdd@pali> From: Daniel Vetter Date: Fri, 5 Feb 2021 10:59:50 +0100 Message-ID: Subject: Re: [PATCH 1/2] PCI: also set up legacy files only after sysfs init To: =?UTF-8?Q?Pali_Roh=C3=A1r?= Cc: Bjorn Helgaas , LKML , Stephen Rothwell , linux-samsung-soc , Jan Kara , Kees Cook , Greg Kroah-Hartman , Linux PCI , 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?Krzysztof_Wilczy=C5=84ski?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: E1B6AC3D355D X-Stat-Signature: zjn7nkbn4cnonobwbg1y864754zndd37 Received-SPF: none (ffwll.ch>: No applicable sender policy available) receiver=imf06; identity=mailfrom; envelope-from=""; helo=mail-ot1-f54.google.com; client-ip=209.85.210.54 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1612519201-32249 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: On Thu, Feb 4, 2021 at 11:24 PM Pali Roh=C3=A1r wrote: > > On Thursday 04 February 2021 15:50:19 Bjorn Helgaas wrote: > > [+cc Oliver, Pali, Krzysztof] > > Just to note that extending or using sysfs_initialized introduces > another race condition into kernel code which results in PCI fatal > errors. Details are in email discussion which Bjorn already sent. Yeah I wondered why this doesn't race, but since the history goes back to pre-git times I figured it would have been addressed somehow already if it indeed does race. -Daniel > > 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 fa= r > > > 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. > > > > > 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. > > > > 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. > > > > 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. > > > > Bjorn > > > > [1] https://lore.kernel.org/r/CAOSf1CHss03DBSDO4PmTtMp0tCEu5kScn704ZEwL= KGXQzBfqaA@mail.gmail.com > > [2] https://lore.kernel.org/dri-devel/CAKMK7uGrdDrbtj0OyzqQc0CGrQwc2F3t= FJU9vLfm2jjufAZ5YQ@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 = *pdev) > > > 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