Skip to content

Commit 3168470

Browse files
committed
drm/amdgpu/display: create fake mst encoders ahead of time (v4)
Prevents a warning in the MST create connector case. v2: create global fake encoders rather per connector fake encoders to avoid running out of encoder indices. v3: use the actual number of crtcs on the asic rather than the max to conserve encoders. v4: v3 plus missing hunk I forgot to git add. Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/1108 Fixes: c6385e5 ("drm/amdgpu: drop legacy drm load and unload callbacks") Reviewed-by: Nicholas Kazlauskas <[email protected]> Signed-off-by: Alex Deucher <[email protected]> Cc: [email protected] # 5.7.x
1 parent d845a20 commit 3168470

File tree

4 files changed

+48
-28
lines changed

4 files changed

+48
-28
lines changed

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,9 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
974974
/* Update the actual used number of crtc */
975975
adev->mode_info.num_crtc = adev->dm.display_indexes_num;
976976

977+
/* create fake encoders for MST */
978+
dm_dp_create_fake_mst_encoders(adev);
979+
977980
/* TODO: Add_display_info? */
978981

979982
/* TODO use dynamic cursor width */
@@ -997,6 +1000,12 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
9971000

9981001
static void amdgpu_dm_fini(struct amdgpu_device *adev)
9991002
{
1003+
int i;
1004+
1005+
for (i = 0; i < adev->dm.display_indexes_num; i++) {
1006+
drm_encoder_cleanup(&adev->dm.mst_encoders[i].base);
1007+
}
1008+
10001009
amdgpu_dm_audio_fini(adev);
10011010

10021011
amdgpu_dm_destroy_drm_device(&adev->dm);

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
*/
4444

4545
#define AMDGPU_DM_MAX_DISPLAY_INDEX 31
46+
47+
#define AMDGPU_DM_MAX_CRTC 6
48+
4649
/*
4750
#include "include/amdgpu_dal_power_if.h"
4851
#include "amdgpu_dm_irq.h"
@@ -328,6 +331,13 @@ struct amdgpu_display_manager {
328331
* available in FW
329332
*/
330333
const struct gpu_info_soc_bounding_box_v1_0 *soc_bounding_box;
334+
335+
/**
336+
* @mst_encoders:
337+
*
338+
* fake encoders used for DP MST.
339+
*/
340+
struct amdgpu_encoder mst_encoders[AMDGPU_DM_MAX_CRTC];
331341
};
332342

