1. 03 9月, 2011 1 次提交
  2. 28 7月, 2011 3 次提交
  3. 14 7月, 2011 1 次提交
    • D
      [media] dvb_frontend: fix race condition in stopping/starting frontend · 2d196931
      Devin Heitmueller 提交于
      Attached is a patch which addresses a race condition in the DVB core
      related to closing/reopening the DVB frontend device in quick
      succession.  This is the reason that devices such as the HVR-1300,
      HVR-3000, and HVR-4000 have been failing to scan properly under MythTV
      and w_scan.
      
      The gory details of the race are described in the patch.
      
      Devin
      
      There is a race condition exhibited when channel scanners such as w_scan and
      MythTV quickly close and then reopen the frontend device node.
      
      Under normal conditions, the behavior is as follows:
      
      1.  Application closes the device node
      2.  DVB frontend ioctl calls dvb_frontend_release which sets
          fepriv->release_jiffies
      3.  DVB frontend thread *eventually* calls dvb_frontend_is_exiting() which
          compares fepriv->release_jiffies, and shuts down the thread if timeout has
          expired
      4.  Thread goes away
      5.  Application opens frontend device
      6.  DVB frontend ioctl() calls ts_bus_ctrl(1)
      7.  DVB frontend ioctl() creates new frontend thread, which calls
          dvb_frontend_init(), which has demod driver init() routine setup initial
          register state for demod chip.
      8.  Tuning request is issued.
      
      The race occurs when the application in step 5 performs the new open() call
      before the frontend thread is shutdown.  In this case the ts_bus_ctrl() call
      is made, which strobes the RESET pin on the demodulator, but the
      dvb_frontend_init() function never gets called because the frontend thread
      hasn't gone away yet.  As a result, the initial register config for the demod
      is *never* setup, causing subsequent tuning requests to fail.
      
      If there is time between the close and open (enough for the dvb frontend
      thread to be torn down), then in that case the new frontend thread is created
      and thus the dvb_frontend_init() function does get called.
      
      The fix is to set the flag which forces reinitialization if we did in fact
      call ts_bus_ctrl().
      
      This problem has been seen on the HVR-1300, HVR-3000, and HVR-4000, and is
      likely occuring on other designs as well where ts_bus_ctrl() actually strobes
      the reset pin on the demodulator.
      
      Note that this patch should supercede any patches submitted for the
      1300/3000/4000 which remove the code that removes GPIO code in
      cx8802_dvb_advise_acquire(), which have been circulating by users for some
      time now...
      
      Canonical tracking this issue in Launchpad 439163:
      
      Thanks to Jon Sayers from Hauppauge and Florent Audebert from Anevia S.A. for
      providing hardware to test/debug with.
      Signed-off-by: NDevin Heitmueller <dheitmueller@kernellabs.com>
      Cc: Jon Sayers <j.sayers@hauppauge.co.uk>
      Cc: Florent Audebert <florent.audebert@anevia.com>
      Signed-off-by: NMauro Carvalho Chehab <mchehab@redhat.com>
      2d196931
  4. 21 5月, 2011 8 次提交
  5. 20 5月, 2011 1 次提交
  6. 31 3月, 2011 1 次提交
  7. 18 11月, 2010 1 次提交
  8. 21 10月, 2010 1 次提交
  9. 15 10月, 2010 1 次提交
    • A
      llseek: automatically add .llseek fop · 6038f373
      Arnd Bergmann 提交于
      All file_operations should get a .llseek operation so we can make
      nonseekable_open the default for future file operations without a
      .llseek pointer.
      
      The three cases that we can automatically detect are no_llseek, seq_lseek
      and default_llseek. For cases where we can we can automatically prove that
      the file offset is always ignored, we use noop_llseek, which maintains
      the current behavior of not returning an error from a seek.
      
      New drivers should normally not use noop_llseek but instead use no_llseek
      and call nonseekable_open at open time.  Existing drivers can be converted
      to do the same when the maintainer knows for certain that no user code
      relies on calling seek on the device file.
      
      The generated code is often incorrectly indented and right now contains
      comments that clarify for each added line why a specific variant was
      chosen. In the version that gets submitted upstream, the comments will
      be gone and I will manually fix the indentation, because there does not
      seem to be a way to do that using coccinelle.
      
      Some amount of new code is currently sitting in linux-next that should get
      the same modifications, which I will do at the end of the merge window.
      
      Many thanks to Julia Lawall for helping me learn to write a semantic
      patch that does all this.
      
      ===== begin semantic patch =====
      // This adds an llseek= method to all file operations,
      // as a preparation for making no_llseek the default.
      //
      // The rules are
      // - use no_llseek explicitly if we do nonseekable_open
      // - use seq_lseek for sequential files
      // - use default_llseek if we know we access f_pos
      // - use noop_llseek if we know we don't access f_pos,
      //   but we still want to allow users to call lseek
      //
      @ open1 exists @
      identifier nested_open;
      @@
      nested_open(...)
      {
      <+...
      nonseekable_open(...)
      ...+>
      }
      
      @ open exists@
      identifier open_f;
      identifier i, f;
      identifier open1.nested_open;
      @@
      int open_f(struct inode *i, struct file *f)
      {
      <+...
      (
      nonseekable_open(...)
      |
      nested_open(...)
      )
      ...+>
      }
      
      @ read disable optional_qualifier exists @
      identifier read_f;
      identifier f, p, s, off;
      type ssize_t, size_t, loff_t;
      expression E;
      identifier func;
      @@
      ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
      {
      <+...
      (
         *off = E
      |
         *off += E
      |
         func(..., off, ...)
      |
         E = *off
      )
      ...+>
      }
      
      @ read_no_fpos disable optional_qualifier exists @
      identifier read_f;
      identifier f, p, s, off;
      type ssize_t, size_t, loff_t;
      @@
      ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
      {
      ... when != off
      }
      
      @ write @
      identifier write_f;
      identifier f, p, s, off;
      type ssize_t, size_t, loff_t;
      expression E;
      identifier func;
      @@
      ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
      {
      <+...
      (
        *off = E
      |
        *off += E
      |
        func(..., off, ...)
      |
        E = *off
      )
      ...+>
      }
      
      @ write_no_fpos @
      identifier write_f;
      identifier f, p, s, off;
      type ssize_t, size_t, loff_t;
      @@
      ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
      {
      ... when != off
      }
      
      @ fops0 @
      identifier fops;
      @@
      struct file_operations fops = {
       ...
      };
      
      @ has_llseek depends on fops0 @
      identifier fops0.fops;
      identifier llseek_f;
      @@
      struct file_operations fops = {
      ...
       .llseek = llseek_f,
      ...
      };
      
      @ has_read depends on fops0 @
      identifier fops0.fops;
      identifier read_f;
      @@
      struct file_operations fops = {
      ...
       .read = read_f,
      ...
      };
      
      @ has_write depends on fops0 @
      identifier fops0.fops;
      identifier write_f;
      @@
      struct file_operations fops = {
      ...
       .write = write_f,
      ...
      };
      
      @ has_open depends on fops0 @
      identifier fops0.fops;
      identifier open_f;
      @@
      struct file_operations fops = {
      ...
       .open = open_f,
      ...
      };
      
      // use no_llseek if we call nonseekable_open
      ////////////////////////////////////////////
      @ nonseekable1 depends on !has_llseek && has_open @
      identifier fops0.fops;
      identifier nso ~= "nonseekable_open";
      @@
      struct file_operations fops = {
      ...  .open = nso, ...
      +.llseek = no_llseek, /* nonseekable */
      };
      
      @ nonseekable2 depends on !has_llseek @
      identifier fops0.fops;
      identifier open.open_f;
      @@
      struct file_operations fops = {
      ...  .open = open_f, ...
      +.llseek = no_llseek, /* open uses nonseekable */
      };
      
      // use seq_lseek for sequential files
      /////////////////////////////////////
      @ seq depends on !has_llseek @
      identifier fops0.fops;
      identifier sr ~= "seq_read";
      @@
      struct file_operations fops = {
      ...  .read = sr, ...
      +.llseek = seq_lseek, /* we have seq_read */
      };
      
      // use default_llseek if there is a readdir
      ///////////////////////////////////////////
      @ fops1 depends on !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      identifier readdir_e;
      @@
      // any other fop is used that changes pos
      struct file_operations fops = {
      ... .readdir = readdir_e, ...
      +.llseek = default_llseek, /* readdir is present */
      };
      
      // use default_llseek if at least one of read/write touches f_pos
      /////////////////////////////////////////////////////////////////
      @ fops2 depends on !fops1 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      identifier read.read_f;
      @@
      // read fops use offset
      struct file_operations fops = {
      ... .read = read_f, ...
      +.llseek = default_llseek, /* read accesses f_pos */
      };
      
      @ fops3 depends on !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      identifier write.write_f;
      @@
      // write fops use offset
      struct file_operations fops = {
      ... .write = write_f, ...
      +	.llseek = default_llseek, /* write accesses f_pos */
      };
      
      // Use noop_llseek if neither read nor write accesses f_pos
      ///////////////////////////////////////////////////////////
      
      @ fops4 depends on !fops1 && !fops2 && !fops3 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      identifier read_no_fpos.read_f;
      identifier write_no_fpos.write_f;
      @@
      // write fops use offset
      struct file_operations fops = {
      ...
       .write = write_f,
       .read = read_f,
      ...
      +.llseek = noop_llseek, /* read and write both use no f_pos */
      };
      
      @ depends on has_write && !has_read && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      identifier write_no_fpos.write_f;
      @@
      struct file_operations fops = {
      ... .write = write_f, ...
      +.llseek = noop_llseek, /* write uses no f_pos */
      };
      
      @ depends on has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      identifier read_no_fpos.read_f;
      @@
      struct file_operations fops = {
      ... .read = read_f, ...
      +.llseek = noop_llseek, /* read uses no f_pos */
      };
      
      @ depends on !has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      @@
      struct file_operations fops = {
      ...
      +.llseek = noop_llseek, /* no read or write fn */
      };
      ===== End semantic patch =====
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Cc: Julia Lawall <julia@diku.dk>
      Cc: Christoph Hellwig <hch@infradead.org>
      6038f373
  10. 03 8月, 2010 1 次提交
  11. 19 5月, 2010 1 次提交
    • M
      V4L/DVB: fix dvb frontend lockup · e36309f5
      matthieu castet 提交于
      If my dvb device is removed while in use, I got the following oops:
      
      [ 4920.484084] Call Trace:
      [ 4920.484102]  [<c102daad>] ? default_wake_function+0x0/0x8
      [ 4920.484147]  [<f8cb09e1>] ? dvb_unregister_frontend+0x95/0xcc [dvb_core]
      [ 4920.484157]  [<c1044412>] ? autoremove_wake_function+0x0/0x2d
      [ 4920.484168]  [<f8dd1af2>] ? dvb_usb_adapter_frontend_exit+0x12/0x21 [dvb_usb]
      [ 4920.484176]  [<f8dd12f1>] ? dvb_usb_exit+0x26/0x88 [dvb_usb]
      [ 4920.484184]  [<f8dd138d>] ? dvb_usb_device_exit+0x3a/0x4a [dvb_usb]
      [ 4920.484217]  [<f7fe1b08>] ? usb_unbind_interface+0x3f/0xb4 [usbcore]
      [ 4920.484227]  [<c11a4178>] ? __device_release_driver+0x74/0xb7
      [ 4920.484233]  [<c11a4247>] ? device_release_driver+0x15/0x1e
      [ 4920.484243]  [<c11a3a33>] ? bus_remove_device+0x6e/0x87
      [ 4920.484249]  [<c11a26d6>] ? device_del+0xfa/0x152
      [ 4920.484264]  [<f7fdf609>] ? usb_disable_device+0x59/0xb9 [usbcore]
      [ 4920.484279]  [<f7fdb9ee>] ? usb_disconnect+0x70/0xdc [usbcore]
      [ 4920.484294]  [<f7fdc728>] ? hub_thread+0x521/0xe1d [usbcore]
      [ 4920.484301]  [<c1044412>] ? autoremove_wake_function+0x0/0x2d
      [ 4920.484316]  [<f7fdc207>] ? hub_thread+0x0/0xe1d [usbcore]
      [ 4920.484321]  [<c10441e0>] ? kthread+0x61/0x66
      [ 4920.484327]  [<c104417f>] ? kthread+0x0/0x66
      [ 4920.484336]  [<c1003d47>] ? kernel_thread_helper+0x7/0x10
      
      If there are users (for example users == -2) :
       - dvb_unregister_frontend :
       - stop kernel thread with dvb_frontend_stop :
        - fepriv->exit = 1;
        - thread loop catch stop event and break while loop
        - fepriv->thread = NULL; and fepriv->exit = 0;
       - dvb_unregister_frontend wait on "fepriv->dvbdev->wait_queue" that fepriv->dvbdev->users==-1.
      The user finish :
       - dvb_frontend_release - set users to -1
       - don't wait wait_queue because fepriv->exit != 1
      
      => dvb_unregister_frontend never exit the wait queue.
      Signed-off-by: NMatthieu CASTET <castet.matthieu@free.fr>
      Signed-off-by: NMauro Carvalho Chehab <mchehab@redhat.com>
      e36309f5
  12. 17 5月, 2010 1 次提交
  13. 27 2月, 2010 3 次提交
  14. 06 12月, 2009 2 次提交
  15. 02 12月, 2009 1 次提交
  16. 19 9月, 2009 3 次提交
  17. 12 9月, 2009 2 次提交
  18. 17 6月, 2009 2 次提交
    • D
      V4L/DVB (11875): dvb_frontend: fix case where fepriv->exit not reset · a5beb7b3
      Devin Heitmueller 提交于
      The fact that we now explicitly set fepriv->exit = 1 when the thread is
      shutting down exposed an edge case where it was not being reset back to zero
      once the thread went away in some cases.  This resulted in failures in cases
      where the frontend was closed, and then opened O_RDONLY, since in that case
      the thread is not being restarted but it was checking the fepriv->exit flag.
      
      Thanks to Thierry Lelegard, who and encountered and debugged a large portion
      of the issue in the same twelve hours that I did (as well as testing my patch).
      
      Cc: Thierry Lelegard <thierry.lelegard@tv-numeric.com>
      Signed-off-by: NDevin Heitmueller <dheitmueller@kernellabs.com>
      Signed-off-by: NMauro Carvalho Chehab <mchehab@redhat.com>
      a5beb7b3
    • D
      V4L/DVB (11785): dvb_frontend: fix race condition resulting in dropped tuning commands · 57594a58
      Devin Heitmueller 提交于
      A race condition was detected in the case that putting the tuner to sleep takes
      an unusually long period of time, combined with applications that quickly
      close/open the dvb frontend.
      
      The kaffeine channel scanner closes and reopens the dvb frontend between each
      tuning attempt.  If it takes an unusually longer period of time to put the
      tuner to sleep (for example, the Pinnacle 801e takes 660 ms), the dvb_frontend
      thread will still be in a running state (and hence fepriv->thread is still set)
      but the fepriv->exit field will still be zero.  As a result, if a
      dvb_frontend_start() call arrives while the frontend thread is in the process
      of terminating, the call will return 0 without actually starting a new thread.
      This results in the tuning request being dropped.
      
      To address this, mark fepriv->exit as soon as we know the thread is going to
      be terminated, so that dvb_frontend_start() knows to start a new instance.
      
      Problem encountered with Kaffeine 0.8.7 doing ATSC scanning against the
      Pinnacle 801e tuner, in conjunction with new code to power down the xc5000
      when not in use.
      Signed-off-by: NDevin Heitmueller <dheitmueller@kernellabs.com>
      Signed-off-by: NMauro Carvalho Chehab <mchehab@redhat.com>
      57594a58
  19. 30 3月, 2009 1 次提交
  20. 14 3月, 2009 1 次提交
  21. 08 1月, 2009 1 次提交
    • M
      V4L/DVB (10178): dvb_frontend: Fix some sparse warnings due to static symbols · 072ce0c5
      Mauro Carvalho Chehab 提交于
      /home/v4l/master/v4l/dvb_frontend.c:838:19: warning: symbol 'dtv_cmds' was not declared. Should it be static?
      /home/v4l/master/v4l/dvb_frontend.c:1035:6: warning: symbol 'dtv_property_dump' was not declared. Should it be static?
      /home/v4l/master/v4l/dvb_frontend.c:1066:5: warning: symbol 'is_legacy_delivery_system' was not declared. Should it be static?
      /home/v4l/master/v4l/dvb_frontend.c:1080:6: warning: symbol 'dtv_property_cache_sync' was not declared. Should it be static?
      /home/v4l/master/v4l/dvb_frontend.c:1132:6: warning: symbol 'dtv_property_legacy_params_sync' was not declared. Should it be static?
      /home/v4l/master/v4l/dvb_frontend.c:1187:6: warning: symbol 'dtv_property_adv_params_sync' was not declared. Should it be static?
      /home/v4l/master/v4l/dvb_frontend.c:1222:6: warning: symbol 'dtv_property_cache_submit' was not declared. Should it be static?
      /home/v4l/master/v4l/dvb_frontend.c:1253:5: warning: symbol 'dtv_property_process_get' was not declared. Should it be static?
      /home/v4l/master/v4l/dvb_frontend.c:1362:5: warning: symbol 'dtv_property_process_set' was not declared. Should it be static?
      Signed-off-by: NMauro Carvalho Chehab <mchehab@redhat.com>
      072ce0c5
  22. 30 12月, 2008 3 次提交