Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2013868ybh; Fri, 24 Jul 2020 02:09:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwteYk4wDLyHm5SvdxAU6AL9gy0DwpgPvUET2wLIfWBUMe8ZMop9DMkSwSz0TvcYoeTpf8 X-Received: by 2002:a17:906:fb99:: with SMTP id lr25mr8281116ejb.49.1595581762935; Fri, 24 Jul 2020 02:09:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595581762; cv=none; d=google.com; s=arc-20160816; b=P8s1Z7j5+qNJ5DEI0TERm1+vwdNvZmhhT6u4cjhBZEOWruuWKXWaBpKdpFBEXvP5+s 63rXJKLyYon8LnGiI6hWqp7H0XhWC9lyANT93F5bHNzmscXrOeVkJPOzq7ETWMgg+aTq pu8JlWF8mq0OHW0BWmABOQtEBaM3G80Nd4NiEjvsLQfWdd2kAnhGm3yGGz5hWTmg+CGa Y2XswRrIpaPcDLTR4dfOy3AEorADTTE5b0fafxdFqgdAYc5xSG2RYOfStayVXijlN1tR 5MlA0xyh/xkQKfFwx20AY+mpnRB9t7C9s2kESCEYPCQ4LCRSposs1AMkA0LGg2lyGKar 8PHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:date:to:cc:from :subject:references:in-reply-to:content-transfer-encoding :mime-version:dkim-signature; bh=EJIlZ1RQLrEu8i0vHuwzipAVrDX6Lvb7Zrvq38kEiXw=; b=lEg/MlgusaZ1XZNeX7/AI/0DS6YoFXke+S6HcPzfA0zzbJfoEseggct3Vd8NEjia8a 0Eqq1t3W4NorpH74VXikIf/rY7a6Tn8/tFuw9pqfQXbzqprDCVKRO9TYXppN2IgcRQ8u sV+voSFxcdn7o6yWVyJ3ZlO6hbDBMuYCr4469/nbcBViQ5vdguCC4UaFbf+h4M4Usdx4 jObQYTiXcrELoqabpAhP5C0lBJJMgsTugvNqBJKpG7fE4zc7ebpU3OHZoUDwqbMofQDc r3tA2OK52sC6dpp3zpCJnNTv+xo0xJ6h0AbPYYu0oZe0EZwO5XiVBeO7/+F+Vx/GXGON W6sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qfS8ar17; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j6si161682edq.8.2020.07.24.02.09.00; Fri, 24 Jul 2020 02:09:22 -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; dkim=pass header.i=@kernel.org header.s=default header.b=qfS8ar17; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727859AbgGXJG4 (ORCPT + 99 others); Fri, 24 Jul 2020 05:06:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:42854 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727050AbgGXJG4 (ORCPT ); Fri, 24 Jul 2020 05:06:56 -0400 Received: from kernel.org (unknown [104.132.0.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B1F132074F; Fri, 24 Jul 2020 09:06:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595581615; bh=u+8QPLNFWhu22Q1xuFhfB9/1RtBv3ZupfetFjIcaBxI=; h=In-Reply-To:References:Subject:From:Cc:To:Date:From; b=qfS8ar17yiMuou9GAlrOZgpCziAF0PVwKT7fs7T1dwLyTDEt42pL+HUcIUCWJkYEU 1T4luJsLlvka6C1VPRnUAUVNhPzc5rfHD3VYrB+pAIbXOPBENh+XMaKBBDoaF7JHkq 88+iQkU+F1BKpirtzj5vmw410V48N0AWi5773Hok= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <20200630003024.6282-1-mdtipton@codeaurora.org> References: <20200630003024.6282-1-mdtipton@codeaurora.org> Subject: Re: [PATCH] clk: Add support for enabling/disabling clocks from debugfs From: Stephen Boyd Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, tdas@codeaurora.org, Mike Tipton To: Mike Tipton , mturquette@baylibre.com Date: Fri, 24 Jul 2020 02:06:54 -0700 Message-ID: <159558161499.3847286.16032712002329424951@swboyd.mtv.corp.google.com> User-Agent: alot/0.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Mike Tipton (2020-06-29 17:30:24) > For test and debug purposes, it's often necessary to enable or disable > clocks from shell. Add a new debugfs file (clk_prepare_enable) that > calls clk_prepare_enable() when writing "1" and clk_disable_unprepare() > when writing "0". >=20 > This can have security implications, so only support it when the code > has been modified to #define CLOCK_ALLOW_WRITE_DEBUGS. DEBUGFS >=20 > Signed-off-by: Mike Tipton > --- > drivers/clk/clk.c | 38 ++++++++++++++++++++++++++++++++++---- > 1 file changed, 34 insertions(+), 4 deletions(-) >=20 > diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c > index 236923b25543..3640bbc56870 100644 > --- a/drivers/clk/clk.c > +++ b/drivers/clk/clk.c > @@ -3034,13 +3034,14 @@ static int clk_dump_show(struct seq_file *s, void= *data) > } > DEFINE_SHOW_ATTRIBUTE(clk_dump); > =20 > -#undef CLOCK_ALLOW_WRITE_DEBUGFS > -#ifdef CLOCK_ALLOW_WRITE_DEBUGFS This didn't need to change. > /* > - * This can be dangerous, therefore don't provide any real compile time > - * configuration option for this feature. > + * These features can be dangerous, therefore don't provide any real com= pile > + * time configuration option for them. > * People who want to use this will need to modify the source code direc= tly. > */ > +#undef CLOCK_ALLOW_WRITE_DEBUGFS > +#ifdef CLOCK_ALLOW_WRITE_DEBUGFS So I put it back and dropped your rewording. > + > static int clk_rate_set(void *data, u64 val) > { > struct clk_core *core =3D data; > @@ -3054,6 +3055,31 @@ static int clk_rate_set(void *data, u64 val) > } > =20 > #define clk_rate_mode 0644 > + > +static int clk_prepare_enable_set(void *data, u64 val) > +{ > + struct clk_core *core =3D data; > + int ret =3D 0; > + > + if (val) > + ret =3D clk_prepare_enable(core->hw->clk); > + else > + clk_disable_unprepare(core->hw->clk); > + > + return ret; > +} > + > +static int clk_prepare_enable_get(void *data, u64 *val) > +{ > + struct clk_core *core =3D data; > + > + *val =3D core->enable_count && core->prepare_count; > + return 0; > +} > + > +DEFINE_DEBUGFS_ATTRIBUTE(clk_prepare_enable_fops, clk_prepare_enable_get, > + clk_prepare_enable_set, "%llu\n"); > + > #else > #define clk_rate_set NULL > #define clk_rate_mode 0444 > @@ -3231,6 +3257,10 @@ static void clk_debug_create_one(struct clk_core *= core, struct dentry *pdentry) > debugfs_create_u32("clk_notifier_count", 0444, root, &core->notif= ier_count); > debugfs_create_file("clk_duty_cycle", 0444, root, core, > &clk_duty_cycle_fops); > +#ifdef CLOCK_ALLOW_WRITE_DEBUGFS This is ugly but I guess we can't do much. > + debugfs_create_file("clk_prepare_enable", 0644, root, core, > + &clk_prepare_enable_fops); > +#endif > =20 Applied to clk-next.