Received: by 10.223.185.116 with SMTP id b49csp2709750wrg; Mon, 12 Feb 2018 14:37:59 -0800 (PST) X-Google-Smtp-Source: AH8x225lbH4Q+UjOLrrqgvOuTM9BLeaXp3lOVagobtashj72s/ndccmNcMUJSZvuYFselvbcNSLV X-Received: by 10.99.109.77 with SMTP id i74mr5304628pgc.73.1518475079746; Mon, 12 Feb 2018 14:37:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518475079; cv=none; d=google.com; s=arc-20160816; b=W6RD+5DkdJsYkjjLASaD5LBXBpe+UC/sAJrFmyCbLVrWiH2B7Q/rJn0Z6MsfaSZwFL doM08qKwaZ+DcaIjL68+WSwBDvUgqWT8+EXBksnNJGJybZDJ7rQudWNqFUvP0o5lOtX1 yXWf12whvXBGSSLgIoI9vSyOjXRVGBuGGI0c1bL0NrKpKM2Y9U7rh+1K6elkc6ImXh3s 8mAjZ/JWpO0l9Iq7Dg7hM+fV7tmGF6/QUixPnRVZ08Ty1/BbNXH8BcvhuHMLlTlCcfNY sIysrve82itBVhyH8jAjdEukoDDxhH+Vi35cVMi5iXt6Dttt0hTMHZThp0ODAsh13AIN 7trQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=bNbw5o21kCD+LtdmOOJY5z0RI933IirRkmzkmad/3Q4=; b=gv6G9U7+4eli+39RjnO6kG0nix2xZjVkU1c3nnj11bYpd7o/87bs7yZAIl5W5wYhZC yWEiXPxr3TIi7Dw8c5xLjoB8cJrfAuTu3sEpZ1JXVOPvPWBl0h8l7RelWt5dBmBqYQMg HnXEsZtT/erb8QZob6aZftvDCpgF394gP+GX2jyGw6mCo5HqwsIF0cERmzCWsLgBXEOj OLtWvoupxOc6xJwwxuLybiIA1Dkab1VgYoTBHJFWER6z+/5/JhBN4XA9KrFkFxrfkL9Y o4kBPjpRokhYPs+ipvwtJFoIuE9fehhv68ydJrbM8hxyV/3xbjKxz4jdXZU+l2gcXXXv w+sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=COT2y1E5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a59-v6si6376718plc.213.2018.02.12.14.37.45; Mon, 12 Feb 2018 14:37:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=COT2y1E5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932773AbeBLWhF (ORCPT + 99 others); Mon, 12 Feb 2018 17:37:05 -0500 Received: from mail-pl0-f65.google.com ([209.85.160.65]:39062 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932669AbeBLWhE (ORCPT ); Mon, 12 Feb 2018 17:37:04 -0500 Received: by mail-pl0-f65.google.com with SMTP id s13so2079924plq.6 for ; Mon, 12 Feb 2018 14:37:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=bNbw5o21kCD+LtdmOOJY5z0RI933IirRkmzkmad/3Q4=; b=COT2y1E5y9obNeGp+xj0p7NpVovsivLxI0thaj7Elmmm/CGGWrVLg7qFJe/nkjwfWX xson7j7BZebGn5aCITyoQd7tIZMj+gF0INOaCkTh04zuW4JGmGebgEjGqSCE+JrvZ6bW LW4gYazgFqZgPB4oxJ1X43uTYMkv3a/G7yioyA7sKS5jL9jx4BKSuykJ3ydJqZaQE0OI uowsSIN4H4gBulvatf762eAfukPkUyb4zbzHNwFebJC9EnPPfkCz6w5JBxpwkShHzDRy +37em2fHbJc5moUup7J3h96Ao50pwpIkb6yCS8SSSerOBHRZtskWmO9Zi7ylCfv0xQK2 p8/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=bNbw5o21kCD+LtdmOOJY5z0RI933IirRkmzkmad/3Q4=; b=UxXqu2KIfRS2SJz3D8HPCCLjTz+EOW1vOdKUEtm7w4H8gWickL43ortsk4RO+lB+ti 19oRhQieQ+a7hI8vy2cAEXVhrkKbv33CvgRax9PEosoZQmO2fMM/MkqLmakMt0ttV0bN GguQTi6kqijChTZJOyf+klqR8N5Q3G6NPgAjgsGg/FKAMnsp2Rgwax34btoXFTfa7KEo aEwMmZqzCKF4fbuo5Wvd9vBfoXTs3o76r52iER294M4FEHfdraMHOUbGksMEke49FIv8 nF+03YfwXO5HAXu7W/3Q1xjMZ3gbTe8t7iv6DgB0t6c7CfM72E9UVXnglUtcL/Mu1THi ZXSw== X-Gm-Message-State: APf1xPD/G+mUI9PpdQYsZz5xzEto1PnkmzlPXcoWBJwFApszqA9FOu+p bP0yxM8OvQXQ22jO3/tjZd5vzg== X-Received: by 2002:a17:902:6a16:: with SMTP id m22-v6mr12395725plk.142.1518475024053; Mon, 12 Feb 2018 14:37:04 -0800 (PST) Received: from localhost (108-223-40-66.lightspeed.sntcca.sbcglobal.net. [108.223.40.66]) by smtp.gmail.com with ESMTPSA id q68sm23492071pfb.104.2018.02.12.14.37.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Feb 2018 14:37:03 -0800 (PST) From: Guenter Roeck To: James Hogan Cc: Ralf Baechle , linux-mips@linux-mips.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [RFC PATCH] MIPS: Provide cmpxchg64 for 32-bit builds Date: Mon, 12 Feb 2018 14:37:01 -0800 Message-Id: <1518475021-3337-1-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since commit 60f481b970386 ("i40e: change flags to use 64 bits"), the i40e driver uses cmpxchg64(). This causes mips:allmodconfig builds to fail with drivers/net/ethernet/intel/i40e/i40e_ethtool.c: In function 'i40e_set_priv_flags': drivers/net/ethernet/intel/i40e/i40e_ethtool.c:4443:2: error: implicit declaration of function 'cmpxchg64' Implement a poor-mans-version of cmpxchg64() to fix the problem for 32-bit mips builds. The code is derived from sparc32, but only uses a single spinlock. Fixes: 60f481b970386 ("i40e: change flags to use 64 bits") Signed-off-by: Guenter Roeck --- Compile-tested only. arch/mips/include/asm/cmpxchg.h | 3 +++ arch/mips/kernel/cmpxchg.c | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/arch/mips/include/asm/cmpxchg.h b/arch/mips/include/asm/cmpxchg.h index 89e9fb7976fe..9f7b1df95b99 100644 --- a/arch/mips/include/asm/cmpxchg.h +++ b/arch/mips/include/asm/cmpxchg.h @@ -206,6 +206,9 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, #define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n)) #ifndef CONFIG_SMP #define cmpxchg64(ptr, o, n) cmpxchg64_local((ptr), (o), (n)) +#else +u64 __cmpxchg_u64(u64 *ptr, u64 old, u64 new); +#define cmpxchg64(ptr, old, new) __cmpxchg_u64(ptr, old, new) #endif #endif diff --git a/arch/mips/kernel/cmpxchg.c b/arch/mips/kernel/cmpxchg.c index 0b9535bc2c53..30216beb2334 100644 --- a/arch/mips/kernel/cmpxchg.c +++ b/arch/mips/kernel/cmpxchg.c @@ -9,6 +9,7 @@ */ #include +#include #include unsigned long __xchg_small(volatile void *ptr, unsigned long val, unsigned int size) @@ -107,3 +108,19 @@ unsigned long __cmpxchg_small(volatile void *ptr, unsigned long old, return old; } } + +static DEFINE_SPINLOCK(cmpxchg_lock); + +u64 __cmpxchg_u64(u64 *ptr, u64 old, u64 new) +{ + unsigned long flags; + u64 prev; + + spin_lock_irqsave(&cmpxchg_lock, flags); + if ((prev = *ptr) == old) + *ptr = new; + spin_unlock_irqrestore(&cmpxchg_lock, flags); + + return prev; +} +EXPORT_SYMBOL(__cmpxchg_u64); -- 2.7.4