From patchwork Sat Aug 11 16:08:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniy Paltsev X-Patchwork-Id: 956573 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=synopsys.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="VThTwu+z"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.b="OTp+BqMR"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41nn4P4GN7z9s9F for ; Sun, 12 Aug 2018 02:09:25 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=I0X7qEkfFFSDQ+ScBr2ym3fbMJrqIqT03k735dnrmzo=; b=VTh Twu+zM7w4A7qs99gScyPLhKw4boainp+O7a6POn6rvvHGKi1aEZWf6w/hl2ZaZ6Fh6/ENf8T1OwIt 2TIYOt07sfMyz6pd0yaLP4ShKYEM97kKGIy1/SC0p3bqcYAuJeh90MpNd8M1HRaKpNaJLpVdr5JKU JVWIyrU8/RnLDmyCPrXfoh9L15QEUJdV07L1kgUtiKrd/9BM8DmQfg8LK7QPPMU4HZ09VXRaYvwPn LVLoI1WsrIksQzAlLaOjY6H1r8H07FY+moLJA9V0D4eZbKCZOrPdfSBn/sNg0M0DQBcFooDMxvtt6 GKQv7tHdQK8TEWXW2kxWlLijyOU0+DQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1foWSB-00023t-Iz; Sat, 11 Aug 2018 16:09:23 +0000 Received: from smtprelay2.synopsys.com ([198.182.60.111] helo=smtprelay.synopsys.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1foWS9-00022p-9z for linux-snps-arc@lists.infradead.org; Sat, 11 Aug 2018 16:09:22 +0000 Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id 2CD5610C087E; Sat, 11 Aug 2018 09:09:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1534003745; bh=6oMecutyGk97An4ahqNcn/BG17MCKYXdRN1ejPwkub8=; h=From:To:Cc:Subject:Date:From; b=OTp+BqMRvfi7cU4mbfGExK2ATNU+Y3/QyliMhEIhxFY6LfqYGEzZmjpE1CXtMfZPk d4QRkZiqueWAXkxZSF7eaRK0A9ElVHgbSKSZysIiN2Mh5uUvJanlAPJdc/rpl2NLnR D7i/OxcI7c0T4imUA9LNk/i2pj1v1r8UMGOfMSrl4U2FGzeUVYT5lIBsiZMDA6KBew ra5CIdzJCg+MPCinMD2cLxvq8dYakx026cO9gGDTRpHmVnBAK52T4UR8fwZeo7ST5C HWCbPmDZiZLHz5nsA4bu6wWKtUfv+JBpTz+ysff1Z2qFXk851s/LDdghD4ji3scMUn Ah5430pm3TFGA== Received: from paltsev-e7480.internal.synopsys.com (unknown [10.121.8.86]) by mailhost.synopsys.com (Postfix) with ESMTP id 8FF053D01; Sat, 11 Aug 2018 09:09:02 -0700 (PDT) From: Eugeniy Paltsev To: linux-snps-arc@lists.infradead.org Subject: [PATCH] ARC: atomic64: fix atomic64_add_unless function Date: Sat, 11 Aug 2018 19:08:56 +0300 Message-Id: <20180811160856.24936-1-Eugeniy.Paltsev@synopsys.com> X-Mailer: git-send-email 2.14.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180811_090921_359105_0B03551D X-CRM114-Status: GOOD ( 10.87 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [198.182.60.111 listed in list.dnswl.org] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Zijlstra , Vineet Gupta , Alexey Brodkin , Will Deacon , linux-kernel@vger.kernel.org, Eugeniy Paltsev , Boqun Feng MIME-Version: 1.0 Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Current implementation of 'atomic64_add_unless' function (and hence 'atomic64_inc_not_zero') return incorrect value if lover 32 bits of compared 64-bit number are equal and higher 32 bits aren't. For in following example atomic64_add_unless must return '1' but it actually returns '0': --------->8--------- atomic64_t val = ATOMIC64_INIT(0x4444000000000000LL); int ret = atomic64_add_unless(&val, 1LL, 0LL) --------->8--------- This happens because we write '0' to returned variable regardless of higher 32 bits comparison result. So fix it. NOTE: this change was tested with atomic64_test. Signed-off-by: Eugeniy Paltsev --- arch/arc/include/asm/atomic.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arc/include/asm/atomic.h b/arch/arc/include/asm/atomic.h index 11859287c52a..e840cb1763b2 100644 --- a/arch/arc/include/asm/atomic.h +++ b/arch/arc/include/asm/atomic.h @@ -578,11 +578,11 @@ static inline int atomic64_add_unless(atomic64_t *v, long long a, long long u) __asm__ __volatile__( "1: llockd %0, [%2] \n" - " mov %1, 1 \n" " brne %L0, %L4, 2f # continue to add since v != u \n" " breq.d %H0, %H4, 3f # return since v == u \n" " mov %1, 0 \n" "2: \n" + " mov %1, 1 \n" " add.f %L0, %L0, %L3 \n" " adc %H0, %H0, %H3 \n" " scondd %0, [%2] \n"