Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4197782ybv; Sun, 16 Feb 2020 16:23:39 -0800 (PST) X-Google-Smtp-Source: APXvYqxs4+7jexqVj6uf0LOrDwGAp1/UsJBe+YYL0Pbnm+JOrenPuYTyqrzbmdm+TtAQ/GIW2vaP X-Received: by 2002:aca:1b11:: with SMTP id b17mr8604157oib.45.1581899018944; Sun, 16 Feb 2020 16:23:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581899018; cv=none; d=google.com; s=arc-20160816; b=Rs1BDVdXA7NuZAXloHvtamdkJXdZ37ykq8c+dklM5nMztC58gvAd1XoLmqIDQxZL+F OqppgaBuRzzghJgrjtH8QfReMM2isA2ib17y7usx/AVPqY7mT1e+UZa4TvIrznGEysCa Im0Os7py8h+wdd1sFOh0aO6z+UgguwTBnxzDTwKIkkwUWNzdX/0HdGRudsPf2FgacblE 1NKfkvl3dbzCOCHAx4+ImNBoeby6iyJrGVW8HW7Yjk+1IKJ8O2kQz/PHG5GWtfQ3Kusp ESi9Nq46S0ozBNqx1khNwGmjkVmeXlW/yP12YAevp1UdX4Dm9B3TKZk/YpYhIj4QGCg/ W6hg== 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 :in-reply-to:references:mime-version; bh=RvBPrsaf/vx3QAte1Qnpsp+hszyxo6KbY+gYM2/7LjA=; b=DSr/mc+qnkaAo5gassNYYJ8hA94tVb6cLr2LjQrPQHwrxQPc4X6Ooc0qB/3xX+rMBx 3K9tezbM2xvqkgqE6BFnMp7OdhjnZ26u3bUFK6ORIkq/Rf62JQKye3fVxWTp5NF2xecp /YfP0uNOPBSX1bdr36KmK6rVwuV8hu7Rz0emFcgDAHC2D8Y6khynUS7wj3j3W5qJFdjW sbeiKu4rMZQ/dXr8YXfhzugd3MwN5z97EkgN8pVy2zlyYrBz/Z+5rM2S5kq+vRjEeA1Z G2SPuarUKo+fMUvoX3IqxMChXELmgwq+xpf9jmk+rG+sS3bzzuMg/z8NY1mD+aLYQ/Ny zojA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=amsat.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d22si6451995oti.316.2020.02.16.16.23.14; Sun, 16 Feb 2020 16:23:38 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=amsat.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726251AbgBQAXC (ORCPT + 99 others); Sun, 16 Feb 2020 19:23:02 -0500 Received: from mail-yw1-f65.google.com ([209.85.161.65]:36336 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726099AbgBQAXC (ORCPT ); Sun, 16 Feb 2020 19:23:02 -0500 Received: by mail-yw1-f65.google.com with SMTP id n184so7166607ywc.3; Sun, 16 Feb 2020 16:23:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RvBPrsaf/vx3QAte1Qnpsp+hszyxo6KbY+gYM2/7LjA=; b=e8nko6o8jnyQyJikRA1fe5DZNTm6bYrKK+LVuMwN4L5yV1lpe3Y3Q89oC08chKlN5f 07gM/qKk5hXZDaRl3+4KcT0TYvEruuLIL9Em7hVwCpBbYlD8e3Sx/a6L37oEHcRLPgDP Aj8OdwOtqjnxDGQqQCNKzrdeinxKrrjvQBAdmWe4oP4i+DLsuliIfr4Y6ylRyg8tnTxt hZl1050AaXQPet92kyn2ptGmB+ynMyUp03u+j7pW5uQy7apRsK0px75LTfBSBw7TCy5x +CICS4fGzT8/m4Ls1KpcAQs3fJEJr1kxf1Uu6U+tTPCG9dlt+LQtGJfQ9+T/+i+Kkzjf Ug3A== X-Gm-Message-State: APjAAAVrilw6XuqqbcA1Cm452G7CJfx6bC7kcMzLEelW+TQYesSUuX6Q sO03ceGlVqzLBbExLmfT+a7A096v9zVzrr/AkMo= X-Received: by 2002:a81:4f8b:: with SMTP id d133mr11513961ywb.368.1581898981330; Sun, 16 Feb 2020 16:23:01 -0800 (PST) MIME-Version: 1.0 References: <20200211212455.3307-1-mark.tomlinson@alliedtelesis.co.nz> In-Reply-To: <20200211212455.3307-1-mark.tomlinson@alliedtelesis.co.nz> From: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= Date: Mon, 17 Feb 2020 01:22:50 +0100 Message-ID: Subject: Re: [PATCH] MIPS: cavium_octeon: Fix syncw generation. To: Mark Tomlinson Cc: Paul Burton , "open list:BROADCOM NVRAM DRIVER" , chris.packham@alliedtelesis.co.nz, open list 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 Hi Mark, On Tue, Feb 11, 2020 at 10:42 PM Mark Tomlinson wrote: > > The Cavium Octeon CPU uses a special sync instruction for implementing > wmb, and due to a CPU bug, the instruction must appear twice. A macro > had been defined to hide this: > > #define __SYNC_rpt(type) (1 + (type == __SYNC_wmb)) > > which was intended to evaluate to 2 for __SYNC_wmb, and 1 for any other > type of sync. However, this expression is evaluated by the assembler, > and not the compiler, and the result of '==' in the assembler is 0 or > -1, not 0 or 1 as it is in C. The net result was wmb() producing no code > at all. The simple fix in this patch is to change the '+' to '-'. Isn't this particular to the assembler implementation? Can you explicit the assembler you are using in the commit description? Assuming we have to look at your commit in 3 years from now, we'll wonder what assembler you were using. Thanks, Phil. > Fixes: bf92927251b3 ("MIPS: barrier: Add __SYNC() infrastructure") > Signed-off-by: Mark Tomlinson > --- > arch/mips/include/asm/sync.h | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/arch/mips/include/asm/sync.h b/arch/mips/include/asm/sync.h > index 7c6a1095f5..aabd097933 100644 > --- a/arch/mips/include/asm/sync.h > +++ b/arch/mips/include/asm/sync.h > @@ -155,9 +155,11 @@ > * effective barrier as noted by commit 6b07d38aaa52 ("MIPS: Octeon: Use > * optimized memory barrier primitives."). Here we specify that the affected > * sync instructions should be emitted twice. > + * Note that this expression is evaluated by the assembler (not the compiler), > + * and that the assembler evaluates '==' as 0 or -1, not 0 or 1. > */ > #ifdef CONFIG_CPU_CAVIUM_OCTEON > -# define __SYNC_rpt(type) (1 + (type == __SYNC_wmb)) > +# define __SYNC_rpt(type) (1 - (type == __SYNC_wmb)) > #else > # define __SYNC_rpt(type) 1 > #endif > -- > 2.25.0 >