Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1938508ybe; Thu, 12 Sep 2019 01:50:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqziEYZl4GITPYqXBsw3LXuJOj5cwX8LI7T/XlGTt38nlHj0L7Q+4cKsqIGMU456VJr9llzJ X-Received: by 2002:a05:6402:286:: with SMTP id l6mr40757909edv.111.1568278210375; Thu, 12 Sep 2019 01:50:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568278210; cv=none; d=google.com; s=arc-20160816; b=f87RXSUiBuUrA2pyQ+UWxr0B5dyqcsx3TZzxYPnSShwANZlLNqoS7QBeW65qJq0Tfn ECg4br9fIZHY3UbwKHBYnCUaF1sW8YyXD+j6q0X9ktPDtFkBS4IXE8Z9KjC+OFWQGWzG x5rwLd493GWVU/QSETHQjiEVNdme3MtKmQPsrE3QQULAaGm6XDnpSvqr+whnHncktnX3 40+ewtf5WcPs6qLFXy6dv3Fmg8dYRoIP7WQbAsxPZfoK7ImLFUyyUvlCzj/zCC59wIw1 nJbKIUhepzVBYwFEioPRx3gXQ84Gi9UjRbyATXi2ryduHvzgmVP3TXOiUQRZVogq8z6Y 61eg== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=e+Gp9bvg2doYl3vt8UvKYTIGNZ3niQ5XGKnO6ggp+VY=; b=iN3BtqYoWv9iKLFpVHQB/icHFwkmlKlY3vdLZ2LAPS2PhNO3T8D72/IHDuMvMNHgYR IiG4dlohuk9mnVS6afnS2qUgdbI9XhrwqCHj+EkfvAu5EcrfW7azRbGQ3nY1d60/RE2x 4dDPmn9+3qZyFp+X81Xjtj9Vaz+2do6skgDRWr0w2nsKvzckR15tonlyljnvBkw4VV0V 37sPeKgTp3gfzl8tIeaAtUOQ+6CPoCe9d7nhf5Jt+tptCPSEyKSOfjLd/TmL6GbWz+mx 8YCwqKms95NatQ03VR0MU7IxhdSEy+R5vH+AZHKGYKsYe5sv8u4PlHLZDSW7OvLe1pkh 96Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BohMUVOw; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f13si8606300edr.445.2019.09.12.01.49.38; Thu, 12 Sep 2019 01:50:10 -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=@gmail.com header.s=20161025 header.b=BohMUVOw; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730268AbfILItN (ORCPT + 99 others); Thu, 12 Sep 2019 04:49:13 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:34432 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726159AbfILItM (ORCPT ); Thu, 12 Sep 2019 04:49:12 -0400 Received: by mail-wr1-f68.google.com with SMTP id a11so17739910wrx.1; Thu, 12 Sep 2019 01:49:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=e+Gp9bvg2doYl3vt8UvKYTIGNZ3niQ5XGKnO6ggp+VY=; b=BohMUVOwccV7eixIyuzSffx1C1R/02VJ5TADZ2b16JPGKurlRaBsjNKAHOstU0x43Q OULaaIo4e046DFHcBMKrwxOvZYFwrZ9hz8h5ti5bFb0Bum8I/M3ySKZymFORO9Osnfnp mbrMEKqEHAfB5vi8DcBXUCXMWnELXFHJd3AT6BQiA2SVjXDBYXOXWnJqdne0EPRAtdyN fFZcZd3TgWFwwvL7dhbDTHVixRDKKpCV2Z0RIt7/Jixclhlg/fTK5bwlNAmNMuggqOpl kyudZlApLfcNaxL4sc90Wlehs0dBoKAjwk1J6YuKLLId/JFNXR3+DqKA5dbncj8JTFJA Os2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=e+Gp9bvg2doYl3vt8UvKYTIGNZ3niQ5XGKnO6ggp+VY=; b=HUMFYdztKbjESzHLKHwqcs0Oc9zioGuxyUl4kMtwIPs7yL7wloVQhoFwieFhhvc93w opHWrLugZXIsIIBNSg27lGNrWbaHpvWtOe0H0wqOHfpAJxWUaWeHlL1XeHiHTnI3Cc7l +TDV89goQzP1I1HHbPrb/qIVhUf0eFGpdvZwPK0vpqwCe2IZEb7ILts3k0M7wzLwWPh7 g1CpfhwvfYmQuEig0OUkckEQE9HZN5y5BFbCS2oQqjODYbFzo09gNcHQaTGxY0lyq5co v1Ti5HJbqHo2Mm0qD5yaL56/LcwvOfr2wUJNfLOVNAjGi0/j1LgOzTGgd12QHdtyefCN zg+g== X-Gm-Message-State: APjAAAUJ03nKI4vlgiPrbzeEO8mISx+4//+wJiQXzDXTfugvUhJ+blYd gows6mvRBgPwajiNB9YmtLk= X-Received: by 2002:adf:ffd1:: with SMTP id x17mr4758794wrs.139.1568278150339; Thu, 12 Sep 2019 01:49:10 -0700 (PDT) Received: from Red ([2a01:cb1d:147:7200:2e56:dcff:fed2:c6d6]) by smtp.googlemail.com with ESMTPSA id p85sm11790384wme.23.2019.09.12.01.49.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Sep 2019 01:49:09 -0700 (PDT) Date: Thu, 12 Sep 2019 10:49:07 +0200 From: Corentin Labbe To: Maxime Ripard Cc: davem@davemloft.net, herbert@gondor.apana.org.au, Maxime Ripard , Chen-Yu Tsai , linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com Subject: Re: [PATCH 2/2] crypto: sun4i-ss: enable pm_runtime Message-ID: <20190912084907.GA26551@Red> References: <20190911114650.20567-1-clabbe.montjoie@gmail.com> <20190911114650.20567-3-clabbe.montjoie@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Thu, Sep 12, 2019 at 08:35:51AM +0200, Maxime Ripard wrote: > Hi, > > Le mer. 11 sept. 2019 ? 13:46, Corentin Labbe > a ?crit : > > > > This patch enables power management on the Security System. > > > > Signed-off-by: Corentin Labbe > > --- > > drivers/crypto/sunxi-ss/sun4i-ss-cipher.c | 5 +++ > > drivers/crypto/sunxi-ss/sun4i-ss-core.c | 42 ++++++++++++++++++++++- > > 2 files changed, 46 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c > > index fa4b1b47822e..1fedec9e83b0 100644 > > --- a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c > > +++ b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c > > @@ -10,6 +10,8 @@ > > * > > * You could find the datasheet in Documentation/arm/sunxi.rst > > */ > > + > > +#include > > #include "sun4i-ss.h" > > > > static int noinline_for_stack sun4i_ss_opti_poll(struct skcipher_request *areq) > > @@ -497,13 +499,16 @@ int sun4i_ss_cipher_init(struct crypto_tfm *tfm) > > return PTR_ERR(op->fallback_tfm); > > } > > > > + pm_runtime_get_sync(op->ss->dev); > > return 0; > > } > > > > void sun4i_ss_cipher_exit(struct crypto_tfm *tfm) > > { > > struct sun4i_tfm_ctx *op = crypto_tfm_ctx(tfm); > > + > > crypto_free_sync_skcipher(op->fallback_tfm); > > + pm_runtime_put_sync(op->ss->dev); > > } > > > > /* check and set the AES key, prepare the mode to be used */ > > diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-core.c b/drivers/crypto/sunxi-ss/sun4i-ss-core.c > > index 2c9ff01dddfc..5e6e1a308f60 100644 > > --- a/drivers/crypto/sunxi-ss/sun4i-ss-core.c > > +++ b/drivers/crypto/sunxi-ss/sun4i-ss-core.c > > @@ -14,6 +14,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -258,6 +259,37 @@ static int sun4i_ss_enable(struct sun4i_ss_ctx *ss) > > return err; > > } > > > > +#ifdef CONFIG_PM > > +static int sun4i_ss_pm_suspend(struct device *dev) > > +{ > > + struct sun4i_ss_ctx *ss = dev_get_drvdata(dev); > > + > > + sun4i_ss_disable(ss); > > + return 0; > > +} > > + > > +static int sun4i_ss_pm_resume(struct device *dev) > > +{ > > + struct sun4i_ss_ctx *ss = dev_get_drvdata(dev); > > + > > + return sun4i_ss_enable(ss); > > +} > > +#endif > > + > > +const struct dev_pm_ops sun4i_ss_pm_ops = { > > + SET_RUNTIME_PM_OPS(sun4i_ss_pm_suspend, sun4i_ss_pm_resume, NULL) > > +}; > > + > > +static void sun4i_ss_pm_init(struct sun4i_ss_ctx *ss) > > +{ > > + pm_runtime_use_autosuspend(ss->dev); > > + pm_runtime_set_autosuspend_delay(ss->dev, 1000); > > + > > + pm_runtime_get_noresume(ss->dev); > > + pm_runtime_set_active(ss->dev); > > + pm_runtime_enable(ss->dev); > > +} > > It's not really clear to me what you're doing here? Can you explain? > I set the autosuspend state and delay. I say that the device is active and so I "get" it. Then I enable PM. I do like that since I use the device later in probe(), so I need to keep it up. At the end of probe() I put the device which go in suspend automaticaly after. Regards