<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Sep 21, 2020 at 1:55 PM Stephen Worthington <<a href="mailto:stephen_agent@jsw.gen.nz">stephen_agent@jsw.gen.nz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Mon, 21 Sep 2020 12:48:30 -0400, you wrote:<br>
<br>
>From what I've read on this list I think I have a race issue. I'm using one<br>
>PCIe and three PCI capture devices, no network tuners, but now that I have<br>
>ACPI functioning, I noticed a conflict for football games on Sunday. Half<br>
>of my tuners were not recognized (outlined in red) fixed with a "sudo<br>
>systemctl restart mythtvbackend". Googling shows a solution for 16.04<br>
>involving system.d, because I'm using 20.04, I'm not sure that that is<br>
>appropriate for me. I believe I need to add a delay and would appreciate<br>
>being told where to put it. OS is now on a SSD, mythtv version 31. TIA<br>
>Daryl<br>
<br>
No, never fix race conditions using a delay.  That always ends badly.<br>
Race conditions should be fixed by waiting for the device to be ready.<br>
For non-networked tuners, you can add a udev rule to make their status<br>
available to systemd, then set up systemd to make mythbackend wait<br>
until all the tuners are available before it starts.<br>
<br>
In /etc/udev/rules.d add a new file 99-tuner.rules:<br>
<br>
#<br>
# Create systemd device units for capture devices<br>
#<br>
SUBSYSTEM=="video4linux", TAG+="systemd"<br>
SUBSYSTEM=="dvb", TAG+="systemd"<br>
SUBSYSTEM=="firewire", TAG+="systemd"<br>
<br>
It should be chown root:root and chmod u=rw,og=r.<br>
<br>
Then do:<br>
<br>
sudo systemctl edit mythtv-backend<br>
<br>
which will either create a new systemd override file or edit an<br>
existing one.  In the override file, put:<br>
<br>
[Unit]<br>
Wants=dev-dvb-adapter0-frontend0.device<br>
After=dev-dvb-adapter0-frontend0.device<br>
Wants=dev-dvb-adapter1-frontend0.device<br>
After=dev-dvb-adapter1-frontend0.device<br>
Wants=dev-dvb-adapter2-frontend0.device<br>
After=dev-dvb-adapter2-frontend0.device<br>
Wants=dev-dvb-adapter3-frontend0.device<br>
After=dev-dvb-adapter3-frontend0.device<br>
<br>
Save the file and exit the editor.  Then do:<br>
<br>
sudo systemctl daemon-reload<br>
<br>
to get systemd to see the new configuration.  Then reboot.<br>
<br>
What the SUBSYSTEM=="dvb", TAG+="systemd" rule does is create systemd<br>
devices for each DVB adapter like "dev-dvb-adapter0-frontend0.device".<br>
If you look in your /var/log/kern.log file you should find messages<br>
about each DVB adapter that gets created giving the adapter numbers.<br>
You can also do a command like:<br>
<br>
sudo systemctl status dev-dvb-adapter0-frontend0.device.  Here is what<br>
I get:<br>
<br>
? dev-dvb-adapter0-frontend0.device - /dev/dvb/adapter0/frontend0<br>
   Follow: unit currently follows state of<br>
sys-devices-pci0000:00-0000:00:0a.0-0000:07:00.0-dvb-dvb0.frontend0.device<br>
   Loaded: loaded<br>
   Active: active (plugged) since Fri 2020-09-18 02:10:33 NZST; 4 days<br>
ago<br>
   Device:<br>
/sys/devices/pci0000:00/0000:00:0a.0/0000:07:00.0/dvb/dvb0.frontend0<br>
<br>
Sep 18 02:10:33 mypvr systemd[1]: Found device<br>
/dev/dvb/adapter0/frontend0.<br>
<br>
and from the sys-devices line you can track down which PCI bus device<br>
is being referred to and hence which tuner.<br>
<br>
The [Unit] Wants and After lines tell systemd that this unit needs<br>
those devices to have been started and become available before it gets<br>
started.  There is a global systemd timeout that gets applied, so that<br>
even if one of the devices is not available, after that timeout (30?<br>
seconds), the unit gets started anyway.<br>
<br>
The above presumes that all your tuners are DVB or ATSC devices which<br>
create devices like /dev/dvb/adapter0/frontend0.  If they are analogue<br>
capture cards that create devices like /dev/video0, then the systemd<br>
device names needed will be like dev-video0.device.  <br><br></blockquote><div>Yes, all ATSC. I just rebooted, after making the changes, and unlike other reboots, when I opened the FE, it searched for the BE, which confirms, for me, that this worked very well. Many thanks Stephen! </div></div></div>