Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1792imm; Thu, 30 Aug 2018 07:01:40 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaxPXOwBWOUXu6E2z4hdmx4LqXpZQ7XMLO7lEseqRnXivCHy1XYalIjXBIr8PMaxTPMr8G1 X-Received: by 2002:a17:902:4d45:: with SMTP id o5-v6mr10375844plh.78.1535637700548; Thu, 30 Aug 2018 07:01:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535637700; cv=none; d=google.com; s=arc-20160816; b=BffbT477JxIUY1ScilrHsMxJ6joBm+l6aNP50PXramNot+DZLuRKChLnfRtMo6wDh9 ubNEjz0eVVtQ/o3HdiHfEmmW1zZx3+xWCKTnRacpGFmBzRYCGKZcATxXKrA2n++eS09e z2fpgx+3ai8aqAP4Y6VkkqE3Ud/3nvMVQtoP06Q5gYCjOBI+wlLf7hB2rJ0zusSIXWlC h7YfjIiYhcpxRsXlc4EgbbWyfpGHWvTCrx9d2Y8t6bqn7TaN0Bs6y5lxh9HtF6uI1QZu +tg3Tyu63i7m1JKQflGb87VyDTeZkbWg17EChttY+f0uqDXS3v8KpJ6TxWv5L045Xa6r mNsQ== 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:dkim-signature :arc-authentication-results; bh=46iSn1dRgmidl9MGnxFSTXHpsIcGWOUVqVGHodivsPs=; b=nXb+kryxIIU0GE2ARYqoX5EpGDy8kU+Gu/nik18aLxVHAOC2MSPlDtpT5L8T9SMzwn RJ5Qo7musdrYCLO4I/DElGZdCptzl56wx96sUQLu8MNLxWE/hFfSww3trT9CohJURt+f GcPrXLLh4+Kh5P/f2nWew2jXcfr919AqOotCXlYshPseh7QRfn66OUd6Y6A//YtDmP7E t63Dolt+ZpvphSZqiKU05nCRxGqKRYuZ9D7X/2EoiAvkFrB/A/DwxXxawZyhjSv2heDt NMfWgO0bSWUq2UEF5ioylg1/Ac7EyRMvrPJRfIUXcAsQCV0SJtiAwWx5Vy2aQsijGvEM HtQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qvkryEsd; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d6-v6si6633123pgi.506.2018.08.30.07.01.23; Thu, 30 Aug 2018 07:01:40 -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; dkim=pass header.i=@kernel.org header.s=default header.b=qvkryEsd; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729134AbeH3SCV (ORCPT + 99 others); Thu, 30 Aug 2018 14:02:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:38782 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728273AbeH3SCU (ORCPT ); Thu, 30 Aug 2018 14:02:20 -0400 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 593C420837; Thu, 30 Aug 2018 14:00:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1535637604; bh=1xt5Oju/LA5eT/tMsK8FqwU2jENVEt36up7ILXM8nPk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=qvkryEsdNtPq19SmNk6AKoHyAgdTa4uvWWXRykK2XvTXgN+jJ1+Y0IcbnO0IDcGEl YKgjz3M/Th1Jx4D+POGpgBG2d1LCF0kn3g2ZTRyfF+UHd7vMoQ/eiMEZlAyQPNr4tl r0Zk0r4ri61iyXwZjqsgHvQRXGCn2Kjcow820LxI= Received: by mail-wr1-f53.google.com with SMTP id k5-v6so8164984wre.10; Thu, 30 Aug 2018 07:00:04 -0700 (PDT) X-Gm-Message-State: APzg51Acbq1RZLfZI5z5vjyvSeVWwhNyD4aVf9met+BY3yv0bqHBipVu ZWUHC4jNUHhrfQNRdjpFicN8nXZazV4mURQ3VhY= X-Received: by 2002:adf:b726:: with SMTP id l38-v6mr7344507wre.115.1535637602886; Thu, 30 Aug 2018 07:00:02 -0700 (PDT) MIME-Version: 1.0 References: <3053033.se6UkFii4W@tauon.chronox.de> <20180830132732eucas1p12b941ed065276c0cbed6e7b1e01a30dc~PrH1zJtnY2603926039eucas1p1b@eucas1p1.samsung.com> In-Reply-To: <20180830132732eucas1p12b941ed065276c0cbed6e7b1e01a30dc~PrH1zJtnY2603926039eucas1p1b@eucas1p1.samsung.com> From: Krzysztof Kozlowski Date: Thu, 30 Aug 2018 15:59:51 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Locking for HW crypto accelerators To: k.konieczny@partner.samsung.com Cc: smueller@chronox.de, herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org 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 On Thu, 30 Aug 2018 at 15:27, Kamil Konieczny wrote: > > On 30.08.2018 15:09, Krzysztof Kozlowski wrote: > > [...] > > Thanks Stephan for hints. Let's assume the each of init, update and > > final are atomic... but how about the relation between update and > > final? I have two concurrent users in user-space but only one HW: > > > > Process A: Process B: > > init() and set_key() > > init() and different key > > update(some_data) > > update(different_data) > > final() > > final() > > > > The final() from process A will now produce the result of hashing/CRC > > of some_data and different_data (and even maybe mixed with init() for > > different key). All because in the meantime process B added its own > > data to the HW. > > > > Best regards, > > Krzysztof > Can your hardware do export/import ? > > If yes, you can use workqueue and guard HW with spinlock, > as in exynos hash in s5p-sss.c (or see other drivers). Yes, workqueue doing all necessary HW initialization would be the solution here as well. The point is what later Herbert wrote - I need to take care about the HW state because the requests even for shash will be coming in random order. Best regards, Krzysztof