host1x_emu: Adding API dispatch functionality

Adding dynamic APi dispatch functionality in host1x-fence
modue. This CL exports new host1x wrapper API, which can
be called by client kernel modules. The wrapper API dispatch
call to either Host1x module or Host1x-EMU depending if the
host1x-emu driver registered its interface during its probe.

Bug 5064819

Change-Id: I49445cdce7c3795a2c94fde9d0871da393993554
Signed-off-by: amitabhd <amitabhd@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3306857
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Leslin Varghese <lvarghese@nvidia.com>
Reviewed-by: Raghavendra Vishnu Kumar <rvk@nvidia.com>
This commit is contained in:
amitabhd
2025-02-20 11:05:00 +00:00
committed by Jon Hunter
parent 1e83ec96df
commit 2cc3c99c6e
10 changed files with 764 additions and 8 deletions

View File

@@ -7,7 +7,6 @@
#include <linux/cdev.h>
#include <linux/file.h>
#include <linux/fs.h>
#include <linux/host1x-next.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_platform.h>
@@ -15,11 +14,14 @@
#include <linux/poll.h>
#include <linux/slab.h>
#include <linux/sync_file.h>
#include <linux/host1x-dispatch.h>
#include "include/uapi/linux/host1x-fence.h"
#define HOST1X_INSTANCE_MAX 2
bool host1x_wrapper_init(void);
static struct host1x_uapi {
struct class *class;
@@ -527,11 +529,21 @@ static int host1x_uapi_init(struct host1x_uapi *uapi)
err = PTR_ERR(uapi->dev);
goto del_cdev;
}
cdev_add(&uapi->cdev, dev_num, 1);
uapi->dev_num = dev_num;
host1x_wrapper_init();
/*
* Don't allow the kernel module to be unloaded. Unloading adds complexity
* during GVS verification. Resolving is not worth the effort in this case
*/
if (!try_module_get(THIS_MODULE)) {
pr_info("Host1x-Fence: Get Module Failed\n");
goto del_cdev;
}
return 0;
del_cdev: