Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp2930711rwa; Mon, 22 Aug 2022 17:12:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR7ACnlU1Jsj7V/CSGFEf0QmP7sSmghL2kfFNt6qF0pjn0LaSc1FOTrBm+aAS36j1SNuHcrE X-Received: by 2002:a17:90b:1bce:b0:1fa:ecc3:9068 with SMTP id oa14-20020a17090b1bce00b001faecc39068mr784164pjb.116.1661213541450; Mon, 22 Aug 2022 17:12:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661213541; cv=none; d=google.com; s=arc-20160816; b=kdP7higbjkMXQqVmPGq0Tk1OFGqDiDnNxu8POQHsy3nI+K7XFTRv0hTtauDspcjSxY 4gEyJFdfOUoav4abYUMyCeZW1My7zPqjibI9KmjU0acwCpffSogM5swfv7kxG8Nl5lYr /zAxn4EaXurcVR7bPNU1VGUDFUiwQ/GzKCSYzx7K8Vwo7hfJXxfqNzCQNG9PdHIh6sq4 6aPi8lIYqC4R6A+dtOGgWobnAq4ksMmJNRnXRMNZ3XIniVgZFs00yrY5Jej/M5lp852g bMen1ZGsMRJ7AI66jifgZ/rRW4Vj2plpOxS+SebSBZECfgCFKJ83T3ow/79toV5xhwGO XohQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:user-agent:date:to:cc:from:subject :references:in-reply-to:content-transfer-encoding:mime-version :dkim-signature; bh=qHFZqyJEOijR53tD1v7UJ3Sius3Feq1a1/kC+RGGmAA=; b=W6g/NyemuSMtZ4XEW8LfN9OPIxms9bvJwwYWLezilPrYCFU+7BahaCGsEOhmF6+MfX dF/7ccPI1FUwBkCfXe7viBVbFy/4d66ERJzJzKvIxQJAd3Mf2OB1qHm58NvqD2H9ee7L Eq47WKYPuYn9e5OrOGE+928G8yfbX0Y38vvNoYoZcSP51yRlu9fUhzaxFAQB/3DmR1sm C7XofSlfiytRIngxR/1XU+lIuCLQp0CzdccT2CRWEtaQ6RxV0crn/0lD2ZwUVKYvzYs+ mH98fMqUhc+NEMH01D1faQnxCBVJS+TeZe7rwnsElDQSN8AYUB3Wmy/nmitLTTDvxPcu hTEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=W2hqZgq0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n8-20020a6546c8000000b0041603073c17si15218573pgr.394.2022.08.22.17.12.10; Mon, 22 Aug 2022 17:12:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=W2hqZgq0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S238654AbiHVXuS (ORCPT + 99 others); Mon, 22 Aug 2022 19:50:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238361AbiHVXuQ (ORCPT ); Mon, 22 Aug 2022 19:50:16 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC7014E86F; Mon, 22 Aug 2022 16:50:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 35F3761388; Mon, 22 Aug 2022 23:50:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86203C433D6; Mon, 22 Aug 2022 23:50:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661212214; bh=tXNjbCxB6WYOWNNVp+WbEUxxjT5qLs6LlQxsR075G/Q=; h=In-Reply-To:References:Subject:From:Cc:To:Date:From; b=W2hqZgq0oir8PTpr8YN0aZtc/2V8mZtvHtUEkLL+atV30eknq0sCDGPWusW8FN8st uVQMpVXVdOMIPViGj6f4DY1QVi0TlFl3bBJFQYgsdTFDOZdzUML4T4tRbfFR0issin NeH6HL20WXPBQDDVekGhLh/DfsJuh3Cpx3p1NvDg66nnE5Ca+WSax83si2pEhAalgH 78NZKN/y5kFAd7NpeW9Ra9krI9dxaguugo36KmibSaB+2JIwWCB6UUiQYGy7svj7zN Od/AKUc1HcwjsbEynGjN6lVctbTpaenz0TjwCvdkSSrU3SSYJFuEbc87HmHYV8zjFu 9nLmx33PFGUqw== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <1659463787-25976-1-git-send-email-badolevishal1116@gmail.com> References: <20220624010550.582BBC341C7@smtp.kernel.org> <1659463787-25976-1-git-send-email-badolevishal1116@gmail.com> Subject: Re: [PATCH v3] Common clock: To list active consumers of clocks From: Stephen Boyd Cc: mturquette@baylibre.com, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, chinmoyghosh2001@gmail.com, vimal.kumar32@gmail.com, Vishal Badole , Mintu Patel To: Vishal Badole Date: Mon, 22 Aug 2022 16:50:12 -0700 User-Agent: alot/0.10 Message-Id: <20220822235014.86203C433D6@smtp.kernel.org> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Vishal Badole (2022-08-02 11:09:47) > diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c > index f00d4c1..c96079f 100644 > --- a/drivers/clk/clk.c > +++ b/drivers/clk/clk.c > @@ -102,6 +102,7 @@ struct clk { > unsigned long min_rate; > unsigned long max_rate; > unsigned int exclusive_count; > + unsigned int enable_count; > struct hlist_node clks_node; > }; > =20 > @@ -1008,6 +1009,10 @@ void clk_disable(struct clk *clk) > return; > =20 > clk_core_disable_lock(clk->core); > + > + if (clk->enable_count > 0) > + clk->enable_count--; > + > } > EXPORT_SYMBOL_GPL(clk_disable); > =20 > @@ -1169,10 +1174,16 @@ EXPORT_SYMBOL_GPL(clk_restore_context); > */ > int clk_enable(struct clk *clk) > { > + int ret; > + > if (!clk) > return 0; > =20 > - return clk_core_enable_lock(clk->core); > + ret =3D clk_core_enable_lock(clk->core); > + if (!ret) > + clk->enable_count++; > + > + return ret; > } > EXPORT_SYMBOL_GPL(clk_enable); We'll want the above three hunks to be a different patch so we can discuss the merits of tracking per user enable counts. Do you have a usecase for this or is it "just for fun"? By adding a count we have more code, and we waste more memory to track this stat. I really would rather not bloat just because, so please elaborate on your use case. > =20 > @@ -2953,28 +2964,41 @@ static void clk_summary_show_one(struct seq_file = *s, struct clk_core *c, > int level) > { > int phase; > + struct clk *clk_user; > + int multi_node =3D 0; > =20 > - seq_printf(s, "%*s%-*s %7d %8d %8d %11lu %10lu ", > + seq_printf(s, "%*s%-*s %-7d %-8d %-8d %-11lu %-10lu ", > level * 3 + 1, "", > - 30 - level * 3, c->name, > + 35 - level * 3, c->name, > c->enable_count, c->prepare_count, c->protect_count, > clk_core_get_rate_recalc(c), > clk_core_get_accuracy_recalc(c)); > =20 > phase =3D clk_core_get_phase(c); > if (phase >=3D 0) > - seq_printf(s, "%5d", phase); > + seq_printf(s, "%-5d", phase); > else > seq_puts(s, "-----"); > =20 > - seq_printf(s, " %6d", clk_core_get_scaled_duty_cycle(c, 100000)); > + seq_printf(s, " %-6d", clk_core_get_scaled_duty_cycle(c, 100000)); > =20 > if (c->ops->is_enabled) > - seq_printf(s, " %9c\n", clk_core_is_enabled(c) ? 'Y' : 'N= '); > + seq_printf(s, " %5c ", clk_core_is_enabled(c) ? 'Y' : 'N'= ); > else if (!c->ops->enable) > - seq_printf(s, " %9c\n", 'Y'); > + seq_printf(s, " %5c ", 'Y'); > else > - seq_printf(s, " %9c\n", '?'); > + seq_printf(s, " %5c ", '?'); > + > + hlist_for_each_entry(clk_user, &c->clks, clks_node) { > + seq_printf(s, "%*s%-*s %-4d\n", > + level * 3 + 2 + 105 * multi_node, "", > + 30, > + clk_user->dev_id ? clk_user->dev_id : "devicel= ess", > + clk_user->enable_count); > + > + multi_node =3D 1; This part that prints the dev_id might be useful and can be the first patch in the series. In that same patch, please print the con_id so we know which clk it is for the device. We should also improve of_clk_get() so that the index is visible to the 'struct clk::con_id' somehow. Maybe we can convert the integer index into a string and assign that to con_id in that case as well.