From patchwork Thu May 14 17:35:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Timo Aaltonen X-Patchwork-Id: 1290563 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ubuntu.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49NJcb3zs4z9sVC; Fri, 15 May 2020 03:36:31 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1jZHmV-0006wR-Jc; Thu, 14 May 2020 17:36:27 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jZHmD-0006oF-Ks for kernel-team@lists.ubuntu.com; Thu, 14 May 2020 17:36:09 +0000 Received: from [192.194.81.50] (helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jZHmD-0008LS-AY for kernel-team@lists.ubuntu.com; Thu, 14 May 2020 17:36:09 +0000 From: Timo Aaltonen To: kernel-team@lists.ubuntu.com Subject: [PATCH 09/25] drm/i915: Introduce intel_connector_hpd_pin() Date: Thu, 14 May 2020 20:35:48 +0300 Message-Id: <20200514173604.37922-10-tjaalton@ubuntu.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200514173604.37922-1-tjaalton@ubuntu.com> References: <20200514173604.37922-1-tjaalton@ubuntu.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Ville Syrjälä BugLink: https://bugs.launchpad.net/bugs/1855399 Simplify the hotplug code connector->encoder->hpd_pin handling by introducing a helper for exactly this purpose. In the helper we can neatly deal with the potential lack of an attached encoder on fresh MST connectors leaving the rest of the hpd code oblivious to such details. Cc: Lyude Paul Signed-off-by: Ville Syrjälä Link: https://patchwork.freedesktop.org/patch/msgid/20200121171100.4370-3-ville.syrjala@linux.intel.com Reviewed-by: Jani Nikula (cherry picked from commit 012ee690372ccc370d4c13cb137dd2e17e2cfc6b) Signed-off-by: Timo Aaltonen --- drivers/gpu/drm/i915/display/intel_hotplug.c | 50 +++++++++++--------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_hotplug.c b/drivers/gpu/drm/i915/display/intel_hotplug.c index 042d98bae1ea..8a3e9e901cf7 100644 --- a/drivers/gpu/drm/i915/display/intel_hotplug.c +++ b/drivers/gpu/drm/i915/display/intel_hotplug.c @@ -120,6 +120,20 @@ enum hpd_pin intel_hpd_pin_default(struct drm_i915_private *dev_priv, #define HPD_STORM_REENABLE_DELAY (2 * 60 * 1000) #define HPD_RETRY_DELAY 1000 +static enum hpd_pin +intel_connector_hpd_pin(struct intel_connector *connector) +{ + struct intel_encoder *encoder = intel_attached_encoder(connector); + + /* + * MST connectors get their encoder attached dynamically + * so need to make sure we have an encoder here. But since + * MST encoders have their hpd_pin set to HPD_NONE we don't + * have to special case them beyond that. + */ + return encoder ? encoder->hpd_pin : HPD_NONE; +} + /** * intel_hpd_irq_storm_detect - gather stats and detect HPD IRQ storm on a pin * @dev_priv: private driver data pointer @@ -193,17 +207,12 @@ intel_hpd_irq_storm_switch_to_polling(struct drm_i915_private *dev_priv) drm_connector_list_iter_begin(dev, &conn_iter); for_each_intel_connector_iter(connector, &conn_iter) { - struct intel_encoder *encoder; enum hpd_pin pin; if (connector->base.polled != DRM_CONNECTOR_POLL_HPD) continue; - encoder = intel_attached_encoder(connector); - if (!encoder) - continue; - - pin = encoder->hpd_pin; + pin = intel_connector_hpd_pin(connector); if (pin == HPD_NONE || dev_priv->hotplug.stats[pin].state != HPD_MARK_DISABLED) continue; @@ -250,9 +259,7 @@ static void intel_hpd_irq_storm_reenable_work(struct work_struct *work) drm_connector_list_iter_begin(dev, &conn_iter); for_each_intel_connector_iter(connector, &conn_iter) { - /* Don't check MST ports, they don't have pins */ - if (!connector->mst_port && - intel_attached_encoder(connector)->hpd_pin == pin) { + if (intel_connector_hpd_pin(connector) == pin) { if (connector->base.polled != connector->polled) DRM_DEBUG_DRIVER("Reenabling HPD on connector %s\n", connector->base.name); @@ -381,17 +388,20 @@ static void i915_hotplug_work_func(struct work_struct *work) drm_connector_list_iter_begin(dev, &conn_iter); for_each_intel_connector_iter(connector, &conn_iter) { - struct intel_encoder *encoder = - intel_attached_encoder(connector); + enum hpd_pin pin; u32 hpd_bit; - if (!encoder) + pin = intel_connector_hpd_pin(connector); + if (pin == HPD_NONE) continue; - hpd_bit = BIT(encoder->hpd_pin); + hpd_bit = BIT(pin); if ((hpd_event_bits | hpd_retry_bits) & hpd_bit) { + struct intel_encoder *encoder = + intel_attached_encoder(connector); + DRM_DEBUG_KMS("Connector %s (pin %i) received hotplug event.\n", - connector->base.name, encoder->hpd_pin); + connector->base.name, pin); switch (encoder->hotplug(encoder, connector, hpd_event_bits & hpd_bit)) { @@ -606,20 +616,16 @@ static void i915_hpd_poll_init_work(struct work_struct *work) drm_connector_list_iter_begin(dev, &conn_iter); for_each_intel_connector_iter(connector, &conn_iter) { - connector->base.polled = connector->polled; + enum hpd_pin pin = intel_connector_hpd_pin(connector); - /* MST has a dynamic intel_connector->encoder and it's reprobing - * is all handled by the MST helpers. */ - if (connector->mst_port) - continue; + connector->base.polled = connector->polled; - if (!connector->base.polled && I915_HAS_HOTPLUG(dev_priv) && - intel_attached_encoder(connector)->hpd_pin > HPD_NONE) { + if (pin != HPD_NONE && I915_HAS_HOTPLUG(dev_priv) && + !connector->base.polled) connector->base.polled = enabled ? DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT : DRM_CONNECTOR_POLL_HPD; - } } drm_connector_list_iter_end(&conn_iter);