[openib-general] Re: [PATCH] signal driven io support for ib_uverbs

Roland Dreier rolandd at cisco.com
Wed Jul 6 14:35:03 PDT 2005


How does this patch look?

Do you have a test program you're using to check SIGIO-based event
handling?  If so can you post it?

Thanks,
  Roland

--- infiniband/core/uverbs.h	(revision 2815)
+++ infiniband/core/uverbs.h	(working copy)
@@ -62,6 +62,7 @@ struct ib_uverbs_event_file {
 	int					fd;
 	int					is_async;
 	wait_queue_head_t			poll_wait;
+	struct fasync_struct		       *async_queue;
 	struct list_head			event_list;
 };
 
--- infiniband/core/uverbs_main.c	(revision 2815)
+++ infiniband/core/uverbs_main.c	(working copy)
@@ -258,11 +258,19 @@ static void ib_uverbs_event_release(stru
 	spin_unlock_irq(&file->lock);
 }
 
+static int ib_uverbs_event_fasync(int fd, struct file *filp, int on)
+{
+	struct ib_uverbs_event_file *file = filp->private_data;
+
+	return fasync_helper(fd, filp, on, &file->async_queue);
+}
+
 static int ib_uverbs_event_close(struct inode *inode, struct file *filp)
 {
 	struct ib_uverbs_event_file *file = filp->private_data;
 
 	ib_uverbs_event_release(file);
+	ib_uverbs_event_fasync(-1, filp, 0);
 	kref_put(&file->uverbs_file->ref, ib_uverbs_release_file);
 
 	return 0;
@@ -277,7 +285,8 @@ static struct file_operations uverbs_eve
 	 */
 	.read 	 = ib_uverbs_event_read,
 	.poll    = ib_uverbs_event_poll,
-	.release = ib_uverbs_event_close
+	.release = ib_uverbs_event_close,
+	.fasync  = ib_uverbs_event_fasync
 };
 
 void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context)
@@ -297,6 +306,7 @@ void ib_uverbs_comp_handler(struct ib_cq
 	spin_unlock_irqrestore(&file->comp_file[0].lock, flags);
 
 	wake_up_interruptible(&file->comp_file[0].poll_wait);
+	kill_fasync(&file->comp_file[0].async_queue, SIGIO, POLL_IN);
 }
 
 static void ib_uverbs_async_handler(struct ib_uverbs_file *file,
@@ -317,6 +327,7 @@ static void ib_uverbs_async_handler(stru
 	spin_unlock_irqrestore(&file->async_file.lock, flags);
 
 	wake_up_interruptible(&file->async_file.poll_wait);
+	kill_fasync(&file->async_file.async_queue, SIGIO, POLL_IN);
 }
 
 void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr)
@@ -351,6 +362,7 @@ static int ib_uverbs_event_init(struct i
 	INIT_LIST_HEAD(&file->event_list);
 	init_waitqueue_head(&file->poll_wait);
 	file->uverbs_file = uverbs_file;
+	file->async_queue = NULL;
 
 	file->fd = get_unused_fd();
 	if (file->fd < 0)



More information about the general mailing list