From patchwork Tue Nov 17 07:37:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stewart Smith X-Patchwork-Id: 545403 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B624514144D for ; Tue, 17 Nov 2015 18:37:30 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 9E7B01A039E for ; Tue, 17 Nov 2015 18:37:30 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id E08F11A0352 for ; Tue, 17 Nov 2015 18:37:27 +1100 (AEDT) Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 17 Nov 2015 00:37:25 -0700 Received: from d03dlp03.boulder.ibm.com (9.17.202.179) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 17 Nov 2015 00:37:23 -0700 X-IBM-Helo: d03dlp03.boulder.ibm.com X-IBM-MailFrom: stewart@linux.vnet.ibm.com X-IBM-RcptTo: skiboot@lists.ozlabs.org Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id 3AEB419D8026 for ; Tue, 17 Nov 2015 00:25:30 -0700 (MST) Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id tAH7Zpfl393606 for ; Tue, 17 Nov 2015 00:35:51 -0700 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id tAH7bMnS003061 for ; Tue, 17 Nov 2015 00:37:22 -0700 Received: from oc8180480414.ibm.com ([9.83.5.151]) by d03av04.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with SMTP id tAH7bCrG002603; Tue, 17 Nov 2015 00:37:21 -0700 Received: by oc8180480414.ibm.com (Postfix, from userid 500) id 7854A3D27; Tue, 17 Nov 2015 18:37:11 +1100 (AEDT) From: Stewart Smith To: =?utf-8?Q?C=C3=A9dric?= Le Goater , skiboot@lists.ozlabs.org In-Reply-To: <1444916177-23904-1-git-send-email-clg@fr.ibm.com> References: <1444916177-23904-1-git-send-email-clg@fr.ibm.com> User-Agent: Notmuch/0.18+16~gec02089 (http://notmuchmail.org) Emacs/23.1.1 (x86_64-redhat-linux-gnu) Date: Tue, 17 Nov 2015 18:37:11 +1100 Message-ID: MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15111707-0021-0000-0000-000014916322 Subject: Re: [Skiboot] [PATCH v2] fsp/rtc: ignore TOD_RESET status X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Cédric Le Goater writes: > When the timeofday is considered INVALID by the FSP : > > System time is INVALID: 2015/10/14 20:13:53.305261 > > it will return a FSP_STATUS_TOD_RESET (0xA9) to any TOD read > request done by OPAL. This status stays invalid until a write > request is done. > > This is a problem for the kernel as the OPAL_RTC_READ calls > are done in loops. The consequence is that the skiroot kernel > hangs quite early in the boot looping on : > > [9163642153,3] RTC TOD in invalid state > [9186642687,3] RTC TOD in invalid state > [9204379669,3] RTC TOD in invalid state > [9226043775,3] RTC TOD in invalid state > [9240944791,3] RTC TOD in invalid state > > with other unpleasant consequences following. The system is > left unusable and it is difficult for the user to know what > is happening. > > This patch modifies the behavior of the read request when an > invalid status is received. It simply ignores it and considers > the read as successful. > > This breaks the loops done in the kernel on OPAL_RTC_READ calls > and lets the boot complete. The status is expected to become > valid after the first TOD write request. The loop in question is likely drivers/rtc/rtc-opal.c: static int opal_get_rtc_time(struct device *dev, struct rtc_time *tm) { ... while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) { rc = opal_rtc_read(&__y_m_d, &__h_m_s_ms); if (rc == OPAL_BUSY_EVENT) opal_poll_events(NULL); else msleep(10); } if (rc != OPAL_SUCCESS) return -EIO; ... } I don't think this is quite the right way to fix it though. I think this was introduced by 6cf8b663e7d7cb1e827b6d9c90e694ea583f6f87 where I refactored fsp-rtc to use a state machine over holding locks (and then we'd have problems with pollers). So what I think is the right fix is: This should mean we return OPAL_INTERNAL_ERROR on TOD error from FSP which will adequately break out of the loop and return EIO to whoverer was asking for RTC value from the kernel. does that look right? Do you have any way to make the FSP give us an invalid time? diff --git a/hw/fsp/fsp-rtc.c b/hw/fsp/fsp-rtc.c index 6b982179d542..df0f67940372 100644 --- a/hw/fsp/fsp-rtc.c +++ b/hw/fsp/fsp-rtc.c @@ -173,19 +173,16 @@ static void fsp_rtc_process_read(struct fsp_msg *read_resp) log_simple_error(&e_info(OPAL_RC_RTC_TOD), "RTC TOD in invalid state\n"); rtc_tod_state = RTC_TOD_INVALID; - rtc_read_request_state = RTC_READ_NO_REQUEST; break; case FSP_STATUS_TOD_PERMANENT_ERROR: log_simple_error(&e_info(OPAL_RC_RTC_TOD), "RTC TOD in permanent error state\n"); rtc_tod_state = RTC_TOD_PERMANENT_ERROR; - rtc_read_request_state = RTC_READ_NO_REQUEST; break; case FSP_STATUS_SUCCESS: /* Save the read RTC value in our cache */ - rtc_read_request_state = RTC_READ_REQUEST_AVAILABLE; rtc_tod_state = RTC_TOD_VALID; datetime_to_tm(read_resp->data.words[0], (u64) read_resp->data.words[1] << 32, &tm); @@ -199,8 +196,8 @@ static void fsp_rtc_process_read(struct fsp_msg *read_resp) log_simple_error(&e_info(OPAL_RC_RTC_TOD), "RTC TOD read failed: %d\n", val); rtc_tod_state = RTC_TOD_INVALID; - rtc_read_request_state = RTC_READ_NO_REQUEST; } + rtc_read_request_state = RTC_READ_REQUEST_AVAILABLE; }