Received: by 10.192.165.156 with SMTP id m28csp1119264imm; Wed, 11 Apr 2018 12:48:28 -0700 (PDT) X-Google-Smtp-Source: AIpwx49sY4474HjdfRXWh3gSKw+YOI/TvVmJxNHTeBGuYXvQn6zTT/03sE/FkI4wSz2IqDchryzl X-Received: by 2002:a17:902:28c4:: with SMTP id f62-v6mr6495090plb.19.1523476108409; Wed, 11 Apr 2018 12:48:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523476108; cv=none; d=google.com; s=arc-20160816; b=I4HVWZCEDB5LVou5VAhGZgoYA7yfetPzQfM6aiDnoRJJpPuThl9HAlEuzIF+MVOTkT ZXEUJyqMs3WP1C8aJRfkkVHuJAWsmlGXKPwgL9DYRUYBgW6qOlAkCBLfrIc7gnsvuhxG +R6S4Nq4/gmtd21iXTIdCDS4mDcnfihZdcfe5QRvPNXF5UKQqYD1illp8rQej19EWvoe kSQph+d2yntlYHOhPVqDnLmqIY4YyYfoMku6i8NHZd3sZHEyREhAiS07ZoKh2TEkmrW9 Q3XUPiKA5++lNmhT0mWCwMtsqdUke8mEEHC//i9VhWxMWCuU7b+htq5Y29SBeC6yOobx qF0Q== 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 :arc-authentication-results; bh=kE32gBLuuFXGBX3/kKNMDKKiiy8th5nR6oZBdiuBI6o=; b=VAil0M/rMms2Nk45xMC7pclUOmCcSytD8b1aujy+wtVD3NJGHgvO8MKLYde2Rj4R2+ +/Z9vI/lWBHxsrvAOFIlCbLZ5jrzZDGTZedbcYiNAfvyRqluqqacCK6D1791eKB4oyzs flsqVBt1qi/vE7DWCt5nCz/rGCKC14D6ACnzQ89S5joI2C8vyymTdY6T/rBFSRBOqWL0 Z109xW6B6yzMxs98zz7uBreM/JyXf0q5/1KjAz8IM/H18bp3ac/nPL0zPMMcsiVAS081 XF4FoyNydzPoOjgF+hj965AGINZ7OaOFN/TcitJM1bKhHj5MG5LgYEFjZ2tm9DoDkeXe i/bA== ARC-Authentication-Results: i=1; mx.google.com; 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 g61-v6si1678517plb.686.2018.04.11.12.47.51; Wed, 11 Apr 2018 12:48:28 -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; 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 S1756625AbeDKTAE (ORCPT + 99 others); Wed, 11 Apr 2018 15:00:04 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37588 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752973AbeDKTAB (ORCPT ); Wed, 11 Apr 2018 15:00:01 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id EA909CDE; Wed, 11 Apr 2018 19:00:00 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vaibhav Jain , Steve Best , Alexandre Belloni , Sasha Levin Subject: [PATCH 4.9 162/310] rtc: opal: Handle disabled TPO in opal_get_tpo_time() Date: Wed, 11 Apr 2018 20:35:01 +0200 Message-Id: <20180411183629.356488295@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183622.305902791@linuxfoundation.org> References: <20180411183622.305902791@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: Vaibhav Jain [ Upstream commit 6dc1cf6f932bb0ea4d8f5e913a0a401ecacd2f03 ] On PowerNV platform when Timed-Power-On(TPO) is disabled, read of stored TPO yields value with all date components set to '0' inside opal_get_tpo_time(). The function opal_to_tm() then converts it to an offset from year 1900 yielding alarm-time == "1900-00-01 00:00:00". This causes problems with __rtc_read_alarm() that expecting an offset from "1970-00-01 00:00:00" and returned alarm-time results in a -ve value for time64_t. Which ultimately results in this error reported in kernel logs with a seemingly garbage value: "rtc rtc0: invalid alarm value: -2-1--1041528741 2005511117:71582844:32" We fix this by explicitly handling the case of all alarm date-time components being '0' inside opal_get_tpo_time() and returning -ENOENT in such a case. This signals generic rtc that no alarm is set and it bails out from the alarm initialization flow without reporting the above error. Signed-off-by: Vaibhav Jain Reported-by: Steve Best Signed-off-by: Alexandre Belloni Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/rtc/rtc-opal.c | 10 ++++++++++ 1 file changed, 10 insertions(+) --- a/drivers/rtc/rtc-opal.c +++ b/drivers/rtc/rtc-opal.c @@ -150,6 +150,16 @@ static int opal_get_tpo_time(struct devi y_m_d = be32_to_cpu(__y_m_d); h_m_s_ms = ((u64)be32_to_cpu(__h_m) << 32); + + /* check if no alarm is set */ + if (y_m_d == 0 && h_m_s_ms == 0) { + pr_debug("No alarm is set\n"); + rc = -ENOENT; + goto exit; + } else { + pr_debug("Alarm set to %x %llx\n", y_m_d, h_m_s_ms); + } + opal_to_tm(y_m_d, h_m_s_ms, &alarm->time); exit: