Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp6004326imm; Wed, 27 Jun 2018 00:03:13 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ66TAnzzCCv+Wq6fhr4R947Q6CspLNvoAI5f0cPlDpSKaxIRUH4zPJyVT00n4pL32wBBkg X-Received: by 2002:a17:902:4d:: with SMTP id 71-v6mr4883245pla.317.1530082993498; Wed, 27 Jun 2018 00:03:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530082993; cv=none; d=google.com; s=arc-20160816; b=NuTWHJf3VuKjfJF5+rW4PuSyiuGJz2MMDDYKqFfMY7Yb318hrWNEXE4gmQhVlqKOVe /SG1g0k3oUFq+I1VLnd25isj+Bju/DMY2rMqqqSIed31kYX2i0garrr++0CDXdfdnF4/ YABsL6OAhQoQ8SGpeCkeiB82UKWlbY0FTEh36UetvFU7yBZqZ+eUcKxufGjIWTV2HJXD ma2DETvA8o3/VnPj32XkD9RNDl/FnEeTPvzFlvOploDzFSQ5NXQculT/IN77xOynzOva RJjUFhu6bwVGmNmsM3+8cCjRvH7t+eFVU8ctzQGofXyQyGegmmbaRlnHAATPOlVvXWJx wy+g== 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:dkim-signature:arc-authentication-results; bh=RW+ffQxu/MgQXrkv2w+PgByDIZeS0QEQ2ZHskf+8WFE=; b=0LfukNV06rbU+D6zDBd/OKwNgEkxZqZj86ZPKxpupK/d0IkyAfKkLXFk59iTKsakxm epnwNHqcWC1AOq04+mChidn1XlfDg6432vsnUhqP+q4cnX8HOLk/pnKUR/9aBk++utvk iu9kL+FXrwFpTa/dg4ms3fuQ8McL5d7XKHDt4GMNkVGIzdAYzSL4msLv/vUBeEZW7yXj 6zQgTp32Tvm8TF+0y3nmXz58iRzO0x8YVaFk65cratPljVK1dCdj8Bk0W/wdUdee+DKQ wxtAe75maALp/LiUK2Ob8/So2IzsFfkh2kFh+qPLvZFGXjZhKZE7f0Dy0J5f3IqgSzs2 QmnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=U24smYfm; 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 d5-v6si3298337plr.13.2018.06.27.00.02.59; Wed, 27 Jun 2018 00:03:13 -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=U24smYfm; 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 S932245AbeF0HCG (ORCPT + 99 others); Wed, 27 Jun 2018 03:02:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:46562 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752095AbeF0HBx (ORCPT ); Wed, 27 Jun 2018 03:01:53 -0400 Received: from localhost (unknown [106.201.61.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7335325791; Wed, 27 Jun 2018 07:01:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1530082913; bh=DHnTsjADK66S93R77642TYs8G4jHOm/8Arr1nxj5Iz0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=U24smYfmQI9ZjWlk2+JJKQIITRW06xtcrGhaxmyLEXeJts07Pqz455Wq8O3K/8Cpd 1qSRL5bBjmIGEprcjkYlKJez3G/kUWFj/tox7D72gVK3WcnN+XCZKK8tpjJk3/EQS+ QNMmqvnmHS0dfmOpzCCqzT5HbrwvekkOXOHJczAw= Date: Wed, 27 Jun 2018 12:31:44 +0530 From: Vinod To: Stephan Mueller Cc: Herbert Xu , Stanimir Varbanov , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Matt Mackall , Arnd Bergmann , Greg Kroah-Hartman , linux-arm-msm@vger.kernel.org Subject: Re: [PATCH 3/3] hwrng: msm - Add support for prng v2 Message-ID: <20180627070144.GG22377@vkoul-mobl> References: <20180619142853.wgi5easw4zv6ttrb@gondor.apana.org.au> <52764537.cSZCttAJ1I@tauon.chronox.de> <20180627062701.GF22377@vkoul-mobl> <170012246.0U45yCEtus@tauon.chronox.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <170012246.0U45yCEtus@tauon.chronox.de> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Stephan, Thanks for quick reply, On 27-06-18, 08:43, Stephan Mueller wrote: > > On 27-06-18, 08:13, Stephan Mueller wrote: > > > The key is: > > > alg->base.cra_ctxsize = sizeof(struct drbg_state); > > > > > > during initialization since the kernel crypto API allocates that buffer > > > for > > > you and releases it during deallocation. > > > > The difference here is that memory is allocated by crypto and driver has > > no way to pass "it's" own data while doing registration. Ideally > > registration should accept a pointer/long and pass that back on a > > callbacks > > Looking at your code, it seems you do what makes sense: there is only one > instance of the driver, if at all. Thus, having qcom_rng_dev as static makes > sense. The kernel crypto API allows arbitrary instances of the RNG as well as > frequent allocations and deallocations. And this is why there must be a > disconnect between the one hardware-resource driver-instance data structure > and the (potentially) multiple crypto API RNG instances and their data > structures. For now it is true, but somehow doesn't make me happy to bank on that.. > > > > Currently am doing bunch of initialization in .probe (platform driver) > > and I think recommendation would be to move that to .cra_init, which seem > > plausible but I don't have pdev to read hw_resource etc.. so would still > > need to get that. > > It seems that your allocation during probe relates to the hardware resource > where you only have one in the system. Thus, doing the allocation here makes > sense. And, you do not want to perform probe or such resource allocation once > per crypto API RNG instance allocation. As said, there can be multiple or even > they can be allocated and deallocated frequently. This in particular applies > if your driver's "stdrng" has the highest prio which means that it will be > allocated and deallocated frequently. Right, that is how I visualized it. Is there a way where we can tweak the register API to pass hw_resource pointer and get that back? Would that work with the security model in crypto. I do not like globals and somehow don't feel that we should do it that way Thanks for the quick look on the code. ~Vinod