Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2014013imm; Thu, 24 May 2018 04:31:52 -0700 (PDT) X-Google-Smtp-Source: AB8JxZphSm9MLrQgVgy60c0gjdPvII33xl4upxQdxphrMarFMuwpYZsxq18ynMAUdzwRC05ZJLEC X-Received: by 2002:a65:47c8:: with SMTP id f8-v6mr5573842pgs.430.1527161512041; Thu, 24 May 2018 04:31:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527161512; cv=none; d=google.com; s=arc-20160816; b=XbiKxa4mWcyPUJoV9UtyxOH/3MdeaBmwccJcWmk69alSewtNMLHfZRS3C6W2/0WxTv v2JG6OlN+gIsLbHExHH//unlxSTgONogpRpQ5wuHhUe7ZWS0kqPDwGEu1/gqNj+XfUPY XrJvUUIKYzQ+QTrzxzR34dwgSvlb9k7F06rO6uQrk6sMMv9ncIyD/gdRBHKq6/oXItT0 Q5u/Qv+Wz+Cb0+LiX8g/EZ7NU3D5vGsSxGDcF+ens/3qnP5F368ke9/bRSwW3p8LzqpJ h3uuhMd3fHJjxYp4nhVCFqmtdvgWBQgAp5dtP1HIOKGAyQVG+DqaDIeTJXdZULv01ACA LStg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=TfkfKXQujcCCvS78BszO9AgNXxkBP8cooWsOtUbAJSQ=; b=0bpzOFHCJKY5qAOKvkxGnYmilN6asa1LIQx0yIgaHbbtMqg5UVypRIK9csrDes2qRT yp78dppovEtOBuom13U7tIeR2OtBcYnG9hdqkRHbM0DHrdhE7I+cGK7lVKwdE04FwZ2f ChdikHTxSIWBpCTUqIvJpwLT66zsQCmYQDQBXJIT2dUl6rFPtIwtTr3E3GXBx6Lm6otA y/wc2JFUP/RifjGu4aeLBGw2ODJC6vDvFotYi+AG1D1y18HVSuHXzPFJo+suknupv2GW nb5+YqwCkRXnwisLa/VPmnPKpHp1ENLjay0RMQYVnz85ynUoOWuccKXxhJ+EwDutLjqU jfyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FKs5Vn7/; 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 j19-v6si20059670pll.518.2018.05.24.04.31.37; Thu, 24 May 2018 04:31:52 -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=@kernel.org header.s=default header.b=FKs5Vn7/; 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 S968960AbeEXLbE (ORCPT + 99 others); Thu, 24 May 2018 07:31:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:44692 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967473AbeEXJvF (ORCPT ); Thu, 24 May 2018 05:51:05 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C3FA920891; Thu, 24 May 2018 09:51:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155465; bh=ZPSfkNV8bHrCnHPrOTVjHdcs3jkunBncePTC4oHbE98=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FKs5Vn7/Uq5DPbEOMh4u3d9MM9wR9FV1G5T2o6/SjPEiqtgdz1/qZxw5W5NnZH3NF 1MkRTQV9AhmQNe6KWdcZasgIHcp4cIip/hZsjB9j0dC/ZqLpgDrOqzU3j3JNhlvhR2 4dwZJ97OyogDmZZC7KCKOF0Qm10Gt9KsuujLUFy4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bryan ODonoghue , Shawn Guo , Alexandre Belloni , Sasha Levin Subject: [PATCH 4.9 94/96] rtc: snvs: Fix usage of snvs_rtc_enable Date: Thu, 24 May 2018 11:39:17 +0200 Message-Id: <20180524093611.297842473@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093605.602125311@linuxfoundation.org> References: <20180524093605.602125311@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 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 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bryan O'Donoghue [ Upstream commit 1485991c024603b2fb4ae77beb7a0d741128a48e ] 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 Acked-by: Shawn Guo Signed-off-by: Alexandre Belloni Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/rtc/rtc-snvs.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) --- a/drivers/rtc/rtc-snvs.c +++ b/drivers/rtc/rtc-snvs.c @@ -132,20 +132,23 @@ static int snvs_rtc_set_time(struct devi { 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) @@ -287,7 +290,11 @@ static int snvs_rtc_probe(struct platfor 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);