Ensure syncpoints are released and event handles closed on channel close (#2812)
This commit is contained in:
parent
f78bcb8048
commit
81e9b86cdb
4 changed files with 84 additions and 49 deletions
|
@ -12,11 +12,27 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||
private KEvent _smExceptionBptPauseReportEvent;
|
||||
private KEvent _errorNotifierEvent;
|
||||
|
||||
private int _smExceptionBptIntReportEventHandle;
|
||||
private int _smExceptionBptPauseReportEventHandle;
|
||||
private int _errorNotifierEventHandle;
|
||||
|
||||
public NvHostGpuDeviceFile(ServiceCtx context, IVirtualMemoryManager memory, long owner) : base(context, memory, owner)
|
||||
{
|
||||
_smExceptionBptIntReportEvent = new KEvent(context.Device.System.KernelContext);
|
||||
_smExceptionBptPauseReportEvent = new KEvent(context.Device.System.KernelContext);
|
||||
_errorNotifierEvent = new KEvent(context.Device.System.KernelContext);
|
||||
_smExceptionBptIntReportEvent = CreateEvent(context, out _smExceptionBptIntReportEventHandle);
|
||||
_smExceptionBptPauseReportEvent = CreateEvent(context, out _smExceptionBptPauseReportEventHandle);
|
||||
_errorNotifierEvent = CreateEvent(context, out _errorNotifierEventHandle);
|
||||
}
|
||||
|
||||
private static KEvent CreateEvent(ServiceCtx context, out int handle)
|
||||
{
|
||||
KEvent evnt = new KEvent(context.Device.System.KernelContext);
|
||||
|
||||
if (context.Process.HandleTable.GenerateHandle(evnt.ReadableEvent, out handle) != KernelResult.Success)
|
||||
{
|
||||
throw new InvalidOperationException("Out of handles!");
|
||||
}
|
||||
|
||||
return evnt;
|
||||
}
|
||||
|
||||
public override NvInternalResult Ioctl2(NvIoctl command, Span<byte> arguments, Span<byte> inlineInBuffer)
|
||||
|
@ -39,41 +55,51 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||
public override NvInternalResult QueryEvent(out int eventHandle, uint eventId)
|
||||
{
|
||||
// TODO: accurately represent and implement those events.
|
||||
KEvent targetEvent = null;
|
||||
|
||||
switch (eventId)
|
||||
{
|
||||
case 0x1:
|
||||
targetEvent = _smExceptionBptIntReportEvent;
|
||||
eventHandle = _smExceptionBptIntReportEventHandle;
|
||||
break;
|
||||
case 0x2:
|
||||
targetEvent = _smExceptionBptPauseReportEvent;
|
||||
eventHandle = _smExceptionBptPauseReportEventHandle;
|
||||
break;
|
||||
case 0x3:
|
||||
targetEvent = _errorNotifierEvent;
|
||||
eventHandle = _errorNotifierEventHandle;
|
||||
break;
|
||||
default:
|
||||
eventHandle = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (targetEvent != null)
|
||||
{
|
||||
if (Context.Process.HandleTable.GenerateHandle(targetEvent.ReadableEvent, out eventHandle) != KernelResult.Success)
|
||||
{
|
||||
throw new InvalidOperationException("Out of handles!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
eventHandle = 0;
|
||||
|
||||
return NvInternalResult.InvalidInput;
|
||||
}
|
||||
|
||||
return NvInternalResult.Success;
|
||||
return eventHandle != 0 ? NvInternalResult.Success : NvInternalResult.InvalidInput;
|
||||
}
|
||||
|
||||
private NvInternalResult SubmitGpfifoEx(ref SubmitGpfifoArguments arguments, Span<ulong> inlineData)
|
||||
{
|
||||
return SubmitGpfifo(ref arguments, inlineData);
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
if (_smExceptionBptIntReportEventHandle != 0)
|
||||
{
|
||||
Context.Process.HandleTable.CloseHandle(_smExceptionBptIntReportEventHandle);
|
||||
_smExceptionBptIntReportEventHandle = 0;
|
||||
}
|
||||
|
||||
if (_smExceptionBptPauseReportEventHandle != 0)
|
||||
{
|
||||
Context.Process.HandleTable.CloseHandle(_smExceptionBptPauseReportEventHandle);
|
||||
_smExceptionBptPauseReportEventHandle = 0;
|
||||
}
|
||||
|
||||
if (_errorNotifierEventHandle != 0)
|
||||
{
|
||||
Context.Process.HandleTable.CloseHandle(_errorNotifierEventHandle);
|
||||
_errorNotifierEventHandle = 0;
|
||||
}
|
||||
|
||||
base.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue