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
(cherry picked from commit ce90abdb8137610988f291cd02ed8cf97bca673f)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3499760
Reviewed-by: Brad Griffis <bgriffis@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Tested-by: Brad Griffis <bgriffis@nvidia.com>
This commit is contained in:
Jon Hunter
2025-04-08 13:30:51 +01:00
committed by mobile promotions
parent 48373c24ad
commit 2ec6cdcc9b
10 changed files with 95 additions and 4 deletions

View File

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

View File

@@ -1776,9 +1776,14 @@ static int cdi_mgr_probe(struct platform_device *pdev)
for (i = 0; i < ARRAY_SIZE(cdi_mgr->gpios); i++) {
pin = &cdi_mgr->gpios[i];
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_MODE_ABS);
pin->timers.timer.function = &cdi_mgr_intr_timer;
#endif
}
if (pdev->dev.of_node) {

View File

@@ -3,8 +3,6 @@
#include <nvidia/conftest.h>
#include <nvidia/conftest.h>
#include <linux/uaccess.h>
#include <linux/module.h>
#include <linux/proc_fs.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->ext_wake, 1);
__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);
#endif
set_bit(BT_WAKE, &bluedroid_pm->flags);
} else {
kfree(buf);
@@ -539,7 +541,11 @@ static int bluedroid_pm_remove(struct platform_device *pdev)
wakeup_source_destroy(&bluedroid_pm->wake_lock);
gpio_free(bluedroid_pm->ext_wake);
remove_bt_proc_interface();
#if defined(NV_TIMER_DELETE_PRESENT) /* Linux v6.15 */
timer_delete(&bluedroid_pm_timer);
#else
del_timer(&bluedroid_pm_timer);
#endif
}
if ((gpio_is_valid(bluedroid_pm->gpio_reset)) ||
(gpio_is_valid(bluedroid_pm->gpio_shutdown)) ||

View File

@@ -1933,7 +1933,11 @@ static int mttcan_remove(struct platform_device *pdev)
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);
#endif
mttcan_delete_sys_files(&dev->dev);
unregister_mttcan_dev(dev);
mttcan_unprepare_clock(priv);

View File

@@ -2956,7 +2956,11 @@ static int ether_close(struct net_device *ndev)
int i;
#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);
#endif
/* TODO: purge the queues */
#endif
@@ -6669,10 +6673,16 @@ static int ether_probe(struct platform_device *pdev)
chan = osi_dma->dma_chans[i];
atomic_set(&pdata->tx_napi[chan]->tx_usecs_timer_armed,
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,
CLOCK_MONOTONIC, HRTIMER_MODE_REL);
pdata->tx_napi[chan]->tx_usecs_timer.function =
ether_tx_usecs_hrtimer;
#endif
}
ret = register_netdev(ndev);

View File

@@ -449,7 +449,11 @@ static int set_mode(struct nvpps_device_data *pdev_data, u32 mode)
if (!pdev_data->only_timer_mode) {
if (pdev_data->timer_inited) {
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);
#endif
}
if (!pdev_data->irq_registered) {
/* register IRQ handler */
@@ -1130,7 +1134,11 @@ static int nvpps_remove(struct platform_device *pdev)
if (pdev_data) {
if (pdev_data->timer_inited) {
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);
#endif
}
if (pdev_data->mac_base_addr) {
devm_iounmap(&pdev->dev, pdev_data->mac_base_addr);
@@ -1138,7 +1146,11 @@ static int nvpps_remove(struct platform_device *pdev)
pdev_data->mac_base_addr);
}
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);
#endif
iounmap(pdev_data->tsc_reg_map_base);
}
device_destroy(s_nvpps_class, pdev_data->dev->devt);

View File

@@ -139,9 +139,14 @@ static int tegra_hv_vcpu_yield_open(struct inode *inode, struct file *filp)
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_MODE_REL_PINNED);
data->yield_timer.function = &timer_callback_func;
#endif
out:
return ret;

View File

@@ -1,8 +1,7 @@
// 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
*
* SPDX-FileCopyrightText: Copyright (c) 2014-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*/
#include <nvidia/conftest.h>
@@ -186,7 +185,11 @@ static int softdog_platform_probe(struct platform_device *pdev)
reboot_unreg:
unregister_reboot_notifier(&swdt->nb);
timer_del:
#if defined(NV_TIMER_DELETE_PRESENT) /* Linux v6.15 */
timer_delete_sync(&swdt->watchdog_ticktock);
#else
del_timer_sync(&swdt->watchdog_ticktock);
#endif
return ret;
}
@@ -194,7 +197,11 @@ static int softdog_platform_remove(struct platform_device *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);
#endif
watchdog_unregister_device(&swdt->wdt_dev);
unregister_reboot_notifier(&swdt->nb);
return 0;
@@ -204,7 +211,11 @@ static void softdog_platform_shutdown(struct platform_device *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);
#endif
}
#ifdef CONFIG_PM_SLEEP

View File

@@ -139,6 +139,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 += get_file_rcu_has_double_ptr_file_arg
NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_user_pages
NV_CONFTEST_FUNCTION_COMPILE_TESTS += hrtimer_setup
NV_CONFTEST_FUNCTION_COMPILE_TESTS += i2c_driver_struct_probe_without_i2c_device_id_arg
NV_CONFTEST_FUNCTION_COMPILE_TESTS += i2c_driver_struct_has_probe_new
NV_CONFTEST_FUNCTION_COMPILE_TESTS += i2c_driver_struct_remove_return_type_int
@@ -194,6 +195,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += tegra_dev_iommu_get_stream_id
NV_CONFTEST_FUNCTION_COMPILE_TESTS += tegra_ivc_struct_has_iosys_map
NV_CONFTEST_FUNCTION_COMPILE_TESTS += thermal_zone_device_priv
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_write_has_u8_ptr_arg
NV_CONFTEST_FUNCTION_COMPILE_TESTS += tty_operations_struct_set_termios_has_const_ktermios_arg

View File

@@ -7496,6 +7496,22 @@ compile_test() {
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)
#
# Determine if netif_set_tso_max_size() function is present
@@ -8302,6 +8318,22 @@ compile_test() {
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)
#
# Determine if the struct tty_operations::send_xchar argument is of type u8.