From patchwork Wed Jul 13 15:20:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 12916896 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 C3E01C43334 for ; Wed, 13 Jul 2022 15:24:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E2C8C9B62D; Wed, 13 Jul 2022 15:24:30 +0000 (UTC) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8E7169AF6E; Wed, 13 Jul 2022 15:24:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1657725869; x=1689261869; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=D/9/bGwpRZX+TbljK/z2FDJVH1oT8QngM4eyQMITS9Q=; b=hxUSG3ZI6OBiAX4sbAmZ7WdnyR4z1n2MqU7cRxutOkq44JaevZVXLYHu 6Ta66AuZO8Wl6kxZMwBBjc6DeEr2dq+2xH+T4G1Lu2V3vunwohsjZ2Kcg 0a5Yh6jtthhVHq1ER0CAjxDsKOP4lqsAoi8do79Gc7TNS5pxq+cS23rH0 wpV7tYSI8FuySiqoOWE9ZurcTVkgzSW8ONDDXaEoval0pdOlrmym28kB9 dd60qZaghI0R7m9OY6RPVJdNE6QWuIux2t+sPjo7qYu/VtQvjYPOiIxUM Vw2HpyltiVpLrXilHlZj9gG+r2//dAH605tb7Dj2Tyqo1uh70swDbwIY/ Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10407"; a="310881089" X-IronPort-AV: E=Sophos;i="5.92,267,1650956400"; d="scan'208";a="310881089" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jul 2022 08:20:38 -0700 X-IronPort-AV: E=Sophos;i="5.92,267,1650956400"; d="scan'208";a="922669133" Received: from lab-ah.igk.intel.com ([10.91.215.196]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jul 2022 08:20:35 -0700 From: Andrzej Hajda To: Jani Nikula , =?utf-8?b?VmlsbGUgU3lyasOk?= =?utf-8?b?bMOk?= , Arun R Murthy Date: Wed, 13 Jul 2022 17:20:19 +0200 Message-Id: <20220713152019.343432-4-andrzej.hajda@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220713152019.343432-1-andrzej.hajda@intel.com> References: <20220713152019.343432-1-andrzej.hajda@intel.com> MIME-Version: 1.0 Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316 Subject: [Intel-gfx] [PATCH v3 3/3] drm/i915/display: add hotplug.suspended flag 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: , Cc: Andrzej Hajda , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Rodrigo Vivi Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" HPD events during driver removal can be generated by hardware and software frameworks - drm_dp_mst, the former we can avoid by disabling interrupts, the latter can be triggered by any drm_dp_mst transaction, and this is too late. Introducing suspended flag allows to solve this chicken-egg problem. Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/5950 Signed-off-by: Andrzej Hajda Reviewed-by: Arun R Murthy --- drivers/gpu/drm/i915/display/intel_display.c | 2 +- drivers/gpu/drm/i915/display/intel_hotplug.c | 13 ++++++++++++- drivers/gpu/drm/i915/display/intel_hotplug.h | 2 +- drivers/gpu/drm/i915/i915_driver.c | 4 ++-- drivers/gpu/drm/i915/i915_drv.h | 2 ++ 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c index ec8e59b3adaea7..b969635b212ba9 100644 --- a/drivers/gpu/drm/i915/display/intel_display.c +++ b/drivers/gpu/drm/i915/display/intel_display.c @@ -9008,7 +9008,7 @@ void intel_modeset_driver_remove_noirq(struct drm_i915_private *i915) intel_dp_mst_suspend(i915); /* MST is the last user of HPD work */ - intel_hpd_cancel_work(i915); + intel_hpd_suspend(i915); /* poll work can call into fbdev, hence clean that up afterwards */ intel_fbdev_fini(i915); diff --git a/drivers/gpu/drm/i915/display/intel_hotplug.c b/drivers/gpu/drm/i915/display/intel_hotplug.c index 5f8b4f481cff9a..2d505db1f6476b 100644 --- a/drivers/gpu/drm/i915/display/intel_hotplug.c +++ b/drivers/gpu/drm/i915/display/intel_hotplug.c @@ -353,6 +353,10 @@ void intel_hpd_trigger_irq(struct intel_digital_port *dig_port) struct drm_i915_private *i915 = to_i915(dig_port->base.base.dev); spin_lock_irq(&i915->irq_lock); + if (i915->hotplug.suspended) { + spin_unlock_irq(&i915->irq_lock); + return; + } i915->hotplug.short_port_mask |= BIT(dig_port->base.port); spin_unlock_irq(&i915->irq_lock); @@ -475,6 +479,11 @@ void intel_hpd_irq_handler(struct drm_i915_private *dev_priv, spin_lock(&dev_priv->irq_lock); + if (dev_priv->hotplug.suspended) { + spin_unlock(&dev_priv->irq_lock); + return; + } + /* * Determine whether ->hpd_pulse() exists for each pin, and * whether we have a short or a long pulse. This is needed @@ -603,6 +612,7 @@ void intel_hpd_init(struct drm_i915_private *dev_priv) * just to make the assert_spin_locked checks happy. */ spin_lock_irq(&dev_priv->irq_lock); + dev_priv->hotplug.suspended = false; intel_hpd_irq_setup(dev_priv); spin_unlock_irq(&dev_priv->irq_lock); } @@ -721,13 +731,14 @@ void intel_hpd_init_work(struct drm_i915_private *dev_priv) intel_hpd_irq_storm_reenable_work); } -void intel_hpd_cancel_work(struct drm_i915_private *dev_priv) +void intel_hpd_suspend(struct drm_i915_private *dev_priv) { if (!HAS_DISPLAY(dev_priv)) return; spin_lock_irq(&dev_priv->irq_lock); + dev_priv->hotplug.suspended = true; dev_priv->hotplug.long_port_mask = 0; dev_priv->hotplug.short_port_mask = 0; dev_priv->hotplug.event_bits = 0; diff --git a/drivers/gpu/drm/i915/display/intel_hotplug.h b/drivers/gpu/drm/i915/display/intel_hotplug.h index b87e95d606e668..54bddc4dd63421 100644 --- a/drivers/gpu/drm/i915/display/intel_hotplug.h +++ b/drivers/gpu/drm/i915/display/intel_hotplug.h @@ -23,7 +23,7 @@ void intel_hpd_irq_handler(struct drm_i915_private *dev_priv, void intel_hpd_trigger_irq(struct intel_digital_port *dig_port); void intel_hpd_init(struct drm_i915_private *dev_priv); void intel_hpd_init_work(struct drm_i915_private *dev_priv); -void intel_hpd_cancel_work(struct drm_i915_private *dev_priv); +void intel_hpd_suspend(struct drm_i915_private *dev_priv); enum hpd_pin intel_hpd_pin_default(struct drm_i915_private *dev_priv, enum port port); bool intel_hpd_disable(struct drm_i915_private *dev_priv, enum hpd_pin pin); diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c index be932a6d9c7dfa..5f87719a74337c 100644 --- a/drivers/gpu/drm/i915/i915_driver.c +++ b/drivers/gpu/drm/i915/i915_driver.c @@ -1079,7 +1079,7 @@ void i915_driver_shutdown(struct drm_i915_private *i915) intel_dp_mst_suspend(i915); intel_runtime_pm_disable_interrupts(i915); - intel_hpd_cancel_work(i915); + intel_hpd_suspend(i915); intel_suspend_encoders(i915); intel_shutdown_encoders(i915); @@ -1148,7 +1148,7 @@ static int i915_drm_suspend(struct drm_device *dev) intel_dp_mst_suspend(dev_priv); intel_runtime_pm_disable_interrupts(dev_priv); - intel_hpd_cancel_work(dev_priv); + intel_hpd_suspend(dev_priv); intel_suspend_encoders(dev_priv); diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index c22f29c3faa0e2..3b5e99b9d2ee60 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -106,6 +106,8 @@ struct vlv_s0ix_state; #define HPD_STORM_DEFAULT_THRESHOLD 50 struct i915_hotplug { + bool suspended; + struct delayed_work hotplug_work; const u32 *hpd, *pch_hpd;