Device bonding

Message ID 20130217153425.GA65533@triton8.kn-bremen.de
State New
Headers

Commit Message

Juergen Lock Feb. 17, 2013, 3:34 p.m. UTC
  On Sat, Feb 16, 2013 at 04:46:36PM +0100, Juergen Lock wrote:
> Hi!
> 
> [...]

> 3. Running with these four tuners (dual DVB-T and the bonded two DVB-S2)
>    I get two different deadlocks waiting for cDvbTuner::bondMutex
>    after live viewing a DVB-T(!) channel for longer (OSD doesn't
>    react anymore and attaching gdb reveals two threads waiting for
>    bondMutex) - the following two changes make it work but there
>    probably is a better fix:  (patch may apply with offsets; one
>    of the problems I think is a lock order reversal with cDvbTuner::mutex
>    and bondMutex when cDvbTuner::SetChannel calls back into itself
>    with bondMutex held.)
> 
> --- dvbdevice.c.orig
> +++ dvbdevice.c
> @@ -476,8 +476,10 @@ void cDvbTuner::SetChannel(const cChanne
>                    t->SetChannel(NULL);
>                }
>             }
> -        else if (strcmp(GetBondingParams(Channel), BondedMaster->GetBondingParams()) != 0)
> +        else if (strcmp(GetBondingParams(Channel), BondedMaster->GetBondingParams()) != 0) {
> +           bondMutex.Unlock();
>             BondedMaster->SetChannel(Channel);
> +           }
>          }
>       cMutexLock MutexLock(&mutex);
>       if (!IsTunedTo(Channel))
> @@ -761,7 +773,12 @@ bool cDvbTuner::SetFrontend(void)
>             tone = SEC_TONE_ON;
>             }
>          int volt = (dtp.Polarization() == 'V' || dtp.Polarization() == 'R') ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18;
> -        if (GetBondedMaster() != this) {
> +#if 1
> +        if (bondedTuner && !bondedMaster)
> +#else
> +        if (GetBondedMaster() != this)
> +#endif
> +           {
>             tone = SEC_TONE_OFF;
>             volt = SEC_VOLTAGE_13;
>             }
> 

Hmm looks like I posted too soon, the first hunk is actually too much
and causes other deadlocks (like when trying to play a DVB-S channel
via streamdev while live viewing another), so the patch I'm not testing
becomes:


 Sorry,
	Juergen
  

Comments

Juergen Lock Feb. 18, 2013, 10:51 p.m. UTC | #1
On Sun, Feb 17, 2013 at 04:34:25PM +0100, Juergen Lock wrote:
> On Sat, Feb 16, 2013 at 04:46:36PM +0100, Juergen Lock wrote:
> > Hi!
> > 
> > [...]
> 
> > 3. Running with these four tuners (dual DVB-T and the bonded two DVB-S2)
> >    I get two different deadlocks waiting for cDvbTuner::bondMutex
> >    after live viewing a DVB-T(!) channel for longer (OSD doesn't
> >    react anymore and attaching gdb reveals two threads waiting for
> >    bondMutex) - the following two changes make it work but there
> >    probably is a better fix:  (patch may apply with offsets; one
> >    of the problems I think is a lock order reversal with cDvbTuner::mutex
> >    and bondMutex when cDvbTuner::SetChannel calls back into itself
> >    with bondMutex held.)
> > 
> > --- dvbdevice.c.orig
> > +++ dvbdevice.c
> > @@ -476,8 +476,10 @@ void cDvbTuner::SetChannel(const cChanne
> >                    t->SetChannel(NULL);
> >                }
> >             }
> > -        else if (strcmp(GetBondingParams(Channel), BondedMaster->GetBondingParams()) != 0)
> > +        else if (strcmp(GetBondingParams(Channel), BondedMaster->GetBondingParams()) != 0) {
> > +           bondMutex.Unlock();
> >             BondedMaster->SetChannel(Channel);
> > +           }
> >          }
> >       cMutexLock MutexLock(&mutex);
> >       if (!IsTunedTo(Channel))
> > @@ -761,7 +773,12 @@ bool cDvbTuner::SetFrontend(void)
> >             tone = SEC_TONE_ON;
> >             }
> >          int volt = (dtp.Polarization() == 'V' || dtp.Polarization() == 'R') ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18;
> > -        if (GetBondedMaster() != this) {
> > +#if 1
> > +        if (bondedTuner && !bondedMaster)
> > +#else
> > +        if (GetBondedMaster() != this)
> > +#endif
> > +           {
> >             tone = SEC_TONE_OFF;
> >             volt = SEC_VOLTAGE_13;
> >             }
> > 
> 
> Hmm looks like I posted too soon, the first hunk is actually too much
> and causes other deadlocks (like when trying to play a DVB-S channel
> via streamdev while live viewing another), so the patch I'm not testing

.. I'm _now_ testing...

> becomes:
> 
> --- dvbdevice.c.orig
> +++ dvbdevice.c
> @@ -761,7 +773,12 @@ bool cDvbTuner::SetFrontend(void)
>             tone = SEC_TONE_ON;
>             }
>          int volt = (dtp.Polarization() == 'V' || dtp.Polarization() == 'R') ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18;
> -        if (GetBondedMaster() != this) {
> +#if 1
> +        if (bondedTuner && !bondedMaster)
> +#else
> +        if (GetBondedMaster() != this)
> +#endif
> +           {
>             tone = SEC_TONE_OFF;
>             volt = SEC_VOLTAGE_13;
>             }
> 

 Stupid typos...
	Juergen
  

Patch

--- dvbdevice.c.orig
+++ dvbdevice.c
@@ -761,7 +773,12 @@  bool cDvbTuner::SetFrontend(void)
            tone = SEC_TONE_ON;
            }
         int volt = (dtp.Polarization() == 'V' || dtp.Polarization() == 'R') ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18;
-        if (GetBondedMaster() != this) {
+#if 1
+        if (bondedTuner && !bondedMaster)
+#else
+        if (GetBondedMaster() != this)
+#endif
+           {
            tone = SEC_TONE_OFF;
            volt = SEC_VOLTAGE_13;
            }