Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1065816imm; Thu, 4 Oct 2018 07:43:02 -0700 (PDT) X-Google-Smtp-Source: ACcGV61kKm5b7AIreqGVfCi1K/fD3NztzlSJNU21gcpjJ6+keeaho0u3nM7s2lETNrmqs3/ksTFE X-Received: by 2002:aa7:8715:: with SMTP id b21-v6mr7032985pfo.250.1538664182082; Thu, 04 Oct 2018 07:43:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538664182; cv=none; d=google.com; s=arc-20160816; b=WBQmVaQKeCB908LuhK5ktWu8YaGQjX4fsSa1V0yhYjbsXm3KpZBEk1ZfYEBq+M2x4g epTF2YLxiZeOwi51/VnoGvV8DSSO2dhi0q4xZEuRg0voAI2q7X7gf3cC5+aRSTrnLiiJ ks6jrTacNnnb0yLGJDUiM/M5AeStBDQE5eZpxPjcdf2DfXxbF0Nm2XvF3aIDbQpETURn 8ID8p5P+8OaSBW6TSuva0d4A6waawQddu7MbMUF1cM2mp/HIOkKsXFfTgWqwt20MYbrJ GdV62XdMUjKlqZbK3tz7Chj0PhgZa4h9iLJvNax8H2Lzu0RR0/TZNCeosi5rGi1Cir4K mlfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:dkim-signature; bh=aPovNyvTfDgVh/o+GOf22MxoMVCBXn7eQkdU3zejh88=; b=Cmdxk5eBSPTF+pQyDkW9ohnWUPdVkma3KJrs44JhkhXbLZqAZvWsaufJtuVdeqxpU9 QnsvZMqPGXyvXanqfdqteT1uiMnov8SNCEnCvQ+Z2hh9oAtdXca/SrQZ3biTwrZZr+wg gDy9eVFjUTamQHhE3CUhhwNH3MAAzgWbt6yT+C+zD9930LKcA9g33yT31pxo+5Xu7lJ2 aJXtblSuXdjPv/lsczoh3Nyjd+dYziTjINEoYdPklcT98AZUA8+praxlWVm55ykYVptg E8ENVIK1PvwDoEiYWkMw2w7ClSLk2RlRwgc/xsgS5KHngTBIp90EiCoZjjz/CU1yfACZ /Pqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=LURBpQo4; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f62-v6si5694597pfb.218.2018.10.04.07.42.45; Thu, 04 Oct 2018 07:43:02 -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=@ti.com header.s=ti-com-17Q1 header.b=LURBpQo4; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727705AbeJDVeX (ORCPT + 99 others); Thu, 4 Oct 2018 17:34:23 -0400 Received: from lelv0142.ext.ti.com ([198.47.23.249]:57744 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727407AbeJDVeX (ORCPT ); Thu, 4 Oct 2018 17:34:23 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id w94EePDa077483; Thu, 4 Oct 2018 09:40:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1538664025; bh=aPovNyvTfDgVh/o+GOf22MxoMVCBXn7eQkdU3zejh88=; h=Subject:To:References:From:Date:In-Reply-To; b=LURBpQo4VUZJCEvxOMK++3vSGamiN3hXlVvviVc3lneQvLuTeo5ESEDuSeUo69W3p e4m1G9Retr2rfvG+V4yVUfHqVEDvoDreI0hi8K96EmVb09RSUNExDu7llpeq1hqD8F ujD3ag5pP/QMiq4JvVXwAuw54R/2Rqb69cgHYDqM= Received: from DLEE103.ent.ti.com (dlee103.ent.ti.com [157.170.170.33]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w94EePid002361; Thu, 4 Oct 2018 09:40:25 -0500 Received: from DLEE115.ent.ti.com (157.170.170.26) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Thu, 4 Oct 2018 09:40:25 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Thu, 4 Oct 2018 09:40:25 -0500 Received: from [127.0.0.1] (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id w94EeKrU030461; Thu, 4 Oct 2018 09:40:21 -0500 Subject: Re: [PATCH RFC 1/2] clk: ti: add a usecount for autoidle To: Andreas Kemnade , , , , , , , , References: <20181004055147.23048-1-andreas@kemnade.info> <20181004055147.23048-2-andreas@kemnade.info> From: Tero Kristo Message-ID: Date: Thu, 4 Oct 2018 17:40:06 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20181004055147.23048-2-andreas@kemnade.info> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/10/18 08:51, 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() > > Signed-off-by: Andreas Kemnade > --- > drivers/clk/ti/autoidle.c | 20 ++++++++++++-------- > include/linux/clk/ti.h | 1 + > 2 files changed, 13 insertions(+), 8 deletions(-) > > diff --git a/drivers/clk/ti/autoidle.c b/drivers/clk/ti/autoidle.c > index 7bb9afbe4058..be2ce42e4f33 100644 > --- a/drivers/clk/ti/autoidle.c > +++ b/drivers/clk/ti/autoidle.c > @@ -48,8 +48,11 @@ int omap2_clk_deny_idle(struct clk *clk) > struct clk_hw_omap *c; > > c = 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) { > + c->autoidle_count--; > + if (c->autoidle_count == -1) > + c->ops->deny_idle(c); This code is racy as you have no locking in place. Please fix. Also, this should be verified that it doesn't cause any PM regressions, I hope you have done that? -Tero > + } > return 0; > } > > @@ -64,8 +67,11 @@ int omap2_clk_allow_idle(struct clk *clk) > struct clk_hw_omap *c; > > c = to_clk_hw_omap(__clk_get_hw(clk)); > - if (c->ops && c->ops->allow_idle) > - c->ops->allow_idle(c); > + if (c->ops && c->ops->allow_idle) { > + c->autoidle_count++; > + if (c->autoidle_count == 0) > + c->ops->allow_idle(c); > + } > return 0; > } > > @@ -201,8 +207,7 @@ int omap2_clk_enable_autoidle_all(void) > struct clk_hw_omap *c; > > list_for_each_entry(c, &clk_hw_omap_clocks, node) > - if (c->ops && c->ops->allow_idle) > - c->ops->allow_idle(c); > + omap2_clk_allow_idle(c->hw.clk); > > _clk_generic_allow_autoidle_all(); > > @@ -223,8 +228,7 @@ int omap2_clk_disable_autoidle_all(void) > struct clk_hw_omap *c; > > list_for_each_entry(c, &clk_hw_omap_clocks, node) > - if (c->ops && c->ops->deny_idle) > - c->ops->deny_idle(c); > + omap2_clk_deny_idle(c->hw.clk); > > _clk_generic_deny_autoidle_all(); > > diff --git a/include/linux/clk/ti.h b/include/linux/clk/ti.h > index a8faa38b1ed6..c460355419c0 100644 > --- a/include/linux/clk/ti.h > +++ b/include/linux/clk/ti.h > @@ -159,6 +159,7 @@ struct clk_hw_omap { > const char *clkdm_name; > struct clockdomain *clkdm; > const struct clk_hw_omap_ops *ops; > + int autoidle_count; > }; > > /* > -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki