Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4771970ybl; Wed, 22 Jan 2020 04:29:53 -0800 (PST) X-Google-Smtp-Source: APXvYqzcXrAApJp030+SjOhu1IcgF/EhFxRzZQGXVha6Rbm9V4RzhzNZ9YD0C68mrLb3PnOpL+kH X-Received: by 2002:aca:72cd:: with SMTP id p196mr6286472oic.99.1579696193238; Wed, 22 Jan 2020 04:29:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1579696193; cv=pass; d=google.com; s=arc-20160816; b=YJfrTiKK/jHxqW5WYnB08ePxmwygN8t8GhF/x1lYZx/hlPiSoycTtzzgxbqttHGkfN NgkzOaG5zB30+y1Il+popyi9x9UsSTyuPWldVcwXodZNTaHPoNAHsdp1+Mv/vm/X9xkc qZtwnl2cqJ9xLTYW20iwE7CfrsKCak+bCQGiuXFrLhcqI5KfvzBWkUAgeHw/cw43RLcv PVp+sC5/iPJcVaSQGkZXi59oT2dSqhMkvcyNERgzhr/mupug2cRI+dnH7a3k86SDNto1 IvCkgVtOr67ZWagv+Dh2TS6QeggiMzX/fZHibNPQtorv+B7aZEEeQz7BpGh+PECsinpR uOTQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:references:message-id:date :thread-index:thread-topic:subject:cc:to:from:dkim-signature; bh=ima0gc7kM5uSLGKNJyiFgHXs/rYus8KLTtH9RAgOl98=; b=AQaXNY6q6DdjL8X7VTMTD6Z6Jb341T+OdZwxohP710om4b2wTa9cZ64iA3niMh78AR k4fh8qdj+MhnfHiNh6fhS2eTv/iEKiQbgZUL+BPLeJUBO0aPZ4HrA+Rk/tHALf5JvKiF smUzncDmVMEvbg6CMuHxzUEvZ+wJ7abBYkP5P6kt9vnUAZxzOlakXAfxrLdkgTbbeRNS BkrdWmJli/AVOjdnt/luj7DQWRDgi31tFzS8bmStQ/crFxqNmjKKc00tlwz96NSBRkdq i0qQW5RLc9pdkMFbQWC4TSj40h36vm4eVuiMTo03CvFskU0Avhb5KfkxMVdVU7pYBC6/ oeDg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=Rxth38U4; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.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; 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 n11si22199066otk.290.2020.01.22.04.29.30; Wed, 22 Jan 2020 04:29:53 -0800 (PST) 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; dkim=pass header.i=@nxp.com header.s=selector2 header.b=Rxth38U4; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728900AbgAVM33 (ORCPT + 99 others); Wed, 22 Jan 2020 07:29:29 -0500 Received: from mail-eopbgr80042.outbound.protection.outlook.com ([40.107.8.42]:1790 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726204AbgAVM33 (ORCPT ); Wed, 22 Jan 2020 07:29:29 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ceOmVHfaWdpoet6um2Bc6Rp+ManfpCnUjBn1TCVMxB59DPUsjRtZQP/jv5OOglIvLSNwStrJwKBtbiQ2cHRcZeqS5NLTr+LH8BEBCz1QNjXTUooorc6/zCpHMXWPkyThZmkkLtJ0guWXKlTHiRl7AIbpgt0UdVVmqCieyFCLtaGH/tAFGxvbHa9lQdc6ENqWgYKA1mwvNzJJusONixIS1dUgpsjFBoFwt8yWwD+DaraPxrTsn9x3DJMKnxopCVRzw9k5owDNvaqVABjzuqgynE1ZZYnnhjBg79dr6FVJOKmvHkG4l5GXeJJgQlptghUSd70+mt0pvdQfil0fpUMEeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ima0gc7kM5uSLGKNJyiFgHXs/rYus8KLTtH9RAgOl98=; b=X+TMTtjsZ4r7GyAhDpVb8JBLon/nZjPywE8ec/5jwH5ES4aw4M9UFZkNgTl77nX1jRFqBvkZTn4tBcw9M8oV5iYfpM6BEU1M1WL3WwVy5Bi+8waxWj7DcF9ahl4inuz7d+8x17Wj5ZKFwU0IPn2/xKYyaMsbjxZQ8TpEhB0WKVH7+aD9ci0kHrymiq2l9t0O+STC/UMODhyrUOKfx95jogEnuTFh3t4u/78AjYxazBEvHd9sw4oF35E0WFwGPrLOhLyiE6zNqpDKnQCctyPhhT7+7cSJb1UYdwolrZjKlr4Q4K0ga/8caKyZ90BA/rYG4mY2xGE63Zg+lieffvIErw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ima0gc7kM5uSLGKNJyiFgHXs/rYus8KLTtH9RAgOl98=; b=Rxth38U4bFNJ1pjODsAfU1GPfA/8MgVi56USOtKdOqevRyu2ATvYHYDiBzLlNTrJJyfEYXljkUx+IRoAT0agOnTFSnAvCO2JJkWBqEHlHbW3lnwejDhOSvE+lxkwk9mEl7ZngO1/NcnHW7DSD1F6VPp/oLzpQ/wZpJ4HxCoRCZM= Received: from VI1PR04MB4445.eurprd04.prod.outlook.com (20.177.55.161) by VI1PR04MB4829.eurprd04.prod.outlook.com (20.177.51.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.23; Wed, 22 Jan 2020 12:29:22 +0000 Received: from VI1PR04MB4445.eurprd04.prod.outlook.com ([fe80::304d:b7d8:1233:2ae0]) by VI1PR04MB4445.eurprd04.prod.outlook.com ([fe80::304d:b7d8:1233:2ae0%6]) with mapi id 15.20.2644.027; Wed, 22 Jan 2020 12:29:22 +0000 From: Iuliana Prodan To: Herbert Xu , Baolin Wang , Corentin Labbe CC: Ard Biesheuvel , Horia Geanta , Maxime Coquelin , Alexandre Torgue , Maxime Ripard , Aymen Sghaier , "David S. Miller" , Silvano Di Ninno , Franck Lenormand , "linux-crypto@vger.kernel.org" , "linux-kernel@vger.kernel.org" , dl-linux-imx Subject: Re: [RFC PATCH] Crypto-engine support for parallel requests Thread-Topic: [RFC PATCH] Crypto-engine support for parallel requests Thread-Index: AQHVz+nyH19jpegvq0OzoQlSx1aIPw== Date: Wed, 22 Jan 2020 12:29:22 +0000 Message-ID: References: <1579563149-3678-1-git-send-email-iuliana.prodan@nxp.com> <20200121100053.GA14095@Red> <20200122104134.GA13173@Red> 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=iuliana.prodan@nxp.com; x-originating-ip: [212.146.100.6] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: de00cc46-5d81-463b-7384-08d79f36b601 x-ms-traffictypediagnostic: VI1PR04MB4829:|VI1PR04MB4829: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 029097202E x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(4636009)(346002)(396003)(136003)(39860400002)(376002)(366004)(199004)(189003)(2906002)(7416002)(86362001)(8936002)(81166006)(81156014)(33656002)(8676002)(7696005)(6506007)(110136005)(44832011)(186003)(54906003)(316002)(71200400001)(26005)(55016002)(52536014)(478600001)(66556008)(64756008)(53546011)(4326008)(91956017)(76116006)(9686003)(5660300002)(66946007)(66446008)(66476007);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR04MB4829;H:VI1PR04MB4445.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: KtaiAuQ40qRNu7iKByIFhjg+8//mig0adsdjTZWh2iQzVvo6yzR0kqME/SrJ0q0kIVAXz5NUS7KPFr70MUt4mwuYG4kH7ADtrfnzZkJUU/yBTWy3Zhi6OyfohcjQeC2KgW2E68RFyxvCI43kf4SZ/mhBS+a8EXCieKxh5blor1OomUmwfKRv+/jB/uq6I15BS96YPOJgiofhS/jKD/ni0KJY9EAfZdnLiEVeJmGXfnUzfQ43vvnjo4kqN37K0jLrIY1hPsJ4nSvf0RQcNNJuoYXXbp+o+oOgghFZZsDe5HtzRNFI2RWLelY7RwRE4EfNf7MFIgj9B6BfFKBFYE46epFV+rmB5iwX8QRWUusC/wKJeuu0JMqw9OJdHLq/OhWNkWtxJ5JahZwnPtdmFQJZjWNdUATqcesugTaDWt7fTZWlNbwr5gWgCoITaQGInjrb Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: de00cc46-5d81-463b-7384-08d79f36b601 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Jan 2020 12:29:22.5865 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: TthnQpUSexdizyn6g0zDVs5cUD7Y2QOHi935Df+e0Nqu/sLj6r8RBUN5kZoDcy/bJBZvizH/xKjcOI1UUkbTRw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4829 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On 1/22/2020 12:41 PM, Corentin Labbe wrote:=0A= > On Tue, Jan 21, 2020 at 02:20:27PM +0000, Iuliana Prodan wrote:=0A= >> On 1/21/2020 12:00 PM, Corentin Labbe wrote:=0A= >>> On Tue, Jan 21, 2020 at 01:32:29AM +0200, Iuliana Prodan wrote:=0A= >>>> Added support for executing multiple requests, in parallel,=0A= >>>> for crypto engine.=0A= >>>> A no_reqs is initialized and set in the new=0A= >>>> crypto_engine_alloc_init_and_set function.=0A= >>>> =0A= >>>>=0A= >>>=0A= >>> Hello=0A= >>>=0A= >>> In your model, who is running finalize_request() ?=0A= >> finalize_request() in CAAM, and in other drivers, is called on the _done= =0A= >> callback (stm32, virtio and omap).=0A= >>=0A= >>> In caam it seems that you have a taskqueue dedicated for that but you c= annot assume that all drivers will have this.=0A= >>> I think the crypto_engine should be sufficient by itself and does not n= eed external thread/taskqueue.=0A= >>>=0A= >>> But in your case, it seems that you dont have the choice, since do_one_= request does not "do" but simply enqueue the request in the "jobring".=0A= >>>=0A= >> But, do_one_request it shouldn't, necessary, execute the request. Is ok= =0A= >> to enqueue it, since we have asynchronous requests. do_one_request is=0A= >> not blocking.=0A= >>=0A= >>> What about adding along prepare/do_one_request/unprepare a new enqueue(= )/can_do_more() function ?=0A= >>>=0A= >>> The stream will be:=0A= >>> retry:=0A= >>> optionnal prepare=0A= >>> optionnal enqueue=0A= >>> optionnal can_do_more() (goto retry)=0A= >>> optionnal do_one_request=0A= >>>=0A= >>> then=0A= >>> finalize()=0A= >>> optionnal unprepare=0A= >>>=0A= >>=0A= >> I'm planning to improve crypto-engine incrementally, so I'm taking one= =0A= >> step at a time :)=0A= >> But I'm not sure if adding an enqueue operation is a good idea, since,= =0A= >> my understanding, is that do_one_request is a non-blocking operation and= =0A= >> it shouldn't execute the request.=0A= > =0A= > do_one_request is a blocking operation on amlogic/sun8i-ce/sun8i-ss and t= he "documentation" is clear "@do_one_request: do encryption for current req= uest".=0A= > But I agree that is a bit small for a documentation.=0A= > =0A= =0A= Herbert, Baolin,=0A= =0A= What do you think about do_one_requet operation: is blocking or not?=0A= =0A= There are several drivers (stm32, omap, virtio, caam) that include =0A= crypto-engine, and uses do_one_request as non-blocking, only the ones =0A= mentioned and implemented by Corentin use do_one_request as blocking.=0A= =0A= >>=0A= >> IMO, the crypto-engine flow should be kept simple:=0A= >> 1. a request comes to hw -> this is doing transfer_request_to_engine;=0A= >> 2. CE enqueue the requests=0A= >> 3. on pump_requests:=0A= >> 3. a) optional prepare operation=0A= >> 3. b) sends the reqs to hw, by do_one_request operation. To wait for=0A= >> completion here it contradicts the asynchronous crypto API.=0A= > =0A= > There are no contradiction, the call is asynchronous for the user of the = API.=0A= > =0A= >> do_one_request operation has a crypto_async_request type as argument.=0A= >> Note: Step 3. b) can be done several times, depending on size of hw queu= e.=0A= >> 4. in driver, when req is done:=0A= >> 4. a) optional unprepare operation=0A= >> 4. b) crypto_finalize_request is called=0A= >> =0A= > =0A= > Since Herbert say the same thing than me:=0A= > "Instead, we should just let the driver tell us when it is ready to accep= t more requests."=0A= > Let me insist on my proposal, I have updated my serie, and it should hand= le your case and mine.=0A= > I will send it within minutes.=0A= > =0A= =0A= Corentin,=0A= =0A= In your new proposal, a few patches include my modifications. The others = =0A= include a solution that fits your drivers very well, but implies =0A= modifications in all the other 4 drivers. It's not backwards compatible.=0A= I believe it can be done better, so we won't need to modify, _at all_, =0A= the other drivers.=0A= =0A= I'm working on a new version for my RFC, that has the can_enqueue_more, =0A= as Herbert suggested, but I would really want to know how =0A= crypto-engine's do_one_request was thought: blocking or non-blocking?=0A= =0A= Just your driver(s) use it as blocking, the other examples use it to =0A= enqueue (don't block in waiting for request to finish).=0A= =0A= Thanks,=0A= Iulia=0A= =0A= =0A= =0A= =0A= =0A=