virtio-win / kvm-guest-drivers-windows

Windows paravirtualized drivers for QEMU\KVM
https://www.linux-kvm.org/page/WindowsGuestDrivers
BSD 3-Clause "New" or "Revised" License
1.92k stars 377 forks source link

About HWCursor and BZ#1919947 #977

Open gang929 opened 10 months ago

gang929 commented 10 months ago

The VirtioGPU driver disabled the HWCursor by default. It's maybe caused by BZ#1919947.

After install VirtioGPU driver, and enable HWCursor by setting reg value HWCursor, it would show incorrect cursor.

The root reason maybe is that m_CtrlQueue and m_CursorQueue is not a same queue. When update cursor and QueueCursor, the cursor pic data is processed after cursor update cmd by virtiogpu device sometimes, so, the cursor is still show old cursor pic data.

By adding some delay between UpdateCursor and QueueCursor, the cursor will show correctlly.

@@   @@NTSTATUS VioGpuAdapter::SetPointerShape(_In_ CONST DXGKARG_SETPOINTERSHAPE* pSetPointerShape, _In_ CONST CURRENT_MODE* pModeCur)
    if (UpdateCursor(pSetPointerShape, pModeCur))
    {
        PGPU_UPDATE_CURSOR crsr;
        PGPU_VBUFFER vbuf;
        UINT ret = 0;
        crsr = (PGPU_UPDATE_CURSOR)m_CursorQueue.AllocCursor(&vbuf);
        RtlZeroMemory(crsr, sizeof(*crsr));

+     m_VioDev.system->vdev_sleep(&m_VioDev, 1);

        crsr->hdr.type = VIRTIO_GPU_CMD_UPDATE_CURSOR;
        crsr->resource_id = m_pCursorBuf->GetId();

But, the solution is too LOW.
Has any better solution? Maybe it's better to moving SetPointerShape QueueCursor cmd to m_CtrlQueue, but, it is need qemu supporting.

vrozenfe commented 10 months ago

hi @gang929 ,

Thank you for your patch. I do keep HWCursor disabled at the moment for the following reason - both SetPointerPosition and SetPointerShape calls are not synchronised and even more - they are initialised from different threads (actually even from different processes). Your solution may work for some cases, but I would prefer a more robust solution, which will require some sort of serialisation of these two calls by adding some queue and a kernel thread.

The issue described in https://bugzilla.redhat.com/show_bug.cgi?id=1919947 is not related to the HW cursor, because all tests were done with the HW cursor disabled at that time.

All the best, Vadim.