Received: by 10.213.65.68 with SMTP id h4csp1059022imn; Sun, 18 Mar 2018 12:54:20 -0700 (PDT) X-Google-Smtp-Source: AG47ELvlNQzTycV1/uEMmukVFUekWfiv6obu4jG+XL2OjeQoEjXDuDhxjgTyb8kqGm7Oy15u0wHh X-Received: by 2002:a17:902:51c3:: with SMTP id y61-v6mr1748531plh.355.1521402860398; Sun, 18 Mar 2018 12:54:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521402860; cv=none; d=google.com; s=arc-20160816; b=zqEF0BZ51Ct1cSEFQ2fSv9dUEVOyvZrKUs5K0Qa0Jro4D8w0p1RIClrloQLSEyjVOr g/KPwXP6Gw18YeCu97g/8yXucaUrkF85idMFCh4h/5k86RW5wxT2deSkywFqcjT+4APk 6HGrxTZF6Z8brUK2s6GZmX3pElpc4kL+utoNNpu+vc0muC0XdjyDRT3lMyXqrdNzs/bX MGGzYCX7a3rn3lFDusWcwO/UYdyq7sZ7D7fKJBecDk4keot5i1JYgnoPt5SlvLQjiD5h bMSQ6andj0rZMbaH8yZJxv4hQV7PhgS3Oj9Zzl5p9Ec1TfKpuyM/BY0PhzsYy2sJCS+k YZ4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=FC4xZArBrkUbWccXkhKw+J0tXjnie1MdTOFHjygOS4g=; b=eO2JTyXKTcyoZozIho9BkAI5q+1nsyctnryUnCQOKfGC1qREkR2kJtci1zKwdzrcEb 2zC7BJj0pLXcv5jrfsexKm2ANkYQZ6Svr+mSILRl/6AFO5Ah5l/5TDW+kfjOoQk925tO Yg/IRrxCCHwT14HMFDBq+vJ0gZZwJLX3tO9X1QsgMZwGxiaD9pedp5mC2VSxqwHuTNoE cmGywbuJOR7s7fRgZPlXbJ2zHOm+35BLhol3gxDUG+irMh5EbYY/8vhBZ1tZ+6dkwRz3 yhP2sJpsgi0Vl/aFlWPg0I1IxQz2hlvn4xTqLNwzqJZvn6xmVcs5TNl0vww32AFFgPDN KLuQ== ARC-Authentication-Results: i=1; mx.google.com; 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 bb5-v6si10366049plb.407.2018.03.18.12.54.01; Sun, 18 Mar 2018 12:54:20 -0700 (PDT) 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; 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 S1754583AbeCRTwq (ORCPT + 99 others); Sun, 18 Mar 2018 15:52:46 -0400 Received: from smtp2200-217.mail.aliyun.com ([121.197.200.217]:53809 "EHLO smtp2200-217.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754549AbeCRTwk (ORCPT ); Sun, 18 Mar 2018 15:52:40 -0400 X-Alimail-AntiSpam: AC=CONTINUE;BC=0.1509042|-1;CH=green;FP=0|0|0|0|0|-1|-1|-1;HT=e02c03290;MF=ren_guo@c-sky.com;NM=1;PH=DS;RN=11;RT=11;SR=0;TI=SMTPD_---.BMC0lr5_1521402717; Received: from localhost(mailfrom:ren_guo@c-sky.com fp:183.159.50.56) by smtp.aliyun-inc.com(10.147.44.118); Mon, 19 Mar 2018 03:51:57 +0800 From: Guo Ren To: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, daniel.lezcano@linaro.org, jason@lakedaemon.net, arnd@arndb.de Cc: c-sky_gcc_upstream@c-sky.com, gnu-csky@mentor.com, thomas.petazzoni@bootlin.com, wbx@uclibc-ng.org, Guo Ren Subject: [PATCH 07/19] csky: Atomic operations Date: Mon, 19 Mar 2018 03:51:29 +0800 Message-Id: <3bb374397444cd5a700efe1f5741e7e80d4650e7.1521399976.git.ren_guo@c-sky.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Guo Ren --- arch/csky/kernel/atomic.S | 55 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 arch/csky/kernel/atomic.S diff --git a/arch/csky/kernel/atomic.S b/arch/csky/kernel/atomic.S new file mode 100644 index 0000000..e6e9fd2 --- /dev/null +++ b/arch/csky/kernel/atomic.S @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd. +#include +#include + +.text + +/* + * int csky_cmpxchg(int oldval, int newval, int *ptr) + * + * If *ptr != oldval && return 1, + * else *ptr = newval return 0. + */ +ENTRY(csky_cmpxchg) + USPTOKSP + mfcr a3, epc + INCTRAP a3 + + subi sp, 8 + stw a3, (sp, 0) + mfcr a3, epsr + stw a3, (sp, 4) + + psrset ee +1: + ldw a3, (a2) + cmpne a0, a3 + bt16 3f +2: + stw a1, (a2) +3: + mvc a0 + ldw a3, (sp, 0) + mtcr a3, epc + ldw a3, (sp, 4) + mtcr a3, epsr + addi sp, 8 + KSPTOUSP + rte +END(csky_cmpxchg) + +/* + * Called from tlbmodified exception + */ +ENTRY(csky_cmpxchg_fixup) + mfcr a0, epc + lrw a1, 2b + cmpne a1, a0 + bt 1f + subi a1, (2b - 1b) + stw a1, (sp, 0) +1: + rts +END(csky_cmpxchg_fixup) + -- 2.7.4