Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2623603pxb; Sun, 17 Oct 2021 20:48:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMGRjyTeFlYhYX9huvmkV29geI6J9wIZPabgpCYpt6PPTkM5v79VZ+5z4XZXkskrbFO2wT X-Received: by 2002:a17:902:654d:b0:13e:a097:208e with SMTP id d13-20020a170902654d00b0013ea097208emr24719802pln.31.1634528851820; Sun, 17 Oct 2021 20:47:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634528851; cv=none; d=google.com; s=arc-20160816; b=RK4aobYvgCv0QXuhvewBaXreQoy+xUk+5KtsMLDWJDlZ18odvXTExLdRzCF9IhBYZf 9lDxNRXLCH2+qFmBbPluK92nJ3XQzOzlFbATc8DBPC0csf2IA7ufsiuosP9yKSzf7DkQ 1ugBtyE14I3NZiOY9GhFrjXX0OjipWD417zP/LmB6cQGNyMJgxcxByCfXB9qIkQ7oeYY WevX6xqV+pAArFXjfF27TRBnQ839XPmOncgb99zJrqhqd5z+haKFUHuIJrBc40ZVd4+Y BYA6GiknYrxI8g34KvoUSCu5DjmcRkPdbG8VWG6Embv48u+mcT+HGM48SkF6YdkhvATE FsfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Fhf7rMoQ6L7izsQlV/8yihcnza8EcnJtUeazGGPlKI8=; b=ROXWzoBdvJ59ikbJDQu0Jzy24wU8X57pP9xxhUaqdTxwB5331OwRqf0YGPBlaBfMTB t06I1zYBjIEuI4TjwJOeV/xdl28wjr+Us3WK63E/AP0q30wY9P1o5CcL8Sxn7NrQZQ7D Li0opi7Sy61lOtlyeCg2/Q5pQdeagD82jJxIt1hCbDtSr33UBlblbH7B4YeEHVDavl8K aMGCErFLxKF3l17dbMc3GcWsyD2/3cVXyWMGtOn3QXuosF9DGx3lTffqaD9kVXke3soS o8FEy0r0y0weQc/l1IOgEXdnNOLzSI7xjQqY8dnByoVIEkHR8rx6oVdPMl/XPq8R2PVv venQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@o2.pl header.s=1024a header.b=jPQd71pc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=o2.pl Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n10si3403156pgj.589.2021.10.17.20.47.19; Sun, 17 Oct 2021 20:47:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@o2.pl header.s=1024a header.b=jPQd71pc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=o2.pl Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344566AbhJQTmL (ORCPT + 98 others); Sun, 17 Oct 2021 15:42:11 -0400 Received: from mx-out.tlen.pl ([193.222.135.142]:15145 "EHLO mx-out.tlen.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344544AbhJQTmK (ORCPT ); Sun, 17 Oct 2021 15:42:10 -0400 Received: (wp-smtpd smtp.tlen.pl 10169 invoked from network); 17 Oct 2021 21:39:58 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=o2.pl; s=1024a; t=1634499598; bh=Fhf7rMoQ6L7izsQlV/8yihcnza8EcnJtUeazGGPlKI8=; h=From:To:Cc:Subject; b=jPQd71pcOiNgR4AWNjo++ZzSVj8wS5QxkIKp71m7Mw/qXrU/bdpGhEXyW+Xn5nK42 unJDXnMCbICL247oN17LFJ3MKiCDfHUmT+5/b7TgMXMmaBX743fb6bUaLfOqeQABnZ CqkTH71bMoP2+FMQVzBzlTkODIobQR+X6ZxSgpo0= Received: from aaet142.neoplus.adsl.tpnet.pl (HELO localhost.localdomain) (mat.jonczyk@o2.pl@[83.4.123.142]) (envelope-sender ) by smtp.tlen.pl (WP-SMTPD) with SMTP for ; 17 Oct 2021 21:39:58 +0200 From: =?UTF-8?q?Mateusz=20Jo=C5=84czyk?= To: linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org Cc: =?UTF-8?q?Mateusz=20Jo=C5=84czyk?= , Alessandro Zummo , Alexandre Belloni , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" Subject: [PATCH RESEND 4/6] rtc-mc146818-lib: reduce RTC_UIP polling period Date: Sun, 17 Oct 2021 21:39:25 +0200 Message-Id: <20211017193927.277409-5-mat.jonczyk@o2.pl> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211017193927.277409-1-mat.jonczyk@o2.pl> References: <20211017193927.277409-1-mat.jonczyk@o2.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-WP-MailID: 7f7b814cec7a0b15916f19c47cf86d36 X-WP-AV: skaner antywirusowy Poczty o2 X-WP-SPAM: NO 0000000 [gTM0] Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A shorter period makes mc146818_get_time() more similar to mach_get_cmos_time() in arch/x86/kernel/rtc.c, which performs the same function, but is busy waiting for the RTC_UIP bit to clear. Waiting 1ms every time is not necessary, for example on some AMD boxes the RTC_UIP bit is documented as being high for around 270 microseconds in some cases [1], which agreed with experiments on an SB710 southbridge. So 100us seems optimal. [1] AMD SB700/710/750 Register Reference Guide, page 307, https://developer.amd.com/wordpress/media/2012/10/43009_sb7xx_rrg_pub_1.00.pdf "SB700 A12: The UIP high pulse is 270 μS Typical when SS on SRC clock is OFF and 100μ min when SRC SS is ON." [sic] Signed-off-by: Mateusz Jończyk Cc: Alessandro Zummo Cc: Alexandre Belloni Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: x86@kernel.org Cc: "H. Peter Anvin" --- drivers/rtc/rtc-mc146818-lib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/rtc/rtc-mc146818-lib.c b/drivers/rtc/rtc-mc146818-lib.c index 9175e11baf26..d1c42b0ef662 100644 --- a/drivers/rtc/rtc-mc146818-lib.c +++ b/drivers/rtc/rtc-mc146818-lib.c @@ -45,7 +45,7 @@ unsigned int mc146818_get_time(struct rtc_time *time) #endif again: - if (iter_count > 10) { + if (iter_count > 100) { pr_err_ratelimited("Unable to read current time from RTC\n"); memset(time, 0xff, sizeof(*time)); return 0; @@ -57,7 +57,7 @@ unsigned int mc146818_get_time(struct rtc_time *time) /* * Check whether there is an update in progress during which the * readout is unspecified. The maximum update time is ~2ms. Poll - * every msec for completion. + * every 100 usec for completion. * * Store the second value before checking UIP so a long lasting NMI * which happens to hit after the UIP check cannot make an update @@ -67,7 +67,7 @@ unsigned int mc146818_get_time(struct rtc_time *time) if (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP) { spin_unlock_irqrestore(&rtc_lock, flags); - mdelay(1); + udelay(100); goto again; } -- 2.25.1