Received: by 10.213.65.68 with SMTP id h4csp764585imn; Wed, 28 Mar 2018 12:16:20 -0700 (PDT) X-Google-Smtp-Source: AIpwx481YoHy1HrGnkJv2mug3QJr9q5OmmTtRquYuFg27BCOEXlIJKK/mOi2B1JQf8orLsjQ28Zg X-Received: by 10.99.111.140 with SMTP id k134mr3433247pgc.11.1522264580916; Wed, 28 Mar 2018 12:16:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522264580; cv=none; d=google.com; s=arc-20160816; b=o/A1JtPn2bCTa5JgdNP1L1gW6LF+n0HFjD5j++t9QTuHKwoJ68uskLU2RlYF0vH6hv 5JKhGiDFCFsNNNXN2iq5/WfT2yalCbHdNhqHS1M7Yvwf+ZNtUZ/6RGWBxGyPn9octT8C e4Ky+5NgLllPet1hhaATL1loK/OoJyB5s8NwR5fPty/tX/10WqllGawy4CHjk0PQpZh+ kc8e8FrqlGaNeZ7FwEsp0IXNy9Xk3i/QNb9Rq2Z+PCm9M9fHWpXQXDv05wX78BT6oJPP ZpHXgdRJKH/4UJQGgZs325Yz70W27xQDdnYKQC1fuRzTQrujf0RtoVUiOdxdPFHzA4V2 2zQg== 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=T5JLS+vVSh05587FLkWOYbFy9vCfN/6ANbj3XVe3Tw8=; b=iNFb3VDg1//X8wwU+D6/DV7oLhWfhfDGkg1HPWdGpMKcK1hkVcx4GG01nSoEysc877 zd+X1gYDpR0jfYVzdBYkAkWLFvAIdWZ44VRYZFYLm7b/T2Y7DZZdJ684PMXN5JbU6983 KcNQf2Vv9Fd5Y4O9ANV/YGpcKvCsFFy3V8wV/cecgw6IJKGVeQ/6FrPPCoe0UhKw+Wvx 09zL80L0/msTzNC6waaUsNErGsRHTOreFWJ9EBOtmOiQHAgB3flfR3nEUTj7m2Tg8UKr ywBVik+QrpSaY/l6XRZ7wIUGrJfwj9uYlxzrz97oV3QXA/PqxRz2g8q6G3g6uPL3DlHo Lrtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nexus-software-ie.20150623.gappssmtp.com header.s=20150623 header.b=Un1m8HKM; 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 v12-v6si4244070plk.615.2018.03.28.12.16.06; Wed, 28 Mar 2018 12:16:20 -0700 (PDT) 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=@nexus-software-ie.20150623.gappssmtp.com header.s=20150623 header.b=Un1m8HKM; 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 S1753915AbeC1TOQ (ORCPT + 99 others); Wed, 28 Mar 2018 15:14:16 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:51554 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753831AbeC1TOO (ORCPT ); Wed, 28 Mar 2018 15:14:14 -0400 Received: by mail-wm0-f66.google.com with SMTP id v21so6867408wmc.1 for ; Wed, 28 Mar 2018 12:14:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nexus-software-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=T5JLS+vVSh05587FLkWOYbFy9vCfN/6ANbj3XVe3Tw8=; b=Un1m8HKMn9krpzLIvrkGQvGmkaNjSzm9H5qrl2ARsDAw6jz5LZiJwhB64RP/cXnBx5 ktIcj833eHooV1tEc0tVwW+AQWPmYtW0DtIieGYFt/qMZvh7qkBDzbTrVJJ/DLKthxHg GWRcgbnaXGqCxhPpmeWxX2C7vhBLQf2XuouuOsvTX/Ru5IJ7UUUX/9sQovnfuh/RdTIS RxQ8KCdKWtqyOnrhRfjDbHMinSsUrIXQ72FC47P0wvABH9gHYAeBK0tqftg0wB7TZ6k6 qwjSv3vEFfnnbgjQE5g7xQJyZ/b3ZENyy2KAkqB5eAj5phnwslf1UeL+qNC/vK0lQxxX 9RvQ== 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=T5JLS+vVSh05587FLkWOYbFy9vCfN/6ANbj3XVe3Tw8=; b=UKlYSOt2sOe7jvfVcGu5tsYBdmDeAX+UgvhgD6dH1OUFr0acwYOJw9XDuPxXwNQdID k7zFKwEA5BXTKjFDIhZFIwDyoPdJ3z3S3RD1sZqTxwckBhufrseNvAaaC6qdR5N63H0H GMCQJZEmGOkD5gXTxadaBgIGRPKDal92+0lRS1Hg+kHsYfInOk9jb2xPdsAoSloaoYc/ QDu/xnAWoFK1aS/IKOEe4MqZcTBFjCpgvnax9xDwtfbGuOf7mu8wVQ2LDcO2fw0LMejN hDR0RmxGBOn067I7khuRINTgDw/ng1Mt14rKqJG6pJRKtyBht7weNVKfswhczBFUN3VJ lK7g== X-Gm-Message-State: AElRT7HUocJedV0LisfQrNpx0mZfMKBgNmQbMzxTXw/8GdgXuzrxGrlN 3vKY4nRoqsTvfCOJp9XepOryyQ== X-Received: by 10.80.165.29 with SMTP id y29mr4574858edb.261.1522264452928; Wed, 28 Mar 2018 12:14:12 -0700 (PDT) Received: from localhost.localdomain ([109.255.42.2]) by smtp.gmail.com with ESMTPSA id g24sm3175613edj.87.2018.03.28.12.14.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Mar 2018 12:14:12 -0700 (PDT) From: Bryan O'Donoghue To: alexandre.belloni@free-electrons.com, linux-kernel@vger.kernel.org Cc: Bryan O'Donoghue , a.zummo@towertech.it, Pan Bian , Guy Shapiro , Stefan Agner , Frank Li , Shawn Guo , linux-rtc@vger.kernel.org, "# v3 . 16+" Subject: [RESEND] [PATCH] rtc: snvs: Fix usage of snvs_rtc_enable Date: Wed, 28 Mar 2018 20:14:05 +0100 Message-Id: <1522264445-2398-1-git-send-email-pure.logic@nexus-software.ie> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org commit 179a502f8c46 ("rtc: snvs: add Freescale rtc-snvs driver") introduces the SNVS RTC driver with a function snvs_rtc_enable(). snvs_rtc_enable() can return an error on the enable path however this driver does not currently trap that failure on the probe() path and consequently if enabling the RTC fails we encounter a later error spinning forever in rtc_write_sync_lp(). [ 36.093481] [] (__irq_svc) from [] (_raw_spin_unlock_irqrestore+0x34/0x44) [ 36.102122] [] (_raw_spin_unlock_irqrestore) from [] (regmap_read+0x4c/0x5c) [ 36.110938] [] (regmap_read) from [] (rtc_write_sync_lp+0x6c/0x98) [ 36.118881] [] (rtc_write_sync_lp) from [] (snvs_rtc_alarm_irq_enable+0x40/0x4c) [ 36.128041] [] (snvs_rtc_alarm_irq_enable) from [] (rtc_timer_do_work+0xd8/0x1a8) [ 36.137291] [] (rtc_timer_do_work) from [] (process_one_work+0x28c/0x76c) [ 36.145840] [] (process_one_work) from [] (worker_thread+0x34/0x58c) [ 36.153961] [] (worker_thread) from [] (kthread+0x138/0x150) [ 36.161388] [] (kthread) from [] (ret_from_fork+0x14/0x20) [ 36.168635] rcu_sched kthread starved for 2602 jiffies! g496 c495 f0x2 RCU_GP_WAIT_FQS(3) ->state=0x0 ->cpu=0 [ 36.178564] rcu_sched R running task 0 8 2 0x00000000 [ 36.185664] [] (__schedule) from [] (schedule+0x3c/0xa0) [ 36.192739] [] (schedule) from [] (schedule_timeout+0x78/0x4e0) [ 36.200422] [] (schedule_timeout) from [] (rcu_gp_kthread+0x648/0x1864) [ 36.208800] [] (rcu_gp_kthread) from [] (kthread+0x138/0x150) [ 36.216309] [] (kthread) from [] (ret_from_fork+0x14/0x20) This patch fixes by parsing the result of rtc_write_sync_lp() and propagating both in the probe and elsewhere. If the RTC doesn't start we don't proceed loading the driver and don't get into this loop mess later on. Fixes: 179a502f8c46 ("rtc: snvs: add Freescale rtc-snvs driver") Signed-off-by: Bryan O'Donoghue Cc: a.zummo@towertech.it Cc: alexandre.belloni@free-electrons.com Cc: Pan Bian Cc: Guy Shapiro Cc: Stefan Agner Cc: Frank Li Cc: Shawn Guo Cc: linux-rtc@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: # v3.16+ --- drivers/rtc/rtc-snvs.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/rtc/rtc-snvs.c b/drivers/rtc/rtc-snvs.c index d8ef9e0..9af591d 100644 --- a/drivers/rtc/rtc-snvs.c +++ b/drivers/rtc/rtc-snvs.c @@ -132,20 +132,23 @@ static int snvs_rtc_set_time(struct device *dev, struct rtc_time *tm) { struct snvs_rtc_data *data = dev_get_drvdata(dev); unsigned long time; + int ret; rtc_tm_to_time(tm, &time); /* Disable RTC first */ - snvs_rtc_enable(data, false); + ret = snvs_rtc_enable(data, false); + if (ret) + return ret; /* Write 32-bit time to 47-bit timer, leaving 15 LSBs blank */ regmap_write(data->regmap, data->offset + SNVS_LPSRTCLR, time << CNTR_TO_SECS_SH); regmap_write(data->regmap, data->offset + SNVS_LPSRTCMR, time >> (32 - CNTR_TO_SECS_SH)); /* Enable RTC again */ - snvs_rtc_enable(data, true); + ret = snvs_rtc_enable(data, true); - return 0; + return ret; } static int snvs_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) @@ -288,7 +291,11 @@ static int snvs_rtc_probe(struct platform_device *pdev) regmap_write(data->regmap, data->offset + SNVS_LPSR, 0xffffffff); /* Enable RTC */ - snvs_rtc_enable(data, true); + ret = snvs_rtc_enable(data, true); + if (ret) { + dev_err(&pdev->dev, "failed to enable rtc %d\n", ret); + goto error_rtc_device_register; + } device_init_wakeup(&pdev->dev, true); -- 2.7.4