Reopen cpu_dma device when changing settings

This fixes a bug with previous filedes remaining open,
only allowing to increase the constraint.
This commit is contained in:
Robin Gareus
2021-06-10 21:35:52 +02:00
parent 5af30601a9
commit b67d783cd6

View File

@@ -286,12 +286,14 @@ setup_hardware_optimization (bool try_optimization)
}
static void
release_dma_latency ()
release_dma_latency (bool log = true)
{
#if !(defined PLATFORM_WINDOWS || defined __APPLE__)
if (cpu_dma_latency_fd >= 0) {
info << _("Released CPU DMA latency request") << endmsg;
::close (cpu_dma_latency_fd);
if (log) {
info << _("Released CPU DMA latency request") << endmsg;
}
}
cpu_dma_latency_fd = -1;
#endif
@@ -313,6 +315,8 @@ request_dma_latency ()
return true;
}
release_dma_latency (false);
cpu_dma_latency_fd = ::open("/dev/cpu_dma_latency", O_WRONLY);
if (cpu_dma_latency_fd < 0) {
warning << string_compose (_("Could not set CPU DMA latency to %1 usec (%2)"), target, strerror (errno)) << endmsg;