From patchwork Wed Jul 20 16:48:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 12924326 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 C903BC43334 for ; Wed, 20 Jul 2022 16:49:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D8404910CE; Wed, 20 Jul 2022 16:49:23 +0000 (UTC) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 98B5C910AC; Wed, 20 Jul 2022 16:49:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658335762; x=1689871762; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1QhT6jQXOf5LANxgn9whzxYWaxnwk7I0tnGhga3K4lI=; b=ntZ008C79tS8acemT9/n3k1Qy5TkiPIdCeeBHxMMlnxU367N8VMEE3YB WRlFLJMQsoLJwL0RHzByq7CMJlnkINRyeLJ82ywB59mxWeb9F9cqn57qC FY+9Z8xDZi8mdbrA9mrtRVSSEeTabEK4k7wef7V3YMgut4+x+P+YQ8bQo 3EX5u+FUvYWyselplgveEfJ4qAOF5GTaQhnehix8LVaFxqxfzBirDcjoG MF5OxEo9AGNZAi9YcmN6faliVw48mK6ucbiqFI4iaO4QL9o7W3Tx/7eE0 8KkHJVldGn4MbHIlCQQaxjqejgepS/5lXeGl3eYuJVhL0pzdZowJPZCME A==; X-IronPort-AV: E=McAfee;i="6400,9594,10414"; a="266604492" X-IronPort-AV: E=Sophos;i="5.92,286,1650956400"; d="scan'208";a="266604492" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2022 09:49:02 -0700 X-IronPort-AV: E=Sophos;i="5.92,286,1650956400"; d="scan'208";a="656349845" Received: from lab-ah.igk.intel.com ([10.91.215.196]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2022 09:49:00 -0700 From: Andrzej Hajda To: Jani Nikula , =?utf-8?b?VmlsbGUgU3lyasOk?= =?utf-8?b?bMOk?= , Arun R Murthy Subject: [PATCH v5 1/4] drm/i915/hpd: postpone HPD cancel work after last user suspension Date: Wed, 20 Jul 2022 18:48:45 +0200 Message-Id: <20220720164848.1246701-2-andrzej.hajda@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220720164848.1246701-1-andrzej.hajda@intel.com> References: <20220720164848.1246701-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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tvrtko Ursulin , Andrzej Hajda , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Rodrigo Vivi Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" i915->hotplug.dig_port_work can be queued from intel_hpd_irq_handler called by IRQ handler or by intel_hpd_trigger_irq called from dp_mst. Since dp_mst is suspended after irq handler uninstall, a cleaner approach is to cancel hpd work after intel_dp_mst_suspend, otherwise we risk use-after-free. It should fix following WARNINGS: [283.405824] cpu_latency_qos_update_request called for unknown object [283.405866] WARNING: CPU: 2 PID: 240 at kernel/power/qos.c:296 cpu_latency_qos_update_request+0x2d/0x100 [283.405912] CPU: 2 PID: 240 Comm: kworker/u64:9 Not tainted 5.18.0-rc6-Patchwork_103738v3-g1672d1c43e43+ #1 [283.405915] Hardware name: Intel Corporation Raptor Lake Client Platform/RPL-S ADP-S DDR5 UDIMM CRB, BIOS RPLSFWI1.R00.2397.A01.2109300731 09/30/2021 [283.405916] Workqueue: i915-dp i915_digport_work_func [i915] [283.406020] RIP: 0010:cpu_latency_qos_update_request+0x2d/0x100 ... [283.406040] Call Trace: [283.406041] [283.406044] intel_dp_aux_xfer+0x60e/0x8e0 [i915] [283.406131] ? finish_swait+0x80/0x80 [283.406139] intel_dp_aux_transfer+0xc5/0x2b0 [i915] [283.406218] drm_dp_dpcd_access+0x79/0x130 [drm_display_helper] [283.406227] drm_dp_dpcd_read+0xe2/0xf0 [drm_display_helper] [283.406233] intel_dp_hpd_pulse+0x134/0x570 [i915] [283.406308] ? __down_killable+0x70/0x140 [283.406313] i915_digport_work_func+0xba/0x150 [i915] Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/4586 Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/5558 Signed-off-by: Andrzej Hajda Reviewed-by: Arun R Murthy --- drivers/gpu/drm/i915/display/intel_display.c | 3 +++ drivers/gpu/drm/i915/i915_irq.c | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c index 903226e2a6260d..ec8e59b3adaea7 100644 --- a/drivers/gpu/drm/i915/display/intel_display.c +++ b/drivers/gpu/drm/i915/display/intel_display.c @@ -9007,6 +9007,9 @@ 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); + /* poll work can call into fbdev, hence clean that up afterwards */ intel_fbdev_fini(i915); diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c index 73cebc6aa65072..db14787aef95dd 100644 --- a/drivers/gpu/drm/i915/i915_irq.c +++ b/drivers/gpu/drm/i915/i915_irq.c @@ -4597,7 +4597,6 @@ void intel_irq_uninstall(struct drm_i915_private *dev_priv) free_irq(irq, dev_priv); - intel_hpd_cancel_work(dev_priv); dev_priv->runtime_pm.irqs_enabled = false; } From patchwork Wed Jul 20 16:48:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 12924329 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 ECE13C43334 for ; Wed, 20 Jul 2022 16:49:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3A4A8910F1; Wed, 20 Jul 2022 16:49:30 +0000 (UTC) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id B2D30910AC; Wed, 20 Jul 2022 16:49:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658335763; x=1689871763; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cnGW971gTKAjs5K8BebO0eDFgVCDB9gEsxUcT1skyLQ=; b=RlLg9tDzMNVhAyjp6TfeluL+qpCw0DY08QQ8WY6TjSuwfc1pFDiRiBnH CQ2bDPwWSWITk4gfv7iCW0TYtcGWw85B7yg77Qq0vU8ygfdplEKmFDYDn 5jDRen0BWGt8VtaWTFWuhln/xMfDORuvTtleaefBpL0GHJqd4jgnuV/uu 0u0xgNqMVApfrB3Muqy33wzHS3LB8pJSaJ4VEJyvSIBANyWXB5jlqVCkw pF5SlZ0A8K8n4+JN8Ft0LqjvGM1f9vI2aAmkmm9oK2fKrdMFZ0wWPSXrR cvAl5Cw9Pbj5w5ciZiQ2hJLCwk4FNa3Ww+L1PZi1DsOM6EhECmI3v2mOi w==; X-IronPort-AV: E=McAfee;i="6400,9594,10414"; a="266604509" X-IronPort-AV: E=Sophos;i="5.92,286,1650956400"; d="scan'208";a="266604509" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2022 09:49:05 -0700 X-IronPort-AV: E=Sophos;i="5.92,286,1650956400"; d="scan'208";a="656349853" Received: from lab-ah.igk.intel.com ([10.91.215.196]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2022 09:49:02 -0700 From: Andrzej Hajda To: Jani Nikula , =?utf-8?b?VmlsbGUgU3lyasOk?= =?utf-8?b?bMOk?= , Arun R Murthy Subject: [PATCH v5 2/4] drm/i915/fbdev: suspend HPD before fbdev unregistration Date: Wed, 20 Jul 2022 18:48:46 +0200 Message-Id: <20220720164848.1246701-3-andrzej.hajda@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220720164848.1246701-1-andrzej.hajda@intel.com> References: <20220720164848.1246701-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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tvrtko Ursulin , Andrzej Hajda , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Rodrigo Vivi Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" HPD event after fbdev unregistration can cause registration of deferred fbdev which will not be unregistered later, causing use-after-free. To avoid it HPD handling should be suspended before fbdev unregistration. It should fix following GPF: [272.634530] general protection fault, probably for non-canonical address 0x6b6b6b6b6b6b6b6b: 0000 [#1] PREEMPT SMP NOPTI [272.634536] CPU: 0 PID: 6030 Comm: i915_selftest Tainted: G U 5.18.0-rc5-CI_DRM_11603-g12dccf4f5eef+ #1 [272.634541] Hardware name: Intel Corporation Raptor Lake Client Platform/RPL-S ADP-S DDR5 UDIMM CRB, BIOS RPLSFWI1.R00.2397.A01.2109300731 09/30/2021 [272.634545] RIP: 0010:fb_do_apertures_overlap.part.14+0x26/0x60 ... [272.634582] Call Trace: [272.634583] [272.634585] do_remove_conflicting_framebuffers+0x59/0xa0 [272.634589] remove_conflicting_framebuffers+0x2d/0xc0 [272.634592] remove_conflicting_pci_framebuffers+0xc8/0x110 [272.634595] drm_aperture_remove_conflicting_pci_framebuffers+0x52/0x70 [272.634604] i915_driver_probe+0x63a/0xdd0 [i915] Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/5329 Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/5510 Signed-off-by: Andrzej Hajda Reviewed-by: Arun R Murthy --- drivers/gpu/drm/i915/display/intel_fbdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/display/intel_fbdev.c b/drivers/gpu/drm/i915/display/intel_fbdev.c index 221336178991f0..b682fd72d4bf25 100644 --- a/drivers/gpu/drm/i915/display/intel_fbdev.c +++ b/drivers/gpu/drm/i915/display/intel_fbdev.c @@ -573,7 +573,8 @@ void intel_fbdev_unregister(struct drm_i915_private *dev_priv) if (!ifbdev) return; - cancel_work_sync(&dev_priv->fbdev_suspend_work); + intel_fbdev_set_suspend(&dev_priv->drm, FBINFO_STATE_SUSPENDED, true); + if (!current_is_async()) intel_fbdev_sync(ifbdev); From patchwork Wed Jul 20 16:48:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 12924327 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 CC524C43334 for ; Wed, 20 Jul 2022 16:49:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ACCBE910EC; Wed, 20 Jul 2022 16:49:29 +0000 (UTC) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8C494910DD; Wed, 20 Jul 2022 16:49:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658335765; x=1689871765; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cHvdhbRlCrVIM4W1/eGFdn4zZiPAYqctVg7E7GHTnxw=; b=gIhHydflgjOsze4XtJppGdZ5bBwZQHG7C12jvnHp1pxkPXuegijzBG4t zM7eCFkj91nq3yWLzIOb5wLNgqigOZ6BjpMEioKfht5qTbWgFJoVKLUrO L0XqjrnVkFYsObs0XMamX+Ligx7aHa9uy6x/u5t75R1diTgQ2/y3O2z48 mgwkkwwTUgO61YGUcg5agYxkiBUeFu7oW2iOVksp6WBBrsobsB39yEEIv /7X2n1Z/xoq9KQJKtq5Rc7P9BlpNjJLrz5ZHNtcdY3RYy0J9L0kwZikWE DAs9JC3ke9+xM8IHVOycKNMzdbWNL3EbX2gMeWcXLkGSkmbRErrPlBpTV w==; X-IronPort-AV: E=McAfee;i="6400,9594,10414"; a="266604528" X-IronPort-AV: E=Sophos;i="5.92,286,1650956400"; d="scan'208";a="266604528" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2022 09:49:07 -0700 X-IronPort-AV: E=Sophos;i="5.92,286,1650956400"; d="scan'208";a="656349862" Received: from lab-ah.igk.intel.com ([10.91.215.196]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2022 09:49:05 -0700 From: Andrzej Hajda To: Jani Nikula , =?utf-8?b?VmlsbGUgU3lyasOk?= =?utf-8?b?bMOk?= , Arun R Murthy Subject: [PATCH v5 3/4] drm/i915/display: add hotplug.suspended flag Date: Wed, 20 Jul 2022 18:48:47 +0200 Message-Id: <20220720164848.1246701-4-andrzej.hajda@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220720164848.1246701-1-andrzej.hajda@intel.com> References: <20220720164848.1246701-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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tvrtko Ursulin , Andrzej Hajda , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Rodrigo Vivi Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 | 11 ++++++++++- 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, 16 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..e1d384cb99df6b 100644 --- a/drivers/gpu/drm/i915/display/intel_hotplug.c +++ b/drivers/gpu/drm/i915/display/intel_hotplug.c @@ -303,6 +303,8 @@ static void i915_digport_work_func(struct work_struct *work) u32 old_bits = 0; spin_lock_irq(&dev_priv->irq_lock); + if (dev_priv->hotplug.suspended) + return spin_unlock_irq(&dev_priv->irq_lock); long_port_mask = dev_priv->hotplug.long_port_mask; dev_priv->hotplug.long_port_mask = 0; short_port_mask = dev_priv->hotplug.short_port_mask; @@ -353,6 +355,8 @@ 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) + return spin_unlock_irq(&i915->irq_lock); i915->hotplug.short_port_mask |= BIT(dig_port->base.port); spin_unlock_irq(&i915->irq_lock); @@ -475,6 +479,9 @@ void intel_hpd_irq_handler(struct drm_i915_private *dev_priv, spin_lock(&dev_priv->irq_lock); + if (dev_priv->hotplug.suspended) + return spin_unlock(&dev_priv->irq_lock); + /* * Determine whether ->hpd_pulse() exists for each pin, and * whether we have a short or a long pulse. This is needed @@ -603,6 +610,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 +729,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; From patchwork Wed Jul 20 16:48:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 12924328 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 16575C433EF for ; Wed, 20 Jul 2022 16:49:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3F215910F3; Wed, 20 Jul 2022 16:49:30 +0000 (UTC) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id F3AD8910E7; Wed, 20 Jul 2022 16:49:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658335766; x=1689871766; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4meeIMkX8KY97+h+8xmCmUd+Stu1WSlIw4GXge4YeHw=; b=OlH0tD0/XStQ7cUeWwKoDPE26Gz1K4GNGXwKQjUbnQEbLKbbuYBewvYO kE3CMClVDRj4y6GxJ402JIM6oqdFJcXjVnsPrgPTpL3baW1vh8S17hWFO 0/5IYDU4HcQVaaekuOel35l2bVEHWBcZ1IrQiSbIAdr3u/jqdFTcRRqCa doxcdLetwORhsu2Dkm9xqxKYWBQFxgNgVVox/A4gQ1Tjcd3ue6J/I7Pod 6HDixkGmBio5WpjqCd0UBgj73cBWmLGt1w999Qml2cee7iuDVGoKDUXyE MNPEs0JSe5H2Zf9klq5cW88T6ED6wJIIYTMyMfg8vLUlrDUfkPkrTs5W4 Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10414"; a="266604538" X-IronPort-AV: E=Sophos;i="5.92,286,1650956400"; d="scan'208";a="266604538" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2022 09:49:09 -0700 X-IronPort-AV: E=Sophos;i="5.92,286,1650956400"; d="scan'208";a="656349870" Received: from lab-ah.igk.intel.com ([10.91.215.196]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2022 09:49:07 -0700 From: Andrzej Hajda To: Jani Nikula , =?utf-8?b?VmlsbGUgU3lyasOk?= =?utf-8?b?bMOk?= , Arun R Murthy Subject: [PATCH v5 4/4] drm/i915/fbdev: do not create fbdev if HPD is suspended Date: Wed, 20 Jul 2022 18:48:48 +0200 Message-Id: <20220720164848.1246701-5-andrzej.hajda@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220720164848.1246701-1-andrzej.hajda@intel.com> References: <20220720164848.1246701-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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tvrtko Ursulin , Andrzej Hajda , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Rodrigo Vivi Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" In case of deferred FB setup core can try to create new framebuffer. Disallow it if hpd_suspended flag is set. Signed-off-by: Andrzej Hajda --- drivers/gpu/drm/i915/display/intel_fbdev.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpu/drm/i915/display/intel_fbdev.c b/drivers/gpu/drm/i915/display/intel_fbdev.c index b682fd72d4bf25..7cd3eb9b7729f9 100644 --- a/drivers/gpu/drm/i915/display/intel_fbdev.c +++ b/drivers/gpu/drm/i915/display/intel_fbdev.c @@ -210,6 +210,12 @@ static int intelfb_create(struct drm_fb_helper *helper, struct drm_i915_gem_object *obj; int ret; + mutex_lock(&ifbdev->hpd_lock); + ret = ifbdev->hpd_suspended ? -EAGAIN : 0; + mutex_unlock(&ifbdev->hpd_lock); + if (ret) + return ret; + if (intel_fb && (sizes->fb_width > intel_fb->base.width || sizes->fb_height > intel_fb->base.height)) {