Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5544308pxb; Wed, 26 Jan 2022 14:38:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJx/HOXGLAGLHjojT6R62inpN81emeAVMKnPeUPxUumERSEgX8wMd+IO8l2wAZgtkpFH5bBt X-Received: by 2002:aa7:c6c8:: with SMTP id b8mr1060591eds.37.1643236694778; Wed, 26 Jan 2022 14:38:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1643236694; cv=pass; d=google.com; s=arc-20160816; b=jnxUFjHBgVkWYOdUCTVGyZ10h+XF/mzVO/iCSF2SHbBKiKyd3RKyMdzGK8Qdb4EnLy PuB2Eglk4drWBmBvmudieIJ/4kre/KTj+JE3Temgp1azZTF3Aj7Y5fkNTfosVue4rXNF kSNDW62yeXbYW3dCvGqxGHEhjJWknazCPXfgZFyuMHz9j7S814fDv1pCzZyY/77ToErs m7XMX2CcuVVpSUcZ/ltwHqnZyLtx4S5Jzwr9lRB4M4wOjN7RzsoN41G15zTLFqubsTku 6Ag7Gwlr6n2uMgmdKyLWP4on5+O5/skzN/uC3kOEuNLtSG5M1f+uAgp7IYIwmcU1Ujx6 Wucw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Fvn2y1S+JopDKqdRGcRcHDiIgbS9s7h5z0hvdyg5AbU=; b=YOBJImD2WN5equXWjj0Kegn+dDYPPmISUULcbfrcgzgaVRDbgQ79R/tQMtXkuC+9mV ZszS+AEWGvYCTTijnLQUskBmxS7kx6KEzUaY9XsJvZxmSGy8kXmr2jvW/MCPgWo3PkWr mKwDxf4oaCJ5BO+9K1cpJlesU1yXH4uPi2zIWgdPiI6jYOeoi6o5lvXAuRhUZ6xf65vS xFUAj5PsMn39qNKFq7VWQzZaInAbK4iXxXSDKn6aABUrVxpd9LAt/RoPo7jIw9ICgGbm DULw1jD2c1z6A6mCr/7W0MqupVZ7QMldFyjruZeCcgLo4GsbvUC/QSbTX9QJqJpF/YBG jLhQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=W7AdAkzp; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f16si294873edx.474.2022.01.26.14.37.46; Wed, 26 Jan 2022 14:38:14 -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=@amd.com header.s=selector1 header.b=W7AdAkzp; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229996AbiAZUKN (ORCPT + 99 others); Wed, 26 Jan 2022 15:10:13 -0500 Received: from mail-mw2nam12on2065.outbound.protection.outlook.com ([40.107.244.65]:63104 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229849AbiAZUKM (ORCPT ); Wed, 26 Jan 2022 15:10:12 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fwxml2L+Pgf1u2vwYL9zKLcKf3ok2Aa+upw8c2+Dq9qQkDyLZWYmSC2a8idc5LNTeOy5HImm1Fvn4mVgxVwbSoztfB+qwHGoq7ts2viHZYU1B7mhX1kJTE7g7lqLVsrOJyuLHU5eunui/WG0lGY7TbllcxhtuAX281wuxUMFUeh3w9ZW4CcgmRzkJ05R0xgi4AIcGS3lxg7E7ANT5sXtVKGUpSfyIn/ImQQSgBUWWZDY8gD3cD8wfbrc55QJtzIwncQc2mtUob1CAgkgUMKnTy+P8QEx4UUY/b0o75nix0/59jbvhuwYHiXrr2l70hkWWvqi1RV4W0J47HYSzCOj0g== 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=Fvn2y1S+JopDKqdRGcRcHDiIgbS9s7h5z0hvdyg5AbU=; b=SsL9lZSPZ3hggojxoJ3atOkQNagnsTitLqBmp5v6Yex1uObpUTCuiu4/TjnHNhjzOYEBwK5/xmc0eyvg4TnCmjGy09yAOhW2g0nJQBr1EnoXBuwG1kM4TEws48+W4FMbPKUdmhZKC2aTt+Jn8mU8vkKHSzuFo38cgQvOlgcfppwWs+MlrgG0bbvGdt7PXO26kSp1PzuzEhd/jeL3/4z1BkMYr9nAb4qR2IeldaVbqfJomsMnC2eN7LHxTBDHOC+NV9z6p6P3AQhXXfKHCditS365y0BIHLo9XqhqFZMRMZ3VbRy+YVN8ZAIzoS8IOp0s2Sy7q+89QkO9SFE6mYiYxQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linaro.org 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 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=Fvn2y1S+JopDKqdRGcRcHDiIgbS9s7h5z0hvdyg5AbU=; b=W7AdAkzpuNdhwWZpfeUqVhAWm7THHWl/3FXOpeJIsWjrigVtUhlOwgSD1nG6FxpTj+vdIR2TsWqquwBsSSs9jZ9Mbbk91Zvb+RX8cUzlIdddiT7qM2SCVZ4jy3tjr8TsHPl92lvwxSu43GYxSNUihQpZRIdqRd05Skv+WA5IsOE= Received: from DM5PR07CA0072.namprd07.prod.outlook.com (2603:10b6:4:ad::37) by CH2PR12MB5563.namprd12.prod.outlook.com (2603:10b6:610:6a::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Wed, 26 Jan 2022 20:10:02 +0000 Received: from DM6NAM11FT025.eop-nam11.prod.protection.outlook.com (2603:10b6:4:ad:cafe::7) by DM5PR07CA0072.outlook.office365.com (2603:10b6:4:ad::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Wed, 26 Jan 2022 20:10:02 +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; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT025.mail.protection.outlook.com (10.13.172.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4930.15 via Frontend Transport; Wed, 26 Jan 2022 20:10:01 +0000 Received: from ethanolx1ade-milan-b0-babu.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.2375.18; Wed, 26 Jan 2022 14:10:00 -0600 From: Carlos Bilbao To: , CC: , , , , , , , , , , , , , , Carlos Bilbao Subject: [PATCH] include: linux: Reorganize timekeeping and ktime headers Date: Wed, 26 Jan 2022 14:07:50 -0600 Message-ID: <20220126200749.12090-1-carlos.bilbao@amd.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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-Office365-Filtering-Correlation-Id: 1bc99a61-e615-4342-856f-08d9e107d5e5 X-MS-TrafficTypeDiagnostic: CH2PR12MB5563:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DVXs57/exLvY/scSDPDso3VeQAy071cSdHv8BOz986c9yhItk2C9sTdLK5lzwmG/SAFPMr5eUHyGr6TDODQwBb+zkSSQEGSUhXfk2piz20DHEkGcMEGsMkY9/xFheX+y+xSGPZg/tC1VRmfi2MIbDii6ItCaYgMGuX6EBNmQ4G/CRR57Y0J8Jxut8ZqU6ScSLBoNdwqwE5PWdV2GU7UFDSTxC/eGxZQGTKdHSD4z/8iWa4Pm9Avy5a3+zIJzKtiCmc7PHpbo96u+6SvHMhMJScmIUYItjmcVrf1wk7Qlv+1/qwCrbisjC+w6QB0zwOsOY77td2p99iIK1SpURS/KXV8oNPIAdp/aMVTDN9mlzjmcKL1tplWAdudsoEnaCqjrJysyGWGYg3R4uWzVpRaT5ZYrJMD4WkKJ/gnnUeLUflDXRcl/iWbc4jxMDpU/SdeqX1VuNgjpIbtYzjR26pZF8lIqCqlAfquYqgSMvFMma1+VHJxYEv8tc7XC6lkHBTCyabhyjX1CDODcnv791CAwgmA6LPNnhJMPRmsXHkWQftbIvwzC1bwWvryr4MLGZaodi4NiBZl2fXFHm4fULtK8KNy/rQv0JY83rIT/2mOUJ3ES5mipy3yCI4XYhf6/uLmoGU0FLuDr1vHFfJy6/E3TtqsYuWS3bfn7hvPGPlPhbrRdyKLqM8NcL53s9lpFCY8aEvBjO25U4R22kpSom59i4A== 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:(13230001)(4636009)(36840700001)(46966006)(40470700004)(47076005)(508600001)(1076003)(2616005)(82310400004)(4326008)(86362001)(6666004)(40460700003)(186003)(36860700001)(7696005)(426003)(16526019)(83380400001)(26005)(36756003)(336012)(356005)(5660300002)(54906003)(110136005)(7416002)(44832011)(316002)(70586007)(30864003)(8676002)(8936002)(2906002)(81166007)(70206006)(36900700001)(20210929001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2022 20:10:01.8151 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1bc99a61-e615-4342-856f-08d9e107d5e5 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: DM6NAM11FT025.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB5563 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The timekeeping subsystem could use some reorganization. Reorganize and separate the headers by making ktime.h take care of the ktime_get() family of functions, and reserve timekeeping.h for the actual timekeeping. This also helps to avoid implicit function errors and strengthens the header dependencies, since timekeeping.h was using ktime_to_ns(), a static function defined in a header it does no include, ktime.h. This patch also includes the header timekeeping.h wherever it is necessary for a successful compilation after the header code reorganization for all archs. Signed-off-by: Carlos Bilbao Acked-by: Geert Uytterhoeven --- arch/arm64/kvm/hypercalls.c | 1 + arch/ia64/kernel/time.c | 1 + arch/m68k/atari/time.c | 1 + arch/m68k/hp300/time.c | 2 + arch/m68k/mac/via.c | 1 + arch/m68k/mvme16x/config.c | 1 + arch/m68k/sun3/sun3ints.c | 1 + arch/powerpc/kernel/time.c | 1 + arch/x86/kernel/rtc.c | 1 + arch/x86/kernel/tsc.c | 1 + drivers/rtc/class.c | 1 + include/linux/ktime.h | 196 +++++++++++++++++++++++++++++++- include/linux/pps_kernel.h | 1 + include/linux/sched_clock.h | 2 + include/linux/stmmac.h | 1 + include/linux/timekeeping.h | 197 +-------------------------------- init/main.c | 1 + kernel/time/ntp.c | 1 + kernel/time/posix-timers.c | 1 + kernel/time/tick-legacy.c | 1 + kernel/time/time.c | 1 + kernel/time/timekeeping.c | 1 + sound/pci/hda/hda_controller.c | 1 + 23 files changed, 218 insertions(+), 198 deletions(-) diff --git a/arch/arm64/kvm/hypercalls.c b/arch/arm64/kvm/hypercalls.c index 30da78f72b3b..41499c1d7379 100644 --- a/arch/arm64/kvm/hypercalls.c +++ b/arch/arm64/kvm/hypercalls.c @@ -3,6 +3,7 @@ #include #include +#include #include diff --git a/arch/ia64/kernel/time.c b/arch/ia64/kernel/time.c index fa9c0ab8c6fc..85e79ff3c98e 100644 --- a/arch/ia64/kernel/time.c +++ b/arch/ia64/kernel/time.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include diff --git a/arch/m68k/atari/time.c b/arch/m68k/atari/time.c index 7e44d0e9d0f8..b09d3ff40b36 100644 --- a/arch/m68k/atari/time.c +++ b/arch/m68k/atari/time.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include diff --git a/arch/m68k/hp300/time.c b/arch/m68k/hp300/time.c index 1d1b7b3b5dd4..56c575096bcb 100644 --- a/arch/m68k/hp300/time.c +++ b/arch/m68k/hp300/time.c @@ -14,6 +14,8 @@ #include #include #include +#include + #include #include #include diff --git a/arch/m68k/mac/via.c b/arch/m68k/mac/via.c index 3d11d6219cdd..6dd8f85288e4 100644 --- a/arch/m68k/mac/via.c +++ b/arch/m68k/mac/via.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include diff --git a/arch/m68k/mvme16x/config.c b/arch/m68k/mvme16x/config.c index b4422c2dfbbf..ebe1dc3ebb4c 100644 --- a/arch/m68k/mvme16x/config.c +++ b/arch/m68k/mvme16x/config.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include diff --git a/arch/m68k/sun3/sun3ints.c b/arch/m68k/sun3/sun3ints.c index 36cc280a4505..209dccc2aed6 100644 --- a/arch/m68k/sun3/sun3ints.c +++ b/arch/m68k/sun3/sun3ints.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index cae8f03a44fe..b577a5a06621 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c @@ -54,6 +54,7 @@ #include #include #include +#include #include #include diff --git a/arch/x86/kernel/rtc.c b/arch/x86/kernel/rtc.c index 586f718b8e95..98ea05cc6aeb 100644 --- a/arch/x86/kernel/rtc.c +++ b/arch/x86/kernel/rtc.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index a698196377be..add4388283c5 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c index 4b460c61f1d8..7e2bce8cf0b1 100644 --- a/drivers/rtc/class.c +++ b/drivers/rtc/class.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include "rtc-core.h" diff --git a/include/linux/ktime.h b/include/linux/ktime.h index 73f20deb497d..07971008b795 100644 --- a/include/linux/ktime.h +++ b/include/linux/ktime.h @@ -229,6 +229,198 @@ static inline ktime_t ms_to_ktime(u64 ms) return ms * NSEC_PER_MSEC; } -# include +/* + * ktime_get() family: read the current time in a multitude of ways, + * + * The default time reference is CLOCK_MONOTONIC, starting at + * boot time but not counting the time spent in suspend. + * For other references, use the functions with "real", "clocktai", + * "boottime" and "raw" suffixes. + * + * To get the time in a different format, use the ones wit + * "ns", "ts64" and "seconds" suffix. + * + * See Documentation/core-api/timekeeping.rst for more details. + */ -#endif + +/* + * timespec64 based interfaces + */ +extern void ktime_get_raw_ts64(struct timespec64 *ts); +extern void ktime_get_ts64(struct timespec64 *ts); +extern void ktime_get_real_ts64(struct timespec64 *tv); +extern void ktime_get_coarse_ts64(struct timespec64 *ts); +extern void ktime_get_coarse_real_ts64(struct timespec64 *ts); + +void getboottime64(struct timespec64 *ts); + +/* + * time64_t base interfaces + */ +extern time64_t ktime_get_seconds(void); +extern time64_t __ktime_get_real_seconds(void); +extern time64_t ktime_get_real_seconds(void); + +/* + * ktime_t based interfaces + */ + +enum tk_offsets { + TK_OFFS_REAL, + TK_OFFS_BOOT, + TK_OFFS_TAI, + TK_OFFS_MAX, +}; + +extern ktime_t ktime_get(void); +extern ktime_t ktime_get_with_offset(enum tk_offsets offs); +extern ktime_t ktime_get_coarse_with_offset(enum tk_offsets offs); +extern ktime_t ktime_mono_to_any(ktime_t tmono, enum tk_offsets offs); +extern ktime_t ktime_get_raw(void); +extern u32 ktime_get_resolution_ns(void); + +/** + * ktime_get_real - get the real (wall-) time in ktime_t format + */ +static inline ktime_t ktime_get_real(void) +{ + return ktime_get_with_offset(TK_OFFS_REAL); +} + +static inline ktime_t ktime_get_coarse_real(void) +{ + return ktime_get_coarse_with_offset(TK_OFFS_REAL); +} + +/** + * ktime_get_boottime - Returns monotonic time since boot in ktime_t format + * + * This is similar to CLOCK_MONTONIC/ktime_get, but also includes the + * time spent in suspend. + */ +static inline ktime_t ktime_get_boottime(void) +{ + return ktime_get_with_offset(TK_OFFS_BOOT); +} + +static inline ktime_t ktime_get_coarse_boottime(void) +{ + return ktime_get_coarse_with_offset(TK_OFFS_BOOT); +} + +/** + * ktime_get_clocktai - Returns the TAI time of day in ktime_t format + */ +static inline ktime_t ktime_get_clocktai(void) +{ + return ktime_get_with_offset(TK_OFFS_TAI); +} + +static inline ktime_t ktime_get_coarse_clocktai(void) +{ + return ktime_get_coarse_with_offset(TK_OFFS_TAI); +} + +static inline ktime_t ktime_get_coarse(void) +{ + struct timespec64 ts; + + ktime_get_coarse_ts64(&ts); + return timespec64_to_ktime(ts); +} + +static inline u64 ktime_get_coarse_ns(void) +{ + return ktime_to_ns(ktime_get_coarse()); +} + +static inline u64 ktime_get_coarse_real_ns(void) +{ + return ktime_to_ns(ktime_get_coarse_real()); +} + +static inline u64 ktime_get_coarse_boottime_ns(void) +{ + return ktime_to_ns(ktime_get_coarse_boottime()); +} + +static inline u64 ktime_get_coarse_clocktai_ns(void) +{ + return ktime_to_ns(ktime_get_coarse_clocktai()); +} + +/** + * ktime_mono_to_real - Convert monotonic time to clock realtime + */ +static inline ktime_t ktime_mono_to_real(ktime_t mono) +{ + return ktime_mono_to_any(mono, TK_OFFS_REAL); +} + +static inline u64 ktime_get_ns(void) +{ + return ktime_to_ns(ktime_get()); +} + +static inline u64 ktime_get_real_ns(void) +{ + return ktime_to_ns(ktime_get_real()); +} + +static inline u64 ktime_get_boottime_ns(void) +{ + return ktime_to_ns(ktime_get_boottime()); +} + +static inline u64 ktime_get_clocktai_ns(void) +{ + return ktime_to_ns(ktime_get_clocktai()); +} + +static inline u64 ktime_get_raw_ns(void) +{ + return ktime_to_ns(ktime_get_raw()); +} + +extern u64 ktime_get_mono_fast_ns(void); +extern u64 ktime_get_raw_fast_ns(void); +extern u64 ktime_get_boot_fast_ns(void); +extern u64 ktime_get_real_fast_ns(void); + +/* + * timespec64/time64_t interfaces utilizing the ktime based ones + * for API completeness, these could be implemented more efficiently + * if needed. + */ +static inline void ktime_get_boottime_ts64(struct timespec64 *ts) +{ + *ts = ktime_to_timespec64(ktime_get_boottime()); +} + +static inline void ktime_get_coarse_boottime_ts64(struct timespec64 *ts) +{ + *ts = ktime_to_timespec64(ktime_get_coarse_boottime()); +} + +static inline time64_t ktime_get_boottime_seconds(void) +{ + return ktime_divns(ktime_get_coarse_boottime(), NSEC_PER_SEC); +} + +static inline void ktime_get_clocktai_ts64(struct timespec64 *ts) +{ + *ts = ktime_to_timespec64(ktime_get_clocktai()); +} + +static inline void ktime_get_coarse_clocktai_ts64(struct timespec64 *ts) +{ + *ts = ktime_to_timespec64(ktime_get_coarse_clocktai()); +} + +static inline time64_t ktime_get_clocktai_seconds(void) +{ + return ktime_divns(ktime_get_coarse_clocktai(), NSEC_PER_SEC); +} + +#endif /* _LINUX_KTIME_H */ diff --git a/include/linux/pps_kernel.h b/include/linux/pps_kernel.h index 78c8ac4951b5..24970c202ac6 100644 --- a/include/linux/pps_kernel.h +++ b/include/linux/pps_kernel.h @@ -12,6 +12,7 @@ #include #include #include +#include /* * Global defines diff --git a/include/linux/sched_clock.h b/include/linux/sched_clock.h index 835ee87ed792..f0fa287710da 100644 --- a/include/linux/sched_clock.h +++ b/include/linux/sched_clock.h @@ -5,6 +5,8 @@ #ifndef LINUX_SCHED_CLOCK #define LINUX_SCHED_CLOCK +#include + #ifdef CONFIG_GENERIC_SCHED_CLOCK /** * struct clock_read_data - data required to read from sched_clock() diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h index a6f03b36fc4f..bf235ff101d5 100644 --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h @@ -14,6 +14,7 @@ #include #include +#include #define MTL_MAX_RX_QUEUES 8 #define MTL_MAX_TX_QUEUES 8 diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h index 78a98bdff76d..b1c54f5ff91e 100644 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h @@ -19,201 +19,6 @@ extern void legacy_timer_tick(unsigned long ticks); extern int do_settimeofday64(const struct timespec64 *ts); extern int do_sys_settimeofday64(const struct timespec64 *tv, const struct timezone *tz); - -/* - * ktime_get() family: read the current time in a multitude of ways, - * - * The default time reference is CLOCK_MONOTONIC, starting at - * boot time but not counting the time spent in suspend. - * For other references, use the functions with "real", "clocktai", - * "boottime" and "raw" suffixes. - * - * To get the time in a different format, use the ones wit - * "ns", "ts64" and "seconds" suffix. - * - * See Documentation/core-api/timekeeping.rst for more details. - */ - - -/* - * timespec64 based interfaces - */ -extern void ktime_get_raw_ts64(struct timespec64 *ts); -extern void ktime_get_ts64(struct timespec64 *ts); -extern void ktime_get_real_ts64(struct timespec64 *tv); -extern void ktime_get_coarse_ts64(struct timespec64 *ts); -extern void ktime_get_coarse_real_ts64(struct timespec64 *ts); - -void getboottime64(struct timespec64 *ts); - -/* - * time64_t base interfaces - */ -extern time64_t ktime_get_seconds(void); -extern time64_t __ktime_get_real_seconds(void); -extern time64_t ktime_get_real_seconds(void); - -/* - * ktime_t based interfaces - */ - -enum tk_offsets { - TK_OFFS_REAL, - TK_OFFS_BOOT, - TK_OFFS_TAI, - TK_OFFS_MAX, -}; - -extern ktime_t ktime_get(void); -extern ktime_t ktime_get_with_offset(enum tk_offsets offs); -extern ktime_t ktime_get_coarse_with_offset(enum tk_offsets offs); -extern ktime_t ktime_mono_to_any(ktime_t tmono, enum tk_offsets offs); -extern ktime_t ktime_get_raw(void); -extern u32 ktime_get_resolution_ns(void); - -/** - * ktime_get_real - get the real (wall-) time in ktime_t format - */ -static inline ktime_t ktime_get_real(void) -{ - return ktime_get_with_offset(TK_OFFS_REAL); -} - -static inline ktime_t ktime_get_coarse_real(void) -{ - return ktime_get_coarse_with_offset(TK_OFFS_REAL); -} - -/** - * ktime_get_boottime - Returns monotonic time since boot in ktime_t format - * - * This is similar to CLOCK_MONTONIC/ktime_get, but also includes the - * time spent in suspend. - */ -static inline ktime_t ktime_get_boottime(void) -{ - return ktime_get_with_offset(TK_OFFS_BOOT); -} - -static inline ktime_t ktime_get_coarse_boottime(void) -{ - return ktime_get_coarse_with_offset(TK_OFFS_BOOT); -} - -/** - * ktime_get_clocktai - Returns the TAI time of day in ktime_t format - */ -static inline ktime_t ktime_get_clocktai(void) -{ - return ktime_get_with_offset(TK_OFFS_TAI); -} - -static inline ktime_t ktime_get_coarse_clocktai(void) -{ - return ktime_get_coarse_with_offset(TK_OFFS_TAI); -} - -static inline ktime_t ktime_get_coarse(void) -{ - struct timespec64 ts; - - ktime_get_coarse_ts64(&ts); - return timespec64_to_ktime(ts); -} - -static inline u64 ktime_get_coarse_ns(void) -{ - return ktime_to_ns(ktime_get_coarse()); -} - -static inline u64 ktime_get_coarse_real_ns(void) -{ - return ktime_to_ns(ktime_get_coarse_real()); -} - -static inline u64 ktime_get_coarse_boottime_ns(void) -{ - return ktime_to_ns(ktime_get_coarse_boottime()); -} - -static inline u64 ktime_get_coarse_clocktai_ns(void) -{ - return ktime_to_ns(ktime_get_coarse_clocktai()); -} - -/** - * ktime_mono_to_real - Convert monotonic time to clock realtime - */ -static inline ktime_t ktime_mono_to_real(ktime_t mono) -{ - return ktime_mono_to_any(mono, TK_OFFS_REAL); -} - -static inline u64 ktime_get_ns(void) -{ - return ktime_to_ns(ktime_get()); -} - -static inline u64 ktime_get_real_ns(void) -{ - return ktime_to_ns(ktime_get_real()); -} - -static inline u64 ktime_get_boottime_ns(void) -{ - return ktime_to_ns(ktime_get_boottime()); -} - -static inline u64 ktime_get_clocktai_ns(void) -{ - return ktime_to_ns(ktime_get_clocktai()); -} - -static inline u64 ktime_get_raw_ns(void) -{ - return ktime_to_ns(ktime_get_raw()); -} - -extern u64 ktime_get_mono_fast_ns(void); -extern u64 ktime_get_raw_fast_ns(void); -extern u64 ktime_get_boot_fast_ns(void); -extern u64 ktime_get_real_fast_ns(void); - -/* - * timespec64/time64_t interfaces utilizing the ktime based ones - * for API completeness, these could be implemented more efficiently - * if needed. - */ -static inline void ktime_get_boottime_ts64(struct timespec64 *ts) -{ - *ts = ktime_to_timespec64(ktime_get_boottime()); -} - -static inline void ktime_get_coarse_boottime_ts64(struct timespec64 *ts) -{ - *ts = ktime_to_timespec64(ktime_get_coarse_boottime()); -} - -static inline time64_t ktime_get_boottime_seconds(void) -{ - return ktime_divns(ktime_get_coarse_boottime(), NSEC_PER_SEC); -} - -static inline void ktime_get_clocktai_ts64(struct timespec64 *ts) -{ - *ts = ktime_to_timespec64(ktime_get_clocktai()); -} - -static inline void ktime_get_coarse_clocktai_ts64(struct timespec64 *ts) -{ - *ts = ktime_to_timespec64(ktime_get_coarse_clocktai()); -} - -static inline time64_t ktime_get_clocktai_seconds(void) -{ - return ktime_divns(ktime_get_coarse_clocktai(), NSEC_PER_SEC); -} - /* * RTC specific */ @@ -308,4 +113,4 @@ void read_persistent_wall_and_boot_offset(struct timespec64 *wall_clock, extern int update_persistent_clock64(struct timespec64 now); #endif -#endif +#endif /* _LINUX_TIMEKEEPING_H */ diff --git a/init/main.c b/init/main.c index bb984ed79de0..6a6f85e9404f 100644 --- a/init/main.c +++ b/init/main.c @@ -99,6 +99,7 @@ #include #include #include +#include #include #include diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index 406dccb79c2b..804f06801737 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "ntp_internal.h" #include "timekeeping_internal.h" diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index 1cd10b102c51..410a9336748e 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include diff --git a/kernel/time/tick-legacy.c b/kernel/time/tick-legacy.c index af225b32f5b3..9a534f716462 100644 --- a/kernel/time/tick-legacy.c +++ b/kernel/time/tick-legacy.c @@ -7,6 +7,7 @@ #include #include #include +#include #include "tick-internal.h" diff --git a/kernel/time/time.c b/kernel/time/time.c index 29923b20e0e4..7292ed074742 100644 --- a/kernel/time/time.c +++ b/kernel/time/time.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index b348749a9fc6..d234cb8a97fe 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "tick-internal.h" #include "ntp_internal.h" diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c index 930ae4002a81..8014f02e4443 100644 --- a/sound/pci/hda/hda_controller.c +++ b/sound/pci/hda/hda_controller.c @@ -16,6 +16,7 @@ #include #include #include +#include #ifdef CONFIG_X86 /* for art-tsc conversion */ -- 2.27.0