drivers: Update timer APIs for Linux v6.15

In Linux v6.15, the timer APIs hrtimer_init() and del_timer() have been
removed. The hrtimer_setup() was added in Linux v6.13 to replace
hrtimer_init() and hrtimer_init() have finally been removed. The
functions del_timer()/del_timer_sync() were renamed to
timer_delete()/timer_delete_sync() in Linux v6.15. Use conftest to
detect these changes and update the drivers as necessary.

JIRA LINQPJ14-47

Change-Id: Id3994900384aad4b91155507cda91e04898ab12c
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3336168
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: Brad Griffis <bgriffis@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
This commit is contained in:
Jon Hunter
2025-04-08 13:30:51 +01:00
parent 1d9d3c1755
commit a59a10dfeb
13 changed files with 125 additions and 23 deletions

View File

@@ -193,7 +193,11 @@ static void vblk_put_req(struct vsc_request *req)
(vblkdev->queue_state == VBLK_QUEUE_SUSPENDED)) { (vblkdev->queue_state == VBLK_QUEUE_SUSPENDED)) {
complete(&vblkdev->req_queue_empty); complete(&vblkdev->req_queue_empty);
} }
#if defined(NV_TIMER_DELETE_PRESENT) /* Linux v6.15 */
timer_delete(&req->timer);
#else
del_timer(&req->timer); del_timer(&req->timer);
#endif
} }
} }

View File

@@ -1,5 +1,8 @@
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
// SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. // SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#include <nvidia/conftest.h>
#include "dev.h" #include "dev.h"
#include "fence.h" #include "fence.h"
#include "poll.h" #include "poll.h"
@@ -178,8 +181,13 @@ void host1x_poll_start(struct host1x *host)
hr_timer_host = host; hr_timer_host = host;
ktime = ktime_set(HRTIMER_TIMEOUT_SEC, host->hr_polling_intrval); ktime = ktime_set(HRTIMER_TIMEOUT_SEC, host->hr_polling_intrval);
#if defined(NV_HRTIMER_SETUP_PRESENT) /* Linux v6.13 */
hrtimer_setup(&emu_hr_timer, &timer_callback, CLOCK_MONOTONIC,
HRTIMER_MODE_REL);
#else
hrtimer_init(&emu_hr_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); hrtimer_init(&emu_hr_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
emu_hr_timer.function = &timer_callback; emu_hr_timer.function = &timer_callback;
#endif
hrtimer_start(&emu_hr_timer, ktime, HRTIMER_MODE_REL); hrtimer_start(&emu_hr_timer, ktime, HRTIMER_MODE_REL);
} }
#endif #endif

View File

@@ -1782,9 +1782,14 @@ static int cdi_mgr_probe(struct platform_device *pdev)
for (i = 0; i < ARRAY_SIZE(cdi_mgr->gpios); i++) { for (i = 0; i < ARRAY_SIZE(cdi_mgr->gpios); i++) {
pin = &cdi_mgr->gpios[i]; pin = &cdi_mgr->gpios[i];
pin->mgr = cdi_mgr; pin->mgr = cdi_mgr;
#if defined(NV_HRTIMER_SETUP_PRESENT) /* Linux v6.13 */
hrtimer_setup(&pin->timers.timer, &cdi_mgr_intr_timer,
CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
#else
hrtimer_init(&pin->timers.timer, CLOCK_MONOTONIC, hrtimer_init(&pin->timers.timer, CLOCK_MONOTONIC,
HRTIMER_MODE_ABS); HRTIMER_MODE_ABS);
pin->timers.timer.function = &cdi_mgr_intr_timer; pin->timers.timer.function = &cdi_mgr_intr_timer;
#endif
} }
if (pdev->dev.of_node) { if (pdev->dev.of_node) {

View File

@@ -36,6 +36,8 @@
#include <linux/miscdevice.h> #include <linux/miscdevice.h>
#include "v4l2loopback.h" #include "v4l2loopback.h"
#include <nvidia/conftest.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0) #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)
#error This module is not supported on kernels before 4.0.0. #error This module is not supported on kernels before 4.0.0.
#endif #endif
@@ -1706,8 +1708,13 @@ static int vidioc_querybuf(struct file *file, void *fh, struct v4l2_buffer *b)
static void buffer_written(struct v4l2_loopback_device *dev, static void buffer_written(struct v4l2_loopback_device *dev,
struct v4l2l_buffer *buf) struct v4l2l_buffer *buf)
{ {
#if defined(NV_TIMER_DELETE_PRESENT) /* Linux v6.15 */
timer_delete_sync(&dev->sustain_timer);
timer_delete_sync(&dev->timeout_timer);
#else
del_timer_sync(&dev->sustain_timer); del_timer_sync(&dev->sustain_timer);
del_timer_sync(&dev->timeout_timer); del_timer_sync(&dev->timeout_timer);
#endif
spin_lock_bh(&dev->list_lock); spin_lock_bh(&dev->list_lock);
list_move_tail(&buf->list_head, &dev->outbufs_list); list_move_tail(&buf->list_head, &dev->outbufs_list);
@@ -2274,8 +2281,13 @@ static int v4l2_loopback_close(struct file *file)
atomic_dec(&dev->open_count); atomic_dec(&dev->open_count);
if (dev->open_count.counter == 0) { if (dev->open_count.counter == 0) {
#if defined(NV_TIMER_DELETE_PRESENT) /* Linux v6.15 */
timer_delete_sync(&dev->sustain_timer);
timer_delete_sync(&dev->timeout_timer);
#else
del_timer_sync(&dev->sustain_timer); del_timer_sync(&dev->sustain_timer);
del_timer_sync(&dev->timeout_timer); del_timer_sync(&dev->timeout_timer);
#endif
} }
try_free_buffers(dev); try_free_buffers(dev);

View File

@@ -1,7 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
// SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. // SPDX-FileCopyrightText: Copyright (c) 2019-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#include <nvidia/conftest.h>
#include <nvidia/conftest.h> #include <nvidia/conftest.h>
@@ -267,7 +265,11 @@ static ssize_t lpm_write_proc(struct file *file, const char __user *buffer,
bluedroid_pm_gpio_set_value( bluedroid_pm_gpio_set_value(
bluedroid_pm->ext_wake, 1); bluedroid_pm->ext_wake, 1);
__pm_stay_awake(&bluedroid_pm->wake_lock); __pm_stay_awake(&bluedroid_pm->wake_lock);
#if defined(NV_TIMER_DELETE_PRESENT) /* Linux v6.15 */
timer_delete(&bluedroid_pm_timer);
#else
del_timer(&bluedroid_pm_timer); del_timer(&bluedroid_pm_timer);
#endif
set_bit(BT_WAKE, &bluedroid_pm->flags); set_bit(BT_WAKE, &bluedroid_pm->flags);
} else { } else {
kfree(buf); kfree(buf);
@@ -507,7 +509,11 @@ static int bluedroid_pm_remove(struct platform_device *pdev)
if ((bluedroid_pm->ext_wake)) { if ((bluedroid_pm->ext_wake)) {
wakeup_source_destroy(&bluedroid_pm->wake_lock); wakeup_source_destroy(&bluedroid_pm->wake_lock);
remove_bt_proc_interface(); remove_bt_proc_interface();
#if defined(NV_TIMER_DELETE_PRESENT) /* Linux v6.15 */
timer_delete(&bluedroid_pm_timer);
#else
del_timer(&bluedroid_pm_timer); del_timer(&bluedroid_pm_timer);
#endif
} }
if (((bluedroid_pm->gpio_reset)) || if (((bluedroid_pm->gpio_reset)) ||
((bluedroid_pm->gpio_shutdown)) || ((bluedroid_pm->gpio_shutdown)) ||

View File

@@ -1,7 +1,5 @@
/* SPDX-License-Identifier: GPL-2.0-only */ // SPDX-License-Identifier: GPL-2.0-only
/* // SPDX-FileCopyrightText: Copyright (c) 2022-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*/
#include <nvidia/conftest.h> #include <nvidia/conftest.h>
@@ -1954,7 +1952,11 @@ static int mttcan_remove(struct platform_device *pdev)
dev_info(&dev->dev, "%s\n", __func__); dev_info(&dev->dev, "%s\n", __func__);
#if defined(NV_TIMER_DELETE_PRESENT) /* Linux v6.15 */
timer_delete_sync(&priv->timer);
#else
del_timer_sync(&priv->timer); del_timer_sync(&priv->timer);
#endif
mttcan_delete_sys_files(&dev->dev); mttcan_delete_sys_files(&dev->dev);
unregister_mttcan_dev(dev); unregister_mttcan_dev(dev);
mttcan_unprepare_clock(priv); mttcan_unprepare_clock(priv);

View File

@@ -3394,7 +3394,11 @@ int ether_close(struct net_device *ndev)
int i; int i;
#ifdef ETHER_NVGRO #ifdef ETHER_NVGRO
#if defined(NV_TIMER_DELETE_PRESENT) /* Linux v6.15 */
timer_delete_sync(&pdata->nvgro_timer);
#else
del_timer_sync(&pdata->nvgro_timer); del_timer_sync(&pdata->nvgro_timer);
#endif
/* TODO: purge the queues */ /* TODO: purge the queues */
#endif #endif
@@ -7514,10 +7518,16 @@ int ether_probe(struct platform_device *pdev)
chan = osi_dma->dma_chans[i]; chan = osi_dma->dma_chans[i];
atomic_set(&pdata->tx_napi[chan]->tx_usecs_timer_armed, atomic_set(&pdata->tx_napi[chan]->tx_usecs_timer_armed,
OSI_DISABLE); OSI_DISABLE);
#if defined(NV_HRTIMER_SETUP_PRESENT) /* Linux v6.13 */
hrtimer_setup(&pdata->tx_napi[chan]->tx_usecs_timer,
ether_tx_usecs_hrtimer, CLOCK_MONOTONIC,
HRTIMER_MODE_REL);
#else
hrtimer_init(&pdata->tx_napi[chan]->tx_usecs_timer, hrtimer_init(&pdata->tx_napi[chan]->tx_usecs_timer,
CLOCK_MONOTONIC, HRTIMER_MODE_REL); CLOCK_MONOTONIC, HRTIMER_MODE_REL);
pdata->tx_napi[chan]->tx_usecs_timer.function = pdata->tx_napi[chan]->tx_usecs_timer.function =
ether_tx_usecs_hrtimer; ether_tx_usecs_hrtimer;
#endif
} }
ret = register_netdev(ndev); ret = register_netdev(ndev);

View File

@@ -509,7 +509,11 @@ static int set_mode(struct nvpps_device_data *pdev_data, u32 mode)
if (!pdev_data->only_timer_mode) { if (!pdev_data->only_timer_mode) {
if (pdev_data->timer_inited) { if (pdev_data->timer_inited) {
pdev_data->timer_inited = false; pdev_data->timer_inited = false;
#if defined(NV_TIMER_DELETE_PRESENT) /* Linux v6.15 */
timer_delete_sync(&pdev_data->timer);
#else
del_timer_sync(&pdev_data->timer); del_timer_sync(&pdev_data->timer);
#endif
} }
if (!pdev_data->irq_registered) { if (!pdev_data->irq_registered) {
/* register IRQ handler */ /* register IRQ handler */
@@ -1377,7 +1381,11 @@ static int nvpps_remove(struct platform_device *pdev)
if (pdev_data) { if (pdev_data) {
if (pdev_data->timer_inited) { if (pdev_data->timer_inited) {
pdev_data->timer_inited = false; pdev_data->timer_inited = false;
#if defined(NV_TIMER_DELETE_PRESENT) /* Linux v6.15 */
timer_delete_sync(&pdev_data->timer);
#else
del_timer_sync(&pdev_data->timer); del_timer_sync(&pdev_data->timer);
#endif
} }
if (pdev_data->mac_base_addr) { if (pdev_data->mac_base_addr) {
devm_iounmap(&pdev->dev, pdev_data->mac_base_addr); devm_iounmap(&pdev->dev, pdev_data->mac_base_addr);
@@ -1385,7 +1393,11 @@ static int nvpps_remove(struct platform_device *pdev)
pdev_data->mac_base_addr); pdev_data->mac_base_addr);
} }
if (pdev_data->support_tsc) { if (pdev_data->support_tsc) {
#if defined(NV_TIMER_DELETE_PRESENT) /* Linux v6.15 */
timer_delete_sync(&pdev_data->tsc_timer);
#else
del_timer_sync(&pdev_data->tsc_timer); del_timer_sync(&pdev_data->tsc_timer);
#endif
iounmap(pdev_data->tsc_reg_map_base); iounmap(pdev_data->tsc_reg_map_base);
} }
device_destroy(s_nvpps_class, pdev_data->dev->devt); device_destroy(s_nvpps_class, pdev_data->dev->devt);

View File

@@ -1,21 +1,10 @@
// SPDX-License-Identifier: GPL-2.0-only
// SPDX-FileCopyrightText: Copyright (c) 2014-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
/* /*
* emc_dfs.c
*
* Emc dynamic frequency scaling due to APE * Emc dynamic frequency scaling due to APE
*
* Copyright (C) 2014-2020, NVIDIA Corporation. All rights reserved.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/ */
#include <nvidia/conftest.h>
#include <linux/tegra_nvadsp.h> #include <linux/tegra_nvadsp.h>
#include <linux/tick.h> #include <linux/tick.h>
#include <linux/timer.h> #include <linux/timer.h>
@@ -193,7 +182,11 @@ static void emc_dfs_disable(void)
einfo->rd_cnt = read64((u32)ABRIDGE_STATS_READ_0); einfo->rd_cnt = read64((u32)ABRIDGE_STATS_READ_0);
einfo->wr_cnt = read64((u32)ABRIDGE_STATS_WRITE_0); einfo->wr_cnt = read64((u32)ABRIDGE_STATS_WRITE_0);
#if defined(NV_TIMER_DELETE_PRESENT) /* Linux v6.15 */
timer_delete_sync(&einfo->cnt_timer);
#else
del_timer_sync(&einfo->cnt_timer); del_timer_sync(&einfo->cnt_timer);
#endif
} }
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS

View File

@@ -139,9 +139,14 @@ static int tegra_hv_vcpu_yield_open(struct inode *inode, struct file *filp)
mutex_unlock(&data->mutex_lock); mutex_unlock(&data->mutex_lock);
#if defined(NV_HRTIMER_SETUP_PRESENT) /* Linux v6.13 */
hrtimer_setup(&data->yield_timer, &timer_callback_func,
CLOCK_MONOTONIC, HRTIMER_MODE_REL_PINNED);
#else
hrtimer_init(&data->yield_timer, CLOCK_MONOTONIC, hrtimer_init(&data->yield_timer, CLOCK_MONOTONIC,
HRTIMER_MODE_REL_PINNED); HRTIMER_MODE_REL_PINNED);
data->yield_timer.function = &timer_callback_func; data->yield_timer.function = &timer_callback_func;
#endif
out: out:
return ret; return ret;

View File

@@ -1,8 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
// SPDX-FileCopyrightText: Copyright (c) 2014-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
/* /*
* A platform based Software Watchdog Device * A platform based Software Watchdog Device
*
* SPDX-FileCopyrightText: Copyright (c) 2014-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*/ */
#include <nvidia/conftest.h> #include <nvidia/conftest.h>
@@ -186,7 +185,11 @@ static int softdog_platform_probe(struct platform_device *pdev)
reboot_unreg: reboot_unreg:
unregister_reboot_notifier(&swdt->nb); unregister_reboot_notifier(&swdt->nb);
timer_del: timer_del:
#if defined(NV_TIMER_DELETE_PRESENT) /* Linux v6.15 */
timer_delete_sync(&swdt->watchdog_ticktock);
#else
del_timer_sync(&swdt->watchdog_ticktock); del_timer_sync(&swdt->watchdog_ticktock);
#endif
return ret; return ret;
} }
@@ -194,7 +197,11 @@ static int softdog_platform_remove(struct platform_device *pdev)
{ {
struct softdog_platform_wdt *swdt = platform_get_drvdata(pdev); struct softdog_platform_wdt *swdt = platform_get_drvdata(pdev);
#if defined(NV_TIMER_DELETE_PRESENT) /* Linux v6.15 */
timer_delete_sync(&swdt->watchdog_ticktock);
#else
del_timer_sync(&swdt->watchdog_ticktock); del_timer_sync(&swdt->watchdog_ticktock);
#endif
watchdog_unregister_device(&swdt->wdt_dev); watchdog_unregister_device(&swdt->wdt_dev);
unregister_reboot_notifier(&swdt->nb); unregister_reboot_notifier(&swdt->nb);
return 0; return 0;
@@ -204,7 +211,11 @@ static void softdog_platform_shutdown(struct platform_device *pdev)
{ {
struct softdog_platform_wdt *swdt = platform_get_drvdata(pdev); struct softdog_platform_wdt *swdt = platform_get_drvdata(pdev);
#if defined(NV_TIMER_DELETE_PRESENT) /* Linux v6.15 */
timer_delete_sync(&swdt->watchdog_ticktock);
#else
del_timer_sync(&swdt->watchdog_ticktock); del_timer_sync(&swdt->watchdog_ticktock);
#endif
} }
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP

View File

@@ -149,6 +149,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += fop_unsigned_offset
NV_CONFTEST_FUNCTION_COMPILE_TESTS += genpd_xlate_t_has_const_of_phandle_args NV_CONFTEST_FUNCTION_COMPILE_TESTS += genpd_xlate_t_has_const_of_phandle_args
NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_file_rcu_has_double_ptr_file_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_file_rcu_has_double_ptr_file_arg
NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_user_pages NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_user_pages
NV_CONFTEST_FUNCTION_COMPILE_TESTS += hrtimer_setup
NV_CONFTEST_FUNCTION_COMPILE_TESTS += icc_get NV_CONFTEST_FUNCTION_COMPILE_TESTS += icc_get
NV_CONFTEST_FUNCTION_COMPILE_TESTS += icc_put NV_CONFTEST_FUNCTION_COMPILE_TESTS += icc_put
NV_CONFTEST_FUNCTION_COMPILE_TESTS += icc_set_bw NV_CONFTEST_FUNCTION_COMPILE_TESTS += icc_set_bw
@@ -222,6 +223,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += tegra_ivc_use_ivc_ext_driver
NV_CONFTEST_FUNCTION_COMPILE_TESTS += thermal_zone_device_priv NV_CONFTEST_FUNCTION_COMPILE_TESTS += thermal_zone_device_priv
NV_CONFTEST_FUNCTION_COMPILE_TESTS += thermal_zone_device_ops_struct_has_get_trip_type NV_CONFTEST_FUNCTION_COMPILE_TESTS += thermal_zone_device_ops_struct_has_get_trip_type
NV_CONFTEST_FUNCTION_COMPILE_TESTS += thermal_zone_for_each_trip NV_CONFTEST_FUNCTION_COMPILE_TESTS += thermal_zone_for_each_trip
NV_CONFTEST_FUNCTION_COMPILE_TESTS += timer_delete
NV_CONFTEST_FUNCTION_COMPILE_TESTS += tty_operations_struct_send_xchar_has_u8_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += tty_operations_struct_send_xchar_has_u8_arg
NV_CONFTEST_FUNCTION_COMPILE_TESTS += tty_operations_struct_write_has_u8_ptr_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += tty_operations_struct_write_has_u8_ptr_arg
NV_CONFTEST_FUNCTION_COMPILE_TESTS += tty_operations_struct_set_termios_has_const_ktermios_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += tty_operations_struct_set_termios_has_const_ktermios_arg

View File

@@ -7682,6 +7682,22 @@ compile_test() {
compile_check_conftest "$CODE" "NV_GPIO_DEVICE_GET_CHIP_PRESENT" "" "functions" compile_check_conftest "$CODE" "NV_GPIO_DEVICE_GET_CHIP_PRESENT" "" "functions"
;; ;;
hrtimer_setup)
#
# Determine if the function hrtimer_setup() is present.
#
# This change was made in Linux v6.13 by commit 908a1d775422
# ("hrtimers: Introduce hrtimer_setup() to replace hrtimer_init()").
#
CODE="
#include <linux/hrtimer.h>
bool conftest_hrtimer_setup(void) {
return hrtimer_setup();
}"
compile_check_conftest "$CODE" "NV_HRTIMER_SETUP_PRESENT" "" "functions"
;;
netif_set_tso_max_size) netif_set_tso_max_size)
# #
# Determine if netif_set_tso_max_size() function is present # Determine if netif_set_tso_max_size() function is present
@@ -8680,6 +8696,22 @@ compile_test() {
compile_check_conftest "$CODE" "NV_TEGRA_DEV_IOMMU_GET_STREAM_ID_PRESENT" "" "functions" compile_check_conftest "$CODE" "NV_TEGRA_DEV_IOMMU_GET_STREAM_ID_PRESENT" "" "functions"
;; ;;
timer_delete)
#
# Determine if the function timer_delete() is present.
#
# This change was made in Linux v6.15 by commit 8fa7292fee5c
# ("treewide: Switch/rename to timer_delete[_sync]()").
#
CODE="
#include <linux/timer.h>
bool conftest_timer_delete(void) {
return timer_delete();
}"
compile_check_conftest "$CODE" "NV_TIMER_DELETE_PRESENT" "" "functions"
;;
tty_operations_struct_send_xchar_has_u8_arg) tty_operations_struct_send_xchar_has_u8_arg)
# #
# Determine if the struct tty_operations::send_xchar argument is of type u8. # Determine if the struct tty_operations::send_xchar argument is of type u8.