aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx18
diff options
context:
space:
mode:
authorAndy Walls <awalls@radix.net>2008-11-21 23:23:22 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-12-30 06:38:11 -0500
commit2bb49f1b9f6a4f50222bc8a6b1e9df87a432c52c (patch)
tree0fa23a00811ba598d0a2f6ead3b14492b31fe6fb /drivers/media/video/cx18
parentbca11a5721917d6d5874571813673a2669ffec4b (diff)
V4L/DVB (9727): cx18: Adjust outgoing mailbox timeouts and remove statistics 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>
Diffstat (limited to 'drivers/media/video/cx18')
-rw-r--r--drivers/media/video/cx18/cx18-driver.c2
-rw-r--r--drivers/media/video/cx18/cx18-driver.h8
-rw-r--r--drivers/media/video/cx18/cx18-io.c14
-rw-r--r--drivers/media/video/cx18/cx18-io.h4
-rw-r--r--drivers/media/video/cx18/cx18-ioctl.c1
-rw-r--r--drivers/media/video/cx18/cx18-mailbox.c33
6 files changed, 8 insertions, 54 deletions
diff --git a/drivers/media/video/cx18/cx18-driver.c b/drivers/media/video/cx18/cx18-driver.c
index 88ce1e831221..fbcbb500ca74 100644
--- a/drivers/media/video/cx18/cx18-driver.c
+++ b/drivers/media/video/cx18/cx18-driver.c
@@ -834,7 +834,6 @@ err:
834 if (retval == 0) 834 if (retval == 0)
835 retval = -ENODEV; 835 retval = -ENODEV;
836 CX18_ERR("Error %d on initialization\n", retval); 836 CX18_ERR("Error %d on initialization\n", retval);
837 cx18_log_statistics(cx);
838 837
839 i = cx->num; 838 i = cx->num;
840 spin_lock(&cx18_cards_lock); 839 spin_lock(&cx18_cards_lock);
@@ -951,7 +950,6 @@ static void cx18_remove(struct pci_dev *pci_dev)
951 950
952 pci_disable_device(cx->dev); 951 pci_disable_device(cx->dev);
953 952
954 cx18_log_statistics(cx);
955 CX18_INFO("Removed %s, card #%d\n", cx->card_name, cx->num); 953 CX18_INFO("Removed %s, card #%d\n", cx->card_name, cx->num);
956} 954}
957 955
diff --git a/drivers/media/video/cx18/cx18-driver.h b/drivers/media/video/cx18/cx18-driver.h
index f06290d32ecf..6e4c90e6cc7c 100644
--- a/drivers/media/video/cx18/cx18-driver.h
+++ b/drivers/media/video/cx18/cx18-driver.h
@@ -367,11 +367,6 @@ struct cx18_i2c_algo_callback_data {
367}; 367};
368 368
369#define CX18_MAX_MMIO_WR_RETRIES 10 369#define CX18_MAX_MMIO_WR_RETRIES 10
370#define CX18_MAX_MB_ACK_DELAY 100
371
372struct cx18_mbox_stats {
373 atomic_t mb_ack_delay[CX18_MAX_MB_ACK_DELAY+1];
374};
375 370
376/* Struct to hold info about cx18 cards */ 371/* Struct to hold info about cx18 cards */
377struct cx18 { 372struct cx18 {
@@ -467,9 +462,6 @@ struct cx18 {
467 u32 gpio_val; 462 u32 gpio_val;
468 struct mutex gpio_lock; 463 struct mutex gpio_lock;
469 464
470 /* Statistics */
471 struct cx18_mbox_stats mbox_stats;
472
473 /* v4l2 and User settings */ 465 /* v4l2 and User settings */
474 466
475 /* codec settings */ 467 /* codec settings */
diff --git a/drivers/media/video/cx18/cx18-io.c b/drivers/media/video/cx18/cx18-io.c
index c6f1d0d7f2c2..ec5b3d7bcc6b 100644
--- a/drivers/media/video/cx18/cx18-io.c
+++ b/drivers/media/video/cx18/cx18-io.c
@@ -24,20 +24,6 @@
24#include "cx18-io.h" 24#include "cx18-io.h"
25#include "cx18-irq.h" 25#include "cx18-irq.h"
26 26
27void cx18_log_statistics(struct cx18 *cx)
28{
29 int i;
30
31 if (!(cx18_debug & CX18_DBGFLG_INFO))
32 return;
33
34 for (i = 0; i <= CX18_MAX_MB_ACK_DELAY; i++)
35 if (atomic_read(&cx->mbox_stats.mb_ack_delay[i]))
36 CX18_DEBUG_INFO("mb_ack_delay[%d] = %d\n", i,
37 atomic_read(&cx->mbox_stats.mb_ack_delay[i]));
38 return;
39}
40
41void cx18_memset_io(struct cx18 *cx, void __iomem *addr, int val, size_t count) 27void cx18_memset_io(struct cx18 *cx, void __iomem *addr, int val, size_t count)
42{ 28{
43 u8 __iomem *dst = addr; 29 u8 __iomem *dst = addr;
diff --git a/drivers/media/video/cx18/cx18-io.h b/drivers/media/video/cx18/cx18-io.h
index 73321fb4cbf5..e6716dcb1e8b 100644
--- a/drivers/media/video/cx18/cx18-io.h
+++ b/drivers/media/video/cx18/cx18-io.h
@@ -34,10 +34,6 @@
34 * *read* functions never retry the mmio (it never helps to do so) 34 * *read* functions never retry the mmio (it never helps to do so)
35 */ 35 */
36 36
37/* Statistics gathering */
38
39void cx18_log_statistics(struct cx18 *cx);
40
41/* Non byteswapping memory mapped IO */ 37/* Non byteswapping memory mapped IO */
42static inline u32 cx18_raw_readl(struct cx18 *cx, const void __iomem *addr) 38static inline u32 cx18_raw_readl(struct cx18 *cx, const void __iomem *addr)
43{ 39{
diff --git a/drivers/media/video/cx18/cx18-ioctl.c b/drivers/media/video/cx18/cx18-ioctl.c
index f0ca50f5fdde..a0e667362cb5 100644
--- a/drivers/media/video/cx18/cx18-ioctl.c
+++ b/drivers/media/video/cx18/cx18-ioctl.c
@@ -752,7 +752,6 @@ static int cx18_log_status(struct file *file, void *fh)
752 CX18_INFO("Read MPEG/VBI: %lld/%lld bytes\n", 752 CX18_INFO("Read MPEG/VBI: %lld/%lld bytes\n",
753 (long long)cx->mpg_data_received, 753 (long long)cx->mpg_data_received,
754 (long long)cx->vbi_data_inserted); 754 (long long)cx->vbi_data_inserted);
755 cx18_log_statistics(cx);
756 CX18_INFO("================== END STATUS CARD #%d ==================\n", cx->num); 755 CX18_INFO("================== END STATUS CARD #%d ==================\n", cx->num);
757 return 0; 756 return 0;
758} 757}
diff --git a/drivers/media/video/cx18/cx18-mailbox.c b/drivers/media/video/cx18/cx18-mailbox.c
index abd39aaa345c..79647c6d6c55 100644
--- a/drivers/media/video/cx18/cx18-mailbox.c
+++ b/drivers/media/video/cx18/cx18-mailbox.c
@@ -462,13 +462,6 @@ void cx18_api_epu_cmd_irq(struct cx18 *cx, int rpu)
462 * Functions called from a non-interrupt, non work_queue context 462 * Functions called from a non-interrupt, non work_queue context
463 */ 463 */
464 464
465static void cx18_api_log_ack_delay(struct cx18 *cx, int msecs)
466{
467 if (msecs > CX18_MAX_MB_ACK_DELAY)
468 msecs = CX18_MAX_MB_ACK_DELAY;
469 atomic_inc(&cx->mbox_stats.mb_ack_delay[msecs]);
470}
471
472static int cx18_api_call(struct cx18 *cx, u32 cmd, int args, u32 data[]) 465static int cx18_api_call(struct cx18 *cx, u32 cmd, int args, u32 data[])
473{ 466{
474 const struct cx18_api_info *info = find_api_info(cmd); 467 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[])
523 */ 516 */
524 state = cx18_readl(cx, xpu_state); 517 state = cx18_readl(cx, xpu_state);
525 req = cx18_readl(cx, &mb->request); 518 req = cx18_readl(cx, &mb->request);
526 timeout = msecs_to_jiffies(20); /* 1 field at 50 Hz vertical refresh */ 519 timeout = msecs_to_jiffies(10);
527 ret = wait_event_timeout(*waitq, 520 ret = wait_event_timeout(*waitq,
528 (ack = cx18_readl(cx, &mb->ack)) == req, 521 (ack = cx18_readl(cx, &mb->ack)) == req,
529 timeout); 522 timeout);
@@ -533,8 +526,8 @@ static int cx18_api_call(struct cx18 *cx, u32 cmd, int args, u32 data[])
533 CX18_ERR("mbox was found stuck busy when setting up for %s; " 526 CX18_ERR("mbox was found stuck busy when setting up for %s; "
534 "clearing busy and trying to proceed\n", info->name); 527 "clearing busy and trying to proceed\n", info->name);
535 } else if (ret != timeout) 528 } else if (ret != timeout)
536 CX18_DEBUG_API("waited %u usecs for busy mbox to be acked\n", 529 CX18_DEBUG_API("waited %u msecs for busy mbox to be acked\n",
537 jiffies_to_usecs(timeout-ret)); 530 jiffies_to_msecs(timeout-ret));
538 531
539 /* Build the outgoing mailbox */ 532 /* Build the outgoing mailbox */
540 req = ((req & 0xfffffffe) == 0xfffffffe) ? 1 : req + 1; 533 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[])
548 541
549 /* 542 /*
550 * Notify the XPU and wait for it to send an Ack back 543 * Notify the XPU and wait for it to send an Ack back
551 * 21 ms = ~ 0.5 frames at a frame rate of 24 fps
552 * 42 ms = ~ 1 frame at a frame rate of 24 fps
553 */ 544 */
554 timeout = msecs_to_jiffies((info->flags & API_FAST) ? 21 : 42); 545 timeout = msecs_to_jiffies((info->flags & API_FAST) ? 10 : 20);
555 546
556 CX18_DEBUG_HI_IRQ("sending interrupt SW1: %x to send %s\n", 547 CX18_DEBUG_HI_IRQ("sending interrupt SW1: %x to send %s\n",
557 irq, info->name); 548 irq, info->name);
@@ -561,27 +552,19 @@ static int cx18_api_call(struct cx18 *cx, u32 cmd, int args, u32 data[])
561 *waitq, 552 *waitq,
562 cx18_readl(cx, &mb->ack) == cx18_readl(cx, &mb->request), 553 cx18_readl(cx, &mb->ack) == cx18_readl(cx, &mb->request),
563 timeout); 554 timeout);
555
564 if (ret == 0) { 556 if (ret == 0) {
565 /* Timed out */ 557 /* Timed out */
566 mutex_unlock(mb_lock); 558 mutex_unlock(mb_lock);
567 i = jiffies_to_msecs(timeout);
568 cx18_api_log_ack_delay(cx, i);
569 CX18_WARN("sending %s timed out waiting %d msecs for RPU " 559 CX18_WARN("sending %s timed out waiting %d msecs for RPU "
570 "acknowledgement\n", info->name, i); 560 "acknowledgement\n",
561 info->name, jiffies_to_msecs(timeout));
571 return -EINVAL; 562 return -EINVAL;
572 } else if (ret < 0) {
573 /* Interrupted */
574 mutex_unlock(mb_lock);
575 CX18_WARN("sending %s was interrupted waiting for RPU"
576 "acknowledgement\n", info->name);
577 return -EINTR;
578 } 563 }
579 564
580 i = jiffies_to_msecs(timeout-ret);
581 cx18_api_log_ack_delay(cx, i);
582 if (ret != timeout) 565 if (ret != timeout)
583 CX18_DEBUG_HI_API("waited %u msecs for %s to be acked\n", 566 CX18_DEBUG_HI_API("waited %u msecs for %s to be acked\n",
584 i, info->name); 567 jiffies_to_msecs(timeout-ret), info->name);
585 568
586 /* Collect data returned by the XPU */ 569 /* Collect data returned by the XPU */
587 for (i = 0; i < MAX_MB_ARGUMENTS; i++) 570 for (i = 0; i < MAX_MB_ARGUMENTS; i++)