lkml.org 
[lkml]   [2022]   [Feb]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v6 09/10] hisi_acc_vfio_pci: Add support for VFIO live migration
On Mon, Feb 28, 2022 at 06:01:44PM +0000, Shameerali Kolothum Thodi wrote:

> +static long hisi_acc_vf_save_unl_ioctl(struct file *filp,
> + unsigned int cmd, unsigned long arg)
> +{
> + struct hisi_acc_vf_migration_file *migf = filp->private_data;
> + loff_t *pos = &filp->f_pos;
> + struct vfio_device_mig_precopy precopy;
> + unsigned long minsz;
> +
> + if (cmd != VFIO_DEVICE_MIG_PRECOPY)
> + return -EINVAL;

ENOTTY

> +
> + minsz = offsetofend(struct vfio_device_mig_precopy, dirty_bytes);
> +
> + if (copy_from_user(&precopy, (void __user *)arg, minsz))
> + return -EFAULT;
> + if (precopy.argsz < minsz)
> + return -EINVAL;
> +
> + mutex_lock(&migf->lock);
> + if (*pos > migf->total_length) {
> + mutex_unlock(&migf->lock);
> + return -EINVAL;
> + }
> +
> + precopy.dirty_bytes = 0;
> + precopy.initial_bytes = migf->total_length - *pos;
> + mutex_unlock(&migf->lock);
> + return copy_to_user((void __user *)arg, &precopy, minsz) ? -EFAULT : 0;
> +}

Yes

And I noticed this didn't include the ENOMSG handling, read() should
return ENOMSG when it reaches EOS for the pre-copy:

+ * During pre-copy the migration data FD has a temporary "end of stream" that is
+ * reached when both initial_bytes and dirty_byte are zero. For instance, this
+ * may indicate that the device is idle and not currently dirtying any internal
+ * state. When read() is done on this temporary end of stream the kernel driver
+ * should return ENOMSG from read(). Userspace can wait for more data (which may
+ * never come) by using poll.

Jason

\
 
 \ /
  Last update: 2022-02-28 19:25    [W:0.197 / U:0.084 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site