Skip to content
This repository was archived by the owner on Apr 21, 2025. It is now read-only.

mxgpu: adapt to changes in kernels >= 4.11.0 #9

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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
13 changes: 8 additions & 5 deletions drv/gim_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/mod_devicetable.h>
#include <linux/version.h>
#include "gim_adapter.h"
#include "gim_unwrapper.h"
#include "gim_pci.h"
Expand Down Expand Up @@ -63,21 +64,23 @@ static const struct pci_device_id gim_pci_tbl[] = {

struct aer_item device_list[MAX_BRIDGES];

static ssize_t gim_sriov(struct device_driver *drv, const char *buf,
static ssize_t sriov_store(struct device_driver *drv, const char *buf,
size_t count)
{
call_interface_functions(buf, count);
return count;
}

static ssize_t gim_sriov_show(struct device_driver *drv, char *buf)
static ssize_t sriov_show(struct device_driver *drv, char *buf)
{
return respond_interface_functions(buf);
}


static DRIVER_ATTR(sriov, (S_IWUSR|S_IRUSR), gim_sriov_show, gim_sriov);

#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0)
static DRIVER_ATTR(sriov, (S_IWUSR | S_IRUSR), sriov_show, sriov_store);
#else
static DRIVER_ATTR_RW(sriov);
#endif

static int gim_probe(struct pci_dev *pdev,
const struct pci_device_id *ent)
Expand Down
19 changes: 15 additions & 4 deletions drv/gim_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#include <linux/fs.h>
#include <asm/segment.h>
#include <asm/uaccess.h>
#include <linux/buffer_head.h>
#include <linux/version.h>

Expand Down Expand Up @@ -60,9 +59,13 @@ unsigned long long file_size(struct file *file)
#if !defined(XEN_DUNDEE) && (KERNEL_VERSION(3, 9, 0) > LINUX_VERSION_CODE)
/* 3.4.9 */
vfs_getattr(file->f_vfsmnt, file->f_dentry, &ks);
#else
#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)
/* 3.14.0 + */
vfs_getattr(&file->f_path, &ks);
#else
/* 4.11.0 + */
vfs_getattr(&file->f_path, &ks, STATX_TYPE | STATX_MODE,
AT_STATX_SYNC_AS_STAT);
#endif
set_fs(oldfs);

Expand Down Expand Up @@ -97,8 +100,9 @@ int file_truncate(struct file *file, unsigned long long size)
}

int file_read(struct file *file, unsigned long long offset, unsigned char *data,
unsigned int size)
unsigned int size)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0)
mm_segment_t oldfs;
int ret;

Expand All @@ -110,11 +114,15 @@ int file_read(struct file *file, unsigned long long offset, unsigned char *data,
set_fs(oldfs);

return ret;
#else
return kernel_read(file, data, size, &offset);
#endif
}

int file_write(struct file *file, unsigned long long offset,
unsigned char *data, unsigned int size)
unsigned char *data, unsigned int size)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0)
mm_segment_t oldfs;
int ret;

Expand All @@ -126,6 +134,9 @@ int file_write(struct file *file, unsigned long long offset,
set_fs(oldfs);

return ret;
#else
return kernel_write(file, data, size, &offset);
#endif
}

int file_sync(struct file *file)
Expand Down