DSC MST support for AMDGPU
Subsystems (6)
cover DSC MST support for AMDGPU
From: Mikita Lipski <[email protected]>
This set of patches is a continuation of DSC enablement patches for AMDGPU. This set enables DSC on MST.
First 3 patches add atomic check functionality to encoder and connector to allocate and release VCPI slots on each state atomic check. These changes utilize newly added drm_mst_helper functions for better tracking of VCPI slots.
Other 12 patches have been introduced in multiple iterations to the mailing list before. These patches were developed by David Francis as part of his work on DSC.
David Francis (12):
drm/dp_mst: Add PBN calculation for DSC modes drm/dp_mst: Parse FEC capability on MST ports drm/dp_mst: Add MST support to DP DPCD R/W functions drm/dp_mst: Fill branch->num_ports
drm/dp_mst: Add helpers for MST DSC and virtual DPCD aux drm/dp_mst: Add new quirk for Synaptics MST hubs drm/amd/display: Use correct helpers to compute timeslots drm/amd/display: Initialize DSC PPS variables to 0 drm/amd/display: Validate DSC caps on MST endpoints drm/amd/display: Write DSC enable to MST DPCD drm/amd/display: MST DSC compute fair share drm/amd/display: Trigger modesets on MST DSC connectors
Mikita Lipski (3):
drm/amdgpu: Add encoder atomic check drm/amdgpu: Add connector atomic check drm/amdgpu: validate mst topology in atomic check
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 153 ++++++ .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 3 + .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 37 +- .../display/amdgpu_dm/amdgpu_dm_mst_types.c | 451 +++++++++++++++++- .../display/amdgpu_dm/amdgpu_dm_mst_types.h | 4 + .../drm/amd/display/dc/core/dc_link_hwss.c | 3 + .../gpu/drm/amd/display/dc/dcn20/dcn20_dsc.c | 3 + .../drm/amd/display/dc/dcn20/dcn20_resource.c | 7 +- .../drm/amd/display/dc/dcn20/dcn20_resource.h | 1 + drivers/gpu/drm/drm_dp_aux_dev.c | 12 +- drivers/gpu/drm/drm_dp_helper.c | 34 +- drivers/gpu/drm/drm_dp_mst_topology.c | 174 ++++++- drivers/gpu/drm/i915/intel_dp_mst.c | 3 +- drivers/gpu/drm/nouveau/dispnv50/disp.c | 3 +- drivers/gpu/drm/radeon/radeon_dp_mst.c | 2 +- include/drm/drm_dp_helper.h | 7 + include/drm/drm_dp_mst_helper.h | 8 +- 17 files changed, 866 insertions(+), 39 deletions(-)
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 1/15 drm/amdgpu: Add encoder atomic check
In reply to a message not in the archiveFrom: Mikita Lipski <[email protected]>
[why]
In order to comply with new MST atomic check we have to find and add VCPI slots to the state during atomic check whenever their is a change on mode or connector.
[how]
- Verify that it is a MST connection
- Convert new stream's clock and bpp
- Calculate PBN based on stream parameters
- Find and add VCPI slots to the state
--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +59 -0
@@ -4432,6 +4432,65 @@ static int dm_encoder_helper_atomic_check(struct drm_encoder *encoder,struct drm_crtc_state *crtc_state, struct drm_connector_state *conn_state) { + struct drm_atomic_state *state = crtc_state->state; +struct drm_connector *connector = conn_state->connector; +struct amdgpu_dm_connector *aconnector =to_amdgpu_dm_connector (connector); +struct dm_crtc_state *dm_new_crtc_state =to_dm_crtc_state (crtc_state); +const struct drm_display_mode *adjusted_mode = &crtc_state->adjusted_mode; +struct drm_dp_mst_topology_mgr *mst_mgr; +struct drm_dp_mst_port *mst_port; +int pbn, slots,clock, bpp =0 ; + +if (!dm_new_crtc_state) +return 0 ; + +if (!aconnector || !aconnector->port) +return 0 ; + + mst_port = aconnector->port; + mst_mgr = &aconnector->mst_port->mst_mgr; + +if (!mst_mgr->mst_state) +return 0 ; + +if (!crtc_state->connectors_changed && !crtc_state->mode_changed) +return 0 ; + +switch (convert_color_depth_from_display_info (connector, conn_state)) { +case COLOR_DEPTH_666 : + bpp =6 ; +break ; +case COLOR_DEPTH_888 : + bpp =8 ; +break ; +case COLOR_DEPTH_101010 : + bpp =10 ; +break ; +case COLOR_DEPTH_121212 : + bpp =12 ; +break ; +case COLOR_DEPTH_141414 : + bpp =14 ; +break ; +case COLOR_DEPTH_161616 : + bpp =16 ; +break ; +default : +ASSERT (bpp !=0 ); +break ; + } + + bpp *=3 ; + clock = adjusted_mode->clock; + pbn =drm_dp_calc_pbn_mode (clock, bpp); + slots =drm_dp_atomic_find_vcpi_slots (state, + mst_mgr, + mst_port, + pbn); +if (slots <0 ) { +DRM_DEBUG_KMS ("failed finding vcpi slots:%d\n" , slots); +return slots; + }return 0 ; }
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/15 drm/amdgpu: Add connector atomic check
In reply to [email protected]From: Mikita Lipski <[email protected]>
[why]
Complying with new MST atomic check requirements. The driver needs to call this function on every atomic check to reset the VCPI slots if new state disables
[how]
- Verify that it is a MST connection
- Verify that old crtc state exists
- Verify the new crtc state disables sink
- Release VCPI slots on the port
--- .../display/amdgpu_dm/amdgpu_dm_mst_types.c | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +34 -0
@@ -252,10 +252,44 @@ static struct drm_encoder *dm_mst_best_encoder(struct drm_connector *connector)return &amdgpu_dm_connector->mst_encoder->base; } +static int dm_dp_mst_atomic_check (struct drm_connector *connector, +struct drm_connector_state *new_conn_state) +{ +struct drm_atomic_state *state = new_conn_state->state; +struct drm_connector_state *old_conn_state = +drm_atomic_get_old_connector_state (state, connector); +struct amdgpu_dm_connector *aconnector =to_amdgpu_dm_connector (connector); +struct drm_crtc_state *new_crtc_state; +struct drm_dp_mst_topology_mgr *mst_mgr; +struct drm_dp_mst_port *mst_port; + +if (!aconnector || !aconnector->port) +return 0 ; + + mst_port = aconnector->port; + mst_mgr = &aconnector->mst_port->mst_mgr; + +if (!old_conn_state->crtc) +return 0 ; + +if (new_conn_state->crtc) { + new_crtc_state =drm_atomic_get_old_crtc_state (state, new_conn_state->crtc); +if (!new_crtc_state || + !drm_atomic_crtc_needs_modeset (new_crtc_state) || + new_crtc_state->enable) +return 0 ; + } + +return drm_dp_atomic_release_vcpi_slots (state, + mst_mgr, + mst_port); +} +static const struct drm_connector_helper_funcs dm_dp_mst_connector_helper_funcs = { .get_modes = dm_dp_mst_get_modes, .mode_valid = amdgpu_dm_connector_mode_valid, .best_encoder = dm_mst_best_encoder, + .atomic_check = dm_dp_mst_atomic_check, };static void amdgpu_dm_encoder_destroy (struct drm_encoder *encoder)
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/15 drm/amdgpu: validate mst topology in atomic check
In reply to a message not in the archiveFrom: Mikita Lipski <[email protected]>
[why]
Validate mst topology and the number of VCPI slots available for a new state. Fail if topology has no more bandwidth for a new state.
[how]
Pass the atomic state to drm_dp_mst_atomic_check to verify if the new topology is possible.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +5 -0
@@ -7485,6 +7485,11 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,if (ret) goto fail; +/* Perform validation of MST topology in the state*/ + ret =drm_dp_mst_atomic_check (state); +if (ret) + goto fail; +if (state->legacy_cursor_update) {/* * This is a fast cursor update coming from the plane update
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/15 drm/dp_mst: Add PBN calculation for DSC modes
In reply to a message not in the archiveFrom: David Francis <[email protected]>
With DSC, bpp can be fractional in multiples of 1/16.
Change drm_dp_calc_pbn_mode to reflect this, adding a new parameter bool dsc. When this parameter is true, treat the bpp parameter as having units not of bits per pixel, but 1/16 of a bit per pixel
v2: Don't add separate function for this
--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 8 +++++++- .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 2 +- drivers/gpu/drm/drm_dp_mst_topology.c | 16 ++++++++++++---- drivers/gpu/drm/i915/intel_dp_mst.c | 3 ++- drivers/gpu/drm/nouveau/dispnv50/disp.c | 3 ++- drivers/gpu/drm/radeon/radeon_dp_mst.c | 2 +- include/drm/drm_dp_mst_helper.h | 3 +-- 7 files changed, 26 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +7 -1
@@ -4482,7 +4482,13 @@ static int dm_encoder_helper_atomic_check(struct drm_encoder *encoder, bpp *=3 ; clock = adjusted_mode->clock; - pbn =drm_dp_calc_pbn_mode (clock, bpp); +#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT +if (aconnector->dc_sink && + aconnector->dc_sink->sink_dsc_caps.dsc_dec_caps.is_dsc_supported) + pbn =drm_dp_calc_pbn_mode (clock, bpp, true); + else +#endif + pbn =drm_dp_calc_pbn_mode (clock, bpp, false); slots = drm_dp_atomic_find_vcpi_slots(state, mst_mgr, mst_port,
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +1 -1
@@ -235,7 +235,7 @@ bool dm_helpers_dp_mst_write_payload_allocation_table(/* TODO need to know link rate */ - pbn =drm_dp_calc_pbn_mode (clock, bpp); + pbn =drm_dp_calc_pbn_mode (clock, bpp, false); slots =drm_dp_find_vcpi_slots (mst_mgr, pbn); ret =drm_dp_mst_allocate_vcpi (mst_mgr, mst_port, pbn, slots);
drivers/gpu/drm/drm_dp_mst_topology.c +12 -4
@@ -3531,10 +3531,11 @@ EXPORT_SYMBOL(drm_dp_check_act_status);* drm_dp_calc_pbn_mode() - Calculate the PBN for a mode. * @clock: dot clock for the mode * @bpp: bpp for the mode. +* @dsc: DSC mode. If true, bpp has units of 1/16 of a bit per pixel * * This uses the formula in the spec to calculate the PBN value for a mode. */ -int drm_dp_calc_pbn_mode (int clock,int bpp) +int drm_dp_calc_pbn_mode (int clock,int bpp,bool dsc) {u64 kbps;s64 peak_kbps;
@@ -3552,11 +3553,18 @@ int drm_dp_calc_pbn_mode(int clock, int bpp)* peak_kbps *= (1006/1000) * peak_kbps *= (64/54) * peak_kbps *= 8 convert to bytes +* +* If the bpp is in units of 1/16, further divide by 16. Put this +* factor in the numerator rather than the denominator to avoid +* integer overflow */ numerator =64 *1006 ; denominator =54 *8 *1000 *1000 ; +if (dsc) + numerator /=16 ; + kbps *= numerator; peak_kbps =drm_fixp_from_fraction (kbps, denominator);
@@ -3567,19 +3575,19 @@ EXPORT_SYMBOL(drm_dp_calc_pbn_mode);static int test_calc_pbn_mode (void ) {int ret; - ret =drm_dp_calc_pbn_mode (154000 ,30 ); + ret =drm_dp_calc_pbn_mode (154000 ,30 , false);if (ret !=689 ) {DRM_ERROR ("PBN calculation test failed - clock %d, bpp %d, expected PBN %d, actual PBN %d.\n" ,154000 ,30 ,689 , ret);return -EINVAL ; } - ret =drm_dp_calc_pbn_mode (234000 ,30 ); + ret =drm_dp_calc_pbn_mode (234000 ,30 , false);if (ret !=1047 ) {DRM_ERROR ("PBN calculation test failed - clock %d, bpp %d, expected PBN %d, actual PBN %d.\n" ,234000 ,30 ,1047 , ret);return -EINVAL ; } - ret =drm_dp_calc_pbn_mode (297000 ,24 ); + ret =drm_dp_calc_pbn_mode (297000 ,24 , false);if (ret !=1063 ) {DRM_ERROR ("PBN calculation test failed - clock %d, bpp %d, expected PBN %d, actual PBN %d.\n" ,297000 ,24 ,1063 , ret);
drivers/gpu/drm/i915/intel_dp_mst.c +2 -1
@@ -58,7 +58,8 @@ static int intel_dp_mst_compute_link_config(struct intel_encoder *encoder, crtc_state->pipe_bpp = bpp; crtc_state->pbn =drm_dp_calc_pbn_mode (adjusted_mode->crtc_clock, - crtc_state->pipe_bpp); + crtc_state->pipe_bpp, + false); slots =drm_dp_atomic_find_vcpi_slots (state, &intel_dp->mst_mgr, port, crtc_state->pbn);
drivers/gpu/drm/nouveau/dispnv50/disp.c +2 -1
@@ -773,7 +773,8 @@ nv50_msto_atomic_check(struct drm_encoder *encoder,if (!state->duplicated) asyh->dp.pbn =drm_dp_calc_pbn_mode (crtc_state->adjusted_mode.clock, - connector->display_info.bpc *3 ); + connector->display_info.bpc *3 , + false);if (drm_atomic_crtc_needs_modeset (crtc_state)) { slots = drm_dp_atomic_find_vcpi_slots(state, &mstm->mgr,
drivers/gpu/drm/radeon/radeon_dp_mst.c +1 -1
@@ -513,7 +513,7 @@ static bool radeon_mst_mode_fixup(struct drm_encoder *encoder, mst_enc = radeon_encoder->enc_priv; - mst_enc->pbn =drm_dp_calc_pbn_mode (adjusted_mode->clock, bpp); + mst_enc->pbn =drm_dp_calc_pbn_mode (adjusted_mode->clock, bpp, false); mst_enc->primary->active_device = mst_enc->primary->devices & mst_enc->connector->devices; DRM_DEBUG_KMS("setting active device to %08x from %08x %08x for encoder %d\n",
include/drm/drm_dp_mst_helper.h +1 -2
@@ -610,8 +610,7 @@ bool drm_dp_mst_port_has_audio(struct drm_dp_mst_topology_mgr *mgr,struct edid *drm_dp_mst_get_edid (struct drm_connector *connector,struct drm_dp_mst_topology_mgr *mgr,struct drm_dp_mst_port *port); -int drm_dp_calc_pbn_mode (int clock,int bpp); - +int drm_dp_calc_pbn_mode (int clock,int bpp,bool dsc);bool drm_dp_mst_allocate_vcpi (struct drm_dp_mst_topology_mgr *mgr,struct drm_dp_mst_port *port,int pbn,int slots);
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 5/15 drm/dp_mst: Parse FEC capability on MST ports
In reply to a message not in the archiveFrom: David Francis <[email protected]>
As of DP1.4, ENUM_PATH_RESOURCES returns a bit indicating if FEC can be supported up to that point in the MST network.
The bit is the first byte of the ENUM_PATH_RESOURCES ack reply, bottom-most bit (refer to section 2.11.9.4 of DP standard, v1.4)
That value is needed for FEC and DSC support
Store it on drm_dp_mst_port
--- drivers/gpu/drm/drm_dp_mst_topology.c | 2 ++ include/drm/drm_dp_mst_helper.h | 3 +++ 2 files changed, 5 insertions(+)
drivers/gpu/drm/drm_dp_mst_topology.c +2 -0
@@ -552,6 +552,7 @@ static bool drm_dp_sideband_parse_enum_path_resources_ack(struct drm_dp_sideband {int idx =1 ; repmsg->u.path_resources.port_number = (raw->msg[idx] >>4 ) &0xf ; + repmsg->u.path_resources.fec_capable = raw->msg[idx] &0x1 ; idx++;if (idx > raw->curlen) goto fail_len;
@@ -2180,6 +2181,7 @@ static int drm_dp_send_enum_path_resources(struct drm_dp_mst_topology_mgr *mgr,DRM_DEBUG_KMS ("enum path resources %d: %d %d\n" , txmsg->reply.u.path_resources.port_number, txmsg->reply.u.path_resources.full_payload_bw_number, txmsg->reply.u.path_resources.avail_payload_bw_number); port->available_pbn = txmsg->reply.u.path_resources.avail_payload_bw_number; + port->fec_capable = txmsg->reply.u.path_resources.fec_capable; } }
include/drm/drm_dp_mst_helper.h +3 -0
@@ -108,6 +108,8 @@ struct drm_dp_mst_port {* audio-capable. */ bool has_audio; + +bool fec_capable; };/**
@@ -312,6 +314,7 @@ struct drm_dp_port_number_req {struct drm_dp_enum_path_resources_ack_reply {u8 port_number; +bool fec_capable;u16 full_payload_bw_number;u16 avail_payload_bw_number; };
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 6/15 drm/dp_mst: Add MST support to DP DPCD R/W functions
In reply to a message not in the archiveFrom: David Francis <[email protected]>
Instead of having drm_dp_dpcd_read/write and drm_dp_mst_dpcd_read/write as entry points into the aux code, have drm_dp_dpcd_read/write handle both.
This means that DRM drivers can make MST DPCD read/writes.
v2: Fix spacing
v3: Dump dpcd access on MST read/writes
--- drivers/gpu/drm/drm_dp_aux_dev.c | 12 ++---------- drivers/gpu/drm/drm_dp_helper.c | 30 ++++++++++++++++++++---------- 2 files changed, 22 insertions(+), 20 deletions(-)
drivers/gpu/drm/drm_dp_aux_dev.c +2 -10
@@ -162,11 +162,7 @@ static ssize_t auxdev_read_iter(struct kiocb *iocb, struct iov_iter *to)break ; } -if (aux_dev->aux->is_remote) - res =drm_dp_mst_dpcd_read (aux_dev->aux, pos, buf, - todo); -else - res =drm_dp_dpcd_read (aux_dev->aux, pos, buf, todo); + res =drm_dp_dpcd_read (aux_dev->aux, pos, buf, todo);if (res <=0 )break ;
@@ -214,11 +210,7 @@ static ssize_t auxdev_write_iter(struct kiocb *iocb, struct iov_iter *from)break ; } -if (aux_dev->aux->is_remote) - res =drm_dp_mst_dpcd_write (aux_dev->aux, pos, buf, - todo); -else - res =drm_dp_dpcd_write (aux_dev->aux, pos, buf, todo); + res =drm_dp_mst_dpcd_write (aux_dev->aux, pos, buf, todo);if (res <=0 )break ;
drivers/gpu/drm/drm_dp_helper.c +20 -10
@@ -29,6 +29,7 @@#include <linux/i2c.h> #include <linux/seq_file.h> #include <drm/drm_dp_helper.h> +#include <drm/drm_dp_mst_helper.h> #include <drm/drmP.h> #include "drm_crtc_helper_internal.h"
@@ -272,7 +273,7 @@ static int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request,/** * drm_dp_dpcd_read() - read a series of bytes from the DPCD -* @aux: DisplayPort AUX channel +* @aux: DisplayPort AUX channel (SST or MST) * @offset: address of the (first) register to read * @buffer: buffer to store the register values * @size: number of bytes in @buffer
@@ -301,13 +302,18 @@ ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset,* We just have to do it before any DPCD access and hope that the * monitor doesn't power down exactly after the throw away read. */ - ret =drm_dp_dpcd_access (aux,DP_AUX_NATIVE_READ ,DP_DPCD_REV , buffer, -1 ); -if (ret !=1 ) - goto out; +if (!aux->is_remote) { + ret =drm_dp_dpcd_access (aux,DP_AUX_NATIVE_READ ,DP_DPCD_REV , + buffer,1 ); +if (ret !=1 ) + goto out; + } - ret =drm_dp_dpcd_access (aux,DP_AUX_NATIVE_READ , offset, buffer, - size); +if (aux->is_remote) + ret =drm_dp_mst_dpcd_read (aux, offset, buffer, size); +else + ret =drm_dp_dpcd_access (aux,DP_AUX_NATIVE_READ , offset, + buffer, size); out:drm_dp_dump_access (aux,DP_AUX_NATIVE_READ , offset, buffer, ret);
@@ -317,7 +323,7 @@ EXPORT_SYMBOL(drm_dp_dpcd_read);/** * drm_dp_dpcd_write() - write a series of bytes to the DPCD -* @aux: DisplayPort AUX channel +* @aux: DisplayPort AUX channel (SST or MST) * @offset: address of the (first) register to write * @buffer: buffer containing the values to write * @size: number of bytes in @buffer
@@ -334,8 +340,12 @@ ssize_t drm_dp_dpcd_write(struct drm_dp_aux *aux, unsigned int offset, {int ret; - ret =drm_dp_dpcd_access (aux,DP_AUX_NATIVE_WRITE , offset, buffer, - size); +if (aux->is_remote) + ret =drm_dp_mst_dpcd_write (aux, offset, buffer, size); +else + ret =drm_dp_dpcd_access (aux,DP_AUX_NATIVE_WRITE , offset, + buffer, size); +drm_dp_dump_access (aux,DP_AUX_NATIVE_WRITE , offset, buffer, ret);return ret; }
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 7/15 drm/dp_mst: Fill branch->num_ports
In reply to a message not in the archiveFrom: David Francis <[email protected]>
This field on drm_dp_mst_branch was never filled
It is initialized to zero when the port is kzallocced. When a port is added to the list, increment num_ports, and when a port is removed from the list, decrement num_ports.
v2: remember to decrement on port removal
v3: don't explicitly init to 0
--- drivers/gpu/drm/drm_dp_mst_topology.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/drm_dp_mst_topology.c +2 -0
@@ -1670,6 +1670,7 @@ static void drm_dp_add_port(struct drm_dp_mst_branch *mstb,mutex_lock (&mstb->mgr->lock);drm_dp_mst_topology_get_port (port);list_add (&port->next, &mstb->ports); + mstb->num_ports++;mutex_unlock (&mstb->mgr->lock); }
@@ -1704,6 +1705,7 @@ static void drm_dp_add_port(struct drm_dp_mst_branch *mstb,/* remove it from the port list */ mutex_lock (&mstb->mgr->lock);list_del (&port->next); + mstb->num_ports--;mutex_unlock (&mstb->mgr->lock);/* drop port list reference */ drm_dp_mst_topology_put_port (port);
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 8/15 drm/dp_mst: Add helpers for MST DSC and virtual DPCD aux
In reply to [email protected]From: David Francis <[email protected]>
Add drm_dp_mst_dsc_aux_for_port. To enable DSC, the DSC_ENABLED register might have to be written on the leaf port's DPCD, its parent's DPCD, or the MST manager's DPCD. This function finds the correct aux for the job.
As part of this, add drm_dp_mst_is_virtual_dpcd. Virtual DPCD is a DP feature new in DP v1.4, which exposes certain DPCD registers on virtual ports.
v2: Remember to unlock mutex on all paths
v3: Refactor to match coding style and increase brevity
--- drivers/gpu/drm/drm_dp_mst_topology.c | 127 ++++++++++++++++++++++++++ include/drm/drm_dp_mst_helper.h | 2 + 2 files changed, 129 insertions(+)
drivers/gpu/drm/drm_dp_mst_topology.c +127 -0
@@ -4147,3 +4147,130 @@ static void drm_dp_mst_unregister_i2c_bus(struct drm_dp_aux *aux) {i2c_del_adapter (&aux->ddc); } + +/** +* drm_dp_mst_is_virtual_dpcd() - Is the given port a virtual DP Peer Device +* @port: The port to check +* +* A single physical MST hub object can be represented in the topology +* by multiple branches, with virtual ports between those branches. +* +* As of DP1.4, An MST hub with internal (virtual) ports must expose +* certain DPCD registers over those ports. See sections 2.6.1.1.1 +* and 2.6.1.1.2 of Display Port specification v1.4 for details. +* +* May acquire mgr->lock +* +* Returns: +* true if the port is a virtual DP peer device, false otherwise +*/ +static bool drm_dp_mst_is_virtual_dpcd (struct drm_dp_mst_port *port) +{ +struct drm_dp_mst_port *downstream_port; + +if (!port || port->dpcd_rev <DP_DPCD_REV_14 ) +return false; + +/* Virtual DP Sink (Internal Display Panel) */ +if (port->port_num >=8 ) +return true; + +/* DP-to-HDMI Protocol Converter */ +if (port->pdt ==DP_PEER_DEVICE_DP_LEGACY_CONV && + !port->mcs && + port->ldps) +return true; + +/* DP-to-DP */ +mutex_lock (&port->mgr->lock); +if (port->pdt ==DP_PEER_DEVICE_MST_BRANCHING && + port->mstb && + port->mstb->num_ports ==2 ) { +list_for_each_entry (downstream_port, &port->mstb->ports, next) { +if (downstream_port->pdt ==DP_PEER_DEVICE_SST_SINK && + !downstream_port->input) { +mutex_unlock (&port->mgr->lock); +return true; + } + } + } +mutex_unlock (&port->mgr->lock); + +return false; +} + +/** +* drm_dp_mst_dsc_aux_for_port() - Find the correct aux for DSC +* @port: The port to check. A leaf of the MST tree with an attached display. +* +* Depending on the situation, DSC may be enabled via the endpoint aux, +* the immediately upstream aux, or the connector's physical aux. +* +* This is both the correct aux to read DSC_CAPABILITY and the +* correct aux to write DSC_ENABLED. +* +* This operation can be expensive (up to four aux reads), so +* the caller should cache the return. +* +* Returns: +* NULL if DSC cannot be enabled on this port, otherwise the aux device +*/ +struct drm_dp_aux *drm_dp_mst_dsc_aux_for_port (struct drm_dp_mst_port *port) +{ +struct drm_dp_mst_port *immediate_upstream_port; +struct drm_dp_mst_port *fec_port; + +if (!port) +return NULL ; + +if (port->parent) + immediate_upstream_port = port->parent->port_parent; +else + immediate_upstream_port =NULL ; + + fec_port = immediate_upstream_port; +while (fec_port) { +/* +* Each physical link (i.e. not a virtual port) between the +* output and the primary device must support FEC +*/ +if (!drm_dp_mst_is_virtual_dpcd (fec_port) && + !fec_port->fec_capable) +return NULL ; + + fec_port = fec_port->parent->port_parent; + } + +/* DP-to-DP peer device */ +if (drm_dp_mst_is_virtual_dpcd (immediate_upstream_port)) { +u8 upstream_dsc; +u8 endpoint_dsc; +u8 endpoint_fec; + +if (drm_dp_dpcd_read (&port->aux, +DP_DSC_SUPPORT , &endpoint_dsc,1 ) <0 ) +return NULL ; +if (drm_dp_dpcd_read (&port->aux, +DP_FEC_CAPABILITY , &endpoint_fec,1 ) <0 ) +return NULL ; +if (drm_dp_dpcd_read (&immediate_upstream_port->aux, +DP_DSC_SUPPORT , &upstream_dsc,1 ) <0 ) +return NULL ; + +/* Enpoint decompression with DP-to-DP peer device */ +if ((endpoint_dsc &DP_DSC_DECOMPRESSION_IS_SUPPORTED ) && + (endpoint_fec &DP_FEC_CAPABLE ) && + (upstream_dsc &0x2 )/* DSC passthrough */ ) +return &port->aux; + +/* Virtual DPCD decompression with DP-to-DP peer device */ +return &immediate_upstream_port->aux; + } + +/* Virtual DPCD decompression with DP-to-HDMI or Virtual DP Sink */ +if (drm_dp_mst_is_virtual_dpcd (port)) +return &port->aux; + +return NULL ; +} +EXPORT_SYMBOL (drm_dp_mst_dsc_aux_for_port);
include/drm/drm_dp_mst_helper.h +2 -0
@@ -673,6 +673,8 @@ int __must_check drm_dp_mst_atomic_check(struct drm_atomic_state *state);void drm_dp_mst_get_port_malloc (struct drm_dp_mst_port *port);void drm_dp_mst_put_port_malloc (struct drm_dp_mst_port *port); +struct drm_dp_aux *drm_dp_mst_dsc_aux_for_port (struct drm_dp_mst_port *port); +extern const struct drm_private_state_funcs drm_dp_mst_topology_state_funcs;/**
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 9/15 drm/dp_mst: Add new quirk for Synaptics MST hubs
In reply to a message not in the archiveFrom: David Francis <[email protected]>
Synaptics DP1.4 hubs (BRANCH_ID 0x90CC24) do not support virtual DPCD registers, but do support DSC. The DSC caps can be read from the physical aux, like in SST DSC. These hubs have many different DEVICE_IDs. Add a new quirk to detect this case.
--- drivers/gpu/drm/drm_dp_helper.c | 4 +++- drivers/gpu/drm/drm_dp_mst_topology.c | 27 +++++++++++++++++++++++++++ include/drm/drm_dp_helper.h | 7 +++++++ 3 files changed, 37 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_dp_helper.c +3 -1
@@ -1288,7 +1288,9 @@ static const struct dpcd_quirk dpcd_quirk_list[] = {/* LG LP140WF6-SPM1 eDP panel */ { OUI(0x00, 0x22, 0xb9), DEVICE_ID('s', 'i', 'v', 'a', 'r', 'T'), false, BIT(DP_DPCD_QUIRK_CONSTANT_N) },/* Apple panels need some additional handling to support PSR */ - { OUI(0x00, 0x10, 0xfa), DEVICE_ID_ANY, false, BIT(DP_DPCD_QUIRK_NO_PSR) } + { OUI(0x00, 0x10, 0xfa), DEVICE_ID_ANY, false, BIT(DP_DPCD_QUIRK_NO_PSR) }, +/* Synaptics DP1.4 MST hubs can support DSC without virtual DPCD */ + { OUI(0x90, 0xCC, 0x24), DEVICE_ID_ANY, true, BIT(DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD) }, };#undef OUI
drivers/gpu/drm/drm_dp_mst_topology.c +27 -0
@@ -4219,6 +4219,7 @@ struct drm_dp_aux *drm_dp_mst_dsc_aux_for_port(struct drm_dp_mst_port *port) {struct drm_dp_mst_port *immediate_upstream_port;struct drm_dp_mst_port *fec_port; +struct drm_dp_desc desc = {0 };if (!port)return NULL ;
@@ -4271,6 +4272,32 @@ struct drm_dp_aux *drm_dp_mst_dsc_aux_for_port(struct drm_dp_mst_port *port)if (drm_dp_mst_is_virtual_dpcd (port))return &port->aux; +/* +* Synaptics quirk +* Applies to ports for which: +* - Physical aux has Synaptics OUI +* - DPv1.4 or higher +* - Port is on primary branch device +* - Not a VGA adapter (DP_DWN_STRM_PORT_TYPE_ANALOG) +*/ +if (!drm_dp_read_desc (port->mgr->aux, &desc, true)) +return NULL ; + +if (drm_dp_has_quirk (&desc,DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD ) && + port->mgr->dpcd[DP_DPCD_REV ] >=DP_DPCD_REV_14 && + port->parent == port->mgr->mst_primary) { +u8 downstreamport; + +if (drm_dp_dpcd_read (&port->aux,DP_DOWNSTREAMPORT_PRESENT , + &downstreamport,1 ) <0 ) +return NULL ; + +if ((downstreamport &DP_DWN_STRM_PORT_PRESENT ) && + ((downstreamport &DP_DWN_STRM_PORT_TYPE_MASK ) + !=DP_DWN_STRM_PORT_TYPE_ANALOG )) +return port->mgr->aux; + } +return NULL ; }EXPORT_SYMBOL (drm_dp_mst_dsc_aux_for_port);
include/drm/drm_dp_helper.h +7 -0
@@ -1414,6 +1414,13 @@ enum drm_dp_quirk {* driver still need to implement proper handling for such device. */ DP_DPCD_QUIRK_NO_PSR , +/** +* @DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD: +* +* The device supports MST DSC despite not supporting Virtual DPCD. +* The DSC caps can be read from the physical aux instead. +*/ + DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD, };/**
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 10/15 drm/amd/display: Use correct helpers to compute timeslots
In reply to [email protected]From: David Francis <[email protected]>
We were using drm helpers to convert a timing into its bandwidth, its bandwidth into pbn, and its pbn into timeslots
These helpers
-Did not take DSC timings into account
-Used the link rate and lane count of the link's aux device, which are not the same as the link's current cap
-Did not take FEC into account (FEC reduces the PBN per timeslot)
For converting timing into PBN, use the new function drm_dp_calc_pbn_mode_dsc that handles the DSC case
For converting PBN into time slots, amdgpu doesn't use the 'correct' atomic method (drm_dp_atomic_find_vcpi_slots), so don't add a new helper to cover our approach. Use the same means of calculating pbn per time slot as the DSC code.
--- .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +13 -5
@@ -188,8 +188,8 @@ bool dm_helpers_dp_mst_write_payload_allocation_table(int slots =0 ;bool ret;int clock; -int bpp =0 ;int pbn =0 ; +int pbn_per_timeslot, bpp =0 ; aconnector = (struct amdgpu_dm_connector *)stream->dm_stream_context;
@@ -233,11 +233,19 @@ bool dm_helpers_dp_mst_write_payload_allocation_table( bpp = bpp *3 ; -/* TODO need to know link rate */ - - pbn =drm_dp_calc_pbn_mode (clock, bpp, false); +#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT +if (stream->timing.flags.DSC) + pbn =drm_dp_calc_pbn_mode (clock, + stream->timing.dsc_cfg.bits_per_pixel, + true); + else +#endif + pbn =drm_dp_calc_pbn_mode (clock, bpp, false); - slots =drm_dp_find_vcpi_slots (mst_mgr, pbn); +/* Convert kilobits per second / 64 (for 64 timeslots) to pbn (54/64 megabytes per second) */ + pbn_per_timeslot =dc_link_bandwidth_kbps ( + stream->link,dc_link_get_link_cap (stream->link)) / (8 *1000 *54 ); + slots =DIV_ROUND_UP (pbn, pbn_per_timeslot); ret =drm_dp_mst_allocate_vcpi (mst_mgr, mst_port, pbn, slots);if (!ret)
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 11/15 drm/amd/display: Initialize DSC PPS variables to 0
In reply to a message not in the archiveFrom: David Francis <[email protected]>
For DSC MST, sometimes monitors would break out in full-screen static. The issue traced back to the PPS generation code, where these variables were being used uninitialized and were picking up garbage.
memset to 0 to avoid this
--- drivers/gpu/drm/amd/display/dc/core/dc_link_hwss.c | 3 +++ drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dsc.c | 3 +++ 2 files changed, 6 insertions(+)
drivers/gpu/drm/amd/display/dc/core/dc_link_hwss.c +3 -0
@@ -496,6 +496,9 @@ bool dp_set_dsc_pps_sdp(struct pipe_ctx *pipe_ctx, bool enable)struct dsc_config dsc_cfg;uint8_t dsc_packed_pps[128 ]; +memset (&dsc_cfg,0 ,sizeof (dsc_cfg)); +memset (dsc_packed_pps,0 ,128 ); +/* Enable DSC hw block */ dsc_cfg.pic_width = stream->timing.h_addressable + stream->timing.h_border_left + stream->timing.h_border_right; dsc_cfg.pic_height = stream->timing.v_addressable + stream->timing.v_border_top + stream->timing.v_border_bottom;
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dsc.c +3 -0
@@ -207,6 +207,9 @@ static bool dsc2_get_packed_pps(struct display_stream_compressor *dsc, const strstruct dsc_reg_values dsc_reg_vals;struct dsc_optc_config dsc_optc_cfg; +memset (&dsc_reg_vals,0 ,sizeof (dsc_reg_vals)); +memset (&dsc_optc_cfg,0 ,sizeof (dsc_optc_cfg)); +DC_LOG_DSC ("Getting packed DSC PPS for DSC Config:" );dsc_config_log (dsc, dsc_cfg);DC_LOG_DSC ("DSC Picture Parameter Set (PPS):" );
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 12/15 drm/amd/display: Validate DSC caps on MST endpoints
In reply to [email protected]From: David Francis <[email protected]>
During MST mode enumeration, if a new dc_sink is created, populate it with dsc caps as appropriate.
Use drm_dp_mst_dsc_aux_for_port to get the raw caps, then parse them onto dc_sink with dc_dsc_parse_dsc_dpcd.
--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 3 ++ .../display/amdgpu_dm/amdgpu_dm_mst_types.c | 31 ++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +3 -0
@@ -268,6 +268,9 @@ struct amdgpu_dm_connector {struct drm_dp_mst_port *port;struct amdgpu_dm_connector *mst_port;struct amdgpu_encoder *mst_encoder; +#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT +struct drm_dp_aux *dsc_aux; +#endif /* TODO see if we can merge with ddc_bus or make a dm_connector */ struct amdgpu_i2c_adapter *i2c;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +30 -1
@@ -25,6 +25,7 @@#include <linux/version.h> #include <drm/drm_atomic_helper.h> +#include <drm/drm_dp_mst_helper.h> #include "dm_services.h" #include "amdgpu.h" #include "amdgpu_dm.h"
@@ -189,6 +190,28 @@ static const struct drm_connector_funcs dm_dp_mst_connector_funcs = { .early_unregister = amdgpu_dm_mst_connector_early_unregister, }; +#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT +static bool validate_dsc_caps_on_connector (struct amdgpu_dm_connector *aconnector) +{ +struct dc_sink *dc_sink = aconnector->dc_sink; +struct drm_dp_mst_port *port = aconnector->port; +u8 dsc_caps[16 ] = {0 }; + + aconnector->dsc_aux =drm_dp_mst_dsc_aux_for_port (port); + +if (!aconnector->dsc_aux) +return false; + +if (drm_dp_dpcd_read (aconnector->dsc_aux,DP_DSC_SUPPORT , dsc_caps,16 ) <0 ) +return false; + +if (!dc_dsc_parse_dsc_dpcd (dsc_caps,NULL , &dc_sink->sink_dsc_caps.dsc_dec_caps)) +return false; + +return true; +} +#endif +static int dm_dp_mst_get_modes (struct drm_connector *connector) {struct amdgpu_dm_connector *aconnector =to_amdgpu_dm_connector (connector);
@@ -231,10 +254,16 @@ static int dm_dp_mst_get_modes(struct drm_connector *connector)/* dc_link_add_remote_sink returns a new reference */ aconnector->dc_sink = dc_sink; -if (aconnector->dc_sink) +if (aconnector->dc_sink) {amdgpu_dm_update_freesync_caps ( connector, aconnector->edid); +#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT +if (!validate_dsc_caps_on_connector (aconnector)) +memset (&aconnector->dc_sink->sink_dsc_caps, +0 ,sizeof (aconnector->dc_sink->sink_dsc_caps)); +#endif + } } drm_connector_update_edid_property(
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 13/15 drm/amd/display: Write DSC enable to MST DPCD
In reply to a message not in the archiveFrom: David Francis <[email protected]>
Rework the dm_helpers_write_dsc_enable callback to handle the MST case.
Use the cached dsc_aux field.
--- .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +18 -1
@@ -38,6 +38,7 @@#include "dc.h" #include "amdgpu_dm.h" #include "amdgpu_dm_irq.h" +#include "amdgpu_dm_mst_types.h" #include "dm_helpers.h"
@@ -557,8 +558,24 @@ bool dm_helpers_dp_write_dsc_enable( ) {uint8_t enable_dsc = enable ?1 :0 ; +struct amdgpu_dm_connector *aconnector; + +if (!stream) +return false; + +if (stream->signal ==SIGNAL_TYPE_DISPLAY_PORT_MST ) { + aconnector = (struct amdgpu_dm_connector *)stream->dm_stream_context; + +if (!aconnector->dsc_aux) +return false; + +return (drm_dp_dpcd_write (aconnector->dsc_aux,DP_DSC_ENABLE , &enable_dsc,1 ) >=0 ); + } + +if (stream->signal ==SIGNAL_TYPE_DISPLAY_PORT ) +return dm_helpers_dp_write_dpcd (ctx, stream->link,DP_DSC_ENABLE , &enable_dsc,1 ); -return dm_helpers_dp_write_dpcd (ctx, stream->sink->link,DP_DSC_ENABLE , &enable_dsc,1 ); +return false; }#endif
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 14/15 drm/amd/display: MST DSC compute fair share
In reply to a message not in the archiveFrom: David Francis <[email protected]>
If there is limited link bandwidth on a MST network, it must be divided fairly between the streams on that network
Implement an algorithm to determine the correct DSC config for each stream
The algorithm:
This
[ ] ( )
represents the range of bandwidths possible for a given stream. The [] area represents the range of DSC configs, and the () represents no DSC. The bandwidth used increases from left to right.
First, try disabling DSC on all streams
[ ] (|)
[ ] (|)
Check this against the bandwidth limits of the link and each branch (including each endpoint). If it passes, the job is done
Second, try maximum DSC compression on all streams that support DSC
[| ] ( )
[| ] ( )
If this does not pass, then enabling this combination of streams is impossible
Otherwise, divide the remaining bandwidth evenly amongst the streams
[ | ] ( )
[ | ] ( )
If one or more of the streams reach minimum compression, evenly divide the reamining bandwidth amongst the remaining streams
[ |] ( )
[ |] ( )
[ | ] ( )
[ | ] ( )
If all streams can reach minimum compression, disable compression greedily
[ |] ( )
[ |] ( )
[ ] (|)Perform this algorithm on each full update, on each MST link with at least one DSC stream on it
After the configs are computed, call dcn20_add_dsc_to_stream_resource on each stream with DSC enabled. It is only after all streams are created that we can know which of them will need DSC.
Do all of this at the end of amdgpu atomic check. If it fails, fail check; This combination of timings cannot be supported.
--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 + .../display/amdgpu_dm/amdgpu_dm_mst_types.c | 386 ++++++++++++++++++ .../display/amdgpu_dm/amdgpu_dm_mst_types.h | 4 + .../drm/amd/display/dc/dcn20/dcn20_resource.c | 7 +- .../drm/amd/display/dc/dcn20/dcn20_resource.h | 1 + 5 files changed, 400 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4 -0
@@ -7564,6 +7564,10 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,if (ret) goto fail; +#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT +if (!compute_mst_dsc_configs_for_state (dm_state->context)) + goto fail; +#endif if (dc_validate_global_state (dc, dm_state->context, false) !=DC_OK ) { ret = -EINVAL ; goto fail;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +386 -0
395 lines not on this page · raw message
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.h +4 -0
@@ -32,4 +32,8 @@ struct amdgpu_dm_connector;void amdgpu_dm_initialize_dp_connector (struct amdgpu_display_manager *dm,struct amdgpu_dm_connector *aconnector); + +#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT +bool compute_mst_dsc_configs_for_state (struct dc_state *dc_state); +#endif #endif
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c +5 -2
@@ -1445,7 +1445,7 @@ static void release_dsc(struct resource_context *res_ctx,#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT -static enum dc_status add_dsc_to_stream_resource (struct dc *dc, +enum dc_status dcn20_add_dsc_to_stream_resource (struct dc *dc,struct dc_state *dc_ctx,struct dc_stream_state *dc_stream) {
@@ -1460,6 +1460,9 @@ static enum dc_status add_dsc_to_stream_resource(struct dc *dc,if (pipe_ctx->stream != dc_stream)continue ; +if (pipe_ctx->stream_res.dsc) +continue ; +acquire_dsc (&dc_ctx->res_ctx, pool, &pipe_ctx->stream_res.dsc);/* The number of DSCs can be less than the number of pipes */
@@ -1511,7 +1514,7 @@ enum dc_status dcn20_add_stream_to_ctx(struct dc *dc, struct dc_state *new_ctx,#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT /* Get a DSC if required and available */ if (result ==DC_OK && dc_stream->timing.flags.DSC) - result =add_dsc_to_stream_resource (dc, new_ctx, dc_stream); + result =dcn20_add_dsc_to_stream_resource (dc, new_ctx, dc_stream);#endif if (result ==DC_OK )
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.h +1 -0
@@ -131,6 +131,7 @@ void dcn20_calculate_dlg_params(enum dc_status dcn20_build_mapped_resource (const struct dc *dc,struct dc_state *context,struct dc_stream_state *stream);enum dc_status dcn20_add_stream_to_ctx (struct dc *dc,struct dc_state *new_ctx,struct dc_stream_state *dc_stream); +enum dc_status dcn20_add_dsc_to_stream_resource (struct dc *dc,struct dc_state *dc_ctx,struct dc_stream_state *dc_stream);enum dc_status dcn20_remove_stream_from_ctx (struct dc *dc,struct dc_state *new_ctx,struct dc_stream_state *dc_stream);enum dc_status dcn20_get_default_swizzle_mode (struct dc_plane_state *plane_state);
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 15/15 drm/amd/display: Trigger modesets on MST DSC connectors
In reply to a message not in the archiveFrom: David Francis <[email protected]>
Whenever a connector on an MST network is attached, detached, or undergoes a modeset, the DSC configs for each stream on that topology will be recalculated. This can change their required bandwidth, requiring a full reprogramming, as though a modeset was performed, even if that stream did not change timing.
Therefore, whenever a crtc has drm_atomic_crtc_needs_modeset, for each crtc that shares a MST topology with that stream and supports DSC, add that crtc (and all affected connectors and planes) to the atomic state and set mode_changed on its state
v2: Do this check only on Navi and before adding connectors and planes on modesetting crtcs
--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +79 -0
@@ -6704,6 +6704,74 @@ static int do_aquire_global_lock(struct drm_device *dev,return ret <0 ? ret :0 ; } +#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT +/* +* TODO: This logic should at some point be moved into DRM +*/ +static int add_affected_mst_dsc_crtcs (struct drm_atomic_state *state,struct drm_crtc *crtc) +{ +struct drm_connector *connector; +struct drm_connector_state *conn_state; +struct drm_connector_list_iter conn_iter; +struct drm_crtc_state *new_crtc_state; +struct amdgpu_dm_connector *aconnector =NULL , *aconnector_to_add; +int i, j; +struct drm_crtc *crtcs_affected[AMDGPU_MAX_CRTCS ] = {0 }; + +for_each_new_connector_in_state (state, connector, conn_state, i) { +if (conn_state->crtc != crtc) +continue ; + + aconnector =to_amdgpu_dm_connector (connector); +if (!aconnector->port) + aconnector =NULL ; +else +break ; + } + +if (!aconnector) +return 0 ; + + i =0 ; +drm_connector_list_iter_begin (state->dev, &conn_iter); +drm_for_each_connector_iter (connector, &conn_iter) { +if (!connector->state || !connector->state->crtc) +continue ; + + aconnector_to_add =to_amdgpu_dm_connector (connector); +if (!aconnector_to_add->port) +continue ; + +if (aconnector_to_add->port->mgr != aconnector->port->mgr) +continue ; + +if (!aconnector_to_add->dc_sink) +continue ; + +if (!aconnector_to_add->dc_sink->sink_dsc_caps.dsc_dec_caps.is_dsc_supported) +continue ; + +if (i >=AMDGPU_MAX_CRTCS ) +continue ; + + crtcs_affected[i] = connector->state->crtc; + i++; + } +drm_connector_list_iter_end (&conn_iter); + +for (j =0 ; j < i; j++) { + new_crtc_state =drm_atomic_get_crtc_state (state, crtcs_affected[j]); +if (IS_ERR (new_crtc_state)) +return PTR_ERR (new_crtc_state); + + new_crtc_state->mode_changed = true; + } + +return 0 ; + +} +#endif +static void get_freesync_config_for_crtc (struct dm_crtc_state *new_crtc_state,struct dm_connector_state *new_con_state)
@@ -7388,6 +7456,17 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,if (ret) goto fail; +#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT +if (adev->asic_type >=CHIP_NAVI10 ) { +for_each_oldnew_crtc_in_state (state, crtc, old_crtc_state, new_crtc_state, i) { +if (drm_atomic_crtc_needs_modeset (new_crtc_state)) { + ret =add_affected_mst_dsc_crtcs (state, crtc); +if (ret) + goto fail; + } + } + } +#endif for_each_oldnew_crtc_in_state (state, crtc, old_crtc_state, new_crtc_state, i) { if (!drm_atomic_crtc_needs_modeset(new_crtc_state) && !new_crtc_state->color_mgmt_changed &&
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Lyude Paul
maintainerRe: [PATCH 01/15] drm/amdgpu: Add encoder atomic check
In reply to [email protected]Haven't looked at these quite yet, but I just wanted to say ahead of time that from a quick glance these look like a big step in the right direction :). Awesome work!
I will review this ASAP
Quoted 96 lines · On Wed, 2019-09-18 at 16:26 -0400, [email protected] wrote:
From: Mikita Lipski <[email protected]>
[why]
In order to comply with new MST atomic check we have to find and add VCPI slots to the state during atomic check whenever their is a change on mode or connector.
[how]
- Verify that it is a MST connection
- Convert new stream's clock and bpp
- Calculate PBN based on stream parameters
- Find and add VCPI slots to the stateCc Lyude Paul <[email protected]>Signed-off-by Mikita Lipski <[email protected]>--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4
-0@@ -4432,6 +4432,65 @@ static int dm_encoder_helper_atomic_check(structdrm_encoder *encoder, struct drm_crtc_state *crtc_state, struct drm_connector_state *conn_state) { + struct drm_atomic_state *state = crtc_state->state; +struct drm_connector *connector = conn_state->connector; +struct amdgpu_dm_connector *aconnector =to_amdgpu_dm_connector (connector); + struct dm_crtc_state *dm_new_crtc_state =
to_dm_crtc_state(crtc_state);drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-0+ const struct drm_display_mode *adjusted_mode = &crtc_state-Quoted 1 line
adjusted_mode;drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +20
-0+struct drm_dp_mst_topology_mgr *mst_mgr; +struct drm_dp_mst_port *mst_port; +int pbn, slots,clock, bpp =0 ; + +if (!dm_new_crtc_state) +return 0 ; + +if (!aconnector || !aconnector->port) +return 0 ; + + mst_port = aconnector->port; + mst_mgr = &aconnector->mst_port->mst_mgr; + +if (!mst_mgr->mst_state) +return 0 ; + +if (!crtc_state->connectors_changed && !crtc_state->mode_changed) +return 0 ; + + switch (convert_color_depth_from_display_info(connector, conn_state)){
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +34
-0+case COLOR_DEPTH_666 : + bpp =6 ; +break ; +case COLOR_DEPTH_888 : + bpp =8 ; +break ; +case COLOR_DEPTH_101010 : + bpp =10 ; +break ; +case COLOR_DEPTH_121212 : + bpp =12 ; +break ; +case COLOR_DEPTH_141414 : + bpp =14 ; +break ; +case COLOR_DEPTH_161616 : + bpp =16 ; +break ; +default : +ASSERT (bpp !=0 ); +break ; + } + + bpp *=3 ; + clock = adjusted_mode->clock; + pbn =drm_dp_calc_pbn_mode (clock, bpp); + slots =drm_dp_atomic_find_vcpi_slots (state, + mst_mgr, + mst_port, + pbn); +if (slots <0 ) { +DRM_DEBUG_KMS ("failed finding vcpi slots:%d\n" , slots); +return slots; + }return 0 ; }
Signature · 7 lines
Cheers, Lyude Paul _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 01/15] drm/amdgpu: Add encoder atomic check
In reply to a message not in the archiveOk, so reviewing this is kind of difficult because this series doesn't apply to drm-tip, and also doesn't make any mention of what branch it's supposed to apply to. So there's no way for me to apply any of these changes in my tree to get an idea of how things look overall with these patches applied. Could you please base the next series on top of drm-tip?
In the mean time, I've left as much feedback as I can below:
For starters, this patch should be combined with the next patch in the series since you really can't use drm_dp_atomic_find_vcpi_slots() without using drm_dp_atomic_release_vcpi_slots(). More down below
Quoted 38 lines · On Wed, 2019-09-18 at 16:26 -0400, [email protected] wrote:
From: Mikita Lipski <[email protected]>
[why]
In order to comply with new MST atomic check we have to find and add VCPI slots to the state during atomic check whenever their is a change on mode or connector.
[how]
- Verify that it is a MST connection
- Convert new stream's clock and bpp
- Calculate PBN based on stream parameters
- Find and add VCPI slots to the stateCc Lyude Paul <[email protected]>Signed-off-by Mikita Lipski <[email protected]>--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4
-0@@ -4432,6 +4432,65 @@ static int dm_encoder_helper_atomic_check(structdrm_encoder *encoder, struct drm_crtc_state *crtc_state, struct drm_connector_state *conn_state) { + struct drm_atomic_state *state = crtc_state->state; +struct drm_connector *connector = conn_state->connector; +struct amdgpu_dm_connector *aconnector =to_amdgpu_dm_connector (connector); + struct dm_crtc_state *dm_new_crtc_state =
to_dm_crtc_state(crtc_state);drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-0+ const struct drm_display_mode *adjusted_mode = &crtc_state-Quoted 1 line
adjusted_mode;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_encoder_helper_atomic_check(struct drm_encoder *encoder, · line 4448
Quoted 9 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +9
-0+struct drm_dp_mst_topology_mgr *mst_mgr; +struct drm_dp_mst_port *mst_port; +int pbn, slots,clock, bpp =0 ; + +if (!dm_new_crtc_state) +return 0 ; + +if (!aconnector || !aconnector->port) +return 0 ;
...in what situation would aconnector ever be NULL? Same for aconnector->port, the drm_dp_mst_port stays around until the drm_connector is destroyed.
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_encoder_helper_atomic_check(struct drm_encoder *encoder, · line 4454
Quoted 6 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +6
-0+ + mst_port = aconnector->port; + mst_mgr = &aconnector->mst_port->mst_mgr; + +if (!mst_mgr->mst_state) +return 0 ;
I'm confused here, what is the purpose of this check? mst_mgr->mst_state shouldn't be touched directly ever, as it refers to the currently committed mgr state. the way to retrieve the mgr's atomic state is:
Even then though, there's no actual need to grab the mst_state here manually. drm_dp_atomic_find_vcpi_slots() does this for you
Quoted 22 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +5
-0+ +if (!crtc_state->connectors_changed && !crtc_state->mode_changed) +return 0 ; + + switch (convert_color_depth_from_display_info(connector, conn_state)){
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +16
-0+case COLOR_DEPTH_666 : + bpp =6 ; +break ; +case COLOR_DEPTH_888 : + bpp =8 ; +break ; +case COLOR_DEPTH_101010 : + bpp =10 ; +break ; +case COLOR_DEPTH_121212 : + bpp =12 ; +break ; +case COLOR_DEPTH_141414 : + bpp =14 ; +break ; +case COLOR_DEPTH_161616 :
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_encoder_helper_atomic_check(struct drm_encoder *encoder, · line 4485
Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +10
-0+ bpp =16 ; +break ; +default : +ASSERT (bpp !=0 ); +break ; + } + + bpp *=3 ; + clock = adjusted_mode->clock; + pbn =drm_dp_calc_pbn_mode (clock, bpp);
I might have forgotten to mention this in the documentation (I'll double check after sending this out and fix it if I did...), but it's a good idea to only recalculate the PBN when !drm_atomic_state->duplicated. The reason for this is that when we're resuming the system from S3, there's a chance that MST topologies which were previously connected to the system might no longer be present or may have changed.
When resuming from S3, or any other situation where the GPU needs to save and restore it's atomic state, the general expectation is that the state that was saved is basically identical to the state that was resumed since a different state won't have the guarantee of passing the atomic check. An example scenario (note that we don't reprobe topologies after resume yet, but we will be doing this very soon):
* MST connector DP-4 starts off with a bpp of 8
* The GPU has a VCPI table that is currently full, and includes an active allocation for DP-4.
* The system goes into S3, and the GPU is suspended and the atomic state saved (this sets state->duplicated to true)
* While the system is still in S3, the user plugs in a monitor that is identical, except for the fact it has 16bpp
* The system resumes, and the GPU begins resuming. amdgpu goes to restore the atomic state from before entering S3
* Because DP-4 now has a bpp of 16, we use that instead of the previous 8bpp from before and end up with a VCPI allocation that is twice as large as before
* The new twice-as-large VCPI allocation does not fit along with the rest of the allocations, and causes the atomic_check during resume to fail (note that during resume, it's expected that the driver does whatever it takes to make the atomic_check pass)
Copying the PBN value as-is from the duplicated atomic state when state-
Quoted 1 line
duplicated == true instead of recalculating it allows us to avoid this by
making sure that regardless of changes with the connector, we still end up restoring the same VCPI allocations that we had before.
Note-this does potentially leave us with the possibility that we could in fact, resume and end up restoring an atomic state with an incorrect VCPI table. I don't think we've really figured out any way around this, and with suspend/resume it's expected that the driver is able to cope with breakages like this until another atomic modeset happens to correct things. So for now, that's OK.
I'd really recommend looking at nouveau's implementation of this as an example, specifically nv50_msto_atomic_check().
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_encoder_helper_atomic_check(struct drm_encoder *encoder, · line 4491
Quoted 6 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +6
-0+ slots =drm_dp_atomic_find_vcpi_slots (state, + mst_mgr, + mst_port, + pbn); +if (slots <0 ) { +DRM_DEBUG_KMS ("failed finding vcpi slots:%d\n" , slots);
I think you meant DRM_DEBUG_ATOMIC() here
Also, this is still a big step in the right direction but there's a bit more missing here. This code only checks if slots != 0 and then drops the value. Later, dm_helpers_dp_mst_write_payload_allocation_table() calculates the VCPI allocation that actually gets used in the commit in the atomic commit using the deprecated drm_dp_find_vcpi_slots() helper.
What we want here instead is to just drop the usage of drm_dp_find_vcpi_slots() entirely, store the VCPI slot allocation returned by drm_dp_atomic_find_vcpi_slots() in the driver's atomic state, then use that value when performing the actual VCPI allocation in dm_helpers_dp_mst_write_payload_allocation_table() using drm_dp_mst_allocate_vcpi(). Maybe struct dc_stream_state is a good place to add this? (feel free to store the pbn as well there, to save a redundant drm_dp_calc_pbn_mode() call).
Quoted 5 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-0+return slots; + }return 0 ; }
Signature · 7 lines
Cheers, Lyude Paul _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 02/15] drm/amdgpu: Add connector atomic check
In reply to a message not in the archiveQuoted 33 lines · On Wed, 2019-09-18 at 16:26 -0400, [email protected] wrote:
From: Mikita Lipski <[email protected]>
[why]
Complying with new MST atomic check requirements. The driver needs to call this function on every atomic check to reset the VCPI slots if new state disables
[how]
- Verify that it is a MST connection
- Verify that old crtc state exists
- Verify the new crtc state disables sink
- Release VCPI slots on the portCc Lyude Paul <[email protected]>Signed-off-by Mikita Lipski <[email protected]>--- .../display/amdgpu_dm/amdgpu_dm_mst_types.c | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +4
-0@@ -252,10 +252,44 @@ static struct drm_encoder *dm_mst_best_encoder(struct drm_connector *connector)return &amdgpu_dm_connector->mst_encoder->base; } +static int dm_dp_mst_atomic_check (struct drm_connector *connector, +struct drm_connector_state *new_conn_state) +{ +struct drm_atomic_state *state = new_conn_state->state;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c static struct drm_encoder *dm_mst_best_encoder(struct · line 269
Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +9
-0+struct drm_connector_state *old_conn_state = +drm_atomic_get_old_connector_state (state, connector); +struct amdgpu_dm_connector *aconnector =to_amdgpu_dm_connector (connector); +struct drm_crtc_state *new_crtc_state; +struct drm_dp_mst_topology_mgr *mst_mgr; +struct drm_dp_mst_port *mst_port; + +if (!aconnector || !aconnector->port) +return 0 ;
Same as the last patch, I don't think you should need either of these checks.
Otherwise, assuming this gets squashed into the previous patch this looks fine to me
Quoted 30 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +21
-0+ + mst_port = aconnector->port; + mst_mgr = &aconnector->mst_port->mst_mgr; + +if (!old_conn_state->crtc) +return 0 ; + +if (new_conn_state->crtc) { + new_crtc_state =drm_atomic_get_old_crtc_state (state, new_conn_state->crtc); +if (!new_crtc_state || + !drm_atomic_crtc_needs_modeset (new_crtc_state) || + new_crtc_state->enable) +return 0 ; + } + +return drm_dp_atomic_release_vcpi_slots (state, + mst_mgr, + mst_port); +} +static const struct drm_connector_helper_funcs dm_dp_mst_connector_helper_funcs = { .get_modes = dm_dp_mst_get_modes, .mode_valid = amdgpu_dm_connector_mode_valid, .best_encoder = dm_mst_best_encoder, + .atomic_check = dm_dp_mst_atomic_check, };static void amdgpu_dm_encoder_destroy (struct drm_encoder *encoder)
Signature · 7 lines
Cheers, Lyude Paul _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Lyude Paul
maintainerRe: [PATCH 03/15] drm/amdgpu: validate mst topology in atomic check
In reply to [email protected]This also needs to be squashed into the previous two patches. There's no point in using drm_dp_atomic_find_vcpi_slots() or drm_dp_atomic_release_vcpi_slots() without drm_dp_mst_atomic_check(), since the VCPI allocations setup by the two functions aren't validated until then.
Quoted 34 lines · On Wed, 2019-09-18 at 16:26 -0400, [email protected] wrote:
From: Mikita Lipski <[email protected]>
[why]
Validate mst topology and the number of VCPI slots available for a new state. Fail if topology has no more bandwidth for a new state.
[how]
Pass the atomic state todrm_dp_mst_atomic_checkto verify if the new topology is possible.Cc Lyude Paul <[email protected]>Signed-off-by Mikita Lipski <[email protected]>--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +5
-0@@ -7485,6 +7485,11 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev, if (ret) goto fail; +/* Perform validation of MST topology in the state*/ + ret =drm_dp_mst_atomic_check (state); +if (ret) + goto fail; +if (state->legacy_cursor_update) {/* * This is a fast cursor update coming from the plane update
Signature · 7 lines
Cheers, Lyude Paul _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Lyude Paul
Reviewed-byRe: [PATCH 08/15] drm/dp_mst: Add helpers for MST DSC and virtual DPCD aux
In reply to a message not in the archiveQuoted 182 lines · On Wed, 2019-09-18 at 16:26 -0400, [email protected] wrote:
From: David Francis <[email protected]>
Add
drm_dp_mst_dsc_aux_for_port. To enable DSC, theDSC_ENABLEDregister might have to be written on the leaf port's DPCD, its parent's DPCD, or the MST manager's DPCD. This function finds the correct aux for the job.As part of this, add
drm_dp_mst_is_virtual_dpcd. Virtual DPCD is a DP feature new in DP v1.4, which exposes certain DPCD registers on virtual ports.v2: Remember to unlock mutex on all paths
v3: Refactor to match coding style and increase brevityCc Lyude Paul <[email protected]>Cc Jani Nikula <[email protected]>Cc Harry Wentland <[email protected]>Reviewed-by Wenjing Liu <[email protected]>Signed-off-by David Francis <[email protected]>--- drivers/gpu/drm/drm_dp_mst_topology.c | 127 ++++++++++++++++++++++++++ include/drm/drm_dp_mst_helper.h | 2 + 2 files changed, 129 insertions(+)drivers/gpu/drm/drm_dp_mst_topology.c +3
-0@@ -4147,3 +4147,130 @@ static void drm_dp_mst_unregister_i2c_bus(struct drm_dp_aux *aux) {i2c_del_adapter (&aux->ddc); } + +/** +* drm_dp_mst_is_virtual_dpcd() - Is the given port a virtual DP Peer Device
+ * @port: The port to check
+ *
+ * A single physical MST hub object can be represented in the topology
+ * by multiple branches, with virtual ports between those branches.
+ *
+ * As of DP1.4, An MST hub with internal (virtual) ports must expose
+ * certain DPCD registers over those ports. See sections 2.6.1.1.1
+ * and 2.6.1.1.2 of Display Port specification v1.4 for details.
+ *
+ * May acquiremgr->lock
+ *
+ * Returns:
+ * true if the port is a virtual DP peer device, false otherwise
+ */drivers/gpu/drm/drm_dp_mst_topology.c +23
-0+static bool drm_dp_mst_is_virtual_dpcd (struct drm_dp_mst_port *port) +{ +struct drm_dp_mst_port *downstream_port; + +if (!port || port->dpcd_rev <DP_DPCD_REV_14 ) +return false; + +/* Virtual DP Sink (Internal Display Panel) */ +if (port->port_num >=8 ) +return true; + +/* DP-to-HDMI Protocol Converter */ +if (port->pdt ==DP_PEER_DEVICE_DP_LEGACY_CONV && + !port->mcs && + port->ldps) +return true; + +/* DP-to-DP */ +mutex_lock (&port->mgr->lock); +if (port->pdt ==DP_PEER_DEVICE_MST_BRANCHING && + port->mstb && + port->mstb->num_ports ==2 ) { +list_for_each_entry (downstream_port, &port->mstb->ports, next){
drivers/gpu/drm/drm_dp_mst_topology.c +15
-0+if (downstream_port->pdt ==DP_PEER_DEVICE_SST_SINK && + !downstream_port->input) { +mutex_unlock (&port->mgr->lock); +return true; + } + } + } +mutex_unlock (&port->mgr->lock); + +return false; +} + +/** +* drm_dp_mst_dsc_aux_for_port() - Find the correct aux for DSC +* @port: The port to check. A leaf of the MST tree with an attached display.
+ *
+ * Depending on the situation, DSC may be enabled via the endpoint aux,
+ * the immediately upstream aux, or the connector's physical aux.
+ *
+ * This is both the correct aux to readDSC_CAPABILITYand the
+ * correct aux to writeDSC_ENABLED.
+ *
+ * This operation can be expensive (up to four aux reads), so
+ * the caller should cache the return.
+ *
+ * Returns:
+ * NULL if DSC cannot be enabled on this port, otherwise the aux device
+ */
+structdrm_dp_aux*drm_dp_mst_dsc_aux_for_port(structdrm_dp_mst_port*port)drivers/gpu/drm/drm_dp_mst_topology.c +58
-0+{ +struct drm_dp_mst_port *immediate_upstream_port; +struct drm_dp_mst_port *fec_port; + +if (!port) +return NULL ; + +if (port->parent) + immediate_upstream_port = port->parent->port_parent; +else + immediate_upstream_port =NULL ; + + fec_port = immediate_upstream_port; +while (fec_port) { +/* +* Each physical link (i.e. not a virtual port) between the +* output and the primary device must support FEC +*/ +if (!drm_dp_mst_is_virtual_dpcd (fec_port) && + !fec_port->fec_capable) +return NULL ; + + fec_port = fec_port->parent->port_parent; + } + +/* DP-to-DP peer device */ +if (drm_dp_mst_is_virtual_dpcd (immediate_upstream_port)) { +u8 upstream_dsc; +u8 endpoint_dsc; +u8 endpoint_fec; + +if (drm_dp_dpcd_read (&port->aux, +DP_DSC_SUPPORT , &endpoint_dsc,1 ) <0 ) +return NULL ; +if (drm_dp_dpcd_read (&port->aux, +DP_FEC_CAPABILITY , &endpoint_fec,1 ) <0 ) +return NULL ; +if (drm_dp_dpcd_read (&immediate_upstream_port->aux, +DP_DSC_SUPPORT , &upstream_dsc,1 ) <0 ) +return NULL ; + +/* Enpoint decompression with DP-to-DP peer device */ +if ((endpoint_dsc &DP_DSC_DECOMPRESSION_IS_SUPPORTED ) && + (endpoint_fec &DP_FEC_CAPABLE ) && + (upstream_dsc &0x2 )/* DSC passthrough */ ) +return &port->aux; + +/* Virtual DPCD decompression with DP-to-DP peer device */ +return &immediate_upstream_port->aux; + } + +/* Virtual DPCD decompression with DP-to-HDMI or Virtual DP Sink */ +if (drm_dp_mst_is_virtual_dpcd (port)) +return &port->aux; + +return NULL ; +} +EXPORT_SYMBOL (drm_dp_mst_dsc_aux_for_port);include/drm/drm_dp_mst_helper.h +2
-0@@ -673,6 +673,8 @@ int __must_check drm_dp_mst_atomic_check(struct drm_atomic_state *state);void drm_dp_mst_get_port_malloc (struct drm_dp_mst_port *port);void drm_dp_mst_put_port_malloc (struct drm_dp_mst_port *port); +struct drm_dp_aux *drm_dp_mst_dsc_aux_for_port (struct drm_dp_mst_port *port); + extern const struct drm_private_state_funcs
drm_dp_mst_topology_state_funcs;/**
Signature · 7 lines
Cheers, Lyude Paul _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Lyude Paul
Reviewed-byRe: [PATCH 09/15] drm/dp_mst: Add new quirk for Synaptics MST hubs
In reply to a message not in the archiveGreat work!
Quoted 106 lines · On Wed, 2019-09-18 at 16:26 -0400, [email protected] wrote:
From: David Francis <[email protected]>
Synaptics DP1.4 hubs (
BRANCH_ID0x90CC24) do not support virtual DPCD registers, but do support DSC. The DSC caps can be read from the physical aux, like in SST DSC. These hubs have many differentDEVICE_IDs. Add a new quirk to detect this case.Change-Id I9d332f273dfca0cfbced111e62f5a06c5c312893Cc Lyude Paul <[email protected]>Cc Jani Nikula <[email protected]>Cc Harry Wentland <[email protected]>Reviewed-by Wenjing Liu <[email protected]>Signed-off-by David Francis <[email protected]>--- drivers/gpu/drm/drm_dp_helper.c | 4 +++- drivers/gpu/drm/drm_dp_mst_topology.c | 27 +++++++++++++++++++++++++++ include/drm/drm_dp_helper.h | 7 +++++++ 3 files changed, 37 insertions(+), 1 deletion(-)drivers/gpu/drm/drm_dp_helper.c +3
-1@@ -1288,7 +1288,9 @@ static const struct dpcd_quirk dpcd_quirk_list[] = {/* LG LP140WF6-SPM1 eDP panel */ {OUI (0x00 ,0x22 ,0xb9 ),DEVICE_ID ('s' ,'i' ,'v' ,'a' ,'r' ,'T' ), false, BIT(DP_DPCD_QUIRK_CONSTANT_N) },/* Apple panels need some additional handling to support PSR */ - { OUI(0x00, 0x10, 0xfa), DEVICE_ID_ANY, false, BIT(DP_DPCD_QUIRK_NO_PSR) } + {OUI (0x00 ,0x10 ,0xfa ),DEVICE_ID_ANY , false, BIT(DP_DPCD_QUIRK_NO_PSR) }, +/* Synaptics DP1.4 MST hubs can support DSC without virtual DPCD */ + { OUI(0x90, 0xCC, 0x24), DEVICE_ID_ANY, true,
BIT(DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD)},
};#undef OUI
drivers/gpu/drm/drm_dp_mst_topology.c +1
-0@@ -4219,6 +4219,7 @@ struct drm_dp_aux *drm_dp_mst_dsc_aux_for_port(struct drm_dp_mst_port *port) {struct drm_dp_mst_port *immediate_upstream_port;struct drm_dp_mst_port *fec_port; +struct drm_dp_desc desc = {0 };if (!port)drivers/gpu/drm/drm_dp_mst_topology.c +26
-0return NULL ;@@ -4271,6 +4272,32 @@ struct drm_dp_aux *drm_dp_mst_dsc_aux_for_port(struct drm_dp_mst_port *port)if (drm_dp_mst_is_virtual_dpcd (port))return &port->aux; +/* +* Synaptics quirk +* Applies to ports for which: +* - Physical aux has Synaptics OUI +* - DPv1.4 or higher +* - Port is on primary branch device +* - Not a VGA adapter (DP_DWN_STRM_PORT_TYPE_ANALOG) +*/ +if (!drm_dp_read_desc (port->mgr->aux, &desc, true)) +return NULL ; + +if (drm_dp_has_quirk (&desc,DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD ) && + port->mgr->dpcd[DP_DPCD_REV ] >=DP_DPCD_REV_14 && + port->parent == port->mgr->mst_primary) { +u8 downstreamport; + +if (drm_dp_dpcd_read (&port->aux,DP_DOWNSTREAMPORT_PRESENT , + &downstreamport,1 ) <0 ) +return NULL ; + +if ((downstreamport &DP_DWN_STRM_PORT_PRESENT ) && + ((downstreamport &DP_DWN_STRM_PORT_TYPE_MASK ) + !=DP_DWN_STRM_PORT_TYPE_ANALOG )) +return port->mgr->aux; + } +return NULL ; }
EXPORT_SYMBOL(drm_dp_mst_dsc_aux_for_port);include/drm/drm_dp_helper.h +7
-0@@ -1414,6 +1414,13 @@ enum drm_dp_quirk {* driver still need to implement proper handling for such device. */ DP_DPCD_QUIRK_NO_PSR , +/** +* @DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD: +* +* The device supports MST DSC despite not supporting Virtual DPCD. +* The DSC caps can be read from the physical aux instead. +*/ + DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD, };/**
Signature · 7 lines
Cheers, Lyude Paul _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Lyude Paul
maintainerRe: [PATCH 15/15] drm/amd/display: Trigger modesets on MST DSC connectors
In reply to [email protected]This still needs to be moved into an atomic helper so it can be reused by other drivers
...
...
however, I've had this patch series on my mind for a while and something occurred to me that would be a lot easier. Why exactly are we not just enabling DSC wherever it's supported, regardless of whether or not it's actually needed to fit into bandwidth constraints? The reason I mention this is while only enabling DSC when needed makes perfect sense for SST, since I'd assume non-DSC consumes less power, it doesn't quite make sense for MST.
See: currently with MST (at least this is the case with i915, but I plan on making it the case with nouveau as well), we always default to link training at the maximum link rate/lane count. i915 does the opposite with SST for optimization, but we maximize for MST because maximizing the amount of bandwidth we have to work with means that we can enable new displays and disable displays without having to potentially update the rest of the topology with new PBN/VCPI allocations (unless the bandwidth restrictions get lowered later, of course).
An abstract example: Let's say a user has a hub setup with two displays, without DSC enabled. The user plugs in a third display, but this display won't fit into the available bandwidth without enabling DSC. But assuming enabling DSC causes us to need to recalculate the bandwidth for the other two displays, we end up having to do a modeset on all three displays.
Alternatively: the user has two displays again. This time though we started off by using DSC from the start, so adding a new display can be done without performing a modeset on the other two displays.
Taking this into consideration, wouldn't we be able to just get rid of this whole function by enabling DSC by default instead of as-needed? And get a nicer result?
Quoted 129 lines · On Wed, 2019-09-18 at 16:26 -0400, [email protected] wrote:
From: David Francis <[email protected]>
Whenever a connector on an MST network is attached, detached, or undergoes a modeset, the DSC configs for each stream on that topology will be recalculated. This can change their required bandwidth, requiring a full reprogramming, as though a modeset was performed, even if that stream did not change timing.
Therefore, whenever a crtc has
drm_atomic_crtc_needs_modeset, for each crtc that shares a MST topology with that stream and supports DSC, add that crtc (and all affected connectors and planes) to the atomic state and setmode_changedon its statev2: Do this check only on Navi and before adding connectors and planes on modesetting crtcs
Cc Leo Li <[email protected]>Cc Nicholas Kazlauskas <[email protected]>Cc Lyude Paul <[email protected]>Signed-off-by David Francis <[email protected]>--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +57
-0@@ -6704,6 +6704,74 @@ static int do_aquire_global_lock(struct drm_device *dev, return ret < 0 ? ret : 0; } +#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT +/* +* TODO: This logic should at some point be moved into DRM +*/ +static int add_affected_mst_dsc_crtcs (struct drm_atomic_state *state,struct drm_crtc *crtc) +{ +struct drm_connector *connector; +struct drm_connector_state *conn_state; +struct drm_connector_list_iter conn_iter; +struct drm_crtc_state *new_crtc_state; +struct amdgpu_dm_connector *aconnector =NULL , *aconnector_to_add; +int i, j; +struct drm_crtc *crtcs_affected[AMDGPU_MAX_CRTCS ] = {0 }; + +for_each_new_connector_in_state (state, connector, conn_state, i) { +if (conn_state->crtc != crtc) +continue ; + + aconnector =to_amdgpu_dm_connector (connector); +if (!aconnector->port) + aconnector =NULL ; +else +break ; + } + +if (!aconnector) +return 0 ; + + i =0 ; +drm_connector_list_iter_begin (state->dev, &conn_iter); +drm_for_each_connector_iter (connector, &conn_iter) { +if (!connector->state || !connector->state->crtc) +continue ; + + aconnector_to_add =to_amdgpu_dm_connector (connector); +if (!aconnector_to_add->port) +continue ; + +if (aconnector_to_add->port->mgr != aconnector->port->mgr) +continue ; + +if (!aconnector_to_add->dc_sink) +continue ; + +if (!aconnector_to_add->dc_sink- >sink_dsc_caps.dsc_dec_caps.is_dsc_supported) +continue ; + +if (i >=AMDGPU_MAX_CRTCS ) +continue ; + + crtcs_affected[i] = connector->state->crtc; + i++; + } +drm_connector_list_iter_end (&conn_iter); + +for (j =0 ; j < i; j++) { + new_crtc_state = drm_atomic_get_crtc_state(state,crtcs_affected[j]);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +22
-0+if (IS_ERR (new_crtc_state)) +return PTR_ERR (new_crtc_state); + + new_crtc_state->mode_changed = true; + } + +return 0 ; + +} +#endif +static void get_freesync_config_for_crtc (struct dm_crtc_state *new_crtc_state,struct dm_connector_state *new_con_state)@@ -7388,6 +7456,17 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev, if (ret) goto fail; +#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT +if (adev->asic_type >=CHIP_NAVI10 ) { +for_each_oldnew_crtc_in_state (state, crtc, old_crtc_state, new_crtc_state, i) { +if (drm_atomic_crtc_needs_modeset (new_crtc_state)) { + ret =add_affected_mst_dsc_crtcs (state, crtc); +if (ret) + goto fail; + } + } + } +#endif for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state,
new_crtc_state, i) {drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-0if (!drm_atomic_crtc_needs_modeset(new_crtc_state) && !new_crtc_state->color_mgmt_changed &&
Signature · 7 lines
Cheers, Lyude Paul _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 15/15] drm/amd/display: Trigger modesets on MST DSC connectors
In reply to a message not in the archiveQuoted 2 lines · Lyude Paul
This still needs to be moved into an atomic helper so it can be reused by other drivers
It would be a future to move the implementation to a contained atomic helper.
Quoted 25 lines
...
...however, I've had this patch series on my mind for a while and something occurred to me that would be a lot easier. Why exactly are we not just enabling DSC wherever it's supported, regardless of whether or not it's actually needed to fit into bandwidth constraints? The reason I mention this is while only enabling DSC when needed makes perfect sense for SST, since I'd assume non-DSC consumes less power, it doesn't quite make sense for MST.
See: currently with MST (at least this is the case with i915, but I plan on making it the case with nouveau as well), we always default to link training at the maximum link rate/lane count. i915 does the opposite with SST for optimization, but we maximize for MST because maximizing the amount of bandwidth we have to work with means that we can enable new displays and disable displays without having to potentially update the rest of the topology with new PBN/VCPI allocations (unless the bandwidth restrictions get lowered later, of course).
An abstract example: Let's say a user has a hub setup with two displays, without DSC enabled. The user plugs in a third display, but this display won't fit into the available bandwidth without enabling DSC. But assuming enabling DSC causes us to need to recalculate the bandwidth for the other two displays, we end up having to do a modeset on all three displays.
Quoted 7 lines
Alternatively: the user has two displays again. This time though we started off by using DSC from the start, so adding a new display can be done without performing a modeset on the other two displays.
Taking this into consideration, wouldn't we be able to just get rid of this whole function by enabling DSC by default instead of as-needed? And get a nicer result?
The idea of enabling DSC from the beginning does sound appealing, but DSC is a lossy compression and we think it is better to enable it only when we need it, not to degrade picture quality. The greedy algorithm developed by David Francis in his patch "MST DSC compute fair share" tries to minimize compression and enable maximum number of streams without it, so they won't lose the picture quality.
That being said, I agree, the implementation of DSC code would be much simpler if we would just enable DSC from the beginning, but again we do not want to compromise the picture quality.
Quoted 131 lines · On Wed, 2019-09-18 at 16:26 -0400, [email protected] wrote:
Quoted 129 lines
From: David Francis <[email protected]>
Whenever a connector on an MST network is attached, detached, or undergoes a modeset, the DSC configs for each stream on that topology will be recalculated. This can change their required bandwidth, requiring a full reprogramming, as though a modeset was performed, even if that stream did not change timing.
Therefore, whenever a crtc has
drm_atomic_crtc_needs_modeset, for each crtc that shares a MST topology with that stream and supports DSC, add that crtc (and all affected connectors and planes) to the atomic state and setmode_changedon its statev2: Do this check only on Navi and before adding connectors and planes on modesetting crtcs
Cc Leo Li <[email protected]>Cc Nicholas Kazlauskas <[email protected]>Cc Lyude Paul <[email protected]>Signed-off-by David Francis <[email protected]>--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +57
-0@@ -6704,6 +6704,74 @@ static int do_aquire_global_lock(struct drm_device *dev, return ret < 0 ? ret : 0; } +#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT +/* +* TODO: This logic should at some point be moved into DRM +*/ +static int add_affected_mst_dsc_crtcs (struct drm_atomic_state *state,struct drm_crtc *crtc) +{ +struct drm_connector *connector; +struct drm_connector_state *conn_state; +struct drm_connector_list_iter conn_iter; +struct drm_crtc_state *new_crtc_state; +struct amdgpu_dm_connector *aconnector =NULL , *aconnector_to_add; +int i, j; +struct drm_crtc *crtcs_affected[AMDGPU_MAX_CRTCS ] = {0 }; + +for_each_new_connector_in_state (state, connector, conn_state, i) { +if (conn_state->crtc != crtc) +continue ; + + aconnector =to_amdgpu_dm_connector (connector); +if (!aconnector->port) + aconnector =NULL ; +else +break ; + } + +if (!aconnector) +return 0 ; + + i =0 ; +drm_connector_list_iter_begin (state->dev, &conn_iter); +drm_for_each_connector_iter (connector, &conn_iter) { +if (!connector->state || !connector->state->crtc) +continue ; + + aconnector_to_add =to_amdgpu_dm_connector (connector); +if (!aconnector_to_add->port) +continue ; + +if (aconnector_to_add->port->mgr != aconnector->port->mgr) +continue ; + +if (!aconnector_to_add->dc_sink) +continue ; + +if (!aconnector_to_add->dc_sink- > sink_dsc_caps.dsc_dec_caps.is_dsc_supported) +continue ; + +if (i >=AMDGPU_MAX_CRTCS ) +continue ; + + crtcs_affected[i] = connector->state->crtc; + i++; + } +drm_connector_list_iter_end (&conn_iter); + +for (j =0 ; j < i; j++) { + new_crtc_state = drm_atomic_get_crtc_state(state,crtcs_affected[j]);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +22
-0+if (IS_ERR (new_crtc_state)) +return PTR_ERR (new_crtc_state); + + new_crtc_state->mode_changed = true; + } + +return 0 ; + +} +#endif +static void get_freesync_config_for_crtc (struct dm_crtc_state *new_crtc_state,struct dm_connector_state *new_con_state)@@ -7388,6 +7456,17 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev, if (ret) goto fail; +#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT +if (adev->asic_type >=CHIP_NAVI10 ) { +for_each_oldnew_crtc_in_state (state, crtc, old_crtc_state, new_crtc_state, i) { +if (drm_atomic_crtc_needs_modeset (new_crtc_state)) { + ret =add_affected_mst_dsc_crtcs (state, crtc); +if (ret) + goto fail; + } + } + } +#endif for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state,
new_crtc_state, i) {
if (!drm_atomic_crtc_needs_modeset(new_crtc_state) &&
!new_crtc_state->color_mgmt_changed &&
Signature · 8 lines
Thanks, Mikita Lipski Software Engineer 2, AMD [email protected] _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx