mbox series

[0/1] media: dvb-core: Enhance shared multi-frontend support

Message ID trinity-e74a4d07-b411-42cb-a763-c6d6828776da-1642799867846@3c-app-gmx-bap04 (mailing list archive)
Headers show
Series media: dvb-core: Enhance shared multi-frontend support | expand

Message

Robert Schlabbach Jan. 21, 2022, 9:17 p.m. UTC
I'm currently developing a driver for a receiver with multiple frontends which
cannot be used simultaneously, and found that employing the mfe_shared field to
exhibit that restriction leads to terrible behavior towards applications:

- the unavailable frontend device cannot be opened at all, not even in read-
  only mode to just query information about the frontend
- and really terrible: the open() call is blocked for a whopping 5 seconds!

The user experience ended up being this (/dev/dvb/adapter0/frontend0 was
already in use):

$ robscan
[5 seconds delay]
Could not open /dev/dvb/adapter0/frontend1, device is busy
Available Frontends and Supported Delivery Systems:
1: /dev/dvb/adapter0/frontend0: Silicon Labs Si2183 (DVB-T/T2)
2: /dev/dvb/adapter0/frontend0: Silicon Labs Si2183 (DVB-C)
[shared frontend is missing]
Select Frontend: 1
ERROR: Could not select frontend Silicon Labs Si2183: Device or resource busy

The actually busy frontend /dev/dvb/adapter0/frontend0 could be queried
for its name and supported delivery systems and the error when trying to
use it came back immediately, so I thought I want the shared frontend to
exhibit the same behavior, i.e. allow it being queried for its name and
supported delivery systems, and reject write access with -EBUSY without
delay.

So I developed the attached patch for dvb_core.c which allows setting the
mfe_shared field to 2 to achieve this behavior. Using this setting in my
driver yielded the desired result:

$ robscan
Available Frontends and Supported Delivery Systems:
1: /dev/dvb/adapter0/frontend0: Silicon Labs Si2183 (DVB-T/T2)
2: /dev/dvb/adapter0/frontend0: Silicon Labs Si2183 (DVB-C)
3: /dev/dvb/adapter0/frontend1: Silicon Labs Si2183 (DVB-S/S2)
Select Frontend: 3
ERROR: Could not select frontend Silicon Labs Si2183: Device or resource busy

No delays, the unavailable frontend can be shown with name and supported
delivery systems, and trying to use it gives the same result as for the
frontend device currently in use.

I left the existing uses of the mfe_shared field untouched so that existing
drivers continue to function as before. Maybe some would already work by just
setting the field to 2, but I did not take the time to thoroughly review their
code, nor do I have those devices available to do regression testing with.

So for now, only my driver would take advantage of this. I intend to submit
my device driver once it is finished.

Signed-off-by: Robert Schlabbach <robert_s@gmx.net>
Tested-by: Robert Schlabbach <robert_s@gmx.net>