Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion XVSEC/linux-kernel/drv/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ all:
make -C /lib/modules/$(XVSEC_KVER)/build M=$(XVSEC_HOME) modules
@mv *.ko $(module_path)/
@cp xvsec_drv.h $(module_path)/
@cp xvsec_drv_int.h $(module_path)/
@cp ./xvsec_mcap/xvsec_mcap.h $(module_path)/
@mv *.o $(module_path)/obj/
@mv .*cmd $(module_path)/obj/
@mv *.symvers $(module_path)/obj/
@mv *.mod* $(module_path)/obj/
@mv *.order* $(module_path)/obj/
@mv .tmp* $(module_path)/obj/
@mv ./xvsec_mcap/*.o $(module_path)/obj/xvsec_mcap/
@mv ./xvsec_mcap/us/*.o $(module_path)/obj/xvsec_mcap/us/
@mv ./xvsec_mcap/versal/*.o $(module_path)/obj/xvsec_mcap/versal/
Expand Down
2 changes: 0 additions & 2 deletions XVSEC/linux-kernel/drv/xvsec_cdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
#include <linux/fs.h>
#include <linux/uaccess.h>
#include <linux/delay.h>
#include <linux/fs.h>
#include <linux/uaccess.h>

#include "xvsec_drv.h"
#include "xvsec_drv_int.h"
Expand Down
11 changes: 6 additions & 5 deletions XVSEC/linux-kernel/drv/xvsec_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@
#include <linux/fs.h>
#include <linux/uaccess.h>
#include <linux/delay.h>
#include <linux/fs.h>
#include <linux/uaccess.h>


#include "version.h"
#include "xvsec_drv.h"
Expand Down Expand Up @@ -361,7 +358,7 @@ static const struct file_operations xvsec_gen_fops = {
};


static int xvsec_initialize(struct pci_dev *pdev, struct context *dev_ctx)
int xvsec_initialize(struct pci_dev *pdev, struct context *dev_ctx)
{
int ret = 0;
int status;
Expand Down Expand Up @@ -405,7 +402,7 @@ static int xvsec_initialize(struct pci_dev *pdev, struct context *dev_ctx)
}
EXPORT_SYMBOL_GPL(xvsec_initialize);

static int xvsec_deinitialize(struct context *dev_ctx)
int xvsec_deinitialize(struct context *dev_ctx)
{
int ret = 0;
uint16_t index;
Expand Down Expand Up @@ -456,7 +453,11 @@ static int __init xvsec_drv_init(void)
if (dev_count == 0)
return 0;

#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0)
g_xvsec_class = class_create(XVSEC_NODE_NAME);
#else
g_xvsec_class = class_create(THIS_MODULE, XVSEC_NODE_NAME);
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0) */
if (IS_ERR(g_xvsec_class)) {
pr_err("failed to create class");
ret = -(PTR_ERR(g_xvsec_class));
Expand Down
3 changes: 3 additions & 0 deletions XVSEC/linux-kernel/drv/xvsec_drv_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,7 @@ extern struct class *g_xvsec_class;
int xvsec_mcap_module_init(struct vsec_context *dev_ctx);
void xvsec_mcap_module_exit(struct vsec_context *dev_ctx);

extern int xvsec_initialize(struct pci_dev *, struct context *);
extern int xvsec_deinitialize(struct context *);

#endif /* __XVSEC_DRV_INT_H__ */
2 changes: 0 additions & 2 deletions XVSEC/linux-kernel/drv/xvsec_mcap/us/xvsec_mcap_us.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
#include <linux/fs.h>
#include <linux/uaccess.h>
#include <linux/delay.h>
#include <linux/fs.h>
#include <linux/uaccess.h>

#include "xvsec_util.h"
#include "xvsec_drv.h"
Expand Down
2 changes: 0 additions & 2 deletions XVSEC/linux-kernel/drv/xvsec_mcap/versal/xvsec_mcap_versal.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
#include <linux/fs.h>
#include <linux/uaccess.h>
#include <linux/delay.h>
#include <linux/fs.h>
#include <linux/uaccess.h>

#include "xvsec_drv.h"
#include "xvsec_drv_int.h"
Expand Down
2 changes: 0 additions & 2 deletions XVSEC/linux-kernel/drv/xvsec_mcap/xvsec_mcap.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
#include <linux/fs.h>
#include <linux/uaccess.h>
#include <linux/delay.h>
#include <linux/fs.h>
#include <linux/uaccess.h>

#include "xvsec_drv.h"
#include "xvsec_drv_int.h"
Expand Down
57 changes: 53 additions & 4 deletions XVSEC/linux-kernel/drv/xvsec_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
#include <linux/fs.h>
#include <linux/uaccess.h>
#include <linux/delay.h>
#include <linux/fs.h>
#include <linux/uaccess.h>
#include <linux/statfs.h>
#include <linux/namei.h>

#include "xvsec_util.h"

Expand Down Expand Up @@ -63,13 +63,21 @@ int xvsec_util_find_file_type(char *fname, const char *suffix)
struct file *xvsec_util_fopen(const char *path, int flags, int rights)
{
struct file *filep;
mm_segment_t oldfs;
int err = 0;

#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0)
mm_segment_t oldfs;

oldfs = get_fs();
set_fs(KERNEL_DS);
#endif

filep = filp_open(path, (flags | O_LARGEFILE), rights);

#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0)
set_fs(oldfs);
#endif

if (IS_ERR(filep) != 0) {
err = PTR_ERR(filep);
pr_err("%s : filp_open failed, err : 0x%X\n", __func__, err);
Expand All @@ -87,17 +95,24 @@ int xvsec_util_fread(struct file *filep, uint64_t offset,
uint8_t *data, uint32_t size)
{
int ret = 0;

#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0)
mm_segment_t oldfs;

oldfs = get_fs();
set_fs(KERNEL_DS);
#endif

#if KERNEL_VERSION(4, 14, 0) > LINUX_VERSION_CODE
ret = vfs_read(filep, (char __user *)data, size, (loff_t *)&offset);
#else
ret = kernel_read(filep, (void *)data, size, (loff_t *)&offset);
#endif
filep->f_pos = offset;

#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0)
set_fs(oldfs);
#endif

if (ret < 0) {
#if KERNEL_VERSION(4, 14, 0) > LINUX_VERSION_CODE
Expand All @@ -117,18 +132,25 @@ int xvsec_util_fwrite(struct file *filep, uint64_t offset,
uint8_t *data, uint32_t size)
{
int ret = 0;

#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0)
mm_segment_t oldfs;

oldfs = get_fs();
set_fs(KERNEL_DS);
#endif

#if KERNEL_VERSION(4, 14, 0) > LINUX_VERSION_CODE
ret = vfs_write(filep, (char __user *)data, size, (loff_t *)&offset);
#else
ret = kernel_write(filep, (void *)data, size,
(loff_t *)&offset);
#endif
filep->f_pos = offset;

#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0)
set_fs(oldfs);
#endif

if (ret < 0) {
#if KERNEL_VERSION(4, 14, 0) > LINUX_VERSION_CODE
Expand All @@ -151,22 +173,49 @@ int xvsec_util_fsync(struct file *filep)
int xvsec_util_get_file_size(const char *fname, loff_t *size)
{
int ret = 0;
mm_segment_t oldfs;
struct kstat stat;

#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0)
mm_segment_t oldfs;

oldfs = get_fs();
set_fs(KERNEL_DS);

memset(&stat, 0, sizeof(struct kstat));

ret = vfs_stat((char __user *)fname, &stat);
set_fs(oldfs);

if (ret < 0) {
pr_err("%s : vfs_stat failed with error : %d\n", __func__, ret);
return -(EIO);
}

*size = stat.size;

#else

struct path path;

memset(&stat, 0, sizeof(struct kstat));

ret = kern_path(fname, LOOKUP_FOLLOW, &path);
if (ret){
pr_err("%s : kern_path failed with error : %d\n", __func__, ret);
return -(EIO);
}

ret = vfs_getattr(&path, &stat, STATX_TYPE, AT_STATX_SYNC_AS_STAT);
path_put(&path);
if (ret){
pr_err("%s : vfs_getattr failed with error : %d\n", __func__, ret);
return -(EIO);
}

*size = stat.size;

#endif

return ret;
}