Received: by 10.223.185.116 with SMTP id b49csp3652945wrg; Tue, 13 Feb 2018 05:46:33 -0800 (PST) X-Google-Smtp-Source: AH8x227/5/R2Z8nJJUTEu+xyVAQkmzz84gMk9Wje/jKaZObphWP9aChICnDDedfSGmnj/ArUWsQ0 X-Received: by 2002:a17:902:6b49:: with SMTP id g9-v6mr1190313plt.9.1518529593463; Tue, 13 Feb 2018 05:46:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518529593; cv=none; d=google.com; s=arc-20160816; b=LEG0mcyRwmz6cSIovbJb0+AukRvPUVOOd8abymYC8BOqGap6cLZE7SAxs9bJzObVPL PAnsgNXH4SocwuZf+RKqQGTlGexE8I+M6mH6LTmzdea6AKDqhOf9F9ThYyjEy7jMwZ2e U32U2kHhDpxEWbcTTNnaQ/hJZmC4iJfCQ2Sra3X2uJjSYh/Ww2ScXhL9qPXSHqhLoYbt 79xC9BXlC5hYWDOV87lnx6HWxPhRccjUnGxdOh5I2YREA1yq4UfdquGMqWN1ZkkgyD46 iLq1LioICIo1i4XH6elr4x1DrhSC2BR0BSN0PjrjP6E73VXbjsA9H7uLYXhsU4oD+CuU g8IQ== 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=z7OTkhIKwofQZeeW0JumlVfQnDW/KIyvh9UWQ+NnLTY=; b=fThGogGjAU7x5t4TAC+6pAd9OCneDQ+fKgvURZY2olnjCJ1qaH7iKD0HIr7ZeHQJf/ C3Te/eGEFhh1JhD3OPfUveQikQKs6kujQU8p4UoVU6HLo4NaG1bXg8olXinJYMGlDNgv GBqiW/rD3aAK5dH88/jVslOwOLTrLc9LTQWcnt6aVnUp1cB0qdvWOHVsQ3R1KdanwXDL L5H2DSnvxpLH7lVRgxanCPc6McTNFLWw3sgWu68kEhzC4deKbhnwIWZSPg1VoPRQ0cnb QZaNKalPvxELFffWDUaxNOQr3jAWga7uzVn1X1eVMzFd1gySoc8KWi3E/gCuE7CPdG2z PiuQ== 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 z21si6177388pfl.96.2018.02.13.05.46.17; Tue, 13 Feb 2018 05:46:33 -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 S964917AbeBMNpJ (ORCPT + 99 others); Tue, 13 Feb 2018 08:45:09 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:53888 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964792AbeBMNpI (ORCPT ); Tue, 13 Feb 2018 08:45:08 -0500 Received: by mail-wm0-f68.google.com with SMTP id t74so16192081wme.3; Tue, 13 Feb 2018 05:45:07 -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=z7OTkhIKwofQZeeW0JumlVfQnDW/KIyvh9UWQ+NnLTY=; b=N3apX3LkTR8m0lkFwevsGe1FE9uGdD6BgHOp5ZrzziosYSzeLrMO/OqAIYX3KNy8Ry nrd+r8ZPQmQxs2t9Bw9yENVS4wNab1lexFmamidEyxgqKHnB9H0ZimmEpJlqYu8mnkgo ZC79LJ31ivb+3CuGHF8szPhQwmchmn5fTP6D+xnYIWNkbtKP7HDpnXZVDPU93XgY5tDa z8V+F/jhJx4J334xuozHtLqX3fyHZzgEjXhqxZab0WNeh90kq2+eDHNh3oo64pOOKnUL Gh/bq0aK8CFC1t3l5rsfrm8sP+HGjx0B0DZb2mXnXVFRwopiUb3OFpTv2QxM8OLOq3xg rMuQ== X-Gm-Message-State: APf1xPCjPPe5A7Yrr+yUQbK0QSdDsmtBLhtbVgW7RCsLXZ9SZMSXrZkT 6lAVEiL4MbrRjfS6xZNVU03Zg3ij X-Received: by 10.80.180.16 with SMTP id b16mr2228837edh.111.1518529506386; Tue, 13 Feb 2018 05:45:06 -0800 (PST) Received: from mail-wr0-f173.google.com (mail-wr0-f173.google.com. [209.85.128.173]) by smtp.gmail.com with ESMTPSA id g59sm6205005ede.19.2018.02.13.05.45.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Feb 2018 05:45:06 -0800 (PST) Received: by mail-wr0-f173.google.com with SMTP id v65so11872994wrc.11; Tue, 13 Feb 2018 05:45:05 -0800 (PST) X-Received: by 10.223.132.103 with SMTP id 94mr1386685wrf.115.1518529505258; Tue, 13 Feb 2018 05:45:05 -0800 (PST) MIME-Version: 1.0 Received: by 10.223.208.197 with HTTP; Tue, 13 Feb 2018 05:44:44 -0800 (PST) In-Reply-To: <20180213133201.kwq4aatpts7nerc2@flea.lan> References: <20180213121414.7000-1-embed3d@gmail.com> <20180213133201.kwq4aatpts7nerc2@flea.lan> From: Chen-Yu Tsai Date: Tue, 13 Feb 2018 21:44:44 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [linux-sunxi] [PATCH v2] rtc: ac100: Fix ac100 determine rate bug To: Maxime Ripard Cc: Philipp Rossak , 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 9:32 PM, Maxime Ripard wrote: > On Tue, Feb 13, 2018 at 01:14:14PM +0100, 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: > > Since when is it there? > >> 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 >> >> Fixes: 04940631b8d2 ("rtc: ac100: Add clk output support") > > Should it be sent to stable? > >> Signed-off-by: Philipp Rossak >> --- >> >> Changes in v2: >> * add tag Fixes: ... to commit message >> * add comment to if statement why we are doing this check >> >> drivers/rtc/rtc-ac100.c | 12 +++++++++++- >> 1 file changed, 11 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/rtc/rtc-ac100.c b/drivers/rtc/rtc-ac100.c >> index 8ff9dc3fe5bf..ba73201d8cc1 100644 >> --- a/drivers/rtc/rtc-ac100.c >> +++ b/drivers/rtc/rtc-ac100.c >> @@ -183,7 +183,17 @@ 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; >> + >> + /* >> + * We purposefully left open the possibility to use the clock >> + * from the codec side but it is not implemented right now. >> + * Thus we need to check if the parent exists. >> + */ >> + if (!parent) >> + continue; >> + >> + prate = clk_hw_get_rate(parent); > > clk_hw_get_num_parents should return the exact number of parents, > which is going to be 1 if you only have one parent, like all DTS seems > to have. > > If not, then it should be explained in the comment and / or fixed > properly. The clock has two parents. One is a fixed clock internally registered by the driver. This is actually an external crystal, and we should probably add a device node and the works for it. The other parent is a clock from the codec side, which we properly declare and reference in the device tree. This clock, though defined, is not implemented in any driver (because we don't have any ATM). This second missing clock is what's causing issues here. The clk core looks for the parent by name, can't find one that is registered, and returns NULL. I guess the comment above is still not clear enough? ChenYu > Maxime > > -- > Maxime Ripard, Bootlin (formerly Free Electrons) > Embedded Linux and Kernel engineering > http://bootlin.com