From patchwork Fri Nov 17 06:32:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 745119 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 7B9F9C5AD4C for ; Fri, 17 Nov 2023 21:09:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346205AbjKQVJm (ORCPT ); Fri, 17 Nov 2023 16:09:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346175AbjKQVJk (ORCPT ); Fri, 17 Nov 2023 16:09:40 -0500 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2074.outbound.protection.outlook.com [40.107.220.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4093EB6; Fri, 17 Nov 2023 13:09:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mIso42epHChjN3wkzeWimyumRN1A/zLcCWEzbGdCiWu6GdtvDw1spZx7CGt3vJpLSVwEOU+MBBEiVyhxMfiOl5kAQGE3805NQwEqeoIeotCN+1RWRvbVveox6ZDe49ha/6u781s0lDoHs7UlCQ7cBr2roWqxN+xqw75aZwnSnCVcgSolqkPWXvm9JDZ6XXYiNHRlNFxWtBmPLaOyXF1VXPJQnGg3A7iNbZ+qUXuKbUVLzoOH5taVF0pVZSE7cIrijegvbPAKsIbPl2u0A3DAYYcVh2ZVHikTJ1q9dIEuycWtajYJ7rSCZFsgQWFdoml8GyZTcBk4c7aNvddJMJyJpg== 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=mNMLQ8vk3cFmorweU+R2WqLnIvOWI61uBYh8EvW0MU8=; b=bJnyUOc1loOs5MqkTa40BIY7+7Iz8L44cei1sqhjxUiGjQAsc/RV852FUSGi4I3NYg08ptkljXC6ejAe/A9GuUzcHu2gJbhDSocWMtOizFEVsKf+cyULNQKmAj5a6BF6IShY3+mN41AcgXF6ZWByzBNlBvWleN6p9TCY6pMejFGzaefdklzZAzlD7vIt2gBQR9w2wI1GumoD30ye14RzBwiFRVVO0GT60AB3J3zgUx/pu6P3g7DFs6H4e5WjKd6ZmtboGhF4+V0v8NCqgKm0eODvxS4GK/+JZ3UVzjVBlvqXJ/hm4Cw1GJEbGVPB0hhYGXG2O730Jhofk1wsAr1oWA== 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=mNMLQ8vk3cFmorweU+R2WqLnIvOWI61uBYh8EvW0MU8=; b=YdRZdyENutQtdNOk3ZKj98mfhL6UObIjH6RiV5PrLJd24tqr92hgiO3qiaOP2mE3hzGCwvDbTz6If3FLcJ7aZ2VqkafD1KVR6SYIslG03uNHG+bkTZiNXH2bkH8gaABGUTrM5+XQayD7YRrQbxuN8EqIBB5BJCkDZyiGNb3lCdo= Received: from MW4P220CA0002.NAMP220.PROD.OUTLOOK.COM (2603:10b6:303:115::7) by DM6PR12MB4169.namprd12.prod.outlook.com (2603:10b6:5:215::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.23; Fri, 17 Nov 2023 21:09:34 +0000 Received: from CO1PEPF000042AA.namprd03.prod.outlook.com (2603:10b6:303:115:cafe::6d) by MW4P220CA0002.outlook.office365.com (2603:10b6:303:115::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.23 via Frontend Transport; Fri, 17 Nov 2023 21:09:33 +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 CO1PEPF000042AA.mail.protection.outlook.com (10.167.243.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7025.12 via Frontend Transport; Fri, 17 Nov 2023 21:09:33 +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.32; Fri, 17 Nov 2023 15:09:32 -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 1/4] rtc: mc146818-lib: Adjust failure return code for mc146818_get_time() Date: Fri, 17 Nov 2023 00:32:17 -0600 Message-ID: <20231117063220.65093-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231117063220.65093-1-mario.limonciello@amd.com> References: <20231117063220.65093-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000042AA:EE_|DM6PR12MB4169:EE_ X-MS-Office365-Filtering-Correlation-Id: a9f5154f-c65d-4afb-22fd-08dbe7b17f81 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IA1JYvfGHFfWxnM8TyeLhOwTBhbAs0mX4/LluHTLgSxkt5FNCQ/VgRW+5sp6rIy8pz6nshIVZglfkxfRc5xZQFIJvnbQjb22BXMJHfezl47TatqO1wUoNfmNQWFmd544yNIduzoQvcNVeK9F+KdSdMhnPBspz+/t2MlQohzWLnV5LmwuHzYVFWtlfCEgwKKwOLLx0E6gqUcjziEoxmcb8CSozVfFSbV1VilLmKTViB/pjS8p4TcVK6A9yUEOePtf4wxK2c9VdsBvYMEYNhe2E+sN5FFozxhTZWIFkT0/rYznJ5q5XcOiLPfr6d+40cwCHIHfYTQ1/HvCKSxk05tNamIeh1WjXRFVVZDjeb1mKVGtlDZE/0jglkxGcNQGHNp2IDhOjDqC93QbjPIBon22ncW07u8ea8coWsrnH4QRUWtu0fEpoeMK4YQvR6bxAwWwQjVp5xlye3dxot5cnjtEGxnv8Pd/VNLPiL86KB4VnzA/PPFV13Ikgr2kneWq6jJY14irYMl8GX2azYx7pitQ/eRfhnBI0j2BY+yiE76X4mQYZSqefY/Z5OIav9gIF78vR1QypwlDY8/NKO47GsPysh4uklkP5gP+9fhqZurIM/ML2X2fY+mui60Hqc5TZBvoKSMHXudaQSH9KsKD/IySsLwCzHW2h5Qkfoz2EzdK/oUJLDxud4zX0zL9GRvky8htajqIChyErkkLKZ/nC/FSSQR8wFKCdvoeBwh0qhNaxt0xhU4Qlzh+xDU5XbHwtQxocWYY5Bqfprm3Bsv6e+SzUw== 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)(376002)(39860400002)(346002)(136003)(396003)(230922051799003)(82310400011)(64100799003)(1800799009)(451199024)(186009)(46966006)(36840700001)(40470700004)(47076005)(7416002)(2906002)(4744005)(4326008)(5660300002)(8936002)(8676002)(40480700001)(36860700001)(44832011)(83380400001)(16526019)(40460700003)(54906003)(110136005)(70586007)(70206006)(426003)(41300700001)(336012)(26005)(356005)(1076003)(81166007)(36756003)(82740400003)(2616005)(316002)(7696005)(6666004)(86362001)(478600001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2023 21:09:33.5891 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a9f5154f-c65d-4afb-22fd-08dbe7b17f81 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: CO1PEPF000042AA.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4169 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. Signed-off-by: Mario Limonciello --- 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 Fri Nov 17 06:32:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 745120 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 06492C54FB9 for ; Fri, 17 Nov 2023 21:09:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232387AbjKQVJk (ORCPT ); Fri, 17 Nov 2023 16:09:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232356AbjKQVJk (ORCPT ); Fri, 17 Nov 2023 16:09:40 -0500 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2069.outbound.protection.outlook.com [40.107.212.69]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3692D52; Fri, 17 Nov 2023 13:09:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GPiDc11S88rDYqmAehOsdtwZLqK61X0llKk0EI7s82cX6uDM4d2a8tjQeZ53Skd2TIPFqmPNCYuIhxsrCJ2u2MwYcvhvTtNBOQZ16s6iViWeogOMeiLoiESsoz5F5sHytq63Kep+6j65zAE6HfZZfHuCK0Ej/zrfojlmSjF3TB+cc5rGtkUOqzABaowPxbaDGZavUcet+PWGugi4+eq22XBmiMf9YL2kYzqQTRgO8CdfaSheNLSao+v4+4kVMNMG+nU4Aj+TRYyV98KblbcUHhKlgVruAuDwN+BPV6hVeSvSrTo+7PxywxKjC5T4NycJBlWKfiXrFTtx3LzG57n0Ng== 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=A03hEYNcjSS8d1zZbRBrQjX1WYCxxmU5do23a04VO1I=; b=gfvpduHihUENmyKihGATb7XVaVofxwlmv77fNMi4HbniTA9NViudODu871GU9yuHgaP7r89Kyfn6hbwZKsFJiwD7VMMmD+z8KL6n7j0is9hFbW5GZpZoBnFaJh0Zg+GAZ4zQWX/+Jy3iTQjRA+qtS+aKpHZLrr96fMDSnX0j2oT1meRc6lI4TCQOgPGZVORJzOs1oGQcqXLKKkqddJ1GNw+69qAkqO4lEIcIWSKs54KDQPbNbfnTnrOucwBQcXwJYIPvUhiNYWsUbuD9ULo7o5dvEPqZswCvqfvI1p/50pWXvMJrgN2fRCIfibidKq9FqawromamXWuwI2jT/43nnw== 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=A03hEYNcjSS8d1zZbRBrQjX1WYCxxmU5do23a04VO1I=; b=DRArC7IMyhKraZrF82FIi2b96Y+bAPfxCBrDOklRh8F04564X++RerrZM5lvVHOlVYxdv9O9ZV+vcXYhXmgBe7sRnGLuzsSepLghdfx3T4L5FDtfLwzjeZYZQcMNwXEBYH2L2YywHOVF5fD/8dGyelFjzKZiXHmifPQXcjd8mEc= Received: from MW4P220CA0003.NAMP220.PROD.OUTLOOK.COM (2603:10b6:303:115::8) by SJ2PR12MB9210.namprd12.prod.outlook.com (2603:10b6:a03:561::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.23; Fri, 17 Nov 2023 21:09:34 +0000 Received: from CO1PEPF000042AA.namprd03.prod.outlook.com (2603:10b6:303:115:cafe::f3) by MW4P220CA0003.outlook.office365.com (2603:10b6:303:115::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.23 via Frontend Transport; Fri, 17 Nov 2023 21:09:34 +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 CO1PEPF000042AA.mail.protection.outlook.com (10.167.243.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7025.12 via Frontend Transport; Fri, 17 Nov 2023 21:09:34 +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.32; Fri, 17 Nov 2023 15:09:33 -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 2/4] rtc: Adjust failure return code for cmos_set_alarm() Date: Fri, 17 Nov 2023 00:32:18 -0600 Message-ID: <20231117063220.65093-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231117063220.65093-1-mario.limonciello@amd.com> References: <20231117063220.65093-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000042AA:EE_|SJ2PR12MB9210:EE_ X-MS-Office365-Filtering-Correlation-Id: 22b4fb51-7f8a-4e10-e1c5-08dbe7b18001 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hhbdlTfoobFI+uUJClk3TlSaXhGCNn75khd2qUstz5v9sjNvojd3gB4yvSfITlZIIHi5/kSaNCS4a+UnhSzQGQJDhBPId+/FIFtG21prCKvVcvmXbNJug0MTTZQig3rBeHofTrjGlBKXnibX170bXqXbHoY2YQYTOBvM067yd0Z9L3mubVpIeiycupWv0m6kw011/tU3aD0JFPUNU4PNiykB3d92mbHhVKV0hboKuygNPB8l+0a9yqjUItpmWBagFDMavXQ7ns41l4GyUHFUmPtM3xkFiyjB2sGx+MoTVK/2AmBTGZd+dZAwpuR4fumgcRamRStZZdClDGtvJXUx91hHt/LNP0U/Tzi/FCHUUVpZmHlhnSUiLR+TS26UrtcmbhmrOaVoiV0Yu71zHGqyeWyVpRvTWotUfmPYa7K3M78wRSA1yl0asrn9ZkiweE3pxQ8OjnLLqAqoAPme2YW+/kr2WAgeRo/IroCUOvEKpQXDtgidoyG7yPmTc2SQwCz3qRFMJb3kWCX4ImvaGZymzhKRANkjFrihB/EMo5tHT6rVjequnNDM9C3QZpcK2j/FiccYvDsstIrSGOXLKydmzuxXmmc4wXOFRu9SzddTIl2oAUzuSl5sPiaFe8fqCgqzoilCR9i/x+JTrgG1AmAeQoAYporSalAFlh9XfK9zv+wiR1NSKInqiLXlZQKxufuzuyjfU3ug3dE7hnHOZCSbwH/MxY9td1vLQobKLRPsVr/IeGCF4y4ht4GhmzYfafI/SvwKi+u5vWN0WV0DSgbw/g== 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)(376002)(346002)(396003)(136003)(39860400002)(230922051799003)(451199024)(64100799003)(1800799009)(186009)(82310400011)(36840700001)(40470700004)(46966006)(44832011)(7696005)(478600001)(40460700003)(6666004)(54906003)(70206006)(70586007)(4326008)(8676002)(8936002)(110136005)(316002)(47076005)(36860700001)(83380400001)(2906002)(356005)(40480700001)(81166007)(41300700001)(36756003)(1076003)(2616005)(7416002)(5660300002)(336012)(426003)(82740400003)(26005)(16526019)(4744005)(86362001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2023 21:09:34.4173 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 22b4fb51-7f8a-4e10-e1c5-08dbe7b18001 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: CO1PEPF000042AA.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB9210 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. Signed-off-by: Mario Limonciello --- drivers/rtc/rtc-cmos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c index 228fb2d11c70..b39890a5531e 100644 --- a/drivers/rtc/rtc-cmos.c +++ b/drivers/rtc/rtc-cmos.c @@ -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 Fri Nov 17 06:32:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 745118 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 AB194C54FB9 for ; Fri, 17 Nov 2023 21:09:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235727AbjKQVJ6 (ORCPT ); Fri, 17 Nov 2023 16:09:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346213AbjKQVJt (ORCPT ); Fri, 17 Nov 2023 16:09:49 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2073.outbound.protection.outlook.com [40.107.92.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 451C2171F; Fri, 17 Nov 2023 13:09:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dNDNlOsqYftdcRKfkUZh2hlg7VuG+2m0ylMhVT2Jne9QqQmcWaMQKqMHLwl+SEMwwB/ixfuwc64FLwPZqsf0tPj+FFZF2kBb9wqJRoJnbv9OUVHxjNfSfXLyRV5U+8FPhOfVVC/3QSMJJhARoezgn6+p9+hmygDV/rSQKjnyOxzHtxPnh3GMGzURbCCQMW9/1wwp3+TBvHoC0SVWGaMayuRe4ZpFuV4c9x0f0mfuxmap6u46o976fjn7IvgLJDJv9O/x7cM447EG+D2/BqODs0AtlS6KwXiyRyUGZJuqbe2y6LcfVAQ+Ywf6zOgE24KFnSviXV0W01Zs0F0s/E/Umw== 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=RFyiGmf119Op9GqQbFyP0NA4Zv5VJqvlGq3oKt7TijQ=; b=Z51eYaE3Qa8orG3JLEt4Qzw936WWroq1NpueNUCngdl8IfZgcaeirFGQjVM6KGMLZrRPccjbuEPZVcx7/Vq6s7O8OPrkUL94Rb9MBguEISn3PuBVZRl4bBQzCLb/uUnNbFmLfIDhHJTwEJNDpjr09h6pghvOJ3eDrnPpbr5O4479J04Q7ugd4bC9N3erXKgDh95n5PoKADcBu0iNT2HmCWWR9gisOahbRa3FCBEWHjHlh8LZQX6FwEiLiVsLtVhNLMu1JurO7dWjBmXZlKpPPLcz4MgtmsuwKCIGC7ft2JB6S7pl1IggXCWYoNDHjY3YI0CXxZ9dyvXM/AfZGIkp/A== 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=RFyiGmf119Op9GqQbFyP0NA4Zv5VJqvlGq3oKt7TijQ=; b=tud27KH2Fa1DZtcj7xap5bx4Mq4AxGahzmcBezqBM3KlXc/IE+WwuKhbu9IXYH1czbx4yIwqegGksMGMmYvKWAco2DAnjDkrGt9LNyRTRhCYzZZKH+dpVzTbrlSnXwUf2xFbleKXa0WSv2WoeVqsHRkE9jJewy87QF+jO9CrIg4= Received: from MW4P220CA0005.NAMP220.PROD.OUTLOOK.COM (2603:10b6:303:115::10) by SJ2PR12MB8847.namprd12.prod.outlook.com (2603:10b6:a03:546::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.21; Fri, 17 Nov 2023 21:09:36 +0000 Received: from CO1PEPF000042AA.namprd03.prod.outlook.com (2603:10b6:303:115:cafe::91) by MW4P220CA0005.outlook.office365.com (2603:10b6:303:115::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.23 via Frontend Transport; Fri, 17 Nov 2023 21:09:36 +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 CO1PEPF000042AA.mail.protection.outlook.com (10.167.243.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7025.12 via Frontend Transport; Fri, 17 Nov 2023 21:09:36 +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.32; Fri, 17 Nov 2023 15:09:34 -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 3/4] rtc: Add support for configuring the UIP timeout for RTC reads Date: Fri, 17 Nov 2023 00:32:19 -0600 Message-ID: <20231117063220.65093-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231117063220.65093-1-mario.limonciello@amd.com> References: <20231117063220.65093-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000042AA:EE_|SJ2PR12MB8847:EE_ X-MS-Office365-Filtering-Correlation-Id: c0912520-5cbb-4516-4b0a-08dbe7b1810f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: f1AvWDSWXbFzEKQu3v/vYEMJqKg0SJF4Y444aPwunfUQ1nl9b62yN1SzNU/Bppet4SWEXk64qpCnqIjc0LoYSymSwoWWPItOVlOmy+Cl6wfeMEMwwrWGiUnw800Su+/cyNU0Fk6gnmzSUIto60Q3Wqu9VW49mfBUbHZYwVvDyFTBeMeSESZ4Rtuc4ov/hF/7Ay+vPzCkiui/T21yzhmji3YXXmkt8uLMB/5c0nwW4w/+HlfIusy8fKotpHV99m4C3rZx1167V9gKRqr0L67MVUkgiWNFWVIPGGteMLXrfVSHvb2QTdNbpJxeamWsJY4MuJ+Nepufk7onUv6Mz6Akt1b38bh+dylZ+X5alaNGiXDhsD/whDy3RT4W9FPQeyHlO1TPSXqcV/vzGOa/Aepaf/t/2Tv1KznN49sszsfScSGUVzs5t4yaPQ0E9C7Rg58bZLV7M/cJYmel3uzDPH7tvM/JEuywu1rpA2r2rm751XXpA07+u7PZvnm8CpoF4MIAYQgd2OTF6DhZEhiw/u5E//Gs/hLbV7Zm6MpuZoL5Dj8ODsZ+yL2yD8AVF7jgnpCnFj+0NU3oPOV+6bhX3uzSZ+5aOiwYaHEnTQsW0xI06d8F+M7clMfX/MEI0D6NI/Sj820AWi3PtPsWh3Sc+Hwos1xwXXi/aGQevUidvrjiR8kf9jgjExH953M3pK7n36DvCOYmIB7NQw/xJn+BoagTxzhziq9DhgqHTtCA5dp96XukHlvwULskmDTOnpYRo/pbpEX3br77aoFLARrNhaLVHaAWzq97eyYMgjxQ4AnpZvzwMXwZmf1FKUvs7GN2vpLjy7U01H4imT1wdaI19WT2hCaHMYCLGJHVVcXR6W9iwuB0vgje5Q/a56abueIWb0Dlt+VeSGn/X1cSXy6j3pxSNA== 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)(376002)(136003)(396003)(346002)(39860400002)(230173577357003)(230273577357003)(230922051799003)(186009)(1800799009)(64100799003)(82310400011)(451199024)(46966006)(36840700001)(40470700004)(336012)(83380400001)(426003)(6666004)(7696005)(82740400003)(16526019)(1076003)(26005)(2616005)(40480700001)(70586007)(70206006)(54906003)(110136005)(478600001)(316002)(36860700001)(47076005)(81166007)(356005)(40460700003)(8936002)(8676002)(4326008)(44832011)(7416002)(41300700001)(2906002)(36756003)(5660300002)(86362001)(557034005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2023 21:09:36.1829 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c0912520-5cbb-4516-4b0a-08dbe7b1810f 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: CO1PEPF000042AA.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8847 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(). Make all callers use 10ms to ensure no functional changes. Signed-off-by: Mario Limonciello --- 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 | 31 +++++++++++++++++++++++-------- include/linux/mc146818rtc.h | 3 ++- 7 files changed, 32 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 b39890a5531e..16dcbd196ce2 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..75b2fc1791e6 100644 --- a/drivers/rtc/rtc-mc146818-lib.c +++ b/drivers/rtc/rtc-mc146818-lib.c @@ -8,26 +8,29 @@ #include #endif +#define UIP_RECHECK_DELAY 100 /* usec */ + /* * 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 < USEC_PER_MSEC / UIP_RECHECK_DELAY * 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 +40,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 +59,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; } @@ -84,7 +87,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 +133,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 */ From patchwork Fri Nov 17 06:32:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 744835 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 6E61BC54FB9 for ; Fri, 17 Nov 2023 21:09:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346241AbjKQVJr (ORCPT ); Fri, 17 Nov 2023 16:09:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346202AbjKQVJp (ORCPT ); Fri, 17 Nov 2023 16:09:45 -0500 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2070.outbound.protection.outlook.com [40.107.237.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B277310EC; Fri, 17 Nov 2023 13:09:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KlfLKy/n7b+nfp/hMbJzwtbeANqXUYVn6nMDxN8o1tRQV42Yj53CBfOMIdt1/t++t0yJxhhUQTo93O4VjK5eBoMcz7QeJDWaXLXrP8AyAu5kwUJvsooFKTrD26bqsJBXwXfw55SCrpD03BSydLP2WVT+ojVZ8WUGPSyP9dyNQLbhmBXD92q0w8qLXa/JsHE0MipNSGCUMRviEO43H+RGjjLs5UatwiEWvM7VJq68Wb0w2F8NzGQQiPyoNhGNdsZf4lzSIduZzWIUhu/iiebu1TOSFP7/Dik8ULwyegW/NYNXeNMXHgdBeUFAgBaDxxlY6HKjZpTYSyFXUwSLfOQD+g== 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=9fQjz7zeh9vmmyAWNqSCY1iMHAwLZ/KlnAy5z4AG6nQ=; b=UdrxRBKrnWaIwqtHK/Gqh/rcU1T0k6Q6NrdViI6YXmhp9VW0Jk+ouI3J2KOvcg1v3p2wI8k75qlDBSiD+DT85lYrGc5jm9XvdHuVJk7VfN9gw7pC2rx6563Qc9Vtl6njz64G52i2Xzo+8/X9D7Uu7U1pZ4RB8HvsRqNYt0SJH0JC4oV27sUG9FIakJdirZ7d6NEAEX0w46ypnmZ3xiBje8Fpz3el6MCM/+cQMHSPk6YvUoewDelxniEhTUtQpPiF+zK9q0h4oGtEOZcKof7Neu/frutmStpA2V8pxORBnYdmiGEmSzrpXOuSagx+2GH3/ZCNUorgKrTTGvhhn6rsrg== 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=9fQjz7zeh9vmmyAWNqSCY1iMHAwLZ/KlnAy5z4AG6nQ=; b=f+/7kf8PHHk2C+45WSba94hKT7SOiZRzRcHZMSO6NkD+Hznb/s/nRGNI+9fmucwUjTc034SWFhA17D88NNQJFqUyrMoEBsRU9mgro9nyieHgAoL8RXogKf6JVhdevIEA1tL8NjOzHlJutKK5kir7jj514Bz9bsWQBwaE8uq2lf4= Received: from MW4P220CA0030.NAMP220.PROD.OUTLOOK.COM (2603:10b6:303:115::35) by SJ2PR12MB7824.namprd12.prod.outlook.com (2603:10b6:a03:4c4::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.17; Fri, 17 Nov 2023 21:09:37 +0000 Received: from CO1PEPF000042AA.namprd03.prod.outlook.com (2603:10b6:303:115:cafe::f7) by MW4P220CA0030.outlook.office365.com (2603:10b6:303:115::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.21 via Frontend Transport; Fri, 17 Nov 2023 21:09:36 +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 CO1PEPF000042AA.mail.protection.outlook.com (10.167.243.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7025.12 via Frontend Transport; Fri, 17 Nov 2023 21:09:36 +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.32; Fri, 17 Nov 2023 15:09:35 -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 4/4] rtc: Extend timeout for waiting for UIP to clear to 1s Date: Fri, 17 Nov 2023 00:32:20 -0600 Message-ID: <20231117063220.65093-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231117063220.65093-1-mario.limonciello@amd.com> References: <20231117063220.65093-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000042AA:EE_|SJ2PR12MB7824:EE_ X-MS-Office365-Filtering-Correlation-Id: 0e62e546-5487-41bf-1f91-08dbe7b18165 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1G4D4h1YiDd667T6FCthrIXsUo83CkvP8/i+Kv+YnTmMyKoZiN2DnHoHceh9L2POv6vVKf6EUFefuvJoG26DZ97jLcah66D2r4Oof1T1V3EdjIx4bjQSew8Mk0BhZA6u9BZ/ojOrZD4E6Ed0iMLryjkG1bjzfA1dPVNA1Z3HFIB42ZDxp6oywl6eR1efas03MkSsUu+zRiEoCn35pWHB/5zM0Hqr7ctuolM7MScPL+OpLNvsodAk0g2IsOIdjdPLTnE40R2Wy1j42ECTiWm4E0LC7Y0PxXvm6BRcCybgAp46FGAXP2qFK71zKLN0e32x+8NYf3p5zRjnLoAjMwYlzztH03W9323J39wSAVoGpi6Uj8G4J553N+3BZnYx1wynM/zZ3vO12rqr1DucKB8fBe88cUfUrpBoPVKZmskKrVYS6FCok5kTOPyD56IABlR0nGR4RbXRwbGb+7uL4i3XNrBgdDW7lcQK4mO6WU/7fBwX6GQ8CFMIUGCqDc1YRxKs2tLeCPtonKlYJ/Au6ZFfWc0+1lXPkWaukxmafCTE1LA6pXGDp3G+XgUvlwAJMwNG2iz5Wj6W7BNGSdSXaHP+SH+AQS6XiJgeP+U4yVpTnWoV2FdWbtuSHA2GvQAOxY46WyXeK2hlvfWSdRJ0I04vFGhQpvkYWMhb4Ii9zRqaZiySRcCBOFaD7IVH4ZGQG01su/evH61DWB5E0PA+UhFQSEXaLF2DArX8srVlo0Vgexq7d3o2v14+R3rM6qAh3cbLgVkv+8C/Hex2qMN16vvJ7g== 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)(396003)(39860400002)(346002)(136003)(376002)(230922051799003)(1800799009)(82310400011)(186009)(451199024)(64100799003)(40470700004)(46966006)(36840700001)(41300700001)(2616005)(36860700001)(44832011)(83380400001)(4326008)(16526019)(8936002)(1076003)(8676002)(336012)(426003)(6666004)(47076005)(26005)(2906002)(478600001)(356005)(40480700001)(81166007)(7416002)(5660300002)(7696005)(82740400003)(54906003)(966005)(316002)(70206006)(36756003)(110136005)(86362001)(40460700003)(70586007)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2023 21:09:36.7610 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0e62e546-5487-41bf-1f91-08dbe7b18165 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: CO1PEPF000042AA.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB7824 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Specs don't say anything about UIP being cleared within 10ms. They only say that UIP won't occur for another 244uS. If a long NMI occurs while UIP is still updating it might not be possible to get valid data in 10ms. This has been observed in the wild that around s2idle some calls can take up to 480ms before UIP is clear. Adjust callers from outside an interrupt context to wait for up to a 1s instead of 10ms. Reported-by: xmb8dsv4@gmail.com Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217626 Signed-off-by: Mario Limonciello --- arch/x86/kernel/rtc.c | 2 +- drivers/base/power/trace.c | 2 +- drivers/rtc/rtc-cmos.c | 2 +- drivers/rtc/rtc-mc146818-lib.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/rtc.c b/arch/x86/kernel/rtc.c index 961ebc7f1872..2e7066980f3e 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, 10)) { + if (mc146818_get_time(&tm, 1000)) { 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 c2e925357474..cd6e559648b2 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, 10) < 0) { + if (mc146818_get_time(&time, 1000) < 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 16dcbd196ce2..345897dadb91 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, 10); + ret = mc146818_get_time(t, 1000); if (ret < 0) { dev_err_ratelimited(dev, "unable to read current time\n"); return ret; diff --git a/drivers/rtc/rtc-mc146818-lib.c b/drivers/rtc/rtc-mc146818-lib.c index 75b2fc1791e6..c6f5db6521dd 100644 --- a/drivers/rtc/rtc-mc146818-lib.c +++ b/drivers/rtc/rtc-mc146818-lib.c @@ -87,7 +87,7 @@ EXPORT_SYMBOL_GPL(mc146818_avoid_UIP); */ bool mc146818_does_rtc_work(void) { - return mc146818_avoid_UIP(NULL, 10, NULL); + return mc146818_avoid_UIP(NULL, 1000, NULL); } EXPORT_SYMBOL_GPL(mc146818_does_rtc_work);