diff options
author | Steven Toth <stoth@kernellabs.com> | 2010-07-31 15:15:22 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-10-21 05:55:10 -0400 |
commit | 606658292a0f8dc01f3165e741b711572af2d83f (patch) | |
tree | 7fad5e81a8f5fe87db95de7633139af29923044c /drivers/media/video/saa7164 | |
parent | 1107237e4870055147379f297af02341d75ce6f6 (diff) |
[media] saa7164: Monitor the command bus and check for inconsistencies
Signed-off-by: Steven Toth <stoth@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/saa7164')
-rw-r--r-- | drivers/media/video/saa7164/saa7164-bus.c | 153 | ||||
-rw-r--r-- | drivers/media/video/saa7164/saa7164-core.c | 40 | ||||
-rw-r--r-- | drivers/media/video/saa7164/saa7164-types.h | 8 |
3 files changed, 131 insertions, 70 deletions
diff --git a/drivers/media/video/saa7164/saa7164-bus.c b/drivers/media/video/saa7164/saa7164-bus.c index ccc61007f33a..8848687bf9d5 100644 --- a/drivers/media/video/saa7164/saa7164-bus.c +++ b/drivers/media/video/saa7164/saa7164-bus.c | |||
@@ -43,17 +43,11 @@ int saa7164_bus_setup(struct saa7164_dev *dev) | |||
43 | 43 | ||
44 | b->m_dwSizeGetRing = SAA_DEVICE_BUFFERBLOCKSIZE; | 44 | b->m_dwSizeGetRing = SAA_DEVICE_BUFFERBLOCKSIZE; |
45 | 45 | ||
46 | b->m_pdwSetWritePos = (u32 *)((u8 *)(dev->bmmio + | 46 | b->m_dwSetWritePos = ((u32)dev->intfdesc.BARLocation) + (2 * sizeof(u64)); |
47 | ((u32)dev->intfdesc.BARLocation) + (2 * sizeof(u64)))); | 47 | b->m_dwSetReadPos = b->m_dwSetWritePos + (1 * sizeof(u32)); |
48 | 48 | ||
49 | b->m_pdwSetReadPos = (u32 *)((u8 *)b->m_pdwSetWritePos + | 49 | b->m_dwGetWritePos = b->m_dwSetWritePos + (2 * sizeof(u32)); |
50 | 1 * sizeof(u32)); | 50 | b->m_dwGetReadPos = b->m_dwSetWritePos + (3 * sizeof(u32)); |
51 | |||
52 | b->m_pdwGetWritePos = (u32 *)((u8 *)b->m_pdwSetWritePos + | ||
53 | 2 * sizeof(u32)); | ||
54 | |||
55 | b->m_pdwGetReadPos = (u32 *)((u8 *)b->m_pdwSetWritePos + | ||
56 | 3 * sizeof(u32)); | ||
57 | 51 | ||
58 | return 0; | 52 | return 0; |
59 | } | 53 | } |
@@ -71,17 +65,44 @@ void saa7164_bus_dump(struct saa7164_dev *dev) | |||
71 | dprintk(DBGLVL_BUS, " .m_pdwGetRing = 0x%p\n", b->m_pdwGetRing); | 65 | dprintk(DBGLVL_BUS, " .m_pdwGetRing = 0x%p\n", b->m_pdwGetRing); |
72 | dprintk(DBGLVL_BUS, " .m_dwSizeGetRing = 0x%x\n", b->m_dwSizeGetRing); | 66 | dprintk(DBGLVL_BUS, " .m_dwSizeGetRing = 0x%x\n", b->m_dwSizeGetRing); |
73 | 67 | ||
74 | dprintk(DBGLVL_BUS, " .m_pdwSetWritePos = 0x%p (0x%08x)\n", | 68 | dprintk(DBGLVL_BUS, " .m_dwSetReadPos = 0x%x (0x%08x)\n", |
75 | b->m_pdwSetWritePos, *b->m_pdwSetWritePos); | 69 | b->m_dwSetReadPos, saa7164_readl(b->m_dwSetReadPos)); |
70 | |||
71 | dprintk(DBGLVL_BUS, " .m_dwSetWritePos = 0x%x (0x%08x)\n", | ||
72 | b->m_dwSetWritePos, saa7164_readl(b->m_dwSetWritePos)); | ||
76 | 73 | ||
77 | dprintk(DBGLVL_BUS, " .m_pdwSetReadPos = 0x%p (0x%08x)\n", | 74 | dprintk(DBGLVL_BUS, " .m_dwGetReadPos = 0x%x (0x%08x)\n", |
78 | b->m_pdwSetReadPos, *b->m_pdwSetReadPos); | 75 | b->m_dwGetReadPos, saa7164_readl(b->m_dwGetReadPos)); |
79 | 76 | ||
80 | dprintk(DBGLVL_BUS, " .m_pdwGetWritePos = 0x%p (0x%08x)\n", | 77 | dprintk(DBGLVL_BUS, " .m_dwGetWritePos = 0x%x (0x%08x)\n", |
81 | b->m_pdwGetWritePos, *b->m_pdwGetWritePos); | 78 | b->m_dwGetWritePos, saa7164_readl(b->m_dwGetWritePos)); |
82 | 79 | ||
83 | dprintk(DBGLVL_BUS, " .m_pdwGetReadPos = 0x%p (0x%08x)\n", | 80 | } |
84 | b->m_pdwGetReadPos, *b->m_pdwGetReadPos); | 81 | |
82 | /* Intensionally throw a BUG() if the state of the message bus looks corrupt */ | ||
83 | void saa7164_bus_verify(struct saa7164_dev *dev) | ||
84 | { | ||
85 | tmComResBusInfo_t *b = &dev->bus; | ||
86 | int bug = 0, debug; | ||
87 | |||
88 | if (saa7164_readl(b->m_dwSetReadPos) > b->m_dwSizeSetRing) | ||
89 | bug++; | ||
90 | |||
91 | if (saa7164_readl(b->m_dwSetWritePos) > b->m_dwSizeSetRing) | ||
92 | bug++; | ||
93 | |||
94 | if (saa7164_readl(b->m_dwGetReadPos) > b->m_dwSizeGetRing) | ||
95 | bug++; | ||
96 | |||
97 | if (saa7164_readl(b->m_dwGetWritePos) > b->m_dwSizeGetRing) | ||
98 | bug++; | ||
99 | |||
100 | if (bug) { | ||
101 | debug = 0xffff; /* Ensure we get the bus dump */ | ||
102 | saa7164_bus_dump(dev); | ||
103 | debug = 1024; /* Ensure we get the bus dump */ | ||
104 | BUG(); | ||
105 | } | ||
85 | } | 106 | } |
86 | 107 | ||
87 | void saa7164_bus_dumpmsg(struct saa7164_dev *dev, tmComResInfo_t* m, void *buf) | 108 | void saa7164_bus_dumpmsg(struct saa7164_dev *dev, tmComResInfo_t* m, void *buf) |
@@ -111,7 +132,7 @@ void saa7164_bus_dumpmsg(struct saa7164_dev *dev, tmComResInfo_t* m, void *buf) | |||
111 | int saa7164_bus_set(struct saa7164_dev *dev, tmComResInfo_t* msg, void *buf) | 132 | int saa7164_bus_set(struct saa7164_dev *dev, tmComResInfo_t* msg, void *buf) |
112 | { | 133 | { |
113 | tmComResBusInfo_t *bus = &dev->bus; | 134 | tmComResBusInfo_t *bus = &dev->bus; |
114 | u32 bytes_to_write, read_distance, timeout, curr_srp, curr_swp; | 135 | u32 bytes_to_write, free_write_space, timeout, curr_srp, curr_swp; |
115 | u32 new_swp, space_rem; | 136 | u32 new_swp, space_rem; |
116 | int ret = SAA_ERR_BAD_PARAMETER; | 137 | int ret = SAA_ERR_BAD_PARAMETER; |
117 | 138 | ||
@@ -121,6 +142,7 @@ int saa7164_bus_set(struct saa7164_dev *dev, tmComResInfo_t* msg, void *buf) | |||
121 | } | 142 | } |
122 | 143 | ||
123 | dprintk(DBGLVL_BUS, "%s()\n", __func__); | 144 | dprintk(DBGLVL_BUS, "%s()\n", __func__); |
145 | saa7164_bus_verify(dev); | ||
124 | 146 | ||
125 | msg->size = cpu_to_le16(msg->size); | 147 | msg->size = cpu_to_le16(msg->size); |
126 | msg->command = cpu_to_le16(msg->command); | 148 | msg->command = cpu_to_le16(msg->command); |
@@ -141,30 +163,30 @@ int saa7164_bus_set(struct saa7164_dev *dev, tmComResInfo_t* msg, void *buf) | |||
141 | mutex_lock(&bus->lock); | 163 | mutex_lock(&bus->lock); |
142 | 164 | ||
143 | bytes_to_write = sizeof(*msg) + msg->size; | 165 | bytes_to_write = sizeof(*msg) + msg->size; |
144 | read_distance = 0; | 166 | free_write_space = 0; |
145 | timeout = SAA_BUS_TIMEOUT; | 167 | timeout = SAA_BUS_TIMEOUT; |
146 | curr_srp = le32_to_cpu(*bus->m_pdwSetReadPos); | 168 | curr_srp = le32_to_cpu(saa7164_readl(bus->m_dwSetReadPos)); |
147 | curr_swp = le32_to_cpu(*bus->m_pdwSetWritePos); | 169 | curr_swp = le32_to_cpu(saa7164_readl(bus->m_dwSetWritePos)); |
148 | 170 | ||
149 | /* Deal with ring wrapping issues */ | 171 | /* Deal with ring wrapping issues */ |
150 | if (curr_srp > curr_swp) | 172 | if (curr_srp > curr_swp) |
151 | /* The ring has not wrapped yet */ | ||
152 | read_distance = curr_srp - curr_swp; | ||
153 | else | ||
154 | /* Deal with the wrapped ring */ | 173 | /* Deal with the wrapped ring */ |
155 | read_distance = (curr_srp + bus->m_dwSizeSetRing) - curr_swp; | 174 | free_write_space = curr_srp - curr_swp; |
175 | else | ||
176 | /* The ring has not wrapped yet */ | ||
177 | free_write_space = (curr_srp + bus->m_dwSizeSetRing) - curr_swp; | ||
156 | 178 | ||
157 | dprintk(DBGLVL_BUS, "%s() bytes_to_write = %d\n", __func__, | 179 | dprintk(DBGLVL_BUS, "%s() bytes_to_write = %d\n", __func__, |
158 | bytes_to_write); | 180 | bytes_to_write); |
159 | 181 | ||
160 | dprintk(DBGLVL_BUS, "%s() read_distance = %d\n", __func__, | 182 | dprintk(DBGLVL_BUS, "%s() free_write_space = %d\n", __func__, |
161 | read_distance); | 183 | free_write_space); |
162 | 184 | ||
163 | dprintk(DBGLVL_BUS, "%s() curr_srp = %x\n", __func__, curr_srp); | 185 | dprintk(DBGLVL_BUS, "%s() curr_srp = %x\n", __func__, curr_srp); |
164 | dprintk(DBGLVL_BUS, "%s() curr_swp = %x\n", __func__, curr_swp); | 186 | dprintk(DBGLVL_BUS, "%s() curr_swp = %x\n", __func__, curr_swp); |
165 | 187 | ||
166 | /* Process the msg and write the content onto the bus */ | 188 | /* Process the msg and write the content onto the bus */ |
167 | while (bytes_to_write >= read_distance) { | 189 | while (bytes_to_write >= free_write_space) { |
168 | 190 | ||
169 | if (timeout-- == 0) { | 191 | if (timeout-- == 0) { |
170 | printk(KERN_ERR "%s() bus timeout\n", __func__); | 192 | printk(KERN_ERR "%s() bus timeout\n", __func__); |
@@ -177,15 +199,15 @@ int saa7164_bus_set(struct saa7164_dev *dev, tmComResInfo_t* msg, void *buf) | |||
177 | mdelay(1); | 199 | mdelay(1); |
178 | 200 | ||
179 | /* Check the space usage again */ | 201 | /* Check the space usage again */ |
180 | curr_srp = le32_to_cpu(*bus->m_pdwSetReadPos); | 202 | curr_srp = le32_to_cpu(saa7164_readl(bus->m_dwSetReadPos)); |
181 | 203 | ||
182 | /* Deal with ring wrapping issues */ | 204 | /* Deal with ring wrapping issues */ |
183 | if (curr_srp > curr_swp) | 205 | if (curr_srp > curr_swp) |
184 | /* Read didn't wrap around the buffer */ | ||
185 | read_distance = curr_srp - curr_swp; | ||
186 | else | ||
187 | /* Deal with the wrapped ring */ | 206 | /* Deal with the wrapped ring */ |
188 | read_distance = (curr_srp + bus->m_dwSizeSetRing) - | 207 | free_write_space = curr_srp - curr_swp; |
208 | else | ||
209 | /* Read didn't wrap around the buffer */ | ||
210 | free_write_space = (curr_srp + bus->m_dwSizeSetRing) - | ||
189 | curr_swp; | 211 | curr_swp; |
190 | 212 | ||
191 | } | 213 | } |
@@ -217,28 +239,28 @@ int saa7164_bus_set(struct saa7164_dev *dev, tmComResInfo_t* msg, void *buf) | |||
217 | dprintk(DBGLVL_BUS, "%s() tr4\n", __func__); | 239 | dprintk(DBGLVL_BUS, "%s() tr4\n", __func__); |
218 | 240 | ||
219 | /* Split the msg into pieces as the ring wraps */ | 241 | /* Split the msg into pieces as the ring wraps */ |
220 | memcpy_toio(bus->m_pdwSetRing + curr_swp, msg, space_rem); | 242 | memcpy(bus->m_pdwSetRing + curr_swp, msg, space_rem); |
221 | memcpy_toio(bus->m_pdwSetRing, (u8 *)msg + space_rem, | 243 | memcpy(bus->m_pdwSetRing, (u8 *)msg + space_rem, |
222 | sizeof(*msg) - space_rem); | 244 | sizeof(*msg) - space_rem); |
223 | 245 | ||
224 | memcpy_toio(bus->m_pdwSetRing + sizeof(*msg) - space_rem, | 246 | memcpy(bus->m_pdwSetRing + sizeof(*msg) - space_rem, |
225 | buf, msg->size); | 247 | buf, msg->size); |
226 | 248 | ||
227 | } else if (space_rem == sizeof(*msg)) { | 249 | } else if (space_rem == sizeof(*msg)) { |
228 | dprintk(DBGLVL_BUS, "%s() tr5\n", __func__); | 250 | dprintk(DBGLVL_BUS, "%s() tr5\n", __func__); |
229 | 251 | ||
230 | /* Additional data at the beginning of the ring */ | 252 | /* Additional data at the beginning of the ring */ |
231 | memcpy_toio(bus->m_pdwSetRing + curr_swp, msg, sizeof(*msg)); | 253 | memcpy(bus->m_pdwSetRing + curr_swp, msg, sizeof(*msg)); |
232 | memcpy_toio(bus->m_pdwSetRing, buf, msg->size); | 254 | memcpy(bus->m_pdwSetRing, buf, msg->size); |
233 | 255 | ||
234 | } else { | 256 | } else { |
235 | /* Additional data wraps around the ring */ | 257 | /* Additional data wraps around the ring */ |
236 | memcpy_toio(bus->m_pdwSetRing + curr_swp, msg, sizeof(*msg)); | 258 | memcpy(bus->m_pdwSetRing + curr_swp, msg, sizeof(*msg)); |
237 | if (msg->size > 0) { | 259 | if (msg->size > 0) { |
238 | memcpy_toio(bus->m_pdwSetRing + curr_swp + | 260 | memcpy(bus->m_pdwSetRing + curr_swp + |
239 | sizeof(*msg), buf, space_rem - | 261 | sizeof(*msg), buf, space_rem - |
240 | sizeof(*msg)); | 262 | sizeof(*msg)); |
241 | memcpy_toio(bus->m_pdwSetRing, (u8 *)buf + | 263 | memcpy(bus->m_pdwSetRing, (u8 *)buf + |
242 | space_rem - sizeof(*msg), | 264 | space_rem - sizeof(*msg), |
243 | bytes_to_write - space_rem); | 265 | bytes_to_write - space_rem); |
244 | } | 266 | } |
@@ -250,23 +272,21 @@ int saa7164_bus_set(struct saa7164_dev *dev, tmComResInfo_t* msg, void *buf) | |||
250 | dprintk(DBGLVL_BUS, "%s() tr6\n", __func__); | 272 | dprintk(DBGLVL_BUS, "%s() tr6\n", __func__); |
251 | 273 | ||
252 | /* The ring buffer doesn't wrap, two simple copies */ | 274 | /* The ring buffer doesn't wrap, two simple copies */ |
253 | memcpy_toio(bus->m_pdwSetRing + curr_swp, msg, sizeof(*msg)); | 275 | memcpy(bus->m_pdwSetRing + curr_swp, msg, sizeof(*msg)); |
254 | memcpy_toio(bus->m_pdwSetRing + curr_swp + sizeof(*msg), buf, | 276 | memcpy(bus->m_pdwSetRing + curr_swp + sizeof(*msg), buf, |
255 | msg->size); | 277 | msg->size); |
256 | } | 278 | } |
257 | 279 | ||
258 | dprintk(DBGLVL_BUS, "%s() new_swp = %x\n", __func__, new_swp); | 280 | dprintk(DBGLVL_BUS, "%s() new_swp = %x\n", __func__, new_swp); |
259 | 281 | ||
260 | /* TODO: Convert all of the direct PCI writes into | ||
261 | * saa7164_writel/b calls for consistency. | ||
262 | */ | ||
263 | |||
264 | /* Update the bus write position */ | 282 | /* Update the bus write position */ |
265 | *bus->m_pdwSetWritePos = cpu_to_le32(new_swp); | 283 | saa7164_writel(bus->m_dwSetWritePos, cpu_to_le32(new_swp)); |
266 | ret = SAA_OK; | 284 | ret = SAA_OK; |
267 | 285 | ||
268 | out: | 286 | out: |
287 | saa7164_bus_dump(dev); | ||
269 | mutex_unlock(&bus->lock); | 288 | mutex_unlock(&bus->lock); |
289 | saa7164_bus_verify(dev); | ||
270 | return ret; | 290 | return ret; |
271 | } | 291 | } |
272 | 292 | ||
@@ -288,6 +308,7 @@ int saa7164_bus_get(struct saa7164_dev *dev, tmComResInfo_t* msg, void *buf, | |||
288 | tmComResInfo_t msg_tmp; | 308 | tmComResInfo_t msg_tmp; |
289 | int ret = SAA_ERR_BAD_PARAMETER; | 309 | int ret = SAA_ERR_BAD_PARAMETER; |
290 | 310 | ||
311 | saa7164_bus_verify(dev); | ||
291 | if (msg == 0) | 312 | if (msg == 0) |
292 | return ret; | 313 | return ret; |
293 | 314 | ||
@@ -309,11 +330,10 @@ int saa7164_bus_get(struct saa7164_dev *dev, tmComResInfo_t* msg, void *buf, | |||
309 | /* Peek the bus to see if a msg exists, if it's not what we're expecting | 330 | /* Peek the bus to see if a msg exists, if it's not what we're expecting |
310 | * then return cleanly else read the message from the bus. | 331 | * then return cleanly else read the message from the bus. |
311 | */ | 332 | */ |
312 | curr_gwp = le32_to_cpu(*bus->m_pdwGetWritePos); | 333 | curr_gwp = le32_to_cpu(saa7164_readl(bus->m_dwGetWritePos)); |
313 | curr_grp = le32_to_cpu(*bus->m_pdwGetReadPos); | 334 | curr_grp = le32_to_cpu(saa7164_readl(bus->m_dwGetReadPos)); |
314 | 335 | ||
315 | if (curr_gwp == curr_grp) { | 336 | if (curr_gwp == curr_grp) { |
316 | dprintk(DBGLVL_BUS, "%s() No message on the bus\n", __func__); | ||
317 | ret = SAA_ERR_EMPTY; | 337 | ret = SAA_ERR_EMPTY; |
318 | goto out; | 338 | goto out; |
319 | } | 339 | } |
@@ -343,19 +363,19 @@ int saa7164_bus_get(struct saa7164_dev *dev, tmComResInfo_t* msg, void *buf, | |||
343 | new_grp -= bus->m_dwSizeGetRing; | 363 | new_grp -= bus->m_dwSizeGetRing; |
344 | space_rem = bus->m_dwSizeGetRing - curr_grp; | 364 | space_rem = bus->m_dwSizeGetRing - curr_grp; |
345 | 365 | ||
346 | memcpy_fromio(&msg_tmp, bus->m_pdwGetRing + curr_grp, space_rem); | 366 | memcpy(&msg_tmp, bus->m_pdwGetRing + curr_grp, space_rem); |
347 | memcpy_fromio((u8 *)&msg_tmp + space_rem, bus->m_pdwGetRing, | 367 | memcpy((u8 *)&msg_tmp + space_rem, bus->m_pdwGetRing, |
348 | bytes_to_read - space_rem); | 368 | bytes_to_read - space_rem); |
349 | 369 | ||
350 | } else { | 370 | } else { |
351 | /* No wrapping */ | 371 | /* No wrapping */ |
352 | memcpy_fromio(&msg_tmp, bus->m_pdwGetRing + curr_grp, bytes_to_read); | 372 | memcpy(&msg_tmp, bus->m_pdwGetRing + curr_grp, bytes_to_read); |
353 | } | 373 | } |
354 | 374 | ||
355 | /* No need to update the read positions, because this was a peek */ | 375 | /* No need to update the read positions, because this was a peek */ |
356 | /* If the caller specifically want to peek, return */ | 376 | /* If the caller specifically want to peek, return */ |
357 | if (peekonly) { | 377 | if (peekonly) { |
358 | memcpy_fromio(msg, &msg_tmp, sizeof(*msg)); | 378 | memcpy(msg, &msg_tmp, sizeof(*msg)); |
359 | goto peekout; | 379 | goto peekout; |
360 | } | 380 | } |
361 | 381 | ||
@@ -401,24 +421,24 @@ int saa7164_bus_get(struct saa7164_dev *dev, tmComResInfo_t* msg, void *buf, | |||
401 | 421 | ||
402 | if (space_rem < sizeof(*msg)) { | 422 | if (space_rem < sizeof(*msg)) { |
403 | /* msg wraps around the ring */ | 423 | /* msg wraps around the ring */ |
404 | memcpy_fromio(msg, bus->m_pdwGetRing + curr_grp, space_rem); | 424 | memcpy(msg, bus->m_pdwGetRing + curr_grp, space_rem); |
405 | memcpy_fromio((u8 *)msg + space_rem, bus->m_pdwGetRing, | 425 | memcpy((u8 *)msg + space_rem, bus->m_pdwGetRing, |
406 | sizeof(*msg) - space_rem); | 426 | sizeof(*msg) - space_rem); |
407 | if (buf) | 427 | if (buf) |
408 | memcpy_fromio(buf, bus->m_pdwGetRing + sizeof(*msg) - | 428 | memcpy(buf, bus->m_pdwGetRing + sizeof(*msg) - |
409 | space_rem, buf_size); | 429 | space_rem, buf_size); |
410 | 430 | ||
411 | } else if (space_rem == sizeof(*msg)) { | 431 | } else if (space_rem == sizeof(*msg)) { |
412 | memcpy_fromio(msg, bus->m_pdwGetRing + curr_grp, sizeof(*msg)); | 432 | memcpy(msg, bus->m_pdwGetRing + curr_grp, sizeof(*msg)); |
413 | if (buf) | 433 | if (buf) |
414 | memcpy(buf, bus->m_pdwGetRing, buf_size); | 434 | memcpy(buf, bus->m_pdwGetRing, buf_size); |
415 | } else { | 435 | } else { |
416 | /* Additional data wraps around the ring */ | 436 | /* Additional data wraps around the ring */ |
417 | memcpy_fromio(msg, bus->m_pdwGetRing + curr_grp, sizeof(*msg)); | 437 | memcpy(msg, bus->m_pdwGetRing + curr_grp, sizeof(*msg)); |
418 | if (buf) { | 438 | if (buf) { |
419 | memcpy_fromio(buf, bus->m_pdwGetRing + curr_grp + | 439 | memcpy(buf, bus->m_pdwGetRing + curr_grp + |
420 | sizeof(*msg), space_rem - sizeof(*msg)); | 440 | sizeof(*msg), space_rem - sizeof(*msg)); |
421 | memcpy_fromio(buf + space_rem - sizeof(*msg), | 441 | memcpy(buf + space_rem - sizeof(*msg), |
422 | bus->m_pdwGetRing, bytes_to_read - | 442 | bus->m_pdwGetRing, bytes_to_read - |
423 | space_rem); | 443 | space_rem); |
424 | } | 444 | } |
@@ -427,14 +447,14 @@ int saa7164_bus_get(struct saa7164_dev *dev, tmComResInfo_t* msg, void *buf, | |||
427 | 447 | ||
428 | } else { | 448 | } else { |
429 | /* No wrapping */ | 449 | /* No wrapping */ |
430 | memcpy_fromio(msg, bus->m_pdwGetRing + curr_grp, sizeof(*msg)); | 450 | memcpy(msg, bus->m_pdwGetRing + curr_grp, sizeof(*msg)); |
431 | if (buf) | 451 | if (buf) |
432 | memcpy_fromio(buf, bus->m_pdwGetRing + curr_grp + sizeof(*msg), | 452 | memcpy(buf, bus->m_pdwGetRing + curr_grp + sizeof(*msg), |
433 | buf_size); | 453 | buf_size); |
434 | } | 454 | } |
435 | 455 | ||
436 | /* Update the read positions, adjusting the ring */ | 456 | /* Update the read positions, adjusting the ring */ |
437 | *bus->m_pdwGetReadPos = cpu_to_le32(new_grp); | 457 | saa7164_writel(bus->m_dwGetReadPos, cpu_to_le32(new_grp)); |
438 | 458 | ||
439 | peekout: | 459 | peekout: |
440 | msg->size = le16_to_cpu(msg->size); | 460 | msg->size = le16_to_cpu(msg->size); |
@@ -443,6 +463,7 @@ peekout: | |||
443 | ret = SAA_OK; | 463 | ret = SAA_OK; |
444 | out: | 464 | out: |
445 | mutex_unlock(&bus->lock); | 465 | mutex_unlock(&bus->lock); |
466 | saa7164_bus_verify(dev); | ||
446 | return ret; | 467 | return ret; |
447 | } | 468 | } |
448 | 469 | ||
diff --git a/drivers/media/video/saa7164/saa7164-core.c b/drivers/media/video/saa7164/saa7164-core.c index 545eeffa5010..fcbb9d5958df 100644 --- a/drivers/media/video/saa7164/saa7164-core.c +++ b/drivers/media/video/saa7164/saa7164-core.c | |||
@@ -1122,6 +1122,46 @@ static int saa7164_proc_show(struct seq_file *m, void *v) | |||
1122 | b = &dev->bus; | 1122 | b = &dev->bus; |
1123 | mutex_lock(&b->lock); | 1123 | mutex_lock(&b->lock); |
1124 | 1124 | ||
1125 | seq_printf(m, " .m_pdwSetWritePos = 0x%x (0x%08x)\n", | ||
1126 | b->m_dwSetReadPos, saa7164_readl(b->m_dwSetReadPos)); | ||
1127 | |||
1128 | seq_printf(m, " .m_pdwSetReadPos = 0x%x (0x%08x)\n", | ||
1129 | b->m_dwSetWritePos, saa7164_readl(b->m_dwSetWritePos)); | ||
1130 | |||
1131 | seq_printf(m, " .m_pdwGetWritePos = 0x%x (0x%08x)\n", | ||
1132 | b->m_dwGetReadPos, saa7164_readl(b->m_dwGetReadPos)); | ||
1133 | |||
1134 | seq_printf(m, " .m_pdwGetReadPos = 0x%x (0x%08x)\n", | ||
1135 | b->m_dwGetWritePos, saa7164_readl(b->m_dwGetWritePos)); | ||
1136 | c = 0; | ||
1137 | seq_printf(m, "\n Set Ring:\n"); | ||
1138 | seq_printf(m, "\n addr 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f\n"); | ||
1139 | for (i = 0; i < b->m_dwSizeSetRing; i++) { | ||
1140 | if (c == 0) | ||
1141 | seq_printf(m, " %04x:", i); | ||
1142 | |||
1143 | seq_printf(m, " %02x", *(b->m_pdwSetRing + i)); | ||
1144 | |||
1145 | if (++c == 16) { | ||
1146 | seq_printf(m, "\n"); | ||
1147 | c = 0; | ||
1148 | } | ||
1149 | } | ||
1150 | |||
1151 | c = 0; | ||
1152 | seq_printf(m, "\n Get Ring:\n"); | ||
1153 | seq_printf(m, "\n addr 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f\n"); | ||
1154 | for (i = 0; i < b->m_dwSizeGetRing; i++) { | ||
1155 | if (c == 0) | ||
1156 | seq_printf(m, " %04x:", i); | ||
1157 | |||
1158 | seq_printf(m, " %02x", *(b->m_pdwGetRing + i)); | ||
1159 | |||
1160 | if (++c == 16) { | ||
1161 | seq_printf(m, "\n"); | ||
1162 | c = 0; | ||
1163 | } | ||
1164 | } | ||
1125 | 1165 | ||
1126 | mutex_unlock(&b->lock); | 1166 | mutex_unlock(&b->lock); |
1127 | 1167 | ||
diff --git a/drivers/media/video/saa7164/saa7164-types.h b/drivers/media/video/saa7164/saa7164-types.h index 3406a95d8fe9..ea245ba563b7 100644 --- a/drivers/media/video/saa7164/saa7164-types.h +++ b/drivers/media/video/saa7164/saa7164-types.h | |||
@@ -82,10 +82,10 @@ typedef struct { | |||
82 | u32 m_dwSizeSetRing; | 82 | u32 m_dwSizeSetRing; |
83 | u8 *m_pdwGetRing; | 83 | u8 *m_pdwGetRing; |
84 | u32 m_dwSizeGetRing; | 84 | u32 m_dwSizeGetRing; |
85 | u32 *m_pdwSetWritePos; | 85 | u32 m_dwSetWritePos; |
86 | u32 *m_pdwSetReadPos; | 86 | u32 m_dwSetReadPos; |
87 | u32 *m_pdwGetWritePos; | 87 | u32 m_dwGetWritePos; |
88 | u32 *m_pdwGetReadPos; | 88 | u32 m_dwGetReadPos; |
89 | 89 | ||
90 | /* All access is protected */ | 90 | /* All access is protected */ |
91 | struct mutex lock; | 91 | struct mutex lock; |