Commit db1b5ddd authored by Matan Barak's avatar Matan Barak Committed by Doug Ledford

IB/core: Rename uverbs event file structure

Previously, ib_uverbs_event_file was suffixed by _file as it contained
the actual file information. Since it's now only used as base struct
for ib_uverbs_async_event_file and ib_uverbs_completion_event_file,
we change its name to ib_uverbs_event_queue. This represents its
logical role better.

Fixes: 1e7710f3 ('IB/core: Change completion channel to use the reworked objects schema')
Signed-off-by: default avatarMatan Barak <matanb@mellanox.com>
Reviewed-by: default avatarSean Hefty <sean.hefty@intel.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent e0fcc611
...@@ -76,12 +76,13 @@ ...@@ -76,12 +76,13 @@
* an asynchronous event queue file is created and released when the * an asynchronous event queue file is created and released when the
* event file is closed. * event file is closed.
* *
* struct ib_uverbs_event_file: One reference is held by the VFS and * struct ib_uverbs_event_queue: Base structure for
* released when the file is closed. For asynchronous event files, * struct ib_uverbs_async_event_file and struct ib_uverbs_completion_event_file.
* another reference is held by the corresponding main context file * One reference is held by the VFS and released when the file is closed.
* and released when that file is closed. For completion event files, * For asynchronous event files, another reference is held by the corresponding
* a reference is taken when a CQ is created that uses the file, and * main context file and released when that file is closed. For completion
* released when the CQ is destroyed. * event files, a reference is taken when a CQ is created that uses the file,
* and released when the CQ is destroyed.
*/ */
struct ib_uverbs_device { struct ib_uverbs_device {
...@@ -101,7 +102,7 @@ struct ib_uverbs_device { ...@@ -101,7 +102,7 @@ struct ib_uverbs_device {
struct list_head uverbs_events_file_list; struct list_head uverbs_events_file_list;
}; };
struct ib_uverbs_event_file { struct ib_uverbs_event_queue {
spinlock_t lock; spinlock_t lock;
int is_closed; int is_closed;
wait_queue_head_t poll_wait; wait_queue_head_t poll_wait;
...@@ -110,7 +111,7 @@ struct ib_uverbs_event_file { ...@@ -110,7 +111,7 @@ struct ib_uverbs_event_file {
}; };
struct ib_uverbs_async_event_file { struct ib_uverbs_async_event_file {
struct ib_uverbs_event_file ev_file; struct ib_uverbs_event_queue ev_queue;
struct ib_uverbs_file *uverbs_file; struct ib_uverbs_file *uverbs_file;
struct kref ref; struct kref ref;
struct list_head list; struct list_head list;
...@@ -118,7 +119,7 @@ struct ib_uverbs_async_event_file { ...@@ -118,7 +119,7 @@ struct ib_uverbs_async_event_file {
struct ib_uverbs_completion_event_file { struct ib_uverbs_completion_event_file {
struct ib_uobject_file uobj_file; struct ib_uobject_file uobj_file;
struct ib_uverbs_event_file ev_file; struct ib_uverbs_event_queue ev_queue;
}; };
struct ib_uverbs_file { struct ib_uverbs_file {
...@@ -191,7 +192,7 @@ struct ib_ucq_object { ...@@ -191,7 +192,7 @@ struct ib_ucq_object {
}; };
extern const struct file_operations uverbs_event_fops; extern const struct file_operations uverbs_event_fops;
void ib_uverbs_init_event_file(struct ib_uverbs_event_file *ev_file); void ib_uverbs_init_event_queue(struct ib_uverbs_event_queue *ev_queue);
struct file *ib_uverbs_alloc_async_event_file(struct ib_uverbs_file *uverbs_file, struct file *ib_uverbs_alloc_async_event_file(struct ib_uverbs_file *uverbs_file,
struct ib_device *ib_dev); struct ib_device *ib_dev);
void ib_uverbs_free_async_event_file(struct ib_uverbs_file *uverbs_file); void ib_uverbs_free_async_event_file(struct ib_uverbs_file *uverbs_file);
......
...@@ -943,7 +943,7 @@ ssize_t ib_uverbs_create_comp_channel(struct ib_uverbs_file *file, ...@@ -943,7 +943,7 @@ ssize_t ib_uverbs_create_comp_channel(struct ib_uverbs_file *file,
ev_file = container_of(uobj, struct ib_uverbs_completion_event_file, ev_file = container_of(uobj, struct ib_uverbs_completion_event_file,
uobj_file.uobj); uobj_file.uobj);
ib_uverbs_init_event_file(&ev_file->ev_file); ib_uverbs_init_event_queue(&ev_file->ev_queue);
if (copy_to_user((void __user *) (unsigned long) cmd.response, if (copy_to_user((void __user *) (unsigned long) cmd.response,
&resp, sizeof resp)) { &resp, sizeof resp)) {
...@@ -1015,7 +1015,7 @@ static struct ib_ucq_object *create_cq(struct ib_uverbs_file *file, ...@@ -1015,7 +1015,7 @@ static struct ib_ucq_object *create_cq(struct ib_uverbs_file *file,
cq->uobject = &obj->uobject; cq->uobject = &obj->uobject;
cq->comp_handler = ib_uverbs_comp_handler; cq->comp_handler = ib_uverbs_comp_handler;
cq->event_handler = ib_uverbs_cq_event_handler; cq->event_handler = ib_uverbs_cq_event_handler;
cq->cq_context = &ev_file->ev_file; cq->cq_context = &ev_file->ev_queue;
atomic_set(&cq->usecnt, 0); atomic_set(&cq->usecnt, 0);
obj->uobject.object = cq; obj->uobject.object = cq;
...@@ -1296,7 +1296,7 @@ ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file, ...@@ -1296,7 +1296,7 @@ ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file,
struct ib_uobject *uobj; struct ib_uobject *uobj;
struct ib_cq *cq; struct ib_cq *cq;
struct ib_ucq_object *obj; struct ib_ucq_object *obj;
struct ib_uverbs_event_file *ev_file; struct ib_uverbs_event_queue *ev_queue;
int ret = -EINVAL; int ret = -EINVAL;
if (copy_from_user(&cmd, buf, sizeof cmd)) if (copy_from_user(&cmd, buf, sizeof cmd))
...@@ -1313,7 +1313,7 @@ ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file, ...@@ -1313,7 +1313,7 @@ ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file,
*/ */
uverbs_uobject_get(uobj); uverbs_uobject_get(uobj);
cq = uobj->object; cq = uobj->object;
ev_file = cq->cq_context; ev_queue = cq->cq_context;
obj = container_of(cq->uobject, struct ib_ucq_object, uobject); obj = container_of(cq->uobject, struct ib_ucq_object, uobject);
memset(&resp, 0, sizeof(resp)); memset(&resp, 0, sizeof(resp));
......
...@@ -171,22 +171,22 @@ void ib_uverbs_release_ucq(struct ib_uverbs_file *file, ...@@ -171,22 +171,22 @@ void ib_uverbs_release_ucq(struct ib_uverbs_file *file,
struct ib_uverbs_event *evt, *tmp; struct ib_uverbs_event *evt, *tmp;
if (ev_file) { if (ev_file) {
spin_lock_irq(&ev_file->ev_file.lock); spin_lock_irq(&ev_file->ev_queue.lock);
list_for_each_entry_safe(evt, tmp, &uobj->comp_list, obj_list) { list_for_each_entry_safe(evt, tmp, &uobj->comp_list, obj_list) {
list_del(&evt->list); list_del(&evt->list);
kfree(evt); kfree(evt);
} }
spin_unlock_irq(&ev_file->ev_file.lock); spin_unlock_irq(&ev_file->ev_queue.lock);
uverbs_uobject_put(&ev_file->uobj_file.uobj); uverbs_uobject_put(&ev_file->uobj_file.uobj);
} }
spin_lock_irq(&file->async_file->ev_file.lock); spin_lock_irq(&file->async_file->ev_queue.lock);
list_for_each_entry_safe(evt, tmp, &uobj->async_list, obj_list) { list_for_each_entry_safe(evt, tmp, &uobj->async_list, obj_list) {
list_del(&evt->list); list_del(&evt->list);
kfree(evt); kfree(evt);
} }
spin_unlock_irq(&file->async_file->ev_file.lock); spin_unlock_irq(&file->async_file->ev_queue.lock);
} }
void ib_uverbs_release_uevent(struct ib_uverbs_file *file, void ib_uverbs_release_uevent(struct ib_uverbs_file *file,
...@@ -194,12 +194,12 @@ void ib_uverbs_release_uevent(struct ib_uverbs_file *file, ...@@ -194,12 +194,12 @@ void ib_uverbs_release_uevent(struct ib_uverbs_file *file,
{ {
struct ib_uverbs_event *evt, *tmp; struct ib_uverbs_event *evt, *tmp;
spin_lock_irq(&file->async_file->ev_file.lock); spin_lock_irq(&file->async_file->ev_queue.lock);
list_for_each_entry_safe(evt, tmp, &uobj->event_list, obj_list) { list_for_each_entry_safe(evt, tmp, &uobj->event_list, obj_list) {
list_del(&evt->list); list_del(&evt->list);
kfree(evt); kfree(evt);
} }
spin_unlock_irq(&file->async_file->ev_file.lock); spin_unlock_irq(&file->async_file->ev_queue.lock);
} }
void ib_uverbs_detach_umcast(struct ib_qp *qp, void ib_uverbs_detach_umcast(struct ib_qp *qp,
...@@ -253,7 +253,7 @@ void ib_uverbs_release_file(struct kref *ref) ...@@ -253,7 +253,7 @@ void ib_uverbs_release_file(struct kref *ref)
kfree(file); kfree(file);
} }
static ssize_t ib_uverbs_event_read(struct ib_uverbs_event_file *file, static ssize_t ib_uverbs_event_read(struct ib_uverbs_event_queue *ev_queue,
struct ib_uverbs_file *uverbs_file, struct ib_uverbs_file *uverbs_file,
struct file *filp, char __user *buf, struct file *filp, char __user *buf,
size_t count, loff_t *pos, size_t count, loff_t *pos,
...@@ -262,16 +262,16 @@ static ssize_t ib_uverbs_event_read(struct ib_uverbs_event_file *file, ...@@ -262,16 +262,16 @@ static ssize_t ib_uverbs_event_read(struct ib_uverbs_event_file *file,
struct ib_uverbs_event *event; struct ib_uverbs_event *event;
int ret = 0; int ret = 0;
spin_lock_irq(&file->lock); spin_lock_irq(&ev_queue->lock);
while (list_empty(&file->event_list)) { while (list_empty(&ev_queue->event_list)) {
spin_unlock_irq(&file->lock); spin_unlock_irq(&ev_queue->lock);
if (filp->f_flags & O_NONBLOCK) if (filp->f_flags & O_NONBLOCK)
return -EAGAIN; return -EAGAIN;
if (wait_event_interruptible(file->poll_wait, if (wait_event_interruptible(ev_queue->poll_wait,
(!list_empty(&file->event_list) || (!list_empty(&ev_queue->event_list) ||
/* The barriers built into wait_event_interruptible() /* The barriers built into wait_event_interruptible()
* and wake_up() guarentee this will see the null set * and wake_up() guarentee this will see the null set
* without using RCU * without using RCU
...@@ -280,27 +280,27 @@ static ssize_t ib_uverbs_event_read(struct ib_uverbs_event_file *file, ...@@ -280,27 +280,27 @@ static ssize_t ib_uverbs_event_read(struct ib_uverbs_event_file *file,
return -ERESTARTSYS; return -ERESTARTSYS;
/* If device was disassociated and no event exists set an error */ /* If device was disassociated and no event exists set an error */
if (list_empty(&file->event_list) && if (list_empty(&ev_queue->event_list) &&
!uverbs_file->device->ib_dev) !uverbs_file->device->ib_dev)
return -EIO; return -EIO;
spin_lock_irq(&file->lock); spin_lock_irq(&ev_queue->lock);
} }
event = list_entry(file->event_list.next, struct ib_uverbs_event, list); event = list_entry(ev_queue->event_list.next, struct ib_uverbs_event, list);
if (eventsz > count) { if (eventsz > count) {
ret = -EINVAL; ret = -EINVAL;
event = NULL; event = NULL;
} else { } else {
list_del(file->event_list.next); list_del(ev_queue->event_list.next);
if (event->counter) { if (event->counter) {
++(*event->counter); ++(*event->counter);
list_del(&event->obj_list); list_del(&event->obj_list);
} }
} }
spin_unlock_irq(&file->lock); spin_unlock_irq(&ev_queue->lock);
if (event) { if (event) {
if (copy_to_user(buf, event, eventsz)) if (copy_to_user(buf, event, eventsz))
...@@ -319,7 +319,7 @@ static ssize_t ib_uverbs_async_event_read(struct file *filp, char __user *buf, ...@@ -319,7 +319,7 @@ static ssize_t ib_uverbs_async_event_read(struct file *filp, char __user *buf,
{ {
struct ib_uverbs_async_event_file *file = filp->private_data; struct ib_uverbs_async_event_file *file = filp->private_data;
return ib_uverbs_event_read(&file->ev_file, file->uverbs_file, filp, return ib_uverbs_event_read(&file->ev_queue, file->uverbs_file, filp,
buf, count, pos, buf, count, pos,
sizeof(struct ib_uverbs_async_event_desc)); sizeof(struct ib_uverbs_async_event_desc));
} }
...@@ -330,24 +330,24 @@ static ssize_t ib_uverbs_comp_event_read(struct file *filp, char __user *buf, ...@@ -330,24 +330,24 @@ static ssize_t ib_uverbs_comp_event_read(struct file *filp, char __user *buf,
struct ib_uverbs_completion_event_file *comp_ev_file = struct ib_uverbs_completion_event_file *comp_ev_file =
filp->private_data; filp->private_data;
return ib_uverbs_event_read(&comp_ev_file->ev_file, return ib_uverbs_event_read(&comp_ev_file->ev_queue,
comp_ev_file->uobj_file.ufile, filp, comp_ev_file->uobj_file.ufile, filp,
buf, count, pos, buf, count, pos,
sizeof(struct ib_uverbs_comp_event_desc)); sizeof(struct ib_uverbs_comp_event_desc));
} }
static unsigned int ib_uverbs_event_poll(struct ib_uverbs_event_file *file, static unsigned int ib_uverbs_event_poll(struct ib_uverbs_event_queue *ev_queue,
struct file *filp, struct file *filp,
struct poll_table_struct *wait) struct poll_table_struct *wait)
{ {
unsigned int pollflags = 0; unsigned int pollflags = 0;
poll_wait(filp, &file->poll_wait, wait); poll_wait(filp, &ev_queue->poll_wait, wait);
spin_lock_irq(&file->lock); spin_lock_irq(&ev_queue->lock);
if (!list_empty(&file->event_list)) if (!list_empty(&ev_queue->event_list))
pollflags = POLLIN | POLLRDNORM; pollflags = POLLIN | POLLRDNORM;
spin_unlock_irq(&file->lock); spin_unlock_irq(&ev_queue->lock);
return pollflags; return pollflags;
} }
...@@ -364,14 +364,14 @@ static unsigned int ib_uverbs_comp_event_poll(struct file *filp, ...@@ -364,14 +364,14 @@ static unsigned int ib_uverbs_comp_event_poll(struct file *filp,
struct ib_uverbs_completion_event_file *comp_ev_file = struct ib_uverbs_completion_event_file *comp_ev_file =
filp->private_data; filp->private_data;
return ib_uverbs_event_poll(&comp_ev_file->ev_file, filp, wait); return ib_uverbs_event_poll(&comp_ev_file->ev_queue, filp, wait);
} }
static int ib_uverbs_async_event_fasync(int fd, struct file *filp, int on) static int ib_uverbs_async_event_fasync(int fd, struct file *filp, int on)
{ {
struct ib_uverbs_event_file *file = filp->private_data; struct ib_uverbs_event_queue *ev_queue = filp->private_data;
return fasync_helper(fd, filp, on, &file->async_queue); return fasync_helper(fd, filp, on, &ev_queue->async_queue);
} }
static int ib_uverbs_comp_event_fasync(int fd, struct file *filp, int on) static int ib_uverbs_comp_event_fasync(int fd, struct file *filp, int on)
...@@ -379,7 +379,7 @@ static int ib_uverbs_comp_event_fasync(int fd, struct file *filp, int on) ...@@ -379,7 +379,7 @@ static int ib_uverbs_comp_event_fasync(int fd, struct file *filp, int on)
struct ib_uverbs_completion_event_file *comp_ev_file = struct ib_uverbs_completion_event_file *comp_ev_file =
filp->private_data; filp->private_data;
return fasync_helper(fd, filp, on, &comp_ev_file->ev_file.async_queue); return fasync_helper(fd, filp, on, &comp_ev_file->ev_queue.async_queue);
} }
static int ib_uverbs_async_event_close(struct inode *inode, struct file *filp) static int ib_uverbs_async_event_close(struct inode *inode, struct file *filp)
...@@ -390,15 +390,15 @@ static int ib_uverbs_async_event_close(struct inode *inode, struct file *filp) ...@@ -390,15 +390,15 @@ static int ib_uverbs_async_event_close(struct inode *inode, struct file *filp)
int closed_already = 0; int closed_already = 0;
mutex_lock(&uverbs_file->device->lists_mutex); mutex_lock(&uverbs_file->device->lists_mutex);
spin_lock_irq(&file->ev_file.lock); spin_lock_irq(&file->ev_queue.lock);
closed_already = file->ev_file.is_closed; closed_already = file->ev_queue.is_closed;
file->ev_file.is_closed = 1; file->ev_queue.is_closed = 1;
list_for_each_entry_safe(entry, tmp, &file->ev_file.event_list, list) { list_for_each_entry_safe(entry, tmp, &file->ev_queue.event_list, list) {
if (entry->counter) if (entry->counter)
list_del(&entry->obj_list); list_del(&entry->obj_list);
kfree(entry); kfree(entry);
} }
spin_unlock_irq(&file->ev_file.lock); spin_unlock_irq(&file->ev_queue.lock);
if (!closed_already) { if (!closed_already) {
list_del(&file->list); list_del(&file->list);
ib_unregister_event_handler(&uverbs_file->event_handler); ib_unregister_event_handler(&uverbs_file->event_handler);
...@@ -416,13 +416,13 @@ static int ib_uverbs_comp_event_close(struct inode *inode, struct file *filp) ...@@ -416,13 +416,13 @@ static int ib_uverbs_comp_event_close(struct inode *inode, struct file *filp)
struct ib_uverbs_completion_event_file *file = filp->private_data; struct ib_uverbs_completion_event_file *file = filp->private_data;
struct ib_uverbs_event *entry, *tmp; struct ib_uverbs_event *entry, *tmp;
spin_lock_irq(&file->ev_file.lock); spin_lock_irq(&file->ev_queue.lock);
list_for_each_entry_safe(entry, tmp, &file->ev_file.event_list, list) { list_for_each_entry_safe(entry, tmp, &file->ev_queue.event_list, list) {
if (entry->counter) if (entry->counter)
list_del(&entry->obj_list); list_del(&entry->obj_list);
kfree(entry); kfree(entry);
} }
spin_unlock_irq(&file->ev_file.lock); spin_unlock_irq(&file->ev_queue.lock);
uverbs_close_fd(filp); uverbs_close_fd(filp);
...@@ -449,23 +449,23 @@ static const struct file_operations uverbs_async_event_fops = { ...@@ -449,23 +449,23 @@ static const struct file_operations uverbs_async_event_fops = {
void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context) void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context)
{ {
struct ib_uverbs_event_file *file = cq_context; struct ib_uverbs_event_queue *ev_queue = cq_context;
struct ib_ucq_object *uobj; struct ib_ucq_object *uobj;
struct ib_uverbs_event *entry; struct ib_uverbs_event *entry;
unsigned long flags; unsigned long flags;
if (!file) if (!ev_queue)
return; return;
spin_lock_irqsave(&file->lock, flags); spin_lock_irqsave(&ev_queue->lock, flags);
if (file->is_closed) { if (ev_queue->is_closed) {
spin_unlock_irqrestore(&file->lock, flags); spin_unlock_irqrestore(&ev_queue->lock, flags);
return; return;
} }
entry = kmalloc(sizeof *entry, GFP_ATOMIC); entry = kmalloc(sizeof *entry, GFP_ATOMIC);
if (!entry) { if (!entry) {
spin_unlock_irqrestore(&file->lock, flags); spin_unlock_irqrestore(&ev_queue->lock, flags);
return; return;
} }
...@@ -474,12 +474,12 @@ void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context) ...@@ -474,12 +474,12 @@ void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context)
entry->desc.comp.cq_handle = cq->uobject->user_handle; entry->desc.comp.cq_handle = cq->uobject->user_handle;
entry->counter = &uobj->comp_events_reported; entry->counter = &uobj->comp_events_reported;
list_add_tail(&entry->list, &file->event_list); list_add_tail(&entry->list, &ev_queue->event_list);
list_add_tail(&entry->obj_list, &uobj->comp_list); list_add_tail(&entry->obj_list, &uobj->comp_list);
spin_unlock_irqrestore(&file->lock, flags); spin_unlock_irqrestore(&ev_queue->lock, flags);
wake_up_interruptible(&file->poll_wait); wake_up_interruptible(&ev_queue->poll_wait);
kill_fasync(&file->async_queue, SIGIO, POLL_IN); kill_fasync(&ev_queue->async_queue, SIGIO, POLL_IN);
} }
static void ib_uverbs_async_handler(struct ib_uverbs_file *file, static void ib_uverbs_async_handler(struct ib_uverbs_file *file,
...@@ -490,15 +490,15 @@ static void ib_uverbs_async_handler(struct ib_uverbs_file *file, ...@@ -490,15 +490,15 @@ static void ib_uverbs_async_handler(struct ib_uverbs_file *file,
struct ib_uverbs_event *entry; struct ib_uverbs_event *entry;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&file->async_file->ev_file.lock, flags); spin_lock_irqsave(&file->async_file->ev_queue.lock, flags);
if (file->async_file->ev_file.is_closed) { if (file->async_file->ev_queue.is_closed) {
spin_unlock_irqrestore(&file->async_file->ev_file.lock, flags); spin_unlock_irqrestore(&file->async_file->ev_queue.lock, flags);
return; return;
} }
entry = kmalloc(sizeof *entry, GFP_ATOMIC); entry = kmalloc(sizeof *entry, GFP_ATOMIC);
if (!entry) { if (!entry) {
spin_unlock_irqrestore(&file->async_file->ev_file.lock, flags); spin_unlock_irqrestore(&file->async_file->ev_queue.lock, flags);
return; return;
} }
...@@ -507,13 +507,13 @@ static void ib_uverbs_async_handler(struct ib_uverbs_file *file, ...@@ -507,13 +507,13 @@ static void ib_uverbs_async_handler(struct ib_uverbs_file *file,
entry->desc.async.reserved = 0; entry->desc.async.reserved = 0;
entry->counter = counter; entry->counter = counter;
list_add_tail(&entry->list, &file->async_file->ev_file.event_list); list_add_tail(&entry->list, &file->async_file->ev_queue.event_list);
if (obj_list) if (obj_list)
list_add_tail(&entry->obj_list, obj_list); list_add_tail(&entry->obj_list, obj_list);
spin_unlock_irqrestore(&file->async_file->ev_file.lock, flags); spin_unlock_irqrestore(&file->async_file->ev_queue.lock, flags);
wake_up_interruptible(&file->async_file->ev_file.poll_wait); wake_up_interruptible(&file->async_file->ev_queue.poll_wait);
kill_fasync(&file->async_file->ev_file.async_queue, SIGIO, POLL_IN); kill_fasync(&file->async_file->ev_queue.async_queue, SIGIO, POLL_IN);
} }
void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr) void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr)
...@@ -580,13 +580,13 @@ void ib_uverbs_free_async_event_file(struct ib_uverbs_file *file) ...@@ -580,13 +580,13 @@ void ib_uverbs_free_async_event_file(struct ib_uverbs_file *file)
file->async_file = NULL; file->async_file = NULL;
} }
void ib_uverbs_init_event_file(struct ib_uverbs_event_file *ev_file) void ib_uverbs_init_event_queue(struct ib_uverbs_event_queue *ev_queue)
{ {
spin_lock_init(&ev_file->lock); spin_lock_init(&ev_queue->lock);
INIT_LIST_HEAD(&ev_file->event_list); INIT_LIST_HEAD(&ev_queue->event_list);
init_waitqueue_head(&ev_file->poll_wait); init_waitqueue_head(&ev_queue->poll_wait);
ev_file->is_closed = 0; ev_queue->is_closed = 0;
ev_file->async_queue = NULL; ev_queue->async_queue = NULL;
} }
struct file *ib_uverbs_alloc_async_event_file(struct ib_uverbs_file *uverbs_file, struct file *ib_uverbs_alloc_async_event_file(struct ib_uverbs_file *uverbs_file,
...@@ -600,7 +600,7 @@ struct file *ib_uverbs_alloc_async_event_file(struct ib_uverbs_file *uverbs_file ...@@ -600,7 +600,7 @@ struct file *ib_uverbs_alloc_async_event_file(struct ib_uverbs_file *uverbs_file
if (!ev_file) if (!ev_file)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
ib_uverbs_init_event_file(&ev_file->ev_file); ib_uverbs_init_event_queue(&ev_file->ev_queue);
ev_file->uverbs_file = uverbs_file; ev_file->uverbs_file = uverbs_file;
kref_get(&ev_file->uverbs_file->ref); kref_get(&ev_file->uverbs_file->ref);
kref_init(&ev_file->ref); kref_init(&ev_file->ref);
...@@ -1186,9 +1186,9 @@ static void ib_uverbs_free_hw_resources(struct ib_uverbs_device *uverbs_dev, ...@@ -1186,9 +1186,9 @@ static void ib_uverbs_free_hw_resources(struct ib_uverbs_device *uverbs_dev,
uverbs_events_file_list, uverbs_events_file_list,
struct ib_uverbs_async_event_file, struct ib_uverbs_async_event_file,
list); list);
spin_lock_irq(&event_file->ev_file.lock); spin_lock_irq(&event_file->ev_queue.lock);
event_file->ev_file.is_closed = 1; event_file->ev_queue.is_closed = 1;
spin_unlock_irq(&event_file->ev_file.lock); spin_unlock_irq(&event_file->ev_queue.lock);
list_del(&event_file->list); list_del(&event_file->list);
ib_unregister_event_handler( ib_unregister_event_handler(
...@@ -1196,8 +1196,8 @@ static void ib_uverbs_free_hw_resources(struct ib_uverbs_device *uverbs_dev, ...@@ -1196,8 +1196,8 @@ static void ib_uverbs_free_hw_resources(struct ib_uverbs_device *uverbs_dev,
event_file->uverbs_file->event_handler.device = event_file->uverbs_file->event_handler.device =
NULL; NULL;
wake_up_interruptible(&event_file->ev_file.poll_wait); wake_up_interruptible(&event_file->ev_queue.poll_wait);
kill_fasync(&event_file->ev_file.async_queue, SIGIO, POLL_IN); kill_fasync(&event_file->ev_queue.async_queue, SIGIO, POLL_IN);
} }
mutex_unlock(&uverbs_dev->lists_mutex); mutex_unlock(&uverbs_dev->lists_mutex);
} }
......
...@@ -138,17 +138,17 @@ int uverbs_free_cq(struct ib_uobject *uobject, ...@@ -138,17 +138,17 @@ int uverbs_free_cq(struct ib_uobject *uobject,
enum rdma_remove_reason why) enum rdma_remove_reason why)
{ {
struct ib_cq *cq = uobject->object; struct ib_cq *cq = uobject->object;
struct ib_uverbs_event_file *ev_file = cq->cq_context; struct ib_uverbs_event_queue *ev_queue = cq->cq_context;
struct ib_ucq_object *ucq = struct ib_ucq_object *ucq =
container_of(uobject, struct ib_ucq_object, uobject); container_of(uobject, struct ib_ucq_object, uobject);
int ret; int ret;
ret = ib_destroy_cq(cq); ret = ib_destroy_cq(cq);
if (!ret || why != RDMA_REMOVE_DESTROY) if (!ret || why != RDMA_REMOVE_DESTROY)
ib_uverbs_release_ucq(uobject->context->ufile, ev_file ? ib_uverbs_release_ucq(uobject->context->ufile, ev_queue ?
container_of(ev_file, container_of(ev_queue,
struct ib_uverbs_completion_event_file, struct ib_uverbs_completion_event_file,
ev_file) : NULL, ev_queue) : NULL,
ucq); ucq);
return ret; return ret;
} }
...@@ -196,15 +196,15 @@ int uverbs_hot_unplug_completion_event_file(struct ib_uobject_file *uobj_file, ...@@ -196,15 +196,15 @@ int uverbs_hot_unplug_completion_event_file(struct ib_uobject_file *uobj_file,
struct ib_uverbs_completion_event_file *comp_event_file = struct ib_uverbs_completion_event_file *comp_event_file =
container_of(uobj_file, struct ib_uverbs_completion_event_file, container_of(uobj_file, struct ib_uverbs_completion_event_file,
uobj_file); uobj_file);
struct ib_uverbs_event_file *event_file = &comp_event_file->ev_file; struct ib_uverbs_event_queue *event_queue = &comp_event_file->ev_queue;
spin_lock_irq(&event_file->lock); spin_lock_irq(&event_queue->lock);
event_file->is_closed = 1; event_queue->is_closed = 1;
spin_unlock_irq(&event_file->lock); spin_unlock_irq(&event_queue->lock);
if (why == RDMA_REMOVE_DRIVER_REMOVE) { if (why == RDMA_REMOVE_DRIVER_REMOVE) {
wake_up_interruptible(&event_file->poll_wait); wake_up_interruptible(&event_queue->poll_wait);
kill_fasync(&event_file->async_queue, SIGIO, POLL_IN); kill_fasync(&event_queue->async_queue, SIGIO, POLL_IN);
} }
return 0; return 0;
}; };
......
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