333343
struct amdgpu_dm_connector {
@@ -356,7 +366,6 @@ struct amdgpu_dm_connector {
356366
struct amdgpu_dm_dp_aux dm_dp_aux;
357367
struct drm_dp_mst_port *port;
358368
struct amdgpu_dm_connector *mst_port;
359-
struct amdgpu_encoder *mst_encoder;
360369
struct drm_dp_aux *dsc_aux;
361370

362371
/* TODO see if we can merge with ddc_bus or make a dm_connector */

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ dm_dp_mst_connector_destroy(struct drm_connector *connector)
9595
{
9696
struct amdgpu_dm_connector *aconnector =
9797
to_amdgpu_dm_connector(connector);
98-
struct amdgpu_encoder *amdgpu_encoder = aconnector->mst_encoder;
9998

10099
if (aconnector->dc_sink) {
101100
dc_link_remove_remote_sink(aconnector->dc_link,
@@ -105,8 +104,6 @@ dm_dp_mst_connector_destroy(struct drm_connector *connector)
105104

106105
kfree(aconnector->edid);
107106

108-
drm_encoder_cleanup(&amdgpu_encoder->base);
109-
kfree(amdgpu_encoder);
110107
drm_connector_cleanup(connector);
111108
drm_dp_mst_put_port_malloc(aconnector->port);
112109
kfree(aconnector);
@@ -243,7 +240,11 @@ static struct drm_encoder *
243240
dm_mst_atomic_best_encoder(struct drm_connector *connector,
244241
struct drm_connector_state *connector_state)
245242
{
246-
return &to_amdgpu_dm_connector(connector)->mst_encoder->base;
243+
struct drm_device *dev = connector->dev;
244+
struct amdgpu_device *adev = dev->dev_private;
245+
struct amdgpu_crtc *acrtc = to_amdgpu_crtc(connector_state->crtc);
246+
247+
return &adev->dm.mst_encoders[acrtc->crtc_id].base;
247248
}
248249

249250
static int
@@ -306,31 +307,27 @@ static const struct drm_encoder_funcs amdgpu_dm_encoder_funcs = {
306307
.destroy = amdgpu_dm_encoder_destroy,
307308
};
308309

309-
static struct amdgpu_encoder *
310-
dm_dp_create_fake_mst_encoder(struct amdgpu_dm_connector *connector)
310+
void
311+
dm_dp_create_fake_mst_encoders(struct amdgpu_device *adev)
311312
{
312-
struct drm_device *dev = connector->base.dev;
313-
struct amdgpu_device *adev = dev->dev_private;
314-
struct amdgpu_encoder *amdgpu_encoder;
315-
struct drm_encoder *encoder;
316-
317-
amdgpu_encoder = kzalloc(sizeof(*amdgpu_encoder), GFP_KERNEL);
318-
if (!amdgpu_encoder)
319-
return NULL;
313+
struct drm_device *dev = adev->ddev;
314+
int i;
320315

321-
encoder = &amdgpu_encoder->base;
322-
encoder->possible_crtcs = amdgpu_dm_get_encoder_crtc_mask(adev);
316+
for (i = 0; i < adev->dm.display_indexes_num; i++) {
317+
struct amdgpu_encoder *amdgpu_encoder = &adev->dm.mst_encoders[i];
318+
struct drm_encoder *encoder = &amdgpu_encoder->base;
323319

324-
drm_encoder_init(
325-
dev,
326-
&amdgpu_encoder->base,
327-
&amdgpu_dm_encoder_funcs,
328-
DRM_MODE_ENCODER_DPMST,
329-
NULL);
320+
encoder->possible_crtcs = amdgpu_dm_get_encoder_crtc_mask(adev);
330321

331-
drm_encoder_helper_add(encoder, &amdgpu_dm_encoder_helper_funcs);
322+
drm_encoder_init(
323+
dev,
324+
&amdgpu_encoder->base,
325+
&amdgpu_dm_encoder_funcs,
326+
DRM_MODE_ENCODER_DPMST,
327+
NULL);
332328

333-
return amdgpu_encoder;
329+
drm_encoder_helper_add(encoder, &amdgpu_dm_encoder_helper_funcs);
330+
}
334331
}
335332

336333
static struct drm_connector *
@@ -343,6 +340,7 @@ dm_dp_add_mst_connector(struct drm_dp_mst_topology_mgr *mgr,
343340
struct amdgpu_device *adev = dev->dev_private;
344341
struct amdgpu_dm_connector *aconnector;
345342
struct drm_connector *connector;
343+
int i;
346344

347345
aconnector = kzalloc(sizeof(*aconnector), GFP_KERNEL);
348346
if (!aconnector)
@@ -369,9 +367,10 @@ dm_dp_add_mst_connector(struct drm_dp_mst_topology_mgr *mgr,
369367
master->dc_link,
370368
master->connector_id);
371369

372-
aconnector->mst_encoder = dm_dp_create_fake_mst_encoder(master);
373-
drm_connector_attach_encoder(&aconnector->base,
374-
&aconnector->mst_encoder->base);
370+
for (i = 0; i < adev->dm.display_indexes_num; i++) {
371+
drm_connector_attach_encoder(&aconnector->base,
372+
&adev->dm.mst_encoders[i].base);
373+
}
375374

376375
connector->max_bpc_property = master->base.max_bpc_property;
377376
if (connector->max_bpc_property)

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ void amdgpu_dm_initialize_dp_connector(struct amdgpu_display_manager *dm,
3535
struct amdgpu_dm_connector *aconnector,
3636
int link_index);
3737

38+
void
39+
dm_dp_create_fake_mst_encoders(struct amdgpu_device *adev);
40+
3841
#if defined(CONFIG_DRM_AMD_DC_DCN)
3942
bool compute_mst_dsc_configs_for_state(struct drm_atomic_state *state,
4043
struct dc_state *dc_state);

0 commit comments

Comments
 (0)