Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp667463imm; Wed, 19 Sep 2018 05:09:40 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYA2/GdqIHc/ULk4AzJozwQKogesx6jqdIoB10cuoK57YzQrv8/AR4DpMCrKnWgHKqTkkKe X-Received: by 2002:a62:c406:: with SMTP id y6-v6mr35986772pff.161.1537358980104; Wed, 19 Sep 2018 05:09:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537358980; cv=none; d=google.com; s=arc-20160816; b=B5C4M/L3uJW5P4vH0Jhj8cq4+qZdIA7HH+faLulwc5h3gd71DmeAPBzBfmIsj6kdFS BuKrnfJhcfxxV1FDzFLi61UMWGG8sOtUePusB3/wEsX8gIRfv50tv7Wj/1TFo9mxj++7 jsheg8eEXp6KivREkcNnOkVvEzVCJhBNjLMbh3OXYyhPLnfNcr24nLEn0PDKUuOqH1+A B+IDvcyy6ZudzzFRGvG1tlRaDU6FfbqJGeAEaJrfkSw0SRy5bWDv4GLWRMhGK0ZQurtt WdrMRG3Ev9hGPo4xeRmxglEUPHWsIA2itf+0/vjzsHE96uW95x1L2BUTw7v0X3BIGCEG 6vkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :organization:in-reply-to:subject:cc:to:from; bh=YT/KZJ6/QERG1xfKLMitV1ZlFeadjDfhGoVGAG6LkmM=; b=k8qcPqpXEBVd1IA6ZTA+Yv8EN3EzO6xydNqdlEVAX3esmeNkjYqqSClAUeo8PpJtBO T7nIuTfLGrm6xEVYNKgynpZ6UdFPlbldNtyedHjPKXsud2JnzTI9cizi4pF8Ymh4Jf+4 YSyZ+omiYhh/RDFf1VO2gg7QNZw6wOuolN+eVIiFGi0cfxyMcxPS4nRNAB6BdDB9UcNc pMRTk89uNghWDUYjTkeWfeRfsuObFdnH5DH7RrQWkuaCvhQci7D1FhTkHM0yKjkmidzi rh67PgXYzCcB/EbGZufGt7fbsePh00QbqOvKRCYbluVUiSP+6ABg1foxoABBs+L0iuZB snvQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t190-v6si22783106pfb.344.2018.09.19.05.09.23; Wed, 19 Sep 2018 05:09:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731345AbeISRqb (ORCPT + 99 others); Wed, 19 Sep 2018 13:46:31 -0400 Received: from mga06.intel.com ([134.134.136.31]:62396 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727772AbeISRqb (ORCPT ); Wed, 19 Sep 2018 13:46:31 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Sep 2018 05:08:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,393,1531810800"; d="scan'208";a="91426762" Received: from jnikula-mobl3.fi.intel.com (HELO localhost) ([10.237.72.61]) by fmsmga001.fm.intel.com with ESMTP; 19 Sep 2018 05:08:50 -0700 From: Jani Nikula To: Chris Chiu Cc: Ville =?utf-8?B?U3lyasOkbMOk?= , joonas.lahtinen@linux.intel.com, rodrigo.vivi@intel.com, David Airlie , intel-gfx@lists.freedesktop.org, Linux Upstreaming Team , Linux Kernel , dri-devel Subject: Re: [BUG] i915 HDMI connector status is connected after disconnection In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20180705144009.GC5565@intel.com> <87tvnjlsap.fsf@intel.com> Date: Wed, 19 Sep 2018 15:08:57 +0300 Message-ID: <87k1nhy9ie.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 19 Sep 2018, Chris Chiu wrote: > I tried to add a slight delay in the hotplug work as follows > > --- a/drivers/gpu/drm/i915/intel_hotplug.c > +++ b/drivers/gpu/drm/i915/intel_hotplug.c > @@ -378,6 +378,8 @@ static void do_i915_hotplug_check(struct work_struct *work, > > spin_unlock_irq(&dev_priv->irq_lock); > > + msleep(100); > + > drm_connector_list_iter_begin(dev, &conn_iter); > drm_for_each_connector_iter(connector, &conn_iter) { > intel_connector = to_intel_connector(connector); > > It does work in most cases, but still fail to update the status if I > unplug the HDMI > cable very slow. I basically pull the HDMI cable in loose connected > state first, and > hold in that state ~1 second, totally unplug after that. The status in > sysfs will report > connected as it used to. There was no problem when I tried the patch > https://bugs.freedesktop.org/show_bug.cgi?id=107125#c8 > > I'll try to modify this patch a little bit and send upstream for > discussion later. Please > advise if any. Thanks. Please let's not add excessive msleeps in work functions. My idea was more along the lines of making the hotplug function run in a delayed work. After a chat with Ville, below is what I came up with. Please let me know how it works. Feel free to toy with the delay. However, 1-2 seconds or more seems too much. BR, Jani. From 72515b3e856171e52e96bb74796774f595a7f418 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Tue, 18 Sep 2018 13:12:34 +0300 Subject: [PATCH] drm/i915: delay hotplug scheduling Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Cc: Jani Nikula On some systems we get the hotplug irq on unplug before the DDC pins have been disconnected, resulting in connector status remaining connected. Since previous attempts at using hotplug live status before DDC have failed, the only viable option is to reduce the window for mistakes. Delay the hotplug processing. Signed-off-by: Jani Nikula --- drivers/gpu/drm/i915/i915_drv.h | 2 +- drivers/gpu/drm/i915/intel_hotplug.c | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 7d4daa7412f1..27f579abddae 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -286,7 +286,7 @@ enum hpd_pin { #define HPD_STORM_DEFAULT_THRESHOLD 5 struct i915_hotplug { - struct work_struct hotplug_work; + struct delayed_work hotplug_work; struct { unsigned long last_jiffies; diff --git a/drivers/gpu/drm/i915/intel_hotplug.c b/drivers/gpu/drm/i915/intel_hotplug.c index 648a13c6043c..3af64daa5cfc 100644 --- a/drivers/gpu/drm/i915/intel_hotplug.c +++ b/drivers/gpu/drm/i915/intel_hotplug.c @@ -110,6 +110,8 @@ enum hpd_pin intel_hpd_pin_default(struct drm_i915_private *dev_priv, } } +#define HOTPLUG_DELAY_MS 300 + #define HPD_STORM_DETECT_PERIOD 1000 #define HPD_STORM_REENABLE_DELAY (2 * 60 * 1000) @@ -319,7 +321,8 @@ static void i915_digport_work_func(struct work_struct *work) spin_lock_irq(&dev_priv->irq_lock); dev_priv->hotplug.event_bits |= old_bits; spin_unlock_irq(&dev_priv->irq_lock); - schedule_work(&dev_priv->hotplug.hotplug_work); + schedule_delayed_work(&dev_priv->hotplug.hotplug_work, + msecs_to_jiffies(HOTPLUG_DELAY_MS)); } } @@ -329,7 +332,7 @@ static void i915_digport_work_func(struct work_struct *work) static void i915_hotplug_work_func(struct work_struct *work) { struct drm_i915_private *dev_priv = - container_of(work, struct drm_i915_private, hotplug.hotplug_work); + container_of(work, struct drm_i915_private, hotplug.hotplug_work.work); struct drm_device *dev = &dev_priv->drm; struct intel_connector *intel_connector; struct intel_encoder *intel_encoder; @@ -466,7 +469,8 @@ void intel_hpd_irq_handler(struct drm_i915_private *dev_priv, if (queue_dig) queue_work(dev_priv->hotplug.dp_wq, &dev_priv->hotplug.dig_port_work); if (queue_hp) - schedule_work(&dev_priv->hotplug.hotplug_work); + schedule_delayed_work(&dev_priv->hotplug.hotplug_work, + msecs_to_jiffies(HOTPLUG_DELAY_MS)); } /** @@ -586,7 +590,8 @@ void intel_hpd_poll_init(struct drm_i915_private *dev_priv) void intel_hpd_init_work(struct drm_i915_private *dev_priv) { - INIT_WORK(&dev_priv->hotplug.hotplug_work, i915_hotplug_work_func); + INIT_DELAYED_WORK(&dev_priv->hotplug.hotplug_work, + i915_hotplug_work_func); INIT_WORK(&dev_priv->hotplug.dig_port_work, i915_digport_work_func); INIT_WORK(&dev_priv->hotplug.poll_init_work, i915_hpd_poll_init_work); INIT_DELAYED_WORK(&dev_priv->hotplug.reenable_work, @@ -604,7 +609,7 @@ void intel_hpd_cancel_work(struct drm_i915_private *dev_priv) spin_unlock_irq(&dev_priv->irq_lock); cancel_work_sync(&dev_priv->hotplug.dig_port_work); - cancel_work_sync(&dev_priv->hotplug.hotplug_work); + cancel_delayed_work_sync(&dev_priv->hotplug.hotplug_work); cancel_work_sync(&dev_priv->hotplug.poll_init_work); cancel_delayed_work_sync(&dev_priv->hotplug.reenable_work); } -- 2.11.0 -- Jani Nikula, Intel Open Source Graphics Center