Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3476543pxa; Wed, 26 Aug 2020 01:04:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxL3D6u6ZiSrHwLmCZg25dcwbUkHPa9Y4/PZOxTLr0vYfqiD/PQcQDyzGbnSjUhcBN6g6/t X-Received: by 2002:aa7:d6d9:: with SMTP id x25mr6461358edr.265.1598429046839; Wed, 26 Aug 2020 01:04:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598429046; cv=none; d=google.com; s=arc-20160816; b=KByI5RVy2L6do/RTSO16znFoTICK825NgvAbyNc1MEg7hfovRtNqdtobR5ZJeHBcjc O8I8zrCUte8PCQSGGhjypgeAGTiLGjLuHpJq+Q7LHuMAtpNZMb+RRjjO2nYE6PMwIWey BWpATPdbwt0b4B12ulUzsvKmLePxsSceyDSVfLUAXJisp9Iq0eceDOoNsNm/7HIUYjZ5 vctzG3r0NMU7PHoID4fAH6ANvi0qjFKzPKxpldDHC/VfdSznV4dxM1fq9URropb7/agK ptBxPydmOjCvslZMtyoQWV7PS1tF/OQIeoeCTjiX5R1t8zFq/RQ7vP2fF0SEgnA3rtuN qc/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id; bh=rYkpTCmRlygn/P/0M2+dM0ke0zZmabS/tgTD4tkPmZg=; b=YtUDTdtHqfI9rX3f+fm4O6aJlzpdPoTGWY+ikf0grCGpJFaHICQ/jpSZJf+xQyhsyl vw18Vg3fdA7xoj4iGAAP7p5T8uDwvkIHvYidNc5FNbCztBvKJmMBtJ7rY/u531JBQFgk Du+FxTtdsbmU8uMqPqcGMJWFkpAX5lKi6y7PBnGlJ6yaktJB8viYmqxzRudZZn3RdOaN mCAxshpetsHhr7a2WWYY0gpWekFnmTwIusTWjVfCrEEzSWK47fROgbuZ1Lincq+VZ+Tm lGN7Xt/p8uusTEsiud51YFytg1YVlc5cz5mlslnITtYTiljLwHPBjz7/2WzcqXmJXcl3 lroQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p14si1072408edj.165.2020.08.26.01.03.42; Wed, 26 Aug 2020 01:04:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726734AbgHZHqj convert rfc822-to-8bit (ORCPT + 99 others); Wed, 26 Aug 2020 03:46:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726698AbgHZHqi (ORCPT ); Wed, 26 Aug 2020 03:46:38 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A124C061756 for ; Wed, 26 Aug 2020 00:46:38 -0700 (PDT) Received: from lupine.hi.pengutronix.de ([2001:67c:670:100:3ad5:47ff:feaf:1a17] helo=lupine) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kAq8T-00014I-FH; Wed, 26 Aug 2020 09:46:21 +0200 Received: from pza by lupine with local (Exim 4.92) (envelope-from ) id 1kAq8S-0003zE-FX; Wed, 26 Aug 2020 09:46:20 +0200 Message-ID: <6a4757e808c2201dc212d1ccf63310b3fd5b2268.camel@pengutronix.de> Subject: Re: [PATCH v2 11/17] clk: imx: Add blk_ctrl combo driver From: Philipp Zabel To: Abel Vesa Cc: Dong Aisheng , Rob Herring , Peng Fan , Fugang Duan , Jacky Bai , Anson Huang , devicetree@vger.kernel.org, Stephen Boyd , Mike Turquette , Linux Kernel Mailing List , NXP Linux Team , Sascha Hauer , Fabio Estevam , Shawn Guo , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Date: Wed, 26 Aug 2020 09:46:20 +0200 In-Reply-To: <20200825183009.olarh5ewkljeh35d@fsr-ub1664-175> References: <1597406966-13740-1-git-send-email-abel.vesa@nxp.com> <1597406966-13740-12-git-send-email-abel.vesa@nxp.com> <20200825112421.eut7gx3i4eirhnfw@fsr-ub1664-175> <8e8e33386eea12036bb17529b4d578704bf735d1.camel@pengutronix.de> <20200825183009.olarh5ewkljeh35d@fsr-ub1664-175> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT User-Agent: Evolution 3.30.5-1.1 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:3ad5:47ff:feaf:1a17 X-SA-Exim-Mail-From: p.zabel@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2020-08-25 at 21:30 +0300, Abel Vesa wrote: [...] > > if (assert) > > pm_runtime_get_sync(); > > spin_lock_irqsave(); > > /* ... */ > > spin_unlock_irqrestore(); > > if (assert && asserted_before) > > pm_runtime_put(); > > > > On a second thought this doesn't work because, for the first assertion, > the runtime put will never be called, if the asserted_before does not count > the current assertion. I'm not sure I follow. The first assert will increment device usage 0 -> 1, all others asserts will just temporarily increment and decrement 1 -> 2 -> 1. Isn't this just missing one if (!assert && !asserted_after) pm_runtime_put() to do the last deassert 1 -> 0 transition? > If it counts the current assertion, then every assertion > will end with runtime put. None of these options work here. > > How about the following: > > if (assert && !test_and_set_bit(1, &drvdata->rst_hws[id].asserted)) > pm_runtime_get_sync(rcdev->dev); > > spin_lock_irqsave(&drvdata->lock, flags); > > reg = readl(reg_addr); > if (assert) > writel(reg & ~(mask << shift), reg_addr); > else > writel(reg | (mask << shift), reg_addr); > > spin_unlock_irqrestore(&drvdata->lock, flags); > > if (!assert && test_and_clear_bit(1, &drvdata->rst_hws[id].asserted)) > pm_runtime_put(rcdev->dev); > > This would only call the get_sync/put once for each reset bit. Yes, that should work. I think it is a much better idea, no more looping through the entire reset control array. regards Philipp