From patchwork Tue Feb 13 12:14:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Rossak X-Patchwork-Id: 872794 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-rtc-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="uxOr24o3"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zghKl6QGFz9sNr for ; Tue, 13 Feb 2018 23:14:19 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934951AbeBMMOT (ORCPT ); Tue, 13 Feb 2018 07:14:19 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:41667 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934938AbeBMMOS (ORCPT ); Tue, 13 Feb 2018 07:14:18 -0500 Received: by mail-wr0-f194.google.com with SMTP id q11so6619785wre.8; Tue, 13 Feb 2018 04:14:17 -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=HSFB8tuq2cjQLo6wvCq5hFjlxOopyg6xeERwUwl5fhg=; b=uxOr24o3udwBpqoK7R6RcWuIXJ+udiK5OhHO8w+Ux0Yv9WgXJeC3DQY5HpOJ2o2X4z xgXwKdkrGiZLMTeHY8mDC9WpFPjUF0NyOb7dRoM2sV2hWfFK0sXK5IMAfcE8wpSBebB9 QLo7Y5mPZZWUsm3tzDUMvy/vGNPEZ4ufeUBo1q/+Csi7Cr56gN8K258a4UbONml5xXE9 elm6HcOTNRKdYTBu5XhylEG6HdZ0OkB7IhReUecndDIsG6aWVt0GfK0JG/DuLNaMUkCp PR35f72Y46t7AxU9n7kYgaF3MvOchGd2jZ20uX3NFNsZ3CDsnTlxizsIdt+rteFhgv74 1B6w== 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=HSFB8tuq2cjQLo6wvCq5hFjlxOopyg6xeERwUwl5fhg=; b=iir6WGkIcQ/qwkoodb131/srjp2oAfk7axSuGR9p8AIlAP0HsQxjRjeYOgkmzVMZQS 2YkUMVdSqEI4ggKdnzYW0QBg4/2hN1iLYZnzqT4tpWtV8d4NrgT6k9PtrqCWsjZPUQzC BkhtiQYrUgvBJNkP5DMr500qGA93X+/RGkzYvVp/L72nenc4SEbYK0w7awcMEsfzWoZy HQXDXx7FHuYSeG9ww5VQgMviHPDu55i2kJFWZfas+kC2LI1KhkK6s6OiSv4lgEsESiuY qLcX8zSxDcaoEdhtIlA/RxchUCYdW0I2K/HJzg21A3I6HpHqeNUoSNIEC1bpeJ+G08fm hV4Q== X-Gm-Message-State: APf1xPCgBhzCxMV4woA9nM/ippt0S1CvtJdFcfoupn9gCWgzZlr9aAhO kLtIm9d4yF5QpB8YWgP56Cs= X-Google-Smtp-Source: AH8x2259ui+YEg+U3fsfR4rg3GdkX62U52178pBRJCXY1oXhZ1Tv4225yKgtACv2WgYPnHmBD/XGLg== X-Received: by 10.223.161.27 with SMTP id o27mr1027616wro.97.1518524056627; Tue, 13 Feb 2018 04:14:16 -0800 (PST) Received: from debian-laptop.fritz.box (p578F04D2.dip0.t-ipconnect.de. [87.143.4.210]) by smtp.gmail.com with ESMTPSA id p35sm5435605wrb.34.2018.02.13.04.14.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Feb 2018 04:14:15 -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 v2] rtc: ac100: Fix ac100 determine rate bug Date: Tue, 13 Feb 2018 13:14:14 +0100 Message-Id: <20180213121414.7000-1-embed3d@gmail.com> X-Mailer: git-send-email 2.11.0 Sender: linux-rtc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rtc@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 Fixes: 04940631b8d2 ("rtc: ac100: Add clk output support") 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); tmp = ac100_clkout_round_rate(hw, req->rate, prate);