DCE-KMD: Update DCE OS abstraction - Part 4

Module covered in this CL: dce-cond

This is not a functional CL. It does the following.
1) Move os/include/linux-kmd/os-cond.h to
   os/linux/include/dce-os-cond.h

2) s/dce_cond/dce_os_cond/g

3) s/DCE_COND/DCE_OS_COND/g

4) Delete intermediate include os/include/os-cond.h and replace
   all includes with <dce-os-cond.h>

JIRA TDS-16126

Change-Id: Ib4f3cbe5402b2abe114be89f36e25a6fe47e8b13
Signed-off-by: anupamg <anupamg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3228543
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
Reviewed-by: Mahesh Kumar <mahkumar@nvidia.com>
This commit is contained in:
anupamg
2024-10-11 23:10:20 +00:00
committed by Jon Hunter
parent ff65048da5
commit 562347a94e
10 changed files with 58 additions and 89 deletions

View File

@@ -100,7 +100,7 @@ int dce_handle_boot_complete_requested_event(struct tegra_dce *d, void *params)
if (ret)
dce_os_err(d, "failed to send DCE_BOOT_COMPLETE_RECEIVED event");
dce_cond_wait_reset(d, DCE_WAIT_BOOT_COMPLETE);
dce_os_cond_wait_reset(d, DCE_WAIT_BOOT_COMPLETE);
goto boot_done;
}
@@ -173,7 +173,7 @@ dce_start_boot_flow(struct tegra_dce *d)
} else {
d->boot_status |= DCE_FW_BOOT_DONE;
dce_os_info(d, "DCE_BOOT_DONE");
dce_cond_broadcast_interruptible(&d->dce_bootstrap_done);
dce_os_cond_broadcast_interruptible(&d->dce_bootstrap_done);
}
exit:

View File

