Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amd/display: Correct the plane enumeration order (v2)

The order of planes is given by the order they are enumerated
by kms.
Planes with a higher ID appears above planes with a lower ID.

Currently the planes are enumerated in the wrong order,
putting the nv12 only plane after the two RGBA planes.

This patch corrects the plane enumeration order such that all
the overlay planes are initialized first then the primary planes.

Due to this change in order the dc_add_plane_to_context() shall
receive the planes in reverse order hence this patch reverses
the parsing of planes in DM side itself.

v2: drop local reverse macro for upstream

Signed-off-by: Shirish S <shirish.s@amd.com>
Signed-off-by: Pratik Vishwakarma <Pratik.Vishwakarma@amd.com>
Reviewed-by: Harry Wentland <Harry.Wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Shirish S and committed by
Alex Deucher
df534fff 9eee2137

+53 -24
+53 -24
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
··· 1365 1365 1366 1366 #endif 1367 1367 1368 + static int initialize_plane(struct amdgpu_display_manager *dm, 1369 + struct amdgpu_mode_info *mode_info, 1370 + int plane_id) 1371 + { 1372 + struct amdgpu_plane *plane; 1373 + unsigned long possible_crtcs; 1374 + int ret = 0; 1375 + 1376 + plane = kzalloc(sizeof(struct amdgpu_plane), GFP_KERNEL); 1377 + mode_info->planes[plane_id] = plane; 1378 + 1379 + if (!plane) { 1380 + DRM_ERROR("KMS: Failed to allocate plane\n"); 1381 + return -ENOMEM; 1382 + } 1383 + plane->base.type = mode_info->plane_type[plane_id]; 1384 + 1385 + /* 1386 + * HACK: IGT tests expect that each plane can only have one 1387 + * one possible CRTC. For now, set one CRTC for each 1388 + * plane that is not an underlay, but still allow multiple 1389 + * CRTCs for underlay planes. 1390 + */ 1391 + possible_crtcs = 1 << plane_id; 1392 + if (plane_id >= dm->dc->caps.max_streams) 1393 + possible_crtcs = 0xff; 1394 + 1395 + ret = amdgpu_dm_plane_init(dm, mode_info->planes[plane_id], possible_crtcs); 1396 + 1397 + if (ret) { 1398 + DRM_ERROR("KMS: Failed to initialize plane\n"); 1399 + return ret; 1400 + } 1401 + 1402 + return ret; 1403 + } 1404 + 1368 1405 /* In this architecture, the association 1369 1406 * connector -> encoder -> crtc 1370 1407 * id not really requried. The crtc and connector will hold the ··· 1412 1375 static int amdgpu_dm_initialize_drm_device(struct amdgpu_device *adev) 1413 1376 { 1414 1377 struct amdgpu_display_manager *dm = &adev->dm; 1415 - uint32_t i; 1378 + int32_t i; 1416 1379 struct amdgpu_dm_connector *aconnector = NULL; 1417 1380 struct amdgpu_encoder *aencoder = NULL; 1418 1381 struct amdgpu_mode_info *mode_info = &adev->mode_info; 1419 1382 uint32_t link_cnt; 1420 - unsigned long possible_crtcs; 1383 + int32_t total_overlay_planes, total_primary_planes; 1421 1384 1422 1385 link_cnt = dm->dc->caps.max_links; 1423 1386 if (amdgpu_dm_mode_config_init(dm->adev)) { ··· 1425 1388 return -1; 1426 1389 } 1427 1390 1428 - for (i = 0; i < dm->dc->caps.max_planes; i++) { 1429 - struct amdgpu_plane *plane; 1391 + /* Identify the number of planes to be initialized */ 1392 + total_overlay_planes = dm->dc->caps.max_slave_planes; 1393 + total_primary_planes = dm->dc->caps.max_planes - dm->dc->caps.max_slave_planes; 1430 1394 1431 - plane = kzalloc(sizeof(struct amdgpu_plane), GFP_KERNEL); 1432 - mode_info->planes[i] = plane; 1433 - 1434 - if (!plane) { 1435 - DRM_ERROR("KMS: Failed to allocate plane\n"); 1395 + /* First initialize overlay planes, index starting after primary planes */ 1396 + for (i = (total_overlay_planes - 1); i >= 0; i--) { 1397 + if (initialize_plane(dm, mode_info, (total_primary_planes + i))) { 1398 + DRM_ERROR("KMS: Failed to initialize overlay plane\n"); 1436 1399 goto fail; 1437 1400 } 1438 - plane->base.type = mode_info->plane_type[i]; 1401 + } 1439 1402 1440 - /* 1441 - * HACK: IGT tests expect that each plane can only have one 1442 - * one possible CRTC. For now, set one CRTC for each 1443 - * plane that is not an underlay, but still allow multiple 1444 - * CRTCs for underlay planes. 1445 - */ 1446 - possible_crtcs = 1 << i; 1447 - if (i >= dm->dc->caps.max_streams) 1448 - possible_crtcs = 0xff; 1449 - 1450 - if (amdgpu_dm_plane_init(dm, mode_info->planes[i], possible_crtcs)) { 1451 - DRM_ERROR("KMS: Failed to initialize plane\n"); 1403 + /* Initialize primary planes */ 1404 + for (i = (total_primary_planes - 1); i >= 0; i--) { 1405 + if (initialize_plane(dm, mode_info, i)) { 1406 + DRM_ERROR("KMS: Failed to initialize primary plane\n"); 1452 1407 goto fail; 1453 1408 } 1454 1409 } ··· 4724 4695 int ret = 0; 4725 4696 4726 4697 4727 - /* Add new planes */ 4728 - for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) { 4698 + /* Add new planes, in reverse order as DC expectation */ 4699 + for_each_oldnew_plane_in_state_reverse(state, plane, old_plane_state, new_plane_state, i) { 4729 4700 new_plane_crtc = new_plane_state->crtc; 4730 4701 old_plane_crtc = old_plane_state->crtc; 4731 4702 dm_new_plane_state = to_dm_plane_state(new_plane_state);