V4L/DVB (9727): cx18: Adjust outgoing mailbox timeouts and remove statistics logging
authorAndy Walls <awalls@radix.net>
Sat, 22 Nov 2008 04:23:22 +0000 (01:23 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 30 Dec 2008 11:38:11 +0000 (09:38 -0200)
cx18: Adjust outgoing mailbox timeouts and remove statistics logging.
This saves some wasted storage in struct cx18 for each card.  Cutting
the outgoing mailbox timeouts in half from the previous value appears to
be safe with MythTV.  Got rid of interrupted case code path after
a wait uninterruptable returns.

Signed-off-by: Andy Walls <awalls@radix.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/cx18/cx18-driver.c
drivers/media/video/cx18/cx18-driver.h
drivers/media/video/cx18/cx18-io.c
drivers/media/video/cx18/cx18-io.h
drivers/media/video/cx18/cx18-ioctl.c
drivers/media/video/cx18/cx18-mailbox.c

index 88ce1e8..fbcbb50 100644 (file)
@@ -834,7 +834,6 @@ err:
        if (retval == 0)
                retval = -ENODEV;
        CX18_ERR("Error %d on initialization\n", retval);
-       cx18_log_statistics(cx);
 
        i = cx->num;
        spin_lock(&cx18_cards_lock);
@@ -951,7 +950,6 @@ static void cx18_remove(struct pci_dev *pci_dev)
 
        pci_disable_device(cx->dev);
 
-       cx18_log_statistics(cx);
        CX18_INFO("Removed %s, card #%d\n", cx->card_name, cx->num);
 }
 
index f06290d..6e4c90e 100644 (file)
@@ -367,11 +367,6 @@ struct cx18_i2c_algo_callback_data {
 };
 
 #define CX18_MAX_MMIO_WR_RETRIES 10
