From patchwork Mon Apr 9 07:46:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 10330703 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B3BAB60236 for ; Mon, 9 Apr 2018 07:46:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A699628AA0 for ; Mon, 9 Apr 2018 07:46:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B45728AA4; Mon, 9 Apr 2018 07:46:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 200CC28AA0 for ; Mon, 9 Apr 2018 07:46:21 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 7A63221F2E0FA; Mon, 9 Apr 2018 00:46:21 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c00::242; helo=mail-pf0-x242.google.com; envelope-from=oohall@gmail.com; receiver=linux-nvdimm@lists.01.org Received: from mail-pf0-x242.google.com (mail-pf0-x242.google.com [IPv6:2607:f8b0:400e:c00::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id DFC2621F2E0ED for ; Mon, 9 Apr 2018 00:46:19 -0700 (PDT) Received: by mail-pf0-x242.google.com with SMTP id g14so5406360pfh.3 for ; Mon, 09 Apr 2018 00:46:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Co0Pr1flt1el9u19kk4tLSLHhjjesuCbrAA5jzrEv54=; b=mgBy8si0JQ0wWshHY1AvWz9ognT2Ia/ujcwO/E3+D4jdnCXG22g8/z4jqkWhtPXUAC e0Ej7xw8RfQt6ZKf3F8FPBfzFYrTHGej1WZFzsSIRm2uoRlxWrW4ID5GFKStLsOkCjFp Jq0I3puIS/Rr+Nmy7UcJ/+XDK+j5J8Sf+7uyW/OcY82pp7zp4CO9M6E0C90lyptVYbIe t4XbUGAYkbfuPvSmTIypLXc5MNKL5TxM9avvAURNKm+j95Q6+GHPGg6NRvdWCp8XTS5D zRTFSWKGsr2GSWKAvgMRWBd7YbvbvG/G8HHVqU4PCW4D+51vSfygDOh8NFBZF5ApDwyZ 0y1Q== 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; bh=Co0Pr1flt1el9u19kk4tLSLHhjjesuCbrAA5jzrEv54=; b=WX+ctr1j6XbspcvkF347fqcry+Wl/G6nFNgSwyEq0PlVHAmosn58Xq08W5pUsS5CY0 B+jF/ZJBweQh0v8Z/mvuf/YPEAmlVe4bnPr8ZukvMXfGxtBJwukxuESwaO76XJcISEqI jSqWN+M3OSARThPwWZn7IsxJQlWGt9spZLXCQLVl6KXZrQSVz1+dPN/KvLdu1PqACbu6 x/RVOqaT2wIOgwDW/Y0N+GqmT4PaF0wqfyXTnjMtmsxgF5+qB7kf+Aljq4Sz+gyZd1u4 mpDgJdGGPbFJhtRpVO9kQUCCSsQfatebJR8ENjqf8vzJT7TLIxtXdLP2SMd0qi6Li75g WmEw== X-Gm-Message-State: ALQs6tDLpBSyQ+pj3slXWXVPhyytomhbAbdQJVbFlvPYSkf/GsMcTeCp sYpKGJb8bevy47Sj2rx4axw= X-Google-Smtp-Source: AIpwx4+4e+KFgKnmST7Y0DDeTzBQqjxS0FaS9c/kdCsdcVbL/C+7mS/+mijlG88A1DH0f3YZVvCKVg== X-Received: by 10.99.117.93 with SMTP id f29mr10442489pgn.197.1523259979423; Mon, 09 Apr 2018 00:46:19 -0700 (PDT) Received: from flat-canetoad.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id 67sm31858861pfz.57.2018.04.09.00.46.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Apr 2018 00:46:18 -0700 (PDT) From: Oliver O'Halloran To: linux-kernel@vger.kernel.org Subject: [PATCH] drivers/of: Introduce ARCH_HAS_OWN_OF_NUMA Date: Mon, 9 Apr 2018 17:46:04 +1000 Message-Id: <20180409074604.17671-1-oohall@gmail.com> X-Mailer: git-send-email 2.9.5 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sfr@canb.auug.org.au, devicetree@vger.kernel.org, linux-nvdimm@lists.01.org, sparclinux@vger.kernel.org, linuxppc-dev@lists.ozlabs.org MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Some OF platforms (pseries and some SPARC systems) has their own implementations of NUMA affinity detection rather than using the generic OF_NUMA driver, which mainly exists for arm64. For other platforms one of two fallbacks provided by the base OF driver are used depending on CONFIG_NUMA. In the CONFIG_NUMA=n case the fallback is an inline function in of.h. In the =y case the fallback is a real function which is defined as a weak symbol so that it may be overwritten by the architecture if desired. The problem with this arrangement is that the real implementations all export of_node_to_nid(). Unfortunately it's not possible to export the fallback since it would clash with the non-weak version. As a result we get build failures when: a) CONFIG_NUMA=y && CONFIG_OF=y, and b) The platform doesn't implement of_node_to_nid(), and c) A module uses of_node_to_nid() Given b) will be true for most platforms this is fairly easy to hit and has been observed on ia64 and x86. This patch remedies the problem by introducing the ARCH_HAS_OWN_OF_NUMA Kconfig option which is selected if an architecture provides an implementation of of_node_to_nid(). If a platform does not use it's own, or the generic OF_NUMA, then always use the inline fallback in of.h so we don't need to futz around with exports. Cc: devicetree@vger.kernel.org Cc: sparclinux@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org Fixes: 298535c00a2c ("of, numa: Add NUMA of binding implementation.") Signed-off-by: Oliver O'Halloran --- arch/powerpc/Kconfig | 1 + arch/sparc/Kconfig | 1 + drivers/of/Kconfig | 3 +++ drivers/of/base.c | 7 ------- include/linux/of.h | 2 +- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index c32a181a7cbb..74ce5f3564ae 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -625,6 +625,7 @@ config NUMA bool "NUMA support" depends on PPC64 default y if SMP && PPC_PSERIES + select ARCH_HAS_OWN_OF_NUMA config NODES_SHIFT int diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index 8767e45f1b2b..f8071f1c3edb 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig @@ -299,6 +299,7 @@ config GENERIC_LOCKBREAK config NUMA bool "NUMA support" depends on SPARC64 && SMP + select ARCH_HAS_OWN_OF_NUMA config NODES_SHIFT int "Maximum NUMA Nodes (as a power of 2)" diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig index ad3fcad4d75b..01c62b747b25 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig @@ -103,4 +103,7 @@ config OF_OVERLAY config OF_NUMA bool +config ARCH_HAS_OWN_OF_NUMA + bool + endif # OF diff --git a/drivers/of/base.c b/drivers/of/base.c index 848f549164cd..82a9584bb0e2 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -84,13 +84,6 @@ int of_n_size_cells(struct device_node *np) } EXPORT_SYMBOL(of_n_size_cells); -#ifdef CONFIG_NUMA -int __weak of_node_to_nid(struct device_node *np) -{ - return NUMA_NO_NODE; -} -#endif - static struct device_node **phandle_cache; static u32 phandle_cache_mask; diff --git a/include/linux/of.h b/include/linux/of.h index 4d25e4f952d9..9bb42dac5e65 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -942,7 +942,7 @@ static inline int of_cpu_node_to_id(struct device_node *np) #define of_node_cmp(s1, s2) strcasecmp((s1), (s2)) #endif -#if defined(CONFIG_OF) && defined(CONFIG_NUMA) +#if defined(CONFIG_OF_NUMA) || defined(CONFIG_ARCH_HAS_OWN_OF_NUMA) extern int of_node_to_nid(struct device_node *np); #else static inline int of_node_to_nid(struct device_node *device)