From patchwork Sat Feb 4 02:29:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lyude Paul X-Patchwork-Id: 9556979 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8021B6021C for ; Mon, 6 Feb 2017 01:24:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72B2920242 for ; Mon, 6 Feb 2017 01:24:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6790226C9B; Mon, 6 Feb 2017 01:24:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CBB7720242 for ; Mon, 6 Feb 2017 01:24:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7AAA46E28E; Mon, 6 Feb 2017 01:24:21 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by gabe.freedesktop.org (Postfix) with ESMTPS id B08CB6E14C; Sat, 4 Feb 2017 02:29:12 +0000 (UTC) Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0BD69C04B30E; Sat, 4 Feb 2017 02:29:13 +0000 (UTC) Received: from whitewolf.lyude.net.com (vpn-59-160.rdu2.redhat.com [10.10.59.160]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v142TAuu018961 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 3 Feb 2017 21:29:11 -0500 From: Lyude To: intel-gfx@lists.freedesktop.org Subject: [PATCH] drm/i915/debugfs: Add i915_hpd_storm_ctl Date: Fri, 3 Feb 2017 21:29:00 -0500 Message-Id: <20170204022901.24758-1-lyude@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Sat, 04 Feb 2017 02:29:13 +0000 (UTC) X-Mailman-Approved-At: Mon, 06 Feb 2017 01:24:20 +0000 Cc: Lyude , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Daniel Vetter X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This adds a file in i915's debugfs directory that allows userspace to manually control HPD storm detection. This is mainly for hotplugging tests, where we might want to test HPD storm functionality or disable storm detection to speed up hotplugging tests without breaking anything. Signed-off-by: Lyude Cc: Tomeu Vizoso --- drivers/gpu/drm/i915/i915_debugfs.c | 102 ++++++++++++++++++++++++++++++++++- drivers/gpu/drm/i915/i915_drv.h | 2 + drivers/gpu/drm/i915/i915_irq.c | 2 + drivers/gpu/drm/i915/intel_hotplug.c | 3 +- 4 files changed, 107 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index 3ae0656..b985c7b 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c @@ -4624,6 +4624,105 @@ static int i915_forcewake_create(struct dentry *root, struct drm_minor *minor) return drm_add_fake_info_node(minor, ent, &i915_forcewake_fops); } +static int i915_hpd_storm_ctl_show(struct seq_file *m, void *data) +{ + struct drm_i915_private *dev_priv = m->private; + + if (delayed_work_pending(&dev_priv->hotplug.reenable_work)) + seq_printf(m, "detected\n"); + else if (dev_priv->hotplug.hpd_storm_detect_enabled) + seq_printf(m, "on\n"); + else + seq_printf(m, "off\n"); + + return 0; +} + +static void i915_hpd_storm_reset(struct drm_i915_private *dev_priv) +{ + int i; + + spin_lock_irq(&dev_priv->irq_lock); + for (i = 0; i < ARRAY_SIZE(dev_priv->hotplug.stats); i++) { + dev_priv->hotplug.stats[i].count = 0; + dev_priv->hotplug.stats[i].last_jiffies = jiffies; + } + spin_unlock_irq(&dev_priv->irq_lock); + + if (delayed_work_pending(&dev_priv->hotplug.reenable_work)) + flush_delayed_work(&dev_priv->hotplug.reenable_work); + else + schedule_delayed_work(&dev_priv->hotplug.reenable_work, 0); +} + +static ssize_t i915_hpd_storm_ctl_write(struct file *file, + const char __user *ubuf, size_t len, + loff_t *offp) +{ + struct seq_file *m = file->private_data; + struct drm_i915_private *dev_priv = m->private; + struct i915_hotplug *hotplug = &dev_priv->hotplug; + char tmp[16]; + enum { + HPD_STORM_DISABLE = 0, + HPD_STORM_ENABLE, + HPD_STORM_RESET + } action; + + if (len >= sizeof(tmp)) + return -EINVAL; + + if (copy_from_user(tmp, ubuf, len)) + return -EFAULT; + + tmp[len] = '\0'; + + if (strcmp(tmp, "off") == 0 || strcmp(tmp, "off\n") == 0) + action = HPD_STORM_DISABLE; + else if (strcmp(tmp, "on") == 0 || strcmp(tmp, "on\n") == 0) + action = HPD_STORM_ENABLE; + else if (strcmp(tmp, "reset") == 0 || strcmp(tmp, "reset\n") == 0) + action = HPD_STORM_RESET; + else + return -EINVAL; + + switch (action) { + case HPD_STORM_DISABLE: + DRM_DEBUG_KMS("Disabling HPD storm detection\n"); + + WRITE_ONCE(hotplug->hpd_storm_detect_enabled, false); + i915_hpd_storm_reset(dev_priv); + break; + case HPD_STORM_ENABLE: + DRM_DEBUG_KMS("Enabling HPD storm detection\n"); + + i915_hpd_storm_reset(dev_priv); + hotplug->hpd_storm_detect_enabled = true; + break; + case HPD_STORM_RESET: + DRM_DEBUG_KMS("Resetting HPD storm stats\n"); + + i915_hpd_storm_reset(dev_priv); + break; + } + + return len; +} + +static int i915_hpd_storm_ctl_open(struct inode *inode, struct file *file) +{ + return single_open(file, i915_hpd_storm_ctl_show, inode->i_private); +} + +static const struct file_operations i915_hpd_storm_ctl_fops = { + .owner = THIS_MODULE, + .open = i915_hpd_storm_ctl_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, + .write = i915_hpd_storm_ctl_write +}; + static int i915_debugfs_create(struct dentry *root, struct drm_minor *minor, const char *name, @@ -4717,7 +4816,8 @@ static const struct i915_debugfs_files { {"i915_dp_test_data", &i915_displayport_test_data_fops}, {"i915_dp_test_type", &i915_displayport_test_type_fops}, {"i915_dp_test_active", &i915_displayport_test_active_fops}, - {"i915_guc_log_control", &i915_guc_log_control_fops} + {"i915_guc_log_control", &i915_guc_log_control_fops}, + {"i915_hpd_storm_ctl", &i915_hpd_storm_ctl_fops} }; int i915_debugfs_register(struct drm_i915_private *dev_priv) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index bd5a38b..b11596f 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -407,6 +407,8 @@ struct i915_hotplug { struct work_struct poll_init_work; bool poll_enabled; + bool hpd_storm_detect_enabled; + /* * if we get a HPD irq from DP and a HPD irq from non-DP * the non-DP HPD could block the workqueue on a mode config diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c index 059d66b..ed3292d 100644 --- a/drivers/gpu/drm/i915/i915_irq.c +++ b/drivers/gpu/drm/i915/i915_irq.c @@ -4225,6 +4225,8 @@ void intel_irq_init(struct drm_i915_private *dev_priv) if (!IS_GEN2(dev_priv)) dev->vblank_disable_immediate = true; + dev_priv->hotplug.hpd_storm_detect_enabled = true; + dev->driver->get_vblank_timestamp = i915_get_vblank_timestamp; dev->driver->get_scanout_position = i915_get_crtc_scanoutpos; diff --git a/drivers/gpu/drm/i915/intel_hotplug.c b/drivers/gpu/drm/i915/intel_hotplug.c index b62e3f8..c1e37dd 100644 --- a/drivers/gpu/drm/i915/intel_hotplug.c +++ b/drivers/gpu/drm/i915/intel_hotplug.c @@ -129,7 +129,8 @@ static bool intel_hpd_irq_storm_detect(struct drm_i915_private *dev_priv, dev_priv->hotplug.stats[pin].last_jiffies = jiffies; dev_priv->hotplug.stats[pin].count = 0; DRM_DEBUG_KMS("Received HPD interrupt on PIN %d - cnt: 0\n", pin); - } else if (dev_priv->hotplug.stats[pin].count > HPD_STORM_THRESHOLD) { + } else if (dev_priv->hotplug.stats[pin].count > HPD_STORM_THRESHOLD && + dev_priv->hotplug.hpd_storm_detect_enabled) { dev_priv->hotplug.stats[pin].state = HPD_MARK_DISABLED; DRM_DEBUG_KMS("HPD interrupt storm detected on PIN %d\n", pin); storm = true;