-#define CX18_MAX_MB_ACK_DELAY 100
-
-struct cx18_mbox_stats {
-       atomic_t mb_ack_delay[CX18_MAX_MB_ACK_DELAY+1];
-};
 
 /* Struct to hold info about cx18 cards */
 struct cx18 {
@@ -467,9 +462,6 @@ struct cx18 {
        u32 gpio_val;
        struct mutex gpio_lock;
 
-       /* Statistics */
-       struct cx18_mbox_stats mbox_stats;
-
        /* v4l2 and User settings */
 
        /* codec settings */
index c6f1d0d..ec5b3d7 100644 (file)
 #include "cx18-io.h"
 #include "cx18-irq.h"
 
-void cx18_log_statistics(struct cx18 *cx)
-{
-       int i;
-
-       if (!(cx18_debug & CX18_DBGFLG_INFO))
-               return;
-
-       for (i = 0; i <= CX18_MAX_MB_ACK_DELAY; i++)
-               if (atomic_read(&cx->mbox_stats.mb_ack_delay[i]))
-                       CX18_DEBUG_INFO("mb_ack_delay[%d] = %d\n", i,
-                                 atomic_read(&cx->mbox_stats.mb_ack_delay[i]));
-       return;
-}
-
 void cx18_memset_io(struct cx18 *cx, void __iomem *addr, int val, size_t count)
 {
        u8 __iomem *dst = addr;
index 73321fb..e6716dc 100644 (file)
  * *read* functions never retry the mmio (it never helps to do so)
  */
 
-/* Statistics gathering */
-
-void cx18_log_statistics(struct cx18 *cx);
-
 /* Non byteswapping memory mapped IO */
 static inline u32 cx18_raw_readl(struct cx18 *cx, const void __iomem *addr)
 {
index f0ca50f..a0e6673 100644 (file)
@@ -752,7 +752,6 @@ static int cx18_log_status(struct file *file, void *fh)
        CX18_INFO("Read MPEG/VBI: %lld/%lld bytes\n",
                        (long long)cx->mpg_data_received,
                        (long long)cx->vbi_data_inserted);
-       cx18_log_statistics(cx);
        CX18_INFO("==================  END STATUS CARD #%d  ==================\n", cx->num);
        return 0;
 }
index abd39aa..79647c6 100644 (file)
@@ -462,13 +462,6 @@ void cx18_api_epu_cmd_irq(struct cx18 *cx, int rpu)
  * Functions called from a non-interrupt, non work_queue context
  */
 
-static void cx18_api_log_ack_delay(struct cx18 *cx, int msecs)
-{
-       if (msecs > CX18_MAX_MB_ACK_DELAY)
-               msecs = CX18_MAX_MB_ACK_DELAY;
-       atomic_inc(&cx->mbox_stats.mb_ack_delay[msecs]);
-}
-
 static int cx18_api_call(struct cx18 *cx, u32 cmd, int args, u32 data[])
 {
        const struct cx18_api_info *info = find_api_info(cmd);
@@ -523,7 +516,7 @@ static int cx18_api_call(struct cx18 *cx, u32 cmd, int args, u32 data[])
         */
        state = cx18_readl(cx, xpu_state);
        req = cx18_readl(cx, &mb->request);
-       timeout = msecs_to_jiffies(20); /* 1 field at 50 Hz vertical refresh */
+       timeout = msecs_to_jiffies(10);
        ret = wait_event_timeout(*waitq,
                                 (ack = cx18_readl(cx, &mb->ack)) == req,
                                 timeout);
@@ -533,8 +526,8 @@ static int cx18_api_call(struct cx18 *cx, u32 cmd, int args, u32 data[])
                CX18_ERR("mbox was found stuck busy when setting up for %s; "
                         "clearing busy and trying to proceed\n", info->name);
        } else if (ret != timeout)
-               CX18_DEBUG_API("waited %u usecs for busy mbox to be acked\n",
-                              jiffies_to_usecs(timeout-ret));
+               CX18_DEBUG_API("waited %u msecs for busy mbox to be acked\n",
+                              jiffies_to_msecs(timeout-ret));
 
        /* Build the outgoing mailbox */
        req = ((req & 0xfffffffe) == 0xfffffffe) ? 1 : req + 1;
@@ -548,10 +541,8 @@ static int cx18_api_call(struct cx18 *cx, u32 cmd, int args, u32 data[])
 
        /*
         * Notify the XPU and wait for it to send an Ack back
-        * 21 ms = ~ 0.5 frames at a frame rate of 24 fps
-        * 42 ms = ~ 1 frame at a frame rate of 24 fps
         */
-       timeout = msecs_to_jiffies((info->flags & API_FAST) ? 21 : 42);
+       timeout = msecs_to_jiffies((info->flags & API_FAST) ? 10 : 20);
 
        CX18_DEBUG_HI_IRQ("sending interrupt SW1: %x to send %s\n",
                          irq, info->name);
@@ -561,27 +552,19 @@ static int cx18_api_call(struct cx18 *cx, u32 cmd, int args, u32 data[])
                       *waitq,
                       cx18_readl(cx, &mb->ack) == cx18_readl(cx, &mb->request),
                       timeout);
+
        if (ret == 0) {
                /* Timed out */
                mutex_unlock(mb_lock);
-               i = jiffies_to_msecs(timeout);
-               cx18_api_log_ack_delay(cx, i);
                CX18_WARN("sending %s timed out waiting %d msecs for RPU "
-                         "acknowledgement\n", info->name, i);
+                         "acknowledgement\n",
+                         info->name, jiffies_to_msecs(timeout));
                return -EINVAL;
-       } else if (ret < 0) {
-               /* Interrupted */
-               mutex_unlock(mb_lock);
-               CX18_WARN("sending %s was interrupted waiting for RPU"
-                         "acknowledgement\n", info->name);
-               return -EINTR;
        }
 
-       i = jiffies_to_msecs(timeout-ret);
-       cx18_api_log_ack_delay(cx, i);
        if (ret != timeout)
                CX18_DEBUG_HI_API("waited %u msecs for %s to be acked\n",
-                                 i, info->name);
+                                 jiffies_to_msecs(timeout-ret), info->name);
 
        /* Collect data returned by the XPU */
        for (i = 0; i < MAX_MB_ARGUMENTS; i++)