Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2181545imm; Mon, 28 May 2018 03:24:15 -0700 (PDT) X-Google-Smtp-Source: AB8JxZobUqihxigF4ELkJt/e5975Ic4U6B9fmmwuNtq/Ag4XWWp9G3i7RXgzAJ5WpElyVIjjNuA2 X-Received: by 2002:a63:8ec8:: with SMTP id k191-v6mr10076935pge.435.1527503055351; Mon, 28 May 2018 03:24:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527503055; cv=none; d=google.com; s=arc-20160816; b=NpHr32gJxSdsq3cuXft1bxCBUEG0UPmE3pfQYU8BLAPjtIPvrWqw7+rmsjoKNnruUm ItH9jmztmQ/fpnHvmOsb11fRsA2NSvo+u22Nroamf/eTmKggKoS+G/r4ZTa/vl9Xu58n UJcbHdE5KIHA3+A4xS8nrVaS0ERZb0bcy/mrHW6rhFEp4v7jLViLjUpk6We6ok2DzDcP qwHrD57NI7B/eZytlFKGlfDJ8NBywEldf23pR2Y+2FoPm4l0/S50l1ZpzIomSbvilU6V K+rPI/W8uDAR0Yzrvyt3SyX/2ekVXr9mp47+JVy7j34c+Ab3Fa6iwhRg3ayI2Eg+Ye6N IZyA== 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=x1DSaSPpc+UoKRi4bCq6Rlwcy7BqmKhLShyLi+0sLSw=; b=wfcpfmTDZmAADD0+WhWjGmJ/bsaJGyst1jfBxQyLoFAjxF9vTaUJOVABOOy0UlYKio nBnA2gJUFgoSV85pY/YP6iTxpR/b1/gSPr5xyMM0dtq8dT2mZisVHm/njMz46zfbWe2s 3349OUjIklqVxLXsXKIWICwkq5Q6CrOL2uxS979lzJGFlFVTsefIdxDbnVizif/is/6i HegXqSGQHe5xSFtIgWFWLqExZ/TNx9vlyr6vYD4EbDs1emvEWUpNAf18UkTJEU3XOHCj gwDBtW7XY2fgGcsiNym7zecISY0GF8LT6wnMn2G743fsZ34XBTB1mYo3i09el9MV/kWk hYsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OWdBnU5F; 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 g63-v6si878778pfk.74.2018.05.28.03.24.00; Mon, 28 May 2018 03:24:15 -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=OWdBnU5F; 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 S1033641AbeE1KXR (ORCPT + 99 others); Mon, 28 May 2018 06:23:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:42536 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033622AbeE1KXI (ORCPT ); Mon, 28 May 2018 06:23:08 -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 C58FB20844; Mon, 28 May 2018 10:23:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527502988; bh=ofYr33FoA7QVglm4r36pL7vl6wi/qcvSLHNd1T/h4sM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OWdBnU5FrUtwjgdDuY7nZw8PGIr+7pCKaAkk9RqdneDhU9pX0jM8S7TN7rBG0YD/+ CThiqj1EIwemdSplIu4FBvhRGAT73MWmSjztGJym8cUBWf0GfML96i7SHnr3pglMVc 2gv10UlNlmWJl3fq4hY/lo9DrmAx12jCDgM/nUKU= 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.4 202/268] clk: Dont show the incorrect clock phase Date: Mon, 28 May 2018 12:02:56 +0200 Message-Id: <20180528100225.180696275@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100202.045206534@linuxfoundation.org> References: <20180528100202.045206534@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.4-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 @@ -1905,6 +1905,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();