Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp1802946ybj; Sun, 22 Sep 2019 12:15:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqzcv67FzlO8mvVB6tLta4S1Oj2ZpEpTNw1NF4B4rYA0PWCqMAvENjCvUNFzZUjVJFqiSAaU X-Received: by 2002:a17:906:4b47:: with SMTP id j7mr26240250ejv.63.1569179748476; Sun, 22 Sep 2019 12:15:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569179748; cv=none; d=google.com; s=arc-20160816; b=sOEx7T6tp9pk3PXsK9124CwJvNhWR2e7QRu1X9iBBX9CM5C4X6ypkyD5IviauhEXSv /yhXOu76Ig/rGRpcyTNG5AWMAGqxwMk7hlIfH31aTnhxpHTfIflJG3/s4UeckPbn+owa ZPdHuOEskPH++xbKFrZAHaUTjuvBI/RAem/4eo+k7KvHUAAKJAKz0+WBEGngybwIXdEy enEgtQp6afEFgBuDuLYbTOhkBHLFW9JCtpDHBeQXyE44OiKJ6yvOBZgaGKnM+5zs6WjA h6msjj4YMQ9CY3PAy1Hq4Yu3X7F6NXSiVKitzF+95HaYgXuUoM+iZcpK11AeyPBvi3Nr T+hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=v13ps7++3YF/KDW3aCdy3F7aYHC4OHBs8pbMHSDP0cg=; b=aso2OLvD1TAR77Lkpg8giKtYnRIrrdxWIP4KdDJNRNwCVXZxuu/rZTmIJGBDxg2m09 VHyWZycs+iwYuZNwItB6NeNcRWrpdari8TleKbvvgc6LkM197Zc2PukK24E3fUtmBhso fjKmNKQfQ6C+kFwKuAuD1A4yhjLaQ7h4BIDZ2pfjmtD/yRHCRRayt67vbLO+OQx2K98V zgSWdAsTTYj4JjwDA9Oyym+3YUYXOYVOo58QTeitGOjr597m6Oliw9RdvSMkfgLJg46t BbTYnqAl9+NQWbVfnpOduG78y9qEZOsCOiQSoIgGVKJ0dyYR8nVzKo7u8IJEZApmpEW3 gakw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-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 x29si5147801eda.297.2019.09.22.12.15.23; Sun, 22 Sep 2019 12:15:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-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-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731120AbfIUK1C (ORCPT + 99 others); Sat, 21 Sep 2019 06:27:02 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:57052 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731118AbfIUK1B (ORCPT ); Sat, 21 Sep 2019 06:27:01 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id D436A1EC664417B2B364; Sat, 21 Sep 2019 18:26:59 +0800 (CST) Received: from [127.0.0.1] (10.63.139.185) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.439.0; Sat, 21 Sep 2019 18:26:49 +0800 Subject: Re: [PATCH 2/2] [v2] crypto: hisilicon - allow compile-testing on x86 To: John Garry , Arnd Bergmann References: <20190919140650.1289963-2-arnd@arndb.de> <20190919140917.1290556-1-arnd@arndb.de> <531214d6-2caf-2963-0f57-2cd615a18762@huawei.com> CC: Herbert Xu , "David S. Miller" , Jonathan Cameron , Kenneth Lee , Mao Wenan , "Hao Fang" , Shiju Jose , "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , "linux-kernel@vger.kernel.org" , Will Deacon From: Zhou Wang Message-ID: <5D85FAEC.9060607@hisilicon.com> Date: Sat, 21 Sep 2019 18:26:52 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <531214d6-2caf-2963-0f57-2cd615a18762@huawei.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.63.139.185] X-CFilter-Loop: Reflected Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On 2019/9/20 22:16, John Garry wrote: > On 20/09/2019 14:36, Arnd Bergmann wrote: >> On Fri, Sep 20, 2019 at 3:26 PM Arnd Bergmann wrote: >>> >>> On Fri, Sep 20, 2019 at 10:34 AM John Garry wrote: >>> >>>>> + if (!IS_ENABLED(CONFIG_ARM64)) { >>>>> + memcpy_toio(fun_base, src, 16); >>>>> + wmb(); >>>>> + return; >>>>> + } >>>>> + >>>>> asm volatile("ldp %0, %1, %3\n" >>>>> "stp %0, %1, %2\n" >>>>> "dsb sy\n" >>>>> >>>> >>>> As I understand, this operation needs to be done atomically. So - even >>>> though your change is just for compile testing - the memcpy_to_io() may >>>> not do the same thing on other archs, right? >>>> >>>> I just wonder if it's right to make that change, or at least warn the >>>> imaginary user of possible malfunction for !arm64. >>> > > Hi Arnd, > >>> It's probably not necessary here. From what I can tell from the documentation, >>> this is only safe on ARMv8.4 or higher anyway, earlier ARMv8.x implementations >>> don't guarantee that an stp arrives on the bus in one piece either. >>> >>> Usually, hardware like this has no hard requirement on an atomic store, >>> it just needs the individual bits to arrive in a particular order, and then >>> triggers the update on the last bit that gets stored. If that is the case here >>> as well, it might actually be better to use two writeq_relaxed() and >>> a barrier. This would also solve the endianess issue. >> >> See also https://lkml.org/lkml/2018/1/26/554 for a previous attempt >> to introduce 128-bit MMIO accessors, this got rejected since they >> are not atomic even on ARMv8.4. > > So this is proprietary IP integrated with a proprietary ARMv8 implementation, > so there could be a tight coupling, the like of which Will mentioned in that thread, > but I'm doubtful. > > I'm looking at the electronically translated documentation on this HW, and it reads > "The Mailbox operation performed by the CPU cannot be interleaved", and then tells > that software should lock against concurrent accesses or alternatively use a 128-bit > access. So it seems that the 128b op used is only to guarantee software is atomic. > > Wang Zhou can confirm my understanding We have to do a 128bit atomic write here to trigger a mailbox. The reason is that one QM hardware entity in one accelerator servers QM mailbox MMIO interfaces in related PF and VFs. A mutex can not lock different processing flows in different functions. As Arnd mentioned, v8.4 extends the support for 16 bytes atomic stp to some kinds of normal memory, but for device memory, it is still implementation defined. For this SoC(Kunpeng920) which has QM/ZIP, if the address is 128bit aligned, stp will be atomic. The offset of QM mailbox is 128bit aligned, so it is safe here. Best, Zhou > > If true, I see that we seem to be already guaranteeing mutual exclusion in qm_mb(), > in taking a mutex. > > Thanks, > John > > >> >> Arnd >> >> . >> > > > > . >