Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1977840imm; Thu, 24 May 2018 03:56:26 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq5SP9lITOlgY0u87nInhEhhT9HSryxhrHpjpwPP2G8pc5Dmb9Pcdl2n+UpMzckvpUChnMJ X-Received: by 2002:a17:902:3f81:: with SMTP id a1-v6mr6743720pld.29.1527159386179; Thu, 24 May 2018 03:56:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527159386; cv=none; d=google.com; s=arc-20160816; b=Fw8S3/3b7y0c51/4edbxHmVqbDJVnnH01v+eRnDYIj0lZVsFhV2pNvyk7o1PF5/qdZ NK9hJNb7Dp7F7LJOs8unXzUJqjopRkY2hjl21AhGVojmFG9FqLI9yJqpbU3T8swcSg/5 yU4b276t2vdilwavUXMSFdyuR38Bmi40IiU6Q3grZJSg98YCR/izsqe2XD4y+SXZlcky HpLbttqoVQj7JnUuHZ45KGza84pJQ2+qVioRvkWsnmPDA+4l0bLwM/hxaODG/4isZPM7 MGJTQ1c+m01iyDA8r2BKLUopGiWmq0FXQ520gxCPHs+T1QzAVIRF4ooPm1mzPDKjFYTa S1JA== 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:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=f06vKPuDXBkuBOOQ7BoKDyzSzEhAs9n2kSmPZAcHb70=; b=nqQuOmRqLx8hP1aM1K9rjJ6KXRxZrKA5mNGrz2uAD8chp3MoI7EySKUhYyP/iAws9U 3iLOOQtjcbQqd/sesELy//LhtXzXu3LVMF2LVU9Nwb7xUaNgXA2T1ASihokhOldLqnV0 wCk++9UOZ52DeXuj5cpJFRnHn7pYwVGJTyjunglUKmz3q9pscnnoYDs2MmE9G5xjyohF ffcDUYUiTdnf8akSdXvDF8iz51knNDsxzi25l8vOaBORaT4hBfOXXHSgOjGioszw+HUG sBxeFykoTnuB/+w1muCFG1jCOsEhmgmvVpK1PoufP63+mZF8G+ZUaw9SNCiN6LBwb1ak cUyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=o4dPt5wG; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c12-v6si13291765pgw.124.2018.05.24.03.56.11; Thu, 24 May 2018 03:56:26 -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=@kernel.org header.s=default header.b=o4dPt5wG; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032476AbeEXKy1 (ORCPT + 99 others); Thu, 24 May 2018 06:54:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:36736 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030352AbeEXJ4y (ORCPT ); Thu, 24 May 2018 05:56:54 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 A2A7D20891; Thu, 24 May 2018 09:56:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155814; bh=EVkwITGDOacAJvE0gn+1XcmE3gYy0tFxdAsHF7jLcps=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o4dPt5wGjlPO2oM4ScboQFFVmhYrKeJOlsFqdjjFNv/0RvL5LYSdHt/+oWPpvN83B EFW8zJnadEuH0djd1jA0pxnF9cSCTnh38sst30HpggxqY2F1Vx/MXlz70JzEC6XWVQ pNMXLD+E6q7cJZICgHBZ5vPIQwmCTlDiybMweyA4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shawn Lin , Jerome Brunet , Stephen Boyd , Sasha Levin Subject: [PATCH 4.14 127/165] clk: Dont show the incorrect clock phase Date: Thu, 24 May 2018 11:38:53 +0200 Message-Id: <20180524093627.142660000@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093621.979359379@linuxfoundation.org> References: <20180524093621.979359379@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shawn Lin [ Upstream commit 1f9c63e8de3d7b377c9d74e4a17524cfb60e6384 ] It's found that the clock phase output from clk_summary is wrong compared to the actual phase reading from the register. cat /sys/kernel/debug/clk/clk_summary | grep sdio_sample sdio_sample 0 1 0 50000000 0 -22 It exposes an issue that clk core, clk_core_get_phase, always returns the cached core->phase which should be either updated by calling clk_set_phase or directly from the first place the clk was registered. When registering the clk, the core->phase geting from ->get_phase() may return negative value indicating error. This is quite common since the clk's phase may be highly related to its parent chain, but it was temporarily orphan when registered, since its parent chains hadn't be ready at that time, so the clk drivers decide to return error in this case. However, if no clk_set_phase is called or maybe the ->set_phase() isn't even implemented, the core->phase would never be updated. This is wrong, and we should try to update it when all its parent chains are settled down, like the way of updating clock rate for that. But it's not deserved to complicate the code now and just update it anyway when calling clk_core_get_phase, which would be much simple and enough. Signed-off-by: Shawn Lin Acked-by: Jerome Brunet Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/clk/clk.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1931,6 +1931,9 @@ static int clk_core_get_phase(struct clk int ret; clk_prepare_lock(); + /* Always try to update cached phase if possible */ + if (core->ops->get_phase) + core->phase = core->ops->get_phase(core->hw); ret = core->phase; clk_prepare_unlock();