Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp6205835ybv; Wed, 12 Feb 2020 07:56:23 -0800 (PST) X-Google-Smtp-Source: APXvYqx/Bv5Y7NW+TadmrsFbaNxnP1Ona2ssttD9B3tEKVO3VeDYNBPwRx3HJwiQrmNpKcTfnmoA X-Received: by 2002:aca:ed94:: with SMTP id l142mr6776770oih.58.1581522983415; Wed, 12 Feb 2020 07:56:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581522983; cv=none; d=google.com; s=arc-20160816; b=Q/dxCkXhEzaLMDCZNS1mV63oXZ4oEIkNlZk0Pm9TpYm/etgdEMBWsAh9eR6JjkWud8 s1Ehz7zIs8A85oJbdXWG7gM8XmDHcDmA4SKy8FWrrMl4Y8VF3C3u/wmN/Mp8SnXBMKFt Sdqu8hbdQmKCsUhOV5UO2oqsUCRGqMpPy47voY1Jo51NbdfMy7stPMTRaFgUt1u7htpU BoVCOfk1b5hJ6ccM1roS2DOgWILNwBlFev9SxIrs+3HiiWkF4mxf44hxG2H3GZwjMew0 ulvPxKd/+QU9dxWEuQMc7N3unmS+2LzYuSm2ft+7vHD6iOLVRWgiuxQN4GcvVQ0+WYMY LOKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=236Mw1/uA8IzDXd3kiwB4aT/6byMucMo+CkTmpwTWV4=; b=ha5U6hiURyPChaqe9+G3kLTlxfQRjnISfWVLssdTYrtm0EixWcSKxUMzPGpeOIYo0i 5/17R95lNN2/XlZbEXG98SK5J30RgDVF4D5QlmqWWWzs3kyxdcLfB1dBrsBgOO76E0Bz H2TpL+c42moxHtQ2Lg4psTZ/yuh87edGi6PfoMBjQUrStx7+5So/BdNTT/74BdIV8A8t UtjEtc03pEPhg6f7pSx9/l7bvrc4fq+gZZQw3wAuJ/64YW0r4CIJ179zgfctZjM7zcDQ Gc0tH6HRWLhxxf6tLSejaU5v035YT19BBo+eE7250afDEGiQRU4YbO1DWKtKfywstbDp iZVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=IWB2GGrr; 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 n186si3395178oig.191.2020.02.12.07.56.11; Wed, 12 Feb 2020 07:56:23 -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=@infradead.org header.s=bombadil.20170209 header.b=IWB2GGrr; 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 S1728605AbgBLPzE (ORCPT + 99 others); Wed, 12 Feb 2020 10:55:04 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:43790 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727458AbgBLPzE (ORCPT ); Wed, 12 Feb 2020 10:55:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=236Mw1/uA8IzDXd3kiwB4aT/6byMucMo+CkTmpwTWV4=; b=IWB2GGrr71/zFcxIvbhVH1hZXm ydlx9gUhkyKw9Oli8Y2DcKNQZo1bXX1ISiLawDf7LTwuduqj9WVsjHeEPjFUHMVaEKles4FJsDTdN T0er4IbprW9Lw4JM2KjnM2S08JjlV9l0gVEQTHhIP9RqZvX1NAVnlNluwQc1EPSu5bitIlMWELQnq 52dpCghtlfAtfj9komDCeR9ygX9+r48vw7E80osLdNZYP9I7U+xQYQASUliWWSkRT00l9NKXXYxLd 3tOMLJPWPyacvT2le07WKx6695JEnWanhrgTwy/xIKOyA67DPN2zbL0JFcQJuf712jLQn8fPvcJLP 884IB6PA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1j1uLu-0002bQ-Hg; Wed, 12 Feb 2020 15:55:02 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 8F20D30220B; Wed, 12 Feb 2020 16:53:11 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id CAA6C2B49C819; Wed, 12 Feb 2020 16:55:00 +0100 (CET) Date: Wed, 12 Feb 2020 16:55:00 +0100 From: Peter Zijlstra To: Michal Simek Cc: linux-kernel@vger.kernel.org, monstr@monstr.eu, git@xilinx.com, arnd@arndb.de, Stefan Asserhall load and store , Boqun Feng , Will Deacon Subject: Re: [PATCH 7/7] microblaze: Do atomic operations by using exclusive ops Message-ID: <20200212155500.GB14973@hirez.programming.kicks-ass.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 12, 2020 at 04:42:29PM +0100, Michal Simek wrote: > From: Stefan Asserhall load and store > > Implement SMP aware atomic operations. > > Signed-off-by: Stefan Asserhall > Signed-off-by: Michal Simek > --- > > arch/microblaze/include/asm/atomic.h | 265 +++++++++++++++++++++++++-- > 1 file changed, 253 insertions(+), 12 deletions(-) > > diff --git a/arch/microblaze/include/asm/atomic.h b/arch/microblaze/include/asm/atomic.h > index 41e9aff23a62..522d704fad63 100644 > --- a/arch/microblaze/include/asm/atomic.h > +++ b/arch/microblaze/include/asm/atomic.h > @@ -1,28 +1,269 @@ > /* SPDX-License-Identifier: GPL-2.0 */ > +/* > + * Copyright (C) 2013-2020 Xilinx, Inc. > + */ > + > #ifndef _ASM_MICROBLAZE_ATOMIC_H > #define _ASM_MICROBLAZE_ATOMIC_H > > +#include > #include > -#include > -#include > + > +#define ATOMIC_INIT(i) { (i) } > + > +#define atomic_read(v) READ_ONCE((v)->counter) > + > +static inline void atomic_set(atomic_t *v, int i) > +{ > + int result, tmp; > + > + __asm__ __volatile__ ( > + /* load conditional address in %2 to %0 */ > + "1: lwx %0, %2, r0;\n" > + /* attempt store */ > + " swx %3, %2, r0;\n" > + /* checking msr carry flag */ > + " addic %1, r0, 0;\n" > + /* store failed (MSR[C] set)? try again */ > + " bnei %1, 1b;\n" > + /* Outputs: result value */ > + : "=&r" (result), "=&r" (tmp) > + /* Inputs: counter address */ > + : "r" (&v->counter), "r" (i) > + : "cc", "memory" > + ); > +} > +#define atomic_set atomic_set Uuuuhh.. *what* ?!? Are you telling me your LL/SC implementation is so bugger that atomic_set() being a WRITE_ONCE() does not in fact work?