From patchwork Fri Feb 5 13:36:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 12070135 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=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT 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 99523C433DB for ; Fri, 5 Feb 2021 13:37:59 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3B2C464FA7 for ; Fri, 5 Feb 2021 13:37:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3B2C464FA7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=c/XrK1sZ06X0d2YQSq4rtLNJfke84h0GY3nvkr+eXC0=; b=QErF4UJp6j/GWyJBGixGYciOx UxYZ4GPCWOT7oChG4TUfrAb84mVJbmfx4ckBDRGmKGe+78qDYtw0rOzlC2It/wV6wZ6rBXHhmi/dY Gn08WALUkIiahBTiQ7SzA2XH20AXcez7mxqgEtcZ2hkn9EiITdJAC947rnlstlnRkIiTeaQnYahtf B+r3qPO5KsV3gduT4KSd8icWluolnnEWN94u1KiPh+KXnKeRs734GvLLFZAE9KmxEzNE+wNfmh/5f Rt1VxIZA3cqOBJixe+oEvkJlKSoVKt/PGymPsovNkQUMdtjhlOylWFkQp96f0W446tCNf61Sj1dcr tmgbnrZeQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l81Hw-0001Iw-JO; Fri, 05 Feb 2021 13:36:44 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l81Ht-0001HG-47 for linux-arm-kernel@lists.infradead.org; Fri, 05 Feb 2021 13:36:42 +0000 Received: by mail-wr1-x42d.google.com with SMTP id v15so7722558wrx.4 for ; Fri, 05 Feb 2021 05:36:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1gQoFS6ud405970AWgVagisJdKuspo0iHcNG3yO+v+Y=; b=ZFx74dwXRN8XJoI8vReT6nG84gTmG6QDsKTETcJ06jTJw70JqS2qOLWzaeIPJLa2+q i3A1Tex+NtYld5e4GVoxTw0izBPXMnjweumu4hA9cypntxtKgmAi+PLJzkGHZ1RqPeVy tW/D5qIVWDn/14kg51lcnIhmcjtyQwf70EOXU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1gQoFS6ud405970AWgVagisJdKuspo0iHcNG3yO+v+Y=; b=aTTQTXwAyHmsWWrZGufsT1AvWvg31YdpF+ETSWgoeXoz0rqL6jaKuF6Yx+0dUwJUXv AYDIE4O6M5oZoPOvUp8uJVYgpRWxZiftcw7E+Zy+GGntulc4Jbk/7FLzs/mpPTYD9g9A UmT/A/gAKGzVISB7y2g6VJbq1C16aPvJEkeN5ghEijdatZSHw7GU3sKSRrTdyiIwTyMQ cN7WCpNmNW12cpqw9IMd7L+y2zprFFa8iGqKv1gOiwOaquFC0NV5nNZERECFQLpsMPcR VVTDnnt/NoSIkP5wuFFTrwEVpeJ36iRNRJdmgxaA8Kkp4ii+Tblw2pVCHOWvYYoTr/8l cXwQ== X-Gm-Message-State: AOAM532EQMAo47CyLGOmuh7AWT83/qWqG47Lnld/0pvKiJJ92IsVs0if tpjDyebUIyOToPTj2IacXt0h/Q== X-Google-Smtp-Source: ABdhPJzWE2gxGEZn4lzZcDo3tutehy5qX/E9j/4aIeZc6b9+p2my5zf6hrvCeUW2K6Drt8e7TSvqBw== X-Received: by 2002:a5d:5283:: with SMTP id c3mr4938476wrv.319.1612532197971; Fri, 05 Feb 2021 05:36:37 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id z8sm11944234wrh.83.2021.02.05.05.36.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 05:36:37 -0800 (PST) From: Daniel Vetter To: LKML Subject: [PATCH] PCI: Also set up legacy files only after sysfs init Date: Fri, 5 Feb 2021 14:36:32 +0100 Message-Id: <20210205133632.2827730-1-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.30.0 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210205_083641_191354_D4BC69C7 X-CRM114-Status: GOOD ( 18.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stephen Rothwell , linux-samsung-soc@vger.kernel.org, Jan Kara , Kees Cook , Greg Kroah-Hartman , Daniel Vetter , linux-pci@vger.kernel.org, DRI Development , linux-mm@kvack.org, Jason Gunthorpe , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , John Hubbard , Bjorn Helgaas , Daniel Vetter , Dan Williams , Andrew Morton , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 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 Acked-by: Bjorn Helgaas --- 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);