Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3232157iob; Sun, 1 May 2022 10:23:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwU/mnmPs7MoJY0AkxNE1loj0OiwOOddS7nOB3F6x/xXdaj2C3iMqvke3HWV8R7KIXEX8Pr X-Received: by 2002:a17:90a:901:b0:1d9:4253:23e with SMTP id n1-20020a17090a090100b001d94253023emr9041179pjn.150.1651425826773; Sun, 01 May 2022 10:23:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651425826; cv=none; d=google.com; s=arc-20160816; b=mi9VBNICUVAyBZObvS6h5evCNDzDhpBCQAf+W9tbD0oGS2nGOpz9b0B9ACx2avfR58 dMaFIkyi2BQ/pS5cE1umlOB/djIfDhuwN2jxMIGVOZYmRozysSMPmTndI4+xvYEup18F UkzrLN6slFmMZEDFvMYYgi0nbYlzmkmn3GnLurhtYYw+b4ee8oiuwPkj4ZBc1mmOal4B rQvJMQDDgXpEorbku3rJsmTLFbq4IXtXdLJO+Pfeta66usKyU1u4aljIttKBiQG3vhbX TrXjw6ek9qIsFD7K2zm67AwilvOSu18ygep8N8VnVftraJ7lkRyD7yCiDHjY+MxmDt3R PYBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=l+Ao2RwIkRyyANPkSXXqtBch6AKumaxguIhH1CidR1Y=; b=yjFHZF7rG0+aEjPRzYBH1F0vUMvOO7JdDMm0yUOryctRb264g7ba9eeIsX/KtWCMt8 hGl/w4WZfpoGeV06MNjA3nnMQYNOfpAe4mddFhslcPQli3sVEkAL0kBL2jauRzTiACUN Srqb4Oi6eZf7s+4E3zCEXQ/f/ihrMppJ03ZCP8BhM+fPiUR8CEnwc6akYgDf8qdgprJn kN4WDQkzC8PPZiNaGa6Rz+8LByYprqpfwExAObsQYOsYBRm7NydeOU22Sk/BCJiREyRk dS2TW/kPPx4E/PXBWqF83Vi5+gvZAhZ9Wx9YzZd6MYQri2vW3xfphtFI855rTkxK6YIe RsUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=emAqveVy; 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=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u37-20020a634565000000b0038253c4de24si11776670pgk.186.2022.05.01.10.23.30; Sun, 01 May 2022 10:23:46 -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=@linaro.org header.s=google header.b=emAqveVy; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378171AbiD2PQj (ORCPT + 99 others); Fri, 29 Apr 2022 11:16:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378149AbiD2PQe (ORCPT ); Fri, 29 Apr 2022 11:16:34 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1841AD4C49 for ; Fri, 29 Apr 2022 08:13:15 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id a21so9445872edb.1 for ; Fri, 29 Apr 2022 08:13:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=l+Ao2RwIkRyyANPkSXXqtBch6AKumaxguIhH1CidR1Y=; b=emAqveVyJeyC4WuwF8N7NcYLVa+LcSLZc8Uu+9bmFtY2XC7qosw9nBSM15Et4VeWk5 6wiLh6cEtHZomttMnIHD09BbSb2eX5yQ3n1T1OQkhVFK8zM2jHx32FAG7O7HjFvwXbm1 gI3SgvTA/eouq5hXzQbAdg4uzFAalqoWue7UFfxCRI0UtRWJOoUjMch/lI3N6GMJ5y/k 98KV6D6A6gNlE6v1ztbwGr+iSv914wRcTES2umwo/N2K5ybbD789xWkAR08lOhXEPqW/ liZnUjVUltDdk+wr6i0VC1Dvbm0Xh+R91+5uYEoh1ktIIZoDHZPppmW9RwWK4hjAGvcF Acvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=l+Ao2RwIkRyyANPkSXXqtBch6AKumaxguIhH1CidR1Y=; b=gkSIEiG938EEGPBsDezJWGWHw81IIxvxR+3jK88iXNWxqjDs+7dw+2tiS/TVYOthDt wB65QMdRqd0Y/Swld14u2Mbh24QwXH2j/vutHcd3767cqIii09ntab6QOkFsGvyMpOEe Q+C9yV4QCUkJTFRfNrqIFcZ9NRfhuP4ZNeah/HMD6aJdRjnxtBIOXFfJ4NpzNHHxd1xE GLKrgfipTrVwjrqONwYnQZDZ/rHhtpcEyYoDjw/xzYLP5kU7bMyDssCwvCS1Es9KvfWo 0E1DVjxIvuL7LkfyfywtdPy+s3UIEpjzwUh54cYYTBsza49TSsFrpP8ZvLN99h0+S5xu Q9YA== X-Gm-Message-State: AOAM5335l2adiS1v0bgoqiDQaIIQOljXqtDr0mdRHHViCklb5D3fvfaa xpoa+y/ML0usDQ23Qb2J//2CsA== X-Received: by 2002:a05:6402:13c3:b0:425:d94b:4118 with SMTP id a3-20020a05640213c300b00425d94b4118mr31006881edx.75.1651245193575; Fri, 29 Apr 2022 08:13:13 -0700 (PDT) Received: from prec5560.. (freifunk-gw.bsa1-cpe1.syseleven.net. [176.74.57.43]) by smtp.gmail.com with ESMTPSA id zp15-20020a17090684ef00b006f3ef214e4esm712677ejb.180.2022.04.29.08.13.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Apr 2022 08:13:12 -0700 (PDT) From: Robert Foss To: bjorn.andersson@linaro.org, agross@kernel.org, mturquette@baylibre.com, sboyd@kernel.org, robh+dt@kernel.org, krzk+dt@kernel.org, jonathan@marek.ca, tdas@codeaurora.org, anischal@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vinod Koul Subject: [PATCH v1 2/9] clk: Introduce CLK_ASSUME_ENABLED_WHEN_UNUSED Date: Fri, 29 Apr 2022 17:12:40 +0200 Message-Id: <20220429151247.388837-2-robert.foss@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220429151247.388837-1-robert.foss@linaro.org> References: <20220429151247.388837-1-robert.foss@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 From: Bjorn Andersson Some clock implementations doesn't provide means of implementing is_enabled(), but still requires to be explicitly disabled when found unused as part of clk_disable_unused(). One such set of clocks are Qualcomm's display RCGs. These can be enabled and disabled automatically by the hardware, so it's not possible to reliably query their configuration. Further more, these clocks need to be disabled when unused, to allow them to be "parked" onto a safe parent. Failure to disable the RCG results in the hardware locking up as clk_disable_unused() traverses up the tree and turns off its source clocks. Add a new flag, CLK_ASSUME_ENABLED_BOOT, which clock drivers can use to signal that these clocks should be disabled even if they don't implement the is_enabled() ops. Signed-off-by: Bjorn Andersson Reviewed-by: Vinod Koul --- drivers/clk/clk.c | 2 +- include/linux/clk-provider.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index ed119182aa1b..9789ec137219 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1284,7 +1284,7 @@ static void __init clk_disable_unused_subtree(struct clk_core *core) * sequence. call .disable_unused if available, otherwise fall * back to .disable */ - if (clk_core_is_enabled(core)) { + if (clk_core_is_enabled(core) || core->flags & CLK_ASSUME_ENABLED_WHEN_UNUSED) { trace_clk_disable(core); if (core->ops->disable_unused) core->ops->disable_unused(core->hw); diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index c10dc4c659e2..9038022ffebd 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -32,6 +32,8 @@ #define CLK_OPS_PARENT_ENABLE BIT(12) /* duty cycle call may be forwarded to the parent clock */ #define CLK_DUTY_CYCLE_PARENT BIT(13) +/* assume clock is enabled if found unused in late init */ +#define CLK_ASSUME_ENABLED_WHEN_UNUSED BIT(14) struct clk; struct clk_hw; -- 2.32.0