From: Ville Syrjälä Date: Mon, 8 Dec 2025 18:26:24 +0000 (+0200) Subject: drm/i915/vga: Clean up VGA registers even if VGA plane is disabled X-Git-Tag: v7.1-rc1~167^2~24^2~232 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f1640f9d7fa44b19f06aa0e9b2e99bdd8e62863a;p=thirdparty%2Flinux.git drm/i915/vga: Clean up VGA registers even if VGA plane is disabled Turns out at least some systems (eg. HSW Lenovo ThinkCentre E73) configure the VGA registers even when booting in UEFI mode. So in order to avoid any issues with the MSR register we should clean up the VGA registers anyway. For now this mostly avoids the potential for unclaimed register accesses due to the power well vs. MDA/CGA selection. But this will become more important soon as we'll start to rely on the MSR register to control VGA memory decode as well. Signed-off-by: Ville Syrjälä Link: https://patch.msgid.link/20251208182637.334-7-ville.syrjala@linux.intel.com Acked-by: Jani Nikula --- diff --git a/drivers/gpu/drm/i915/display/intel_vga.c b/drivers/gpu/drm/i915/display/intel_vga.c index 744812260ae3e..6a19fb2422480 100644 --- a/drivers/gpu/drm/i915/display/intel_vga.c +++ b/drivers/gpu/drm/i915/display/intel_vga.c @@ -63,7 +63,6 @@ void intel_vga_disable(struct intel_display *display) { struct pci_dev *pdev = to_pci_dev(display->drm->dev); i915_reg_t vga_reg = intel_vga_cntrl_reg(display); - enum pipe pipe; u8 msr, sr1; u32 tmp; @@ -79,18 +78,33 @@ void intel_vga_disable(struct intel_display *display) } tmp = intel_de_read(display, vga_reg); - if (tmp & VGA_DISP_DISABLE) - return; - if (display->platform.cherryview) - pipe = REG_FIELD_GET(VGA_PIPE_SEL_MASK_CHV, tmp); - else if (has_vga_pipe_sel(display)) - pipe = REG_FIELD_GET(VGA_PIPE_SEL_MASK, tmp); - else - pipe = PIPE_A; + if ((tmp & VGA_DISP_DISABLE) == 0) { + enum pipe pipe; + + if (display->platform.cherryview) + pipe = REG_FIELD_GET(VGA_PIPE_SEL_MASK_CHV, tmp); + else if (has_vga_pipe_sel(display)) + pipe = REG_FIELD_GET(VGA_PIPE_SEL_MASK, tmp); + else + pipe = PIPE_A; + + drm_dbg_kms(display->drm, "Disabling VGA plane on pipe %c\n", + pipe_name(pipe)); + } else { + drm_dbg_kms(display->drm, "VGA plane is disabled\n"); - drm_dbg_kms(display->drm, "Disabling VGA plane on pipe %c\n", - pipe_name(pipe)); + /* + * Unfortunately at least some BIOSes (eg. HSW Lenovo + * ThinkCentre E73) set up the VGA registers even when + * in UEFI mode with the VGA plane disabled. So we need to + * always clean up the mess for iGPUs. For discrete GPUs we + * don't really care about the state of the VGA registers + * since all VGA accesses can be blocked via the bridge. + */ + if (display->platform.dgfx) + goto reset_vgacntr; + } /* WaEnableVGAAccessThroughIOPort:ctg,elk,ilk,snb,ivb,vlv,hsw */ vga_get_uninterruptible(pdev, VGA_RSRC_LEGACY_IO);