• Colin Xu's avatar
    drm/i915/gvt: Get accurate vGPU virtual display refresh rate from vreg · 6a4500c7
    Colin Xu authored
    Guest OS builds up its timing mode list based on the virtual EDID as
    simulated by GVT. However since there are several timings supported in
    the virtual EDID, and each timing can also support several modes
    (resolution and refresh rate), current emulated vblank period (16ms)
    may not always be correct and could lead to miss-sync behavior in guest.
    
    Guest driver will setup new resolution and program vregs accordingly and
    it should always follows GEN PRM. Based on the simulated display regs by
    GVT, it's safe to decode the actual refresh rate using by guest from
    vreg only.
    
    Current implementation only enables PIPE_A and PIPE_A is always tied to
    TRANSCODER_A in HW. GVT may simulate DP monitor on PORT_B or PORT_D
    based on the caller. So we can find out which DPLL is used by PORT_x
    which connected to TRANSCODER_A and calculate the DP bit rate from the
    DPLL frequency. Then DP stream clock (pixel clock) can be calculated
    from DP link M/N and DP bit rate. Finally, get the refresh rate from
    pixel clock, H total and V total.
    
    The per-vGPU accurate refresh rate is not used yet but only stored,
    until per-vGPU vblank timer is enabled. Then each vGPU can have
    different and accurate refresh rate per-guest driver configuration.
    
    Refer to PRM for GEN display and VESA timing standard for more details.
    
    V2:
    Rebase to 5.11.
    Correctly calculate DP link rate for BDW and BXT.
    Use GVT_DEFAULT_REFRESH_RATE instead of hardcoded to 60 as init refresh.
    Typo fix. (zhenyu)
    Signed-off-by: default avatarColin Xu <colin.xu@intel.com>
    Signed-off-by: default avatarZhenyu Wang <zhenyuw@linux.intel.com>
    Link: http://patchwork.freedesktop.org/patch/msgid/20210226044559.283622-1-colin.xu@intel.comReviewed-by: default avatarZhenyu Wang <zhenyuw@linux.intel.com>
    6a4500c7
handlers.c 122 KB