Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4057854pxb; Mon, 1 Feb 2021 11:13:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJxa2l/Msz7bBR1jGgjHRyF0agMeHkWpgspQFmMzdriqrO13ORP+L3xnaXcGCzoWXMr+XqqL X-Received: by 2002:a05:6402:22db:: with SMTP id dm27mr20939033edb.379.1612206824688; Mon, 01 Feb 2021 11:13:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612206824; cv=none; d=google.com; s=arc-20160816; b=tnVLzHUawF4S7LDuEv8bqhzfUdN7AoBXtpyzL6ovshgfqxRN7j9WHyp/B7b/hH45VY uht4UxonOiUPFfY0jP8klugq3JPc9Vohx3/z6i+mlnd2gFRSJdCJms9Zjk+Qn7fbHeYY lC44lBLPFF5e9xYl5hbj9TGjx/FqcVbe4n6EWAZEMNobkVM0uO2gIUW89TTyMHiQgVvK WJ2Vx3rt6V+jRRtfF7fynRqDWwUDVfOvgY6SbmpHWref4u4YbEQD5ohbSHpT1DgAYAYW 1MzMk3O4dM7IxpzDrBM2NilVGoaY67BHs9qbzf+68D7XkWrrCWdYcoJXXXTbCPDvePU/ 1RWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=qIi7Y2wtgcFcE5QpHplMFS5nIPaJWE0ofpSOrxqX7vE=; b=gs+X385oTA7s7YHdVM7awLXSl6QEVIU2Gu2Eq6W6tlOSxT80cNQAidoNvw/063MzfB H8Bo5hMG2cBRP01+zi9yjSig/uq7CjZTfOpEREnBjn9BjfHSf8SNVpyR+x+CfuNYllf4 dRmpZJ1KRYQwo+AJs8mOg4iPeE27/kVNjPuIR6FckRTasztEY2dHBNQkZn4il/XTxrSd Ly/c3TuQAydMyYYIcEDqyJV9NOAbhOiKVnAe/N+MSqowWK36wUQmlZE+LRpI/2+FO6hn YY+8/Gr7Ttx8zr8GOzewVMOrJkhMCieGDbaY4BoQYGhr9JGgIhwRY9MmHk/04nEk1V2/ msDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="XVmXH/B6"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=nr5ldRcM; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m26si12829126edp.591.2021.02.01.11.13.08; Mon, 01 Feb 2021 11:13:44 -0800 (PST) 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 header.i=@linutronix.de header.s=2020 header.b="XVmXH/B6"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=nr5ldRcM; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231643AbhBATKX (ORCPT + 99 others); Mon, 1 Feb 2021 14:10:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231150AbhBATKV (ORCPT ); Mon, 1 Feb 2021 14:10:21 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACFE1C061573; Mon, 1 Feb 2021 11:09:41 -0800 (PST) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1612206579; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=qIi7Y2wtgcFcE5QpHplMFS5nIPaJWE0ofpSOrxqX7vE=; b=XVmXH/B6KgSVLx6xfI3eJjezpOfEi1eu4mz6Qt71Tm9DLLlI/N5KqKtG0YGJgYNEwFjKkM OK3UjG52+49DUid7jyyf526RvToGf2WR4+Zw1F/mkMwEZAiDdshBq9jFbPeKOEZmG3b6oS 4NWgSnfMTqeiWLzcfEy70S6YaA3SE8+7MsywHIbohp3qOI1VxvZiqJ5J23+i8VFWic1FHP 5WJSecs1s3G3juRN0lWOUFo4lbBxuWhtQlzwKNPwVJDGx1jEkQs/HrjL/HY7j5GubHICWo k/l/Rq8RBCyzKMGTtX431hXvB7+Ak3cdSak6JEAu3WoyPZ6pFN3cWY5uYZBFZw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1612206579; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=qIi7Y2wtgcFcE5QpHplMFS5nIPaJWE0ofpSOrxqX7vE=; b=nr5ldRcMu1IXndLxDOTd4OagNk0bW6PEKeYtTng93ri2yrP0by8qsM4kA0qgbeGLMzxpLG S3ac5sUH3lmKJlDw== To: Serge Belyshev Cc: Dirk Gouders , =?utf-8?Q?Micka=C3=ABl_Sala=C3=BCn?= , LKML , Alexandre Belloni , Jason Gunthorpe , Miroslav Lichvar , John Stultz , Prarit Bhargava , Alessandro Zummo , linux-rtc@vger.kernel.org, Peter Zijlstra , Linus Torvalds Subject: [PATCH] rtc: mc146818: Dont test for bit 0-5 in Register D In-Reply-To: <877dnrc2sv.fsf@depni.sinp.msu.ru> References: <20201206214613.444124194@linutronix.de> <20201206220541.594826678@linutronix.de> <19a7753c-c492-42e4-241a-8a052b32bb63@digikod.net> <871re7hlsg.fsf@nanos.tec.linutronix.de> <98cb59e8-ecb4-e29d-0b8f-73683ef2bee7@digikod.net> <87y2gfg18p.fsf@nanos.tec.linutronix.de> <87tur3fx7w.fsf@nanos.tec.linutronix.de> <877dnrc2sv.fsf@depni.sinp.msu.ru> Date: Mon, 01 Feb 2021 20:09:39 +0100 Message-ID: <8735yfd2q4.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The recent change to validate the RTC turned out to be overly tight. While it cures the problem on the reporters machine it breaks machines with Intel chipsets which use bit 0-5 of the D register. So check only for bit 6 being 0 which is the case on these Intel machines as well. Fixes: 211e5db19d15 ("rtc: mc146818: Detect and handle broken RTCs") Reported-by: Serge Belyshev Reported-by: Dirk Gouders Signed-off-by: Thomas Gleixner --- drivers/rtc/rtc-cmos.c | 8 ++++++++ drivers/rtc/rtc-mc146818-lib.c | 7 +++++++ 2 files changed, 15 insertions(+) --- a/drivers/rtc/rtc-cmos.c +++ b/drivers/rtc/rtc-cmos.c @@ -805,6 +805,14 @@ cmos_do_probe(struct device *dev, struct spin_lock_irq(&rtc_lock); + /* Ensure that the RTC is accessible. Bit 6 must be 0! */ + if ((CMOS_READ(RTC_VALID) & 0x40) != 0) { + spin_unlock_irq(&rtc_lock); + dev_warn(dev, "not accessible\n"); + retval = -ENXIO; + goto cleanup1; + } + if (!(flags & CMOS_RTC_FLAGS_NOFREQ)) { /* force periodic irq to CMOS reset default of 1024Hz; * --- a/drivers/rtc/rtc-mc146818-lib.c +++ b/drivers/rtc/rtc-mc146818-lib.c @@ -21,6 +21,13 @@ unsigned int mc146818_get_time(struct rt again: spin_lock_irqsave(&rtc_lock, flags); + /* Ensure that the RTC is accessible. Bit 6 must be 0! */ + if (WARN_ON_ONCE((CMOS_READ(RTC_VALID) & 0x40) != 0)) { + spin_unlock_irqrestore(&rtc_lock, flags); + memset(time, 0xff, sizeof(*time)); + return 0; + } + /* * Check whether there is an update in progress during which the * readout is unspecified. The maximum update time is ~2ms. Poll