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: 896153 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40KMqH6YFtz9s0n for ; Mon, 9 Apr 2018 17:48:11 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="mgBy8si0"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40KMqH4rwdzF29l for ; Mon, 9 Apr 2018 17:48:11 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="mgBy8si0"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c00::242; helo=mail-pf0-x242.google.com; envelope-from=oohall@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="mgBy8si0"; dkim-atps=neutral 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 lists.ozlabs.org (Postfix) with ESMTPS id 40KMn962xZzDrnk for ; Mon, 9 Apr 2018 17:46:21 +1000 (AEST) Received: by mail-pf0-x242.google.com with SMTP id u86so5413571pfd.2 for ; Mon, 09 Apr 2018 00:46:21 -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=pOy+kk70xMwi2eeNDA8tMW9Dcm/OSRAezxlmDnXCQmzs9952BzHOx6rhTK/5m63XPQ gJz0nGBUr65eDIGmeSim3CDVzV5cGVbqq5hq9fWaCQ6/WN2DeziTU3tXzKEMI4qp+t/q A+5mDCenrh8GXUcw8JDNGxWd0Jd2PHGaFMYj21GsElYo98qUibGQmJqxuN1USBhtR+K/ 9oDeb2lE2zBS53krmtPD48/6zceABfby2nK7I8UgOdXsUtWr/dEtXLY4Hwr3dv4jdc7+ pIUelwL6mTAQN2eUCXrOiI1mMhxAJ+DLm6BFACPtyQcqxuWEs1C76xezso71tCbC7Jpa pDuQ== X-Gm-Message-State: ALQs6tA2DJuwhJBem+AlU6qQ7qW4UdXcy89Rf0dbIS4Dw16uJ8G0Dou3 vpWY2/LgHCdXedfBWkKfrY4= 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: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail 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, Oliver O'Halloran , sparclinux@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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)