From patchwork Wed Dec 4 15:07:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 13893935 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B3874E7716B for ; Wed, 4 Dec 2024 15:07:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 61D3310E2AA; Wed, 4 Dec 2024 15:07:33 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="Q4zv808H"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 87E9D10E2AA; Wed, 4 Dec 2024 15:07:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1733324853; x=1764860853; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZwnFnKLC40CwGv7FvZELQ4hQUn0L1NTlHO1yXTxU3aA=; b=Q4zv808HIazkiD391qjRHZGwsD9sLjg5/RMPsbfjQTCIPssdr32mLOv8 /ChieKWEmRdkJbndf9RcrJU7ZTRCEa82qbgbh1TP0resO0NOxQxA33agI Y1B3q6zn1mN42lP9iSwxFItJ5JgfqV1Ycxm85My3QTMT6kxP24tydpLdd aQ9goPcKcj1O64K9bPupLlRTBQG+xtSjnINBl4GiVbT8NH/y3tJq/rzmX lbFbjpUmr3ORHbWdSVFzEzrwKTIcWqEMILcRe5XGR5TdddpQ3Z7cjwmEQ 89JpZVZTYheEjOOTA9I824GR4JbFRkmHVoVytigx/gwMhVUAvet9H/ytY A==; X-CSE-ConnectionGUID: IXT1ofx6SOqGO+qPm6rrLg== X-CSE-MsgGUID: XtraP6AFS72lSsaMV79T6g== X-IronPort-AV: E=McAfee;i="6700,10204,11276"; a="33745678" X-IronPort-AV: E=Sophos;i="6.12,207,1728975600"; d="scan'208";a="33745678" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2024 07:07:33 -0800 X-CSE-ConnectionGUID: TPz+ojAGRVuZOHHFLZC0YA== X-CSE-MsgGUID: 0EQzEeDZReO7OBpb4Wnssw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,207,1728975600"; d="scan'208";a="117038231" Received: from mwiniars-desk2.ger.corp.intel.com (HELO localhost) ([10.245.246.205]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2024 07:07:30 -0800 From: Jani Nikula To: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org Cc: jani.nikula@intel.com, Sergey Senozhatsky , Ville Syrjala Subject: [PATCH v2 1/5] drm/i915/hdmi: propagate errors from intel_hdmi_init_connector() Date: Wed, 4 Dec 2024 17:07:17 +0200 Message-Id: <11370b6714b0c0f29b2e91451d74a51460f3e1f8.1733324735.git.jani.nikula@intel.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Propagate errors from intel_hdmi_init_connector() to be able to handle them at callers. This is similar to intel_dp_init_connector(). Cc: Sergey Senozhatsky Cc: Ville Syrjala Reported-and-tested-by: Sergey Senozhatsky Closes: https://lore.kernel.org/r/20241031105145.2140590-1-senozhatsky@chromium.org Reviewed-by: Sergey Senozhatsky Signed-off-by: Jani Nikula --- drivers/gpu/drm/i915/display/intel_hdmi.c | 10 ++++++---- drivers/gpu/drm/i915/display/intel_hdmi.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c index 63e56c9ff516..b0a22b6046b1 100644 --- a/drivers/gpu/drm/i915/display/intel_hdmi.c +++ b/drivers/gpu/drm/i915/display/intel_hdmi.c @@ -3040,7 +3040,7 @@ void intel_infoframe_init(struct intel_digital_port *dig_port) } } -void intel_hdmi_init_connector(struct intel_digital_port *dig_port, +bool intel_hdmi_init_connector(struct intel_digital_port *dig_port, struct intel_connector *intel_connector) { struct intel_display *display = to_intel_display(dig_port); @@ -3057,17 +3057,17 @@ void intel_hdmi_init_connector(struct intel_digital_port *dig_port, intel_encoder->base.base.id, intel_encoder->base.name); if (DISPLAY_VER(display) < 12 && drm_WARN_ON(dev, port == PORT_A)) - return; + return false; if (drm_WARN(dev, dig_port->max_lanes < 4, "Not enough lanes (%d) for HDMI on [ENCODER:%d:%s]\n", dig_port->max_lanes, intel_encoder->base.base.id, intel_encoder->base.name)) - return; + return false; ddc_pin = intel_hdmi_ddc_pin(intel_encoder); if (!ddc_pin) - return; + return false; drm_connector_init_with_ddc(dev, connector, &intel_hdmi_connector_funcs, @@ -3112,6 +3112,8 @@ void intel_hdmi_init_connector(struct intel_digital_port *dig_port, &conn_info); if (!intel_hdmi->cec_notifier) drm_dbg_kms(display->drm, "CEC notifier get failed\n"); + + return true; } /* diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.h b/drivers/gpu/drm/i915/display/intel_hdmi.h index 466f48df8a74..38deaeb302a2 100644 --- a/drivers/gpu/drm/i915/display/intel_hdmi.h +++ b/drivers/gpu/drm/i915/display/intel_hdmi.h @@ -22,7 +22,7 @@ struct intel_encoder; struct intel_hdmi; union hdmi_infoframe; -void intel_hdmi_init_connector(struct intel_digital_port *dig_port, +bool intel_hdmi_init_connector(struct intel_digital_port *dig_port, struct intel_connector *intel_connector); bool intel_hdmi_compute_has_hdmi_sink(struct intel_encoder *encoder, const struct intel_crtc_state *crtc_state, From patchwork Wed Dec 4 15:07:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 13893936 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 18EE3E7716B for ; Wed, 4 Dec 2024 15:07:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B2F9B10E2AB; Wed, 4 Dec 2024 15:07:38 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="RkQAeEJe"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6DA1110E2AB; Wed, 4 Dec 2024 15:07:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1733324858; x=1764860858; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bSfokEruiqL+ai8fKHqUlL51zAVT6x4ykZcgxIcfVF8=; b=RkQAeEJenr+zIg8ZRTQua+zcAj9iQ/YpJMFr1rynvDZpMH5NIXLM/EWW fJ88kY74iA9ymiLnlIuO10eAN/BWqFs64AsLqeGalrAR0Aq9GGhzU7Bsb KCirnATGlROWsy1nAbg8xadswW2aDeiDceCD7YDcj0ONiuTyMyU5Kfvjt smoIiAfK1xpJXWAHT85OiSBtsjgXIH+K3/DeeyZVUNfdGTAwQVXLDgDPi 3bxIeYdM98A+FsE3KEUAhAcAo98TKdr0EVuwWLLBGb2doPM2YvjGKNLvc bVZ07AjlVh8qUwe7ax9qdFBU6vW5ac7EfzOqPYFheRTQWQLlVtigvSPer w==; X-CSE-ConnectionGUID: VWAyL2KTRbeJSbTeCi4buQ== X-CSE-MsgGUID: /Kzxip4kT22Lk6q7bABrgA== X-IronPort-AV: E=McAfee;i="6700,10204,11276"; a="33745688" X-IronPort-AV: E=Sophos;i="6.12,207,1728975600"; d="scan'208";a="33745688" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2024 07:07:38 -0800 X-CSE-ConnectionGUID: zP3IBLIxQfaDDwlUVS2t5A== X-CSE-MsgGUID: wMtMCvx6QXu7lf1RPM4h6Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,207,1728975600"; d="scan'208";a="117038242" Received: from mwiniars-desk2.ger.corp.intel.com (HELO localhost) ([10.245.246.205]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2024 07:07:35 -0800 From: Jani Nikula To: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org Cc: jani.nikula@intel.com, Sergey Senozhatsky , Ville Syrjala Subject: [PATCH v2 2/5] drm/i915/hdmi: add error handling in g4x_hdmi_init() Date: Wed, 4 Dec 2024 17:07:18 +0200 Message-Id: <6ea48b8ccf0a13d3306dcd21616dd866f0672683.1733324735.git.jani.nikula@intel.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Handle encoder and connector init failures in g4x_hdmi_init(). This is similar to g4x_dp_init(). Cc: Sergey Senozhatsky Cc: Ville Syrjala Reported-and-tested-by: Sergey Senozhatsky Closes: https://lore.kernel.org/r/20241031105145.2140590-1-senozhatsky@chromium.org Reviewed-by: Sergey Senozhatsky Signed-off-by: Jani Nikula --- drivers/gpu/drm/i915/display/g4x_hdmi.c | 35 ++++++++++++++++--------- drivers/gpu/drm/i915/display/g4x_hdmi.h | 5 ++-- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/i915/display/g4x_hdmi.c b/drivers/gpu/drm/i915/display/g4x_hdmi.c index d1a7d0d57c6b..bc6362a68fcc 100644 --- a/drivers/gpu/drm/i915/display/g4x_hdmi.c +++ b/drivers/gpu/drm/i915/display/g4x_hdmi.c @@ -682,7 +682,7 @@ static bool assert_hdmi_port_valid(struct drm_i915_private *i915, enum port port "Platform does not support HDMI %c\n", port_name(port)); } -void g4x_hdmi_init(struct drm_i915_private *dev_priv, +bool g4x_hdmi_init(struct drm_i915_private *dev_priv, i915_reg_t hdmi_reg, enum port port) { struct intel_display *display = &dev_priv->display; @@ -692,10 +692,10 @@ void g4x_hdmi_init(struct drm_i915_private *dev_priv, struct intel_connector *intel_connector; if (!assert_port_valid(dev_priv, port)) - return; + return false; if (!assert_hdmi_port_valid(dev_priv, port)) - return; + return false; devdata = intel_bios_encoder_data_lookup(display, port); @@ -706,15 +706,13 @@ void g4x_hdmi_init(struct drm_i915_private *dev_priv, dig_port = kzalloc(sizeof(*dig_port), GFP_KERNEL); if (!dig_port) - return; + return false; dig_port->aux_ch = AUX_CH_NONE; intel_connector = intel_connector_alloc(); - if (!intel_connector) { - kfree(dig_port); - return; - } + if (!intel_connector) + goto err_connector_alloc; intel_encoder = &dig_port->base; @@ -722,9 +720,10 @@ void g4x_hdmi_init(struct drm_i915_private *dev_priv, mutex_init(&dig_port->hdcp_mutex); - drm_encoder_init(&dev_priv->drm, &intel_encoder->base, - &intel_hdmi_enc_funcs, DRM_MODE_ENCODER_TMDS, - "HDMI %c", port_name(port)); + if (drm_encoder_init(&dev_priv->drm, &intel_encoder->base, + &intel_hdmi_enc_funcs, DRM_MODE_ENCODER_TMDS, + "HDMI %c", port_name(port))) + goto err_encoder_init; intel_encoder->hotplug = intel_hdmi_hotplug; intel_encoder->compute_config = g4x_hdmi_compute_config; @@ -787,5 +786,17 @@ void g4x_hdmi_init(struct drm_i915_private *dev_priv, intel_infoframe_init(dig_port); - intel_hdmi_init_connector(dig_port, intel_connector); + if (!intel_hdmi_init_connector(dig_port, intel_connector)) + goto err_init_connector; + + return true; + +err_init_connector: + drm_encoder_cleanup(&intel_encoder->base); +err_encoder_init: + kfree(intel_connector); +err_connector_alloc: + kfree(dig_port); + + return false; } diff --git a/drivers/gpu/drm/i915/display/g4x_hdmi.h b/drivers/gpu/drm/i915/display/g4x_hdmi.h index 817f55c7a3a1..a52e8986ec7a 100644 --- a/drivers/gpu/drm/i915/display/g4x_hdmi.h +++ b/drivers/gpu/drm/i915/display/g4x_hdmi.h @@ -16,14 +16,15 @@ struct drm_connector; struct drm_i915_private; #ifdef I915 -void g4x_hdmi_init(struct drm_i915_private *dev_priv, +bool g4x_hdmi_init(struct drm_i915_private *dev_priv, i915_reg_t hdmi_reg, enum port port); int g4x_hdmi_connector_atomic_check(struct drm_connector *connector, struct drm_atomic_state *state); #else -static inline void g4x_hdmi_init(struct drm_i915_private *dev_priv, +static inline bool g4x_hdmi_init(struct drm_i915_private *dev_priv, i915_reg_t hdmi_reg, int port) { + return false; } static inline int g4x_hdmi_connector_atomic_check(struct drm_connector *connector, struct drm_atomic_state *state) From patchwork Wed Dec 4 15:07:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 13893937 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DC8F4E7716B for ; Wed, 4 Dec 2024 15:07:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8B6AF10E4BB; Wed, 4 Dec 2024 15:07:43 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="Yts2A8vc"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id B252510E296; Wed, 4 Dec 2024 15:07:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1733324863; x=1764860863; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mTkoejX5FalHwIEntNF2nt45uUjZSD53owJRWwuDWBg=; b=Yts2A8vc18iYcAdt48f7ZgYFsZh5kZ3dIU3rsf0V/A6WLqNIUwcLy2cO HIdc+OaYkvrzmbymkDoCzUhvGATiMMBT5rwWvDYZ79NbKQS12SbK9nfYd faMuJtPtF7gySCrDdCtAOUCJ0ZJaCw1goh2ks3L8fIrRxGQLrN+ZvJlJ1 IjQ46bJ3SXs2rP2hYBlAWdQXD2bxWA01SUacAH8/KXLIEPVmIJEQwcsqT EYXvUipz3FeNkoksQtPCcY4araK4oofdBRszm0kjM+gkdK+BC705Lxgpd w4OdLTeV4/53cvvD1TbxVad/TjKpEIBXaAp/nOdzISvAvbDaFx/Pa2C8Q A==; X-CSE-ConnectionGUID: FEKKW40rSfi4G+FCCSjYCg== X-CSE-MsgGUID: sbL7i7NoSeeK7/Ruhwt7jA== X-IronPort-AV: E=McAfee;i="6700,10204,11276"; a="33745699" X-IronPort-AV: E=Sophos;i="6.12,207,1728975600"; d="scan'208";a="33745699" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2024 07:07:43 -0800 X-CSE-ConnectionGUID: pMYUPbcWQ8G2AXp4KfqfoA== X-CSE-MsgGUID: AspLhDt1QJ6dDwBrJs4y0w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,207,1728975600"; d="scan'208";a="117038261" Received: from mwiniars-desk2.ger.corp.intel.com (HELO localhost) ([10.245.246.205]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2024 07:07:40 -0800 From: Jani Nikula To: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org Cc: jani.nikula@intel.com, Sergey Senozhatsky , Ville Syrjala Subject: [PATCH v2 3/5] drm/i915/ddi: propagate errors from intel_ddi_init_hdmi_connector() Date: Wed, 4 Dec 2024 17:07:19 +0200 Message-Id: X-Mailer: git-send-email 2.39.5 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Propagate connector init errors from intel_ddi_init_hdmi_connector(). The caller already handles the allocation failures, and this is all similar to intel_ddi_init_dp_connector(). Cc: Sergey Senozhatsky Cc: Ville Syrjala Reported-and-tested-by: Sergey Senozhatsky Closes: https://lore.kernel.org/r/20241031105145.2140590-1-senozhatsky@chromium.org Reviewed-by: Sergey Senozhatsky Signed-off-by: Jani Nikula --- drivers/gpu/drm/i915/display/intel_ddi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c b/drivers/gpu/drm/i915/display/intel_ddi.c index 4f9c50996446..67bbfba58b54 100644 --- a/drivers/gpu/drm/i915/display/intel_ddi.c +++ b/drivers/gpu/drm/i915/display/intel_ddi.c @@ -4759,7 +4759,11 @@ intel_ddi_init_hdmi_connector(struct intel_digital_port *dig_port) return NULL; dig_port->hdmi.hdmi_reg = DDI_BUF_CTL(port); - intel_hdmi_init_connector(dig_port, connector); + + if (!intel_hdmi_init_connector(dig_port, connector)) { + kfree(connector); + return NULL; + } return connector; } From patchwork Wed Dec 4 15:07:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 13893938 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 29B60E7716B for ; Wed, 4 Dec 2024 15:07:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D014810E2AD; Wed, 4 Dec 2024 15:07:48 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="Ph52gUE5"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 86B1210E1AF; Wed, 4 Dec 2024 15:07:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1733324868; x=1764860868; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lwbRLL/fjrUy9Lhps+Cchzjcz8tCLrh7jJ9xqaT5Zk0=; b=Ph52gUE5kT4yt5m3A0JboBV84l73+WtnkNbpyUzOj1aqLBCAfy5j9jg1 AOX1zomSFDZNKkr7OY9f4rGyZKHIX4ATSHy3+7sMrT+Vv7eZPu811WZkY 6z8FpsEJkE55AYEbBRHhJkxAMZWGCIWJsEimeDjOZvd02Q/16ePiLeJdX pp3B8RoB9IlBO3bnXZTtVRB/kdzGubp26x+HYBYaA374s6fuiK91Lvx7k yqyBPxU87UfFZB6neTSw3Xu2gjmNFXvPAvr3oIe/NKMwdwASk3bLn0Ydr z8JM+h8H/XPH5px2edaBVdl/kT2Aoh7j54YOkyf2fxgb06an96UfEVL49 w==; X-CSE-ConnectionGUID: WrkI73dgS62XMXOzhK2MzA== X-CSE-MsgGUID: oWAqUCK5So2yW6ZYfVcZjQ== X-IronPort-AV: E=McAfee;i="6700,10204,11276"; a="33745719" X-IronPort-AV: E=Sophos;i="6.12,207,1728975600"; d="scan'208";a="33745719" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2024 07:07:48 -0800 X-CSE-ConnectionGUID: tHLoE31ZSval+d1zchqvHA== X-CSE-MsgGUID: +tG4sFOdTpKJtaD7WenkRw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,207,1728975600"; d="scan'208";a="117038274" Received: from mwiniars-desk2.ger.corp.intel.com (HELO localhost) ([10.245.246.205]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2024 07:07:45 -0800 From: Jani Nikula To: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org Cc: jani.nikula@intel.com, Sergey Senozhatsky , Ville Syrjala Subject: [PATCH v2 4/5] drm/i915/display: add intel_encoder_is_hdmi() Date: Wed, 4 Dec 2024 17:07:20 +0200 Message-Id: <4292505b249268d824834d545b73aa0ad2d33984.1733324735.git.jani.nikula@intel.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Similar to intel_encoder_is_dp() and friends. Cc: Sergey Senozhatsky Cc: Ville Syrjala Signed-off-by: Jani Nikula Reviewed-by: Suraj Kandpal --- drivers/gpu/drm/i915/display/intel_display_types.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h index 167aa8ec4948..0ae026a850c2 100644 --- a/drivers/gpu/drm/i915/display/intel_display_types.h +++ b/drivers/gpu/drm/i915/display/intel_display_types.h @@ -1959,6 +1959,19 @@ static inline bool intel_encoder_is_dp(struct intel_encoder *encoder) } } +static inline bool intel_encoder_is_hdmi(struct intel_encoder *encoder) +{ + switch (encoder->type) { + case INTEL_OUTPUT_HDMI: + return true; + case INTEL_OUTPUT_DDI: + /* See if the HDMI encoder is valid. */ + return i915_mmio_reg_valid(enc_to_intel_hdmi(encoder)->hdmi_reg); + default: + return false; + } +} + static inline struct intel_lspcon * enc_to_intel_lspcon(struct intel_encoder *encoder) { From patchwork Wed Dec 4 15:07:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 13893939 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 18820E7716B for ; Wed, 4 Dec 2024 15:07:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8B58410E4C2; Wed, 4 Dec 2024 15:07:53 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="WbdXPFrW"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 45F1C10E34A; Wed, 4 Dec 2024 15:07:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1733324873; x=1764860873; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mo0Z/33dVNqkKJF41fJByWt0P9z8QarHVe/LsRfKJFM=; b=WbdXPFrWfwQ6nl6EzA3B0+PHty7yHZDk79t3OH/WlDGoy7aYdqP5gETt DF1zpufQ/iC2Xt1Wgvn9nD6hMXDYDecDNL1aAqoD7WXvJhbZ4/ohVPp2p TMO+oNMJGiOcu6k0zkioo+LBbiqfQEjak6iitgkG6korhSU/zZUclyLyn Hq40EK8oi9jq9kViWFeKpIGMR4AJXduKJ1G6pvQ/SKyhLs6iQqJK+RANW 5d0Sryg7+7ICj9pJoF12gsYpPooe46OIHGMyyDLKcOeAWg7UpkgkNa+/8 ZHBpYABOlB5Kx336XjuxeVzMgNZrhDNtxWW/M3vTuQljayOKkwkTFG+R1 w==; X-CSE-ConnectionGUID: YJmBYEeLS/SoP7UN6/Iitg== X-CSE-MsgGUID: lLdUS6APTN6Xx+is5zj9PA== X-IronPort-AV: E=McAfee;i="6700,10204,11276"; a="33745731" X-IronPort-AV: E=Sophos;i="6.12,207,1728975600"; d="scan'208";a="33745731" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2024 07:07:53 -0800 X-CSE-ConnectionGUID: 4t5FVLYuSx6zg20sp/yeCw== X-CSE-MsgGUID: mJUhj3v4QGiDhZMKUtAESg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,207,1728975600"; d="scan'208";a="117038284" Received: from mwiniars-desk2.ger.corp.intel.com (HELO localhost) ([10.245.246.205]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2024 07:07:50 -0800 From: Jani Nikula To: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org Cc: jani.nikula@intel.com, Sergey Senozhatsky , Ville Syrjala Subject: [PATCH v2 5/5] drm/i915/ddi: only call shutdown hooks for valid encoders Date: Wed, 4 Dec 2024 17:07:21 +0200 Message-Id: X-Mailer: git-send-email 2.39.5 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" DDI might be HDMI or DP only, leaving the other encoder uninitialized. Calling the shutdown hook on an uninitialized encoder may lead to a NULL pointer dereference. Check the encoder types (and thus validity via the DP output_reg or HDMI hdmi_reg checks) before calling the hooks. Reported-by: Sergey Senozhatsky Closes: https://lore.kernel.org/r/20241031105145.2140590-1-senozhatsky@chromium.org Cc: Sergey Senozhatsky Cc: Ville Syrjala Signed-off-by: Jani Nikula Reviewed-by: Suraj Kandpal --- TODO: We should probably audit all DDI encoder hooks for this, and add the necessary checks. --- drivers/gpu/drm/i915/display/intel_ddi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c b/drivers/gpu/drm/i915/display/intel_ddi.c index 67bbfba58b54..f3e27c67c419 100644 --- a/drivers/gpu/drm/i915/display/intel_ddi.c +++ b/drivers/gpu/drm/i915/display/intel_ddi.c @@ -4920,8 +4920,10 @@ static void intel_ddi_tc_encoder_suspend_complete(struct intel_encoder *encoder) static void intel_ddi_encoder_shutdown(struct intel_encoder *encoder) { - intel_dp_encoder_shutdown(encoder); - intel_hdmi_encoder_shutdown(encoder); + if (intel_encoder_is_dp(encoder)) + intel_dp_encoder_shutdown(encoder); + if (intel_encoder_is_hdmi(encoder)) + intel_hdmi_encoder_shutdown(encoder); } static void intel_ddi_tc_encoder_shutdown_complete(struct intel_encoder *encoder)