From 2ab3b7a1fc64e8f855f076206e581476a6a67c24 Mon Sep 17 00:00:00 2001 From: Sameeh Jubran Date: Mon, 26 Sep 2016 16:00:07 +0300 Subject: [PATCH] Use frame buffer in VGA mode only Framebuffer should only be used in VGA mode, as WDDM DOD driver doesn't use the frame buffer (bar0), so no reason to map in into memory. However the mode is only known at runtime therefore framebuffer logic should be active when the driver is operating in vga mode only. There were rare BSOD failures when the mapping failed. Signed-off-by: Sameeh Jubran Signed-off-by: Dmitry Fleytman --- qxldod/QxlDod.cpp | 38 +++++++++++++++++++++----------------- qxldod/QxlDod.h | 4 ++++ 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/qxldod/QxlDod.cpp b/qxldod/QxlDod.cpp index e12aeed..0d91f92 100755 --- a/qxldod/QxlDod.cpp +++ b/qxldod/QxlDod.cpp @@ -222,9 +222,7 @@ VOID QxlDod::CleanUp(VOID) { if (m_CurrentModes[Source].FrameBuffer.Ptr) { - UnmapFrameBuffer(m_CurrentModes[Source].FrameBuffer.Ptr, m_CurrentModes[Source].DispInfo.Height * m_CurrentModes[Source].DispInfo.Pitch); - m_CurrentModes[Source].FrameBuffer.Ptr = NULL; - m_CurrentModes[Source].Flags.FrameBufferIsActive = FALSE; + m_pHWDevice->ReleaseFrameBuffer(&m_CurrentModes[Source]); } } } @@ -1395,11 +1393,7 @@ NTSTATUS QxlDod::CommitVidPn(_In_ CONST DXGKARG_COMMITVIDPN* CONST pCommitVidPn) if (m_CurrentModes[pCommitVidPn->AffectedVidPnSourceId].FrameBuffer.Ptr && !m_CurrentModes[pCommitVidPn->AffectedVidPnSourceId].Flags.DoNotMapOrUnmap) { - Status = UnmapFrameBuffer(m_CurrentModes[pCommitVidPn->AffectedVidPnSourceId].FrameBuffer.Ptr, - m_CurrentModes[pCommitVidPn->AffectedVidPnSourceId].DispInfo.Pitch * m_CurrentModes[pCommitVidPn->AffectedVidPnSourceId].DispInfo.Height); - m_CurrentModes[pCommitVidPn->AffectedVidPnSourceId].FrameBuffer.Ptr = NULL; - m_CurrentModes[pCommitVidPn->AffectedVidPnSourceId].Flags.FrameBufferIsActive = FALSE; - + Status = m_pHWDevice->ReleaseFrameBuffer(&m_CurrentModes[pCommitVidPn->AffectedVidPnSourceId]); if (!NT_SUCCESS(Status)) { goto CommitVidPnExit; @@ -1523,15 +1517,7 @@ NTSTATUS QxlDod::SetSourceModeAndPath(CONST D3DKMDT_VIDPN_SOURCE_MODE* pSourceMo pCurrentBddMode->DispInfo.Height = pSourceMode->Format.Graphics.PrimSurfSize.cy; pCurrentBddMode->DispInfo.Pitch = pSourceMode->Format.Graphics.PrimSurfSize.cx * BPPFromPixelFormat(pCurrentBddMode->DispInfo.ColorFormat) / BITS_PER_BYTE; - - if (!pCurrentBddMode->Flags.DoNotMapOrUnmap) - { - // Map the new frame buffer - QXL_ASSERT(pCurrentBddMode->FrameBuffer.Ptr == NULL); - Status = MapFrameBuffer(pCurrentBddMode->DispInfo.PhysicAddress, - pCurrentBddMode->DispInfo.Pitch * pCurrentBddMode->DispInfo.Height, - &(pCurrentBddMode->FrameBuffer.Ptr)); - } + Status = m_pHWDevice->AcquireFrameBuffer(pCurrentBddMode); if (NT_SUCCESS(Status)) { @@ -2933,6 +2919,24 @@ VOID VgaDevice::ResetDevice(VOID) { } +NTSTATUS VgaDevice::AcquireFrameBuffer(CURRENT_BDD_MODE* pCurrentBddMode) +{ + // Map the new frame buffer + QXL_ASSERT(pCurrentBddMode->FrameBuffer.Ptr == NULL); + NTSTATUS status = MapFrameBuffer(pCurrentBddMode->DispInfo.PhysicAddress, + pCurrentBddMode->DispInfo.Pitch * pCurrentBddMode->DispInfo.Height, + &(pCurrentBddMode->FrameBuffer.Ptr)); + return status; +} + +NTSTATUS VgaDevice::ReleaseFrameBuffer(CURRENT_BDD_MODE* pCurrentBddMode) +{ + NTSTATUS status = UnmapFrameBuffer(pCurrentBddMode->FrameBuffer.Ptr, pCurrentBddMode->DispInfo.Height * pCurrentBddMode->DispInfo.Pitch); + pCurrentBddMode->FrameBuffer.Ptr = NULL; + pCurrentBddMode->Flags.FrameBufferIsActive = FALSE; + return status; +} + NTSTATUS VgaDevice::SetPointerShape(_In_ CONST DXGKARG_SETPOINTERSHAPE* pSetPointerShape) { UNREFERENCED_PARAMETER(pSetPointerShape); diff --git a/qxldod/QxlDod.h b/qxldod/QxlDod.h index 24e0f64..c808eb1 100755 --- a/qxldod/QxlDod.h +++ b/qxldod/QxlDod.h @@ -225,6 +225,8 @@ public: virtual BOOLEAN InterruptRoutine(_In_ PDXGKRNL_INTERFACE pDxgkInterface, _In_ ULONG MessageNumber) = 0; virtual VOID DpcRoutine(PVOID) = 0; virtual VOID ResetDevice(void) = 0; + virtual NTSTATUS AcquireFrameBuffer(CURRENT_BDD_MODE* pCurrentBddMode) { return STATUS_SUCCESS; } + virtual NTSTATUS ReleaseFrameBuffer(CURRENT_BDD_MODE* pCurrentBddMode) { return STATUS_SUCCESS; } virtual ULONG GetModeCount(void) = 0; PVIDEO_MODE_INFORMATION GetModeInfo(UINT idx) {return &m_ModeInfo[idx];} @@ -290,6 +292,8 @@ public: BOOLEAN InterruptRoutine(_In_ PDXGKRNL_INTERFACE pDxgkInterface, _In_ ULONG MessageNumber); VOID DpcRoutine(PVOID); VOID ResetDevice(VOID); + NTSTATUS AcquireFrameBuffer(CURRENT_BDD_MODE* pCurrentBddMode); + NTSTATUS ReleaseFrameBuffer(CURRENT_BDD_MODE* pCurrentBddMode); NTSTATUS SetPointerShape(_In_ CONST DXGKARG_SETPOINTERSHAPE* pSetPointerShape); NTSTATUS SetPointerPosition(_In_ CONST DXGKARG_SETPOINTERPOSITION* pSetPointerPosition); NTSTATUS Escape(_In_ CONST DXGKARG_ESCAPE* pEscap);