Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1721657imu; Fri, 9 Nov 2018 23:55:31 -0800 (PST) X-Google-Smtp-Source: AJdET5fHgtvnTxZ3kOtAp+8+msByozgcIrg8rnLj7CHErMvMbBb1NLL+tK+x0qH6M+BU1tOwEqr4 X-Received: by 2002:a17:902:8648:: with SMTP id y8-v6mr9028541plt.159.1541836531902; Fri, 09 Nov 2018 23:55:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541836531; cv=none; d=google.com; s=arc-20160816; b=K5XXuBCHAQGWssupCoF8xuD7cIFLpSlfH2Uthk3HJpbCmOPLLdfBuZqMoJY4OHC2hp XPHx8vxVdqDfPysogw61elbqbnHNihtt04wPOhYiP7UPQli5NEj2/6PwggoV0Kn+jhN7 zpJfysi8Fs1mijLMpCTY/F9X2UPcZ0+HzkG0bX+fl92ZNqCt3TjD0vCKga52Ps31T6is gRDuJQ3f2z4zcVUu9Vyzq8acHK6lleqLfJZeUOnOrPhUQ5/kcFP7N47cwZxIbDSsFZXb EZJ9wPgOIFbr5tSNNWRMkk5rPfCn/d6Kwi1q8JC4bq8guZgDbeYd3WspvomH6UFtTzUX xUuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:dkim-signature; bh=G9tr0ALZEuyGTWfbsHV9yfhGwwaWECTn1OaNtMnAyLY=; b=zQafOJxxdXuBa7DvEOwuc1MPVr8ezEXG2OGmBSPi1nfEFq/ImMqdmoqRH1o51pHZTQ QhNHk1qGUKRz7cFkqNe2badpL9Z6l97rtU8z6+qqqVlVj4lvm8elZ4NUC384RmNJTbDl Mr6Ua8sduNiLyI6B5zF21Yvs1Do1OOIP1e5fCkhQNGYIzhFb6uF6rjoZ0R0LCfQa2wih cUx7qseHCpjtv7fWIalkbTpHVZSIDWZFnSv9Zj+g2joj822tY2BqkHAe3FpaHleAKw6d HAkkpEpnlYVj5QM3c4EG5NoJ1nZOm6DfWTUxcqH3WBJNLTnuhbQr273SLSFUOLWpG5XW YYUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kemnade.info header.s=20180802 header.b="jqhn/mJF"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z127-v6si9018677pgb.118.2018.11.09.23.55.16; Fri, 09 Nov 2018 23:55:31 -0800 (PST) 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=fail header.i=@kemnade.info header.s=20180802 header.b="jqhn/mJF"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729024AbeKJRhc (ORCPT + 99 others); Sat, 10 Nov 2018 12:37:32 -0500 Received: from mail.andi.de1.cc ([85.214.239.24]:53506 "EHLO h2641619.stratoserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728682AbeKJRhb (ORCPT ); Sat, 10 Nov 2018 12:37:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kemnade.info; s=20180802; h=Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=G9tr0ALZEuyGTWfbsHV9yfhGwwaWECTn1OaNtMnAyLY=; b=jqhn/mJFcXaDy4wJUJoWJJcz6 n54Mj1Dxq8Df/nvxTI/5Q0BGnR8vOHmBdM197JEpWSWhVqDivZPuV++aLsdKQ2v8UXQ9rlirau2Ef coye83Z7c/6zZRz/b9mhmgdDM/vu3Dtpxodx0L+U38v5okm54clA9jeAzCMyAJgiOOLfM=; Received: from p200300ccfbfa4e007ee9d3fffe1fa246.dip0.t-ipconnect.de ([2003:cc:fbfa:4e00:7ee9:d3ff:fe1f:a246] helo=localhost) by h2641619.stratoserver.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLO52-00076Z-VN; Sat, 10 Nov 2018 08:53:21 +0100 Received: from [::1] (helo=localhost) by localhost with esmtp (Exim 4.89) (envelope-from ) id 1gLO51-0003X6-8P; Sat, 10 Nov 2018 08:53:19 +0100 Date: Sat, 10 Nov 2018 08:52:43 +0100 From: Andreas Kemnade To: Tero Kristo Cc: , , , , , , , , Subject: Re: [PATCH 1/2] clk: ti: add a usecount for autoidle Message-ID: <20181110085243.7da163b9@kemnade.info> In-Reply-To: <23cbfc19-20d9-99f0-c086-e782cc36de34@ti.com> References: <20181004203817.22101-1-andreas@kemnade.info> <20181004203817.22101-2-andreas@kemnade.info> <23cbfc19-20d9-99f0-c086-e782cc36de34@ti.com> X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; i686-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; boundary="Sig_/g7+_xUFQiCBMaTFikRMVVkp"; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --Sig_/g7+_xUFQiCBMaTFikRMVVkp Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Thu, 8 Nov 2018 12:36:35 +0200 Tero Kristo wrote: > On 04/10/2018 23:38, Andreas Kemnade wrote: > > We have the scenario that first autoidle is disabled for all clocks, > > then it is disabled for selected ones and then enabled for all. So > > we should have some counting here, also according to the > > comment in _setup_iclk_autoidle() > >=20 > > Signed-off-by: Andreas Kemnade > > --- > > drivers/clk/ti/autoidle.c | 32 ++++++++++++++++++++++++-------- > > include/linux/clk/ti.h | 1 + > > 2 files changed, 25 insertions(+), 8 deletions(-) > >=20 > > diff --git a/drivers/clk/ti/autoidle.c b/drivers/clk/ti/autoidle.c > > index 7bb9afbe4058..bb6cff168e73 100644 > > --- a/drivers/clk/ti/autoidle.c > > +++ b/drivers/clk/ti/autoidle.c > > @@ -37,6 +37,14 @@ struct clk_ti_autoidle { > > static LIST_HEAD(autoidle_clks); > > static LIST_HEAD(clk_hw_omap_clocks); > > =20 > > +/* > > + * we have some non-atomic read/write > > + * operations behind it, so lets > > + * take one mutex for handling autoidle > > + * of all clocks > > + */ > > +static DEFINE_MUTEX(autoidle_mutex); =20 >=20 > Why mutex? This prevents calling the autoidle APIs from atomic context.=20 > Did you check the mutex debug kernel configs with this? >=20 Oops, I thought they were on, but they were not. OK, I am preparing a v2 of this thing. > This may cause problems with the runtime PM entries to the code at least. >=20 >=20 > > + > > /** > > * omap2_clk_deny_idle - disable autoidle on an OMAP clock > > * @clk: struct clk * to disable autoidle for > > @@ -48,8 +56,13 @@ int omap2_clk_deny_idle(struct clk *clk) > > struct clk_hw_omap *c; > > =20 > > c =3D to_clk_hw_omap(__clk_get_hw(clk)); > > - if (c->ops && c->ops->deny_idle) > > - c->ops->deny_idle(c); > > + if (c->ops && c->ops->deny_idle) { > > + mutex_lock(&autoidle_mutex); > > + c->autoidle_count--; > > + if (c->autoidle_count =3D=3D -1) =20 >=20 > I think you should swap the arithmetics here, all the other usecounters=20 > use positive values, here you enter deep to the negative side when=20 > autoidle is denied by multiple users, which might be confusing. >=20 agreed. Regards, Andreas --Sig_/g7+_xUFQiCBMaTFikRMVVkp Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEE7sDbhY5mwNpwYgrAfb1qx03ikyQFAlvmjksACgkQfb1qx03i kyTa/w/9Em6bQXMvZfpW/9iK4GXuM2on18lYod2wZn6xWUzESe0L3uDK+0oQMtd6 QWyxhNfqZ81q3sgZokwWOEspnyr6Naa1a0u8JLFbSMZwY1ajxp3aCsmcmVuAqhAO HBWH5VCb8MbA3eXJwUsDU9zyx4Zlxyu7hVB7ku05+HMsxaGPdZFOLjI7RJPU7/ok 6LCo3qUaa+RrNdU+2mZXKEA16s4J7rtjjyqmXqVyRPI0d+o3jx/1ByVrJeGrkeoF dD2SqibJQmdVgEWLav5qZoymY4MhY6Q3SGQttA+3U8IileC/m6BlOwd47X0ETVgD wQ6HQ218JUElIW4SPWFdi7QdV2EPOuinnjpUiVON4f6e0GxYgR4626/tz7Edaiin zy99XHSSiWozSmuhUEJwXcS9niI01fLDVonh4wh8aTtZ2tSIjBmi9FJrFBlJV0EN v+F8kJWiclDSjwIhvD/1Z9TWzp1MsLJctJJlEa9GwfZ2uZPqFiFIt9Xl1KFR85AD MmYN1Et49aPF1nFTzuW2O+yVZCkVjjGLn6UrYxrWkVTBat50pedRT5WzWfzjWWA0 aKACN9dXO3ZE+GBXT/HzaDUBo7uQ7sk/YznN94g0wi6FNAeh6Rg+Wt9QNidCNUCy V2ZEFjjtAXTd9PoXZGO9Al7Kto4TsnkNtgE26wc0ik+3oPdsYEo= =BL1u -----END PGP SIGNATURE----- --Sig_/g7+_xUFQiCBMaTFikRMVVkp--