RE: [PATCH v3] drm/amd/display: Refactor construct_phy function in dc/link/link_factory.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[AMD Official Use Only - AMD Internal Distribution Only]

Reviewed-by: Wenjing Liu <wenjing.liu@xxxxxxx>

-----Original Message-----
From: SHANMUGAM, SRINIVASAN <SRINIVASAN.SHANMUGAM@xxxxxxx>
Sent: Friday, May 10, 2024 6:12 AM
To: Liu, Wenjing <Wenjing.Liu@xxxxxxx>; Siqueira, Rodrigo <Rodrigo.Siqueira@xxxxxxx>; Pillai, Aurabindo <Aurabindo.Pillai@xxxxxxx>
Cc: amd-gfx@xxxxxxxxxxxxxxxxxxxxx; SHANMUGAM, SRINIVASAN <SRINIVASAN.SHANMUGAM@xxxxxxx>; Zuo, Jerry <Jerry.Zuo@xxxxxxx>; Zhuo, Lillian <Qingqing.Zhuo@xxxxxxx>; Chung, ChiaHsuan (Tom) <ChiaHsuan.Chung@xxxxxxx>; Lee, Alvin <Alvin.Lee2@xxxxxxx>; Li, Roman <Roman.Li@xxxxxxx>; Wu, Hersen <hersenxs.wu@xxxxxxx>; Hung, Alex <Alex.Hung@xxxxxxx>; Wentland, Harry <Harry.Wentland@xxxxxxx>
Subject: [PATCH v3] drm/amd/display: Refactor construct_phy function in dc/link/link_factory.c

This commit modifies the construct_phy function to handle the case where `bios->integrated_info` is NULL and to address a compiler warning about a large stack allocation.

Upon examination, it was found that the local `integrated_info` structure was just used to copy values which is large and was being declared directly on the stack which could potentially lead to performance issues. This commit changes the code to use `bios->integrated_info` directly, which avoids the need for a large stack allocation.

The function now checks if `bios->integrated_info` is NULL before entering a for loop that uses it. If `bios->integrated_info` is NULL, the function skips the for loop and continues executing the rest of the code. This ensures that the function behaves correctly when `bios->integrated_info` is NULL and improves compatibility with dGPUs.

Fixes the below with gcc W=1:
drivers/gpu/drm/amd/amdgpu/../display/dc/link/link_factory.c: In function ‘construct_phy’:
drivers/gpu/drm/amd/amdgpu/../display/dc/link/link_factory.c:743:1: warning: the frame size of 1056 bytes is larger than 1024 bytes [-Wframe-larger-than=]

Cc: Wenjing Liu <wenjing.liu@xxxxxxx>
Cc: Jerry Zuo <jerry.zuo@xxxxxxx>
Cc: Qingqing Zhuo <qingqing.zhuo@xxxxxxx>
Cc: Tom Chung <chiahsuan.chung@xxxxxxx>
Cc: Alvin Lee <alvin.lee2@xxxxxxx>
Cc: Rodrigo Siqueira <Rodrigo.Siqueira@xxxxxxx>
Cc: Roman Li <roman.li@xxxxxxx>
Cc: Hersen Wu <hersenxs.wu@xxxxxxx>
Cc: Alex Hung <alex.hung@xxxxxxx>
Cc: Aurabindo Pillai <aurabindo.pillai@xxxxxxx>
Cc: Harry Wentland <harry.wentland@xxxxxxx>
Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@xxxxxxx>
Suggested-by: Wenjing Liu <wenjing.liu@xxxxxxx>
---
v3:
 - Directly used bios->integrated_info instead of integrated_info to
   avoid large copying (Wenjing)

 .../drm/amd/display/dc/link/link_factory.c    | 67 ++++++++++---------
 1 file changed, 34 insertions(+), 33 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/link/link_factory.c b/drivers/gpu/drm/amd/display/dc/link/link_factory.c
