aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx18/cx18-io.c
diff options
context:
space:
mode:
authorAndy Walls <awalls@radix.net>2008-09-28 20:46:02 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-10-12 07:37:14 -0400
commitd267d85101c509020a12686b96cbd179deaf4ecd (patch)
tree1a016966d11efb400ca310cd5726478053cd00a0 /drivers/media/video/cx18/cx18-io.c
parent7f9876785276ac7f8606f8bf53a3dae4c10b8adb (diff)
V4L/DVB (9110): cx18: Add default behavior of checking and retrying PCI MMIO accesses
cx18: Add default behavior of checking and retrying PCI MMIO accesses. The concept of checking and retrying PCI MMIO accesses for better reliability in older motherboards was suggested by Steve Toth <stoth@linuxtv.org>. This change implements MMIO retries and the retry_mmio module parameter that is enabled by default. Limited experiments have shown this is more reliable than the mmio_ndelay parameter. mmio_ndelay has insignificant effect with retries enabled. Signed-off-by: Andy Walls <awalls@radix.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/cx18/cx18-io.c')
-rw-r--r--drivers/media/video/cx18/cx18-io.c135
1 files changed, 125 insertions, 10 deletions
diff --git a/drivers/media/video/cx18/cx18-io.c b/drivers/media/video/cx18/cx18-io.c
index 55d1df93292a..700ab9439c16 100644
--- a/drivers/media/video/cx18/cx18-io.c
+++ b/drivers/media/video/cx18/cx18-io.c
@@ -24,6 +24,131 @@
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_MMIO_RETRIES; i++)
35 CX18_DEBUG_INFO("retried_write[%d] = %d\n", i,
36 atomic_read(&cx->mmio_stats.retried_write[i]));
37 for (i = 0; i <= CX18_MAX_MMIO_RETRIES; i++)
38 CX18_DEBUG_INFO("retried_read[%d] = %d\n", i,
39 atomic_read(&cx->mmio_stats.retried_read[i]));
40 return;
41}
42
43void cx18_raw_writel_retry(struct cx18 *cx, u32 val, void __iomem *addr)
44{
45 int i;
46 for (i = 0; i < CX18_MAX_MMIO_RETRIES; i++) {
47 cx18_raw_writel_noretry(cx, val, addr);
48 if (val == cx18_raw_readl_noretry(cx, addr))
49 break;
50 }
51 cx18_log_write_retries(cx, i, addr);
52}
53
54u32 cx18_raw_readl_retry(struct cx18 *cx, const void __iomem *addr)
55{
56 int i;
57 u32 val;
58 for (i = 0; i < CX18_MAX_MMIO_RETRIES; i++) {
59 val = cx18_raw_readl_noretry(cx, addr);
60 if (val != 0xffffffff) /* PCI bus read error */
61 break;
62 }
63 cx18_log_read_retries(cx, i, addr);
64 return val;
65}
66
67u16 cx18_raw_readw_retry(struct cx18 *cx, const void __iomem *addr)
68{
69 int i;
70 u16 val;
71 for (i = 0; i < CX18_MAX_MMIO_RETRIES; i++) {
72 val = cx18_raw_readw_noretry(cx, addr);
73 if (val != 0xffff) /* PCI bus read error */
74 break;
75 }
76 cx18_log_read_retries(cx, i, addr);
77 return val;
78}
79
80void cx18_writel_retry(struct cx18 *cx, u32 val, void __iomem *addr)
81{
82 int i;
83 for (i = 0; i < CX18_MAX_MMIO_RETRIES; i++) {
84 cx18_writel_noretry(cx, val, addr);
85 if (val == cx18_readl_noretry(cx, addr))
86 break;
87 }
88 cx18_log_write_retries(cx, i, addr);
89}
90
91void cx18_writew_retry(struct cx18 *cx, u16 val, void __iomem *addr)
92{
93 int i;
94 for (i = 0; i < CX18_MAX_MMIO_RETRIES; i++) {
95 cx18_writew_noretry(cx, val, addr);
96 if (val == cx18_readw_noretry(cx, addr))
97 break;
98 }
99 cx18_log_write_retries(cx, i, addr);
100}
101
102void cx18_writeb_retry(struct cx18 *cx, u8 val, void __iomem *addr)
103{
104 int i;
105 for (i = 0; i < CX18_MAX_MMIO_RETRIES; i++) {
106 cx18_writeb_noretry(cx, val, addr);
107 if (val == cx18_readb_noretry(cx, addr))
108 break;
109 }
110 cx18_log_write_retries(cx, i, addr);
111}
112
113u32 cx18_readl_retry(struct cx18 *cx, const void __iomem *addr)
114{
115 int i;
116 u32 val;
117 for (i = 0; i < CX18_MAX_MMIO_RETRIES; i++) {
118 val = cx18_readl_noretry(cx, addr);
119 if (val != 0xffffffff) /* PCI bus read error */
120 break;
121 }
122 cx18_log_read_retries(cx, i, addr);
123 return val;
124}
125
126u16 cx18_readw_retry(struct cx18 *cx, const void __iomem *addr)
127{
128 int i;
129 u16 val;
130 for (i = 0; i < CX18_MAX_MMIO_RETRIES; i++) {
131 val = cx18_readw_noretry(cx, addr);
132 if (val != 0xffff) /* PCI bus read error */
133 break;
134 }
135 cx18_log_read_retries(cx, i, addr);
136 return val;
137}
138
139u8 cx18_readb_retry(struct cx18 *cx, const void __iomem *addr)
140{
141 int i;
142 u8 val;
143 for (i = 0; i < CX18_MAX_MMIO_RETRIES; i++) {
144 val = cx18_readb_noretry(cx, addr);
145 if (val != 0xff) /* PCI bus read error */
146 break;
147 }
148 cx18_log_read_retries(cx, i, addr);
149 return val;
150}
151
27void cx18_memcpy_fromio(struct cx18 *cx, void *to, 152void cx18_memcpy_fromio(struct cx18 *cx, void *to,
28 const void __iomem *from, unsigned int len) 153 const void __iomem *from, unsigned int len)
29{ 154{
@@ -127,13 +252,3 @@ void cx18_setup_page(struct cx18 *cx, u32 addr)
127 val = (val & ~0x1f00) | ((addr >> 17) & 0x1f00); 252 val = (val & ~0x1f00) | ((addr >> 17) & 0x1f00);
128 cx18_write_reg(cx, val, 0xD000F8); 253 cx18_write_reg(cx, val, 0xD000F8);
129} 254}
130
131/* Tries to recover from the CX23418 responding improperly on the PCI bus */
132int cx18_pci_try_recover(struct cx18 *cx)
133{
134 u16 status;
135
136 pci_read_config_word(cx->dev, PCI_STATUS, &status);
137 pci_write_config_word(cx->dev, PCI_STATUS, status);
138 return 0;
139}