From patchwork Thu Oct 9 15:38:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Todd Previte X-Patchwork-Id: 5058941 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 26456C11AC for ; Thu, 9 Oct 2014 15:38:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 119DD201BC for ; Thu, 9 Oct 2014 15:38:56 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 0322F2018E for ; Thu, 9 Oct 2014 15:38:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 78AEE6E385; Thu, 9 Oct 2014 08:38:54 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-yk0-f170.google.com (mail-yk0-f170.google.com [209.85.160.170]) by gabe.freedesktop.org (Postfix) with ESMTP id 685E16E386 for ; Thu, 9 Oct 2014 08:38:53 -0700 (PDT) Received: by mail-yk0-f170.google.com with SMTP id 20so815494yks.1 for ; Thu, 09 Oct 2014 08:38:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nn1i/820O4Mv+Taaj7aBB4jqo6TfMIxsO8KzOZZVhcM=; b=vuI8sH9FSQ7ipD5U53gPwfVKmVeqRT7CM31ADNSu8ni01a6rXuF8729uMFitohJgAQ 0hPrxS9D8a8JZuvpVWN/b7b9VouKgE3i70qR8KsXFobFA3686V3q4TVBkCVyJCqFEgZr kg95vVBuv5c8mL5Byql+dvSryHX03EqaxF5Ys3zGTUmax6VklPqMYBUUQnhtKfh/UmrB gwatAwsiNO8DsOwBMaYFBa6FevhMWbz8myDVsN8e+ELXyaQLe6V1iOgASUDHY4JHRVwV D8cpsWwEanx10Jr7glVrfoHJRBuquXv2oAod6eemVdFgXkk2V1fr0+J2y0ifkb2J6HjB O+0w== X-Received: by 10.70.36.79 with SMTP id o15mr15691558pdj.6.1412869132870; Thu, 09 Oct 2014 08:38:52 -0700 (PDT) Received: from localhost.localdomain (ip72-201-95-47.ph.ph.cox.net. [72.201.95.47]) by mx.google.com with ESMTPSA id y1sm844710pbw.89.2014.10.09.08.38.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Oct 2014 08:38:51 -0700 (PDT) From: Todd Previte To: intel-gfx@lists.freedesktop.org Date: Thu, 9 Oct 2014 08:38:06 -0700 Message-Id: <1412869090-48010-7-git-send-email-tprevite@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1412869090-48010-1-git-send-email-tprevite@gmail.com> References: <1412869090-48010-1-git-send-email-tprevite@gmail.com> Subject: [Intel-gfx] [PATCH 06/10] drm/i915: Add debugfs interface and support functions to notify userspace apps for Displayport compliance testing X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Adds the capability for the driver to signal a userspace application for Displayport compliance testing. The userspace app must write its PID to the appropriate debugfs file, at which time the kernel will read and store that PID internally. PIDs are specified on a per-connector basis. Signed-off-by: Todd Previte --- drivers/gpu/drm/i915/i915_debugfs.c | 124 +++++++++++++++++++++++++++++++++++- drivers/gpu/drm/i915/intel_dp.c | 34 ++++++++++ drivers/gpu/drm/i915/intel_drv.h | 4 ++ 3 files changed, 161 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index 2dada18..d16612c 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c @@ -54,6 +54,7 @@ static const char *yesno(int v) #define DP_PARAMETER_COUNT 8 #define MAX_DP_CONFIG_LINE_COUNT 64 +#define PID_BUFFER_SIZE 16 enum dp_config_param { DP_CONFIG_PARAM_INVALID = -1, @@ -3884,6 +3885,126 @@ out: return len; } +static int displayport_user_pid_show(struct seq_file *m, void *data) +{ + struct drm_device *dev = m->private; + struct drm_connector *connector; + struct intel_encoder *intel_encoder; + struct intel_connector *intel_connector; + struct intel_dp *intel_dp; + + if (!dev) + return -ENODEV; + + list_for_each_entry(connector, &dev->mode_config.connector_list, head) { + intel_connector = to_intel_connector(connector); + intel_encoder = intel_connector->encoder; + DRM_DEBUG_DRIVER("Got connector %s with type %08x\n", + connector->name, connector->connector_type); + if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) { + if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT || + intel_encoder->type == INTEL_OUTPUT_UNKNOWN) { + intel_dp = enc_to_intel_dp(&intel_encoder->base); + seq_printf(m, "%s: %lu\n", + connector->name, + intel_dp->compliance_app_pid); + } + } + } + + return 0; +} + +static int i915_displayport_user_pid_open(struct inode *inode, + struct file *file) +{ + struct drm_device *dev = inode->i_private; + + return single_open(file, displayport_user_pid_show, dev); +} + +static ssize_t displayport_user_pid_write(struct file *file, + const char __user *ubuf, + size_t len, loff_t *offp) +{ + /* Userspace app writes its PID in here and is stored in the intel_dp + struct for the connector. The PID is used when the driver receives + an intrrupt for a compliance request to notify userspace of the + event. */ + struct seq_file *m; + struct drm_device *dev; + struct drm_connector *connector; + struct intel_encoder *intel_encoder; + struct intel_connector *intel_connector; + struct intel_dp *intel_dp; + int status = 0; + long user_pid = 0; + char pidbuf[PID_BUFFER_SIZE+1]; + char *start = pidbuf; + + m = file->private_data; + if (!m) { + status = -ENODEV; + goto out; + } + + dev = m->private; + if (!dev) { + status = -ENODEV; + goto out; + } + + if (len > PID_BUFFER_SIZE) { + status = -EINVAL; + goto out; + } + + if (copy_from_user(pidbuf, ubuf, len)) { + status = -EFAULT; + goto out; + } + + pidbuf[len] = '\0'; + /* Skip to separator */ + while (*start != ':') + start++; + start++; + /* skip whitespace */ + while (*start <= 0x20) + start++; + /* Get the PID now */ + status = kstrtol(start, 10, &user_pid); + if (status < 0) + goto out; + + list_for_each_entry(connector, &dev->mode_config.connector_list, head) { + intel_connector = to_intel_connector(connector); + intel_encoder = intel_connector->encoder; + DRM_DEBUG_DRIVER("Got connector %s with type %08x\n", + connector->name, connector->connector_type); + if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) { + if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT || + intel_encoder->type == INTEL_OUTPUT_UNKNOWN) { + DRM_DEBUG_DRIVER("Pid %ld added to Connector %s\n", + user_pid, connector->name); + intel_dp = enc_to_intel_dp(&intel_encoder->base); + intel_dp->compliance_app_pid = user_pid; + } + } + } +out: + return status; +} + +static const struct file_operations displayport_user_pid_fops = { + .owner = THIS_MODULE, + .write = displayport_user_pid_write, + .open = i915_displayport_user_pid_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release +}; + static const struct file_operations i915_displayport_config_ctl_fops = { .owner = THIS_MODULE, .open = displayport_config_ctl_open, @@ -4596,7 +4717,8 @@ static const struct i915_debugfs_files { {"i915_spr_wm_latency", &i915_spr_wm_latency_fops}, {"i915_cur_wm_latency", &i915_cur_wm_latency_fops}, {"i915_fbc_false_color", &i915_fbc_fc_fops}, - {"i915_displayport_config_ctl", &i915_displayport_config_ctl_fops} + {"i915_displayport_config_ctl", &i915_displayport_config_ctl_fops}, + {"i915_displayport_user_pid", &displayport_user_pid_fops} }; void intel_display_crc_init(struct drm_device *dev) diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index b3ddd15..717cb5d 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c @@ -39,6 +39,7 @@ #include "i915_drv.h" #define DP_LINK_CHECK_TIMEOUT (10 * 1000) +#define SIG_DP_COMPLIANCE 47 struct dp_link_dpll { int link_bw; @@ -157,6 +158,37 @@ static u8 intel_dp_max_lane_count(struct intel_dp *intel_dp) return min(source_max, sink_max); } +int intel_dp_signal_userspace(struct intel_dp *intel_dp) +{ + int status = 0; + struct siginfo s_info; + struct task_struct *compliance_app; + + /* Setup signal structure */ + memset(&s_info, 0, sizeof(struct siginfo)); + s_info.si_signo = SIG_DP_COMPLIANCE; + s_info.si_code = SI_QUEUE; + s_info.si_int = intel_dp->compliance_test_data; + + rcu_read_lock(); + compliance_app = pid_task(find_pid_ns(intel_dp->compliance_app_pid, + &init_pid_ns), PIDTYPE_PID); + if (compliance_app == NULL) { + rcu_read_unlock(); + DRM_DEBUG_DRIVER("Compliance test requested with no available userspace handler. Testing aborted\n"); + status = -ENODEV; + goto out; + } + rcu_read_unlock(); + + /* Send signal */ + status = send_sig_info(SIG_DP_COMPLIANCE, &s_info, compliance_app); + if (status < 0) + DRM_DEBUG_DRIVER("Error: Could not send signal\n"); +out: + return status; +} + /* * The units on the numbers in the next two are... bizarre. Examples will * make it clearer; this one parallels an example in the eDP spec. @@ -4006,6 +4038,8 @@ intel_dp_handle_test_request(struct intel_dp *intel_dp) DRM_DEBUG_KMS("Received automated test request\n"); status = drm_dp_dpcd_read(&intel_dp->aux, DP_TEST_REQUEST, &rxdata, 1); + intel_dp->compliance_test_data = rxdata; + /* ACK/NAK response based on test function response Unimplemented/unsupported tests will NAK by default */ switch (rxdata) { diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index e8f4839..29d51f9 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -613,6 +613,10 @@ struct intel_dp { enum edp_drrs_refresh_rate_type refresh_rate_type; struct mutex mutex; } drrs_state; + /* Displayport compliance testing */ + unsigned long compliance_app_pid; + unsigned long compliance_test_data; + bool compliance_testing_active; };