Received: by 10.223.185.116 with SMTP id b49csp3556049wrg; Tue, 13 Feb 2018 04:16:18 -0800 (PST) X-Google-Smtp-Source: AH8x227++FSGh3iX1yhu3lt/AOd5Efd9Gv5qWJnmsVBTMUfAfyjVrcZfUFBiV1RafD2Mbu/xOfSE X-Received: by 2002:a17:902:128c:: with SMTP id g12-v6mr954639pla.85.1518524178522; Tue, 13 Feb 2018 04:16:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518524178; cv=none; d=google.com; s=arc-20160816; b=p4zkpeoX5LYF8plLWh707JdtpPDB6HlEGNTB+cVCTwdivpywMsuNFSAPAa+7t0Bin1 MVhc5WentziJMaLm9u7rLr6JVcVPoTNBI5fesl/Su6X6nrIhsJUMqGOtYIOPmZrqXOq0 k8/sVPopC+buZojzewt3ujyl6CdMSlyZd11fHVYLDByVYHIH6M3F08GoDT+LWEESnKQO RgvuYtQXRzAa9y/+ketoQbDH7ZcIRwAZxyOasITP0SitseBndsCXC9JqHRtiLMTJ/0qW eJTM4qGSifpopEYZ24rUTP0XZPACEV2hag8q6U4I5JDSoSPd1Pz/o/lxnEatOPmr/+5C dvKA== 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=HSFB8tuq2cjQLo6wvCq5hFjlxOopyg6xeERwUwl5fhg=; b=lOhED7a52zlTl5GLHkUcdKI5bXdr3iwAJC8xmMgaxhuUN6kPEfEAsOvGEjQavofE3o F20/PnZZFLYOjOiFD7dBM2J7JrgDJHsWl692Gh/Fg7z4EeNkumaP7rP7YdTkbdURQPqo 3Aq19W5ROFS8opUctbWE/pMp4E16FUf/2VRQcoTbYI95h2rLVJHibTmQiceyvRO+TA8+ 3oItSPuJtrSz4yl7p/ZPzaoGfa441FQ1C21I16L2NX6VckAV+815uwIPUNMW+In3qWac 6Czp8JytS58+iun6t1p40lpRMqEgReTNt7zZLU9Mu2yxqWB8FCO/YGDDrevj3YL6PCtY gqpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uxOr24o3; 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 y20si4992686pgv.723.2018.02.13.04.16.03; Tue, 13 Feb 2018 04:16:18 -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=uxOr24o3; 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 S935072AbeBMMOT (ORCPT + 99 others); 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-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-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 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); -- 2.11.0