1. 25 4月, 2008 5 次提交
    • M
      V4L/DVB (7714): pvrusb2: Fix hang on module removal · 18ecbb47
      Mike Isely 提交于
      The pvrusb2 driver was getting had by this scenario:
      
      1. Task A calls kthread_stop() for task B.
      2. Before exiting, then Task B calls kthread_stop() for task C.
      
      The problem is, kthread_stop() wants to allocate an internal resource
      to itself (i.e. acquire a lock), which won't be released until
      kthread_stop() returns.  But kthread_stop() won't return until task B
      is dead.  But task B won't die until it finishes its call to
      kthread_stop() for task C, and that will block waiting on the resource
      already allocated inside task A.  Deadlock.
      
      With the pvrusb2 driver, task A is the caller to pvr_exit(), task B is
      the control thread run inside of pvrusb2-context.c, and task C is any
      worker thread run inside of pvrusb2-hdw.c.
      
      This problem got introduced by the previous threading setup change,
      which was itself an attempt to fix a module tear-down race (which it
      actually did fix).  The lesson here is that a task being waited on as
      part of a kthread_stop() simply cannot be allow to also issue a
      kthread_stop() - or we make sure not to issue the enclosing
      kthread_stop() until we know that the inner kthread_stop() has
      completed first.  The solution for the pvrusb2 driver is some hackish
      code which changes the main control thread tear down into a two step
      process.  This then makes it possible to delay issuing the
      kthread_stop() on the control thread until after we know that
      everything has been torn down first.  (And yes, we really need that
      kthread_stop() because it's the only way to safely guarantee that a
      module-referencing kernel thread has safely returned back out of the
      module before we finally remove the module.)
      Signed-off-by: NMike Isely <isely@pobox.com>
      Signed-off-by: NMauro Carvalho Chehab <mchehab@infradead.org>
      18ecbb47
    • M
      V4L/DVB (7711): pvrusb2: Fix race on module unload · e5be15c6
      Mike Isely 提交于
      The pvrusb2 driver - for basically forever - was not enforcing a
      proper module tear-down.  Kernel threads are used inside the driver
      and all must be gone before the module can be safely removed.  This
      changeset reimplements a chunk of pvrusb2-context.c to enforce this
      correctly.  Unfortunately this is not a simple fix.  The new
      implementation also cuts back on kernel thread usage; instead of there
      being 1 control thread per instance now it's just 1 control thread
      shared by all instances.  (By dropping to a single thread then the
      module exit function can block on its shutdown and the thread itself
      can monitor and cleanly shut down all of the other instances first.)
      Signed-off-by: NMike Isely <isely@pobox.com>
      Signed-off-by: NMauro Carvalho Chehab <mchehab@infradead.org>
      e5be15c6
    • M
      V4L/DVB (7321): pvrusb2: Rework context handling and initialization · 794b1607
      Mike Isely 提交于
      This change significantly rearranges pvr2_context level initialization
      and operation:
      
      1. A new kernel thread is set up for management of the context.
      
      2. Destruction of the pvr2_context instance is moved into the kernel
         thread.  No other context is able to remove the instance; doing
         this simplifies lock handling.
      
      3. The callback into pvrusb2-main, which is used to trigger
         initialization of each interface, is now issued from this kernel
         thread.  Previously it had been indirectly issued out of the work
         queue thread in pvr2_hdw, which led to deadlock issues if the
         interface needed to change a control setting (which in turn
         requires dispatch of another work queue entry).
      
      4. Callbacks into the interfaces (via the pvr2_channel structure) are
         now issued strictly from this thread.  The net result of this is
         that such callback functions can now also safely operate driver
         controls without deadlocking the work queue.  (At the moment this
         is not actually a problem, but I'm anticipating issues with this in
         the future).
      
      5. There is no longer any need for anyone to enter / exit the
         pvr2_context structure.  Implementation of the kernel thread here
         allows this all to be internal now, simplifying other logic.
      
      6. A very very longstanding issue involving a mutex deadlock between
         the pvrusb2 driver and v4l should now be solved.  The deadlock
         involved the pvr2_context mutex and a globals-protecting mutex in
         v4l.  During initialization the driver would take the pvr2_context
         mutex first then the v4l2 interface would register with v4l and
         implicitly take the v4l mutex.  Later when v4l would call back into
         the driver, the two mutexes could possibly be taken in the opposite
         order, a situation that can lead to deadlock.  In practice this
         really wasn't an issue unless a v4l app tried to start VERY early
         after the driver appeared.  However it still needed to be solved,
         and with the use of the kernel thread relieving need for
         pvr2_context mutex, the problem should be finally solved.
      Signed-off-by: NMike Isely <isely@pobox.com>
      Signed-off-by: NMauro Carvalho Chehab <mchehab@infradead.org>
      794b1607
    • M
      V4L/DVB (7319): pvrusb2: Close potential race condition during initialization · c4a8828d
      Mike Isely 提交于
      There is a callback that is issued to into pvr2_context from pvr2_hdw
      after initialization is done.  There was a probability that this
      callback could get missed.  Fixed.
      Signed-off-by: NMike Isely <isely@pobox.com>
      Signed-off-by: NMauro Carvalho Chehab <mchehab@infradead.org>
      c4a8828d
    • M
  2. 19 4月, 2008 1 次提交
  3. 26 1月, 2008 1 次提交
    • M
      V4L/DVB (6691): pvrusb2: Rework pipeline state control · 681c7399
      Mike Isely 提交于
      This is a new implementation for video pipeline control within the
      pvrusb2 driver.  Actual start/stop of the pipeline is moved to the
      driver's kernel thread.  Pipeline stages are controlled autonomously
      based on surrounding pipeline or application control state.  Kernel
      thread management is also cleaned up and moved into the internal
      control structure of the driver, solving a set up / tear down race
      along the way.  Better failure recovery is implemented with this new
      control strategy.  Also with this change comes better control of the
      cx23416 encoder, building on additional information learned about the
      peculiarities of controlling this part (this information was the
      original trigger for this rework).  With this change, overall encoder
      stability should be considerably improved.  Yes, this is a large
      change for this driver, but due to the nature of the feature being
      worked on, the changes are fairly pervasive and would be difficult to
      break into smaller pieces with any semblence of step-wise stability.
      Signed-off-by: NMike Isely <isely@pobox.com>
      Signed-off-by: NMauro Carvalho Chehab <mchehab@infradead.org>
      681c7399
  4. 10 10月, 2007 1 次提交
  5. 21 2月, 2007 3 次提交
  6. 22 11月, 2006 1 次提交
  7. 01 7月, 2006 1 次提交
  8. 27 6月, 2006 1 次提交