Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5289839ybe; Tue, 10 Sep 2019 01:08:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqyJ82nfGhR0DVpBS7yqtW+V27zzZN6+GlLKMFlkOCo7Rms0vPG6xKPBSCiSf+K47y+SizfJ X-Received: by 2002:a05:6402:1e7:: with SMTP id i7mr29945690edy.103.1568102919719; Tue, 10 Sep 2019 01:08:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568102919; cv=none; d=google.com; s=arc-20160816; b=uZgN7VBnrHpOdtj3DO+Pzz8GXWRvtYsrVzDNLoU4TqC9mTQV+ro5FVvFN4r+2Se/NO kbOteszklQRPAEu6yQrkyajlERycGYdmKXIs/8tvCTjNehwh0qlpr+37pKrm1fL7vDCE ep75AewjWGjBS89YH4CHTj+ObFw0QRU1+4eLZDilzK9lwD9G0clrMoM6XyV7tEGf4KDZ WbUJXF8TNseEjIt4Zpez0EpdM9Wx4omMue74dzaO4K6yMsA+pjINBeq1lJLLm8Z1Zb3x OAjIWH3+6auz/lgGpJjlKU7t+i8HAus7BSySdZNYB/6AbRMiVid7COsBLXN3ryiMY8cf 9pAw== 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; bh=MlPzGPXqSl0vHmD9qqSsnEnJLG3H0mtEbeSrDGmKkT0=; b=cxndrERryFuELybPUkuUdkhC8sn+djXAA3XuTKwsOh9hh+6Rf/YuKcWdRGLKLsYCKB A2eCRp6BIW6hCApdEV5dtW3DD9OfErvaklMJY1/nTfgmIssV3GWk9l2CVhemHbBn7hXr GOgnxTirSmsRZ4FkWPyHegCRTO6GamoCWG1XY2iiz3rdXXMmYt4Z/wx0r/CEYi9hRAXc TBOwGiOb6OMUnCDAMnYn5eIOsHWh6O9G9ne1Ea1UQ8SsdVD8sWRUMxFK8kDjURuDa4Ku M1XqBClCP9yh3rXYvvyhrZrI8M382jPiMvnOZS8EddzwcdB2Hf8PenEpuI9gJdBCA7g8 z4eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UieH1zXY; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o26si9859601edr.329.2019.09.10.01.08.15; Tue, 10 Sep 2019 01:08:39 -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; dkim=pass header.i=@kernel.org header.s=default header.b=UieH1zXY; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405101AbfIIN7Q (ORCPT + 99 others); Mon, 9 Sep 2019 09:59:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:40922 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405085AbfIIN7Q (ORCPT ); Mon, 9 Sep 2019 09:59:16 -0400 Received: from localhost (lfbn-1-17395-211.w86-250.abo.wanadoo.fr [86.250.200.211]) (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 7759E2086D; Mon, 9 Sep 2019 13:59:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568037554; bh=1LOeIrNaojbFutO/35pibYdicy6zk1C9NEftmHLgaYE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UieH1zXYFmI9ZQoBmDFp/Caccsfb8zgAwWbjMjeDAAsY7nOdDGw25MsSl3XEWM/eK aCMGsGuAWbMv29jYF4cNJLtde8dflId6l4spy1NhpVNiZk1DIBghKpAI9y5BFNAJ5s Vr1SD9rR+VQpQwiMsnxecPLCM1nyBKQ6YwApwNbI= Date: Mon, 9 Sep 2019 15:59:10 +0200 From: Maxime Ripard To: Corentin Labbe Cc: davem@davemloft.net, herbert@gondor.apana.org.au, linux@armlinux.org.uk, mark.rutland@arm.com, robh+dt@kernel.org, wens@csie.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com Subject: Re: [PATCH 2/9] crypto: Add Allwinner sun8i-ce Crypto Engine Message-ID: <20190909135908.vkvcuykrplhxxwtd@flea> References: <20190906184551.17858-1-clabbe.montjoie@gmail.com> <20190906184551.17858-3-clabbe.montjoie@gmail.com> <20190907081951.v2huvhm44jfprfop@flea> <20190907190408.GE2628@Red> <20190909113837.vrnqdfgzhsiymfpm@flea> <20190909131906.GA12882@Red> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190909131906.GA12882@Red> User-Agent: NeoMutt/20180716 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Mon, Sep 09, 2019 at 03:19:06PM +0200, Corentin Labbe wrote: > On Mon, Sep 09, 2019 at 01:38:37PM +0200, Maxime Ripard wrote: > > On Sat, Sep 07, 2019 at 09:04:08PM +0200, Corentin Labbe wrote: > > > > Also, I'm not sure what is the point of having the clocks names be > > > > parameters there as well. It's constant across all the compatibles, > > > > the only thing that isn't is the number of clocks and the module clock > > > > rate. It's what you should have in there. > > > > > > Since the datasheet give some max frequency, I think I will add a > > > max_freq and add a check to verify if the clock is in the right > > > range > > > > It's a bit pointless. What are you going to do if it's not correct? > > What are you trying to fix / report with this? > > I thinked to print a warning. If someone want to play with > overclocking for example, the driver should said that probably some > result could be invalid. If someone wants to play with overclocking, the crypto engine is going to be the least of their concern. > > > > > +int sun8i_ce_get_engine_number(struct sun8i_ce_dev *ce) > > > > > +{ > > > > > + return atomic_inc_return(&ce->flow) % ce->variant->maxflow; > > > > > +} > > > > > > > > I'm not sure what this is supposed to be doing, but that mod there > > > > seems pretty dangerous. > > > > > > > > ... > > > > > > This mod do a round robin on each channel. > > > I dont see why it is dangerous. > > > > Well, you're using the atomic API here which is most commonly used for > > refcounting, while you're using a mod. > > > > Plus, while the increment is atomic, the modulo isn't, so you can end > > up in a case where you would be preempted between the > > atomic_inc_return and the mod, which is dangerous. > > > > Again, I'm not sure what this function is doing (which is also a > > problem in itself). I guess you should just make it clearer what it > > does, and then we can discuss it properly. > > Each request need to be assigned to a channel. > Each channel are identified by a number from 1 to 4. > > So this function return the channel to use, 1 then 2 then 3 then 4 then 1... > > Note that this is uncritical. If, due to anything, two request are > assigned to the same channel, nothing will break. I'm not sure why you're using the atomic API then? Also, I guess a bitfield and find_first_bit (and a different function name) would be more obvious to the reader. Thanks! Maxime