IB/hfi1: Refactor hfi_user_exp_rcv_invalid() IOCTLs
The IOCTL is a bit unwieldy. Refactor to a common pattern. Refactor _TID_INVAL_READ IOCTLs. Reviewed-by: Ira Weiny <ira.weiny@intel.com> Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com> Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
This commit is contained in:
parent
3920eef7a7
commit
8a41da09e6
|
@ -90,6 +90,8 @@ static int user_exp_rcv_setup(struct hfi1_filedata *fd, unsigned long arg,
|
||||||
u32 len);
|
u32 len);
|
||||||
static int user_exp_rcv_clear(struct hfi1_filedata *fd, unsigned long arg,
|
static int user_exp_rcv_clear(struct hfi1_filedata *fd, unsigned long arg,
|
||||||
u32 len);
|
u32 len);
|
||||||
|
static int user_exp_rcv_invalid(struct hfi1_filedata *fd, unsigned long arg,
|
||||||
|
u32 len);
|
||||||
static int setup_base_ctxt(struct hfi1_filedata *fd,
|
static int setup_base_ctxt(struct hfi1_filedata *fd,
|
||||||
struct hfi1_ctxtdata *uctxt);
|
struct hfi1_ctxtdata *uctxt);
|
||||||
static int setup_subctxt(struct hfi1_ctxtdata *uctxt);
|
static int setup_subctxt(struct hfi1_ctxtdata *uctxt);
|
||||||
|
@ -223,9 +225,7 @@ static long hfi1_file_ioctl(struct file *fp, unsigned int cmd,
|
||||||
{
|
{
|
||||||
struct hfi1_filedata *fd = fp->private_data;
|
struct hfi1_filedata *fd = fp->private_data;
|
||||||
struct hfi1_ctxtdata *uctxt = fd->uctxt;
|
struct hfi1_ctxtdata *uctxt = fd->uctxt;
|
||||||
struct hfi1_tid_info tinfo;
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
unsigned long addr;
|
|
||||||
int uval = 0;
|
int uval = 0;
|
||||||
unsigned long ul_uval = 0;
|
unsigned long ul_uval = 0;
|
||||||
u16 uval16 = 0;
|
u16 uval16 = 0;
|
||||||
|
@ -263,18 +263,7 @@ static long hfi1_file_ioctl(struct file *fp, unsigned int cmd,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HFI1_IOCTL_TID_INVAL_READ:
|
case HFI1_IOCTL_TID_INVAL_READ:
|
||||||
if (copy_from_user(&tinfo,
|
ret = user_exp_rcv_invalid(fd, arg, _IOC_SIZE(cmd));
|
||||||
(struct hfi11_tid_info __user *)arg,
|
|
||||||
sizeof(tinfo)))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
ret = hfi1_user_exp_rcv_invalid(fd, &tinfo);
|
|
||||||
if (ret)
|
|
||||||
break;
|
|
||||||
addr = arg + offsetof(struct hfi1_tid_info, tidcnt);
|
|
||||||
if (copy_to_user((void __user *)addr, &tinfo.tidcnt,
|
|
||||||
sizeof(tinfo.tidcnt)))
|
|
||||||
ret = -EFAULT;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HFI1_IOCTL_RECV_CTRL:
|
case HFI1_IOCTL_RECV_CTRL:
|
||||||
|
@ -1466,6 +1455,43 @@ static int user_exp_rcv_clear(struct hfi1_filedata *fd, unsigned long arg,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* user_exp_rcv_invalid - Invalidate the given tid rcv list
|
||||||
|
* @fd: file data of the current driver instance
|
||||||
|
* @arg: ioctl argumnent for user space information
|
||||||
|
* @len: length of data structure associated with ioctl command
|
||||||
|
*
|
||||||
|
* Wrapper to validate ioctl information before doing _rcv_invalid.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static int user_exp_rcv_invalid(struct hfi1_filedata *fd, unsigned long arg,
|
||||||
|
u32 len)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
unsigned long addr;
|
||||||
|
struct hfi1_tid_info tinfo;
|
||||||
|
|
||||||
|
if (sizeof(tinfo) != len)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (!fd->invalid_tids)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (copy_from_user(&tinfo, (void __user *)arg, (sizeof(tinfo))))
|
||||||
|
return -EFAULT;
|
||||||
|
|
||||||
|
ret = hfi1_user_exp_rcv_invalid(fd, &tinfo);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
addr = arg + offsetof(struct hfi1_tid_info, tidcnt);
|
||||||
|
if (copy_to_user((void __user *)addr, &tinfo.tidcnt,
|
||||||
|
sizeof(tinfo.tidcnt)))
|
||||||
|
ret = -EFAULT;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static unsigned int poll_urgent(struct file *fp,
|
static unsigned int poll_urgent(struct file *fp,
|
||||||
struct poll_table_struct *pt)
|
struct poll_table_struct *pt)
|
||||||
{
|
{
|
||||||
|
|
|
@ -546,9 +546,6 @@ int hfi1_user_exp_rcv_invalid(struct hfi1_filedata *fd,
|
||||||
u32 *array;
|
u32 *array;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (!fd->invalid_tids)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* copy_to_user() can sleep, which will leave the invalid_lock
|
* copy_to_user() can sleep, which will leave the invalid_lock
|
||||||
* locked and cause the MMU notifier to be blocked on the lock
|
* locked and cause the MMU notifier to be blocked on the lock
|
||||||
|
|
Loading…
Reference in New Issue