@@ -151,7 +151,7 @@ int tegra_dce_register_ipc_client(u32 type,
* Wait for bootstrapping to complete before client IPC registration
*/
#define DCE_IPC_REGISTER_BOOT_WAIT (30U * 1000)
ret = DCE_COND_WAIT_INTERRUPTIBLE_TIMEOUT(&d->dce_bootstrap_done,
ret = DCE_OS_COND_WAIT_INTERRUPTIBLE_TIMEOUT(&d->dce_bootstrap_done,
dce_is_bootstrap_done(d),
DCE_IPC_REGISTER_BOOT_WAIT);
if (ret) {
@@ -173,7 +173,7 @@ int tegra_dce_register_ipc_client(u32 type,
cl->callback_fn = callback_fn;
dce_os_atomic_set(&cl->complete, 0);
ret = dce_cond_init(&cl->recv_wait);
ret = dce_os_cond_init(&cl->recv_wait);
if (ret) {
dce_os_err(d, "dce condition initialization failed for int_type: [%u]",
int_type);
@@ -204,8 +204,8 @@ int tegra_dce_unregister_ipc_client(u32 handle)
return -EINVAL;
}
dce_cond_destroy(&cl->recv_wait);
atomic_set(&cl->complete, 0);
dce_os_cond_destroy(&cl->recv_wait);
dce_os_atomic_set(&cl->complete, 0);
return dce_client_ipc_handle_free(cl);
}
@@ -283,7 +283,7 @@ int dce_client_ipc_wait(struct tegra_dce *d, u32 int_type)
}
retry_wait:
DCE_COND_WAIT_INTERRUPTIBLE(&cl->recv_wait,
DCE_OS_COND_WAIT_INTERRUPTIBLE(&cl->recv_wait,
dce_os_atomic_read(&cl->complete) == 1);
if (dce_os_atomic_read(&cl->complete) != 1)
goto retry_wait;
@@ -375,5 +375,5 @@ void dce_client_ipc_wakeup(struct tegra_dce *d, u32 ch_type)
return dce_client_schedule_event_work(d);
dce_os_atomic_set(&cl->complete, 1);
dce_cond_signal_interruptible(&cl->recv_wait);
dce_os_cond_signal_interruptible(&cl->recv_wait);
}

View File

@@ -371,13 +371,13 @@ void dce_os_log_msg(struct tegra_dce *d, const char *func_name, int line,
}
/**
* dce_cond_init - Initialize a condition variable
* dce_os_cond_init - Initialize a condition variable
*
* @cond - The condition variable to initialize
*
* Initialize a condition variable before using it.
*/
int dce_cond_init(struct dce_cond *cond)
int dce_os_cond_init(struct dce_os_cond *cond)
{
init_waitqueue_head(&cond->wq);
cond->initialized = true;
@@ -386,17 +386,17 @@ int dce_cond_init(struct dce_cond *cond)
}
/**
* dce_cond_destroy - Destroy a condition variable
* dce_os_cond_destroy - Destroy a condition variable
*
* @cond - The condition variable to destroy
*/
void dce_cond_destroy(struct dce_cond *cond)
void dce_os_cond_destroy(struct dce_os_cond *cond)
{
cond->initialized = false;
}
/**
* dce_cond_signal - Signal a condition variable
* dce_os_cond_signal - Signal a condition variable
*
* @cond - The condition variable to signal
*
@@ -405,7 +405,7 @@ void dce_cond_destroy(struct dce_cond *cond)
*
* The waiter is using an uninterruptible wait.
*/
void dce_cond_signal(struct dce_cond *cond)
void dce_os_cond_signal(struct dce_os_cond *cond)
{
WARN_ON(!cond->initialized);
@@ -413,7 +413,7 @@ void dce_cond_signal(struct dce_cond *cond)
}
/**
* dce_cond_signal_interruptible - Signal a condition variable
* dce_os_cond_signal_interruptible - Signal a condition variable
*
* @cond - The condition variable to signal
*
@@ -422,7 +422,7 @@ void dce_cond_signal(struct dce_cond *cond)
*
* The waiter is using an interruptible wait.
*/
void dce_cond_signal_interruptible(struct dce_cond *cond)
void dce_os_cond_signal_interruptible(struct dce_os_cond *cond)
{
WARN_ON(!cond->initialized);
@@ -430,7 +430,7 @@ void dce_cond_signal_interruptible(struct dce_cond *cond)
}
/**
* dce_cond_broadcast - Signal all waiters of a condition variable
* dce_os_cond_broadcast - Signal all waiters of a condition variable
*
* @cond - The condition variable to signal
*
@@ -439,7 +439,7 @@ void dce_cond_signal_interruptible(struct dce_cond *cond)
*
* The waiters are using an uninterruptible wait.
*/
int dce_cond_broadcast(struct dce_cond *cond)
int dce_os_cond_broadcast(struct dce_os_cond *cond)
{
if (!cond->initialized)
return -EINVAL;
@@ -450,7 +450,7 @@ int dce_cond_broadcast(struct dce_cond *cond)
}
/**
* dce_cond_broadcast_interruptible - Signal all waiters of a condition
* dce_os_cond_broadcast_interruptible - Signal all waiters of a condition
* variable
*
* @cond - The condition variable to signal
@@ -460,7 +460,7 @@ int dce_cond_broadcast(struct dce_cond *cond)
*
* The waiters are using an interruptible wait.
*/
int dce_cond_broadcast_interruptible(struct dce_cond *cond)
int dce_os_cond_broadcast_interruptible(struct dce_os_cond *cond)
{
if (!cond->initialized)
return -EINVAL;

View File

@@ -4,7 +4,7 @@
*/
#include <dce.h>
#include <os-cond.h>
#include <dce-os-cond.h>
#include <dce-os-lock.h>
#include <dce-worker.h>
#include <dce-os-utils.h>
@@ -34,7 +34,7 @@ int dce_wait_interruptible(struct tegra_dce *d, u32 msg_id)
* start waiting. But that should not be an issue as wait->complete
* Will be "1" and we immediately exit from the wait.
*/
DCE_COND_WAIT_INTERRUPTIBLE(&wait->cond_wait,
DCE_OS_COND_WAIT_INTERRUPTIBLE(&wait->cond_wait,
dce_os_atomic_read(&wait->complete) == 1);
if (dce_os_atomic_read(&wait->complete) != 1)
@@ -70,22 +70,22 @@ void dce_wakeup_interruptible(struct tegra_dce *d, u32 msg_id)
/*
* Set wait->complete to "1", so if the wait is called even after
* "dce_cond_signal_interruptible", it'll see the complete variable
* "dce_os_cond_signal_interruptible", it'll see the complete variable
* as "1" and exit the wait immediately.
*/
dce_os_atomic_set(&wait->complete, 1);
dce_cond_signal_interruptible(&wait->cond_wait);
dce_os_cond_signal_interruptible(&wait->cond_wait);
}
/*
* dce_cond_wait_reset : reset condition wait variable to zero
* dce_os_cond_wait_reset : reset condition wait variable to zero
*
* @d : Pointer to tegra_dce struct.
* @msg_id : index of wait condition
*
* Return : void
*/
void dce_cond_wait_reset(struct tegra_dce *d, u32 msg_id)
void dce_os_cond_wait_reset(struct tegra_dce *d, u32 msg_id)
{
struct dce_wait_cond *wait;
@@ -110,7 +110,7 @@ int dce_work_cond_sw_resource_init(struct tegra_dce *d)
int ret = 0;
int i;
if (dce_cond_init(&d->dce_bootstrap_done)) {
if (dce_os_cond_init(&d->dce_bootstrap_done)) {
dce_os_err(d, "dce boot wait condition init failed");
ret = -1;
goto exit;
@@ -119,7 +119,7 @@ int dce_work_cond_sw_resource_init(struct tegra_dce *d)
for (i = 0; i < DCE_MAX_WAIT; i++) {
struct dce_wait_cond *wait = &d->ipc_waits[i];
if (dce_cond_init(&wait->cond_wait)) {
if (dce_os_cond_init(&wait->cond_wait)) {
dce_os_err(d, "dce wait condition %d init failed", i);
ret = -1;
goto init_error;
@@ -133,10 +133,10 @@ init_error:
while (i >= 0) {
struct dce_wait_cond *wait = &d->ipc_waits[i];
dce_cond_destroy(&wait->cond_wait);
dce_os_cond_destroy(&wait->cond_wait);
i--;
}
dce_cond_destroy(&d->dce_bootstrap_done);
dce_os_cond_destroy(&d->dce_bootstrap_done);
exit:
return ret;
}
@@ -155,9 +155,9 @@ void dce_work_cond_sw_resource_deinit(struct tegra_dce *d)
for (i = 0; i < DCE_MAX_WAIT; i++) {
struct dce_wait_cond *wait = &d->ipc_waits[i];
dce_cond_destroy(&wait->cond_wait);
dce_os_cond_destroy(&wait->cond_wait);
dce_os_atomic_set(&wait->complete, 0);
}
dce_cond_destroy(&d->dce_bootstrap_done);
dce_os_cond_destroy(&d->dce_bootstrap_done);
}

View File

@@ -33,7 +33,7 @@ struct tegra_dce_client_ipc {
uint32_t handle;
uint32_t int_type;
struct tegra_dce *d;
struct dce_cond recv_wait;
struct dce_os_cond recv_wait;
dce_os_atomic_t complete;
tegra_dce_client_ipc_callback_t callback_fn;
};

View File

@@ -6,7 +6,7 @@
#ifndef DCE_FSM_H
#define DCE_FSM_H
#include <os-cond.h>
#include <dce-os-cond.h>
#include <dce-os-lock.h>
/**

View File

@@ -6,7 +6,7 @@
#ifndef DCE_WORKER_H
#define DCE_WORKER_H
#include <os-cond.h>
#include <dce-os-cond.h>
#include <dce-os-lock.h>
#include <dce-os-atomic.h>
@@ -21,7 +21,7 @@ struct tegra_dce;
struct dce_wait_cond {
dce_os_atomic_t complete;
struct dce_cond cond_wait;
struct dce_os_cond cond_wait;
};
int dce_work_cond_sw_resource_init(struct tegra_dce *d);
@@ -29,6 +29,6 @@ void dce_work_cond_sw_resource_deinit(struct tegra_dce *d);
void dce_schedule_boot_complete_wait_worker(struct tegra_dce *d);
int dce_wait_interruptible(struct tegra_dce *d, u32 msg_id);
void dce_wakeup_interruptible(struct tegra_dce *d, u32 msg_id);
void dce_cond_wait_reset(struct tegra_dce *d, u32 msg_id);
void dce_os_cond_wait_reset(struct tegra_dce *d, u32 msg_id);
#endif

View File

@@ -11,7 +11,7 @@
#include <dce-ipc.h>
#include <dce-hsp.h>
#include <dce-os-lock.h>
#include <os-cond.h>
#include <dce-os-cond.h>
#include <dce-regs.h>
#include <dce-worker.h>
#include <dce-fsm.h>
@@ -164,7 +164,7 @@ struct tegra_dce {
/**
* dce_bootstrap_done - Data structure to manage wait for boot done
*/
struct dce_cond dce_bootstrap_done;
struct dce_os_cond dce_bootstrap_done;
/**
* @d_mb - Stores the current status of dce mailbox interfaces.
*/

View File

@@ -1,24 +0,0 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: LicenseRef-NvidiaProprietary
*
* NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
* property and proprietary rights in and to this material, related
* documentation and any modifications thereto. Any use, reproduction,
* disclosure or distribution of this material and related documentation
* without an express license agreement from NVIDIA CORPORATION or
* its affiliates is strictly prohibited.
*/
#ifndef NVDISPLAY_SERVER_OS_COND_H
#define NVDISPLAY_SERVER_OS_COND_H
#ifdef __KERNEL__
#include <linux-kmd/os-cond.h>
#elif defined(NVDISPLAY_SERVER_HVRTOS)
#include <hvrtos/os-cond.h>
#else
#error "OS Not Supported"
#endif
#endif /* NVDISPLAY_SERVER_OS_COND_H */

View File

@@ -1,35 +1,28 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: LicenseRef-NvidiaProprietary
*
* NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
* property and proprietary rights in and to this material, related
* documentation and any modifications thereto. Any use, reproduction,
* disclosure or distribution of this material and related documentation
* without an express license agreement from NVIDIA CORPORATION or
* its affiliates is strictly prohibited.
*/
#ifndef NVDISPLAY_SERVER_OS_COND_LINUX_H
#define NVDISPLAY_SERVER_OS_COND_LINUX_H
#ifndef DCE_OS_COND_H
#define DCE_OS_COND_H
#include <linux/wait.h>
#include <linux/sched.h>
struct dce_cond {
struct dce_os_cond {
bool initialized;
wait_queue_head_t wq;
};
/**
* DCE_COND_WAIT - Wait for a condition to be true
* DCE_OS_COND_WAIT - Wait for a condition to be true
*
* @c - The condition variable to sleep on
* @condition - The condition that needs to be true
*
* Wait for a condition to become true.
*/
#define DCE_COND_WAIT(c, condition) \
#define DCE_OS_COND_WAIT(c, condition) \
({\
int ret = 0; \
wait_event((c)->wq, condition); \
@@ -37,7 +30,7 @@ struct dce_cond {
})
/**
* DCE_COND_WAIT_INTERRUPTIBLE - Wait for a condition to be true
* DCE_OS_COND_WAIT_INTERRUPTIBLE - Wait for a condition to be true
*
* @c - The condition variable to sleep on
* @condition - The condition that needs to be true
@@ -45,7 +38,7 @@ struct dce_cond {
* Wait for a condition to become true. Returns -ERESTARTSYS
* on signal.
*/
#define DCE_COND_WAIT_INTERRUPTIBLE(c, condition) \
#define DCE_OS_COND_WAIT_INTERRUPTIBLE(c, condition) \
({ \
int ret = 0; \
ret = wait_event_interruptible((c)->wq, condition); \
@@ -53,7 +46,7 @@ struct dce_cond {
})
/**
* DCE_COND_WAIT_TIMEOUT - Wait for a condition to be true
* DCE_OS_COND_WAIT_TIMEOUT - Wait for a condition to be true
*
* @c - The condition variable to sleep on
* @condition - The condition that needs to be true
@@ -66,7 +59,7 @@ struct dce_cond {
* Wait for a condition to become true. Returns -ETIMEOUT if
* the wait timed out with condition false.
*/
#define DCE_COND_WAIT_TIMEOUT(c, condition, timeout_ms) \
#define DCE_OS_COND_WAIT_TIMEOUT(c, condition, timeout_ms) \
({\
int ret = 0; \
/* This is the assignment to enforce a u32 for timeout_ms */ \
@@ -84,7 +77,7 @@ struct dce_cond {
})
/**
* DCE_COND_WAIT_INTERRUPTIBLE_TIMEOUT - Wait for a condition to be true
* DCE_OS_COND_WAIT_INTERRUPTIBLE_TIMEOUT - Wait for a condition to be true
*
* @c - The condition variable to sleep on
* @condition - The condition that needs to be true
@@ -98,7 +91,7 @@ struct dce_cond {
* the wait timed out with condition false or -ERESTARTSYS on
* signal.
*/
#define DCE_COND_WAIT_INTERRUPTIBLE_TIMEOUT(c, condition, timeout_ms) \
#define DCE_OS_COND_WAIT_INTERRUPTIBLE_TIMEOUT(c, condition, timeout_ms) \
({ \
int ret = 0; \
/* This is the assignment to enforce a u32 for timeout_ms */ \
@@ -117,16 +110,16 @@ struct dce_cond {
ret; \
})
int dce_cond_init(struct dce_cond *cond);
int dce_os_cond_init(struct dce_os_cond *cond);
void dce_cond_signal(struct dce_cond *cond);
void dce_os_cond_signal(struct dce_os_cond *cond);
void dce_cond_signal_interruptible(struct dce_cond *cond);
void dce_os_cond_signal_interruptible(struct dce_os_cond *cond);
int dce_cond_broadcast(struct dce_cond *cond);
int dce_os_cond_broadcast(struct dce_os_cond *cond);
int dce_cond_broadcast_interruptible(struct dce_cond *cond);
int dce_os_cond_broadcast_interruptible(struct dce_os_cond *cond);
void dce_cond_destroy(struct dce_cond *cond);
void dce_os_cond_destroy(struct dce_os_cond *cond);
#endif /* NVDISPLAY_SERVER_OS_COND_LINUX_H */
#endif /* DCE_OS_COND_H */