Received: by 10.213.65.68 with SMTP id h4csp282601imn; Tue, 20 Mar 2018 03:31:05 -0700 (PDT) X-Google-Smtp-Source: AG47ELvYUiUxd7YIIU3COdjWTk+LHKELDh0Ht5Ds2FchUZVJRk8dUFr2hMjwiMFEMtZcszApad9J X-Received: by 2002:a17:902:bd94:: with SMTP id q20-v6mr16163978pls.364.1521541865197; Tue, 20 Mar 2018 03:31:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521541865; cv=none; d=google.com; s=arc-20160816; b=BjmsPQ6FGntxCgOFvsepbQ1tNGHFdIWD0QL8KdOgRBkx27zTjsyY8t6w00ZUOlRJcx h2JP5VyGlzuRVUgXnvJN+p+4YmLS+5zWsxbM/MMWYT01z5GGYMVqPjlNHLQHYbyHCOLY sKTgU/FIRR2h2NXgVphx8JjPNlT2PJhZAdrl90ugXbpr4tF+nmH1zNwTsLbl3vR2eWX+ l3Oqs4zo4DZZfxS1bq4XueDZXDhBM+Ql/2OulnkI428QiXeqP5epec4mTMNa1Eq+KA16 jxrIhrwBAoSwoU/vaS9VflXuIsRAaeLncxQKkpLp0AvwOXpnO7OxrnCcIfpEMKNsC1MH xA0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=BN8M92tV7XsbK03nKT3EmF+8kZXB4BbKP8sA96dfbRE=; b=Q7sNPULo+WENvgAtEi50uuz7CTL+sIw1w3xZdliRcrpgu2M+zUxDPjwmco3+cawhqO wRqmVvrpsI3T8O6l5iEJmcC2QYgP/u4bHk9LqccaRqSZe8tgxc8G8Z0AzR/hmBKqchEy s0Xuo//yl9bpVkLAO1BF3U6nxwbuB7ZBJHp0YoisgTAZskTvtERcdUADuAG8IFfzwmsY 2lvVSXHAoX22ZOZlZEcDx1lIEuoP1b4lgDZkw53BkNKk5FJ98eKW8t2TXDkW76bBguAM 2iMHMRAN8Ze77+ti5PMefdLCWjQU7EfU8s5VMyWmdx94O95s9HeQGETsomFMbIcAApc5 LyGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector1 header.b=ryC0DeXg; 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=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g11si1013887pgf.5.2018.03.20.03.30.50; Tue, 20 Mar 2018 03:31:05 -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=@nxp.com header.s=selector1 header.b=ryC0DeXg; 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=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752636AbeCTK3w (ORCPT + 99 others); Tue, 20 Mar 2018 06:29:52 -0400 Received: from mail-eopbgr00057.outbound.protection.outlook.com ([40.107.0.57]:55232 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752244AbeCTK3t (ORCPT ); Tue, 20 Mar 2018 06:29:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=BN8M92tV7XsbK03nKT3EmF+8kZXB4BbKP8sA96dfbRE=; b=ryC0DeXgC6F4oIBg7gu4TJpzi8pSWM/BHAfZZhNylzQTrPAc58bJWBMnDVhp3VeD1lWPqNfl+vuPMW/Aa/ViU5+51q7pZkf6Yx2BHlPHwgkTyQG6YnH1KegfUs0Ch5U/PW7GFup0yyJRt2oQnvv1rS8w24y7/MFeMBcAmYihNb8= Received: from DBXPR04MB463.eurprd04.prod.outlook.com (10.141.232.154) by DBXPR04MB144.eurprd04.prod.outlook.com (10.242.140.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.588.14; Tue, 20 Mar 2018 10:29:45 +0000 Received: from DBXPR04MB463.eurprd04.prod.outlook.com ([fe80::bd4e:5832:a1a1:e2a]) by DBXPR04MB463.eurprd04.prod.outlook.com ([fe80::bd4e:5832:a1a1:e2a%16]) with mapi id 15.20.0588.017; Tue, 20 Mar 2018 10:29:45 +0000 From: =?iso-8859-2?Q?Horia_Geant=E3?= To: Kamil Konieczny , Herbert Xu , "David S. Miller" , Jonathan Corbet CC: "linux-crypto@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-doc@vger.kernel.org" , Bartlomiej Zolnierkiewicz Subject: Re: [PATCH v2] crypto: doc - clarify hash callbacks state machine Thread-Topic: [PATCH v2] crypto: doc - clarify hash callbacks state machine Thread-Index: AQHTwCh9gcjc1z/CcUO3XGrj5FBtzw== Date: Tue, 20 Mar 2018 10:29:45 +0000 Message-ID: References: <20180305103945.3517-1-horia.geanta@nxp.com> <20180320075612.22719-1-horia.geanta@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=horia.geanta@nxp.com; x-originating-ip: [86.34.165.90] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DBXPR04MB144;7:d3vXZPyL+NiYhfBo4ysyNb7BGntV1qMF91E8d+iOQ0jWrkjTHNhDA+9fcdGfMzwxDubbq/cQcUfF8duTPwfq8WWyXaG+/gi/YvNNoCo/oaK0UG2XdOREiun4A0nkpKNjkHmIqCr6G0P4TbvkUlIo7T9UCiPXnQRD4PA7hLjEJjPE/aad+YileIUJLvGNLlXMD9zDITocgL7vKTmQ3RMP301Hwa1oJ2Won/yjwvXS5Ycg/PbB2JR7qGU4i1I/rwVb x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 9adcbf24-b583-44a3-1b59-08d58e4d802f x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020);SRVR:DBXPR04MB144; x-ms-traffictypediagnostic: DBXPR04MB144: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(185117386973197)(42068640409301); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231221)(944501309)(52105095)(10201501046)(93006095)(93001095)(3002001)(6055026)(6041310)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(6072148)(201708071742011);SRVR:DBXPR04MB144;BCL:0;PCL:0;RULEID:;SRVR:DBXPR04MB144; x-forefront-prvs: 061725F016 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39860400002)(376002)(346002)(396003)(39380400002)(366004)(199004)(189003)(25786009)(81166006)(81156014)(76176011)(53936002)(99286004)(316002)(2906002)(5250100002)(55016002)(561944003)(7696005)(33656002)(8676002)(6306002)(9686003)(3846002)(6116002)(66066001)(8936002)(6436002)(106356001)(2900100001)(93886005)(6246003)(59450400001)(3280700002)(305945005)(26005)(186003)(110136005)(3660700001)(102836004)(53546011)(229853002)(6506007)(478600001)(5660300001)(68736007)(7736002)(74316002)(966005)(14454004)(4326008)(97736004)(54906003)(105586002)(86362001);DIR:OUT;SFP:1101;SCL:1;SRVR:DBXPR04MB144;H:DBXPR04MB463.eurprd04.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: azIiUS25C6s+PdrO14cGGWZz+q31INEoGRiPveIvgbAvoi2Zs3VCuaezuglR2JAJ/tpWwhFZ/zSjto/3oeXpmp7ihtXPExd6bHOQYJdhe2DQzbXLf6feDR8vyiHbTqGOgfbTqaOrQHZLOBGrTHzbtgPO6onZL/+I9qZUbM7ChIjLVuZTrrXCut2Teqy+O1h1UPYeCCIs+y5j5qiLMA7ta4UN9GcRp4o0Eb4z6vQzpoFXGguWarKl/GwVMCXX7PG6QjtuESwNQIDX/UujNDjhLYXuR+7jFLm67ijDByWc+U+tAmlLleuJNsEvS5PY5Ol0XDum61JZqfctp1m88frtYw== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9adcbf24-b583-44a3-1b59-08d58e4d802f X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Mar 2018 10:29:45.6052 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBXPR04MB144 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/20/2018 10:50 AM, Kamil Konieczny wrote:=0A= > On 20.03.2018 08:56, Horia Geant=E3 wrote:=0A= >> Add a note that it is perfectly legal to "abandon" a request object:=0A= >> - call .init() and then (as many times) .update()=0A= >> - _not_ call any of .final(), .finup() or .export() at any point in=0A= >> future=0A= >>=0A= >> Link: https://lkml.kernel.org/r/20180222114741.ga27...@gondor.apana.org.= au=0A= >> Signed-off-by: Horia Geant=E3 =0A= >> ---=0A= >> Documentation/crypto/devel-algos.rst | 8 ++++++++=0A= >> 1 file changed, 8 insertions(+)=0A= >>=0A= >> diff --git a/Documentation/crypto/devel-algos.rst b/Documentation/crypto= /devel-algos.rst=0A= >> index 66f50d32dcec..c45c6f400dbd 100644=0A= >> --- a/Documentation/crypto/devel-algos.rst=0A= >> +++ b/Documentation/crypto/devel-algos.rst=0A= >> @@ -236,6 +236,14 @@ when used from another part of the kernel.=0A= >> |=0A= >> '---------------> HASH2=0A= >> =0A= >> +Note that it is perfectly legal to "abandon" a request object:=0A= >> +- call .init() and then (as many times) .update()=0A= >> +- _not_ call any of .final(), .finup() or .export() at any point in fut= ure=0A= >> +=0A= >> +In other words implementations should mind the resource allocation and = clean-up.=0A= >> +No resources related to request objects should remain allocated after a= call=0A= > -- ^^^^^^^^^^^^=0A= >> +to .init() or .update(), since there might be no chance to free them.= =0A= > =0A= > is it for crypto api users or for drivers ?=0A= > =0A= For drivers / providers (below crypto API).=0A= =0A= > the creator of request context is responsible for alloc and destroy,=0A= > so why there are no chance of free ?=0A= > =0A= Hash request object (including request context) is allocated by the user /= =0A= client by means of ahash_request_alloc(), and later on freed using=0A= ahash_request_free().=0A= I don't see a problem with this.=0A= =0A= However, besides the memory allocated for the request context, other resour= ces=0A= (related to the request) might be needed by the driver.=0A= I provided an example of needing to DMA map a buffer (to load/store HW stat= e=0A= from/to crypto engine), and I am not happy with either solutions:=0A= -DMA map & unmap after each .update()=0A= -Herbert's proposal to use a convoluted DMA mapping scheme=0A= =0A= Another example: dynamic memory allocation might be needed beyond what's=0A= available in request context, i.e. driver might not have apriori all the=0A= information needed to inform the tfm about required memory using=0A= crypto_ahash_set_reqsize().=0A= =0A= This happens due to the semantics of the crypto API, which allows the user = to=0A= initialize a request object and drop it without getting a result (final or= =0A= partial hash).=0A= I don't see what below use case is good for, maybe just for benchmarking:= =0A= req =3D ahash_request_alloc();=0A= [...]=0A= crypto_ahash_init(req);=0A= crypto_ahash_update(req);=0A= ahash_request_free(req);=0A= =0A= Horia=0A= =0A=