Backport pull request #9050 from jellyfin/release-10.8.z

Update workaround for i915 hang in linux 5.18 to 6.1.3

Original-merge: 464136cfc9

Merged-by: Bond-009 <bond.009@outlook.com>

Backported-by: Joshua M. Boniface <joshua@boniface.me>
This commit is contained in:
nyanmisaka 2023-01-22 14:05:00 -05:00 committed by Joshua M. Boniface
parent ab96d1b7ad
commit d6f44818e4

View File

@ -38,7 +38,10 @@ namespace MediaBrowser.Controller.MediaEncoding
private readonly ISubtitleEncoder _subtitleEncoder; private readonly ISubtitleEncoder _subtitleEncoder;
private readonly IConfiguration _config; private readonly IConfiguration _config;
private readonly Version _minKernelVersionAmdVkFmtModifier = new Version(5, 15); private readonly Version _minKernelVersionAmdVkFmtModifier = new Version(5, 15);
private readonly Version _minKernelVersioni915Hang = new Version(5, 18); // i915 hang was fixed by linux 6.2 (3f882f2)
private readonly Version _minKerneli915Hang = new Version(5, 18);
private readonly Version _maxKerneli915Hang = new Version(6, 1, 3);
private readonly Version _minFixedKernel60i915Hang = new Version(6, 0, 18);
private static readonly string[] _videoProfilesH264 = new[] private static readonly string[] _videoProfilesH264 = new[]
{ {
@ -1336,7 +1339,7 @@ namespace MediaBrowser.Controller.MediaEncoding
// which will reduce overhead in performance intensive tasks such as 4k transcoding and tonemapping. // which will reduce overhead in performance intensive tasks such as 4k transcoding and tonemapping.
var intelLowPowerHwEncoding = false; var intelLowPowerHwEncoding = false;
// Workaround for linux 5.18+ i915 hang at cost of performance. // Workaround for linux 5.18 to 6.1.3 i915 hang at cost of performance.
// https://github.com/intel/media-driver/issues/1456 // https://github.com/intel/media-driver/issues/1456
var enableWaFori915Hang = false; var enableWaFori915Hang = false;
@ -1355,18 +1358,25 @@ namespace MediaBrowser.Controller.MediaEncoding
} }
else if (string.Equals(encodingOptions.HardwareAccelerationType, "qsv", StringComparison.OrdinalIgnoreCase)) else if (string.Equals(encodingOptions.HardwareAccelerationType, "qsv", StringComparison.OrdinalIgnoreCase))
{ {
if (OperatingSystem.IsLinux() && Environment.OSVersion.Version >= _minKernelVersioni915Hang) if (OperatingSystem.IsLinux())
{ {
var vidDecoder = GetHardwareVideoDecoder(state, encodingOptions) ?? string.Empty; var ver = Environment.OSVersion.Version;
var isIntelDecoder = vidDecoder.Contains("qsv", StringComparison.OrdinalIgnoreCase) var isFixedKernel60 = ver.Major == 6 && ver.Minor == 0 && ver >= _minFixedKernel60i915Hang;
|| vidDecoder.Contains("vaapi", StringComparison.OrdinalIgnoreCase); var isUnaffectedKernel = ver < _minKerneli915Hang || ver > _maxKerneli915Hang;
var doOclTonemap = _mediaEncoder.SupportsHwaccel("qsv")
&& IsVaapiSupported(state)
&& IsOpenclFullSupported()
&& !IsVaapiVppTonemapAvailable(state, encodingOptions)
&& IsHwTonemapAvailable(state, encodingOptions);
enableWaFori915Hang = isIntelDecoder && doOclTonemap; if (!(isUnaffectedKernel || isFixedKernel60))
{
var vidDecoder = GetHardwareVideoDecoder(state, encodingOptions) ?? string.Empty;
var isIntelDecoder = vidDecoder.Contains("qsv", StringComparison.OrdinalIgnoreCase)
|| vidDecoder.Contains("vaapi", StringComparison.OrdinalIgnoreCase);
var doOclTonemap = _mediaEncoder.SupportsHwaccel("qsv")
&& IsVaapiSupported(state)
&& IsOpenclFullSupported()
&& !IsVaapiVppTonemapAvailable(state, encodingOptions)
&& IsHwTonemapAvailable(state, encodingOptions);
enableWaFori915Hang = isIntelDecoder && doOclTonemap;
}
} }
if (string.Equals(videoEncoder, "h264_qsv", StringComparison.OrdinalIgnoreCase)) if (string.Equals(videoEncoder, "h264_qsv", StringComparison.OrdinalIgnoreCase))