Re: [PATCH] drm/i915: Try to sanitize bogus DPLL state left over by broken SNB BIOSen

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Ville,

Thank you for the patch! Perhaps something to improve:

url:    https://github.com/0day-ci/linux/commits/Ville-Syrjala/drm-i915-Try-to-sanitize-bogus-DPLL-state-left-over-by-broken-SNB-BIOSen/20190109-222838
base:   git://anongit.freedesktop.org/drm-intel for-linux-next

New smatch warnings:
drivers/gpu/drm/i915/intel_display.c:15452 has_bogus_dpll_config() warn: variable dereferenced before check 'crtc_state' (see line 15439)
drivers/gpu/drm/i915/intel_display.c:15472 intel_sanitize_encoder() error: we previously assumed 'crtc_state' could be null (see line 15469)
drivers/gpu/drm/i915/intel_display.c:15487 intel_sanitize_encoder() warn: variable dereferenced before check 'crtc_state' (see line 15472)

# https://github.com/0day-ci/linux/commit/5a0056f774727561e522ccde5fe7fe78d343d25f
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout 5a0056f774727561e522ccde5fe7fe78d343d25f
vim +/crtc_state +15452 drivers/gpu/drm/i915/intel_display.c

249293524 Daniel Vetter     2012-07-02  15436  
5a0056f77 Ville Syrjälä     2019-01-09  15437  static bool has_bogus_dpll_config(struct intel_crtc_state *crtc_state)
5a0056f77 Ville Syrjälä     2019-01-09  15438  {
5a0056f77 Ville Syrjälä     2019-01-09 @15439  	struct drm_i915_private *dev_priv = to_i915(crtc_state->base.crtc->dev);
5a0056f77 Ville Syrjälä     2019-01-09  15440  
5a0056f77 Ville Syrjälä     2019-01-09  15441  	/*
5a0056f77 Ville Syrjälä     2019-01-09  15442  	 * Some SNB BIOSen (eg. ASUS K53SV) are known to misprogram
5a0056f77 Ville Syrjälä     2019-01-09  15443  	 * the hardware when a high res displays plugged in. DPLL P
5a0056f77 Ville Syrjälä     2019-01-09  15444  	 * divider is zero, and the pipe timings are bonkers. We'll
5a0056f77 Ville Syrjälä     2019-01-09  15445  	 * try to disable everything in that case.
5a0056f77 Ville Syrjälä     2019-01-09  15446  	 *
5a0056f77 Ville Syrjälä     2019-01-09  15447  	 * FIXME would be nice to be able to sanitize this state
5a0056f77 Ville Syrjälä     2019-01-09  15448  	 * without several WARNs, but for now let's take the easy
5a0056f77 Ville Syrjälä     2019-01-09  15449  	 * road.
5a0056f77 Ville Syrjälä     2019-01-09  15450  	 */
5a0056f77 Ville Syrjälä     2019-01-09  15451  	return IS_GEN(dev_priv, 6) &&
5a0056f77 Ville Syrjälä     2019-01-09 @15452  		crtc_state &&
5a0056f77 Ville Syrjälä     2019-01-09  15453  		crtc_state->base.active &&
5a0056f77 Ville Syrjälä     2019-01-09  15454  		crtc_state->shared_dpll &&
5a0056f77 Ville Syrjälä     2019-01-09  15455  		crtc_state->port_clock == 0;
5a0056f77 Ville Syrjälä     2019-01-09  15456  }
5a0056f77 Ville Syrjälä     2019-01-09  15457  
249293524 Daniel Vetter     2012-07-02  15458  static void intel_sanitize_encoder(struct intel_encoder *encoder)
249293524 Daniel Vetter     2012-07-02  15459  {
70332ac53 Imre Deak         2018-11-01  15460  	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
249293524 Daniel Vetter     2012-07-02  15461  	struct intel_connector *connector;
5a0056f77 Ville Syrjälä     2019-01-09  15462  	struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc);
5a0056f77 Ville Syrjälä     2019-01-09  15463  	struct intel_crtc_state *crtc_state = crtc ?
5a0056f77 Ville Syrjälä     2019-01-09  15464  		to_intel_crtc_state(crtc->base.state) : NULL;
249293524 Daniel Vetter     2012-07-02  15465  
249293524 Daniel Vetter     2012-07-02  15466  	/* We need to check both for a crtc link (meaning that the
249293524 Daniel Vetter     2012-07-02  15467  	 * encoder is active and trying to read from a pipe) and the
249293524 Daniel Vetter     2012-07-02  15468  	 * pipe itself being active. */
5a0056f77 Ville Syrjälä     2019-01-09 @15469  	bool has_active_crtc = crtc_state &&
5a0056f77 Ville Syrjälä     2019-01-09  15470  		crtc_state->base.active;
5a0056f77 Ville Syrjälä     2019-01-09  15471  
5a0056f77 Ville Syrjälä     2019-01-09 @15472  	if (has_bogus_dpll_config(crtc_state)) {
5a0056f77 Ville Syrjälä     2019-01-09  15473  		DRM_DEBUG_KMS("BIOS has misprogrammed the hardware. Disabling pipe %c\n",
5a0056f77 Ville Syrjälä     2019-01-09  15474  			      pipe_name(crtc->pipe));
5a0056f77 Ville Syrjälä     2019-01-09  15475  		has_active_crtc = false;
5a0056f77 Ville Syrjälä     2019-01-09  15476  	}
249293524 Daniel Vetter     2012-07-02  15477  
496b0fc37 Maarten Lankhorst 2016-08-23  15478  	connector = intel_encoder_find_connector(encoder);
496b0fc37 Maarten Lankhorst 2016-08-23  15479  	if (connector && !has_active_crtc) {
249293524 Daniel Vetter     2012-07-02  15480  		DRM_DEBUG_KMS("[ENCODER:%d:%s] has active connectors but no active pipe!\n",
249293524 Daniel Vetter     2012-07-02  15481  			      encoder->base.base.id,
8e329a039 Jani Nikula       2014-06-03  15482  			      encoder->base.name);
249293524 Daniel Vetter     2012-07-02  15483  
249293524 Daniel Vetter     2012-07-02  15484  		/* Connector is active, but has no active pipe. This is
249293524 Daniel Vetter     2012-07-02  15485  		 * fallout from our resume register restoring. Disable
249293524 Daniel Vetter     2012-07-02  15486  		 * the encoder manually again. */
5a0056f77 Ville Syrjälä     2019-01-09 @15487  		if (crtc_state) {
5a0056f77 Ville Syrjälä     2019-01-09  15488  			struct drm_encoder *best_encoder;
fd6bbda9c Maarten Lankhorst 2016-08-09  15489  
249293524 Daniel Vetter     2012-07-02  15490  			DRM_DEBUG_KMS("[ENCODER:%d:%s] manually disabled\n",
249293524 Daniel Vetter     2012-07-02  15491  				      encoder->base.base.id,
8e329a039 Jani Nikula       2014-06-03  15492  				      encoder->base.name);
5a0056f77 Ville Syrjälä     2019-01-09  15493  
5a0056f77 Ville Syrjälä     2019-01-09  15494  			/* avoid oopsing in case the hooks consult best_encoder */
5a0056f77 Ville Syrjälä     2019-01-09  15495  			best_encoder = connector->base.state->best_encoder;
5a0056f77 Ville Syrjälä     2019-01-09  15496  			connector->base.state->best_encoder = &encoder->base;
5a0056f77 Ville Syrjälä     2019-01-09  15497  
c84c6fe30 Jani Nikula       2018-10-16  15498  			if (encoder->disable)
5a0056f77 Ville Syrjälä     2019-01-09  15499  				encoder->disable(encoder, crtc_state,
5a0056f77 Ville Syrjälä     2019-01-09  15500  						 connector->base.state);
a62d14975 Ville Syrjälä     2014-06-28  15501  			if (encoder->post_disable)
5a0056f77 Ville Syrjälä     2019-01-09  15502  				encoder->post_disable(encoder, crtc_state,
5a0056f77 Ville Syrjälä     2019-01-09  15503  						      connector->base.state);
5a0056f77 Ville Syrjälä     2019-01-09  15504  
5a0056f77 Ville Syrjälä     2019-01-09  15505  			connector->base.state->best_encoder = best_encoder;
249293524 Daniel Vetter     2012-07-02  15506  		}
7f1950fbb Egbert Eich       2014-04-25  15507  		encoder->base.crtc = NULL;
249293524 Daniel Vetter     2012-07-02  15508  
249293524 Daniel Vetter     2012-07-02  15509  		/* Inconsistent output/port/pipe state happens presumably due to
249293524 Daniel Vetter     2012-07-02  15510  		 * a bug in one of the get_hw_state functions. Or someplace else
249293524 Daniel Vetter     2012-07-02  15511  		 * in our code, like the register restore mess on resume. Clamp
249293524 Daniel Vetter     2012-07-02  15512  		 * things to off as a safer default. */
fd6bbda9c Maarten Lankhorst 2016-08-09  15513  
7f1950fbb Egbert Eich       2014-04-25  15514  		connector->base.dpms = DRM_MODE_DPMS_OFF;
7f1950fbb Egbert Eich       2014-04-25  15515  		connector->base.encoder = NULL;
249293524 Daniel Vetter     2012-07-02  15516  	}
d6cae4aa3 Maarten Lankhorst 2018-05-16  15517  
d6cae4aa3 Maarten Lankhorst 2018-05-16  15518  	/* notify opregion of the sanitized encoder state */
d6cae4aa3 Maarten Lankhorst 2018-05-16  15519  	intel_opregion_notify_encoder(encoder, connector && has_active_crtc);
70332ac53 Imre Deak         2018-11-01  15520  
70332ac53 Imre Deak         2018-11-01  15521  	if (INTEL_GEN(dev_priv) >= 11)
70332ac53 Imre Deak         2018-11-01  15522  		icl_sanitize_encoder_pll_mapping(encoder);
249293524 Daniel Vetter     2012-07-02  15523  }
249293524 Daniel Vetter     2012-07-02  15524  

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux