virt: tegra: Fix build for Linux v6.17

Upstream commit fc2898ea793a ("workqueue: Remove unused
work_on_cpu_safe") removed the 'work_on_cpu_safe()' function for Linux
v6.17. Fix this by open coding the 'work_on_cpu_safe()' in the Tegra HV
CPU Yield driver.

Bug 5420210

Change-Id: I3110554839853be9a906063d479539543394acbd
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3423830
(cherry picked from commit 97075404a16dc4f9d66147ae4b15a04526978e0e)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3462466
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: Brad Griffis <bgriffis@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Jon Hunter
2025-06-26 11:16:36 +01:00
committed by mobile promotions
parent 74171df1a4
commit a5bb404485
3 changed files with 36 additions and 0 deletions

View File

@@ -11,6 +11,11 @@
#include <linux/types.h>
#include <linux/fs.h>
#include <linux/cdev.h>
#if defined(NV_LINUX_CPUHPLOCK_H_PRESENT)
#include <linux/cpuhplock.h>
#else
#include <linux/cpu.h>
#endif
#include <linux/slab.h>
#include <linux/hrtimer.h>
#include <linux/kthread.h>
@@ -21,6 +26,7 @@
#include <linux/sched.h>
#include <uapi/linux/tegra_hv_vcpu_yield_ioctl.h>
#include <linux/interrupt.h>
#include <linux/workqueue.h>
#include <soc/tegra/virt/hv-ivc.h>
@@ -173,6 +179,9 @@ static long tegra_hv_vcpu_yield_ioctl(struct file *filp, unsigned int cmd,
struct vcpu_yield_dev *data =
(struct vcpu_yield_dev *)filp->private_data;
struct vcpu_yield_start_ctl yield_start_ctl_data;
#if defined(NV_WORK_ON_CPU_KEY_PRESENT) /* Linux v6.7 */
static struct lock_class_key __key;
#endif
switch (cmd) {
case VCPU_YIELD_START_IOCTL:
@@ -201,8 +210,16 @@ static long tegra_hv_vcpu_yield_ioctl(struct file *filp, unsigned int cmd,
if (data->timeout_us > max_timeout_us)
data->timeout_us = max_timeout_us;
#if defined(NV_WORK_ON_CPU_KEY_PRESENT) /* Linux v6.7 */
cpus_read_lock();
if (cpu_online(data->vcpu))
ret = work_on_cpu_key(data->vcpu, vcpu_yield_func,
(void *)data, &__key);
cpus_read_unlock();
#else
ret = work_on_cpu_safe(data->vcpu, vcpu_yield_func,
(void *)data);
#endif
if (ret)
pr_err("work_on_cpu_safe Failed :%d\n", ret);
}