diff mbox series

[3/3] drm/amd/display: Move connector debugfs to drm

Message ID 20220408065350.1485328-4-bhanuprakash.modem@intel.com (mailing list archive)
State New, archived
Headers show
Series Expose max and current bpc via debugfs | expand

Commit Message

Modem, Bhanuprakash April 8, 2022, 6:53 a.m. UTC
As drm_connector already have the display_info, instead of creating
"output_bpc" debugfs in vendor specific driver, move the logic to
the drm layer.

This patch will also move "Current" bpc to the crtc debugfs from
connector debugfs, since we are getting this info from crtc_state.

Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  4 --
 .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 38 +++++++------------
 .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.h |  2 -
 3 files changed, 13 insertions(+), 31 deletions(-)

Comments

kernel test robot April 8, 2022, 12:56 p.m. UTC | #1
Hi Bhanuprakash,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on drm-intel/for-linux-next]
[also build test ERROR on drm-tip/drm-tip next-20220408]
[cannot apply to drm/drm-next v5.18-rc1]
[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]

url:    https://github.com/intel-lab-lkp/linux/commits/Bhanuprakash-Modem/Expose-max-and-current-bpc-via-debugfs/20220408-145638
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: s390-randconfig-r022-20220408 (https://download.01.org/0day-ci/archive/20220408/202204082024.SJWgNUte-lkp@intel.com/config)
compiler: s390-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/25c70426c3d3454fc0c82bc71b101bf7b8bdf11f
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Bhanuprakash-Modem/Expose-max-and-current-bpc-via-debugfs/20220408-145638
        git checkout 25c70426c3d3454fc0c82bc71b101bf7b8bdf11f
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=s390 SHELL=/bin/bash drivers/gpu/drm/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from drivers/gpu/drm/amd/amdgpu/../display/dmub/dmub_srv.h:67,
                    from drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:35:
   drivers/gpu/drm/amd/amdgpu/../display/dmub/inc/dmub_cmd.h: In function 'dmub_rb_flush_pending':
   drivers/gpu/drm/amd/amdgpu/../display/dmub/inc/dmub_cmd.h:2961:26: warning: variable 'temp' set but not used [-Wunused-but-set-variable]
    2961 |                 uint64_t temp;
         |                          ^~~~
   drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c: In function 'amdgpu_dm_crtc_late_register':
>> drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:6614:9: error: implicit declaration of function 'crtc_debugfs_init'; did you mean 'amdgpu_debugfs_init'? [-Werror=implicit-function-declaration]
    6614 |         crtc_debugfs_init(crtc);
         |         ^~~~~~~~~~~~~~~~~
         |         amdgpu_debugfs_init
   In file included from drivers/gpu/drm/amd/amdgpu/../display/dc/inc/core_types.h:32,
                    from drivers/gpu/drm/amd/amdgpu/../display/dc/inc/link_enc_cfg.h:33,
                    from drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:32:
   At top level:
   drivers/gpu/drm/amd/amdgpu/../display/include/ddc_service_types.h:128:22: warning: 'SYNAPTICS_DEVICE_ID' defined but not used [-Wunused-const-variable=]
     128 | static const uint8_t SYNAPTICS_DEVICE_ID[] = "SYNA";
         |                      ^~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/amd/amdgpu/../display/include/ddc_service_types.h:125:22: warning: 'DP_SINK_DEVICE_STR_ID_2' defined but not used [-Wunused-const-variable=]
     125 | static const uint8_t DP_SINK_DEVICE_STR_ID_2[] = {7, 1, 8, 7, 5, 0};
         |                      ^~~~~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/amd/amdgpu/../display/include/ddc_service_types.h:124:22: warning: 'DP_SINK_DEVICE_STR_ID_1' defined but not used [-Wunused-const-variable=]
     124 | static const uint8_t DP_SINK_DEVICE_STR_ID_1[] = {7, 1, 8, 7, 3, 0};
         |                      ^~~~~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors


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

e7b07ceef2a650 Harry Wentland 2017-08-10  6611  
e69231c4451ae0 Wayne Lin      2021-03-08  6612  static int amdgpu_dm_crtc_late_register(struct drm_crtc *crtc)
86bc221918925a Wayne Lin      2021-03-02  6613  {
86bc221918925a Wayne Lin      2021-03-02 @6614  	crtc_debugfs_init(crtc);
86bc221918925a Wayne Lin      2021-03-02  6615  
86bc221918925a Wayne Lin      2021-03-02  6616  	return 0;
86bc221918925a Wayne Lin      2021-03-02  6617  }
86bc221918925a Wayne Lin      2021-03-02  6618
Harry Wentland April 8, 2022, 3:03 p.m. UTC | #2
On 2022-04-08 02:53, Bhanuprakash Modem wrote:
> As drm_connector already have the display_info, instead of creating
> "output_bpc" debugfs in vendor specific driver, move the logic to
> the drm layer.
> 
> This patch will also move "Current" bpc to the crtc debugfs from
> connector debugfs, since we are getting this info from crtc_state.
> 

Does the amd_max_bpc test pass after this change?

Harry

> Cc: Harry Wentland <harry.wentland@amd.com>
> Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
> Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
> ---
>  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  4 --
>  .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 38 +++++++------------
>  .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.h |  2 -
>  3 files changed, 13 insertions(+), 31 deletions(-)
> 
> 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 73423b805b54..f89651c71ec7 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -6615,14 +6615,12 @@ dm_crtc_duplicate_state(struct drm_crtc *crtc)
>  	return &state->base;
>  }
>  
> -#ifdef CONFIG_DRM_AMD_SECURE_DISPLAY
>  static int amdgpu_dm_crtc_late_register(struct drm_crtc *crtc)
>  {
>  	crtc_debugfs_init(crtc);
>  
>  	return 0;
>  }
> -#endif
>  
>  static inline int dm_set_vupdate_irq(struct drm_crtc *crtc, bool enable)
>  {
> @@ -6720,9 +6718,7 @@ static const struct drm_crtc_funcs amdgpu_dm_crtc_funcs = {
>  	.enable_vblank = dm_enable_vblank,
>  	.disable_vblank = dm_disable_vblank,
>  	.get_vblank_timestamp = drm_crtc_vblank_helper_get_vblank_timestamp,
> -#if defined(CONFIG_DRM_AMD_SECURE_DISPLAY)
>  	.late_register = amdgpu_dm_crtc_late_register,
> -#endif
>  };
>  
>  static enum drm_connector_status
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
> index da17ece1a2c5..3ee26083920b 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
> @@ -873,28 +873,18 @@ static int psr_capability_show(struct seq_file *m, void *data)
>  }
>  
>  /*
> - * Returns the current and maximum output bpc for the connector.
> - * Example usage: cat /sys/kernel/debug/dri/0/DP-1/output_bpc
> + * Returns the current bpc for the crtc.
> + * Example usage: cat /sys/kernel/debug/dri/0/crtc-0/amdgpu_current_bpc
>   */
> -static int output_bpc_show(struct seq_file *m, void *data)
> +static int amdgpu_current_bpc_show(struct seq_file *m, void *data)
>  {
> -	struct drm_connector *connector = m->private;
> -	struct drm_device *dev = connector->dev;
> -	struct drm_crtc *crtc = NULL;
> +	struct drm_crtc *crtc = m->private;
> +	struct drm_device *dev = crtc->dev;
>  	struct dm_crtc_state *dm_crtc_state = NULL;
>  	int res = -ENODEV;
>  	unsigned int bpc;
>  
>  	mutex_lock(&dev->mode_config.mutex);
> -	drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
> -
> -	if (connector->state == NULL)
> -		goto unlock;
> -
> -	crtc = connector->state->crtc;
> -	if (crtc == NULL)
> -		goto unlock;
> -
>  	drm_modeset_lock(&crtc->mutex, NULL);
>  	if (crtc->state == NULL)
>  		goto unlock;
> @@ -924,18 +914,15 @@ static int output_bpc_show(struct seq_file *m, void *data)
>  	}
>  
>  	seq_printf(m, "Current: %u\n", bpc);
> -	seq_printf(m, "Maximum: %u\n", connector->display_info.bpc);
>  	res = 0;
>  
>  unlock:
> -	if (crtc)
> -		drm_modeset_unlock(&crtc->mutex);
> -
> -	drm_modeset_unlock(&dev->mode_config.connection_mutex);
> +	drm_modeset_unlock(&crtc->mutex);
>  	mutex_unlock(&dev->mode_config.mutex);
>  
>  	return res;
>  }
> +DEFINE_SHOW_ATTRIBUTE(amdgpu_current_bpc);
>  
>  /*
>   * Example usage:
> @@ -2541,7 +2528,6 @@ static int target_backlight_show(struct seq_file *m, void *unused)
>  DEFINE_SHOW_ATTRIBUTE(dp_dsc_fec_support);
>  DEFINE_SHOW_ATTRIBUTE(dmub_fw_state);
>  DEFINE_SHOW_ATTRIBUTE(dmub_tracebuffer);
> -DEFINE_SHOW_ATTRIBUTE(output_bpc);
>  DEFINE_SHOW_ATTRIBUTE(dp_lttpr_status);
>  #ifdef CONFIG_DRM_AMD_DC_HDCP
>  DEFINE_SHOW_ATTRIBUTE(hdcp_sink_capability);
> @@ -2788,7 +2774,6 @@ static const struct {
>  	const struct file_operations *fops;
>  } connector_debugfs_entries[] = {
>  		{"force_yuv420_output", &force_yuv420_output_fops},
> -		{"output_bpc", &output_bpc_fops},
>  		{"trigger_hotplug", &trigger_hotplug_debugfs_fops},
>  		{"internal_display", &internal_display_fops}
>  };
> @@ -3172,9 +3157,10 @@ static int crc_win_update_get(void *data, u64 *val)
>  
>  DEFINE_DEBUGFS_ATTRIBUTE(crc_win_update_fops, crc_win_update_get,
>  			 crc_win_update_set, "%llu\n");
> -
> +#endif
>  void crtc_debugfs_init(struct drm_crtc *crtc)
>  {
> +#ifdef CONFIG_DRM_AMD_SECURE_DISPLAY
>  	struct dentry *dir = debugfs_lookup("crc", crtc->debugfs_entry);
>  
>  	if (!dir)
> @@ -3190,9 +3176,11 @@ void crtc_debugfs_init(struct drm_crtc *crtc)
>  				   &crc_win_y_end_fops);
>  	debugfs_create_file_unsafe("crc_win_update", 0644, dir, crtc,
>  				   &crc_win_update_fops);
> -
> -}
>  #endif
> +	debugfs_create_file("amdgpu_current_bpc", 0644, crtc->debugfs_entry,
> +			    crtc, &amdgpu_current_bpc_fops);
> +}
> +
>  /*
>   * Writes DTN log state to the user supplied buffer.
>   * Example usage: cat /sys/kernel/debug/dri/0/amdgpu_dm_dtn_log
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.h
> index 3366cb644053..071200473c27 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.h
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.h
> @@ -31,8 +31,6 @@
>  
>  void connector_debugfs_init(struct amdgpu_dm_connector *connector);
>  void dtn_debugfs_init(struct amdgpu_device *adev);
> -#if defined(CONFIG_DRM_AMD_SECURE_DISPLAY)
>  void crtc_debugfs_init(struct drm_crtc *crtc);
> -#endif
>  
>  #endif
Modem, Bhanuprakash April 8, 2022, 3:23 p.m. UTC | #3
On Fri-08-04-2022 08:33 pm, Harry Wentland wrote:
> 
> 
> On 2022-04-08 02:53, Bhanuprakash Modem wrote:
>> As drm_connector already have the display_info, instead of creating
>> "output_bpc" debugfs in vendor specific driver, move the logic to
>> the drm layer.
>>
>> This patch will also move "Current" bpc to the crtc debugfs from
>> connector debugfs, since we are getting this info from crtc_state.
>>
> 
> Does the amd_max_bpc test pass after this change?

We need IGT fix along with this change. And I have made the required 
changes in IGT: https://patchwork.freedesktop.org/series/102387/

- Bhanu

> 
> Harry
> 
>> Cc: Harry Wentland <harry.wentland@amd.com>
>> Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
>> Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
>> ---
>>   .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  4 --
>>   .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 38 +++++++------------
>>   .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.h |  2 -
>>   3 files changed, 13 insertions(+), 31 deletions(-)
>>
>> 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 73423b805b54..f89651c71ec7 100644
>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>> @@ -6615,14 +6615,12 @@ dm_crtc_duplicate_state(struct drm_crtc *crtc)
>>   	return &state->base;
>>   }
>>   
>> -#ifdef CONFIG_DRM_AMD_SECURE_DISPLAY
>>   static int amdgpu_dm_crtc_late_register(struct drm_crtc *crtc)
>>   {
>>   	crtc_debugfs_init(crtc);
>>   
>>   	return 0;
>>   }
>> -#endif
>>   
>>   static inline int dm_set_vupdate_irq(struct drm_crtc *crtc, bool enable)
>>   {
>> @@ -6720,9 +6718,7 @@ static const struct drm_crtc_funcs amdgpu_dm_crtc_funcs = {
>>   	.enable_vblank = dm_enable_vblank,
>>   	.disable_vblank = dm_disable_vblank,
>>   	.get_vblank_timestamp = drm_crtc_vblank_helper_get_vblank_timestamp,
>> -#if defined(CONFIG_DRM_AMD_SECURE_DISPLAY)
>>   	.late_register = amdgpu_dm_crtc_late_register,
>> -#endif
>>   };
>>   
>>   static enum drm_connector_status
>> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
>> index da17ece1a2c5..3ee26083920b 100644
>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
>> @@ -873,28 +873,18 @@ static int psr_capability_show(struct seq_file *m, void *data)
>>   }
>>   
>>   /*
>> - * Returns the current and maximum output bpc for the connector.
>> - * Example usage: cat /sys/kernel/debug/dri/0/DP-1/output_bpc
>> + * Returns the current bpc for the crtc.
>> + * Example usage: cat /sys/kernel/debug/dri/0/crtc-0/amdgpu_current_bpc
>>    */
>> -static int output_bpc_show(struct seq_file *m, void *data)
>> +static int amdgpu_current_bpc_show(struct seq_file *m, void *data)
>>   {
>> -	struct drm_connector *connector = m->private;
>> -	struct drm_device *dev = connector->dev;
>> -	struct drm_crtc *crtc = NULL;
>> +	struct drm_crtc *crtc = m->private;
>> +	struct drm_device *dev = crtc->dev;
>>   	struct dm_crtc_state *dm_crtc_state = NULL;
>>   	int res = -ENODEV;
>>   	unsigned int bpc;
>>   
>>   	mutex_lock(&dev->mode_config.mutex);
>> -	drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
>> -
>> -	if (connector->state == NULL)
>> -		goto unlock;
>> -
>> -	crtc = connector->state->crtc;
>> -	if (crtc == NULL)
>> -		goto unlock;
>> -
>>   	drm_modeset_lock(&crtc->mutex, NULL);
>>   	if (crtc->state == NULL)
>>   		goto unlock;
>> @@ -924,18 +914,15 @@ static int output_bpc_show(struct seq_file *m, void *data)
>>   	}
>>   
>>   	seq_printf(m, "Current: %u\n", bpc);
>> -	seq_printf(m, "Maximum: %u\n", connector->display_info.bpc);
>>   	res = 0;
>>   
>>   unlock:
>> -	if (crtc)
>> -		drm_modeset_unlock(&crtc->mutex);
>> -
>> -	drm_modeset_unlock(&dev->mode_config.connection_mutex);
>> +	drm_modeset_unlock(&crtc->mutex);
>>   	mutex_unlock(&dev->mode_config.mutex);
>>   
>>   	return res;
>>   }
>> +DEFINE_SHOW_ATTRIBUTE(amdgpu_current_bpc);
>>   
>>   /*
>>    * Example usage:
>> @@ -2541,7 +2528,6 @@ static int target_backlight_show(struct seq_file *m, void *unused)
>>   DEFINE_SHOW_ATTRIBUTE(dp_dsc_fec_support);
>>   DEFINE_SHOW_ATTRIBUTE(dmub_fw_state);
>>   DEFINE_SHOW_ATTRIBUTE(dmub_tracebuffer);
>> -DEFINE_SHOW_ATTRIBUTE(output_bpc);
>>   DEFINE_SHOW_ATTRIBUTE(dp_lttpr_status);
>>   #ifdef CONFIG_DRM_AMD_DC_HDCP
>>   DEFINE_SHOW_ATTRIBUTE(hdcp_sink_capability);
>> @@ -2788,7 +2774,6 @@ static const struct {
>>   	const struct file_operations *fops;
>>   } connector_debugfs_entries[] = {
>>   		{"force_yuv420_output", &force_yuv420_output_fops},
>> -		{"output_bpc", &output_bpc_fops},
>>   		{"trigger_hotplug", &trigger_hotplug_debugfs_fops},
>>   		{"internal_display", &internal_display_fops}
>>   };
>> @@ -3172,9 +3157,10 @@ static int crc_win_update_get(void *data, u64 *val)
>>   
>>   DEFINE_DEBUGFS_ATTRIBUTE(crc_win_update_fops, crc_win_update_get,
>>   			 crc_win_update_set, "%llu\n");
>> -
>> +#endif
>>   void crtc_debugfs_init(struct drm_crtc *crtc)
>>   {
>> +#ifdef CONFIG_DRM_AMD_SECURE_DISPLAY
>>   	struct dentry *dir = debugfs_lookup("crc", crtc->debugfs_entry);
>>   
>>   	if (!dir)
>> @@ -3190,9 +3176,11 @@ void crtc_debugfs_init(struct drm_crtc *crtc)
>>   				   &crc_win_y_end_fops);
>>   	debugfs_create_file_unsafe("crc_win_update", 0644, dir, crtc,
>>   				   &crc_win_update_fops);
>> -
>> -}
>>   #endif
>> +	debugfs_create_file("amdgpu_current_bpc", 0644, crtc->debugfs_entry,
>> +			    crtc, &amdgpu_current_bpc_fops);
>> +}
>> +
>>   /*
>>    * Writes DTN log state to the user supplied buffer.
>>    * Example usage: cat /sys/kernel/debug/dri/0/amdgpu_dm_dtn_log
>> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.h
>> index 3366cb644053..071200473c27 100644
>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.h
>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.h
>> @@ -31,8 +31,6 @@
>>   
>>   void connector_debugfs_init(struct amdgpu_dm_connector *connector);
>>   void dtn_debugfs_init(struct amdgpu_device *adev);
>> -#if defined(CONFIG_DRM_AMD_SECURE_DISPLAY)
>>   void crtc_debugfs_init(struct drm_crtc *crtc);
>> -#endif
>>   
>>   #endif
>
Harry Wentland April 8, 2022, 3:25 p.m. UTC | #4
On 2022-04-08 11:23, Modem, Bhanuprakash wrote:
> On Fri-08-04-2022 08:33 pm, Harry Wentland wrote:
>>
>>
>> On 2022-04-08 02:53, Bhanuprakash Modem wrote:
>>> As drm_connector already have the display_info, instead of creating
>>> "output_bpc" debugfs in vendor specific driver, move the logic to
>>> the drm layer.
>>>
>>> This patch will also move "Current" bpc to the crtc debugfs from
>>> connector debugfs, since we are getting this info from crtc_state.
>>>
>>
>> Does the amd_max_bpc test pass after this change?
> 
> We need IGT fix along with this change. And I have made the required changes in IGT: https://patchwork.freedesktop.org/series/102387/>> 

Thanks, I spotted that patch after I sent this email. :)

Harry

> - Bhanu
> 
>>
>> Harry
>>
>>> Cc: Harry Wentland <harry.wentland@amd.com>
>>> Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
>>> Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
>>> ---
>>>   .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  4 --
>>>   .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 38 +++++++------------
>>>   .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.h |  2 -
>>>   3 files changed, 13 insertions(+), 31 deletions(-)
>>>
>>> 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 73423b805b54..f89651c71ec7 100644
>>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>>> @@ -6615,14 +6615,12 @@ dm_crtc_duplicate_state(struct drm_crtc *crtc)
>>>       return &state->base;
>>>   }
>>>   -#ifdef CONFIG_DRM_AMD_SECURE_DISPLAY
>>>   static int amdgpu_dm_crtc_late_register(struct drm_crtc *crtc)
>>>   {
>>>       crtc_debugfs_init(crtc);
>>>         return 0;
>>>   }
>>> -#endif
>>>     static inline int dm_set_vupdate_irq(struct drm_crtc *crtc, bool enable)
>>>   {
>>> @@ -6720,9 +6718,7 @@ static const struct drm_crtc_funcs amdgpu_dm_crtc_funcs = {
>>>       .enable_vblank = dm_enable_vblank,
>>>       .disable_vblank = dm_disable_vblank,
>>>       .get_vblank_timestamp = drm_crtc_vblank_helper_get_vblank_timestamp,
>>> -#if defined(CONFIG_DRM_AMD_SECURE_DISPLAY)
>>>       .late_register = amdgpu_dm_crtc_late_register,
>>> -#endif
>>>   };
>>>     static enum drm_connector_status
>>> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
>>> index da17ece1a2c5..3ee26083920b 100644
>>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
>>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
>>> @@ -873,28 +873,18 @@ static int psr_capability_show(struct seq_file *m, void *data)
>>>   }
>>>     /*
>>> - * Returns the current and maximum output bpc for the connector.
>>> - * Example usage: cat /sys/kernel/debug/dri/0/DP-1/output_bpc
>>> + * Returns the current bpc for the crtc.
>>> + * Example usage: cat /sys/kernel/debug/dri/0/crtc-0/amdgpu_current_bpc
>>>    */
>>> -static int output_bpc_show(struct seq_file *m, void *data)
>>> +static int amdgpu_current_bpc_show(struct seq_file *m, void *data)
>>>   {
>>> -    struct drm_connector *connector = m->private;
>>> -    struct drm_device *dev = connector->dev;
>>> -    struct drm_crtc *crtc = NULL;
>>> +    struct drm_crtc *crtc = m->private;
>>> +    struct drm_device *dev = crtc->dev;
>>>       struct dm_crtc_state *dm_crtc_state = NULL;
>>>       int res = -ENODEV;
>>>       unsigned int bpc;
>>>         mutex_lock(&dev->mode_config.mutex);
>>> -    drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
>>> -
>>> -    if (connector->state == NULL)
>>> -        goto unlock;
>>> -
>>> -    crtc = connector->state->crtc;
>>> -    if (crtc == NULL)
>>> -        goto unlock;
>>> -
>>>       drm_modeset_lock(&crtc->mutex, NULL);
>>>       if (crtc->state == NULL)
>>>           goto unlock;
>>> @@ -924,18 +914,15 @@ static int output_bpc_show(struct seq_file *m, void *data)
>>>       }
>>>         seq_printf(m, "Current: %u\n", bpc);
>>> -    seq_printf(m, "Maximum: %u\n", connector->display_info.bpc);
>>>       res = 0;
>>>     unlock:
>>> -    if (crtc)
>>> -        drm_modeset_unlock(&crtc->mutex);
>>> -
>>> -    drm_modeset_unlock(&dev->mode_config.connection_mutex);
>>> +    drm_modeset_unlock(&crtc->mutex);
>>>       mutex_unlock(&dev->mode_config.mutex);
>>>         return res;
>>>   }
>>> +DEFINE_SHOW_ATTRIBUTE(amdgpu_current_bpc);
>>>     /*
>>>    * Example usage:
>>> @@ -2541,7 +2528,6 @@ static int target_backlight_show(struct seq_file *m, void *unused)
>>>   DEFINE_SHOW_ATTRIBUTE(dp_dsc_fec_support);
>>>   DEFINE_SHOW_ATTRIBUTE(dmub_fw_state);
>>>   DEFINE_SHOW_ATTRIBUTE(dmub_tracebuffer);
>>> -DEFINE_SHOW_ATTRIBUTE(output_bpc);
>>>   DEFINE_SHOW_ATTRIBUTE(dp_lttpr_status);
>>>   #ifdef CONFIG_DRM_AMD_DC_HDCP
>>>   DEFINE_SHOW_ATTRIBUTE(hdcp_sink_capability);
>>> @@ -2788,7 +2774,6 @@ static const struct {
>>>       const struct file_operations *fops;
>>>   } connector_debugfs_entries[] = {
>>>           {"force_yuv420_output", &force_yuv420_output_fops},
>>> -        {"output_bpc", &output_bpc_fops},
>>>           {"trigger_hotplug", &trigger_hotplug_debugfs_fops},
>>>           {"internal_display", &internal_display_fops}
>>>   };
>>> @@ -3172,9 +3157,10 @@ static int crc_win_update_get(void *data, u64 *val)
>>>     DEFINE_DEBUGFS_ATTRIBUTE(crc_win_update_fops, crc_win_update_get,
>>>                crc_win_update_set, "%llu\n");
>>> -
>>> +#endif
>>>   void crtc_debugfs_init(struct drm_crtc *crtc)
>>>   {
>>> +#ifdef CONFIG_DRM_AMD_SECURE_DISPLAY
>>>       struct dentry *dir = debugfs_lookup("crc", crtc->debugfs_entry);
>>>         if (!dir)
>>> @@ -3190,9 +3176,11 @@ void crtc_debugfs_init(struct drm_crtc *crtc)
>>>                      &crc_win_y_end_fops);
>>>       debugfs_create_file_unsafe("crc_win_update", 0644, dir, crtc,
>>>                      &crc_win_update_fops);
>>> -
>>> -}
>>>   #endif
>>> +    debugfs_create_file("amdgpu_current_bpc", 0644, crtc->debugfs_entry,
>>> +                crtc, &amdgpu_current_bpc_fops);
>>> +}
>>> +
>>>   /*
>>>    * Writes DTN log state to the user supplied buffer.
>>>    * Example usage: cat /sys/kernel/debug/dri/0/amdgpu_dm_dtn_log
>>> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.h
>>> index 3366cb644053..071200473c27 100644
>>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.h
>>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.h
>>> @@ -31,8 +31,6 @@
>>>     void connector_debugfs_init(struct amdgpu_dm_connector *connector);
>>>   void dtn_debugfs_init(struct amdgpu_device *adev);
>>> -#if defined(CONFIG_DRM_AMD_SECURE_DISPLAY)
>>>   void crtc_debugfs_init(struct drm_crtc *crtc);
>>> -#endif
>>>     #endif
>>
>
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 73423b805b54..f89651c71ec7 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -6615,14 +6615,12 @@  dm_crtc_duplicate_state(struct drm_crtc *crtc)
 	return &state->base;
 }
 
-#ifdef CONFIG_DRM_AMD_SECURE_DISPLAY
 static int amdgpu_dm_crtc_late_register(struct drm_crtc *crtc)
 {
 	crtc_debugfs_init(crtc);
 
 	return 0;
 }
-#endif
 
 static inline int dm_set_vupdate_irq(struct drm_crtc *crtc, bool enable)
 {
@@ -6720,9 +6718,7 @@  static const struct drm_crtc_funcs amdgpu_dm_crtc_funcs = {
 	.enable_vblank = dm_enable_vblank,
 	.disable_vblank = dm_disable_vblank,
 	.get_vblank_timestamp = drm_crtc_vblank_helper_get_vblank_timestamp,
-#if defined(CONFIG_DRM_AMD_SECURE_DISPLAY)
 	.late_register = amdgpu_dm_crtc_late_register,
-#endif
 };
 
 static enum drm_connector_status
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
index da17ece1a2c5..3ee26083920b 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
@@ -873,28 +873,18 @@  static int psr_capability_show(struct seq_file *m, void *data)
 }
 
 /*
- * Returns the current and maximum output bpc for the connector.
- * Example usage: cat /sys/kernel/debug/dri/0/DP-1/output_bpc
+ * Returns the current bpc for the crtc.
+ * Example usage: cat /sys/kernel/debug/dri/0/crtc-0/amdgpu_current_bpc
  */
