Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1664356pxb; Wed, 10 Feb 2021 13:42:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJyFRTHjMfXUevWVofRKkob0bPxfM3EkVXB9HXo2SerTBGjzJSq3VP4x2SjRY17mdPyoTBBu X-Received: by 2002:a17:907:7811:: with SMTP id la17mr4803290ejc.436.1612993366741; Wed, 10 Feb 2021 13:42:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612993366; cv=none; d=google.com; s=arc-20160816; b=jKxPoxi184ulLnF6JGR5++ibDH3RXrNLdOHHBqNTJJqWKaju2kCeg+e0VSauPxplg3 mHtQwlJPYyW43ATwU3danga+enhYqQy+ElRx+3DFAjWtv7Ql86+Cc/8+Hcdrn6Or7ofF CZgKgBWxp+rj5mjMpSTOs1KITRcLMQMiid3XK4G8ZpBCUt5teCtpk2IZtVFonj70XrMZ DmwQu/fbkGTBaG2mwn0f9EtT59PZjytyEHV3IUtiZSqqQ3ikPQwm8R/HyQzIb9hy22r+ +hEl28BGMUojw4BagoZJ3s3gAKyoyA/n12Ktuj656HJOcxEh8WKQwxM/oU9M1Qmtq3aG 767A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:message-id:subject:cc:to:from:date :dkim-signature; bh=i9vkOf15ficn/4oxMCk55lhuGfuCRbO1abnRCzXnOO8=; b=bO1MdSZBkRdLhlekF9YLcmJgypOIU7brInhVtX74PCX/32/jKMhzwpK6TqFJvKydM5 AjEj3cS//lb9he4O5bHXo5gDlsY0ez1A0oQfkUSfLcQdJuSmIC/U9Q155rS4gPfp6HGD +cPkPKa4F63dvhZbG0vuR46C1/u0ltqVvLg5lpuNnz0fVBvn1RCweHjuBXL8i3vxT028 DhPI42X1m2XcpD/ilUFunDK3L14myTPgJwHZOrKHP1bGL3aNhv1Fgfu+cF5IqWf0wIki /JLG618XcVDorSRjsC8toKvrXKAO/p8kEci1O72+K0azoMb9MCL44lHZf+wchFyWVM5E tC/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LDqSvUKK; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l13si2395967edn.5.2021.02.10.13.42.19; Wed, 10 Feb 2021 13:42:46 -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=@kernel.org header.s=k20201202 header.b=LDqSvUKK; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233336AbhBJVlj (ORCPT + 99 others); Wed, 10 Feb 2021 16:41:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:59602 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232031AbhBJVlf (ORCPT ); Wed, 10 Feb 2021 16:41:35 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 567E564EDF; Wed, 10 Feb 2021 21:40:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612993254; bh=f44NPsIKdvVz4sgR73Jy/yomvy3TJguxverZulfIkv8=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=LDqSvUKK/dUgih+SoexCs2NpBSymHqLD605AiZy5maqEI/6AXrW+0vdTCv29oBcMY YCFOw/3wWb5caauRzNrqcxwD3sCdCJqnzWaAH63oGNWvDmcMwvcbp1ctcxDIx58LX3 uYloZZbhn4lEJKGkImgCuUFSGFdF/tLpU9VsdRNoacSf8dmHkmo0BKK7UNh4w4lkJu /XENEBx69/iQ83muLFq1rWDQ9od8Owbknpii8zdqtmgbKMkvaJXWRb5syq+u/1u2rS ZCC/XOr8dUuEvj/3xCBcOgyFQxtUgHARvza/bW3yo2UMR9/W7LVDY0BaJBHaMhQIgN OY6ZR9sRLKOqg== Date: Wed, 10 Feb 2021 15:40:53 -0600 From: Bjorn Helgaas To: Daniel Vetter Cc: LKML , Stephen Rothwell , linux-samsung-soc@vger.kernel.org, Jan Kara , Kees Cook , Greg Kroah-Hartman , linux-pci@vger.kernel.org, DRI Development , linux-mm@kvack.org, Jason Gunthorpe , =?iso-8859-1?B?Suly9G1l?= Glisse , John Hubbard , Bjorn Helgaas , Daniel Vetter , Dan Williams , Andrew Morton , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Subject: Re: [PATCH] PCI: Also set up legacy files only after sysfs init Message-ID: <20210210214053.GA610964@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210205133632.2827730-1-daniel.vetter@ffwll.ch> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > Cc: Stephen Rothwell > Cc: Jason Gunthorpe > Cc: Kees Cook > Cc: Dan Williams > Cc: Andrew Morton > Cc: John Hubbard > Cc: J?r?me 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 = 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 = NULL; > + struct pci_bus *pbus = NULL; > int retval; > > sysfs_initialized = 1; > @@ -1459,6 +1463,9 @@ static int __init pci_sysfs_init(void) > } > } > > + while ((pbus = 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