mirror of
https://git.ryujinx.app/projects/Kenji-NX.git
synced 2026-10-08 12:39:03 +02:00
Snapdragon 8 Elite (& Adreno 8xx) Fixes
See merge request kenji-nx/ryujinx!20
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.HLE.HOS.Kernel.Threading;
|
||||
using Ryujinx.Horizon.Common;
|
||||
using System.Collections.Generic;
|
||||
@@ -52,8 +53,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
|
||||
|
||||
lock (_lock)
|
||||
{
|
||||
if (_current2[index] >= _limit[index])
|
||||
if (_current2[index] >= _limit[index] && amount > 0)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Kernel, $"Resource limit {resource} reached! Current: {_current[index]}, Current2: {_current2[index]}, Limit: {_limit[index]}, Requested: {amount}");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -87,6 +89,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
|
||||
|
||||
success = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Kernel, $"Resource limit {resource} exceeded! Current: {_current[index]}, Current2: {_current2[index]}, Limit: {_limit[index]}, Requested: {amount}");
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.HLE.HOS.Kernel.Memory;
|
||||
using Ryujinx.Horizon.Common;
|
||||
using System;
|
||||
@@ -31,8 +32,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
|
||||
}
|
||||
|
||||
ulong ramSize = KSystemControl.GetDramSize(size);
|
||||
ulong memoryLimit = ramSize + 12288 * 1024 * 1024UL; // Add 12GB slack for System Resource and MapPhysicalMemory
|
||||
|
||||
EnsureSuccess(resourceLimit.SetLimitValue(LimitableResource.Memory, (long)ramSize));
|
||||
Logger.Info?.Print(LogClass.Kernel, $"Initializing system resource limit: DRAM={ramSize / 1024 / 1024}MB, Total={memoryLimit / 1024 / 1024}MB");
|
||||
|
||||
EnsureSuccess(resourceLimit.SetLimitValue(LimitableResource.Memory, (long)memoryLimit));
|
||||
EnsureSuccess(resourceLimit.SetLimitValue(LimitableResource.Thread, 800));
|
||||
EnsureSuccess(resourceLimit.SetLimitValue(LimitableResource.Event, 700));
|
||||
EnsureSuccess(resourceLimit.SetLimitValue(LimitableResource.TransferMemory, 200));
|
||||
@@ -47,8 +51,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
|
||||
|
||||
public static KMemoryRegionManager[] GetMemoryRegions(MemorySize size, MemoryArrange arrange)
|
||||
{
|
||||
ulong poolEnd = KSystemControl.GetDramEndAddress(size);
|
||||
ulong applicationPoolSize = KSystemControl.GetApplicationPoolSize(arrange);
|
||||
ulong dramSize = KSystemControl.GetDramSize(size);
|
||||
ulong slack = 12288 * 1024 * 1024UL;
|
||||
ulong poolEnd = DramMemoryMap.DramBase + dramSize + slack;
|
||||
|
||||
ulong applicationPoolSize = KSystemControl.GetApplicationPoolSize(arrange) + slack;
|
||||
ulong appletPoolSize = KSystemControl.GetAppletPoolSize(arrange);
|
||||
|
||||
MemoryRegion servicePool;
|
||||
|
||||
@@ -1887,12 +1887,16 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
}
|
||||
|
||||
Logger.Error?.Print(LogClass.KernelSvc, "The guest program broke execution!");
|
||||
Logger.Error?.Print(
|
||||
LogClass.KernelSvc,
|
||||
$"SvcBreak reason=0x{reason:X16} pid={currentThread.Owner?.Pid} titleId=0x{currentThread.Owner?.TitleId:X16} name={currentThread.Owner?.Name} tid={currentThread.ThreadUid} pc=0x{currentThread.Context.Pc:X}"
|
||||
);
|
||||
Logger.Flush();
|
||||
|
||||
// TODO: Debug events.
|
||||
currentThread.Owner.TerminateCurrentProcess();
|
||||
|
||||
throw new GuestBrokeExecutionException();
|
||||
currentThread.Exit();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1263,17 +1263,30 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
||||
_schedulerWaitEvent.Wait();
|
||||
KernelStatic.SetKernelContext(KernelContext, this);
|
||||
|
||||
if (_customThreadStart != null)
|
||||
try
|
||||
{
|
||||
_customThreadStart();
|
||||
if (_customThreadStart != null)
|
||||
{
|
||||
_customThreadStart();
|
||||
|
||||
// Ensure that anything trying to join the HLE thread is unblocked.
|
||||
Exit();
|
||||
HandlePostSyscall();
|
||||
// Ensure that anything trying to join the HLE thread is unblocked.
|
||||
Exit();
|
||||
HandlePostSyscall();
|
||||
}
|
||||
else
|
||||
{
|
||||
Owner.Context.Execute(Context, _entrypoint);
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (Ryujinx.HLE.Exceptions.GuestBrokeExecutionException)
|
||||
{
|
||||
Owner.Context.Execute(Context, _entrypoint);
|
||||
Logger.Warning?.Print(LogClass.Kernel, "Guest broke execution. Thread exiting.");
|
||||
Exit();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error?.Print(LogClass.Kernel, $"Unhandled exception in guest thread: {ex}");
|
||||
Exit();
|
||||
}
|
||||
|
||||
Context.Dispose();
|
||||
|
||||
@@ -398,6 +398,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
||||
return NvInternalResult.Success;
|
||||
}
|
||||
|
||||
public override void Close() { }
|
||||
public override void Close()
|
||||
{
|
||||
_asContext.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
@@ -123,6 +123,17 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types
|
||||
return _reservations.Remove(gpuVa);
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
foreach (var map in _maps.Values)
|
||||
{
|
||||
Gmm.Unmap(map.Start, map.End - map.Start);
|
||||
}
|
||||
|
||||
_maps.Clear();
|
||||
_reservations.Clear();
|
||||
}
|
||||
|
||||
private Range BinarySearch(SortedList<ulong, Range> list, ulong address)
|
||||
{
|
||||
int left = 0;
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl
|
||||
/// Max failing count until waiting on CPU.
|
||||
/// FIXME: This seems enough for most of the cases, reduce if needed.
|
||||
/// </summary>
|
||||
private const uint FailingCountMax = 2;
|
||||
private const uint FailingCountMax = 10;
|
||||
|
||||
public NvHostEvent(NvHostSyncpt syncpointManager, uint eventId, Horizon system)
|
||||
{
|
||||
|
||||
@@ -368,7 +368,16 @@ namespace Ryujinx.HLE.HOS.Services
|
||||
_requestDataReader,
|
||||
_responseDataWriter);
|
||||
|
||||
GetSessionObj(serverSessionHandle).CallCmifMethod(context);
|
||||
try
|
||||
{
|
||||
GetSessionObj(serverSessionHandle).CallCmifMethod(context);
|
||||
}
|
||||
catch (Ryujinx.HLE.Exceptions.GuestBrokeExecutionException)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Kernel, "Guest broke execution in service call. Thread exiting.");
|
||||
_selfThread.Exit();
|
||||
return false;
|
||||
}
|
||||
|
||||
response.RawData = _responseDataStream.ToArray();
|
||||
}
|
||||
|
||||
@@ -334,8 +334,11 @@ namespace Ryujinx.HLE.Loaders.Processes
|
||||
KResourceLimit resourceLimit = new(context);
|
||||
|
||||
long applicationRgSize = (long)context.MemoryManager.MemoryRegions[(int)MemoryRegion.Application].Size;
|
||||
long memoryLimit = applicationRgSize + 12288 * 1024 * 1024L; // Add 12GB slack for System Resource and MapPhysicalMemory
|
||||
|
||||
result = resourceLimit.SetLimitValue(LimitableResource.Memory, applicationRgSize);
|
||||
Logger.Info?.Print(LogClass.Loader, $"Initializing process resource limit: ApplicationRegion={applicationRgSize / 1024 / 1024}MB, Total={memoryLimit / 1024 / 1024}MB");
|
||||
|
||||
result = resourceLimit.SetLimitValue(LimitableResource.Memory, memoryLimit);
|
||||
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace Ryujinx.HLE
|
||||
static class MemoryConfigurationExtensions
|
||||
{
|
||||
private const ulong GiB = 1024 * 1024 * 1024;
|
||||
private const ulong DRAMSlackSize = 12288 * 1024 * 1024UL;
|
||||
|
||||
#pragma warning disable IDE0055 // Disable formatting
|
||||
public static MemoryArrange ToKernelMemoryArrange(this MemoryConfiguration configuration)
|
||||
@@ -54,7 +55,7 @@ namespace Ryujinx.HLE
|
||||
|
||||
public static ulong ToDramSize(this MemoryConfiguration configuration)
|
||||
{
|
||||
return configuration switch
|
||||
ulong size = configuration switch
|
||||
{
|
||||
MemoryConfiguration.MemoryConfiguration4GiB or
|
||||
MemoryConfiguration.MemoryConfiguration4GiBAppletDev or
|
||||
@@ -66,6 +67,8 @@ namespace Ryujinx.HLE
|
||||
MemoryConfiguration.MemoryConfiguration12GiB => 12 * GiB,
|
||||
_ => throw new AggregateException($"Invalid memory configuration \"{configuration}\"."),
|
||||
};
|
||||
|
||||
return size + DRAMSlackSize;
|
||||
}
|
||||
#pragma warning restore IDE0055
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user