From: Lyude Paul <lyude@redhat.com>
To: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
nouveau@lists.freedesktop.org
Subject: [PATCH 1/6] drm/dp_mst: Add drm_dp_get_payload_info()
Date: Fri, 16 Nov 2018 19:21:15 -0500 [thread overview]
Message-ID: <20181117002120.28703-2-lyude@redhat.com> (raw)
In-Reply-To: <20181117002120.28703-1-lyude@redhat.com>
Some hardware (nvidia hardware in particular) needs to be notified of
the exact VCPI and payload settings that the topology manager decided on
for each mstb port. Since there isn't currently any way to get this
information without going through port (which drivers are very much not
supposed to do by themselves, ever), let's add one.
Signed-off-by: Lyude Paul <lyude@redhat.com>
---
drivers/gpu/drm/drm_dp_mst_topology.c | 56 +++++++++++++++++++++++++++
include/drm/drm_dp_mst_helper.h | 5 ++-
2 files changed, 60 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
index 529414556962..4336d17ce904 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -1982,6 +1982,62 @@ int drm_dp_update_payload_part2(struct drm_dp_mst_topology_mgr *mgr)
}
EXPORT_SYMBOL(drm_dp_update_payload_part2);
+/**
+ * drm_dp_get_payload_info() - Retrieve payload/vcpi information for the given
+ * @port
+ * @mgr: manager to use
+ * @port: the port to get the relevant payload information for
+ * @vcpi_out: where to copy the port's VCPI information to
+ * @payload_out: where to copy the port's payload information to
+ *
+ * Searches the current payloads for @mgr and finds the relevant payload and
+ * VCPI information that was programmed by the topology mgr, then copies it
+ * into @vcpi_out and @payload_out. Drivers which need to know this
+ * information must use this helper as opposed to checking @port themselves,
+ * as this helper will ensure the port reference is still valid and grab the
+ * appropriate locks in @mgr.
+ *
+ * Returns:
+ * 0 on success, negative error code if the port is no longer valid or a
+ * programmed payload could not be found for @port.
+ */
+int drm_dp_get_payload_info(struct drm_dp_mst_topology_mgr *mgr,
+ struct drm_dp_mst_port *port,
+ struct drm_dp_vcpi *vcpi_out,
+ struct drm_dp_payload *payload_out)
+{
+ struct drm_dp_payload *payload = NULL;
+ int i;
+ int ret = 0;
+
+ port = drm_dp_get_validated_port_ref(mgr, port);
+ if (!port)
+ return -EINVAL;
+
+ mutex_lock(&mgr->payload_lock);
+ /* Figure out which of the payloads belongs to this port */
+ for (i = 0; i < mgr->max_payloads; i++) {
+ if (mgr->payloads[i].vcpi == port->vcpi.vcpi) {
+ payload = &mgr->payloads[i];
+ break;
+ }
+ }
+
+ if (!payload) {
+ DRM_DEBUG_KMS("Failed to find payload for port %p\n", port);
+ ret = -EINVAL;
+ goto out;
+ }
+
+ *payload_out = *payload;
+ *vcpi_out = port->vcpi;
+out:
+ mutex_unlock(&mgr->payload_lock);
+ drm_dp_put_port(port);
+ return ret;
+}
+EXPORT_SYMBOL(drm_dp_get_payload_info);
+
#if 0 /* unused as of yet */
static int drm_dp_send_dpcd_read(struct drm_dp_mst_topology_mgr *mgr,
struct drm_dp_mst_port *port,
diff --git a/include/drm/drm_dp_mst_helper.h b/include/drm/drm_dp_mst_helper.h
index 59f005b419cf..9cc93ea60e7e 100644
--- a/include/drm/drm_dp_mst_helper.h
+++ b/include/drm/drm_dp_mst_helper.h
@@ -592,7 +592,10 @@ bool drm_dp_mst_allocate_vcpi(struct drm_dp_mst_topology_mgr *mgr,
struct drm_dp_mst_port *port, int pbn, int slots);
int drm_dp_mst_get_vcpi_slots(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port);
-
+int drm_dp_get_payload_info(struct drm_dp_mst_topology_mgr *mgr,
+ struct drm_dp_mst_port *port,
+ struct drm_dp_vcpi *vcpi_out,
+ struct drm_dp_payload *payload_out);
void drm_dp_mst_reset_vcpi_slots(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port);
--
2.19.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2018-11-17 0:21 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-17 0:21 [PATCH 0/6] Remove all bad dp_mst_port uses and hide struct def Lyude Paul
2018-11-17 0:21 ` Lyude Paul [this message]
[not found] ` <20181117002120.28703-2-lyude-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2018-11-27 21:23 ` [PATCH 1/6] drm/dp_mst: Add drm_dp_get_payload_info() Daniel Vetter
2018-11-27 21:28 ` [Nouveau] " Lyude Paul
2018-11-17 0:21 ` [PATCH 3/6] drm/nouveau: Stop reading port->mgr in nv50_mstc_get_modes() Lyude Paul
2018-11-17 12:24 ` Sasha Levin
2018-11-17 12:24 ` Sasha Levin
2018-11-17 0:21 ` [PATCH 4/6] drm/nouveau: Stop reading port->mgr in nv50_mstc_detect() Lyude Paul
2018-11-17 12:24 ` Sasha Levin
2018-11-17 12:24 ` Sasha Levin
2018-11-27 18:28 ` Lyude Paul
2018-11-17 0:21 ` [PATCH 6/6] drm/i915: Start using struct drm_dp_mst_port again Lyude Paul
2018-11-17 0:52 ` ✓ Fi.CI.BAT: success for Remove all bad dp_mst_port uses and hide struct def Patchwork
2018-11-17 10:08 ` ✓ Fi.CI.IGT: " Patchwork
[not found] ` <20181117002120.28703-1-lyude-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2018-11-17 0:21 ` [PATCH 2/6] drm/nouveau: Use drm_dp_get_payload_info() for getting payload/vcpi Lyude Paul
2018-11-17 0:21 ` [PATCH 5/6] drm/dp_mst: Hide drm_dp_mst_port contents from drivers Lyude Paul
2018-11-24 15:55 ` [PATCH 0/6] Remove all bad dp_mst_port uses and hide struct def Karol Herbst
2018-11-27 22:17 ` Ben Skeggs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181117002120.28703-2-lyude@redhat.com \
--to=lyude@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=nouveau@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.