From: Harry Wentland <hwentlan@amd.com>
To: mikita.lipski@amd.com, amd-gfx@lists.freedesktop.org
Cc: Jerry Zuo <Jerry.Zuo@amd.com>,
Harry Wentland <harry.wentland@amd.com>,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v8 12/17] drm/dp_mst: Add branch bandwidth validation to MST atomic check
Date: Thu, 5 Dec 2019 14:28:09 -0500 [thread overview]
Message-ID: <fa775363-1031-51c0-099e-aac2b8dda0d3@amd.com> (raw)
In-Reply-To: <20191203143530.27262-13-mikita.lipski@amd.com>
On 2019-12-03 9:35 a.m., mikita.lipski@amd.com wrote:
> From: Mikita Lipski <mikita.lipski@amd.com>
>
> Adding PBN attribute to drm_dp_vcpi_allocation structure to
> keep track of how much bandwidth each Port requires.
> Adding drm_dp_mst_atomic_check_bw_limit to verify that
> state's bandwidth needs doesn't exceed available bandwidth.
> The funtion is called in drm_dp_mst_atomic_check after
> drm_dp_mst_atomic_check_topology_state to fully verify that
> the proposed topology is supported.
>
> Cc: Jerry Zuo <Jerry.Zuo@amd.com>
> Cc: Harry Wentland <harry.wentland@amd.com>
> Cc: Lyude Paul <lyude@redhat.com>
> Signed-off-by: Mikita Lipski <mikita.lipski@amd.com>
> ---
> drivers/gpu/drm/drm_dp_mst_topology.c | 67 ++++++++++++++++++++++++++-
> include/drm/drm_dp_mst_helper.h | 1 +
> 2 files changed, 66 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
> index 5e549f48ffb8..76bcbb4cd8b4 100644
> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> @@ -4052,7 +4052,7 @@ int drm_dp_atomic_find_vcpi_slots(struct drm_atomic_state *state,
> {
> struct drm_dp_mst_topology_state *topology_state;
> struct drm_dp_vcpi_allocation *pos, *vcpi = NULL;
> - int prev_slots, req_slots;
> + int prev_slots, prev_bw, req_slots, ret;
>
'ret' is unused here.
Harry
> topology_state = drm_atomic_get_mst_topology_state(state, mgr);
> if (IS_ERR(topology_state))
> @@ -4063,6 +4063,7 @@ int drm_dp_atomic_find_vcpi_slots(struct drm_atomic_state *state,
> if (pos->port == port) {
> vcpi = pos;
> prev_slots = vcpi->vcpi;
> + prev_bw = vcpi->pbn;
>
> /*
> * This should never happen, unless the driver tries
> @@ -4078,8 +4079,10 @@ int drm_dp_atomic_find_vcpi_slots(struct drm_atomic_state *state,
> break;
> }
> }
> - if (!vcpi)
> + if (!vcpi) {
> prev_slots = 0;
> + prev_bw = 0;
> + }
>
> if (pbn_div <= 0)
> pbn_div = mgr->pbn_div;
> @@ -4089,6 +4092,9 @@ int drm_dp_atomic_find_vcpi_slots(struct drm_atomic_state *state,
> DRM_DEBUG_ATOMIC("[CONNECTOR:%d:%s] [MST PORT:%p] VCPI %d -> %d\n",
> port->connector->base.id, port->connector->name,
> port, prev_slots, req_slots);
> + DRM_DEBUG_ATOMIC("[CONNECTOR:%d:%s] [MST PORT:%p] PBN %d -> %d\n",
> + port->connector->base.id, port->connector->name,
> + port, prev_bw, pbn);
>
> /* Add the new allocation to the state */
> if (!vcpi) {
> @@ -4101,6 +4107,7 @@ int drm_dp_atomic_find_vcpi_slots(struct drm_atomic_state *state,
> list_add(&vcpi->next, &topology_state->vcpis);
> }
> vcpi->vcpi = req_slots;
> + vcpi->pbn = pbn;
>
> return req_slots;
> }
> @@ -4703,6 +4710,59 @@ static void drm_dp_mst_destroy_state(struct drm_private_obj *obj,
> kfree(mst_state);
> }
>
> +static bool drm_dp_mst_port_downstream_of_branch(struct drm_dp_mst_port *port,
> + struct drm_dp_mst_branch *branch)
> +{
> + while (port->parent) {
> + if (port->parent == branch)
> + return true;
> +
> + if (port->parent->port_parent)
> + port = port->parent->port_parent;
> + else
> + break;
> + }
> + return false;
> +}
> +
> +static inline
> +int drm_dp_mst_atomic_check_bw_limit(struct drm_dp_mst_branch *branch,
> + struct drm_dp_mst_topology_state *mst_state)
> +{
> + struct drm_dp_mst_port *port;
> + struct drm_dp_vcpi_allocation *vcpi;
> + int pbn_limit = 0, pbn_used = 0;
> +
> + list_for_each_entry(port, &branch->ports, next) {
> + if (port->mstb) {
> + if (drm_dp_mst_atomic_check_bw_limit(port->mstb, mst_state))
> + return -EINVAL;
> + }
> + if (port->available_pbn > 0)
> + pbn_limit = port->available_pbn;
> + }
> + DRM_DEBUG_ATOMIC("[MST BRANCH:%p] branch has %d PBN available\n",
> + branch,
> + pbn_limit);
> +
> + list_for_each_entry(vcpi, &mst_state->vcpis, next) {
> + if (!vcpi->pbn)
> + continue;
> +
> + if (drm_dp_mst_port_downstream_of_branch(vcpi->port, branch))
> + pbn_used += vcpi->pbn;
> + }
> + DRM_DEBUG_ATOMIC("[MST BRANCH:%p] branch used %d PBN\n",
> + branch,
> + pbn_used);
> + if (pbn_used > pbn_limit) {
> + DRM_DEBUG_ATOMIC("[MST BRANCH:%p] No available bandwidth\n",
> + branch);
> + return -EINVAL;
> + }
> + return 0;
> +}
> +
> static inline int
> drm_dp_mst_atomic_check_topology_state(struct drm_dp_mst_topology_mgr *mgr,
> struct drm_dp_mst_topology_state *mst_state)
> @@ -4834,6 +4894,9 @@ int drm_dp_mst_atomic_check(struct drm_atomic_state *state)
> ret = drm_dp_mst_atomic_check_topology_state(mgr, mst_state);
> if (ret)
> break;
> + ret = drm_dp_mst_atomic_check_bw_limit(mgr->mst_primary, mst_state);
> + if (ret)
> + break;
> }
>
> return ret;
> diff --git a/include/drm/drm_dp_mst_helper.h b/include/drm/drm_dp_mst_helper.h
> index 830c94b7f45d..2919d9776af3 100644
> --- a/include/drm/drm_dp_mst_helper.h
> +++ b/include/drm/drm_dp_mst_helper.h
> @@ -502,6 +502,7 @@ struct drm_dp_payload {
> struct drm_dp_vcpi_allocation {
> struct drm_dp_mst_port *port;
> int vcpi;
> + int pbn;
> bool dsc_enabled;
> struct list_head next;
> };
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2019-12-05 19:28 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-03 14:35 [PATCH v8 00/17] DSC MST support for DRM and AMDGPU mikita.lipski
2019-12-03 14:35 ` [PATCH v8 01/17] drm/dp_mst: Add PBN calculation for DSC modes mikita.lipski
2019-12-06 0:22 ` kbuild test robot
2019-12-07 0:17 ` Lyude Paul
2019-12-07 22:13 ` Lipski, Mikita
2019-12-03 14:35 ` [PATCH v8 02/17] drm/dp_mst: Parse FEC capability on MST ports mikita.lipski
2019-12-03 21:09 ` kbuild test robot
2019-12-03 14:35 ` [PATCH v8 03/17] drm/dp_mst: Add MST support to DP DPCD R/W functions mikita.lipski
2019-12-03 14:35 ` [PATCH v8 04/17] drm/dp_mst: Fill branch->num_ports mikita.lipski
2019-12-06 4:30 ` Harry Wentland
2019-12-03 14:35 ` [PATCH v8 05/17] drm/dp_mst: Add helpers for MST DSC and virtual DPCD aux mikita.lipski
2019-12-03 14:35 ` [PATCH v8 06/17] drm/dp_mst: Add new quirk for Synaptics MST hubs mikita.lipski
2019-12-03 14:35 ` [PATCH v8 07/17] drm/amd/display: Initialize DSC PPS variables to 0 mikita.lipski
2019-12-03 14:35 ` [PATCH v8 08/17] drm/amd/display: Validate DSC caps on MST endpoints mikita.lipski
2019-12-03 14:35 ` [PATCH v8 09/17] drm/amd/display: Write DSC enable to MST DPCD mikita.lipski
2019-12-03 14:35 ` [PATCH v8 10/17] drm/dp_mst: Manually overwrite PBN divider for calculating timeslots mikita.lipski
2019-12-03 14:35 ` [PATCH v8 11/17] drm/dp_mst: Add DSC enablement helpers to DRM mikita.lipski
2019-12-03 21:52 ` kbuild test robot
2019-12-07 0:24 ` Lyude Paul
2019-12-09 14:07 ` Mikita Lipski
2019-12-03 14:35 ` [PATCH v8 12/17] drm/dp_mst: Add branch bandwidth validation to MST atomic check mikita.lipski
2019-12-05 19:28 ` Harry Wentland [this message]
2019-12-07 0:30 ` Lyude Paul
2019-12-03 14:35 ` [PATCH v8 13/17] drm/amd/display: Add PBN per slot calculation for DSC mikita.lipski
2019-12-03 14:35 ` [PATCH v8 14/17] drm/amd/display: MST DSC compute fair share mikita.lipski
2019-12-07 0:53 ` Lyude Paul
2019-12-03 14:35 ` [PATCH v8 15/17] drm/amd/display: Recalculate VCPI slots for new DSC connectors mikita.lipski
2019-12-07 0:52 ` Lyude Paul
2019-12-03 14:35 ` [PATCH v8 16/17] drm/dp_mst: Add helper to trigger modeset on affected DSC MST CRTCs mikita.lipski
2019-12-03 22:40 ` kbuild test robot
2019-12-07 0:51 ` Lyude Paul
2019-12-03 14:35 ` [PATCH v8 17/17] drm/amd/display: Trigger modesets on MST DSC connectors mikita.lipski
2019-12-07 0:53 ` Lyude Paul
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=fa775363-1031-51c0-099e-aac2b8dda0d3@amd.com \
--to=hwentlan@amd.com \
--cc=Jerry.Zuo@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=harry.wentland@amd.com \
--cc=mikita.lipski@amd.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox