Commit 48b6b372 authored by Lyude Paul's avatar Lyude Paul

drm/display/dp_mst: Rename drm_dp_mst_vcpi_allocation

In retrospect, the name I chose for this originally is confusing, as
there's a lot more info in here then just the VCPI. This really should be
called a payload. Let's make it more obvious that this is meant to be
related to the atomic state and is about payloads by renaming it to
drm_dp_mst_atomic_payload. Also, rename various variables throughout the
code that use atomic payloads.
Signed-off-by: default avatarLyude Paul <lyude@redhat.com>
Cc: Wayne Lin <Wayne.Lin@amd.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Fangzhi Zuo <Jerry.Zuo@amd.com>
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Imre Deak <imre.deak@intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Sean Paul <sean@poorly.run>
Acked-by: default avatarJani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220817193847.557945-4-lyude@redhat.com
parent dbaadb3c
...@@ -4370,7 +4370,7 @@ int drm_dp_atomic_find_vcpi_slots(struct drm_atomic_state *state, ...@@ -4370,7 +4370,7 @@ int drm_dp_atomic_find_vcpi_slots(struct drm_atomic_state *state,
int pbn_div) int pbn_div)
{ {
struct drm_dp_mst_topology_state *topology_state; struct drm_dp_mst_topology_state *topology_state;
struct drm_dp_vcpi_allocation *pos, *vcpi = NULL; struct drm_dp_mst_atomic_payload *pos, *payload = NULL;
int prev_slots, prev_bw, req_slots; int prev_slots, prev_bw, req_slots;
topology_state = drm_atomic_get_mst_topology_state(state, mgr); topology_state = drm_atomic_get_mst_topology_state(state, mgr);
...@@ -4378,11 +4378,11 @@ int drm_dp_atomic_find_vcpi_slots(struct drm_atomic_state *state, ...@@ -4378,11 +4378,11 @@ int drm_dp_atomic_find_vcpi_slots(struct drm_atomic_state *state,
return PTR_ERR(topology_state); return PTR_ERR(topology_state);
/* Find the current allocation for this port, if any */ /* Find the current allocation for this port, if any */
list_for_each_entry(pos, &topology_state->vcpis, next) { list_for_each_entry(pos, &topology_state->payloads, next) {
if (pos->port == port) { if (pos->port == port) {
vcpi = pos; payload = pos;
prev_slots = vcpi->vcpi; prev_slots = payload->vcpi;
prev_bw = vcpi->pbn; prev_bw = payload->pbn;
/* /*
* This should never happen, unless the driver tries * This should never happen, unless the driver tries
...@@ -4399,7 +4399,7 @@ int drm_dp_atomic_find_vcpi_slots(struct drm_atomic_state *state, ...@@ -4399,7 +4399,7 @@ int drm_dp_atomic_find_vcpi_slots(struct drm_atomic_state *state,
break; break;
} }
} }
if (!vcpi) { if (!payload) {
prev_slots = 0; prev_slots = 0;
prev_bw = 0; prev_bw = 0;
} }
...@@ -4417,17 +4417,17 @@ int drm_dp_atomic_find_vcpi_slots(struct drm_atomic_state *state, ...@@ -4417,17 +4417,17 @@ int drm_dp_atomic_find_vcpi_slots(struct drm_atomic_state *state,
port, prev_bw, pbn); port, prev_bw, pbn);
/* Add the new allocation to the state */ /* Add the new allocation to the state */
if (!vcpi) { if (!payload) {
vcpi = kzalloc(sizeof(*vcpi), GFP_KERNEL); payload = kzalloc(sizeof(*payload), GFP_KERNEL);
if (!vcpi) if (!payload)
return -ENOMEM; return -ENOMEM;
drm_dp_mst_get_port_malloc(port); drm_dp_mst_get_port_malloc(port);
vcpi->port = port; payload->port = port;
list_add(&vcpi->next, &topology_state->vcpis); list_add(&payload->next, &topology_state->payloads);
} }
vcpi->vcpi = req_slots; payload->vcpi = req_slots;
vcpi->pbn = pbn; payload->pbn = pbn;
return req_slots; return req_slots;
} }
...@@ -4464,21 +4464,21 @@ int drm_dp_atomic_release_vcpi_slots(struct drm_atomic_state *state, ...@@ -4464,21 +4464,21 @@ int drm_dp_atomic_release_vcpi_slots(struct drm_atomic_state *state,
struct drm_dp_mst_port *port) struct drm_dp_mst_port *port)
{ {
struct drm_dp_mst_topology_state *topology_state; struct drm_dp_mst_topology_state *topology_state;
struct drm_dp_vcpi_allocation *pos; struct drm_dp_mst_atomic_payload *pos;
bool found = false; bool found = false;
topology_state = drm_atomic_get_mst_topology_state(state, mgr); topology_state = drm_atomic_get_mst_topology_state(state, mgr);
if (IS_ERR(topology_state)) if (IS_ERR(topology_state))
return PTR_ERR(topology_state); return PTR_ERR(topology_state);
list_for_each_entry(pos, &topology_state->vcpis, next) { list_for_each_entry(pos, &topology_state->payloads, next) {
if (pos->port == port) { if (pos->port == port) {
found = true; found = true;
break; break;
} }
} }
if (WARN_ON(!found)) { if (WARN_ON(!found)) {
drm_err(mgr->dev, "no VCPI for [MST PORT:%p] found in mst state %p\n", drm_err(mgr->dev, "No payload for [MST PORT:%p] found in mst state %p\n",
port, &topology_state->base); port, &topology_state->base);
return -EINVAL; return -EINVAL;
} }
...@@ -5060,7 +5060,7 @@ drm_dp_mst_duplicate_state(struct drm_private_obj *obj) ...@@ -5060,7 +5060,7 @@ drm_dp_mst_duplicate_state(struct drm_private_obj *obj)
{ {
struct drm_dp_mst_topology_state *state, *old_state = struct drm_dp_mst_topology_state *state, *old_state =
to_dp_mst_topology_state(obj->state); to_dp_mst_topology_state(obj->state);
struct drm_dp_vcpi_allocation *pos, *vcpi; struct drm_dp_mst_atomic_payload *pos, *payload;
state = kmemdup(old_state, sizeof(*state), GFP_KERNEL); state = kmemdup(old_state, sizeof(*state), GFP_KERNEL);
if (!state) if (!state)
...@@ -5068,25 +5068,25 @@ drm_dp_mst_duplicate_state(struct drm_private_obj *obj) ...@@ -5068,25 +5068,25 @@ drm_dp_mst_duplicate_state(struct drm_private_obj *obj)
__drm_atomic_helper_private_obj_duplicate_state(obj, &state->base); __drm_atomic_helper_private_obj_duplicate_state(obj, &state->base);
INIT_LIST_HEAD(&state->vcpis); INIT_LIST_HEAD(&state->payloads);
list_for_each_entry(pos, &old_state->vcpis, next) { list_for_each_entry(pos, &old_state->payloads, next) {
/* Prune leftover freed VCPI allocations */ /* Prune leftover freed VCPI allocations */
if (!pos->vcpi) if (!pos->vcpi)
continue; continue;
vcpi = kmemdup(pos, sizeof(*vcpi), GFP_KERNEL); payload = kmemdup(pos, sizeof(*payload), GFP_KERNEL);
if (!vcpi) if (!payload)
goto fail; goto fail;
drm_dp_mst_get_port_malloc(vcpi->port); drm_dp_mst_get_port_malloc(payload->port);
list_add(&vcpi->next, &state->vcpis); list_add(&payload->next, &state->payloads);
} }
return &state->base; return &state->base;
fail: fail:
list_for_each_entry_safe(pos, vcpi, &state->vcpis, next) { list_for_each_entry_safe(pos, payload, &state->payloads, next) {
drm_dp_mst_put_port_malloc(pos->port); drm_dp_mst_put_port_malloc(pos->port);
kfree(pos); kfree(pos);
} }
...@@ -5100,9 +5100,9 @@ static void drm_dp_mst_destroy_state(struct drm_private_obj *obj, ...@@ -5100,9 +5100,9 @@ static void drm_dp_mst_destroy_state(struct drm_private_obj *obj,
{ {
struct drm_dp_mst_topology_state *mst_state = struct drm_dp_mst_topology_state *mst_state =
to_dp_mst_topology_state(state); to_dp_mst_topology_state(state);
struct drm_dp_vcpi_allocation *pos, *tmp; struct drm_dp_mst_atomic_payload *pos, *tmp;
list_for_each_entry_safe(pos, tmp, &mst_state->vcpis, next) { list_for_each_entry_safe(pos, tmp, &mst_state->payloads, next) {
/* We only keep references to ports with non-zero VCPIs */ /* We only keep references to ports with non-zero VCPIs */
if (pos->vcpi) if (pos->vcpi)
drm_dp_mst_put_port_malloc(pos->port); drm_dp_mst_put_port_malloc(pos->port);
...@@ -5135,7 +5135,7 @@ static int ...@@ -5135,7 +5135,7 @@ static int
drm_dp_mst_atomic_check_mstb_bw_limit(struct drm_dp_mst_branch *mstb, drm_dp_mst_atomic_check_mstb_bw_limit(struct drm_dp_mst_branch *mstb,
struct drm_dp_mst_topology_state *state) struct drm_dp_mst_topology_state *state)
{ {
struct drm_dp_vcpi_allocation *vcpi; struct drm_dp_mst_atomic_payload *payload;
struct drm_dp_mst_port *port; struct drm_dp_mst_port *port;
int pbn_used = 0, ret; int pbn_used = 0, ret;
bool found = false; bool found = false;
...@@ -5143,9 +5143,9 @@ drm_dp_mst_atomic_check_mstb_bw_limit(struct drm_dp_mst_branch *mstb, ...@@ -5143,9 +5143,9 @@ drm_dp_mst_atomic_check_mstb_bw_limit(struct drm_dp_mst_branch *mstb,
/* Check that we have at least one port in our state that's downstream /* Check that we have at least one port in our state that's downstream
* of this branch, otherwise we can skip this branch * of this branch, otherwise we can skip this branch
*/ */
list_for_each_entry(vcpi, &state->vcpis, next) { list_for_each_entry(payload, &state->payloads, next) {
if (!vcpi->pbn || if (!payload->pbn ||
!drm_dp_mst_port_downstream_of_branch(vcpi->port, mstb)) !drm_dp_mst_port_downstream_of_branch(payload->port, mstb))
continue; continue;
found = true; found = true;
...@@ -5176,7 +5176,7 @@ static int ...@@ -5176,7 +5176,7 @@ static int
drm_dp_mst_atomic_check_port_bw_limit(struct drm_dp_mst_port *port, drm_dp_mst_atomic_check_port_bw_limit(struct drm_dp_mst_port *port,
struct drm_dp_mst_topology_state *state) struct drm_dp_mst_topology_state *state)
{ {
struct drm_dp_vcpi_allocation *vcpi; struct drm_dp_mst_atomic_payload *payload;
int pbn_used = 0; int pbn_used = 0;
if (port->pdt == DP_PEER_DEVICE_NONE) if (port->pdt == DP_PEER_DEVICE_NONE)
...@@ -5185,10 +5185,10 @@ drm_dp_mst_atomic_check_port_bw_limit(struct drm_dp_mst_port *port, ...@@ -5185,10 +5185,10 @@ drm_dp_mst_atomic_check_port_bw_limit(struct drm_dp_mst_port *port,
if (drm_dp_mst_is_end_device(port->pdt, port->mcs)) { if (drm_dp_mst_is_end_device(port->pdt, port->mcs)) {
bool found = false; bool found = false;
list_for_each_entry(vcpi, &state->vcpis, next) { list_for_each_entry(payload, &state->payloads, next) {
if (vcpi->port != port) if (payload->port != port)
continue; continue;
if (!vcpi->pbn) if (!payload->pbn)
return 0; return 0;
found = true; found = true;
...@@ -5208,7 +5208,7 @@ drm_dp_mst_atomic_check_port_bw_limit(struct drm_dp_mst_port *port, ...@@ -5208,7 +5208,7 @@ drm_dp_mst_atomic_check_port_bw_limit(struct drm_dp_mst_port *port,
return -EINVAL; return -EINVAL;
} }
pbn_used = vcpi->pbn; pbn_used = payload->pbn;
} else { } else {
pbn_used = drm_dp_mst_atomic_check_mstb_bw_limit(port->mstb, pbn_used = drm_dp_mst_atomic_check_mstb_bw_limit(port->mstb,
state); state);
...@@ -5233,25 +5233,25 @@ static inline int ...@@ -5233,25 +5233,25 @@ static inline int
drm_dp_mst_atomic_check_vcpi_alloc_limit(struct drm_dp_mst_topology_mgr *mgr, drm_dp_mst_atomic_check_vcpi_alloc_limit(struct drm_dp_mst_topology_mgr *mgr,
struct drm_dp_mst_topology_state *mst_state) struct drm_dp_mst_topology_state *mst_state)
{ {
struct drm_dp_vcpi_allocation *vcpi; struct drm_dp_mst_atomic_payload *payload;
int avail_slots = mst_state->total_avail_slots, payload_count = 0; int avail_slots = mst_state->total_avail_slots, payload_count = 0;
list_for_each_entry(vcpi, &mst_state->vcpis, next) { list_for_each_entry(payload, &mst_state->payloads, next) {
/* Releasing VCPI is always OK-even if the port is gone */ /* Releasing payloads is always OK-even if the port is gone */
if (!vcpi->vcpi) { if (!payload->vcpi) {
drm_dbg_atomic(mgr->dev, "[MST PORT:%p] releases all VCPI slots\n", drm_dbg_atomic(mgr->dev, "[MST PORT:%p] releases all VCPI slots\n",
vcpi->port); payload->port);
continue; continue;
} }
drm_dbg_atomic(mgr->dev, "[MST PORT:%p] requires %d vcpi slots\n", drm_dbg_atomic(mgr->dev, "[MST PORT:%p] requires %d vcpi slots\n",
vcpi->port, vcpi->vcpi); payload->port, payload->vcpi);
avail_slots -= vcpi->vcpi; avail_slots -= payload->vcpi;
if (avail_slots < 0) { if (avail_slots < 0) {
drm_dbg_atomic(mgr->dev, drm_dbg_atomic(mgr->dev,
"[MST PORT:%p] not enough VCPI slots in mst state %p (avail=%d)\n", "[MST PORT:%p] not enough VCPI slots in mst state %p (avail=%d)\n",
vcpi->port, mst_state, avail_slots + vcpi->vcpi); payload->port, mst_state, avail_slots + payload->vcpi);
return -ENOSPC; return -ENOSPC;
} }
...@@ -5284,7 +5284,7 @@ drm_dp_mst_atomic_check_vcpi_alloc_limit(struct drm_dp_mst_topology_mgr *mgr, ...@@ -5284,7 +5284,7 @@ drm_dp_mst_atomic_check_vcpi_alloc_limit(struct drm_dp_mst_topology_mgr *mgr,
int drm_dp_mst_add_affected_dsc_crtcs(struct drm_atomic_state *state, struct drm_dp_mst_topology_mgr *mgr) int drm_dp_mst_add_affected_dsc_crtcs(struct drm_atomic_state *state, struct drm_dp_mst_topology_mgr *mgr)
{ {
struct drm_dp_mst_topology_state *mst_state; struct drm_dp_mst_topology_state *mst_state;
struct drm_dp_vcpi_allocation *pos; struct drm_dp_mst_atomic_payload *pos;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_state *conn_state; struct drm_connector_state *conn_state;
struct drm_crtc *crtc; struct drm_crtc *crtc;
...@@ -5295,7 +5295,7 @@ int drm_dp_mst_add_affected_dsc_crtcs(struct drm_atomic_state *state, struct drm ...@@ -5295,7 +5295,7 @@ int drm_dp_mst_add_affected_dsc_crtcs(struct drm_atomic_state *state, struct drm
if (IS_ERR(mst_state)) if (IS_ERR(mst_state))
return -EINVAL; return -EINVAL;
list_for_each_entry(pos, &mst_state->vcpis, next) { list_for_each_entry(pos, &mst_state->payloads, next) {
connector = pos->port->connector; connector = pos->port->connector;
...@@ -5349,7 +5349,7 @@ int drm_dp_mst_atomic_enable_dsc(struct drm_atomic_state *state, ...@@ -5349,7 +5349,7 @@ int drm_dp_mst_atomic_enable_dsc(struct drm_atomic_state *state,
bool enable) bool enable)
{ {
struct drm_dp_mst_topology_state *mst_state; struct drm_dp_mst_topology_state *mst_state;
struct drm_dp_vcpi_allocation *pos; struct drm_dp_mst_atomic_payload *pos;
bool found = false; bool found = false;
int vcpi = 0; int vcpi = 0;
...@@ -5358,7 +5358,7 @@ int drm_dp_mst_atomic_enable_dsc(struct drm_atomic_state *state, ...@@ -5358,7 +5358,7 @@ int drm_dp_mst_atomic_enable_dsc(struct drm_atomic_state *state,
if (IS_ERR(mst_state)) if (IS_ERR(mst_state))
return PTR_ERR(mst_state); return PTR_ERR(mst_state);
list_for_each_entry(pos, &mst_state->vcpis, next) { list_for_each_entry(pos, &mst_state->payloads, next) {
if (pos->port == port) { if (pos->port == port) {
found = true; found = true;
break; break;
...@@ -5544,7 +5544,7 @@ int drm_dp_mst_topology_mgr_init(struct drm_dp_mst_topology_mgr *mgr, ...@@ -5544,7 +5544,7 @@ int drm_dp_mst_topology_mgr_init(struct drm_dp_mst_topology_mgr *mgr,
mst_state->start_slot = 1; mst_state->start_slot = 1;
mst_state->mgr = mgr; mst_state->mgr = mgr;
INIT_LIST_HEAD(&mst_state->vcpis); INIT_LIST_HEAD(&mst_state->payloads);
drm_atomic_private_obj_init(dev, &mgr->base, drm_atomic_private_obj_init(dev, &mgr->base,
&mst_state->base, &mst_state->base,
......
...@@ -542,7 +542,7 @@ struct drm_dp_payload { ...@@ -542,7 +542,7 @@ struct drm_dp_payload {
#define to_dp_mst_topology_state(x) container_of(x, struct drm_dp_mst_topology_state, base) #define to_dp_mst_topology_state(x) container_of(x, struct drm_dp_mst_topology_state, base)
struct drm_dp_vcpi_allocation { struct drm_dp_mst_atomic_payload {
struct drm_dp_mst_port *port; struct drm_dp_mst_port *port;
int vcpi; int vcpi;
int pbn; int pbn;
...@@ -552,7 +552,7 @@ struct drm_dp_vcpi_allocation { ...@@ -552,7 +552,7 @@ struct drm_dp_vcpi_allocation {
struct drm_dp_mst_topology_state { struct drm_dp_mst_topology_state {
struct drm_private_state base; struct drm_private_state base;
struct list_head vcpis; struct list_head payloads;
struct drm_dp_mst_topology_mgr *mgr; struct drm_dp_mst_topology_mgr *mgr;
u8 total_avail_slots; u8 total_avail_slots;
u8 start_slot; u8 start_slot;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment