diff mbox series

[v4,11/11] drm/amd/display: remove dc_edid handler from dm_helpers_parse_edid_caps

Message ID 20240706034004.801329-12-mwen@igalia.com (mailing list archive)
State New, archived
Headers show
Series drm/amd/display: switch amdgpu_dm_connector to use struct drm_edid | expand

Commit Message

Melissa Wen July 6, 2024, 3:35 a.m. UTC
We can parse edid caps from drm_edid and drm_eld and any calls of
dm_helpers_parse_edid_caps is made in a state that we have drm_edid set
to amdgpu connector.

Signed-off-by: Melissa Wen <mwen@igalia.com>
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  6 ++--
 .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 29 +++++++++----------
 drivers/gpu/drm/amd/display/dc/dm_helpers.h   |  1 -
 .../drm/amd/display/dc/link/link_detection.c  |  6 ++--
 4 files changed, 17 insertions(+), 25 deletions(-)

Comments

kernel test robot July 7, 2024, 2:24 a.m. UTC | #1
Hi Melissa,

kernel test robot noticed the following build warnings:

[auto build test WARNING on next-20240703]
[cannot apply to amd-pstate/linux-next amd-pstate/bleeding-edge linus/master v6.10-rc6 v6.10-rc5 v6.10-rc4 v6.10-rc6]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Melissa-Wen/drm-amd-display-clean-unused-variables-for-hdmi-freesync-parser/20240706-121621
base:   next-20240703
patch link:    https://lore.kernel.org/r/20240706034004.801329-12-mwen%40igalia.com
patch subject: [PATCH v4 11/11] drm/amd/display: remove dc_edid handler from dm_helpers_parse_edid_caps
config: loongarch-allmodconfig (https://download.01.org/0day-ci/archive/20240707/202407071047.0LkXU4JN-lkp@intel.com/config)
compiler: loongarch64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240707/202407071047.0LkXU4JN-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202407071047.0LkXU4JN-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_helpers.c:92: warning: Excess function parameter 'edid' description in 'dm_helpers_parse_edid_caps'


vim +92 drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_helpers.c

613a7956deb3b1 Aurabindo Pillai     2023-06-12   79  
4855fdb5fc5488 Melissa Wen          2024-07-06   80  #define AMDGPU_ELD_DISPLAY_NAME_SIZE_IN_CHARS 13
f0b60e6e9b2ba3 Srinivasan Shanmugam 2023-07-13   81  /**
f0b60e6e9b2ba3 Srinivasan Shanmugam 2023-07-13   82   * dm_helpers_parse_edid_caps() - Parse edid caps
4562236b3bc0a2 Harry Wentland       2017-09-12   83   *
f0b60e6e9b2ba3 Srinivasan Shanmugam 2023-07-13   84   * @link: current detected link
4562236b3bc0a2 Harry Wentland       2017-09-12   85   * @edid:	[in] pointer to edid
f0b60e6e9b2ba3 Srinivasan Shanmugam 2023-07-13   86   * @edid_caps:	[in] pointer to edid caps
f0b60e6e9b2ba3 Srinivasan Shanmugam 2023-07-13   87   *
f0b60e6e9b2ba3 Srinivasan Shanmugam 2023-07-13   88   * Return: void
f0b60e6e9b2ba3 Srinivasan Shanmugam 2023-07-13   89   */
4dbd1b96ef4bca Melissa Wen          2024-07-06   90  enum dc_edid_status dm_helpers_parse_edid_caps(struct dc_link *link,
4562236b3bc0a2 Harry Wentland       2017-09-12   91  					       struct dc_edid_caps *edid_caps)
4562236b3bc0a2 Harry Wentland       2017-09-12  @92  {
3c021931023a30 Claudio Suarez       2021-10-17   93  	struct amdgpu_dm_connector *aconnector = link->priv;
3c021931023a30 Claudio Suarez       2021-10-17   94  	struct drm_connector *connector = &aconnector->base;
766cded62d4ba6 Melissa Wen          2024-07-06   95  	const struct drm_edid *drm_edid = aconnector->drm_edid;
766cded62d4ba6 Melissa Wen          2024-07-06   96  	struct drm_edid_product_id product_id;
c3e817e49503e3 Melissa Wen          2024-07-06   97  	int sad_count;
4562236b3bc0a2 Harry Wentland       2017-09-12   98  	int i = 0;
4562236b3bc0a2 Harry Wentland       2017-09-12   99  	enum dc_edid_status result = EDID_OK;
4562236b3bc0a2 Harry Wentland       2017-09-12  100  
4dbd1b96ef4bca Melissa Wen          2024-07-06  101  	if (!edid_caps || !drm_edid)
4562236b3bc0a2 Harry Wentland       2017-09-12  102  		return EDID_BAD_INPUT;
4562236b3bc0a2 Harry Wentland       2017-09-12  103  
766cded62d4ba6 Melissa Wen          2024-07-06  104  	drm_edid_get_product_id(drm_edid, &product_id);
766cded62d4ba6 Melissa Wen          2024-07-06  105  
766cded62d4ba6 Melissa Wen          2024-07-06  106  	edid_caps->manufacturer_id = le16_to_cpu(product_id.manufacturer_name);
766cded62d4ba6 Melissa Wen          2024-07-06  107  	edid_caps->product_id = le16_to_cpu(product_id.product_code);
766cded62d4ba6 Melissa Wen          2024-07-06  108  	edid_caps->serial_number = le32_to_cpu(product_id.serial_number);
766cded62d4ba6 Melissa Wen          2024-07-06  109  	edid_caps->manufacture_week = product_id.week_of_manufacture;
766cded62d4ba6 Melissa Wen          2024-07-06  110  	edid_caps->manufacture_year = product_id.year_of_manufacture;
4562236b3bc0a2 Harry Wentland       2017-09-12  111  
4855fdb5fc5488 Melissa Wen          2024-07-06  112  	memset(edid_caps->display_name, 0, AUDIO_INFO_DISPLAY_NAME_SIZE_IN_CHARS);
4855fdb5fc5488 Melissa Wen          2024-07-06  113  	memcpy(edid_caps->display_name,
4855fdb5fc5488 Melissa Wen          2024-07-06  114  	       &connector->eld[DRM_ELD_MONITOR_NAME_STRING],
4855fdb5fc5488 Melissa Wen          2024-07-06  115  	       AMDGPU_ELD_DISPLAY_NAME_SIZE_IN_CHARS);
4562236b3bc0a2 Harry Wentland       2017-09-12  116  
3c021931023a30 Claudio Suarez       2021-10-17  117  	edid_caps->edid_hdmi = connector->display_info.is_hdmi;
4562236b3bc0a2 Harry Wentland       2017-09-12  118  
766cded62d4ba6 Melissa Wen          2024-07-06  119  	apply_edid_quirks(&product_id, edid_caps);
b7cdccc6a84956 Ryan Lin             2024-02-28  120  
b13a74b7280b1a Melissa Wen          2024-07-06  121  	sad_count = drm_eld_sad_count(connector->eld);
ae2a3495973ef0 Jean Delvare         2019-09-04  122  	if (sad_count <= 0)
4562236b3bc0a2 Harry Wentland       2017-09-12  123  		return result;
4562236b3bc0a2 Harry Wentland       2017-09-12  124  
1347b15d5e8e16 Srinivasan Shanmugam 2023-08-13  125  	edid_caps->audio_mode_count = min(sad_count, DC_MAX_AUDIO_DESC_COUNT);
4562236b3bc0a2 Harry Wentland       2017-09-12  126  	for (i = 0; i < edid_caps->audio_mode_count; ++i) {
b13a74b7280b1a Melissa Wen          2024-07-06  127  		struct cea_sad sad;
4562236b3bc0a2 Harry Wentland       2017-09-12  128  
b13a74b7280b1a Melissa Wen          2024-07-06  129  		if (drm_eld_sad_get(connector->eld, i, &sad) < 0)
b13a74b7280b1a Melissa Wen          2024-07-06  130  			continue;
b13a74b7280b1a Melissa Wen          2024-07-06  131  
b13a74b7280b1a Melissa Wen          2024-07-06  132  		edid_caps->audio_modes[i].format_code = sad.format;
b13a74b7280b1a Melissa Wen          2024-07-06  133  		edid_caps->audio_modes[i].channel_count = sad.channels + 1;
b13a74b7280b1a Melissa Wen          2024-07-06  134  		edid_caps->audio_modes[i].sample_rate = sad.freq;
b13a74b7280b1a Melissa Wen          2024-07-06  135  		edid_caps->audio_modes[i].sample_size = sad.byte2;
4562236b3bc0a2 Harry Wentland       2017-09-12  136  	}
4562236b3bc0a2 Harry Wentland       2017-09-12  137  
4562236b3bc0a2 Harry Wentland       2017-09-12  138  
c3e817e49503e3 Melissa Wen          2024-07-06  139  	if (connector->eld[DRM_ELD_SPEAKER])
c3e817e49503e3 Melissa Wen          2024-07-06  140  		edid_caps->speaker_flags = connector->eld[DRM_ELD_SPEAKER];
4562236b3bc0a2 Harry Wentland       2017-09-12  141  	else
4562236b3bc0a2 Harry Wentland       2017-09-12  142  		edid_caps->speaker_flags = DEFAULT_SPEAKER_LOCATION;
4562236b3bc0a2 Harry Wentland       2017-09-12  143  
4562236b3bc0a2 Harry Wentland       2017-09-12  144  	return result;
4562236b3bc0a2 Harry Wentland       2017-09-12  145  }
4562236b3bc0a2 Harry Wentland       2017-09-12  146
diff mbox series

Patch

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 34e380b4408e..fd3580bf1fb2 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -7024,10 +7024,8 @@  static void amdgpu_dm_connector_funcs_force(struct drm_connector *connector)
 
 		memset(&dc_em_sink->edid_caps, 0, sizeof(struct dc_edid_caps));
 		memmove(dc_em_sink->dc_edid.raw_edid, (uint8_t *)edid, (edid->extensions + 1) * EDID_LENGTH);
-		dm_helpers_parse_edid_caps(
-			dc_link,
-			&dc_em_sink->dc_edid,
-			&dc_em_sink->edid_caps);
+		dm_helpers_parse_edid_caps(dc_link,
+					   &dc_em_sink->edid_caps);
 	}
 }
 
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
index 3fb07f437793..59c12cb1db5a 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
@@ -87,27 +87,20 @@  static void apply_edid_quirks(struct drm_edid_product_id *product_id, struct dc_
  *
  * Return: void
  */
-enum dc_edid_status dm_helpers_parse_edid_caps(
-		struct dc_link *link,
-		const struct dc_edid *edid,
-		struct dc_edid_caps *edid_caps)
+enum dc_edid_status dm_helpers_parse_edid_caps(struct dc_link *link,
+					       struct dc_edid_caps *edid_caps)
 {
 	struct amdgpu_dm_connector *aconnector = link->priv;
 	struct drm_connector *connector = &aconnector->base;
 	const struct drm_edid *drm_edid = aconnector->drm_edid;
 	struct drm_edid_product_id product_id;
-	struct edid *edid_buf = edid ? (struct edid *) edid->raw_edid : NULL;
 	int sad_count;
 	int i = 0;
-
 	enum dc_edid_status result = EDID_OK;
 
-	if (!edid_caps || !edid)
+	if (!edid_caps || !drm_edid)
 		return EDID_BAD_INPUT;
 
-	if (!drm_edid_is_valid(edid_buf))
-		result = EDID_BAD_CHECKSUM;
-
 	drm_edid_get_product_id(drm_edid, &product_id);
 
 	edid_caps->manufacturer_id = le16_to_cpu(product_id.manufacturer_name);
@@ -919,19 +912,23 @@  enum dc_edid_status dm_helpers_read_local_edid(
 		if (!drm_edid)
 			return EDID_NO_RESPONSE;
 
-		edid = drm_edid_raw(drm_edid); // FIXME: Get rid of drm_edid_raw()
+		/* FIXME: Get rid of drm_edid_raw()
+		 * Raw edid is still needed for dm_helpers_dp_write_dpcd()
+		 */
+		edid = drm_edid_raw(drm_edid);
 		sink->dc_edid.length = EDID_LENGTH * (edid->extensions + 1);
 		memmove(sink->dc_edid.raw_edid, (uint8_t *)edid, sink->dc_edid.length);
 
 		edid_status = dm_helpers_parse_edid_caps(
 						link,
-						&sink->dc_edid,
 						&sink->edid_caps);
 
-		/* We don't need the original edid anymore */
-		drm_edid_free(drm_edid);
-
-	} while (edid_status == EDID_BAD_CHECKSUM && --retry > 0);
+		if (edid_status != EDID_OK) {
+			/* We can discard the drm_edid and retry */
+			drm_edid_free(drm_edid);
+			drm_edid_connector_update(connector, drm_edid);
+		}
+	} while (edid_status != EDID_OK && --retry > 0);
 
 	if (edid_status != EDID_OK)
 		DRM_ERROR("EDID err: %d, on connector: %s",
diff --git a/drivers/gpu/drm/amd/display/dc/dm_helpers.h b/drivers/gpu/drm/amd/display/dc/dm_helpers.h
index 34adae7ab6e8..bcdfc46c844e 100644
--- a/drivers/gpu/drm/amd/display/dc/dm_helpers.h
+++ b/drivers/gpu/drm/amd/display/dc/dm_helpers.h
@@ -61,7 +61,6 @@  void dm_helpers_free_gpu_mem(
 
 enum dc_edid_status dm_helpers_parse_edid_caps(
 	struct dc_link *link,
-	const struct dc_edid *edid,
 	struct dc_edid_caps *edid_caps);
 
 
diff --git a/drivers/gpu/drm/amd/display/dc/link/link_detection.c b/drivers/gpu/drm/amd/display/dc/link/link_detection.c
index bba644024780..c7bb146636b2 100644
--- a/drivers/gpu/drm/amd/display/dc/link/link_detection.c
+++ b/drivers/gpu/drm/amd/display/dc/link/link_detection.c
@@ -1417,10 +1417,8 @@  struct dc_sink *link_add_remote_sink(
 			dc_sink))
 		goto fail_add_sink;
 
-	edid_status = dm_helpers_parse_edid_caps(
-			link,
-			&dc_sink->dc_edid,
-			&dc_sink->edid_caps);
+	edid_status = dm_helpers_parse_edid_caps(link,
+						 &dc_sink->edid_caps);
 
 	/*
 	 * Treat device as no EDID device if EDID