Received: by 10.223.185.116 with SMTP id b49csp2965127wrg; Mon, 12 Feb 2018 18:35:42 -0800 (PST) X-Google-Smtp-Source: AH8x227K4nZPdK/SS9kS+OGbsnb/b/IIyxAWxF7Uw+cPPCuTd+G5oDVd3fh7dpTgaSnmjfxuAO1g X-Received: by 2002:a17:902:bf41:: with SMTP id u1-v6mr12146299pls.416.1518489342437; Mon, 12 Feb 2018 18:35:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518489342; cv=none; d=google.com; s=arc-20160816; b=uW2FruSWuZTFEeGyWXWv6hj7F/H8tE3ztkbVVF2+Hyxki53aAY9vdQbtPZdr1qZ92R x6tdkW6LfClm3JZCx7q7G4yVcdqMjem7ZDDhKJ01YmlaqNtvYeW6l5d/9uwj2D5dorij 1F778AtI2D9MGnEsXvvFBLAyLj+rWbGgSyA+AJMMLvP5OUo7Xp7RWKPjCahRRMvmAimC KGAnDOH0JkG0fFV+VSSMn8d3E5JeiyRW4gk7Nr5tveD0UcNZwpSB2jQfT7OEFtKKocq8 N8Foa71iBRkyqgZbhBwK0eWTfJGzNcAFSO2N6BAFV1BXSEIyAygNyUuRw+6bSo3s8OWz QRDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:arc-authentication-results; bh=zCFwC2Z1RtuDrFE16BXFv5uBDzBx3D3TpQ9OWsqtycQ=; b=sIqX1s27tULo1uKhve/9rVFjwdIO7ZzDq3TuYA7TS5PD14gXlrPL4Y2McNq9xre3Li ZP7TVCLtEBY74XG8aYOA022WBeNFHPyjbmmlDaGw9zuEOkLNdzXhIwJln5N/06M8r2Ni NRPplvXNLd+w+AeWOvEBK6PbrTyHNsd3+yWcynTqdLhdx6ixAGwtlN37aOu7IEBnRDLD E9J+mGAXRHcTZCpbiVsCHFP2nZqZJAvoFMjQJUpWveaUdSWqXlZF/0xGnpfKQgi/0Dbi uxIEqQ3HhTBff1tX2IS1g3NauHHxHY2iwQb/s7rRHEl3PjOfrGTxnK0TsZS2CCwRNHSe jVrg== ARC-Authentication-Results: i=1; mx.google.com; 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 k13si673457pgc.651.2018.02.12.18.35.26; Mon, 12 Feb 2018 18:35:42 -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; 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 S933307AbeBMCeq (ORCPT + 99 others); Mon, 12 Feb 2018 21:34:46 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:34157 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933199AbeBMCep (ORCPT ); Mon, 12 Feb 2018 21:34:45 -0500 Received: by mail-wm0-f65.google.com with SMTP id j21so11276333wmh.1; Mon, 12 Feb 2018 18:34:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=zCFwC2Z1RtuDrFE16BXFv5uBDzBx3D3TpQ9OWsqtycQ=; b=Re2wVnUKcybobDTV7YKdzSt1BiB5DTtX21utfPrB6CN4bCu3/C2xTv3OehVD89It82 q3sbCovgHY5tnYQFNzj5EG8vW/YQ0TeMw7fQ3EjyKUc0wkddGAHWpCcpXzN+7T7sPE91 lEOyPC+wharjBRi3ve8ySItH/J1qEk4TAdLjBK56z+OynoBfLdP4i79OeVP7KnqdZ/Av UsOSJCXgU8NKg7NCpsfIFhnmrskOx++chdzElO2/qoxT/Jndi+oNR2Hvmf4anYY2gW6x LpKX6vOfau3UspByFa+iJtY7t6VqJlvcbgKx7yfNncv9lxeFTVNsot0CxbmvohkVzUsF lgPg== X-Gm-Message-State: APf1xPAIj5wzKzo5XxjLy3Bk4lJDXsXUIaZPOwj0SaAMDyi9GbxYlzZy cJVXxaeommyeIS+IN+WrgAIaPDyX X-Received: by 10.80.195.18 with SMTP id a18mr54943edb.178.1518489283595; Mon, 12 Feb 2018 18:34:43 -0800 (PST) Received: from mail-wm0-f43.google.com (mail-wm0-f43.google.com. [74.125.82.43]) by smtp.gmail.com with ESMTPSA id w2sm6034455edb.25.2018.02.12.18.34.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Feb 2018 18:34:43 -0800 (PST) Received: by mail-wm0-f43.google.com with SMTP id v71so13384700wmv.2; Mon, 12 Feb 2018 18:34:43 -0800 (PST) X-Received: by 10.28.90.197 with SMTP id o188mr37796wmb.34.1518489282856; Mon, 12 Feb 2018 18:34:42 -0800 (PST) MIME-Version: 1.0 Received: by 10.223.208.197 with HTTP; Mon, 12 Feb 2018 18:34:22 -0800 (PST) In-Reply-To: <20180212210723.20919-1-embed3d@gmail.com> References: <20180212210723.20919-1-embed3d@gmail.com> From: Chen-Yu Tsai Date: Tue, 13 Feb 2018 10:34:22 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] rtc: ac100: Fix ac100 determine rate bug To: Philipp Rossak Cc: Alessandro Zummo , Alexandre Belloni , linux-kernel , linux-sunxi , linux-rtc@vger.kernel.org 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 On Tue, Feb 13, 2018 at 5:07 AM, Philipp Rossak wrote: > 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 > Please add the tag: Fixes: 04940631b8d2 ("rtc: ac100: Add clk output support") > 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; There should be a comment on why this is happening, i.e. we purposefully left open the possibility of the clock from the codec side missing. Otherwise I think the clk subsystem doesn't expect this to happen, which is why there are no checks like this anywhere. ChenYu > + > + prate = clk_hw_get_rate(parent); > > tmp = ac100_clkout_round_rate(hw, req->rate, prate); > > -- > 2.11.0 >