From patchwork Mon Nov 20 14:15:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 745556 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D062CC197A0 for ; Mon, 20 Nov 2023 14:16:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232986AbjKTOQZ (ORCPT ); Mon, 20 Nov 2023 09:16:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232963AbjKTOQY (ORCPT ); Mon, 20 Nov 2023 09:16:24 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2050.outbound.protection.outlook.com [40.107.92.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10C84110; Mon, 20 Nov 2023 06:16:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bDwtTK7LRvrmhVJBFF0SrCZG4Ehfocggf9qL/k+eqYFLC+hkDIw/WjdI3jf2SdWNy99rze0chMn04c5Lb3EyCUQrskpA93dSpdRQDJ+aONPtg0jTcNVnzaQouuLxVNK7mp5vWfqA2tC7HwmwRWo74SpPtfVBAI7eyerbattdJJ7hI0eI6AaFCIIW89quV76dF8Jjuvfc30J1PuyAOtOuiOQh0WuYro34FObAQkAf2mAa/MCRhZ8ZKSnM/q61MAjqY8DqkeUmW6PQNFZcy7/PHxZH8+LcWrdHkqDob+lYFAT+TxdoTQsx3+nh/OWw/HHnsD2/i3PtF8vJPpKN8fJy8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3AQ+mHof3kjrxEz9O7jMsJYhFe655aK6wk5/P6yxx+E=; b=dpmdxfRYmpzIP0Nae7p87BcmqrSqz5VAt4OOSzFWym5qJzGCI0QJzJg7gk7+uzJ10d0rIFl1rO1iCWu33HP7WL59evhz3uVPFLZ9DfU81Pd2Nt0p4WhwckmUayLywykyxXes4NaV57lOtgJyy85Amht/s/+yi2NpD1R61/FuXLHua2WI/G7bwc1VhjMJGqZTUKVtogFvLtid+b1Y9HFptMCK3tkGzAVtyLZKuIxODMUNIdTR5j1MtLxJIdUooltac52wM9HPvXhd4a5/8+HNKoF/7wTG3g9xBP35Pyngvobv9LAeKckfQuA7hDBt5804bgHKvlP5ElzC39WbQ4XoUw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=o2.pl smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3AQ+mHof3kjrxEz9O7jMsJYhFe655aK6wk5/P6yxx+E=; b=LN6qFNNtaTVj+eJD0qtgZwMN4AxYFE2AV5BqX6J21rQSMejIP7F61nXBAfo800/4rlCZso0TMFqwrt0WNq2VPoAmn8xWk8Vx6KjNrBIPlSD3qIkU4maFK3WNFWVBN1syj8jE7EF3oDW/QvQ0uYhn0L9uuaWQH46/BVri4hEp2yU= Received: from CY8PR12CA0058.namprd12.prod.outlook.com (2603:10b6:930:4c::23) by DM4PR12MB6662.namprd12.prod.outlook.com (2603:10b6:8:b5::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.27; Mon, 20 Nov 2023 14:16:18 +0000 Received: from CY4PEPF0000EE3E.namprd03.prod.outlook.com (2603:10b6:930:4c:cafe::67) by CY8PR12CA0058.outlook.office365.com (2603:10b6:930:4c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.27 via Frontend Transport; Mon, 20 Nov 2023 14:16:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EE3E.mail.protection.outlook.com (10.167.242.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7025.12 via Frontend Transport; Mon, 20 Nov 2023 14:16:18 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Mon, 20 Nov 2023 08:16:16 -0600 From: Mario Limonciello To: =?utf-8?q?Mateusz_Jo=C5=84czyk?= , Alessandro Zummo , Alexandre Belloni CC: "open list:REAL TIME CLOCK (RTC) SUBSYSTEM" , open list , , , , , , , , "Mario Limonciello" Subject: [PATCH v2 1/4] rtc: mc146818-lib: Adjust failure return code for mc146818_get_time() Date: Mon, 20 Nov 2023 08:15:52 -0600 Message-ID: <20231120141555.458-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231120141555.458-1-mario.limonciello@amd.com> References: <20231120141555.458-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3E:EE_|DM4PR12MB6662:EE_ X-MS-Office365-Filtering-Correlation-Id: b82c310b-9a2e-4a05-79ec-08dbe9d343ad X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jL9RDqRQFso9fznOglG/9zPPG7NJMns+JYleJBDWBXlEEhAZE2gp+3JnKGaYfP5Ur8y6v7/sHHXQalek9TAzfW8XyZJdsttbEiBHJS4Wp/S084N2yo+0Zw7IeBpuomOVFoXRBFWQ39p8qWFITWNrpPxtODbYMlPWJf6zTYAJuG2eyebyiQ9BvcWQcZrYz7Y4UNV1c4j3Z/XlwRJgIwtF4iv6hD9pSHuMXWG5ZC7kXK9ob2QUbjPylrMhuYXg/00h0AwyqN2EBDSBouIvKfN07oAMvpEVtLtx4vOuTtXX0tgOMoqg6CYEEtpAXN0NBWoRp3j/QtciCES0+xtFpjvIgeZCOIMPGQV56BFL0tgg0YCG+mtha5OQ22SMtD5XuPBCqfq3g/eN3eZpDBfGN64171+VgjTlxTLENn3vdyUVvWZixRZxW9MBc16/RTls+qBub/a/rqFyuQ5d1Ji0niq2S9L7vSmgpVfHW2EusbzvgBA513zCJmWPfGwsg9GHtsfxCDvAlhujnChwKrLm9pu51xIvtIImePfsZgo3dqrL8Hd/pziLnX24fPpQoP4Dneo0Hit514mu1mbP6zNdXpqO33ldLAZKv0/I+dUiSHBGQ7aiCLPFI/DLu20i7aSPt7iQiM80kdpmBuGSrDTeCG0Uq4j0bXspGsSwnjDg+/VklkJubKESUceBwlatPN+s8UmfrYZfL22ZDibddsuBoUiFm3Qxj6hiW64f37A7vWGUU5zUF7qCuOaDfFWafFEWSinAoqi5ZB2mv6BldVHZz4qSmg== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(39860400002)(136003)(346002)(396003)(376002)(230922051799003)(82310400011)(451199024)(64100799003)(1800799012)(186009)(36840700001)(46966006)(40470700004)(40460700003)(83380400001)(426003)(336012)(26005)(16526019)(1076003)(47076005)(36860700001)(4326008)(8676002)(8936002)(41300700001)(7416002)(2906002)(44832011)(5660300002)(316002)(478600001)(7696005)(6666004)(110136005)(70586007)(70206006)(54906003)(36756003)(81166007)(86362001)(82740400003)(356005)(2616005)(40480700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Nov 2023 14:16:18.4933 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b82c310b-9a2e-4a05-79ec-08dbe9d343ad X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EE3E.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6662 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org mc146818_get_time() calls mc146818_avoid_UIP() to avoid fetching the time while RTC update is in progress (UIP). When this fails, the return code is -EIO, but actually there was no IO failure. The reason for the return from mc146818_avoid_UIP() is that the UIP wasn't cleared in the time period. Adjust the return code to -ETIMEDOUT to match the behavior. Cc: stable@vger.kernel.org Fixes: 2a61b0ac5493 ("rtc: mc146818-lib: refactor mc146818_get_time") Signed-off-by: Mario Limonciello --- v1->v2: * Add stable and fixes tag --- drivers/rtc/rtc-mc146818-lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/rtc/rtc-mc146818-lib.c b/drivers/rtc/rtc-mc146818-lib.c index f1c09f1db044..43a28e82674e 100644 --- a/drivers/rtc/rtc-mc146818-lib.c +++ b/drivers/rtc/rtc-mc146818-lib.c @@ -138,7 +138,7 @@ int mc146818_get_time(struct rtc_time *time) if (!mc146818_avoid_UIP(mc146818_get_time_callback, &p)) { memset(time, 0, sizeof(*time)); - return -EIO; + return -ETIMEDOUT; } if (!(p.ctrl & RTC_DM_BINARY) || RTC_ALWAYS_BCD) From patchwork Mon Nov 20 14:15:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 745555 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BFBFC2BB3F for ; Mon, 20 Nov 2023 14:16:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233348AbjKTOQ0 (ORCPT ); Mon, 20 Nov 2023 09:16:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233128AbjKTOQZ (ORCPT ); Mon, 20 Nov 2023 09:16:25 -0500 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2079.outbound.protection.outlook.com [40.107.96.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BF0B112; Mon, 20 Nov 2023 06:16:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RULUSfo8EtKIsH91vVf2Dd+va+bhnRouNTcyTJFx8j+qekEiFUUKtzqh8PakThUBQvwIsgkw5rKopQHN29OxjeN4on/2/Taiw+dG0NLmADM9qejJq1DetdmlSmEPzAhTivP2yQS2GKA69A/jeA7PJOBpLhfW3rczKKOipaggsx1JK9F5HEKEKj34rxrguWIyzF++3BOpHxj5rFphl2UqvW6HcAn989ds7lhwJBpY4RmQW/3nensQFo2BkfBpzpzDtxB7DUYVWWlEQ2dWqTuzDy0goVutiFWNeQhpuJV7pbtq156tY0+Q22KUwRaR1hThM56xBlmVy9ic0P36Zqa4bA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=eoO2hsj6V7V8s3YNmSkGpN60ZmtwaHkyVi9LGkFRJGE=; b=iN9oW2Q22lfuwP0DaHSWgDztLv75lv5BS/59Epn00FkWB5dVShSB8OgtFAiQqHsNYQEO0ms0vAe2jOffEmns2JXESCIoKsdxNz9Sn9836e+7OCFOREj4zd3DBq4bBeWkGpvl0BIlcl2CcRjSK8KEAMD4wZ5FMOXxAlB8e8r1Yx6rn1K+sxXHvoD5yD9gjyrdLZJAUIgKOOhPCf16wKGdLCZ0gEdzVyqTx+a9fRudJlihmJPz0vr4oYb2jyGdIuo4AFUpr8B5n9+iKVsBvWZosYCLBgHgc7j0HuwXjBwB0m8RsWwbOa1uOBqzB7lAs4Ml0GXri+F/n6D2RNe2WHzgIg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=o2.pl smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eoO2hsj6V7V8s3YNmSkGpN60ZmtwaHkyVi9LGkFRJGE=; b=WXAb1aj7NzTc4lWQ6bPrMGpR0bUVIsYidkOyD1dycSFFLL6nei3g0Dv57Eg7vwp7jUxrHm6cVHaEjx2mC59yMvN2iHN2RDulk+PMwQxavID+lJHpEi2JEsHXCTHUmWwcZBFVRQCDoRLy0nbuoDX/eP6YDkAKAj95JBLIZbTz8po= Received: from CY8PR12CA0071.namprd12.prod.outlook.com (2603:10b6:930:4c::22) by SA1PR12MB8987.namprd12.prod.outlook.com (2603:10b6:806:386::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.26; Mon, 20 Nov 2023 14:16:19 +0000 Received: from CY4PEPF0000EE3E.namprd03.prod.outlook.com (2603:10b6:930:4c:cafe::9d) by CY8PR12CA0071.outlook.office365.com (2603:10b6:930:4c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.27 via Frontend Transport; Mon, 20 Nov 2023 14:16:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EE3E.mail.protection.outlook.com (10.167.242.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7025.12 via Frontend Transport; Mon, 20 Nov 2023 14:16:19 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Mon, 20 Nov 2023 08:16:17 -0600 From: Mario Limonciello To: =?utf-8?q?Mateusz_Jo=C5=84czyk?= , Alessandro Zummo , Alexandre Belloni CC: "open list:REAL TIME CLOCK (RTC) SUBSYSTEM" , open list , , , , , , , , "Mario Limonciello" Subject: [PATCH v2 2/4] rtc: Adjust failure return code for cmos_set_alarm() Date: Mon, 20 Nov 2023 08:15:53 -0600 Message-ID: <20231120141555.458-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231120141555.458-1-mario.limonciello@amd.com> References: <20231120141555.458-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3E:EE_|SA1PR12MB8987:EE_ X-MS-Office365-Filtering-Correlation-Id: 29ee09bf-3549-43aa-4ebb-08dbe9d34403 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: P14lE1DbBPSO+WKrAh6RO8nILE6ZwaOSDwQj7c9rxRzsOeTNSwEq7eco3bHJkKzUvRKhcqwfJkC/URGzPON3AG4I4/jbdFvcyuZgEzNKn+WM5hPzB+Il0p9pFVdxDm5E/gqd5Vy4MqmuerF77Dyi8SvaqskwuoBsJpiwQwKmpEoCXVyL0wc0JUQsGxj7O5VUVDFon9C+7zAAwBjqz/EF33YwN3RXhKxF1xQn7s+NqFAiDm0lwbPH7kcqH7WenyLf/T1hBOQfSD7FP7L5dlyUiCkGqQgBdfgCt1gqldubWt0864So6kvQG+1LGDRAZuOD2EzWzpgGOj3ImrZYTCbgjmgK/2Cfzs23DTH7rdp7gxvo63vB4/SrnZXc3bt4ssZl/9xWUF17KRtSWAyyMTl14uZ90YnCDY3CbKgWTXwPCIIEjZcTbTKdyaOFRqEtp/IjHkQQVToErAoy3QXUDwgqoqrTblznVUB7353OFgFybvmm9us/+8l0GCs1pQUwXfFYSd7jBHl0L1CZ2aHZNOvCaBBzf6GL1wVGWFHA42dQb6Vl1aDywQ8vzi9QPUYHY2LMwAzjDEP6FwhLvM9B17xz2Mek0+YwCCnf4u5pzSH0/SgwXdvYBp/HNBIr9EOEMNbeEuqPxecEpT1UFOdtFwipdLQzaJ+KzUDJ4F4xtUeotQT0g2ot3jp+dhdLqVsqV8/ZKSSfJCEr+XLmodSdjfbQTknpcjBzjkAg8UeuThEFXLeztC4XTOw46C7j+AcE1evJzeLGE42ditb0sLWbJCbs9w== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(346002)(396003)(39860400002)(136003)(376002)(230922051799003)(451199024)(64100799003)(186009)(1800799012)(82310400011)(36840700001)(46966006)(40470700004)(40460700003)(70206006)(70586007)(110136005)(54906003)(316002)(7696005)(36756003)(6666004)(426003)(336012)(478600001)(2616005)(16526019)(1076003)(82740400003)(81166007)(356005)(83380400001)(36860700001)(86362001)(47076005)(44832011)(40480700001)(26005)(2906002)(5660300002)(7416002)(4326008)(8676002)(8936002)(41300700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Nov 2023 14:16:19.0402 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 29ee09bf-3549-43aa-4ebb-08dbe9d34403 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EE3E.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8987 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org When mc146818_avoid_UIP() fails to return a valid value, this is because UIP didn't clear in the timeout period. Adjust the return code in this case to -ETIMEDOUT. Cc: stable@vger.kernel.org Fixes: cdedc45c579f ("rtc: cmos: avoid UIP when reading alarm time") Fixes: cd17420ebea5 ("rtc: cmos: avoid UIP when writing alarm time") Signed-off-by: Mario Limonciello --- v1->v2: * cover cmos_read_alarm() too * Add stable tags --- drivers/rtc/rtc-cmos.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c index 228fb2d11c70..391f91d3d144 100644 --- a/drivers/rtc/rtc-cmos.c +++ b/drivers/rtc/rtc-cmos.c @@ -292,7 +292,7 @@ static int cmos_read_alarm(struct device *dev, struct rtc_wkalrm *t) /* This not only a rtc_op, but also called directly */ if (!is_valid_irq(cmos->irq)) - return -EIO; + return -ETIMEDOUT; /* Basic alarms only support hour, minute, and seconds fields. * Some also support day and month, for alarms up to a year in @@ -557,7 +557,7 @@ static int cmos_set_alarm(struct device *dev, struct rtc_wkalrm *t) * Use mc146818_avoid_UIP() to avoid this. */ if (!mc146818_avoid_UIP(cmos_set_alarm_callback, &p)) - return -EIO; + return -ETIMEDOUT; cmos->alarm_expires = rtc_tm_to_time64(&t->time); From patchwork Mon Nov 20 14:15:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 745554 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3048C54E76 for ; Mon, 20 Nov 2023 14:16:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233389AbjKTOQd (ORCPT ); Mon, 20 Nov 2023 09:16:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233422AbjKTOQ3 (ORCPT ); Mon, 20 Nov 2023 09:16:29 -0500 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2059.outbound.protection.outlook.com [40.107.100.59]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39111113; Mon, 20 Nov 2023 06:16:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HS4/W3f3CE6RWmslp8t/m2rkXROi2MrQGsfccsBtfGqeYqPdkJedCUGP4eEWCd2oerHQpmv6+hj38J6X6GXUg2XnuW8GYoZBb48oD3dAT1SYSe9sBZTocN/5fipefNGIkiEf7IC0oIv0Yhtsek1w2alBeMv8vXsim1YEDVeE6C4tnzzhplYZmRwdlv/0r9Wxq1Ngio1hVmnRK8pE4rcTB4mUHlrAeSmQ3ngERc08G+rXU7FqKgMieDxhRs6OBxTO5mvC7gjdUXOdf4Z68EshmAB01xro6wex/RPdk5thCZnRK64GcXGAzdWbqtNlbXgNV9OArrgXphy0p6VJnl7TVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qU/xXbt7Cmsljc+S5yKqygKRc9J22o56OUEH5CQ8XRU=; b=f6D2v2nTYIg0Ks5imAm8aCDoTk/JnWwOG2Qc2N5XUReKFklSvZU3fff3FhDZbJnQiubgVmHEtNIAZKBmwSafNc88A93IpYM4YyCAwKrv3HGkLpnaVhudpUO2QVpRVMOFOnSu7VJ3E/2ocx1nkPrra+bO/5aUa52m3ukEpHUGaai6BEdV8sP8Mwafk/oGU/g1hWIyGphhqPEStZAvS8W0JdxbABSAUqNtg3MdLlG58N05KBzPuIED9KlOS+7HXKCrdb77L32TbQLSlNuZUrpG8yusJbrLMeA1SZRkbxCNgMQVjJRkJSbIcU+HZYmV54oUz6RX8EWeYZNnKVlo/UY6eA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=o2.pl smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qU/xXbt7Cmsljc+S5yKqygKRc9J22o56OUEH5CQ8XRU=; b=fKdL18UKx67DlLzBWnSppoczNYxlgXaVZrCImLxoixRlVVmHTNs9QC1Ak3ZruVa/RKF9/RV/P81Sg9Tdl+2GwItymjFVbF+b4GT6RYsbjAowS8YoJBDGIsZoUqohzpvP1Oudcr1UOJdqa4BaXgmQ7CMKeM/AuLjLZGMhw0jvB5I= Received: from CY8PR12CA0067.namprd12.prod.outlook.com (2603:10b6:930:4c::7) by PH8PR12MB7376.namprd12.prod.outlook.com (2603:10b6:510:214::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.27; Mon, 20 Nov 2023 14:16:20 +0000 Received: from CY4PEPF0000EE3E.namprd03.prod.outlook.com (2603:10b6:930:4c:cafe::68) by CY8PR12CA0067.outlook.office365.com (2603:10b6:930:4c::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.27 via Frontend Transport; Mon, 20 Nov 2023 14:16:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EE3E.mail.protection.outlook.com (10.167.242.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7025.12 via Frontend Transport; Mon, 20 Nov 2023 14:16:20 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Mon, 20 Nov 2023 08:16:18 -0600 From: Mario Limonciello To: =?utf-8?q?Mateusz_Jo=C5=84czyk?= , Alessandro Zummo , Alexandre Belloni CC: "open list:REAL TIME CLOCK (RTC) SUBSYSTEM" , open list , , , , , , , , "Mario Limonciello" Subject: [PATCH v2 3/4] rtc: Add support for configuring the UIP timeout for RTC reads Date: Mon, 20 Nov 2023 08:15:54 -0600 Message-ID: <20231120141555.458-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231120141555.458-1-mario.limonciello@amd.com> References: <20231120141555.458-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3E:EE_|PH8PR12MB7376:EE_ X-MS-Office365-Filtering-Correlation-Id: e92f08f4-55fa-4f48-9611-08dbe9d344ac X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3ephIpTB6BTU6Q9pb9Uz3T3rfptOSHlU/Psdc30MkJ/8v7/qA0sI/nj2EdKlTcUHpayvVfotV6UJgMPe+8s+bCw3CBc+j524Sl+EppCYn5QmD3o7Pr0y2nmCssIj60Ijb/cFM7khYylgOIvRERi8hGIEk2He9m1P1mn2zlWeYVxVqC9G1f6sJ5EcoB/kbJ9l7lLw/Dg9oSA1jQ0oP4k2s772ip2Rn/2QfEz6fZjT+dgVkewkuw6dJ9Bqd0TxqEmUDYJmy3xd0UW5b9OFG5AI0n5Qdjz0hAowEQNFIhLtfNnqucu5Dzedgl2gqiztTIGdJ5rAUzRKqtm/VLKQVXBeH9czdrcPBC6YvlCEf9B6c5UNdJHfUKZaYzlpyk/B6SD44GYnJ7BTLS1wcLdkWiJL7yfb+aRH8t5+2DxVpXDZoxN1byEeZAPXPMc8AVFjdpJzVBchiCIR5OZ1yjMpZvXEzzU0bvjL6rg8CV4/7TgbS3RVMsP7bpbMNVz+dtD90JSZm5Jvuu+vMudWjWEHg/jyxyfyOFXm78A13zy220mP46z8S633VIjANVS8Krai3ft1NYOp9A+0UwnQ8UqoOPXRAKdmjhRGeRJlSEA/qNoGUmDFk/XFHPwDFVy4ujJvFGoQ1ymU3RSXjrjsg4man4qfNfAjFnigM/fdPWoTJ3tsNRsWiZ3v29tdAr0h3oal1rcqBFv2SPDjQWK01hQhPHGxR5IDlNxcQSuptNtabxPuJfeirUI44CHvHpL4RCEGkEYcA3UJ5nuNCbtlFNwuBsDLKVRuf4vLIJiMpptuUtR2c/e1WL+LA7lh09zQNWgy7DphaIYR+610jY3UowgdRTD4qA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(39860400002)(136003)(396003)(376002)(346002)(230273577357003)(230173577357003)(230922051799003)(82310400011)(451199024)(186009)(1800799012)(64100799003)(36840700001)(40470700004)(46966006)(110136005)(316002)(70206006)(70586007)(54906003)(336012)(426003)(16526019)(26005)(40460700003)(36756003)(4326008)(8676002)(8936002)(41300700001)(81166007)(82740400003)(36860700001)(47076005)(44832011)(86362001)(2906002)(5660300002)(7416002)(83380400001)(478600001)(6666004)(7696005)(356005)(1076003)(2616005)(40480700001)(557034005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Nov 2023 14:16:20.1495 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e92f08f4-55fa-4f48-9611-08dbe9d344ac X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EE3E.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7376 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The UIP timeout is hardcoded to 10ms for all RTC reads, but in some contexts this might not be enough time. Add a timeout parameter to mc146818_get_time() and mc146818_get_time_callback(). If UIP timeout is configured by caller to be >=100 ms and a call takes this long, log a warning. Make all callers use 10ms to ensure no functional changes. Cc: stable@vger.kernel.org # 6.1.y: commit d2a632a8a117 ("rtc: mc146818-lib: reduce RTC_UIP polling period") Fixes: ec5895c0f2d8 ("rtc: mc146818-lib: extract mc146818_avoid_UIP") Signed-off-by: Mario Limonciello --- v1->v2: * Add a warning if 100ms or more * Add stable and fixes tags --- arch/alpha/kernel/rtc.c | 2 +- arch/x86/kernel/hpet.c | 2 +- arch/x86/kernel/rtc.c | 2 +- drivers/base/power/trace.c | 2 +- drivers/rtc/rtc-cmos.c | 6 +++--- drivers/rtc/rtc-mc146818-lib.c | 35 ++++++++++++++++++++++++++-------- include/linux/mc146818rtc.h | 3 ++- 7 files changed, 36 insertions(+), 16 deletions(-) diff --git a/arch/alpha/kernel/rtc.c b/arch/alpha/kernel/rtc.c index fb3025396ac9..cfdf90bc8b3f 100644 --- a/arch/alpha/kernel/rtc.c +++ b/arch/alpha/kernel/rtc.c @@ -80,7 +80,7 @@ init_rtc_epoch(void) static int alpha_rtc_read_time(struct device *dev, struct rtc_time *tm) { - int ret = mc146818_get_time(tm); + int ret = mc146818_get_time(tm, 10); if (ret < 0) { dev_err_ratelimited(dev, "unable to read current time\n"); diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c index 41eecf180b7f..17adad4cbe78 100644 --- a/arch/x86/kernel/hpet.c +++ b/arch/x86/kernel/hpet.c @@ -1438,7 +1438,7 @@ irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id) memset(&curr_time, 0, sizeof(struct rtc_time)); if (hpet_rtc_flags & (RTC_UIE | RTC_AIE)) { - if (unlikely(mc146818_get_time(&curr_time) < 0)) { + if (unlikely(mc146818_get_time(&curr_time, 10) < 0)) { pr_err_ratelimited("unable to read current time from RTC\n"); return IRQ_HANDLED; } diff --git a/arch/x86/kernel/rtc.c b/arch/x86/kernel/rtc.c index 1309b9b05338..961ebc7f1872 100644 --- a/arch/x86/kernel/rtc.c +++ b/arch/x86/kernel/rtc.c @@ -67,7 +67,7 @@ void mach_get_cmos_time(struct timespec64 *now) return; } - if (mc146818_get_time(&tm)) { + if (mc146818_get_time(&tm, 10)) { pr_err("Unable to read current time from RTC\n"); now->tv_sec = now->tv_nsec = 0; return; diff --git a/drivers/base/power/trace.c b/drivers/base/power/trace.c index 72b7a92337b1..c2e925357474 100644 --- a/drivers/base/power/trace.c +++ b/drivers/base/power/trace.c @@ -120,7 +120,7 @@ static unsigned int read_magic_time(void) struct rtc_time time; unsigned int val; - if (mc146818_get_time(&time) < 0) { + if (mc146818_get_time(&time, 10) < 0) { pr_err("Unable to read current time from RTC\n"); return 0; } diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c index 391f91d3d144..d278b085821e 100644 --- a/drivers/rtc/rtc-cmos.c +++ b/drivers/rtc/rtc-cmos.c @@ -231,7 +231,7 @@ static int cmos_read_time(struct device *dev, struct rtc_time *t) if (!pm_trace_rtc_valid()) return -EIO; - ret = mc146818_get_time(t); + ret = mc146818_get_time(t, 10); if (ret < 0) { dev_err_ratelimited(dev, "unable to read current time\n"); return ret; @@ -307,7 +307,7 @@ static int cmos_read_alarm(struct device *dev, struct rtc_wkalrm *t) * * Use the mc146818_avoid_UIP() function to avoid this. */ - if (!mc146818_avoid_UIP(cmos_read_alarm_callback, &p)) + if (!mc146818_avoid_UIP(cmos_read_alarm_callback, 10, &p)) return -EIO; if (!(p.rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { @@ -556,7 +556,7 @@ static int cmos_set_alarm(struct device *dev, struct rtc_wkalrm *t) * * Use mc146818_avoid_UIP() to avoid this. */ - if (!mc146818_avoid_UIP(cmos_set_alarm_callback, &p)) + if (!mc146818_avoid_UIP(cmos_set_alarm_callback, 10, &p)) return -ETIMEDOUT; cmos->alarm_expires = rtc_tm_to_time64(&t->time); diff --git a/drivers/rtc/rtc-mc146818-lib.c b/drivers/rtc/rtc-mc146818-lib.c index 43a28e82674e..5abb925da4fa 100644 --- a/drivers/rtc/rtc-mc146818-lib.c +++ b/drivers/rtc/rtc-mc146818-lib.c @@ -8,26 +8,30 @@ #include #endif +#define UIP_RECHECK_DELAY 100 /* usec */ +#define UIP_RECHECK_TIMEOUT_MS(x) (USEC_PER_MSEC / UIP_RECHECK_DELAY * x) + /* * Execute a function while the UIP (Update-in-progress) bit of the RTC is - * unset. + * unset. The timeout is configurable by the caller in ms. * * Warning: callback may be executed more then once. */ bool mc146818_avoid_UIP(void (*callback)(unsigned char seconds, void *param), + int timeout, void *param) { int i; unsigned long flags; unsigned char seconds; - for (i = 0; i < 100; i++) { + for (i = 0; i < UIP_RECHECK_TIMEOUT_MS(timeout); i++) { spin_lock_irqsave(&rtc_lock, flags); /* * Check whether there is an update in progress during which the * readout is unspecified. The maximum update time is ~2ms. Poll - * every 100 usec for completion. + * for completion. * * Store the second value before checking UIP so a long lasting * NMI which happens to hit after the UIP check cannot make @@ -37,7 +41,7 @@ bool mc146818_avoid_UIP(void (*callback)(unsigned char seconds, void *param), if (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP) { spin_unlock_irqrestore(&rtc_lock, flags); - udelay(100); + udelay(UIP_RECHECK_DELAY); continue; } @@ -56,7 +60,7 @@ bool mc146818_avoid_UIP(void (*callback)(unsigned char seconds, void *param), */ if (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP) { spin_unlock_irqrestore(&rtc_lock, flags); - udelay(100); + udelay(UIP_RECHECK_DELAY); continue; } @@ -72,6 +76,9 @@ bool mc146818_avoid_UIP(void (*callback)(unsigned char seconds, void *param), } spin_unlock_irqrestore(&rtc_lock, flags); + if (i >= UIP_RECHECK_TIMEOUT_MS(100)) + pr_warn("RTC took %d iterations to clear UIP\n", i); + return true; } return false; @@ -84,7 +91,7 @@ EXPORT_SYMBOL_GPL(mc146818_avoid_UIP); */ bool mc146818_does_rtc_work(void) { - return mc146818_avoid_UIP(NULL, NULL); + return mc146818_avoid_UIP(NULL, 10, NULL); } EXPORT_SYMBOL_GPL(mc146818_does_rtc_work); @@ -130,13 +137,25 @@ static void mc146818_get_time_callback(unsigned char seconds, void *param_in) p->ctrl = CMOS_READ(RTC_CONTROL); } -int mc146818_get_time(struct rtc_time *time) +/** + * mc146818_get_time - Get the current time from the RTC + * @time: pointer to struct rtc_time to store the current time + * @timeout: timeout value in ms + * + * This function reads the current time from the RTC and stores it in the + * provided struct rtc_time. The timeout parameter specifies the maximum + * time to wait for the RTC to become ready. + * + * Return: 0 on success, -ETIMEDOUT if the RTC did not become ready within + * the specified timeout, or another error code if an error occurred. + */ +int mc146818_get_time(struct rtc_time *time, int timeout) { struct mc146818_get_time_callback_param p = { .time = time }; - if (!mc146818_avoid_UIP(mc146818_get_time_callback, &p)) { + if (!mc146818_avoid_UIP(mc146818_get_time_callback, timeout, &p)) { memset(time, 0, sizeof(*time)); return -ETIMEDOUT; } diff --git a/include/linux/mc146818rtc.h b/include/linux/mc146818rtc.h index b0da04fe087b..34dfcc77f505 100644 --- a/include/linux/mc146818rtc.h +++ b/include/linux/mc146818rtc.h @@ -126,10 +126,11 @@ struct cmos_rtc_board_info { #endif /* ARCH_RTC_LOCATION */ bool mc146818_does_rtc_work(void); -int mc146818_get_time(struct rtc_time *time); +int mc146818_get_time(struct rtc_time *time, int timeout); int mc146818_set_time(struct rtc_time *time); bool mc146818_avoid_UIP(void (*callback)(unsigned char seconds, void *param), + int timeout, void *param); #endif /* _MC146818RTC_H */