Re: Sometimes DVB broken with commit 6769a0b7ee0c3b

From: Mauro Carvalho Chehab
Date: Mon Jun 05 2023 - 06:37:47 EST


Em Mon, 5 Jun 2023 11:38:49 +0200
"Linux regression tracking (Thorsten Leemhuis)" <regressions@xxxxxxxxxxxxx> escreveu:

> Hi, Thorsten here, the Linux kernel's regression tracker.
>
> On 30.05.23 13:12, Thomas Voegtle wrote:
> >
> > I have the problem that sometimes my DVB card does not initialize
> > properly booting Linux 6.4-rc4.
> > This is not always, maybe in 3 out of 4 attempts.
> > When this happens somehow you don't see anything special in dmesg, but
> > the card just doesn't work.
> >
> > Reverting this helps:
> > commit 6769a0b7ee0c3b31e1b22c3fadff2bfb642de23f
> > Author: Hyunwoo Kim <imv4bel@xxxxxxxxx>
> > Date:   Thu Nov 17 04:59:22 2022 +0000
> >
> >     media: dvb-core: Fix use-after-free on race condition at dvb_frontend
> >
> >
> > I have:
> > 03:00.0 Multimedia video controller [0400]: Conexant Systems, Inc.
> > CX23887/8
> > PCIe Broadcast Audio and Video Decoder with 3D Comb [14f1:8880] (rev 04)
> >         Subsystem: Hauppauge computer works Inc. Device [0070:c138]
> >         Kernel driver in use: cx23885
>
> Hmmm, that was posted last Tuesday and received not a single reply. :-/
>
> Hyunwoo Kim: could you please look at it, as it's a regression caused by
> a commit of yours (one that would be good to solve before 6.4 is
> finalized!)? And in case you are unable to do so let us know?
>
> But FWIW:
>
> Mauro: I wonder if this is something you or someone else has to look
> into, as Hyunwoo Kim posted a few times per months to Linux lists, but
> according to a quick search on lore hasn't posted anything since ~two
> months now. :-/

Yeah, I was slow applying this one, as I was afraid of it to cause
troubles. The DVB frontend state machine is complex, and uses a
semaphore to update its state. There was some past attempts of
addressing some lifetime issues there that we ended needing to revert
or not being applied, as the fix caused more harm than good.

The way DVB tuning works is that it uses a zigzag mechanism to
tune to a frequency. It actually tries to tune at several different
frequencies, like:

f
f + delta
f - delta
f + 2 * delta
f - 2 * delta
...

the DVB core supports 3 different types of zigzag approaches:
- hardware-based - no need to do any special implementation;
- software-based - Kernel will try the above tunes in in a
zig-zag way;
- custom-based - the hardware has some helpers to speedup
and improve the tuning logic.

If a signal is lost, the device will re-run the zigzag logic.

It is not trivial to test all possible conditions there, and some
boards may have multiple frontend devices for different types of
TV transmission (cable, satellite, air).

As I don't have a DVB signal generator anymore, my tests were limited to
devices I have it handy that are compatible with DVB/T.

In any case, we need more details about the problem, as CX23887 is just
the media streaming PCIe bridge device. It tells nothing about what
frontend is attached to the bridge.

Regards,
Mauro