index 2c3f5d662285..8073fdae9cb1 100644
--- a/drivers/gpu/drm/amd/display/dc/link/link_factory.c
+++ b/drivers/gpu/drm/amd/display/dc/link/link_factory.c
@@ -456,7 +456,6 @@ static bool construct_phy(struct dc_link *link,
        struct dc_context *dc_ctx = init_params->ctx;
        struct encoder_init_data enc_init_data = { 0 };
        struct panel_cntl_init_data panel_cntl_init_data = { 0 };
-       struct integrated_info info = { 0 };
        struct dc_bios *bios = init_params->dc->ctx->dc_bios;
        const struct dc_vbios_funcs *bp_funcs = bios->funcs;
        struct bp_disp_connector_caps_info disp_connect_caps_info = { 0 }; @@ -671,42 +670,44 @@ static bool construct_phy(struct dc_link *link,
                break;
        }

-       if (bios->integrated_info)
-               info = *bios->integrated_info;
-
-       /* Look for channel mapping corresponding to connector and device tag */
-       for (i = 0; i < MAX_NUMBER_OF_EXT_DISPLAY_PATH; i++) {
-               struct external_display_path *path =
-                       &info.ext_disp_conn_info.path[i];
-
-               if (path->device_connector_id.enum_id == link->link_id.enum_id &&
-                   path->device_connector_id.id == link->link_id.id &&
-                   path->device_connector_id.type == link->link_id.type) {
-                       if (link->device_tag.acpi_device != 0 &&
-                           path->device_acpi_enum == link->device_tag.acpi_device) {
-                               link->ddi_channel_mapping = path->channel_mapping;
-                               link->chip_caps = path->caps;
-                               DC_LOG_DC("BIOS object table - ddi_channel_mapping: 0x%04X", link->ddi_channel_mapping.raw);
-                               DC_LOG_DC("BIOS object table - chip_caps: %d", link->chip_caps);
-                       } else if (path->device_tag ==
-                                  link->device_tag.dev_id.raw_device_tag) {
-                               link->ddi_channel_mapping = path->channel_mapping;
-                               link->chip_caps = path->caps;
-                               DC_LOG_DC("BIOS object table - ddi_channel_mapping: 0x%04X", link->ddi_channel_mapping.raw);
-                               DC_LOG_DC("BIOS object table - chip_caps: %d", link->chip_caps);
-                       }
+       if (bios->integrated_info) {
+               /* Look for channel mapping corresponding to connector and device tag */
+               for (i = 0; i < MAX_NUMBER_OF_EXT_DISPLAY_PATH; i++) {
+                       struct external_display_path *path =
+                               &bios->integrated_info->ext_disp_conn_info.path[i];
+
+                       if (path->device_connector_id.enum_id == link->link_id.enum_id &&
+                           path->device_connector_id.id == link->link_id.id &&
+                           path->device_connector_id.type == link->link_id.type) {
+                               if (link->device_tag.acpi_device != 0 &&
+                                   path->device_acpi_enum == link->device_tag.acpi_device) {
+                                       link->ddi_channel_mapping = path->channel_mapping;
+                                       link->chip_caps = path->caps;
+                                       DC_LOG_DC("BIOS object table - ddi_channel_mapping: 0x%04X",
+                                                 link->ddi_channel_mapping.raw);
+                                       DC_LOG_DC("BIOS object table - chip_caps: %d",
+                                                 link->chip_caps);
+                               } else if (path->device_tag ==
+                                          link->device_tag.dev_id.raw_device_tag) {
+                                       link->ddi_channel_mapping = path->channel_mapping;
+                                       link->chip_caps = path->caps;
+                                       DC_LOG_DC("BIOS object table - ddi_channel_mapping: 0x%04X",
+                                                 link->ddi_channel_mapping.raw);
+                                       DC_LOG_DC("BIOS object table - chip_caps: %d",
+                                                 link->chip_caps);
+                               }
+
+                               if (link->chip_caps & EXT_DISPLAY_PATH_CAPS__DP_FIXED_VS_EN) {
+                                       link->bios_forced_drive_settings.VOLTAGE_SWING =
+                                               (bios->integrated_info->ext_disp_conn_info.fixdpvoltageswing & 0x3);
+                                       link->bios_forced_drive_settings.PRE_EMPHASIS =
+                                               ((bios->integrated_info->ext_disp_conn_info.fixdpvoltageswing >> 2) & 0x3);
+                               }

-                       if (link->chip_caps & EXT_DISPLAY_PATH_CAPS__DP_FIXED_VS_EN) {
-                               link->bios_forced_drive_settings.VOLTAGE_SWING =
-                                               (info.ext_disp_conn_info.fixdpvoltageswing & 0x3);
-                               link->bios_forced_drive_settings.PRE_EMPHASIS =
-                                               ((info.ext_disp_conn_info.fixdpvoltageswing >> 2) & 0x3);
+                               break;
                        }
-
-                       break;
                }
        }
-
        if (bios->funcs->get_atom_dc_golden_table)
                bios->funcs->get_atom_dc_golden_table(bios);

--
2.34.1





[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux