Received: by 10.223.164.221 with SMTP id h29csp2481505wrb; Mon, 30 Oct 2017 04:54:28 -0700 (PDT) X-Google-Smtp-Source: ABhQp+S+6bKEkjxmgrvXalcT4RwQTRLuyzpkJZ3xH2kQfcWKcT8JtQQI/Xyo0d28qXytY/ljpbaF X-Received: by 10.101.92.202 with SMTP id b10mr7693644pgt.164.1509364468799; Mon, 30 Oct 2017 04:54:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509364468; cv=none; d=google.com; s=arc-20160816; b=SV0HsB/HvXKRTJ2WxPK/quVaDhw2JJ5vPMBYbOQuznKLWK+Yl1k/fvY1m+E1YTbOeS +VS0VeGSd3AkaYo/xgjBPilytrEERRKXEd2/GkDoLAgZMMW0r0NJV6Ee/J2rvcONe9Ln mg0ePxgX7S9yvJMSTkH3H4zWyEOc2utoHXJM2QhSosmkoWI7RUbsgLJPBWAcRsrmbeFb r0adiJAsXyudltMxheAsk4A0bDudwUeoPYFf31oi9F7R61Ot4Wyg2yZnYR8AaYi1GuX0 k6PEHtfhFjTxDXEMY5qeGEWHXd/GGMBE74RS7Thwes+IFXyyqWnDIz0sdBF7cHIoeLU7 Iw4A== 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:arc-authentication-results; bh=O6bTFF7IaTjmQZCVg0A2IIsnMa8fLtYU3oSMm+pZpQo=; b=uW/h1yXnt8uyAxZMLnGetTpjT39B9z5qF7JPs7CzoXB3bn3BeT7bMp8CeXu9RfPyNu 7SDux/hDj7m9bUJ+RujsvyvXJaHbSFTcw2XAo+5iD4bapNC8wkruvAuHkjarZxiAJHWI iI5inOZNSF1TkOqRKIYuFr+lYnrXLmYQM6fg1hG1r/q5T7PSeKHsIYjE15FWqU4zbOOq czvSW6ngbdhLxbuwG8iuJ60ldAqxG5GZGTEiZU4KEEoaAUyIZehhXQw43Wbm5ULTddaT +hjRYFQSekA8DeyhC+ZsRcRzaXTP4SENsWau3Bl5I9IFCIYrGYvW0KciLt8fbMoChWCG 6MYA== 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 m12si9189572pln.482.2017.10.30.04.54.15; Mon, 30 Oct 2017 04:54:28 -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 S1753177AbdJ3Lhl (ORCPT + 99 others); Mon, 30 Oct 2017 07:37:41 -0400 Received: from foss.arm.com ([217.140.101.70]:51048 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752821AbdJ3Lhi (ORCPT ); Mon, 30 Oct 2017 07:37:38 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C8DDE1529; Mon, 30 Oct 2017 04:37:37 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1DF1B3F483; Mon, 30 Oct 2017 04:37:34 -0700 (PDT) Date: Mon, 30 Oct 2017 11:37:32 +0000 From: Mark Rutland To: Leo Yan Cc: Kaihua Zhong , robh+dt@kernel.org, xuwei5@hisilicon.com, catalin.marinas@arm.com, will.deacon@arm.com, jassisinghbrar@gmail.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, guodong.xu@linaro.org, haojian.zhuang@linaro.org, suzhuangluan@hisilicon.com, xuezhiliang@hisilicon.com, kevin.wangtao@hisilicon.com Subject: Re: [PATCH v2 2/3] mailbox: Add support for Hi3660 mailbox Message-ID: <20171030113732.dajsdj3lcm2qjxke@lakrids.cambridge.arm.com> References: <1509084904-2505-1-git-send-email-zhongkaihua@huawei.com> <1509084904-2505-3-git-send-email-zhongkaihua@huawei.com> <20171027104559.em5n5ogro46ethmq@salmiak> <20171030044506.GE31478@leoy-ThinkPad-T440> <20171030101940.dtf6rw7alhkn6irf@lakrids.cambridge.arm.com> <20171030111313.GF31478@leoy-ThinkPad-T440> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171030111313.GF31478@leoy-ThinkPad-T440> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 30, 2017 at 07:13:13PM +0800, Leo Yan wrote: > Hi Mark, > > On Mon, Oct 30, 2017 at 10:19:40AM +0000, Mark Rutland wrote: > > Hi, > > > > On Mon, Oct 30, 2017 at 12:45:06PM +0800, Leo Yan wrote: > > > On Fri, Oct 27, 2017 at 11:46:00AM +0100, Mark Rutland wrote: > > > > On Fri, Oct 27, 2017 at 02:15:03PM +0800, Kaihua Zhong wrote: > > > > > +static int hi3660_mbox_check_state(struct mbox_chan *chan) > > > > > +{ > > > > > > > + /* Ensure channel is released */ > > > > > + writel_relaxed(0xffffffff, base + MBOX_IMASK_REG); > > > > > + writel_relaxed(BIT(mdev->ack_irq), base + MBOX_SRC_REG); > > > > > + __asm__ volatile ("sev"); > > > > > + return 0; > > > > > +} > > > > > > > > Drivers really shouldn't be using SEV directly (even if via the > > > > sev() macro)... > > > > > > > > This SEV isn't ordered w.r.t. anything, and it's unclear what > > > > ordering you need, so this simply does not work. > > > > > > I will leave your questions for Hisilicon colleagues, essentially your > > > questions are related with mailbox mechanism. > > > > > > But I'd like to firstly get clear your question for "This SEV isn't > > > ordered w.r.t. anything". From my understanding, ARMv8 architecture > > > natually adds DMB before SEV so all previous register writing > > > opreations should be ensured to endpoint before SEV? > > > > This is not the case; SEV does not add any implicit memory barrier, and > > is not ordered w.r.t. memory accesses. > > > > See ARM DDI 0487B.b, page D1-1905, "The Send Event instructions": > > > > The PE is not required to guarantee the ordering of this event with > > respect to the completion of memory accesses by instructions before > > the SEV instruction. Therefore, ARM recommends that software > > includes a DSB instruction before any SEV instruction. > > My fault and thanks for explanation. > > > Note that a DMB is not sufficient, as SEV is not a memory access. > > Understood now, so below code should be safe? > > wmb(); -> dsb(st); > sev(); Whether that is safe depends on what you are trying to ensure is ordered, and what the other side (with the WFE) is doing. For example, my understanding is that in general, WFE is also not ordered w.r.t. memory accesses. This is a very subtle part of the architecture, and I'm very much not keen on using WFE and SEV outside of architecture code implementing locking primitives. Thanks, Mark. From 1582656413211236525@xxx Mon Oct 30 04:46:12 +0000 2017 X-GM-THRID: 1582390514550393253 X-Gmail-Labels: Inbox,Category Forums