Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2352918pxb; Fri, 5 Feb 2021 16:08:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJyEwD2YHM6i4QgIvZbunjfy2rCRbJ1WmD7i+l8ltWjgHYr9Sj/DlSmWmPew8eevks3ZCPcq X-Received: by 2002:a17:906:af58:: with SMTP id ly24mr6556916ejb.208.1612570082535; Fri, 05 Feb 2021 16:08:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612570082; cv=none; d=google.com; s=arc-20160816; b=h9/mRZOCa8WD4hpRE1VHGGtrO7/6e6bdVj0/JQdx1Jm4RggRr+SW0dY84toQ/tOVSc m82QqSE+r+7hrKezPiixjWWy+2PepTHyvANHMHyUwYsaI+qeQ23jXAh7R5/aE1YTkkOG QcjAiQoysUxhsad8GHI72e5MPjBGP6/fWXEpZkpX70mRA0pkBbhJV337DgmeBje5ua79 5E6McgUV30FVeQJxyFIR/JwZfuhgKqmmXS7RmF438MBsmOO0CcsJ/jQjEZp1F4sJnFMq qChsaeY5woxLeMYLXklytm5q4tD7sg3J/8jJsNRnCSS/52yIgiex6dVKutJWENTQHdfO 8NuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1gQoFS6ud405970AWgVagisJdKuspo0iHcNG3yO+v+Y=; b=e0kAy0pWnZbW5U7yLyn/MNFPMGFW6LPVzbrpCOtDz7h18DRapxqL9MuGAyRRrAF2v5 wEl+yigZ2Sos2oIJ7t0Xrw1NQKGFlGpOxEejFEhVsLJzbR5X7CzPbtueUxS1+CkduIw8 Xl+p58nj+n88DMAvA+2VqjX2qzVhi/zefyazfRdZFZmrq7xB8HQUVs3+SZgqIO/WA6bC FKf0d076TRT0GEMM/WnpNR7gw6N/+fFRIZKu8qpBHAmlLzrTzsH8tfML/UR/3JGMhJSZ suRwGetNt7w9mG7+DmA9YYcpyrA6sXK0rvuJOSTpPVpGfb21yZx/QODB0ISxcRFefGoC 1a3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=ZFx74dwX; 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 ku3si6187180ejc.497.2021.02.05.16.07.38; Fri, 05 Feb 2021 16:08:02 -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=ZFx74dwX; 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 S231452AbhBFAFc (ORCPT + 99 others); Fri, 5 Feb 2021 19:05:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230094AbhBENhT (ORCPT ); Fri, 5 Feb 2021 08:37:19 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48650C061786 for ; Fri, 5 Feb 2021 05:36:39 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id u14so7743941wri.3 for ; Fri, 05 Feb 2021 05:36:39 -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=fmYR86OkqG5FWo+C0U3WTNqu9CVF155leYoImHxM6o2qP7vDcVTVjDP7t0G64hynwG gAeqzvm5dPgeA7cJAOqJCisVE2qK2t9SWVNG01v46LmzlrObxE3LfJK758d/iPsMfPQl a3p/zbvusVHYwBg/3fE6Tz7+5pGlLuIM0eAk8oEqZr2BMiMMIYJZMJ18IR/Tt2RPh+O/ 51swyjlmv6vBue8TyxsNGk/FIaCnwmqTfDuTRleGQYArsC7bk3uimimpfCLbBqGKYdn+ LUHvribyEXqRV1MeW4d3H+Q4xh6zgtxdaWn7/IsSDcHTJlQ6bVGtsvR/vXxVZI3kXlVR Ei7A== X-Gm-Message-State: AOAM532xw9ILHGW6Be2DkzZW1qwd2fr6oMX8sIer8YBF9xglnHKxQDZn hI7f/R1kXDE0WHva5OyGbwEY+J/yHEahg9Mg 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 Cc: DRI Development , Daniel Vetter , Daniel Vetter , Stephen Rothwell , Jason Gunthorpe , Kees Cook , Dan Williams , Andrew Morton , John Hubbard , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Jan Kara , Greg Kroah-Hartman , linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-media@vger.kernel.org, Bjorn Helgaas , linux-pci@vger.kernel.org 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 --- 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