Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1383948pxb; Thu, 4 Feb 2021 11:29:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJyPxVXJLHA1Io9zsd9xMDZHDFECcRprA3GQONeTdh4diVKR7BsSHQfRrAAkggy6RpslPmkD X-Received: by 2002:a05:6402:d09:: with SMTP id eb9mr119991edb.285.1612466954632; Thu, 04 Feb 2021 11:29:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612466954; cv=none; d=google.com; s=arc-20160816; b=I0aVXBB+iemaUVI9T/uOa/rF5pOFpwCxr1+MeTZFwvwKHzRoQz6hr1OspU+MqieCol E26MrqSkZKtIj/qgktvDkeHHDZmSF0DMz0CBeZSgyBrpa/Ll90WKQoRcQvLEsg8h0ZOr MIc9lhFSYv3HCm3yG/Ucx9by9bqXwmFYeyDdnVM1TTIUr6b2Eq4uA6rI4NlTiUBuppBP NjfGgNU9NgNb+kE3AlaoDVCKb6dUkW6gAClrQe6nIvnlmXtFdA/2j0192+VQg5HQFRDu Mtz26Vz0jI7GaLrNsC9QpWCzrVUZSUJ58P3y5gzzOkVDnaSWZulsfwFk3/Xybr/Utjsw xE/A== 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=pjpQViTnfy9zJdPT1OTcZQSZ/SAyjWhVVtQHP1tzBRY=; b=MufUPIjIF82iYaiWbplSTuESrfUBAOIkQSNXwkHIjf71buzIlHioiAjkIZMoWOqq9w 0CyiIS4lh0OON3yziNji3kguQYq/Ps0RmCZaMlFCZ+4RwTDpxj09rxoiVZW/AUgS7CMy TqrH8L6xV1OJSqslnS5G6OR7JQS11hgKgtDPIRgT7/tO9FIQpG9oYRCLB/ZYqnDvadt8 FZKw12dXPPUpbV/ZgIOM1D9Rtt2MDjj8IFDi09cjxa/1HM1rwvty5wjuX6KFIA0aGSCJ kPGhGWkUkJsNwoBSjNIvVAJYiuvzaN8AfbmygqC/c4xEp/c6rIPQAzvKkfJm80Dri5c+ aWWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=Cp4q0GJh; 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 sb9si4497544ejb.162.2021.02.04.11.28.49; Thu, 04 Feb 2021 11:29:14 -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=Cp4q0GJh; 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 S237926AbhBDTZp (ORCPT + 99 others); Thu, 4 Feb 2021 14:25:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238203AbhBDQ74 (ORCPT ); Thu, 4 Feb 2021 11:59:56 -0500 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 762A9C061793 for ; Thu, 4 Feb 2021 08:58:41 -0800 (PST) Received: by mail-wm1-x32b.google.com with SMTP id 190so3763131wmz.0 for ; Thu, 04 Feb 2021 08:58:41 -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=pjpQViTnfy9zJdPT1OTcZQSZ/SAyjWhVVtQHP1tzBRY=; b=Cp4q0GJhHnTgtCNs+BZulRpkv3QXkbb/WQaLNMMiMqwCyKhuSmH0qBjFkaq9MdZ9G0 BlZsCQfEDn10zMPOMNE7h7wWcT2r55JmPCa+IrCt8f1zR+Aoj93uBi7Rg63nKXGV8rqw //pnEscML6TZjEoyQPRfdcvm9DHGnovVBhmYI= 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=pjpQViTnfy9zJdPT1OTcZQSZ/SAyjWhVVtQHP1tzBRY=; b=HImLaKgDaMSXhv3QMe/4LJTcWrYFusfXBVx767kFJ3FJqhOKYEWU9jS2/Ud05idVW7 WmSxbu9cFINxkF4A+VOPqhwa53WTrMvVvpr3n/Ryrrc6ugoMvJZxZH6zZiP4wb0Ss75/ lk59viC4xLSx61Gj8uy9PAZ0K7yC5plbCD3jZb3sSj9uSCjbl7J6R/BWBuOLYZQopkou GheSVVYAWRFKD7jZeGG+Nn93/ZtjThDzIdAb8mVefQglKyCAQshujJGogYPe6HRW7dma EK2YPkGqznF8NCx2WXWp14EedbsP2Cs6BaYgz+zJvwgElTxjOF4qRXolwhq1RVY/rF7I QkNA== X-Gm-Message-State: AOAM533PfvevW0BYMeow1AKo0g1N9pz6SKZxECePKtLayxj49uoFQtAI QZtQc1bHxmf9zZSh4xN9a7CzGJCkq/9rXUVh X-Received: by 2002:a1c:7217:: with SMTP id n23mr68437wmc.183.1612457920134; Thu, 04 Feb 2021 08:58:40 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id i64sm6700187wmi.19.2021.02.04.08.58.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 08:58:39 -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 1/2] PCI: also set up legacy files only after sysfs init Date: Thu, 4 Feb 2021 17:58:30 +0100 Message-Id: <20210204165831.2703772-2-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210204165831.2703772-1-daniel.vetter@ffwll.ch> References: <20210204165831.2703772-1-daniel.vetter@ffwll.ch> 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 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. 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. 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