Received: by 10.223.164.202 with SMTP id h10csp5941201wrb; Tue, 21 Nov 2017 19:02:54 -0800 (PST) X-Google-Smtp-Source: AGs4zMY5zFso+tb5/tu6IRgT84QWMdCoeuQXqxpS0464bazqPDkyjdS52oRxEtIoZA1uwVjr5BnU X-Received: by 10.101.81.72 with SMTP id g8mr8240876pgq.135.1511319774654; Tue, 21 Nov 2017 19:02:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511319774; cv=none; d=google.com; s=arc-20160816; b=AqYO+8iC7f8mYtuSW/Gn38uf3MXju3IR8BfLNkQxefhHunNvC/SIEO+O7kU43QJE1g 9MDfzw2bz2gcOKxgpAjUJ44nq4283siQ979Kav3hgHQv5DIyBdu6uGclMEby303bUcBS BkKW44c6mN8LHMK5tuQlxw2lpBYW5Nuqxr4hpH6bHigvf0TQCxWnCao63qj2GglvR7zT 4pFvxdA0owzVdJ9kztWDK8d1d50S0iodalJSYUJFW/594iYnPh50uKo3KH3cHqY+Vf/Y i0P3Uc/qoVpE0STh9USL1bVPiUsat1lEg+x5Eht2bi0/ouHQ+cseYFTWvzitzEcmJEr6 m5ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=XvRdEjQQDX5kM34wjooxkauphISxsAHB6ZFT9D+FVF4=; b=ID2KvreK3hLaJqutWJfRzCATO0+Nasr24FqZV4eMiQxv6VmgYjKkuA8+oa6X2QdYsX DTQ1Fd79sZ0vVIghwj4f/rmeO9+18DTbHLgO9o8Ly2JIfiSum7lV1GEXmDV3OxLsfFry FNlbAcmrBePsjnTBYscTmuV/Mh2uPOQKZUAo9Hc9uIC40odr4LqH+uyi8TfeAr0Mxu9G e5yEQJt7AfVjTZgXCoP+0hNMn177Z0jGemhhzxmHu8jJl2qGsWveKrqb9AdMLIvCX7rC pyMcr2VNGpVPV7kyDd1qagDiY04YRuLyq6i2cmp6m2nbInvjZA2iiLP3wM4by0Dn0sAf Utyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tYoVWcl2; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h3si248856pgr.714.2017.11.21.19.02.43; Tue, 21 Nov 2017 19:02:54 -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=pass header.i=@gmail.com header.s=20161025 header.b=tYoVWcl2; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752591AbdKVDCI (ORCPT + 76 others); Tue, 21 Nov 2017 22:02:08 -0500 Received: from mail-it0-f65.google.com ([209.85.214.65]:43460 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751565AbdKVDCF (ORCPT ); Tue, 21 Nov 2017 22:02:05 -0500 Received: by mail-it0-f65.google.com with SMTP id m191so4504145itg.2; Tue, 21 Nov 2017 19:02:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=XvRdEjQQDX5kM34wjooxkauphISxsAHB6ZFT9D+FVF4=; b=tYoVWcl2ZNQTxvVbGoPQJjfyCKFocWhrJ6lyUsql9EKS6ZxFF690XyI/5EQW0y53Ho YgQO0zedXMRyuqFHQ1dIQ/80kggODHpxfFnwNsUow+S/KviHUo9QMGoBYZigsET7SFMp 1e8OpXm2wZEeFBn/0xGM+W24WEyByXmWzRl4uWALr4dt81HsQem4PQiDvhtuI+BlW64g 0WxVlrDP4hM0d0932QoSDpP0V4wahENu4n10Hgu3VTnnYFKtnfhi8YYfxDsItJ0P/VWX c+bdv7ybX1HZsyup/3cTt+qabd5bRHaGKrCIGtJvNhnTXO+cTPNe0xU3NIgYsv4x7i50 jgeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=XvRdEjQQDX5kM34wjooxkauphISxsAHB6ZFT9D+FVF4=; b=O8edmcHaR1Wcz28vLV3myDbDcGzeT0g7knG4lRykruaMKqDBa8qXZWtTzt4H38xRQ6 zsd1CjXxGcLmVbdsL0XT6+VaWZr7uT/mql5FmhbFy/ft8KEQr4AruxirO4lz6/QNxpxa i0twXOP3Ai0L8KLTO9OVXJd4y6VIVBr3JyXyXqptbaZJQ751b05NshKY/AYxtYPX7eE4 zG5wYtGmLYmXnUU4HybATkQVvzZTN0Y/aZAGhvtNEVhOR+DSg4u3Ys+TWaUcQCxUiPoR kkjNa/bj288jLifCn397qKWlPEtQGdwc3OIN+N31BYVAU1QQo0meNuJbJvTDaxEOtGIT MMIw== X-Gm-Message-State: AJaThX4xh7zfxswPN1Wd2i4ahWuMLvbKgXb1HFqhCZjBDdGABGzysBzs v/SC93QT4PRuJ770osmgEHTx5oDDsnVI0ZoVXxAjcg== X-Received: by 10.36.40.207 with SMTP id h198mr5197702ith.95.1511319724105; Tue, 21 Nov 2017 19:02:04 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.7.91 with HTTP; Tue, 21 Nov 2017 19:02:03 -0800 (PST) In-Reply-To: <20171120142925.GC32488@arm.com> References: <20171120142925.GC32488@arm.com> From: Vincent Chen Date: Wed, 22 Nov 2017 11:02:03 +0800 Message-ID: Subject: Re: [PATCH 11/31] nds32: Atomic operations To: Will Deacon Cc: Greentime Hu , greentime@andestech.com, linux-kernel@vger.kernel.org, Arnd Bergmann , linux-arch@vger.kernel.org, tglx@linutronix.de, jason@lakedaemon.net, marc.zyngier@arm.com, robh+dt@kernel.org, netdev@vger.kernel.org, Vincent Chen , peterz@infradead.org, paulmck@linux.vnet.ibm.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2017-11-20 22:29 GMT+08:00 Will Deacon : > Hi Greentime, > > On Wed, Nov 08, 2017 at 01:54:59PM +0800, Greentime Hu wrote: >> From: Greentime Hu >> >> Signed-off-by: Vincent Chen >> Signed-off-by: Greentime Hu >> --- >> arch/nds32/include/asm/futex.h | 116 ++++++++++++++++++++++++ >> arch/nds32/include/asm/spinlock.h | 178 +++++++++++++++++++++++++++++++++++++ >> 2 files changed, 294 insertions(+) >> create mode 100644 arch/nds32/include/asm/futex.h >> create mode 100644 arch/nds32/include/asm/spinlock.h > > [...] > >> +static inline int >> +futex_atomic_cmpxchg_inatomic(u32 * uval, u32 __user * uaddr, >> + u32 oldval, u32 newval) >> +{ >> + int ret = 0; >> + u32 val, tmp, flags; >> + >> + if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32))) >> + return -EFAULT; >> + >> + smp_mb(); >> + asm volatile (" movi $ta, #0\n" >> + "1: llw %1, [%6 + $ta]\n" >> + " sub %3, %1, %4\n" >> + " cmovz %2, %5, %3\n" >> + " cmovn %2, %1, %3\n" >> + "2: scw %2, [%6 + $ta]\n" >> + " beqz %2, 1b\n" >> + "3:\n " __futex_atomic_ex_table("%7") >> + :"+&r"(ret), "=&r"(val), "=&r"(tmp), "=&r"(flags) >> + :"r"(oldval), "r"(newval), "r"(uaddr), "i"(-EFAULT) >> + :"$ta", "memory"); >> + smp_mb(); >> + >> + *uval = val; >> + return ret; >> +} > > I see you rely on asm-generic/barrier.h for your barrier definitions, which > suggests that you only need to prevent reordering by the compiler because > you're not SMP. Is that right? If so, using smp_mb() is a little weird. > Thanks. So, Is it better to replace smp_mb() with mb() for us? > What about DMA transactions? I imagine you might need some extra > instructions for the mandatory barriers there. > I don't get it. Do you mean before DMA transations? Data are moved from memory to device, we will writeback data cache before DMA transactions. Data are moved from device to memory, we will invalidate data cache after DMA transactions. > Also: > >> +static inline void arch_spin_lock(arch_spinlock_t * lock) >> +{ >> + unsigned long tmp; >> + >> + __asm__ __volatile__("1:\n" >> + "\tllw\t%0, [%1]\n" >> + "\tbnez\t%0, 1b\n" >> + "\tmovi\t%0, #0x1\n" >> + "\tscw\t%0, [%1]\n" >> + "\tbeqz\t%0, 1b\n" >> + :"=&r"(tmp) >> + :"r"(&lock->lock) >> + :"memory"); >> +} > > Here it looks like you're eliding an explicit barrier here because you > already have a "memory" clobber. Can't you do the same for the futex code > above? > Thanks. OK. I will modify it in the next version patch. > Will Best regards Vincent From 1584595696306523897@xxx Mon Nov 20 14:30:17 +0000 2017 X-GM-THRID: 1583483471237188505 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread