From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.5 required=3.0 tests=FAKE_REPLY_C, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D407C43387 for ; Thu, 10 Jan 2019 19:43:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EC28A208E3 for ; Thu, 10 Jan 2019 19:43:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727933AbfAJTnU (ORCPT ); Thu, 10 Jan 2019 14:43:20 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:40828 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727653AbfAJTnU (ORCPT ); Thu, 10 Jan 2019 14:43:20 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x0AJdUko167446; Thu, 10 Jan 2019 19:41:15 GMT Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2ptm0uh9nj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Jan 2019 19:41:14 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x0AJfD7n009153 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Jan 2019 19:41:14 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x0AJfCbx008714; Thu, 10 Jan 2019 19:41:13 GMT Received: from kadam (/41.202.241.51) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 10 Jan 2019 11:41:12 -0800 Date: Thu, 10 Jan 2019 22:41:09 +0300 From: kbuild test robot To: kbuild@01.org, Ville Syrjala Cc: Dan Carpenter , kbuild-all@01.org, intel-gfx@lists.freedesktop.org, Daniel Kamil Kozar , stable@vger.kernel.org Subject: Re: [Intel-gfx] [PATCH] drm/i915: Try to sanitize bogus DPLL state left over by broken SNB BIOSen Message-ID: <20190110194109.GH1718@kadam> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190109120919.21668-1-ville.syrjala@linux.intel.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9132 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901100152 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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