CAM tried to send a buffer larger than the ecount size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On this week I bought a KNC1 clone card with CI to watch cable TV on
my desktop with Kaffeine and the cable provider supplied a Conax
TechniCrypt CX CAM with the subscriber card. I built Kaffeine with
xine-lib-1.2 with VDPAU support so I can watch HD with really low CPU
usage, woah! ;)

For a time everything was fine until I noticed the CAM sometimes
"freezes" on channel switching with the following kernel message:
 dvb_ca adapter 0: CAM tried to send a buffer larger than the ecount size
 dvb_ca adapter 0: DVB CAM link initialisation failed :(


I did some debugging with systemtap and found 2 problems:
1. dvb_ca_en50221_write_data sometimes got a STATUSREG_WE status after
the writeout
2. recovery from slot_state:DVB_CA_SLOTSTATE_LINKINIT doesn't work
because dvb_ca_en50221_link_init expects CAM buffer size in 2 bytes
but got 6

On channel switching, there's 2 "big" writes in a bunch. In every
examined case only the second failed and doesn't depend on the size of
bytes_write. dvb_ca_en50221_io_write called from the context of
Kaffeine with valid data, I didn't found race condition, tried to play
with timing in ciintf_write_cam_control@xxxxxxxxxxx but no success, so
I find workaround:

I found if I replay the write, the next try will successed after
!(status & (STATUSREG_DA | STATUSREG_RE') becomes true again.

A typical error (logged by systemtap) is:
[channel switching]
1. dvb_ca_en50221_write_data bytes_write:0x54 by kaffeine returns OK
2. 2nd dvb_ca_en50221_write_data 0x54 by kaffeine returns -EAGAIN
3. 3rd dvb_ca_en50221_write_data 0x54 by kaffeine
 ciintf_read_cam_control returns 0x82 (STATUSREG_DA | STATUSREG_WE)
 so dvb_ca_en50221_write_data returns -EIO and the LINKINIT fails

My first workaround is return -EAGAIN instead of -EIO in
dvb_ca_en50221_write_data:
[channel switching]
1. dvb_ca_en50221_write_data bytes_write:0x54 by kaffeine returns OK
2. 2nd dvb_ca_en50221_write_data 0x54 by kaffeine returns -EAGAIN
3. 3rd dvb_ca_en50221_write_data 0x54 by kaffeine
  ciintf_read_cam_control returns 0x82
  dvb_ca_en50221_write_data returns -EAGAIN
    thread wakeup, ciintf_read_cam_control called from the thread returns 0x82
    dvb_ca_en50221_io_write calls dvb_ca_en50221_write_data for 10-20
times in a loop cause CTRLIF_STATUS:0x02
    CTRLIF_STATUS becomes 0x80, the thread wakes up and do a read again
    dvb_ca_en50221_write_data got CTRLIF_STATUS:0x40 and the replayed write OK

So the workaround perfect but the root cause is unknown for me. I'm
ready to do more debugging, but I have no idea what should I try next.
Can you help?

(I've no CI/CAM experience and don't have too much time for heavy
interface documentations.)


Related reports:
http://linuxtv.org/pipermail/linux-dvb/2008-August/027764.html
http://www.spinics.net/lists/linux-media/msg19295.html

System info:
Athlon 4850e CPU
Fedora 14, kernel 2.6.35.12-90.fc14.x86_64

DVB card info:
Mystique CaBiX-C2 + Mystique View CI

CAM info (gnutv -cammenu):
1/
CAM Application type: 01
CAM Application manufacturer: cafe
CAM Manufacturer code: babe
CAM Menu string: Conax Conditional Access
7/
1. Software version: CNX-ORDGRC-2.5.10m2
2. Hardware version: 2.2.1
4. Interface version: 0x40
6. Number of sessions: 5
8. CA_SYS_ID: 0x0b00
9. CIM Build Date : Aug  6 2010


--
 Roland Pallai

Attachment: budget-av.stap
Description: Binary data


[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux