From patchwork Fri Oct 15 23:22:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 515857 Delivered-To: patch@linaro.org Received: by 2002:ac0:da11:0:0:0:0:0 with SMTP id d17csp1008896imi; Fri, 15 Oct 2021 16:20:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCCPfQWdQAOSBE6Ci86EVRogLIdNGhvCXr/4Ej9RafUKadhBBpRLHnyymL08aJkIOnv+5A X-Received: by 2002:a17:90b:4c47:: with SMTP id np7mr16623281pjb.22.1634340029620; Fri, 15 Oct 2021 16:20:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634340029; cv=none; d=google.com; s=arc-20160816; b=Q8A38bykHBhI9U1A7isnfejr05e6oDZ1KT8bhUJXuYFFKr/ohuchgCRDN/emQDRedW qdiMra4kwlinIPDUlRj6a9JG+h/47stsr5m/uxNg8I0VdGWkPu6I31LccgnrMeHMjoo6 unIMtSO481mHTUcaz/uhjTQrS7b1X35JZK1kJ1ww0lnj5yRuHAwzT5TcsKU1e9z98wa9 GjKFKsGwOVqWyAmlkfArV6esupk1X/EzZyC+lXKujzMUtjfqUhvwU+4m8pQ/jgGZooP0 uuHovF1EA9/JhobY0pXdeD8QyruLzWw6ly06mBKxE4lEKRR+12zmJgwEvSiay/UjHHEz 9KZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :delivered-to; bh=DD82WbwLimEkgGB+aqUxdRRvDUvC5eko9EPcFoU6FmI=; b=yw0Bs1rOzyqKXv/P8pqxZ8+6FveHBos3660uDLw6zozVUXEX7H8VQp3lpvRNNFH0dv HrqXo1428REFcBgBVNRFb/IPdImp+SZcOIC/qy10pmkOj7HlEHyHu373SXI7nMzWaDPy CYRxgzAY1I9QReA3MUKlseA9y7/XZkKcYKL0MNP0fIr60pZpFtmXZ79Gqq5Ix7iBm0N6 mF5gxHutCzf+Tfab48ZDfx/NVfIr55fVAGiyOyI4rKECNLB9oN7bmKz3rOHMy6sF+PFS EpQt4CDKvkFhgsKyu9Ms3YzlSUilsM7Z9R5xvxKWL84gHBssHH+aY319lUWedBVmnhD9 X0NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AhJ3Do4G; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id f18si10607601pfe.368.2021.10.15.16.20.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Oct 2021 16:20:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AhJ3Do4G; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 915A86E405; Fri, 15 Oct 2021 23:20:26 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1120D6EE09 for ; Fri, 15 Oct 2021 23:20:25 +0000 (UTC) Received: by mail-oi1-x236.google.com with SMTP id t4so15214458oie.5 for ; Fri, 15 Oct 2021 16:20:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DD82WbwLimEkgGB+aqUxdRRvDUvC5eko9EPcFoU6FmI=; b=AhJ3Do4G3wf9WT1ezdE5nzrmWxhISeH0AOiqeZyU4KSH/W7Bjk28ABCdvJfF1hfnU4 fIkxC1K0Xvf8BWqtvZIAE0DLEGHqdrieVTBtQ7um3kKRaQKYpewbhiqzZKqejxVHJJk9 hb3CBDYze1eqI425iw2jJ18TzM4y4lCGN347X+HF7ELktKgrfTvPookXs/roaNp/jnSA vhRWBWd3ZkTuEfKIL3hGeknD/CaWnoVVL/BrJnMaINHr0OdKLQpQV0ZPyr6CWP6U6h7m jCNwEmWYURz3l9mel7VAz7NeEty3YOxAAqv82kmSH9PAWuCABkBHqS6HFTOEg01s43Ap L0yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DD82WbwLimEkgGB+aqUxdRRvDUvC5eko9EPcFoU6FmI=; b=ao/dCpObfbeiNJrWwKbZhuXqBE1XhqSqrk4fFisgEPmpZisEZR1za8Yw8vSSSSKZGh a3FIw50PJWCGVWpAtusfDXX3zjSoCQQB2f2PQbVJ1DE+8l6vmCYpK2Nqc622ZHtFkDBL 8bGyGpfqyCVRIpaUDwbWfluuNqu8jZPq/8ee0UznwGyjKFBNPq0hH6dLdPF+HiP4d4Zx K297/X3Dxmsh/Nam/wpVAYmsJB6jR40xZE8uRp9oViVcdZHNoMVNUAOsVGXm2gYHiO6q 8uvBcNrhE2eGk8+Y0ENFiY4GZ4/ZzrFLAxJGrnnDrpJGrfGcY0CAU9qgtMcpe/XnAquY Skyw== X-Gm-Message-State: AOAM530e2MgLu4fbQCYdUyeXdiAwxMFh7cJVBs6F7LIdc6VhTi+hF3gF poABL5OSERihcnIedz1qDVOZ7A== X-Received: by 2002:a05:6808:21a1:: with SMTP id be33mr10295809oib.161.1634340024131; Fri, 15 Oct 2021 16:20:24 -0700 (PDT) Received: from localhost.localdomain ([2600:1700:a0:3dc8:205:1bff:fec0:b9b3]) by smtp.gmail.com with ESMTPSA id a6sm1233150ooi.3.2021.10.15.16.20.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Oct 2021 16:20:23 -0700 (PDT) From: Bjorn Andersson To: Rob Clark , Dmitry Baryshkov Cc: Sean Paul , David Airlie , Daniel Vetter , Abhinav Kumar , Stephen Boyd , Kuogee Hsieh , Guenter Roeck , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] drm/msm/dp: Use the connector passed to dp_debug_get() Date: Fri, 15 Oct 2021 16:22:13 -0700 Message-Id: <20211015232213.1839472-1-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The debugfs code is provided an array of a single drm_connector. Then to access the connector, the list of all connectors of the DRM device is traversed and all non-DisplayPort connectors are skipped, to find the one and only DisplayPort connector. But as we move to support multiple DisplayPort controllers this will now find multiple connectors and has no way to distinguish them. Pass the single connector to dp_debug_get() and use this in the debugfs functions instead, both to simplify the code and the support the multiple instances. Reviewed-by: Abhinav Kumar Reviewed-by: Stephen Boyd Signed-off-by: Bjorn Andersson --- Changes since v1: - Reduce the indirection in the !DEBUG_FS stub function in dp_debug.h as well drivers/gpu/drm/msm/dp/dp_debug.c | 131 ++++++++++------------------ drivers/gpu/drm/msm/dp/dp_debug.h | 4 +- drivers/gpu/drm/msm/dp/dp_display.c | 2 +- 3 files changed, 47 insertions(+), 90 deletions(-) -- 2.29.2 diff --git a/drivers/gpu/drm/msm/dp/dp_debug.c b/drivers/gpu/drm/msm/dp/dp_debug.c index af709d93bb9f..da4323556ef3 100644 --- a/drivers/gpu/drm/msm/dp/dp_debug.c +++ b/drivers/gpu/drm/msm/dp/dp_debug.c @@ -24,7 +24,7 @@ struct dp_debug_private { struct dp_usbpd *usbpd; struct dp_link *link; struct dp_panel *panel; - struct drm_connector **connector; + struct drm_connector *connector; struct device *dev; struct drm_device *drm_dev; @@ -97,59 +97,35 @@ DEFINE_SHOW_ATTRIBUTE(dp_debug); static int dp_test_data_show(struct seq_file *m, void *data) { - struct drm_device *dev; - struct dp_debug_private *debug; - struct drm_connector *connector; - struct drm_connector_list_iter conn_iter; + const struct dp_debug_private *debug = m->private; + const struct drm_connector *connector = debug->connector; u32 bpc; - debug = m->private; - dev = debug->drm_dev; - drm_connector_list_iter_begin(dev, &conn_iter); - drm_for_each_connector_iter(connector, &conn_iter) { - - if (connector->connector_type != - DRM_MODE_CONNECTOR_DisplayPort) - continue; - - if (connector->status == connector_status_connected) { - bpc = debug->link->test_video.test_bit_depth; - seq_printf(m, "hdisplay: %d\n", - debug->link->test_video.test_h_width); - seq_printf(m, "vdisplay: %d\n", - debug->link->test_video.test_v_height); - seq_printf(m, "bpc: %u\n", - dp_link_bit_depth_to_bpc(bpc)); - } else - seq_puts(m, "0"); + if (connector->status == connector_status_connected) { + bpc = debug->link->test_video.test_bit_depth; + seq_printf(m, "hdisplay: %d\n", + debug->link->test_video.test_h_width); + seq_printf(m, "vdisplay: %d\n", + debug->link->test_video.test_v_height); + seq_printf(m, "bpc: %u\n", + dp_link_bit_depth_to_bpc(bpc)); + } else { + seq_puts(m, "0"); } - drm_connector_list_iter_end(&conn_iter); - return 0; } DEFINE_SHOW_ATTRIBUTE(dp_test_data); static int dp_test_type_show(struct seq_file *m, void *data) { - struct dp_debug_private *debug = m->private; - struct drm_device *dev = debug->drm_dev; - struct drm_connector *connector; - struct drm_connector_list_iter conn_iter; - - drm_connector_list_iter_begin(dev, &conn_iter); - drm_for_each_connector_iter(connector, &conn_iter) { - - if (connector->connector_type != - DRM_MODE_CONNECTOR_DisplayPort) - continue; + const struct dp_debug_private *debug = m->private; + const struct drm_connector *connector = debug->connector; - if (connector->status == connector_status_connected) - seq_printf(m, "%02x", DP_TEST_LINK_VIDEO_PATTERN); - else - seq_puts(m, "0"); - } - drm_connector_list_iter_end(&conn_iter); + if (connector->status == connector_status_connected) + seq_printf(m, "%02x", DP_TEST_LINK_VIDEO_PATTERN); + else + seq_puts(m, "0"); return 0; } @@ -161,14 +137,12 @@ static ssize_t dp_test_active_write(struct file *file, { char *input_buffer; int status = 0; - struct dp_debug_private *debug; - struct drm_device *dev; - struct drm_connector *connector; - struct drm_connector_list_iter conn_iter; + const struct dp_debug_private *debug; + const struct drm_connector *connector; int val = 0; debug = ((struct seq_file *)file->private_data)->private; - dev = debug->drm_dev; + connector = debug->connector; if (len == 0) return 0; @@ -179,30 +153,22 @@ static ssize_t dp_test_active_write(struct file *file, DRM_DEBUG_DRIVER("Copied %d bytes from user\n", (unsigned int)len); - drm_connector_list_iter_begin(dev, &conn_iter); - drm_for_each_connector_iter(connector, &conn_iter) { - if (connector->connector_type != - DRM_MODE_CONNECTOR_DisplayPort) - continue; - - if (connector->status == connector_status_connected) { - status = kstrtoint(input_buffer, 10, &val); - if (status < 0) - break; - DRM_DEBUG_DRIVER("Got %d for test active\n", val); - /* To prevent erroneous activation of the compliance - * testing code, only accept an actual value of 1 here - */ - if (val == 1) - debug->panel->video_test = true; - else - debug->panel->video_test = false; + if (connector->status == connector_status_connected) { + status = kstrtoint(input_buffer, 10, &val); + if (status < 0) { + kfree(input_buffer); + return status; } + DRM_DEBUG_DRIVER("Got %d for test active\n", val); + /* To prevent erroneous activation of the compliance + * testing code, only accept an actual value of 1 here + */ + if (val == 1) + debug->panel->video_test = true; + else + debug->panel->video_test = false; } - drm_connector_list_iter_end(&conn_iter); kfree(input_buffer); - if (status < 0) - return status; *offp += len; return len; @@ -211,25 +177,16 @@ static ssize_t dp_test_active_write(struct file *file, static int dp_test_active_show(struct seq_file *m, void *data) { struct dp_debug_private *debug = m->private; - struct drm_device *dev = debug->drm_dev; - struct drm_connector *connector; - struct drm_connector_list_iter conn_iter; - - drm_connector_list_iter_begin(dev, &conn_iter); - drm_for_each_connector_iter(connector, &conn_iter) { - if (connector->connector_type != - DRM_MODE_CONNECTOR_DisplayPort) - continue; - - if (connector->status == connector_status_connected) { - if (debug->panel->video_test) - seq_puts(m, "1"); - else - seq_puts(m, "0"); - } else + struct drm_connector *connector = debug->connector; + + if (connector->status == connector_status_connected) { + if (debug->panel->video_test) + seq_puts(m, "1"); + else seq_puts(m, "0"); + } else { + seq_puts(m, "0"); } - drm_connector_list_iter_end(&conn_iter); return 0; } @@ -278,7 +235,7 @@ static int dp_debug_init(struct dp_debug *dp_debug, struct drm_minor *minor) struct dp_debug *dp_debug_get(struct device *dev, struct dp_panel *panel, struct dp_usbpd *usbpd, struct dp_link *link, - struct drm_connector **connector, struct drm_minor *minor) + struct drm_connector *connector, struct drm_minor *minor) { int rc = 0; struct dp_debug_private *debug; diff --git a/drivers/gpu/drm/msm/dp/dp_debug.h b/drivers/gpu/drm/msm/dp/dp_debug.h index 7eaedfbb149c..8c0d0b5178fd 100644 --- a/drivers/gpu/drm/msm/dp/dp_debug.h +++ b/drivers/gpu/drm/msm/dp/dp_debug.h @@ -43,7 +43,7 @@ struct dp_debug { */ struct dp_debug *dp_debug_get(struct device *dev, struct dp_panel *panel, struct dp_usbpd *usbpd, struct dp_link *link, - struct drm_connector **connector, + struct drm_connector *connector, struct drm_minor *minor); /** @@ -60,7 +60,7 @@ void dp_debug_put(struct dp_debug *dp_debug); static inline struct dp_debug *dp_debug_get(struct device *dev, struct dp_panel *panel, struct dp_usbpd *usbpd, struct dp_link *link, - struct drm_connector **connector, struct drm_minor *minor) + struct drm_connector *connector, struct drm_minor *minor) { return ERR_PTR(-EINVAL); } diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c index 2a7239ef94d1..3aa67c53dbc0 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -1464,7 +1464,7 @@ void msm_dp_debugfs_init(struct msm_dp *dp_display, struct drm_minor *minor) dev = &dp->pdev->dev; dp->debug = dp_debug_get(dev, dp->panel, dp->usbpd, - dp->link, &dp->dp_display.connector, + dp->link, dp->dp_display.connector, minor); if (IS_ERR(dp->debug)) { rc = PTR_ERR(dp->debug);