-static int output_bpc_show(struct seq_file *m, void *data)
+static int amdgpu_current_bpc_show(struct seq_file *m, void *data)
 {
-	struct drm_connector *connector = m->private;
-	struct drm_device *dev = connector->dev;
-	struct drm_crtc *crtc = NULL;
+	struct drm_crtc *crtc = m->private;
+	struct drm_device *dev = crtc->dev;
 	struct dm_crtc_state *dm_crtc_state = NULL;
 	int res = -ENODEV;
 	unsigned int bpc;
 
 	mutex_lock(&dev->mode_config.mutex);
-	drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
-
-	if (connector->state == NULL)
-		goto unlock;
-
-	crtc = connector->state->crtc;
-	if (crtc == NULL)
-		goto unlock;
-
 	drm_modeset_lock(&crtc->mutex, NULL);
 	if (crtc->state == NULL)
 		goto unlock;
@@ -924,18 +914,15 @@  static int output_bpc_show(struct seq_file *m, void *data)
 	}
 
 	seq_printf(m, "Current: %u\n", bpc);
-	seq_printf(m, "Maximum: %u\n", connector->display_info.bpc);
 	res = 0;
 
 unlock:
-	if (crtc)
-		drm_modeset_unlock(&crtc->mutex);
-
-	drm_modeset_unlock(&dev->mode_config.connection_mutex);
+	drm_modeset_unlock(&crtc->mutex);
 	mutex_unlock(&dev->mode_config.mutex);
 
 	return res;
 }
