1. 03 9月, 2011 1 次提交
  2. 28 7月, 2011 5 次提交
  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 2 次提交
  6. 31 3月, 2011 1 次提交
  7. 22 3月, 2011 1 次提交
  8. 29 12月, 2010 1 次提交
  9. 24 12月, 2010 1 次提交
    • T
      dvb: don't use flush_scheduled_work() · 0d9c76ae
      Tejun Heo 提交于
      flush_scheduled_work() is deprecated and scheduled to be removed.
      
      * Flush the used works directly.
      
      * Replace the deprecated cancel_rearming_delayed_work() +
        flush_scheduled_work() -> cancel_delayed_work_sync().
      
      * Make sure mantis->uart_work isn't running on exit.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
      Cc: linux-media@vger.kernel.org
      0d9c76ae
  10. 18 11月, 2010 1 次提交
  11. 21 10月, 2010 3 次提交
  12. 19 10月, 2010 1 次提交
    • A
      dvb-core: kill the big kernel lock · 72024f1e
      Arnd Bergmann 提交于
      The dvb core only uses the big kernel lock in the open
      and ioctl functions, which means it can be replaced with
      a dvb specific mutex. Fortunately, all the ioctl functions
      go through dvb_usercopy, so we can move the serialization
      in there.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
      Cc: linux-media@vger.kernel.org
      72024f1e
  13. 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
  14. 03 8月, 2010 4 次提交
  15. 01 6月, 2010 1 次提交
  16. 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
  17. 18 5月, 2010 1 次提交
  18. 17 5月, 2010 1 次提交
  19. 04 4月, 2010 1 次提交
    • J
      net: convert multicast list to list_head · 22bedad3
      Jiri Pirko 提交于
      Converts the list and the core manipulating with it to be the same as uc_list.
      
      +uses two functions for adding/removing mc address (normal and "global"
       variant) instead of a function parameter.
      +removes dev_mcast.c completely.
      +exposes netdev_hw_addr_list_* macros along with __hw_addr_* functions for
       manipulation with lists on a sandbox (used in bonding and 80211 drivers)
      Signed-off-by: NJiri Pirko <jpirko@redhat.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      22bedad3
  20. 30 3月, 2010 1 次提交
    • T
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking... · 5a0e3ad6
      Tejun Heo 提交于
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
      
      percpu.h is included by sched.h and module.h and thus ends up being
      included when building most .c files.  percpu.h includes slab.h which
      in turn includes gfp.h making everything defined by the two files
      universally available and complicating inclusion dependencies.
      
      percpu.h -> slab.h dependency is about to be removed.  Prepare for
      this change by updating users of gfp and slab facilities include those
      headers directly instead of assuming availability.  As this conversion
      needs to touch large number of source files, the following script is
      used as the basis of conversion.
      
        http://userweb.kernel.org/~tj/misc/slabh-sweep.py
      
      The script does the followings.
      
      * Scan files for gfp and slab usages and update includes such that
        only the necessary includes are there.  ie. if only gfp is used,
        gfp.h, if slab is used, slab.h.
      
      * When the script inserts a new include, it looks at the include
        blocks and try to put the new include such that its order conforms
        to its surrounding.  It's put in the include block which contains
        core kernel includes, in the same order that the rest are ordered -
        alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
        doesn't seem to be any matching order.
      
      * If the script can't find a place to put a new include (mostly
        because the file doesn't have fitting include block), it prints out
        an error message indicating which .h file needs to be added to the
        file.
      
      The conversion was done in the following steps.
      
      1. The initial automatic conversion of all .c files updated slightly
         over 4000 files, deleting around 700 includes and adding ~480 gfp.h
         and ~3000 slab.h inclusions.  The script emitted errors for ~400
         files.
      
      2. Each error was manually checked.  Some didn't need the inclusion,
         some needed manual addition while adding it to implementation .h or
         embedding .c file was more appropriate for others.  This step added
         inclusions to around 150 files.
      
      3. The script was run again and the output was compared to the edits
         from #2 to make sure no file was left behind.
      
      4. Several build tests were done and a couple of problems were fixed.
         e.g. lib/decompress_*.c used malloc/free() wrappers around slab
         APIs requiring slab.h to be added manually.
      
      5. The script was run on all .h files but without automatically
         editing them as sprinkling gfp.h and slab.h inclusions around .h
         files could easily lead to inclusion dependency hell.  Most gfp.h
         inclusion directives were ignored as stuff from gfp.h was usually
         wildly available and often used in preprocessor macros.  Each
         slab.h inclusion directive was examined and added manually as
         necessary.
      
      6. percpu.h was updated not to include slab.h.
      
      7. Build test were done on the following configurations and failures
         were fixed.  CONFIG_GCOV_KERNEL was turned off for all tests (as my
         distributed build env didn't work with gcov compiles) and a few
         more options had to be turned off depending on archs to make things
         build (like ipr on powerpc/64 which failed due to missing writeq).
      
         * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
         * powerpc and powerpc64 SMP allmodconfig
         * sparc and sparc64 SMP allmodconfig
         * ia64 SMP allmodconfig
         * s390 SMP allmodconfig
         * alpha SMP allmodconfig
         * um on x86_64 SMP allmodconfig
      
      8. percpu.h modifications were reverted so that it could be applied as
         a separate patch and serve as bisection point.
      
      Given the fact that I had only a couple of failures from tests on step
      6, I'm fairly confident about the coverage of this conversion patch.
      If there is a breakage, it's likely to be something in one of the arch
      headers which should be easily discoverable easily on most builds of
      the specific arch.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Guess-its-ok-by: NChristoph Lameter <cl@linux-foundation.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
      5a0e3ad6
  21. 17 3月, 2010 1 次提交
  22. 27 2月, 2010 2 次提交