staging: unisys: visorchannel: Add peek function
authorNeil Horman <nhorman@redhat.com>
Fri, 31 Jul 2015 22:56:32 +0000 (18:56 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 4 Aug 2015 00:45:02 +0000 (17:45 -0700)
According to unisys, the s_par hypervisor has a bug in which it never
triggers an interrupt.  That makes the visornic effectively a 2ms poll
loop.  In order to just have the rx thread shceduling a napi poll every
2ms, lets instead give it the chance to check the response queue for
data before we schedule.  This helper provides that functionality

Signed-off-by: Neil Horman <nhorman@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/unisys/include/visorbus.h
drivers/staging/unisys/visorbus/visorchannel.c

index a0144c6a8ad18e959a3bcaab35bb290551bd326e..9235536fa75f76ee2ace83093dec44e80b59efee 100644 (file)
@@ -201,6 +201,8 @@ bool visorchannel_signalremove(struct visorchannel *channel, u32 queue,
                               void *msg);
 bool visorchannel_signalinsert(struct visorchannel *channel, u32 queue,
                               void *msg);
+bool visorchannel_signalempty(struct visorchannel *channel, u32 queue);
+
 int visorchannel_signalqueue_slots_avail(struct visorchannel *channel,
                                         u32 queue);
 int visorchannel_signalqueue_max_slots(struct visorchannel *channel, u32 queue);
index 242246492b7a6dc6c098532a493c1bdde3adbcb5..6da7e49a662758c7e673aea32705a86e2269cb2c 100644 (file)
@@ -430,6 +430,27 @@ visorchannel_signalremove(struct visorchannel *channel, u32 queue, void *msg)
 }
 EXPORT_SYMBOL_GPL(visorchannel_signalremove);
 
+bool
+visorchannel_signalempty(struct visorchannel *channel, u32 queue)
+{
+       unsigned long flags = 0;
+       struct signal_queue_header sig_hdr;
+       bool rc = false;
+
+       if (channel->needs_lock)
+               spin_lock_irqsave(&channel->remove_lock, flags);
+
+       if (!sig_read_header(channel, queue, &sig_hdr))
+               rc = true;
+       if (sig_hdr.head == sig_hdr.tail)
+               rc = true;
+       if (channel->needs_lock)
+               spin_unlock_irqrestore(&channel->remove_lock, flags);
+
+       return rc;
+}
+EXPORT_SYMBOL_GPL(visorchannel_signalempty);
+
 static bool
 signalinsert_inner(struct visorchannel *channel, u32 queue, void *msg)
 {