Received: by 10.223.185.116 with SMTP id b49csp2639627wrg; Mon, 12 Feb 2018 13:08:57 -0800 (PST) X-Google-Smtp-Source: AH8x227CvIhEqnKwtGiaV7RyhhH10WUBR+sbtVvFUG9Vxt3nTIpU3F89qFyggfn7uGg7KQ8sOUoE X-Received: by 10.99.165.71 with SMTP id r7mr5838101pgu.60.1518469737739; Mon, 12 Feb 2018 13:08:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518469737; cv=none; d=google.com; s=arc-20160816; b=bR0Jl602HHmg9YHCJJkZ7vW7ZlssHSKFnvngvpBQBf5BHvrIx2cv6YCtL0bplSUsHm TkeHgyM4F+Yofz4no0794r+HSr7Sot/9ljj7D9nce4pA7pILH1W4QOa651qjybM4HA3p VV8ZOS4HS5hPJLeslObb1+VwNp+0Y1+hRqPIR2OITeSx98qrR9vabb4BQfMCuOoMN0qR aowvyogu69E5xakOrHk9iSQgV6zCj2MJ2KVea6mVuhcSxa+oh4/pUxgHyE0EjcM1Lkmm oVSpZDsLLRSRaCCPUpOUzVeqeoaCtnp1vpUYY/F0lS4Y5a7Q4/FLqvgjm1lMQo/Jkdn2 mZfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=dBdRQJgymmtqhjx45Bpi4ujMQKyEDofN9fB3kXdkqUY=; b=I27g6+Wu4JMM9uI6buC46dDZAE7r2Zm6wzst9ppaLzebewzpEeJgSE2kVVlsbqiI1U /7F6htc2376MLy6M0DPtdS5Y8LG4fT8OY+wzBQ5LpFYXDAotWfJoTgf/DKuIbKVHZElE 4Vx9HhCHkTo673yyizjdZXMgmDr2XpKkeRrRz1BsYjSO8M4LC9U2k2ut7EZm8Nd9Vc63 Ks8gI9zzLWhqD2ol6o30GFtViv0l0KJRyFGchTm01kb4JBgwDHp9SdFL8RClkOHum/ui Bc2C7fgwMF86ChFArLD7VxNGkc2lvdlo+povFoMp79fOBESCTVJ798GYPjvHTu2+VZK6 i6ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iMxD06Sc; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t18-v6si145018plo.493.2018.02.12.13.08.42; Mon, 12 Feb 2018 13:08:57 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=iMxD06Sc; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754115AbeBLVH2 (ORCPT + 99 others); Mon, 12 Feb 2018 16:07:28 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:34283 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753908AbeBLVH1 (ORCPT ); Mon, 12 Feb 2018 16:07:27 -0500 Received: by mail-wr0-f194.google.com with SMTP id m5so4545443wrg.1; Mon, 12 Feb 2018 13:07:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=dBdRQJgymmtqhjx45Bpi4ujMQKyEDofN9fB3kXdkqUY=; b=iMxD06ScMrbgn/UwMhC2iC38WF1Ql3MtNwVs94/FauGTfrUexVs8jDQakjVHYRLbwB 8zKlR9ESYpUNvmmFWhmdVY/q8tRZdxHRHXNtO1mrybmZx4CPglqTNino0sxFsA4EE/JH OOY0BIUuZlVipJTQD40pq8w2ai5nOjFcB+c3MP/jLgB2EuZjD2lTzT3vWWgbYyDr2iyY 7ShZKuoKy8nEFC/ytbGwtzTkz+W0KjUR7o8ZgM1gbMAkBfXG0Znko8V/0yxBGp3lWmra mFwCcCx+t46aH+tHE7lhBlhok0pRerH91R4IJw9W0Tz2/9VxqM0ZZ9krwsJ3bacX5jy7 KiAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=dBdRQJgymmtqhjx45Bpi4ujMQKyEDofN9fB3kXdkqUY=; b=ILaDY3QVgKkT4B+JdP+VLfVwS/85sax+EPF7Wq7G24u5v5cQV0LlgtcAu10u179+ca 1y6lrWSIHCIsM+51d/UlYw6AdKMYlDVd9SdMflpyN9xFsKI8rpCxM5bcvO+7Rb9e0Yvj /6Iw1ByGtI+7tFEFbQZyzhdTfQWTUgan0xNGA41+kLN+unKPSuMk0qm/1HYk8zAY+sbu 9lFEA2BSxX7F/LufiN59yTOk/qLB2suvNrUFQpWxIdHWJRrOk3RW6RPJ1+VDY+NgO1+y PWwoncQQ/iJCTuL4i2tll4vo+rl9WvzVgMbFRPtrFD+/Klb/NvGn8He3Y7TJPMtbENvZ JTZA== X-Gm-Message-State: APf1xPAWI6CLd2JN5igtqqt5dhveWHJe9FwhZ/6pbQH5E2TO5RpntJwD kps4eN3xDnp0lVaJZnqiI2o= X-Received: by 10.223.134.20 with SMTP id 20mr10381588wrv.280.1518469645664; Mon, 12 Feb 2018 13:07:25 -0800 (PST) Received: from debian-laptop.fritz.box (p578F04D2.dip0.t-ipconnect.de. [87.143.4.210]) by smtp.gmail.com with ESMTPSA id k36sm9590711wre.39.2018.02.12.13.07.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Feb 2018 13:07:25 -0800 (PST) From: Philipp Rossak To: wens@csie.org, a.zummo@towertech.it, alexandre.belloni@free-electrons.com Cc: linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, linux-rtc@vger.kernel.org Subject: [PATCH] rtc: ac100: Fix ac100 determine rate bug Date: Mon, 12 Feb 2018 22:07:23 +0100 Message-Id: <20180212210723.20919-1-embed3d@gmail.com> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch fixes a bug, that prevents the Allwinner A83T and the A80 from a successful boot. You can find the shortend trace below: Unable to handle kernel NULL pointer dereference at virtual address 00000000 pgd = (ptrval) [00000000] *pgd=00000000 Internal error: Oops: 5 [#1] SMP ARM Modules linked in: CPU: 0 PID: 49 Comm: kworker/0:1 Not tainted 4.15.0-10190-gb89e32ccd1be #2 Hardware name: Allwinner sun8i Family Workqueue: events deferred_probe_work_func PC is at clk_hw_get_rate+0x0/0x34 LR is at ac100_clkout_determine_rate+0x48/0x19c [ ... ] (clk_hw_get_rate) from (ac100_clkout_determine_rate+0x48/0x19c) (ac100_clkout_determine_rate) from (clk_core_set_rate_nolock+0x3c/0x1a0) (clk_core_set_rate_nolock) from (clk_set_rate+0x30/0x88) (clk_set_rate) from (of_clk_set_defaults+0x200/0x364) (of_clk_set_defaults) from (platform_drv_probe+0x18/0xb0) To fix that bug, we first check if the return of the clk_hw_get_parent_by_index is non zero. If it is zero we skip that clock parent. The BUG report could be found here: https://lkml.org/lkml/2018/2/10/198 Signed-off-by: Philipp Rossak --- drivers/rtc/rtc-ac100.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/rtc/rtc-ac100.c b/drivers/rtc/rtc-ac100.c index 8ff9dc3fe5bf..820ce6fb9d34 100644 --- a/drivers/rtc/rtc-ac100.c +++ b/drivers/rtc/rtc-ac100.c @@ -183,7 +183,12 @@ static int ac100_clkout_determine_rate(struct clk_hw *hw, for (i = 0; i < num_parents; i++) { struct clk_hw *parent = clk_hw_get_parent_by_index(hw, i); - unsigned long tmp, prate = clk_hw_get_rate(parent); + unsigned long tmp, prate; + + if (!parent) + continue; + + prate = clk_hw_get_rate(parent); tmp = ac100_clkout_round_rate(hw, req->rate, prate); -- 2.11.0