Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1136914pxf; Fri, 2 Apr 2021 02:08:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyOM4j9SiUPCtSK04tY0BJ1GZhQTYNoB5F7Epne/UOZR6Zzwfcms+xTZSbWFnMlIayWQ2zv X-Received: by 2002:aa7:d5c9:: with SMTP id d9mr15070537eds.102.1617354532416; Fri, 02 Apr 2021 02:08:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617354532; cv=none; d=google.com; s=arc-20160816; b=lLJqLhTx6M6DR6AKO20GNIJVPCszLMdpnvvzFtWYdxhPE6g6PPNcxXLjpwKD0cRLP0 BmNQVQuX2oajipbElkKXpP4ZnajaDzZMckWmyICKzqtdA4pX/cV9rFXF4w9JYaa2NWoH jOXV4AJIFveKYCelim7KZ/kbPMckTePbWvBIVLVo+BQVgMfB+yAFcZ5/nqwfRwuzIt4I fiCeh4lIVTjEPSVf7FHkZriIdC9fOw2RWB27B3FXwm0PQsfXIfXLS06S110zU8CsmaMp MIb7ium/I3ctioJ8YzhHR0CRa5QWjQoZtY3VJq6UIe9TF4cHQKP7TyI1hUE4L7VbHkEp 7pxA== 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; bh=P2C9PtCzzqyXNx60dzByV8fxnUkQlQW4kbo3GE4RAdo=; b=z6wzd5AQsuAp2qzUeavQyJaHr3qURkuOGXjXc4S1AbVtsPpwRA3ACZQZWxpUkJuM4b zvPmrdaQv5hzYgBTRAn/hh+NrL0UVMClBFKzp+IjJPRdWwV38fKsbnguSDGl13mVmsC/ 6NNElBsKO7P6GKULsU8AlgmREzmaDtqsxfeIGE+chw2TBMElwLZdcX1BrzmA/Cqc3Laz 5WcDASB306L2523SSrFIjYnoi2u6//ecatKB8VZ2KkJ+eHX3Cf5x5/KPA9v1ADvFvddz MubYzWJrs93koe7N1TzL9BxTYV6gm6MKfCMMCQK5ynvJLrfT0KqHzDF/8Cmrn0Dm9GDW Jc4A== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=marcan.st Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dj7si6007725edb.378.2021.04.02.02.08.23; Fri, 02 Apr 2021 02:08:52 -0700 (PDT) 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; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=marcan.st Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234161AbhDBJHZ (ORCPT + 99 others); Fri, 2 Apr 2021 05:07:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234860AbhDBJHO (ORCPT ); Fri, 2 Apr 2021 05:07:14 -0400 Received: from mail.marcansoft.com (marcansoft.com [IPv6:2a01:298:fe:f::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B9C9C06178A; Fri, 2 Apr 2021 02:07:12 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hector@marcansoft.com) by mail.marcansoft.com (Postfix) with ESMTPSA id 0F19242725; Fri, 2 Apr 2021 09:07:04 +0000 (UTC) From: Hector Martin To: linux-arm-kernel@lists.infradead.org Cc: Hector Martin , Marc Zyngier , Rob Herring , Arnd Bergmann , Olof Johansson , Krzysztof Kozlowski , Mark Kettenis , Tony Lindgren , Mohamed Mediouni , Stan Skowronek , Alexander Graf , Will Deacon , Linus Walleij , Mark Rutland , Andy Shevchenko , Jonathan Corbet , Catalin Marinas , Christoph Hellwig , "David S. Miller" , devicetree@vger.kernel.org, linux-doc@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 11/18] asm-generic/io.h: implement pci_remap_cfgspace using ioremap_np Date: Fri, 2 Apr 2021 18:05:35 +0900 Message-Id: <20210402090542.131194-12-marcan@marcan.st> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210402090542.131194-1-marcan@marcan.st> References: <20210402090542.131194-1-marcan@marcan.st> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that we have ioremap_np(), we can make pci_remap_cfgspace() default to it, falling back to ioremap() on platforms where it is not available. Remove the arm64 implementation, since that is now redundant. Future cleanups should be able to do the same for other arches, and eventually make the generic pci_remap_cfgspace() unconditional. Signed-off-by: Hector Martin --- arch/arm64/include/asm/io.h | 10 ---------- include/linux/io.h | 21 +++++++++++++-------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/arch/arm64/include/asm/io.h b/arch/arm64/include/asm/io.h index 953b8703af60..7fd836bea7eb 100644 --- a/arch/arm64/include/asm/io.h +++ b/arch/arm64/include/asm/io.h @@ -171,16 +171,6 @@ extern void __iomem *ioremap_cache(phys_addr_t phys_addr, size_t size); #define ioremap_wc(addr, size) __ioremap((addr), (size), __pgprot(PROT_NORMAL_NC)) #define ioremap_np(addr, size) __ioremap((addr), (size), __pgprot(PROT_DEVICE_nGnRnE)) -/* - * PCI configuration space mapping function. - * - * The PCI specification disallows posted write configuration transactions. - * Add an arch specific pci_remap_cfgspace() definition that is implemented - * through nGnRnE device memory attribute as recommended by the ARM v8 - * Architecture reference manual Issue A.k B2.8.2 "Device memory". - */ -#define pci_remap_cfgspace(addr, size) __ioremap((addr), (size), __pgprot(PROT_DEVICE_nGnRnE)) - /* * io{read,write}{16,32,64}be() macros */ diff --git a/include/linux/io.h b/include/linux/io.h index d718354ed3e1..6f6b9233f2c3 100644 --- a/include/linux/io.h +++ b/include/linux/io.h @@ -82,20 +82,25 @@ void devm_memunmap(struct device *dev, void *addr); #ifdef CONFIG_PCI /* * The PCI specifications (Rev 3.0, 3.2.5 "Transaction Ordering and - * Posting") mandate non-posted configuration transactions. There is - * no ioremap API in the kernel that can guarantee non-posted write - * semantics across arches so provide a default implementation for - * mapping PCI config space that defaults to ioremap(); arches - * should override it if they have memory mapping implementations that - * guarantee non-posted writes semantics to make the memory mapping - * compliant with the PCI specification. + * Posting") mandate non-posted configuration transactions. This default + * implementation attempts to use the ioremap_np() API to provide this + * on arches that support it, and falls back to ioremap() on those that + * don't. Overriding this function is deprecated; arches that properly + * support non-posted accesses should implement ioremap_np() instead, which + * this default implementation can then use to return mappings compliant with + * the PCI specification. */ #ifndef pci_remap_cfgspace #define pci_remap_cfgspace pci_remap_cfgspace static inline void __iomem *pci_remap_cfgspace(phys_addr_t offset, size_t size) { - return ioremap(offset, size); + void __iomem *ret = ioremap_np(offset, size); + + if (!ret) + ret = ioremap(offset, size); + + return ret; } #endif #endif -- 2.30.0