Commit 37d4607e authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'vfio-v5.3-rc1' of git://github.com/awilliam/linux-vfio

Pull VFIO updates from Alex Williamson:

 - Static symbol cleanup in mdev samples (Kefeng Wang)

 - Use vma help in nvlink code (Peng Hao)

 - Remove unused code in mbochs sample (YueHaibing)

 - Send uevents around mdev registration (Alex Williamson)

* tag 'vfio-v5.3-rc1' of git://github.com/awilliam/linux-vfio:
  mdev: Send uevents around parent device registration
  sample/mdev/mbochs: remove set but not used variable 'mdev_state'
  vfio: vfio_pci_nvlink2: use a vma helper function
  vfio-mdev/samples: make some symbols static
parents 916f562f 1e4d09d2
...@@ -143,6 +143,8 @@ int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops) ...@@ -143,6 +143,8 @@ int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops)
{ {
int ret; int ret;
struct mdev_parent *parent; struct mdev_parent *parent;
char *env_string = "MDEV_STATE=registered";
char *envp[] = { env_string, NULL };
/* check for mandatory ops */ /* check for mandatory ops */
if (!ops || !ops->create || !ops->remove || !ops->supported_type_groups) if (!ops || !ops->create || !ops->remove || !ops->supported_type_groups)
...@@ -194,6 +196,8 @@ int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops) ...@@ -194,6 +196,8 @@ int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops)
mutex_unlock(&parent_list_lock); mutex_unlock(&parent_list_lock);
dev_info(dev, "MDEV: Registered\n"); dev_info(dev, "MDEV: Registered\n");
kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
return 0; return 0;
add_dev_err: add_dev_err:
...@@ -217,6 +221,8 @@ EXPORT_SYMBOL(mdev_register_device); ...@@ -217,6 +221,8 @@ EXPORT_SYMBOL(mdev_register_device);
void mdev_unregister_device(struct device *dev) void mdev_unregister_device(struct device *dev)
{ {
struct mdev_parent *parent; struct mdev_parent *parent;
char *env_string = "MDEV_STATE=unregistered";
char *envp[] = { env_string, NULL };
mutex_lock(&parent_list_lock); mutex_lock(&parent_list_lock);
parent = __find_parent_device(dev); parent = __find_parent_device(dev);
...@@ -240,6 +246,9 @@ void mdev_unregister_device(struct device *dev) ...@@ -240,6 +246,9 @@ void mdev_unregister_device(struct device *dev)
up_write(&parent->unreg_sem); up_write(&parent->unreg_sem);
mdev_put_parent(parent); mdev_put_parent(parent);
/* We still have the caller's reference to use for the uevent */
kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
} }
EXPORT_SYMBOL(mdev_unregister_device); EXPORT_SYMBOL(mdev_unregister_device);
......
...@@ -161,8 +161,7 @@ static int vfio_pci_nvgpu_mmap(struct vfio_pci_device *vdev, ...@@ -161,8 +161,7 @@ static int vfio_pci_nvgpu_mmap(struct vfio_pci_device *vdev,
atomic_inc(&data->mm->mm_count); atomic_inc(&data->mm->mm_count);
ret = (int) mm_iommu_newdev(data->mm, data->useraddr, ret = (int) mm_iommu_newdev(data->mm, data->useraddr,
(vma->vm_end - vma->vm_start) >> PAGE_SHIFT, vma_pages(vma), data->gpu_hpa, &data->mem);
data->gpu_hpa, &data->mem);
trace_vfio_pci_nvgpu_mmap(vdev->pdev, data->gpu_hpa, data->useraddr, trace_vfio_pci_nvgpu_mmap(vdev->pdev, data->gpu_hpa, data->useraddr,
vma->vm_end - vma->vm_start, ret); vma->vm_end - vma->vm_start, ret);
......
...@@ -1185,9 +1185,6 @@ static long mbochs_ioctl(struct mdev_device *mdev, unsigned int cmd, ...@@ -1185,9 +1185,6 @@ static long mbochs_ioctl(struct mdev_device *mdev, unsigned int cmd,
{ {
int ret = 0; int ret = 0;
unsigned long minsz, outsz; unsigned long minsz, outsz;
struct mdev_state *mdev_state;
mdev_state = mdev_get_drvdata(mdev);
switch (cmd) { switch (cmd) {
case VFIO_DEVICE_GET_INFO: case VFIO_DEVICE_GET_INFO:
......
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
* Global Structures * Global Structures
*/ */
struct mtty_dev { static struct mtty_dev {
dev_t vd_devt; dev_t vd_devt;
struct class *vd_class; struct class *vd_class;
struct cdev vd_cdev; struct cdev vd_cdev;
...@@ -84,7 +84,7 @@ struct mdev_region_info { ...@@ -84,7 +84,7 @@ struct mdev_region_info {
}; };
#if defined(DEBUG_REGS) #if defined(DEBUG_REGS)
const char *wr_reg[] = { static const char *wr_reg[] = {
"TX", "TX",
"IER", "IER",
"FCR", "FCR",
...@@ -95,7 +95,7 @@ const char *wr_reg[] = { ...@@ -95,7 +95,7 @@ const char *wr_reg[] = {
"SCR" "SCR"
}; };
const char *rd_reg[] = { static const char *rd_reg[] = {
"RX", "RX",
"IER", "IER",
"IIR", "IIR",
...@@ -143,8 +143,8 @@ struct mdev_state { ...@@ -143,8 +143,8 @@ struct mdev_state {
int nr_ports; int nr_ports;
}; };
struct mutex mdev_list_lock; static struct mutex mdev_list_lock;
struct list_head mdev_devices_list; static struct list_head mdev_devices_list;
static const struct file_operations vd_fops = { static const struct file_operations vd_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
...@@ -167,7 +167,7 @@ static struct mdev_state *find_mdev_state_by_uuid(const guid_t *uuid) ...@@ -167,7 +167,7 @@ static struct mdev_state *find_mdev_state_by_uuid(const guid_t *uuid)
return NULL; return NULL;
} }
void dump_buffer(u8 *buf, uint32_t count) static void dump_buffer(u8 *buf, uint32_t count)
{ {
#if defined(DEBUG) #if defined(DEBUG)
int i; int i;
...@@ -723,7 +723,7 @@ static ssize_t mdev_access(struct mdev_device *mdev, u8 *buf, size_t count, ...@@ -723,7 +723,7 @@ static ssize_t mdev_access(struct mdev_device *mdev, u8 *buf, size_t count,
return ret; return ret;
} }
int mtty_create(struct kobject *kobj, struct mdev_device *mdev) static int mtty_create(struct kobject *kobj, struct mdev_device *mdev)
{ {
struct mdev_state *mdev_state; struct mdev_state *mdev_state;
char name[MTTY_STRING_LEN]; char name[MTTY_STRING_LEN];
...@@ -773,7 +773,7 @@ int mtty_create(struct kobject *kobj, struct mdev_device *mdev) ...@@ -773,7 +773,7 @@ int mtty_create(struct kobject *kobj, struct mdev_device *mdev)
return 0; return 0;
} }
int mtty_remove(struct mdev_device *mdev) static int mtty_remove(struct mdev_device *mdev)
{ {
struct mdev_state *mds, *tmp_mds; struct mdev_state *mds, *tmp_mds;
struct mdev_state *mdev_state = mdev_get_drvdata(mdev); struct mdev_state *mdev_state = mdev_get_drvdata(mdev);
...@@ -795,7 +795,7 @@ int mtty_remove(struct mdev_device *mdev) ...@@ -795,7 +795,7 @@ int mtty_remove(struct mdev_device *mdev)
return ret; return ret;
} }
int mtty_reset(struct mdev_device *mdev) static int mtty_reset(struct mdev_device *mdev)
{ {
struct mdev_state *mdev_state; struct mdev_state *mdev_state;
...@@ -811,8 +811,8 @@ int mtty_reset(struct mdev_device *mdev) ...@@ -811,8 +811,8 @@ int mtty_reset(struct mdev_device *mdev)
return 0; return 0;
} }
ssize_t mtty_read(struct mdev_device *mdev, char __user *buf, size_t count, static ssize_t mtty_read(struct mdev_device *mdev, char __user *buf,
loff_t *ppos) size_t count, loff_t *ppos)
{ {
unsigned int done = 0; unsigned int done = 0;
int ret; int ret;
...@@ -870,7 +870,7 @@ ssize_t mtty_read(struct mdev_device *mdev, char __user *buf, size_t count, ...@@ -870,7 +870,7 @@ ssize_t mtty_read(struct mdev_device *mdev, char __user *buf, size_t count,
return -EFAULT; return -EFAULT;
} }
ssize_t mtty_write(struct mdev_device *mdev, const char __user *buf, static ssize_t mtty_write(struct mdev_device *mdev, const char __user *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
unsigned int done = 0; unsigned int done = 0;
...@@ -1063,7 +1063,7 @@ static int mtty_trigger_interrupt(const guid_t *uuid) ...@@ -1063,7 +1063,7 @@ static int mtty_trigger_interrupt(const guid_t *uuid)
return ret; return ret;
} }
int mtty_get_region_info(struct mdev_device *mdev, static int mtty_get_region_info(struct mdev_device *mdev,
struct vfio_region_info *region_info, struct vfio_region_info *region_info,
u16 *cap_type_id, void **cap_type) u16 *cap_type_id, void **cap_type)
{ {
...@@ -1112,7 +1112,8 @@ int mtty_get_region_info(struct mdev_device *mdev, ...@@ -1112,7 +1112,8 @@ int mtty_get_region_info(struct mdev_device *mdev,
return 0; return 0;
} }
int mtty_get_irq_info(struct mdev_device *mdev, struct vfio_irq_info *irq_info) static int mtty_get_irq_info(struct mdev_device *mdev,
struct vfio_irq_info *irq_info)
{ {
switch (irq_info->index) { switch (irq_info->index) {
case VFIO_PCI_INTX_IRQ_INDEX: case VFIO_PCI_INTX_IRQ_INDEX:
...@@ -1136,7 +1137,7 @@ int mtty_get_irq_info(struct mdev_device *mdev, struct vfio_irq_info *irq_info) ...@@ -1136,7 +1137,7 @@ int mtty_get_irq_info(struct mdev_device *mdev, struct vfio_irq_info *irq_info)
return 0; return 0;
} }
int mtty_get_device_info(struct mdev_device *mdev, static int mtty_get_device_info(struct mdev_device *mdev,
struct vfio_device_info *dev_info) struct vfio_device_info *dev_info)
{ {
dev_info->flags = VFIO_DEVICE_FLAGS_PCI; dev_info->flags = VFIO_DEVICE_FLAGS_PCI;
...@@ -1268,13 +1269,13 @@ static long mtty_ioctl(struct mdev_device *mdev, unsigned int cmd, ...@@ -1268,13 +1269,13 @@ static long mtty_ioctl(struct mdev_device *mdev, unsigned int cmd,
return -ENOTTY; return -ENOTTY;
} }
int mtty_open(struct mdev_device *mdev) static int mtty_open(struct mdev_device *mdev)
{ {
pr_info("%s\n", __func__); pr_info("%s\n", __func__);
return 0; return 0;
} }
void mtty_close(struct mdev_device *mdev) static void mtty_close(struct mdev_device *mdev)
{ {
pr_info("%s\n", __func__); pr_info("%s\n", __func__);
} }
...@@ -1298,7 +1299,7 @@ static const struct attribute_group mtty_dev_group = { ...@@ -1298,7 +1299,7 @@ static const struct attribute_group mtty_dev_group = {
.attrs = mtty_dev_attrs, .attrs = mtty_dev_attrs,
}; };
const struct attribute_group *mtty_dev_groups[] = { static const struct attribute_group *mtty_dev_groups[] = {
&mtty_dev_group, &mtty_dev_group,
NULL, NULL,
}; };
...@@ -1325,7 +1326,7 @@ static const struct attribute_group mdev_dev_group = { ...@@ -1325,7 +1326,7 @@ static const struct attribute_group mdev_dev_group = {
.attrs = mdev_dev_attrs, .attrs = mdev_dev_attrs,
}; };
const struct attribute_group *mdev_dev_groups[] = { static const struct attribute_group *mdev_dev_groups[] = {
&mdev_dev_group, &mdev_dev_group,
NULL, NULL,
}; };
...@@ -1347,7 +1348,7 @@ name_show(struct kobject *kobj, struct device *dev, char *buf) ...@@ -1347,7 +1348,7 @@ name_show(struct kobject *kobj, struct device *dev, char *buf)
return -EINVAL; return -EINVAL;
} }
MDEV_TYPE_ATTR_RO(name); static MDEV_TYPE_ATTR_RO(name);
static ssize_t static ssize_t
available_instances_show(struct kobject *kobj, struct device *dev, char *buf) available_instances_show(struct kobject *kobj, struct device *dev, char *buf)
...@@ -1375,7 +1376,7 @@ available_instances_show(struct kobject *kobj, struct device *dev, char *buf) ...@@ -1375,7 +1376,7 @@ available_instances_show(struct kobject *kobj, struct device *dev, char *buf)
return sprintf(buf, "%d\n", (MAX_MTTYS - used)/ports); return sprintf(buf, "%d\n", (MAX_MTTYS - used)/ports);
} }
MDEV_TYPE_ATTR_RO(available_instances); static MDEV_TYPE_ATTR_RO(available_instances);
static ssize_t device_api_show(struct kobject *kobj, struct device *dev, static ssize_t device_api_show(struct kobject *kobj, struct device *dev,
...@@ -1384,7 +1385,7 @@ static ssize_t device_api_show(struct kobject *kobj, struct device *dev, ...@@ -1384,7 +1385,7 @@ static ssize_t device_api_show(struct kobject *kobj, struct device *dev,
return sprintf(buf, "%s\n", VFIO_DEVICE_API_PCI_STRING); return sprintf(buf, "%s\n", VFIO_DEVICE_API_PCI_STRING);
} }
MDEV_TYPE_ATTR_RO(device_api); static MDEV_TYPE_ATTR_RO(device_api);
static struct attribute *mdev_types_attrs[] = { static struct attribute *mdev_types_attrs[] = {
&mdev_type_attr_name.attr, &mdev_type_attr_name.attr,
...@@ -1403,7 +1404,7 @@ static struct attribute_group mdev_type_group2 = { ...@@ -1403,7 +1404,7 @@ static struct attribute_group mdev_type_group2 = {
.attrs = mdev_types_attrs, .attrs = mdev_types_attrs,
}; };
struct attribute_group *mdev_type_groups[] = { static struct attribute_group *mdev_type_groups[] = {
&mdev_type_group1, &mdev_type_group1,
&mdev_type_group2, &mdev_type_group2,
NULL, NULL,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment