Skip to content

Commit

Permalink
V4L/DVB (9727): cx18: Adjust outgoing mailbox timeouts and remove sta…
Browse files Browse the repository at this point in the history
…tistics logging

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>
  • Loading branch information
Andy Walls authored and Mauro Carvalho Chehab committed Dec 30, 2008
1 parent bca11a5 commit 2bb49f1
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 54 deletions.
2 changes: 0 additions & 2 deletions drivers/media/video/cx18/cx18-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,6 @@ static int __devinit cx18_probe(struct pci_dev *dev,
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);
Expand Down Expand Up @@ -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);
}

Expand Down
8 changes: 0 additions & 8 deletions drivers/media/video/cx18/cx18-driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 */
Expand Down
14 changes: 0 additions & 14 deletions drivers/media/video/cx18/cx18-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,6 @@
#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;
Expand Down
4 changes: 0 additions & 4 deletions drivers/media/video/cx18/cx18-io.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@
* *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)
{
Expand Down
1 change: 0 additions & 1 deletion drivers/media/video/cx18/cx18-ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
33 changes: 8 additions & 25 deletions drivers/media/video/cx18/cx18-mailbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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++)
Expand Down

0 comments on commit 2bb49f1

Please sign in to comment.