Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2019094imm; Thu, 24 May 2018 04:37:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrJ9x9QB2r7JB6T0maDFZl/StLo232da+pVRh54Q7gVtTbZ6ukkj+TngFpHfKRX73JAeh3f X-Received: by 2002:a17:902:5c6:: with SMTP id f64-v6mr6962249plf.50.1527161823467; Thu, 24 May 2018 04:37:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527161823; cv=none; d=google.com; s=arc-20160816; b=D3gOo8/tVKtLbY2OHsZMmWeeTPvq3jFIz2PTAcdHkwy1YjoQ9A+DWFuTrll1FuA2dO 9zZOKpTIBmoNbYv5sfXEGOlwNOBygi/Z3o7KQ1TUu8DfTjR+U+nmJv4yKV4o59jz2Ogv jYVwY3gz+WEDekwWDCofVoO0bPIN9BjrA42wWIoXLdTTsXIO97QwUTbIuqyAFtv664j8 szGe06HttanaplRdphh5NX3QyrVXTdSl+aIk2AEhuR++pMH2KNzJxY7QXbAVXOeGCM2n MxobwPnq3j9knMp+tJqQe1N5KmvD7uAv9NQ9PkH0dUnr7VtLAipCOJHGQPB3bpuLcCux qPJA== 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=ouUZAIpDvODIzU0YdoEYXuce6g6wgQQHIDrv8qzjalI=; b=VWKMkw4Bacl2zKVDG+E1fbQ/oi+9ArFRmd7p+2xqhCr0x2honbfLVMTM3ROfXUxfOP ZWxewPcnlZBnL+mEPdQSByvc0/rtDBvuEZzPw27qiVbjCMHb0prbiQadcG934ZbrvIzN Anq2Ut9VPcW9yL9uH4caFMns/zazjCsFj+N5r2JzEx8NkYuInbQ1UETGPZpFiNRBh7B5 jsu4yZorb72gdKS3XKaVloi5JdOXkxw850NXCBUjcLU73+JVKB0WOrJxR+Sf957pfXtz GMFl7yM8RV/qcNAuQcd+tzHlTmZJaleG3HFG8yRT6V6EZF1LLpotyAeb6ivEgcTIlA7e GbAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JOIlXFaM; 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 t1-v6si4160158plq.341.2018.05.24.04.36.49; Thu, 24 May 2018 04:37:03 -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=JOIlXFaM; 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 S969079AbeEXLgS (ORCPT + 99 others); Thu, 24 May 2018 07:36:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:39854 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967500AbeEXJt5 (ORCPT ); Thu, 24 May 2018 05:49:57 -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 683902089E; Thu, 24 May 2018 09:49:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155396; bh=2QVR4GYqk0X7uOx4wwsLOq5wMaJoY1ZFmKFG+Xkj4no=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JOIlXFaMIJw9bUerqJThWdX62rkaNwa8YBNoif8RlDlo+uliyFNhAzrGFkgiGjPg9 6mbwtl4lxqWY8RFSFieoNTFZL8U3KiPyGcxPopNKoC0NAFhpahhmZu7SyUKRYJN6Wo YuM19uo2DJUnbpd7TvT0ARnQIXrytS7QUGYdMcj0= 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.9 71/96] clk: Dont show the incorrect clock phase Date: Thu, 24 May 2018 11:38:54 +0200 Message-Id: <20180524093609.470469718@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093605.602125311@linuxfoundation.org> References: <20180524093605.602125311@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.9-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 @@ -1929,6 +1929,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();