+DEFINE_SHOW_ATTRIBUTE(amdgpu_current_bpc);
 
 /*
  * Example usage:
@@ -2541,7 +2528,6 @@  static int target_backlight_show(struct seq_file *m, void *unused)
 DEFINE_SHOW_ATTRIBUTE(dp_dsc_fec_support);
 DEFINE_SHOW_ATTRIBUTE(dmub_fw_state);
 DEFINE_SHOW_ATTRIBUTE(dmub_tracebuffer);
-DEFINE_SHOW_ATTRIBUTE(output_bpc);
 DEFINE_SHOW_ATTRIBUTE(dp_lttpr_status);
 #ifdef CONFIG_DRM_AMD_DC_HDCP
 DEFINE_SHOW_ATTRIBUTE(hdcp_sink_capability);
@@ -2788,7 +2774,6 @@  static const struct {
 	const struct file_operations *fops;
 } connector_debugfs_entries[] = {
 		{"force_yuv420_output", &force_yuv420_output_fops},
-		{"output_bpc", &output_bpc_fops},
 		{"trigger_hotplug", &trigger_hotplug_debugfs_fops},
 		{"internal_display", &internal_display_fops}
 };
@@ -3172,9 +3157,10 @@  static int crc_win_update_get(void *data, u64 *val)
 
 DEFINE_DEBUGFS_ATTRIBUTE(crc_win_update_fops, crc_win_update_get,
 			 crc_win_update_set, "%llu\n");
-
+#endif
 void crtc_debugfs_init(struct drm_crtc *crtc)
 {
+#ifdef CONFIG_DRM_AMD_SECURE_DISPLAY
 	struct dentry *dir = debugfs_lookup("crc", crtc->debugfs_entry);
 
 	if (!dir)
@@ -3190,9 +3176,11 @@  void crtc_debugfs_init(struct drm_crtc *crtc)
 				   &crc_win_y_end_fops);
 	debugfs_create_file_unsafe("crc_win_update", 0644, dir, crtc,
 				   &crc_win_update_fops);
-
-}
 #endif
+	debugfs_create_file("amdgpu_current_bpc", 0644, crtc->debugfs_entry,
+			    crtc, &amdgpu_current_bpc_fops);
+}
+
 /*
  * Writes DTN log state to the user supplied buffer.
  * Example usage: cat /sys/kernel/debug/dri/0/amdgpu_dm_dtn_log
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.h
index 3366cb644053..071200473c27 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.h
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.h
@@ -31,8 +31,6 @@ 
 
 void connector_debugfs_init(struct amdgpu_dm_connector *connector);
 void dtn_debugfs_init(struct amdgpu_device *adev);
-#if defined(CONFIG_DRM_AMD_SECURE_DISPLAY)
 void crtc_debugfs_init(struct drm_crtc *crtc);
-#endif
 
 #endif