Received: by 10.223.185.116 with SMTP id b49csp710943wrg; Wed, 14 Feb 2018 05:57:15 -0800 (PST) X-Google-Smtp-Source: AH8x2260wHxTlkEABz8+Nx//ujVJUawYoiKgQTtnf/rccDfuBwEnAUOHceWnp812uX4J5N0qe3/i X-Received: by 10.101.64.67 with SMTP id h3mr4035476pgp.168.1518616635838; Wed, 14 Feb 2018 05:57:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518616635; cv=none; d=google.com; s=arc-20160816; b=woXDjj1gYeCZAbt+1wPS58Hl4U+cudxJ9UwmrmfxdKAkVr7oz+/5Kmi9jVJtp5FLyP d8aZTALuDSLeoyyo9owMkGmHFtj4wgL8B3NhsMWK/PaFRleuh0Ck3+L+Tg7pFjUDQ1sA 2bQz5m7zrJBBtIZSKCQGYMXsE/I4yAhluiGCnIeBqFpbFgJi+4ojBRESu+X6HR1W2VA0 QDuMemI806FXaWidfU4SAVn6DnafEqYsGqPO7/0RFuSIlIwpFCYvgnbSNohXk5qSpmh6 jsX+FrqzZDxTNuc4lXv1OONC0Z097GSkgKKTdlly0R5JZP12+U7TfIrCDGf6E86v6gw8 mTeQ== 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=LAq5pRwMpwFLXXXT7bPnXXMaPyGyZPx7iw11EnSpN/M=; b=HqFuJyOjBadxCokcOKLnwYdyqlBIgKznKUExNUMHMHcNx//zn6VfV6mISO14MFn3a+ xTI1oqTWm63Td7KJGD4ell4/5w0EXGh1zIDw+b/7fGF23gAJh9RbgqseUcqiY1XjtAp5 qkvWVniOyIBpU0fGqz2utNu+y58OcwqIGEc3TEx4A+zHT6p7R+nbEELTzZ6jtOlMm636 JbHM2aLRVknHm/McopyTgzGbk95OX5VTV5n4jjUlPyDqg9p+C58x2miEcMMpa1mjpZuK OCku8qEjIaSzQxRx97cKkCkBiFK5XaeG8ct6u3yJyNfzWI9d54LloWS3vT4mQzK34ZZd aYmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VANAzpaZ; 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 p12-v6si483485pll.191.2018.02.14.05.57.00; Wed, 14 Feb 2018 05:57:15 -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=VANAzpaZ; 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 S1030583AbeBNN4U (ORCPT + 99 others); Wed, 14 Feb 2018 08:56:20 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:52397 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030422AbeBNN4Q (ORCPT ); Wed, 14 Feb 2018 08:56:16 -0500 Received: by mail-wm0-f66.google.com with SMTP id j199so10691830wmj.2; Wed, 14 Feb 2018 05:56:15 -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=LAq5pRwMpwFLXXXT7bPnXXMaPyGyZPx7iw11EnSpN/M=; b=VANAzpaZ0bt9Y8opWqmgZjv+Nmf8kZVIZfcykt4ZQpuHahH59YIN5lfM2VNufj8YqD UmfXRGNULrnOo01E8xYBltB9gDczpwP4JTU6BFj/0YkAr034GELwGOuefeTo5J6G12Xe Jnhm3T76do5n7wpzRo+25j1PdGeGRWhRC/cBzpdjOkEwlpulxzMpyb2cJoUze9bSbJeA MZMQ/8wG0jCcqroh0Az/srf0uLlIJwYViyu5g4uRh4CUHFrAa6AopHtbISiSOhfa18hH asL00AKmM2wGoyaJnoLs3l7zdsykPuL+k5b/xbn7PKRly3BHvJSOFVrn6zXjd7WgYYKo MZHg== 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=LAq5pRwMpwFLXXXT7bPnXXMaPyGyZPx7iw11EnSpN/M=; b=FaZspM8RR4opCuhZTda2LjvHIt3m18p7pzOrJYZANeSmCi1XwCHdaO9rYBRXE3c80X U8jsv79NAC+Z8BuLON44yM8xzsqxUnOXwcKyWerQN53hH9xCo48aV63ojwD1n+zj7OyS HY/QR7pORBuHJhzjlxAncGtUf9KhM3q7Y/nfcbxmVFO44nMkMkv36n2d6rK4aIViTaY4 yzIbUh9C6MJoTMJs+CAXg2O3uP3pJoQ3W2ElN5B/hCrYWXGJ+CnouZhntr/REQPxOKwy EdJCS8IDFKtBKlXNnBx/mHYicc+Ge/4bTmwEISDjq2SPDTLFDJPhFg33DHKyLOogJ9VW J4FQ== X-Gm-Message-State: APf1xPDH9GSi5q4IqzQNdWFR4JfUFUYswmrE0IKx/Ck3fwHszLKD4Lsd kaxltaNrq5jM4bGVOSpKxXgeXA== X-Received: by 10.28.24.193 with SMTP id 184mr4053376wmy.144.1518616574651; Wed, 14 Feb 2018 05:56:14 -0800 (PST) Received: from debian-laptop.fritz.box (p578F04D2.dip0.t-ipconnect.de. [87.143.4.210]) by smtp.gmail.com with ESMTPSA id 62sm14334437wrg.81.2018.02.14.05.56.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Feb 2018 05:56:13 -0800 (PST) From: Philipp Rossak To: wens@csie.org, a.zummo@towertech.it, alexandre.belloni@bootlin.com, maxime.ripard@bootlin.com Cc: linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, linux-rtc@vger.kernel.org Subject: [PATCH v3] rtc: ac100: Fix ac100 determine rate bug Date: Wed, 14 Feb 2018 14:56:12 +0100 Message-Id: <20180214135612.21356-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. The bug is there since v4.16-rc1 and appeared after the clk branch was merged. 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 v3: * add information when the bug appeared * make the comment more clear 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 | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/rtc/rtc-ac100.c b/drivers/rtc/rtc-ac100.c index 8ff9dc3fe5bf..2412aa2e8399 100644 --- a/drivers/rtc/rtc-ac100.c +++ b/drivers/rtc/rtc-ac100.c @@ -183,7 +183,24 @@ 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; + + /* + * The clock has two parents, one is a fixed clock which is + * internally registered by the ac100 driver. The other parent + * is a clock from the codec side of the chip, which we + * properly declare and reference in the devicetree and is + * not implemented in any driver right now. + * If the clock core looks for the parent of that second + * missing clock, it can't one that is registered and + * returns NULL. + * Thus we need to check if the parent exists before + * we get the parent rate. + */ + if (!parent) + continue; + + prate = clk_hw_get_rate(parent); tmp = ac100_clkout_round_rate(hw, req->rate, prate); -- 2.11.0