TBS5281 suspend support in Libreelec 8.0

  • I'm using the TBS-5281 dvb-c USB module with Tvheadend 4.2 in Libreelec 8.0.0 environment. This Libreelec version uses the Linux 4.9.8 version.

    I would like to sleep the system is used by Kodi Krypton suspend power-off option, but the system is freezed. If I have disconnected the USB module from system the suspend process has worked correctly.
    In next step I have rebooted and reconnected the USB hardware to Libreelec and I have tested the cx231xx module dependency tree by lsmod command:


    Before I removed from memory the dvb driver module I have stopped the tvheadend by using the following commands:

    Code
    systemctl stop service.tvheadend42
    
    
    systemctl is-active service.tvheadend42
    inactive


    After this randomly sometimes rmmod cx231xx_dvb_ci command answers:
    rmmod: ERROR: Module cx231xx_dvb_ci is in use
    or
    Killed

    I think it doesn't normal message, may be it is a Linux kernel module problem.

    BTW I will use the `89-tvheadend.power` script file in /storage/.config.sleep.d for stopping and restarting the dvb modules, but until doesn't solve above problem I couldn't use it. The `REMOVE_MODULE` variable can be set in Tvheadend42 addon configuration panel which will be included the removing module name sequence.

    Can somebody help me?

    PS: I'm sending some additional information:

    Code
    modinfo cx231xx_dvb_ci
    filename:       /lib/modules/4.9.8/updates/cx231xx-dvb-ci.ko
    license:        GPL
    author:         Srinivasa Deevi <[email protected]>
    description:    driver for cx231xx based DVB cards
    depends:        cx231xx,dvb-core,tas2101
    vermagic:       4.9.8 SMP mod_unload
    parm:           debug:enable debug messages [dvb] (int)
    parm:           adapter_nr:DVB adapter numbers (array of short)


    Edited once, last by schneci (March 27, 2017 at 6:24 PM).

  • the easiest way to test it

    boot to normal LE
    systemctl stop service.tvheadend42
    rmmod cx231xx_dvb_ci cx231xx cx2341x

    the rmmod ... has to work without an error - if you have an error you have to adjust the chain (you can't unload something that is used from another module), if you have a working unload chain you can also input it into the addon settings, then you won't need to do some script :)


  • the easiest way to test it

    boot to normal LE
    systemctl stop service.tvheadend42
    rmmod cx231xx_dvb_ci cx231xx cx2341x

    the rmmod ... has to work without an error - if you have an error you have to adjust the chain (you can't unload something that is used from another module), if you have a working unload chain you can also input it into the addon settings, then you won't need to do some script :)

    I have test above mode but the result is not too promising:

    Code
    ~ # rmmod cx231xx_dvb_ci cx231xx cx2341x
    Segmentation fault
    ~ # rmmod cx231xx_dvb_ci cx231xx cx2341x
    rmmod: ERROR: Module cx231xx_dvb_ci is in use
    rmmod: ERROR: Module cx231xx is in use by: cx231xx_dvb_ci
    rmmod: ERROR: Module cx2341x is in use by: cx231xx

    I think segfault message is a dvb driver code problem or other mistake.

    Edited once, last by schneci (March 27, 2017 at 7:15 PM).


  • could you test if rmmod cx231xx_dvb_ci works ?

    Firstofall I stopped the tvheadend and after this issued the rmmod cx231xx_dvb_ci

    ~ # systemctl stop service.tvheadend42~ # systemctl is-active service.tvheadend42inactive~ #~ # rmmod cx231xx_dvb_ciKilled

    I think the Killed answer is not normal message. Probably the dvb driver is crashed.

  • yes this shouldn't be the correct response :/
    I guess you have Generic LE8.
    Here LibreELEC-Generic.x86_64-8.0.1-cc-2017-22-03.img.gz is a version with the latest TBS drivers, maybe it is fixed.

    I have installed above image without tvheadend plugin install, but unfortunately the same situation:

    • rmmod try stops the cx231xx_dvb_ci module with Segfault or Killed message
    • kodi suspend freezes
    • kodi suspend works unplugged dvb usb hardware


    lsmod output is before rmmod cx231xx_dvb_ci: GQSZ
    and after rmmod: NLHT

    The different is:
    Module Size Used bysi2157 5741 2si2168 8881 2cx231xx_dvb_ci 15513 0

    ...

    Module Size Used bysi2157 5741 1si2168 8881 1cx231xx_dvb_ci 15513 -1

    Edited once, last by schneci (March 28, 2017 at 9:52 AM).


  • so lets guess cx231xx_dvb_ci is kind of broken, do you need the CI ?
    If not you could blacklisting the module and maybe then the other stuff works.echo "blacklist cx231xx_dvb_ci" >> /storage/.config/modprobe.d/blacklist.conf
    then try rmmod without the ci module

    Unfortunately it did not help, because the cx231xx_dvb_ci module is loaded and rmmod worked the same mistake as before. I don't know what is the reason of the blacklist didn't disable the loading of cx231xx_dvb_ci module.

    You can see in end of dmesg what happened after rmmod cx231xx_dvb_ci:
    FNJj

    I think the following messages in dmesg are caused the rmmod Killed or Segfault output:

    [ 50.184375] BUG: unable to handle kernel NULL pointer dereference at 0000000000000010[ 50.184546] IP: [<ffffffffa09f7306>] dvb_fini+0xf6/0x150 [cx231xx_dvb_ci]

    I use OSCAM system for encrypted channels receiving with PCSCD conax card reader driver. I don't know that ci-api should be for encoding operation. I think tvheadend uses CCAM interface protocol with OSCAM

    Edited once, last by schneci (March 29, 2017 at 9:39 AM).

  • I think I have found the main problem. The TBS 5281 usb card includes dual adapter. The TBS proprietary driver use the adap_cnt counter variable:

    The kernel BUG message in dmesg shows the problem is caused by dvb_fini process with kernel NULL point exception during rmmod. I have seen the TBS proprietary driver source and this calculates the adapter number in adapter release and unregister calling, but the opensource cx231xx driver not:

    What is your opinion? Can anybody help to solve this problem?

    Edited once, last by schneci (March 30, 2017 at 11:10 AM).

  • Hi Cvh,

    Thank you your advice, I have earlier put this issue on that Github site.

    The dvd-drivers branch of GitHub - CvH/LibreELEC.tv: 'Just enough OS' for Kodi site is working by TBS528 and I correctly use rmmod of cx231xx driver and I can use Librelec 7 (kodi 16.1) suspend power-off option. On this site I found the LE8-dvb-drivers branch but I couldn't use it because the dvb-drivers.txt file is handled inaccurate:

    LibreELEC.tv/init at LE8-dvb-drivers · CvH/LibreELEC.tv · GitHub



    Above code doesn't read dvb-drivers.txt.

    What was your goal of this branch? Has anybody used this version? I would like using the "tbsc" driver option for TBS-5281 adapter.

    Edited once, last by schneci (March 31, 2017 at 8:50 AM).

  • Thank you the new image.

    I have tested it and now is working the rmmod of cx231xx_dvb_ci module and properly go to suspend the kodi.

    When this repaired version wil be appeared on github? What is the schedule the libreelec8.0 release?

    Thank you again for your effort solving of this problem!