[PATCH] drm/amd/powerplay: fix deadlock around smu_handle_task V2

2019-07-11 Thread Evan Quan
As the lock was already held on the entrance to smu_handle_task.

- V2: lock in small granularity

Change-Id: I5388aa917ef0e330974e26c59db42d1354b6a865
Signed-off-by: Evan Quan 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
index 961f4e54ed18..eb255a6bd3a9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
@@ -3049,11 +3049,9 @@ void amdgpu_pm_compute_clocks(struct amdgpu_device *adev)
if (is_support_sw_smu(adev)) {
struct smu_context *smu = >smu;
struct smu_dpm_context *smu_dpm = >smu.smu_dpm;
-   mutex_lock(&(smu->mutex));
smu_handle_task(>smu,
smu_dpm->dpm_level,
AMD_PP_TASK_DISPLAY_CONFIG_CHANGE);
-   mutex_unlock(&(smu->mutex));
} else {
if (adev->powerplay.pp_funcs->dispatch_tasks) {
if (!amdgpu_device_has_dc_support(adev)) {
-- 
2.21.0

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH] drm/amd/powerplay: fix deadlock around smu_handle_task

2019-07-11 Thread Evan Quan
As the lock was already held on the entrance to smu_handle_task.

Change-Id: I5388aa917ef0e330974e26c59db42d1354b6a865
Signed-off-by: Evan Quan 
---
 drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c 
b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
index c60899de88bb..2bca6f133415 100644
--- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
+++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
@@ -1311,10 +1311,8 @@ smu_v11_0_display_clock_voltage_request(struct 
smu_context *smu,
if (ret)
goto failed;
 
-   mutex_lock(>mutex);
ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetHardMinByFreq,
(smu_clk_get_index(smu, clk_select) << 16) | clk_freq);
-   mutex_unlock(>mutex);
}
 
 failed:
-- 
2.21.0

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH] drm/amd/powerplay: fix memory allocation failure check V2

2019-07-11 Thread Evan Quan
Fix memory allocation failure check.

- V2: fix one more similar error

Change-Id: I012b082a7a2b92973a76db8029897fb4a3441694
Signed-off-by: Evan Quan 
---
 drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c 
b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
index 1fc367307ac0..c826e65430b6 100644
--- a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
@@ -319,7 +319,7 @@ static int vega20_tables_init(struct smu_context *smu, 
struct smu_table *tables)
   AMDGPU_GEM_DOMAIN_VRAM);
 
smu_table->metrics_table = kzalloc(sizeof(SmuMetrics_t), GFP_KERNEL);
-   if (smu_table->metrics_table)
+   if (!smu_table->metrics_table)
return -ENOMEM;
smu_table->metrics_time = 0;
 
@@ -1502,7 +1502,7 @@ static int vega20_set_default_od8_setttings(struct 
smu_context *smu)
 
od8_settings = kzalloc(sizeof(struct vega20_od8_settings), GFP_KERNEL);
 
-   if (od8_settings)
+   if (!od8_settings)
return -ENOMEM;
 
smu->od_settings = (void *)od8_settings;
-- 
2.21.0

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH] drm/amd/powerplay: bump vega20 smu driver if version

2019-07-11 Thread Evan Quan
To match latest SMU firmware.

Change-Id: Icc8a687357ba46ae1d199d89cb2000c61b4de703
Signed-off-by: Evan Quan 
---
 drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if.h | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if.h 
b/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if.h
index 195c4ae67058..755d51f9c6a9 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if.h
@@ -27,7 +27,7 @@
 // *** IMPORTANT ***
 // SMU TEAM: Always increment the interface version if
 // any structure is changed in this file
-#define SMU11_DRIVER_IF_VERSION 0x12
+#define SMU11_DRIVER_IF_VERSION 0x13
 
 #define PPTABLE_V20_SMU_VERSION 3
 
@@ -615,6 +615,7 @@ typedef struct {
   uint16_t UclkAverageLpfTau;
   uint16_t GfxActivityLpfTau;
   uint16_t UclkActivityLpfTau;
+  uint16_t SocketPowerLpfTau;
 
 
   uint32_t MmHubPadding[8];
@@ -665,7 +666,8 @@ typedef struct {
   uint32_t ThrottlerStatus   ;
 
   uint8_t  LinkDpmLevel;
-  uint8_t  Padding[3];
+  uint16_t AverageSocketPower;
+  uint8_t  Padding;
 
 
   uint32_t MmHubPadding[7];
-- 
2.21.0

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

RE: [PATCH] drm/amd/powerplay: add pstate mclk(uclk) support for navi10

2019-07-11 Thread Quan, Evan
Reviewed-by: Evan Quan 

> -Original Message-
> From: Wang, Kevin(Yang) 
> Sent: Friday, July 12, 2019 11:34 AM
> To: amd-gfx@lists.freedesktop.org
> Cc: Feng, Kenneth ; Quan, Evan
> ; Wang, Kevin(Yang) 
> Subject: [PATCH] drm/amd/powerplay: add pstate mclk(uclk) support for
> navi10
> 
> add pstate mclk(uclk) support.
> 
> Change-Id: I7f3bca4901833b4ea213fe02249fc055b80e5cdd
> Signed-off-by: Kevin Wang 
> ---
>  drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 1 +
> drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 8 +++-
>  2 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> index de6cc5d489cd..67db2746ec4f 100644
> --- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> +++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> @@ -136,6 +136,7 @@ int smu_get_dpm_freq_range(struct smu_context
> *smu, enum smu_clk_type clk_type,
>   return -EINVAL;
> 
>   switch (clk_type) {
> + case SMU_MCLK:
>   case SMU_UCLK:
>   if (!smu_feature_is_enabled(smu,
> SMU_FEATURE_DPM_UCLK_BIT)) {
>   pr_warn("uclk dpm is not enabled\n"); diff --git
> a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
> b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
> index cd32b20a13c1..16a4c1ca98cf 100644
> --- a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
> +++ b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
> @@ -709,7 +709,7 @@ static int navi10_force_clk_levels(struct smu_context
> *smu,  static int navi10_populate_umd_state_clk(struct smu_context *smu)
> {
>   int ret = 0;
> - uint32_t min_sclk_freq = 0;
> + uint32_t min_sclk_freq = 0, min_mclk_freq = 0;
> 
>   ret = smu_get_dpm_freq_range(smu, SMU_SCLK, _sclk_freq,
> NULL);
>   if (ret)
> @@ -717,6 +717,12 @@ static int navi10_populate_umd_state_clk(struct
> smu_context *smu)
> 
>   smu->pstate_sclk = min_sclk_freq * 100;
> 
> + ret = smu_get_dpm_freq_range(smu, SMU_MCLK, _mclk_freq,
> NULL);
> + if (ret)
> + return ret;
> +
> + smu->pstate_mclk = min_mclk_freq * 100;
> +
>   return ret;
>  }
> 
> --
> 2.22.0

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH] drm/amd/powerplay: add pstate mclk(uclk) support for navi10

2019-07-11 Thread Wang, Kevin(Yang)
add pstate mclk(uclk) support.

Change-Id: I7f3bca4901833b4ea213fe02249fc055b80e5cdd
Signed-off-by: Kevin Wang 
---
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 1 +
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 8 +++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c 
b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
index de6cc5d489cd..67db2746ec4f 100644
--- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
@@ -136,6 +136,7 @@ int smu_get_dpm_freq_range(struct smu_context *smu, enum 
smu_clk_type clk_type,
return -EINVAL;
 
switch (clk_type) {
+   case SMU_MCLK:
case SMU_UCLK:
if (!smu_feature_is_enabled(smu, SMU_FEATURE_DPM_UCLK_BIT)) {
pr_warn("uclk dpm is not enabled\n");
diff --git a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c 
b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
index cd32b20a13c1..16a4c1ca98cf 100644
--- a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
@@ -709,7 +709,7 @@ static int navi10_force_clk_levels(struct smu_context *smu,
 static int navi10_populate_umd_state_clk(struct smu_context *smu)
 {
int ret = 0;
-   uint32_t min_sclk_freq = 0;
+   uint32_t min_sclk_freq = 0, min_mclk_freq = 0;
 
ret = smu_get_dpm_freq_range(smu, SMU_SCLK, _sclk_freq, NULL);
if (ret)
@@ -717,6 +717,12 @@ static int navi10_populate_umd_state_clk(struct 
smu_context *smu)
 
smu->pstate_sclk = min_sclk_freq * 100;
 
+   ret = smu_get_dpm_freq_range(smu, SMU_MCLK, _mclk_freq, NULL);
+   if (ret)
+   return ret;
+
+   smu->pstate_mclk = min_mclk_freq * 100;
+
return ret;
 }
 
-- 
2.22.0

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH] drm/amd/powerplay: avoid access before allocation

2019-07-11 Thread Evan Quan
No access before allocation.

Change-Id: Ia1d78786f2400cd1cd227d1ab6ea4c6a71619e4c
Signed-off-by: Evan Quan 
---
 drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c 
b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
index 9e3e737926aa..c70262e6e250 100644
--- a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
@@ -441,7 +441,6 @@ static int vega20_store_powerplay_table(struct smu_context 
*smu)
 {
ATOM_Vega20_POWERPLAYTABLE *powerplay_table = NULL;
struct smu_table_context *table_context = >smu_table;
-   int ret;
 
if (!table_context->power_play_table)
return -EINVAL;
@@ -455,9 +454,7 @@ static int vega20_store_powerplay_table(struct smu_context 
*smu)
table_context->thermal_controller_type = 
powerplay_table->ucThermalControllerType;
table_context->TDPODLimit = 
le32_to_cpu(powerplay_table->OverDrive8Table.ODSettingsMax[ATOM_VEGA20_ODSETTING_POWERPERCENTAGE]);
 
-   ret = vega20_setup_od8_information(smu);
-
-   return ret;
+   return 0;
 }
 
 static int vega20_append_powerplay_table(struct smu_context *smu)
@@ -1507,6 +1504,12 @@ static int vega20_set_default_od8_setttings(struct 
smu_context *smu)
 
smu->od_settings = (void *)od8_settings;
 
+   ret = vega20_setup_od8_information(smu);
+   if (ret) {
+   pr_err("Retrieve board OD limits failed!\n");
+   return ret;
+   }
+
if (smu_feature_is_enabled(smu, SMU_FEATURE_DPM_SOCCLK_BIT)) {
if 
(od8_settings->od_feature_capabilities[ATOM_VEGA20_ODFEATURE_GFXCLK_LIMITS] &&
od8_settings->od_settings_max[OD8_SETTING_GFXCLK_FMAX] > 0 
&&
-- 
2.21.0

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Re: [PATCH] drm/amd/powerplay: fix memory allocation failure check

2019-07-11 Thread Wang, Kevin(Yang)
Reviewed-by: Kevin Wang 


Best Regards,

Kevin


From: amd-gfx  on behalf of Evan Quan 

Sent: Friday, July 12, 2019 10:34:46 AM
To: amd-gfx@lists.freedesktop.org
Cc: Quan, Evan
Subject: [PATCH] drm/amd/powerplay: fix memory allocation failure check

Fix memory allocation failure check.

Change-Id: I012b082a7a2b92973a76db8029897fb4a3441694
Signed-off-by: Evan Quan 
---
 drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c 
b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
index 1fc367307ac0..9e3e737926aa 100644
--- a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
@@ -319,7 +319,7 @@ static int vega20_tables_init(struct smu_context *smu, 
struct smu_table *tables)
AMDGPU_GEM_DOMAIN_VRAM);

 smu_table->metrics_table = kzalloc(sizeof(SmuMetrics_t), GFP_KERNEL);
-   if (smu_table->metrics_table)
+   if (!smu_table->metrics_table)
 return -ENOMEM;
 smu_table->metrics_time = 0;

--
2.21.0

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH] drm/amd/powerplay: fix memory allocation failure check

2019-07-11 Thread Evan Quan
Fix memory allocation failure check.

Change-Id: I012b082a7a2b92973a76db8029897fb4a3441694
Signed-off-by: Evan Quan 
---
 drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c 
b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
index 1fc367307ac0..9e3e737926aa 100644
--- a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
@@ -319,7 +319,7 @@ static int vega20_tables_init(struct smu_context *smu, 
struct smu_table *tables)
   AMDGPU_GEM_DOMAIN_VRAM);
 
smu_table->metrics_table = kzalloc(sizeof(SmuMetrics_t), GFP_KERNEL);
-   if (smu_table->metrics_table)
+   if (!smu_table->metrics_table)
return -ENOMEM;
smu_table->metrics_time = 0;
 
-- 
2.21.0

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

RE: [PATCH] drm/amd/powerplay: fix smu clock type change miss error

2019-07-11 Thread Quan, Evan
Reviewed-by: Evan Quan 

> -Original Message-
> From: amd-gfx  On Behalf Of
> Wang, Kevin(Yang)
> Sent: Thursday, July 11, 2019 9:41 PM
> To: amd-gfx@lists.freedesktop.org
> Cc: Wang, Kevin(Yang) ; Feng, Kenneth
> 
> Subject: [PATCH] drm/amd/powerplay: fix smu clock type change miss error
> 
> in the smu module, use the smu_xxxclk type to identify the CLK type use
> SMU_SCLK, SMU_MCLK to replace PP_SCLK, PP_MCLK.
> 
> Change-Id: Ifa870aea38f043e1983f6f0560eed2ac070b68b7
> Signed-off-by: Kevin Wang 
> ---
>  drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> index 1c15f02101fe..de6cc5d489cd 100644
> --- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> +++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> @@ -1386,8 +1386,8 @@ int smu_adjust_power_state_dynamic(struct
> smu_context *smu,
>_mask);
>   if (ret)
>   return ret;
> - smu_force_clk_levels(smu, PP_SCLK, 1 <<
> sclk_mask);
> - smu_force_clk_levels(smu, PP_MCLK, 1 <<
> mclk_mask);
> + smu_force_clk_levels(smu, SMU_SCLK, 1 <<
> sclk_mask);
> + smu_force_clk_levels(smu, SMU_MCLK, 1 <<
> mclk_mask);
>   break;
> 
>   case AMD_DPM_FORCED_LEVEL_MANUAL:
> --
> 2.22.0
> 
> ___
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Re: [PATCH v4 23/23] drm/i915: Provide ddc symlink in hdmi connector sysfs directory

2019-07-11 Thread Ville Syrjälä
On Thu, Jul 11, 2019 at 01:26:50PM +0200, Andrzej Pietrasiewicz wrote:
> Use the ddc pointer provided by the generic connector.

We already have a symlink via intel_hdmi_create_i2c_symlink(). I guess
we should remove that in favor of the generic one. Oleg?

> 
> Signed-off-by: Andrzej Pietrasiewicz 
> ---
>  drivers/gpu/drm/i915/display/intel_hdmi.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c 
> b/drivers/gpu/drm/i915/display/intel_hdmi.c
> index 0ebec69bbbfc..678fa4d1bd4e 100644
> --- a/drivers/gpu/drm/i915/display/intel_hdmi.c
> +++ b/drivers/gpu/drm/i915/display/intel_hdmi.c
> @@ -3094,6 +3094,9 @@ void intel_hdmi_init_connector(struct 
> intel_digital_port *intel_dig_port,
>intel_dig_port->max_lanes, port_name(port)))
>   return;
>  
> + intel_hdmi->ddc_bus = intel_hdmi_ddc_pin(dev_priv, port);
> + connector->ddc = intel_gmbus_get_adapter(dev_priv, intel_hdmi->ddc_bus);
> +
>   drm_connector_init(dev, connector, _hdmi_connector_funcs,
>  DRM_MODE_CONNECTOR_HDMIA);
>   drm_connector_helper_add(connector, _hdmi_connector_helper_funcs);
> @@ -3105,8 +3108,6 @@ void intel_hdmi_init_connector(struct 
> intel_digital_port *intel_dig_port,
>   if (INTEL_GEN(dev_priv) >= 10 || IS_GEMINILAKE(dev_priv))
>   connector->ycbcr_420_allowed = true;
>  
> - intel_hdmi->ddc_bus = intel_hdmi_ddc_pin(dev_priv, port);
> -
>   if (WARN_ON(port == PORT_A))
>   return;
>   intel_encoder->hpd_pin = intel_hpd_pin_default(dev_priv, port);
> -- 
> 2.17.1

-- 
Ville Syrjälä
Intel
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Re: [PATCH v4 01/23] drm: Include ddc adapter pointer in struct drm_connector

2019-07-11 Thread Ville Syrjälä
On Thu, Jul 11, 2019 at 01:26:28PM +0200, Andrzej Pietrasiewicz wrote:
> Add generic code which creates symbolic links in sysfs, pointing to ddc
> interface used by a particular video output. For example:
> 
> ls -l /sys/class/drm/card0-HDMI-A-1/ddc
> lrwxrwxrwx 1 root root 0 Jun 24 10:42 /sys/class/drm/card0-HDMI-A-1/ddc \
>   -> ../../../../soc/1388.i2c/i2c-2
> 
> This makes it easy for user to associate a display with its ddc adapter
> and use e.g. ddcutil to control the chosen monitor.
> 
> This patch adds an i2c_adapter pointer to struct drm_connector. Particular
> drivers can then use it instead of using their own private instance. If a
> connector contains a ddc, then create a symbolic link in sysfs.
> 
> Signed-off-by: Andrzej Pietrasiewicz 
> Acked-by: Daniel Vetter 
> Reviewed-by: Andrzej Hajda 
> ---
>  drivers/gpu/drm/drm_sysfs.c |  7 +++
>  include/drm/drm_connector.h | 11 +++
>  2 files changed, 18 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
> index ad10810bc972..26d359b39785 100644
> --- a/drivers/gpu/drm/drm_sysfs.c
> +++ b/drivers/gpu/drm/drm_sysfs.c
> @@ -294,6 +294,9 @@ int drm_sysfs_connector_add(struct drm_connector 
> *connector)
>   /* Let userspace know we have a new connector */
>   drm_sysfs_hotplug_event(dev);
>  
> + if (connector->ddc)
> + return sysfs_create_link(>kdev->kobj,
> +  >ddc->dev.kobj, "ddc");
>   return 0;
>  }
>  
> @@ -301,6 +304,10 @@ void drm_sysfs_connector_remove(struct drm_connector 
> *connector)
>  {
>   if (!connector->kdev)
>   return;
> +
> + if (connector->ddc)
> + sysfs_remove_link(>kdev->kobj, "ddc");
> +
>   DRM_DEBUG("removing \"%s\" from sysfs\n",
> connector->name);
>  
> diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> index ca745d9feaf5..1ad3d1d54ba7 100644
> --- a/include/drm/drm_connector.h
> +++ b/include/drm/drm_connector.h
> @@ -23,6 +23,7 @@
>  #ifndef __DRM_CONNECTOR_H__
>  #define __DRM_CONNECTOR_H__
>  
> +#include 

struct i2c_adapter;
would suffice.

>  #include 
>  #include 
>  #include 
> @@ -1308,6 +1309,16 @@ struct drm_connector {
>* [0]: progressive, [1]: interlaced
>*/
>   int audio_latency[2];
> +
> + /**
> +  * @ddc: associated ddc adapter.
> +  * A connector usually has its associated ddc adapter. If a driver uses
> +  * this field, then an appropriate symbolic link is created in connector
> +  * sysfs directory to make it easy for the user to tell which i2c
> +  * adapter is for a particular display.
> +  */
> + struct i2c_adapter *ddc;
> +
>   /**
>* @null_edid_counter: track sinks that give us all zeros for the EDID.
>* Needed to workaround some HW bugs where we get all 0s
> -- 
> 2.17.1

-- 
Ville Syrjälä
Intel
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Re: [PATCH v4 17/23] drm/ast: Provide ddc symlink in connector sysfs directory

2019-07-11 Thread Thomas Zimmermann
Acked-by: Thomas Zimmermann 

Am 11.07.19 um 13:26 schrieb Andrzej Pietrasiewicz:
> Use the ddc pointer provided by the generic connector.
> 
> Signed-off-by: Andrzej Pietrasiewicz 
> ---
>  drivers/gpu/drm/ast/ast_mode.c | 9 +
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
> index ffccbef962a4..1ca9bc4aa3bb 100644
> --- a/drivers/gpu/drm/ast/ast_mode.c
> +++ b/drivers/gpu/drm/ast/ast_mode.c
> @@ -890,6 +890,11 @@ static int ast_connector_init(struct drm_device *dev)
>   return -ENOMEM;
>  
>   connector = _connector->base;
> + ast_connector->i2c = ast_i2c_create(dev);
> + if (!ast_connector->i2c)
> + DRM_ERROR("failed to add ddc bus for connector\n");
> +
> + connector->ddc = _connector->i2c->adapter;
>   drm_connector_init(dev, connector, _connector_funcs, 
> DRM_MODE_CONNECTOR_VGA);
>  
>   drm_connector_helper_add(connector, _connector_helper_funcs);
> @@ -904,10 +909,6 @@ static int ast_connector_init(struct drm_device *dev)
>   encoder = list_first_entry(>mode_config.encoder_list, struct 
> drm_encoder, head);
>   drm_connector_attach_encoder(connector, encoder);
>  
> - ast_connector->i2c = ast_i2c_create(dev);
> - if (!ast_connector->i2c)
> - DRM_ERROR("failed to add ddc bus for connector\n");
> -
>   return 0;
>  }
>  
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Linux GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah
HRB 21284 (AG Nürnberg)



signature.asc
Description: OpenPGP digital signature
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Re: [PATCH v4 16/23] drm/mgag200: Provide ddc symlink in connector sysfs directory

2019-07-11 Thread Thomas Zimmermann
Acked-by: Thomas Zimmermann 

Am 11.07.19 um 13:26 schrieb Andrzej Pietrasiewicz:
> Use the ddc pointer provided by the generic connector.
> 
> Signed-off-by: Andrzej Pietrasiewicz 
> ---
>  drivers/gpu/drm/mgag200/mgag200_mode.c | 9 +
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c 
> b/drivers/gpu/drm/mgag200/mgag200_mode.c
> index a25054015e8c..8fb9444b2142 100644
> --- a/drivers/gpu/drm/mgag200/mgag200_mode.c
> +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
> @@ -1703,6 +1703,11 @@ static struct drm_connector *mga_vga_init(struct 
> drm_device *dev)
>   return NULL;
>  
>   connector = _connector->base;
> + mga_connector->i2c = mgag200_i2c_create(dev);
> + if (!mga_connector->i2c)
> + DRM_ERROR("failed to add ddc bus\n");
> +
> + connector->ddc = _connector->i2c->adapter;
>  
>   drm_connector_init(dev, connector,
>  _vga_connector_funcs, DRM_MODE_CONNECTOR_VGA);
> @@ -1711,10 +1716,6 @@ static struct drm_connector *mga_vga_init(struct 
> drm_device *dev)
>  
>   drm_connector_register(connector);
>  
> - mga_connector->i2c = mgag200_i2c_create(dev);
> - if (!mga_connector->i2c)
> - DRM_ERROR("failed to add ddc bus\n");
> -
>   return connector;
>  }
>  
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Linux GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah
HRB 21284 (AG Nürnberg)



signature.asc
Description: OpenPGP digital signature
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Re: [PATCH] drm/amdkfd: fix cp hang in eviction

2019-07-11 Thread Kuehling, Felix
On 2019-07-10 11:20 a.m., Huang, JinHuiEric wrote:
> The cp hang occurs in OCL conformance test only on supermicro
> platform which has 40 cores and the test generates 40 threads.
> The root cause is race condition in non-protected flags.
>
> The fix is to add flags of is_evicted and is_active(init_mqd())
> into protected area.
>
> Signed-off-by: Eric Huang 

Sorry, I missed this one. I only saw the one earlier that you recalled.

Reviewed-by: Felix Kuehling 


> ---
>   drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 16 +---
>   1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c 
> b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> index 9ffdda5..f23e17b 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> @@ -1157,12 +1157,7 @@ static int create_queue_cpsch(struct 
> device_queue_manager *dqm, struct queue *q,
>   
>   mqd_mgr = dqm->mqd_mgrs[get_mqd_type_from_queue_type(
>   q->properties.type)];
> - /*
> -  * Eviction state logic: mark all queues as evicted, even ones
> -  * not currently active. Restoring inactive queues later only
> -  * updates the is_evicted flag but is a no-op otherwise.
> -  */
> - q->properties.is_evicted = !!qpd->evicted;
> +
>   if (q->properties.type == KFD_QUEUE_TYPE_SDMA ||
>   q->properties.type == KFD_QUEUE_TYPE_SDMA_XGMI)
>   dqm->asic_ops.init_sdma_vm(dqm, q, qpd);
> @@ -1173,9 +1168,16 @@ static int create_queue_cpsch(struct 
> device_queue_manager *dqm, struct queue *q,
>   retval = -ENOMEM;
>   goto out_deallocate_doorbell;
>   }
> +
> + dqm_lock(dqm);
> + /*
> +  * Eviction state logic: mark all queues as evicted, even ones
> +  * not currently active. Restoring inactive queues later only
> +  * updates the is_evicted flag but is a no-op otherwise.
> +  */
> + q->properties.is_evicted = !!qpd->evicted;
>   mqd_mgr->init_mqd(mqd_mgr, >mqd, q->mqd_mem_obj,
>   >gart_mqd_addr, >properties);
> - dqm_lock(dqm);
>   
>   list_add(>list, >queues_list);
>   qpd->queue_count++;
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Re: [PATCH] drm/amd/powerplay: fix smu clock type change miss error

2019-07-11 Thread Xu, Feifei
Reviewed-by: Feifei Xu 

> On Jul 11, 2019, at 21:40, Wang, Kevin(Yang)  wrote:
> 
> in the smu module, use the smu_xxxclk type to identify the CLK type
> use SMU_SCLK, SMU_MCLK to replace PP_SCLK, PP_MCLK.
> 
> Change-Id: Ifa870aea38f043e1983f6f0560eed2ac070b68b7
> Signed-off-by: Kevin Wang 
> ---
> drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c 
> b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> index 1c15f02101fe..de6cc5d489cd 100644
> --- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> +++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> @@ -1386,8 +1386,8 @@ int smu_adjust_power_state_dynamic(struct smu_context 
> *smu,
> _mask);
>if (ret)
>return ret;
> -smu_force_clk_levels(smu, PP_SCLK, 1 << sclk_mask);
> -smu_force_clk_levels(smu, PP_MCLK, 1 << mclk_mask);
> +smu_force_clk_levels(smu, SMU_SCLK, 1 << sclk_mask);
> +smu_force_clk_levels(smu, SMU_MCLK, 1 << mclk_mask);
>break;
> 
>case AMD_DPM_FORCED_LEVEL_MANUAL:
> -- 
> 2.22.0
> 
> ___
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Re: [PATCH] drm/amdkfd: fix cp hang in eviction

2019-07-11 Thread Huang, JinHuiEric
ping.

On 2019-07-10 11:20 a.m., Huang, JinHuiEric wrote:
> The cp hang occurs in OCL conformance test only on supermicro
> platform which has 40 cores and the test generates 40 threads.
> The root cause is race condition in non-protected flags.
>
> The fix is to add flags of is_evicted and is_active(init_mqd())
> into protected area.
>
> Signed-off-by: Eric Huang 
> ---
>   drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 16 +---
>   1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c 
> b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> index 9ffdda5..f23e17b 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> @@ -1157,12 +1157,7 @@ static int create_queue_cpsch(struct 
> device_queue_manager *dqm, struct queue *q,
>   
>   mqd_mgr = dqm->mqd_mgrs[get_mqd_type_from_queue_type(
>   q->properties.type)];
> - /*
> -  * Eviction state logic: mark all queues as evicted, even ones
> -  * not currently active. Restoring inactive queues later only
> -  * updates the is_evicted flag but is a no-op otherwise.
> -  */
> - q->properties.is_evicted = !!qpd->evicted;
> +
>   if (q->properties.type == KFD_QUEUE_TYPE_SDMA ||
>   q->properties.type == KFD_QUEUE_TYPE_SDMA_XGMI)
>   dqm->asic_ops.init_sdma_vm(dqm, q, qpd);
> @@ -1173,9 +1168,16 @@ static int create_queue_cpsch(struct 
> device_queue_manager *dqm, struct queue *q,
>   retval = -ENOMEM;
>   goto out_deallocate_doorbell;
>   }
> +
> + dqm_lock(dqm);
> + /*
> +  * Eviction state logic: mark all queues as evicted, even ones
> +  * not currently active. Restoring inactive queues later only
> +  * updates the is_evicted flag but is a no-op otherwise.
> +  */
> + q->properties.is_evicted = !!qpd->evicted;
>   mqd_mgr->init_mqd(mqd_mgr, >mqd, q->mqd_mem_obj,
>   >gart_mqd_addr, >properties);
> - dqm_lock(dqm);
>   
>   list_add(>list, >queues_list);
>   qpd->queue_count++;
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH] drm/amd/powerplay: fix smu clock type change miss error

2019-07-11 Thread Wang, Kevin(Yang)
in the smu module, use the smu_xxxclk type to identify the CLK type
use SMU_SCLK, SMU_MCLK to replace PP_SCLK, PP_MCLK.

Change-Id: Ifa870aea38f043e1983f6f0560eed2ac070b68b7
Signed-off-by: Kevin Wang 
---
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c 
b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
index 1c15f02101fe..de6cc5d489cd 100644
--- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
@@ -1386,8 +1386,8 @@ int smu_adjust_power_state_dynamic(struct smu_context 
*smu,
 _mask);
if (ret)
return ret;
-   smu_force_clk_levels(smu, PP_SCLK, 1 << sclk_mask);
-   smu_force_clk_levels(smu, PP_MCLK, 1 << mclk_mask);
+   smu_force_clk_levels(smu, SMU_SCLK, 1 << sclk_mask);
+   smu_force_clk_levels(smu, SMU_MCLK, 1 << mclk_mask);
break;
 
case AMD_DPM_FORCED_LEVEL_MANUAL:
-- 
2.22.0

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH v4 23/23] drm/i915: Provide ddc symlink in hdmi connector sysfs directory

2019-07-11 Thread Andrzej Pietrasiewicz
Use the ddc pointer provided by the generic connector.

Signed-off-by: Andrzej Pietrasiewicz 
---
 drivers/gpu/drm/i915/display/intel_hdmi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c 
b/drivers/gpu/drm/i915/display/intel_hdmi.c
index 0ebec69bbbfc..678fa4d1bd4e 100644
--- a/drivers/gpu/drm/i915/display/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/display/intel_hdmi.c
@@ -3094,6 +3094,9 @@ void intel_hdmi_init_connector(struct intel_digital_port 
*intel_dig_port,
 intel_dig_port->max_lanes, port_name(port)))
return;
 
+   intel_hdmi->ddc_bus = intel_hdmi_ddc_pin(dev_priv, port);
+   connector->ddc = intel_gmbus_get_adapter(dev_priv, intel_hdmi->ddc_bus);
+
drm_connector_init(dev, connector, _hdmi_connector_funcs,
   DRM_MODE_CONNECTOR_HDMIA);
drm_connector_helper_add(connector, _hdmi_connector_helper_funcs);
@@ -3105,8 +3108,6 @@ void intel_hdmi_init_connector(struct intel_digital_port 
*intel_dig_port,
if (INTEL_GEN(dev_priv) >= 10 || IS_GEMINILAKE(dev_priv))
connector->ycbcr_420_allowed = true;
 
-   intel_hdmi->ddc_bus = intel_hdmi_ddc_pin(dev_priv, port);
-
if (WARN_ON(port == PORT_A))
return;
intel_encoder->hpd_pin = intel_hpd_pin_default(dev_priv, port);
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH v4 19/23] drm/bridge: dw-hdmi: Provide ddc symlink in connector sysfs directory

2019-07-11 Thread Andrzej Pietrasiewicz
Use the ddc pointer provided by the generic connector.

Signed-off-by: Andrzej Pietrasiewicz 
---
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 40 +++
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c 
b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
index c6490949d9db..0b9c9f2619da 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
@@ -161,7 +161,6 @@ struct dw_hdmi {
 
struct drm_display_mode previous_mode;
 
-   struct i2c_adapter *ddc;
void __iomem *regs;
bool sink_is_hdmi;
bool sink_has_audio;
@@ -1118,7 +1117,7 @@ static bool dw_hdmi_support_scdc(struct dw_hdmi *hdmi)
return false;
 
/* Disable if no DDC bus */
-   if (!hdmi->ddc)
+   if (!hdmi->connector.ddc)
return false;
 
/* Disable if SCDC is not supported, or if an HF-VSDB block is absent */
@@ -1156,10 +1155,11 @@ void dw_hdmi_set_high_tmds_clock_ratio(struct dw_hdmi 
*hdmi)
 
/* Control for TMDS Bit Period/TMDS Clock-Period Ratio */
if (dw_hdmi_support_scdc(hdmi)) {
+   struct i2c_adapter *ddc = hdmi->connector.ddc;
if (mtmdsclock > HDMI14_MAX_TMDSCLK)
-   drm_scdc_set_high_tmds_clock_ratio(hdmi->ddc, 1);
+   drm_scdc_set_high_tmds_clock_ratio(ddc, 1);
else
-   drm_scdc_set_high_tmds_clock_ratio(hdmi->ddc, 0);
+   drm_scdc_set_high_tmds_clock_ratio(ddc, 0);
}
 }
 EXPORT_SYMBOL_GPL(dw_hdmi_set_high_tmds_clock_ratio);
@@ -1750,6 +1750,7 @@ static void hdmi_av_composer(struct dw_hdmi *hdmi,
if (dw_hdmi_support_scdc(hdmi)) {
if (vmode->mtmdsclock > HDMI14_MAX_TMDSCLK ||
hdmi_info->scdc.scrambling.low_rates) {
+   struct i2c_adapter *ddc = hdmi->connector.ddc;
/*
 * HDMI2.0 Specifies the following procedure:
 * After the Source Device has determined that
@@ -1759,13 +1760,12 @@ static void hdmi_av_composer(struct dw_hdmi *hdmi,
 * Source Devices compliant shall set the
 * Source Version = 1.
 */
-   drm_scdc_readb(hdmi->ddc, SCDC_SINK_VERSION,
-  );
-   drm_scdc_writeb(hdmi->ddc, SCDC_SOURCE_VERSION,
+   drm_scdc_readb(ddc, SCDC_SINK_VERSION, );
+   drm_scdc_writeb(ddc, SCDC_SOURCE_VERSION,
min_t(u8, bytes, SCDC_MIN_SOURCE_VERSION));
 
/* Enabled Scrambling in the Sink */
-   drm_scdc_set_scrambling(hdmi->ddc, 1);
+   drm_scdc_set_scrambling(hdmi->connector.ddc, 1);
 
/*
 * To activate the scrambler feature, you must ensure
@@ -1781,7 +1781,7 @@ static void hdmi_av_composer(struct dw_hdmi *hdmi,
hdmi_writeb(hdmi, 0, HDMI_FC_SCRAMBLER_CTRL);
hdmi_writeb(hdmi, (u8)~HDMI_MC_SWRSTZ_TMDSSWRST_REQ,
HDMI_MC_SWRSTZ);
-   drm_scdc_set_scrambling(hdmi->ddc, 0);
+   drm_scdc_set_scrambling(hdmi->connector.ddc, 0);
}
}
 
@@ -2127,10 +2127,10 @@ static int dw_hdmi_connector_get_modes(struct 
drm_connector *connector)
struct edid *edid;
int ret = 0;
 
-   if (!hdmi->ddc)
+   if (!hdmi->connector.ddc)
return 0;
 
-   edid = drm_get_edid(connector, hdmi->ddc);
+   edid = drm_get_edid(connector, hdmi->connector.ddc);
if (edid) {
dev_dbg(hdmi->dev, "got edid: width[%d] x height[%d]\n",
edid->width_cm, edid->height_cm);
@@ -2548,9 +2548,9 @@ __dw_hdmi_probe(struct platform_device *pdev,
 
ddc_node = of_parse_phandle(np, "ddc-i2c-bus", 0);
if (ddc_node) {
-   hdmi->ddc = of_get_i2c_adapter_by_node(ddc_node);
+   hdmi->connector.ddc = of_get_i2c_adapter_by_node(ddc_node);
of_node_put(ddc_node);
-   if (!hdmi->ddc) {
+   if (!hdmi->connector.ddc) {
dev_dbg(hdmi->dev, "failed to read ddc node\n");
return ERR_PTR(-EPROBE_DEFER);
}
@@ -2689,7 +2689,7 @@ __dw_hdmi_probe(struct platform_device *pdev,
hdmi_init_clk_regenerator(hdmi);
 
/* If DDC bus is not specified, try to register HDMI I2C bus */
-   if (!hdmi->ddc) {
+   if (!hdmi->connector.ddc) {
/* Look for (optional) stuff related to unwedging */
hdmi->pinctrl = devm_pinctrl_get(dev);
if (!IS_ERR(hdmi->pinctrl)) {
@@ -2708,9 +2708,9 @@ 

[PATCH v4 22/23] drm/radeon: Provide ddc symlink in connector sysfs directory

2019-07-11 Thread Andrzej Pietrasiewicz
Use the ddc pointer provided by the generic connector.

Signed-off-by: Andrzej Pietrasiewicz 
---
 drivers/gpu/drm/radeon/radeon_connectors.c | 80 ++
 1 file changed, 52 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c 
b/drivers/gpu/drm/radeon/radeon_connectors.c
index c60d1a44d22a..ee7430d0516e 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -1947,10 +1947,12 @@ radeon_add_atom_connector(struct drm_device *dev,
radeon_connector->con_priv = radeon_dig_connector;
if (i2c_bus->valid) {
radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, 
i2c_bus);
-   if (radeon_connector->ddc_bus)
+   if (radeon_connector->ddc_bus) {
has_aux = true;
-   else
+   connector->ddc = 
_connector->ddc_bus->adapter;
+   } else {
DRM_ERROR("DP: Failed to assign ddc bus! Check 
dmesg for i2c errors.\n");
+   }
}
switch (connector_type) {
case DRM_MODE_CONNECTOR_VGA:
@@ -2042,13 +2044,15 @@ radeon_add_atom_connector(struct drm_device *dev,
} else {
switch (connector_type) {
case DRM_MODE_CONNECTOR_VGA:
-   drm_connector_init(dev, _connector->base, 
_vga_connector_funcs, connector_type);
-   drm_connector_helper_add(_connector->base, 
_vga_connector_helper_funcs);
if (i2c_bus->valid) {
radeon_connector->ddc_bus = 
radeon_i2c_lookup(rdev, i2c_bus);
if (!radeon_connector->ddc_bus)
DRM_ERROR("VGA: Failed to assign ddc 
bus! Check dmesg for i2c errors.\n");
+   else
+   connector->ddc = 
_connector->ddc_bus->adapter;
}
+   drm_connector_init(dev, _connector->base, 
_vga_connector_funcs, connector_type);
+   drm_connector_helper_add(_connector->base, 
_vga_connector_helper_funcs);
radeon_connector->dac_load_detect = true;
drm_object_attach_property(_connector->base.base,
  
rdev->mode_info.load_detect_property,
@@ -2067,13 +2071,15 @@ radeon_add_atom_connector(struct drm_device *dev,
connector->doublescan_allowed = true;
break;
case DRM_MODE_CONNECTOR_DVIA:
-   drm_connector_init(dev, _connector->base, 
_vga_connector_funcs, connector_type);
-   drm_connector_helper_add(_connector->base, 
_vga_connector_helper_funcs);
if (i2c_bus->valid) {
radeon_connector->ddc_bus = 
radeon_i2c_lookup(rdev, i2c_bus);
if (!radeon_connector->ddc_bus)
DRM_ERROR("DVIA: Failed to assign ddc 
bus! Check dmesg for i2c errors.\n");
+   else
+   connector->ddc = 
_connector->ddc_bus->adapter;
}
+   drm_connector_init(dev, _connector->base, 
_vga_connector_funcs, connector_type);
+   drm_connector_helper_add(_connector->base, 
_vga_connector_helper_funcs);
radeon_connector->dac_load_detect = true;
drm_object_attach_property(_connector->base.base,
  
rdev->mode_info.load_detect_property,
@@ -2098,13 +2104,15 @@ radeon_add_atom_connector(struct drm_device *dev,
goto failed;
radeon_dig_connector->igp_lane_info = igp_lane_info;
radeon_connector->con_priv = radeon_dig_connector;
-   drm_connector_init(dev, _connector->base, 
_dvi_connector_funcs, connector_type);
-   drm_connector_helper_add(_connector->base, 
_dvi_connector_helper_funcs);
if (i2c_bus->valid) {
radeon_connector->ddc_bus = 
radeon_i2c_lookup(rdev, i2c_bus);
if (!radeon_connector->ddc_bus)
DRM_ERROR("DVI: Failed to assign ddc 
bus! Check dmesg for i2c errors.\n");
+   else
+   connector->ddc = 
_connector->ddc_bus->adapter;
}
+   drm_connector_init(dev, _connector->base, 
_dvi_connector_funcs, connector_type);
+   

[PATCH v4 21/23] drm/amdgpu: Provide ddc symlink in connector sysfs directory

2019-07-11 Thread Andrzej Pietrasiewicz
Use the ddc pointer provided by the generic connector.

Signed-off-by: Andrzej Pietrasiewicz 
---
 .../gpu/drm/amd/amdgpu/amdgpu_connectors.c| 56 ---
 1 file changed, 36 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
index 73b2ede773d3..e119d4c1f724 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
@@ -1574,10 +1574,12 @@ amdgpu_connector_add(struct amdgpu_device *adev,
amdgpu_connector->con_priv = amdgpu_dig_connector;
if (i2c_bus->valid) {
amdgpu_connector->ddc_bus = amdgpu_i2c_lookup(adev, 
i2c_bus);
-   if (amdgpu_connector->ddc_bus)
+   if (amdgpu_connector->ddc_bus) {
has_aux = true;
-   else
+   connector->ddc = 
_connector->ddc_bus->adapter;
+   } else {
DRM_ERROR("DP: Failed to assign ddc bus! Check 
dmesg for i2c errors.\n");
+   }
}
switch (connector_type) {
case DRM_MODE_CONNECTOR_VGA:
@@ -1659,13 +1661,15 @@ amdgpu_connector_add(struct amdgpu_device *adev,
} else {
switch (connector_type) {
case DRM_MODE_CONNECTOR_VGA:
-   drm_connector_init(dev, _connector->base, 
_connector_vga_funcs, connector_type);
-   drm_connector_helper_add(_connector->base, 
_connector_vga_helper_funcs);
if (i2c_bus->valid) {
amdgpu_connector->ddc_bus = 
amdgpu_i2c_lookup(adev, i2c_bus);
if (!amdgpu_connector->ddc_bus)
DRM_ERROR("VGA: Failed to assign ddc 
bus! Check dmesg for i2c errors.\n");
+   else
+   connector->ddc = 
_connector->ddc_bus->adapter;
}
+   drm_connector_init(dev, _connector->base, 
_connector_vga_funcs, connector_type);
+   drm_connector_helper_add(_connector->base, 
_connector_vga_helper_funcs);
amdgpu_connector->dac_load_detect = true;
drm_object_attach_property(_connector->base.base,
  
adev->mode_info.load_detect_property,
@@ -1679,13 +1683,15 @@ amdgpu_connector_add(struct amdgpu_device *adev,
connector->doublescan_allowed = true;
break;
case DRM_MODE_CONNECTOR_DVIA:
-   drm_connector_init(dev, _connector->base, 
_connector_vga_funcs, connector_type);
-   drm_connector_helper_add(_connector->base, 
_connector_vga_helper_funcs);
if (i2c_bus->valid) {
amdgpu_connector->ddc_bus = 
amdgpu_i2c_lookup(adev, i2c_bus);
if (!amdgpu_connector->ddc_bus)
DRM_ERROR("DVIA: Failed to assign ddc 
bus! Check dmesg for i2c errors.\n");
+   else
+   connector->ddc = 
_connector->ddc_bus->adapter;
}
+   drm_connector_init(dev, _connector->base, 
_connector_vga_funcs, connector_type);
+   drm_connector_helper_add(_connector->base, 
_connector_vga_helper_funcs);
amdgpu_connector->dac_load_detect = true;
drm_object_attach_property(_connector->base.base,
  
adev->mode_info.load_detect_property,
@@ -1704,13 +1710,15 @@ amdgpu_connector_add(struct amdgpu_device *adev,
if (!amdgpu_dig_connector)
goto failed;
amdgpu_connector->con_priv = amdgpu_dig_connector;
-   drm_connector_init(dev, _connector->base, 
_connector_dvi_funcs, connector_type);
-   drm_connector_helper_add(_connector->base, 
_connector_dvi_helper_funcs);
if (i2c_bus->valid) {
amdgpu_connector->ddc_bus = 
amdgpu_i2c_lookup(adev, i2c_bus);
if (!amdgpu_connector->ddc_bus)
DRM_ERROR("DVI: Failed to assign ddc 
bus! Check dmesg for i2c errors.\n");
+   else
+   connector->ddc = 
_connector->ddc_bus->adapter;
}
+   drm_connector_init(dev, _connector->base, 
_connector_dvi_funcs, connector_type);
+   drm_connector_helper_add(_connector->base, 

[PATCH v4 20/23] drm/bridge: ti-tfp410: Provide ddc symlink in connector sysfs directory

2019-07-11 Thread Andrzej Pietrasiewicz
Use the ddc pointer provided by the generic connector.

Signed-off-by: Andrzej Pietrasiewicz 
---
 drivers/gpu/drm/bridge/ti-tfp410.c | 19 +--
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/bridge/ti-tfp410.c 
b/drivers/gpu/drm/bridge/ti-tfp410.c
index dbf35c7bc85e..e55358f0a5ba 100644
--- a/drivers/gpu/drm/bridge/ti-tfp410.c
+++ b/drivers/gpu/drm/bridge/ti-tfp410.c
@@ -26,7 +26,6 @@ struct tfp410 {
unsigned intconnector_type;
 
u32 bus_format;
-   struct i2c_adapter  *ddc;
struct gpio_desc*hpd;
int hpd_irq;
struct delayed_work hpd_work;
@@ -55,10 +54,10 @@ static int tfp410_get_modes(struct drm_connector *connector)
struct edid *edid;
int ret;
 
-   if (!dvi->ddc)
+   if (!dvi->connector.ddc)
goto fallback;
 
-   edid = drm_get_edid(connector, dvi->ddc);
+   edid = drm_get_edid(connector, dvi->connector.ddc);
if (!edid) {
DRM_INFO("EDID read failed. Fallback to standard modes\n");
goto fallback;
@@ -98,8 +97,8 @@ tfp410_connector_detect(struct drm_connector *connector, bool 
force)
return connector_status_disconnected;
}
 
-   if (dvi->ddc) {
-   if (drm_probe_ddc(dvi->ddc))
+   if (dvi->connector.ddc) {
+   if (drm_probe_ddc(dvi->connector.ddc))
return connector_status_connected;
else
return connector_status_disconnected;
@@ -297,8 +296,8 @@ static int tfp410_get_connector_properties(struct tfp410 
*dvi)
if (!ddc_phandle)
goto fail;
 
-   dvi->ddc = of_get_i2c_adapter_by_node(ddc_phandle);
-   if (dvi->ddc)
+   dvi->connector.ddc = of_get_i2c_adapter_by_node(ddc_phandle);
+   if (dvi->connector.ddc)
dev_info(dvi->dev, "Connector's ddc i2c bus found\n");
else
ret = -EPROBE_DEFER;
@@ -367,7 +366,7 @@ static int tfp410_init(struct device *dev, bool i2c)
 
return 0;
 fail:
-   i2c_put_adapter(dvi->ddc);
+   i2c_put_adapter(dvi->connector.ddc);
if (dvi->hpd)
gpiod_put(dvi->hpd);
return ret;
@@ -382,8 +381,8 @@ static int tfp410_fini(struct device *dev)
 
drm_bridge_remove(>bridge);
 
-   if (dvi->ddc)
-   i2c_put_adapter(dvi->ddc);
+   if (dvi->connector.ddc)
+   i2c_put_adapter(dvi->connector.ddc);
if (dvi->hpd)
gpiod_put(dvi->hpd);
 
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH v4 18/23] drm/bridge: dumb-vga-dac: Provide ddc symlink in connector sysfs directory

2019-07-11 Thread Andrzej Pietrasiewicz
Use the ddc pointer provided by the generic connector.

Signed-off-by: Andrzej Pietrasiewicz 
---
 drivers/gpu/drm/bridge/dumb-vga-dac.c | 19 +--
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/bridge/dumb-vga-dac.c 
b/drivers/gpu/drm/bridge/dumb-vga-dac.c
index d32885b906ae..b4cc3238400a 100644
--- a/drivers/gpu/drm/bridge/dumb-vga-dac.c
+++ b/drivers/gpu/drm/bridge/dumb-vga-dac.c
@@ -20,7 +20,6 @@ struct dumb_vga {
struct drm_bridge   bridge;
struct drm_connectorconnector;
 
-   struct i2c_adapter  *ddc;
struct regulator*vdd;
 };
 
@@ -42,10 +41,10 @@ static int dumb_vga_get_modes(struct drm_connector 
*connector)
struct edid *edid;
int ret;
 
-   if (IS_ERR(vga->ddc))
+   if (IS_ERR(vga->connector.ddc))
goto fallback;
 
-   edid = drm_get_edid(connector, vga->ddc);
+   edid = drm_get_edid(connector, vga->connector.ddc);
if (!edid) {
DRM_INFO("EDID readout failed, falling back to standard 
modes\n");
goto fallback;
@@ -84,7 +83,7 @@ dumb_vga_connector_detect(struct drm_connector *connector, 
bool force)
 * wire the DDC pins, or the I2C bus might not be working at
 * all.
 */
-   if (!IS_ERR(vga->ddc) && drm_probe_ddc(vga->ddc))
+   if (!IS_ERR(vga->connector.ddc) && drm_probe_ddc(vga->connector.ddc))
return connector_status_connected;
 
return connector_status_unknown;
@@ -190,14 +189,14 @@ static int dumb_vga_probe(struct platform_device *pdev)
dev_dbg(>dev, "No vdd regulator found: %d\n", ret);
}
 
-   vga->ddc = dumb_vga_retrieve_ddc(>dev);
-   if (IS_ERR(vga->ddc)) {
-   if (PTR_ERR(vga->ddc) == -ENODEV) {
+   vga->connector.ddc = dumb_vga_retrieve_ddc(>dev);
+   if (IS_ERR(vga->connector.ddc)) {
+   if (PTR_ERR(vga->connector.ddc) == -ENODEV) {
dev_dbg(>dev,
"No i2c bus specified. Disabling EDID 
readout\n");
} else {
dev_err(>dev, "Couldn't retrieve i2c bus\n");
-   return PTR_ERR(vga->ddc);
+   return PTR_ERR(vga->connector.ddc);
}
}
 
@@ -216,8 +215,8 @@ static int dumb_vga_remove(struct platform_device *pdev)
 
drm_bridge_remove(>bridge);
 
-   if (!IS_ERR(vga->ddc))
-   i2c_put_adapter(vga->ddc);
+   if (!IS_ERR(vga->connector.ddc))
+   i2c_put_adapter(vga->connector.ddc);
 
return 0;
 }
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH v4 17/23] drm/ast: Provide ddc symlink in connector sysfs directory

2019-07-11 Thread Andrzej Pietrasiewicz
Use the ddc pointer provided by the generic connector.

Signed-off-by: Andrzej Pietrasiewicz 
---
 drivers/gpu/drm/ast/ast_mode.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index ffccbef962a4..1ca9bc4aa3bb 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -890,6 +890,11 @@ static int ast_connector_init(struct drm_device *dev)
return -ENOMEM;
 
connector = _connector->base;
+   ast_connector->i2c = ast_i2c_create(dev);
+   if (!ast_connector->i2c)
+   DRM_ERROR("failed to add ddc bus for connector\n");
+
+   connector->ddc = _connector->i2c->adapter;
drm_connector_init(dev, connector, _connector_funcs, 
DRM_MODE_CONNECTOR_VGA);
 
drm_connector_helper_add(connector, _connector_helper_funcs);
@@ -904,10 +909,6 @@ static int ast_connector_init(struct drm_device *dev)
encoder = list_first_entry(>mode_config.encoder_list, struct 
drm_encoder, head);
drm_connector_attach_encoder(connector, encoder);
 
-   ast_connector->i2c = ast_i2c_create(dev);
-   if (!ast_connector->i2c)
-   DRM_ERROR("failed to add ddc bus for connector\n");
-
return 0;
 }
 
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH v4 14/23] drm/tilcdc: Provide ddc symlink in connector sysfs directory

2019-07-11 Thread Andrzej Pietrasiewicz
Use the ddc pointer provided by the generic connector.

Signed-off-by: Andrzej Pietrasiewicz 
---
 drivers/gpu/drm/tilcdc/tilcdc_tfp410.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c 
b/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c
index 62d014c20988..c373edb95666 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c
@@ -219,6 +219,7 @@ static struct drm_connector *tfp410_connector_create(struct 
drm_device *dev,
tfp410_connector->mod = mod;
 
connector = _connector->base;
+   connector->ddc = mod->i2c;
 
drm_connector_init(dev, connector, _connector_funcs,
DRM_MODE_CONNECTOR_DVID);
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH v4 16/23] drm/mgag200: Provide ddc symlink in connector sysfs directory

2019-07-11 Thread Andrzej Pietrasiewicz
Use the ddc pointer provided by the generic connector.

Signed-off-by: Andrzej Pietrasiewicz 
---
 drivers/gpu/drm/mgag200/mgag200_mode.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c 
b/drivers/gpu/drm/mgag200/mgag200_mode.c
index a25054015e8c..8fb9444b2142 100644
--- a/drivers/gpu/drm/mgag200/mgag200_mode.c
+++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
@@ -1703,6 +1703,11 @@ static struct drm_connector *mga_vga_init(struct 
drm_device *dev)
return NULL;
 
connector = _connector->base;
+   mga_connector->i2c = mgag200_i2c_create(dev);
+   if (!mga_connector->i2c)
+   DRM_ERROR("failed to add ddc bus\n");
+
+   connector->ddc = _connector->i2c->adapter;
 
drm_connector_init(dev, connector,
   _vga_connector_funcs, DRM_MODE_CONNECTOR_VGA);
@@ -1711,10 +1716,6 @@ static struct drm_connector *mga_vga_init(struct 
drm_device *dev)
 
drm_connector_register(connector);
 
-   mga_connector->i2c = mgag200_i2c_create(dev);
-   if (!mga_connector->i2c)
-   DRM_ERROR("failed to add ddc bus\n");
-
return connector;
 }
 
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH v4 15/23] drm: sti: Provide ddc symlink in hdmi connector sysfs directory

2019-07-11 Thread Andrzej Pietrasiewicz
Use the ddc pointer provided by the generic connector.

Signed-off-by: Andrzej Pietrasiewicz 
---
 drivers/gpu/drm/sti/sti_hdmi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/sti/sti_hdmi.c b/drivers/gpu/drm/sti/sti_hdmi.c
index f03d617edc4c..90f8db63c095 100644
--- a/drivers/gpu/drm/sti/sti_hdmi.c
+++ b/drivers/gpu/drm/sti/sti_hdmi.c
@@ -1279,6 +1279,7 @@ static int sti_hdmi_bind(struct device *dev, struct 
device *master, void *data)
drm_bridge_attach(encoder, bridge, NULL);
 
connector->encoder = encoder;
+   drm_connector->ddc = hdmi->ddc_adapt;
 
drm_connector = (struct drm_connector *)connector;
 
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH v4 12/23] drm: zte: Provide ddc symlink in hdmi connector sysfs directory

2019-07-11 Thread Andrzej Pietrasiewicz
Use the ddc pointer provided by the generic connector.

Signed-off-by: Andrzej Pietrasiewicz 
---
 drivers/gpu/drm/zte/zx_hdmi.c | 25 +
 1 file changed, 9 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/zte/zx_hdmi.c b/drivers/gpu/drm/zte/zx_hdmi.c
index bfe918b27c5c..862a855ea14a 100644
--- a/drivers/gpu/drm/zte/zx_hdmi.c
+++ b/drivers/gpu/drm/zte/zx_hdmi.c
@@ -29,15 +29,11 @@
 #define ZX_HDMI_INFOFRAME_SIZE 31
 #define DDC_SEGMENT_ADDR   0x30
 
-struct zx_hdmi_i2c {
-   struct i2c_adapter adap;
-   struct mutex lock;
-};
-
 struct zx_hdmi {
struct drm_connector connector;
struct drm_encoder encoder;
-   struct zx_hdmi_i2c *ddc;
+   /* protects ddc access */
+   struct mutex ddc_lock;
struct device *dev;
struct drm_device *drm;
void __iomem *mmio;
@@ -264,7 +260,7 @@ static int zx_hdmi_connector_get_modes(struct drm_connector 
*connector)
struct edid *edid;
int ret;
 
-   edid = drm_get_edid(connector, >ddc->adap);
+   edid = drm_get_edid(connector, connector->ddc);
if (!edid)
return 0;
 
@@ -562,10 +558,9 @@ static int zx_hdmi_i2c_xfer(struct i2c_adapter *adap, 
struct i2c_msg *msgs,
int num)
 {
struct zx_hdmi *hdmi = i2c_get_adapdata(adap);
-   struct zx_hdmi_i2c *ddc = hdmi->ddc;
int i, ret = 0;
 
-   mutex_lock(>lock);
+   mutex_lock(>ddc_lock);
 
/* Enable DDC master access */
hdmi_writeb_mask(hdmi, TPI_DDC_MASTER_EN, HW_DDC_MASTER, HW_DDC_MASTER);
@@ -590,7 +585,7 @@ static int zx_hdmi_i2c_xfer(struct i2c_adapter *adap, 
struct i2c_msg *msgs,
/* Disable DDC master access */
hdmi_writeb_mask(hdmi, TPI_DDC_MASTER_EN, HW_DDC_MASTER, 0);
 
-   mutex_unlock(>lock);
+   mutex_unlock(>ddc_lock);
 
return ret;
 }
@@ -608,17 +603,15 @@ static const struct i2c_algorithm zx_hdmi_algorithm = {
 static int zx_hdmi_ddc_register(struct zx_hdmi *hdmi)
 {
struct i2c_adapter *adap;
-   struct zx_hdmi_i2c *ddc;
int ret;
 
-   ddc = devm_kzalloc(hdmi->dev, sizeof(*ddc), GFP_KERNEL);
-   if (!ddc)
+   adap = devm_kzalloc(hdmi->dev, sizeof(*adap), GFP_KERNEL);
+   if (!adap)
return -ENOMEM;
 
-   hdmi->ddc = ddc;
-   mutex_init(>lock);
+   hdmi->connector.ddc = adap;
+   mutex_init(>ddc_lock);
 
-   adap = >adap;
adap->owner = THIS_MODULE;
adap->class = I2C_CLASS_DDC;
adap->dev.parent = hdmi->dev;
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH v4 13/23] drm: zte: Provide ddc symlink in vga connector sysfs directory

2019-07-11 Thread Andrzej Pietrasiewicz
Use the ddc pointer provided by the generic connector.

Signed-off-by: Andrzej Pietrasiewicz 
---
 drivers/gpu/drm/zte/zx_vga.c | 25 +
 1 file changed, 9 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/zte/zx_vga.c b/drivers/gpu/drm/zte/zx_vga.c
index 1634a08707fb..a3a4d6982888 100644
--- a/drivers/gpu/drm/zte/zx_vga.c
+++ b/drivers/gpu/drm/zte/zx_vga.c
@@ -23,15 +23,11 @@ struct zx_vga_pwrctrl {
u32 mask;
 };
 
-struct zx_vga_i2c {
-   struct i2c_adapter adap;
-   struct mutex lock;
-};
-
 struct zx_vga {
struct drm_connector connector;
struct drm_encoder encoder;
-   struct zx_vga_i2c *ddc;
+   /* protects ddc access */
+   struct mutex ddc_lock;
struct device *dev;
void __iomem *mmio;
struct clk *i2c_wclk;
@@ -86,7 +82,7 @@ static int zx_vga_connector_get_modes(struct drm_connector 
*connector)
 */
zx_writel(vga->mmio + VGA_AUTO_DETECT_SEL, 0);
 
-   edid = drm_get_edid(connector, >ddc->adap);
+   edid = drm_get_edid(connector, connector->ddc);
if (!edid) {
/*
 * If EDID reading fails, we set the device state into
@@ -282,11 +278,10 @@ static int zx_vga_i2c_xfer(struct i2c_adapter *adap, 
struct i2c_msg *msgs,
   int num)
 {
struct zx_vga *vga = i2c_get_adapdata(adap);
-   struct zx_vga_i2c *ddc = vga->ddc;
int ret = 0;
int i;
 
-   mutex_lock(>lock);
+   mutex_lock(>ddc_lock);
 
for (i = 0; i < num; i++) {
if (msgs[i].flags & I2C_M_RD)
@@ -301,7 +296,7 @@ static int zx_vga_i2c_xfer(struct i2c_adapter *adap, struct 
i2c_msg *msgs,
if (!ret)
ret = num;
 
-   mutex_unlock(>lock);
+   mutex_unlock(>ddc_lock);
 
return ret;
 }
@@ -320,17 +315,15 @@ static int zx_vga_ddc_register(struct zx_vga *vga)
 {
struct device *dev = vga->dev;
struct i2c_adapter *adap;
-   struct zx_vga_i2c *ddc;
int ret;
 
-   ddc = devm_kzalloc(dev, sizeof(*ddc), GFP_KERNEL);
-   if (!ddc)
+   adap = devm_kzalloc(dev, sizeof(*adap), GFP_KERNEL);
+   if (!adap)
return -ENOMEM;
 
-   vga->ddc = ddc;
-   mutex_init(>lock);
+   vga->connector.ddc = adap;
+   mutex_init(>ddc_lock);
 
-   adap = >adap;
adap->owner = THIS_MODULE;
adap->class = I2C_CLASS_DDC;
adap->dev.parent = dev;
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH v4 11/23] drm/vc4: Provide ddc symlink in connector sysfs directory

2019-07-11 Thread Andrzej Pietrasiewicz
Use the ddc pointer provided by the generic connector.

Signed-off-by: Andrzej Pietrasiewicz 
---
 drivers/gpu/drm/vc4/vc4_hdmi.c | 21 -
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
index ee7d4e7b0ee3..abacd48a1462 100644
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
@@ -76,7 +76,6 @@ struct vc4_hdmi {
 
struct vc4_hdmi_audio audio;
 
-   struct i2c_adapter *ddc;
void __iomem *hdmicore_regs;
void __iomem *hd_regs;
int hpd_gpio;
@@ -207,7 +206,7 @@ vc4_hdmi_connector_detect(struct drm_connector *connector, 
bool force)
return connector_status_disconnected;
}
 
-   if (drm_probe_ddc(vc4->hdmi->ddc))
+   if (drm_probe_ddc(connector->ddc))
return connector_status_connected;
 
if (HDMI_READ(VC4_HDMI_HOTPLUG) & VC4_HDMI_HOTPLUG_CONNECTED)
@@ -233,7 +232,7 @@ static int vc4_hdmi_connector_get_modes(struct 
drm_connector *connector)
int ret = 0;
struct edid *edid;
 
-   edid = drm_get_edid(connector, vc4->hdmi->ddc);
+   edid = drm_get_edid(connector, connector->ddc);
cec_s_phys_addr_from_edid(vc4->hdmi->cec_adap, edid);
if (!edid)
return -ENODEV;
@@ -267,7 +266,8 @@ static const struct drm_connector_helper_funcs 
vc4_hdmi_connector_helper_funcs =
 };
 
 static struct drm_connector *vc4_hdmi_connector_init(struct drm_device *dev,
-struct drm_encoder 
*encoder)
+struct drm_encoder 
*encoder,
+struct i2c_adapter *ddc)
 {
struct drm_connector *connector;
struct vc4_hdmi_connector *hdmi_connector;
@@ -280,6 +280,7 @@ static struct drm_connector *vc4_hdmi_connector_init(struct 
drm_device *dev,
connector = _connector->base;
 
hdmi_connector->encoder = encoder;
+   connector->ddc = ddc;
 
drm_connector_init(dev, connector, _hdmi_connector_funcs,
   DRM_MODE_CONNECTOR_HDMIA);
@@ -1291,6 +1292,7 @@ static int vc4_hdmi_bind(struct device *dev, struct 
device *master, void *data)
struct vc4_hdmi *hdmi;
struct vc4_hdmi_encoder *vc4_hdmi_encoder;
struct device_node *ddc_node;
+   struct i2c_adapter *ddc;
u32 value;
int ret;
 
@@ -1338,9 +1340,9 @@ static int vc4_hdmi_bind(struct device *dev, struct 
device *master, void *data)
return -ENODEV;
}
 
-   hdmi->ddc = of_find_i2c_adapter_by_node(ddc_node);
+   ddc = of_find_i2c_adapter_by_node(ddc_node);
of_node_put(ddc_node);
-   if (!hdmi->ddc) {
+   if (ddc) {
DRM_DEBUG("Failed to get ddc i2c adapter by node\n");
return -EPROBE_DEFER;
}
@@ -1395,7 +1397,7 @@ static int vc4_hdmi_bind(struct device *dev, struct 
device *master, void *data)
 DRM_MODE_ENCODER_TMDS, NULL);
drm_encoder_helper_add(hdmi->encoder, _hdmi_encoder_helper_funcs);
 
-   hdmi->connector = vc4_hdmi_connector_init(drm, hdmi->encoder);
+   hdmi->connector = vc4_hdmi_connector_init(drm, hdmi->encoder, ddc);
if (IS_ERR(hdmi->connector)) {
ret = PTR_ERR(hdmi->connector);
goto err_destroy_encoder;
@@ -1452,7 +1454,7 @@ static int vc4_hdmi_bind(struct device *dev, struct 
device *master, void *data)
clk_disable_unprepare(hdmi->hsm_clock);
pm_runtime_disable(dev);
 err_put_i2c:
-   put_device(>ddc->dev);
+   put_device(>dev);
 
return ret;
 }
@@ -1463,6 +1465,7 @@ static void vc4_hdmi_unbind(struct device *dev, struct 
device *master,
struct drm_device *drm = dev_get_drvdata(master);
struct vc4_dev *vc4 = drm->dev_private;
struct vc4_hdmi *hdmi = vc4->hdmi;
+   struct i2c_adapter *ddc = hdmi->connector->ddc;
 
cec_unregister_adapter(hdmi->cec_adap);
vc4_hdmi_connector_destroy(hdmi->connector);
@@ -1471,7 +1474,7 @@ static void vc4_hdmi_unbind(struct device *dev, struct 
device *master,
clk_disable_unprepare(hdmi->hsm_clock);
pm_runtime_disable(dev);
 
-   put_device(>ddc->dev);
+   put_device(>dev);
 
vc4->hdmi = NULL;
 }
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH v4 09/23] drm/imx: imx-ldb: Provide ddc symlink in connector's sysfs

2019-07-11 Thread Andrzej Pietrasiewicz
Use the ddc pointer provided by the generic connector.

Signed-off-by: Andrzej Pietrasiewicz 
---
 drivers/gpu/drm/imx/imx-ldb.c | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-ldb.c b/drivers/gpu/drm/imx/imx-ldb.c
index 383733302280..44fdb264339e 100644
--- a/drivers/gpu/drm/imx/imx-ldb.c
+++ b/drivers/gpu/drm/imx/imx-ldb.c
@@ -55,7 +55,6 @@ struct imx_ldb_channel {
struct drm_bridge *bridge;
 
struct device_node *child;
-   struct i2c_adapter *ddc;
int chno;
void *edid;
int edid_len;
@@ -131,8 +130,8 @@ static int imx_ldb_connector_get_modes(struct drm_connector 
*connector)
return num_modes;
}
 
-   if (!imx_ldb_ch->edid && imx_ldb_ch->ddc)
-   imx_ldb_ch->edid = drm_get_edid(connector, imx_ldb_ch->ddc);
+   if (!imx_ldb_ch->edid && connector->ddc)
+   imx_ldb_ch->edid = drm_get_edid(connector, connector->ddc);
 
if (imx_ldb_ch->edid) {
drm_connector_update_edid_property(connector,
@@ -550,15 +549,15 @@ static int imx_ldb_panel_ddc(struct device *dev,
 
ddc_node = of_parse_phandle(child, "ddc-i2c-bus", 0);
if (ddc_node) {
-   channel->ddc = of_find_i2c_adapter_by_node(ddc_node);
+   channel->connector.ddc = of_find_i2c_adapter_by_node(ddc_node);
of_node_put(ddc_node);
-   if (!channel->ddc) {
+   if (!channel->connector.ddc) {
dev_warn(dev, "failed to get ddc i2c adapter\n");
return -EPROBE_DEFER;
}
}
 
-   if (!channel->ddc) {
+   if (!channel->connector.ddc) {
/* if no DDC available, fallback to hardcoded EDID */
dev_dbg(dev, "no ddc available\n");
 
@@ -725,7 +724,7 @@ static void imx_ldb_unbind(struct device *dev, struct 
device *master,
drm_panel_detach(channel->panel);
 
kfree(channel->edid);
-   i2c_put_adapter(channel->ddc);
+   i2c_put_adapter(channel->connector.ddc);
}
 }
 
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH v4 10/23] drm/imx: imx-tve: Provide ddc symlink in connector's sysfs

2019-07-11 Thread Andrzej Pietrasiewicz
Use the ddc pointer provided by the generic connector.

Signed-off-by: Andrzej Pietrasiewicz 
---
 drivers/gpu/drm/imx/imx-tve.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-tve.c b/drivers/gpu/drm/imx/imx-tve.c
index e725af8a0025..b8bee4e1f169 100644
--- a/drivers/gpu/drm/imx/imx-tve.c
+++ b/drivers/gpu/drm/imx/imx-tve.c
@@ -109,7 +109,6 @@ struct imx_tve {
 
struct regmap *regmap;
struct regulator *dac_reg;
-   struct i2c_adapter *ddc;
struct clk *clk;
struct clk *di_sel_clk;
struct clk_hw clk_hw_di;
@@ -218,14 +217,13 @@ static int tve_setup_vga(struct imx_tve *tve)
 
 static int imx_tve_connector_get_modes(struct drm_connector *connector)
 {
-   struct imx_tve *tve = con_to_tve(connector);
struct edid *edid;
int ret = 0;
 
-   if (!tve->ddc)
+   if (!connector->ddc)
return 0;
 
-   edid = drm_get_edid(connector, tve->ddc);
+   edid = drm_get_edid(connector, connector->ddc);
if (edid) {
drm_connector_update_edid_property(connector, edid);
ret = drm_add_edid_modes(connector, edid);
@@ -551,7 +549,7 @@ static int imx_tve_bind(struct device *dev, struct device 
*master, void *data)
 
ddc_node = of_parse_phandle(np, "ddc-i2c-bus", 0);
if (ddc_node) {
-   tve->ddc = of_find_i2c_adapter_by_node(ddc_node);
+   tve->connector.ddc = of_find_i2c_adapter_by_node(ddc_node);
of_node_put(ddc_node);
}
 
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH v4 07/23] drm/mediatek: Provide ddc symlink in hdmi connector sysfs directory

2019-07-11 Thread Andrzej Pietrasiewicz
Use the ddc pointer provided by the generic connector.

Signed-off-by: Andrzej Pietrasiewicz 
---
 drivers/gpu/drm/mediatek/mtk_hdmi.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c 
b/drivers/gpu/drm/mediatek/mtk_hdmi.c
index 5d6a9f094df5..6c5321dcc4b8 100644
--- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
+++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
@@ -146,7 +146,6 @@ struct mtk_hdmi {
struct device *dev;
struct phy *phy;
struct device *cec_dev;
-   struct i2c_adapter *ddc_adpt;
struct clk *clk[MTK_HDMI_CLK_COUNT];
struct drm_display_mode mode;
bool dvi_mode;
@@ -1213,10 +1212,10 @@ static int mtk_hdmi_conn_get_modes(struct drm_connector 
*conn)
struct edid *edid;
int ret;
 
-   if (!hdmi->ddc_adpt)
+   if (!conn->ddc)
return -ENODEV;
 
-   edid = drm_get_edid(conn, hdmi->ddc_adpt);
+   edid = drm_get_edid(conn, conn->ddc);
if (!edid)
return -ENODEV;
 
@@ -1509,9 +1508,9 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi,
}
of_node_put(remote);
 
-   hdmi->ddc_adpt = of_find_i2c_adapter_by_node(i2c_np);
+   hdmi->conn.ddc = of_find_i2c_adapter_by_node(i2c_np);
of_node_put(i2c_np);
-   if (!hdmi->ddc_adpt) {
+   if (!hdmi->conn.ddc) {
dev_err(dev, "Failed to get ddc i2c adapter by node\n");
return -EINVAL;
}
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH v4 05/23] drm/msm/hdmi: Provide ddc symlink in hdmi connector sysfs directory

2019-07-11 Thread Andrzej Pietrasiewicz
Use the ddc pointer provided by the generic connector.

Signed-off-by: Andrzej Pietrasiewicz 
---
 drivers/gpu/drm/msm/hdmi/hdmi_connector.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_connector.c 
b/drivers/gpu/drm/msm/hdmi/hdmi_connector.c
index 07b4cb877d82..6f33d5e43dd2 100644
--- a/drivers/gpu/drm/msm/hdmi/hdmi_connector.c
+++ b/drivers/gpu/drm/msm/hdmi/hdmi_connector.c
@@ -450,6 +450,7 @@ struct drm_connector *msm_hdmi_connector_init(struct hdmi 
*hdmi)
 
connector = _connector->base;
 
+   connector->ddc = hdmi->i2c;
drm_connector_init(hdmi->dev, connector, _connector_funcs,
DRM_MODE_CONNECTOR_HDMIA);
drm_connector_helper_add(connector, _hdmi_connector_helper_funcs);
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH v4 06/23] drm/sun4i: hdmi: Provide ddc symlink in sun4i hdmi connector sysfs directory

2019-07-11 Thread Andrzej Pietrasiewicz
Use the ddc pointer provided by the generic connector.

Signed-off-by: Andrzej Pietrasiewicz 
---
 drivers/gpu/drm/sun4i/sun4i_hdmi.h |  1 -
 drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 14 +++---
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi.h 
b/drivers/gpu/drm/sun4i/sun4i_hdmi.h
index 7ad3f06c127e..1649273b1493 100644
--- a/drivers/gpu/drm/sun4i/sun4i_hdmi.h
+++ b/drivers/gpu/drm/sun4i/sun4i_hdmi.h
@@ -265,7 +265,6 @@ struct sun4i_hdmi {
struct clk  *tmds_clk;
 
struct i2c_adapter  *i2c;
-   struct i2c_adapter  *ddc_i2c;
 
/* Regmap fields for I2C adapter */
struct regmap_field *field_ddc_en;
diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c 
b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
index 9c3f99339b82..250bec00dc35 100644
--- a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
+++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
@@ -213,7 +213,7 @@ static int sun4i_hdmi_get_modes(struct drm_connector 
*connector)
struct edid *edid;
int ret;
 
-   edid = drm_get_edid(connector, hdmi->ddc_i2c ?: hdmi->i2c);
+   edid = drm_get_edid(connector, connector->ddc ?: hdmi->i2c);
if (!edid)
return 0;
 
@@ -598,11 +598,11 @@ static int sun4i_hdmi_bind(struct device *dev, struct 
device *master,
goto err_disable_mod_clk;
}
 
-   hdmi->ddc_i2c = sun4i_hdmi_get_ddc(dev);
-   if (IS_ERR(hdmi->ddc_i2c)) {
-   ret = PTR_ERR(hdmi->ddc_i2c);
+   hdmi->connector.ddc = sun4i_hdmi_get_ddc(dev);
+   if (IS_ERR(hdmi->connector.ddc)) {
+   ret = PTR_ERR(hdmi->connector.ddc);
if (ret == -ENODEV)
-   hdmi->ddc_i2c = NULL;
+   hdmi->connector.ddc = NULL;
else
goto err_del_i2c_adapter;
}
@@ -663,7 +663,7 @@ static int sun4i_hdmi_bind(struct device *dev, struct 
device *master,
cec_delete_adapter(hdmi->cec_adap);
drm_encoder_cleanup(>encoder);
 err_put_ddc_i2c:
-   i2c_put_adapter(hdmi->ddc_i2c);
+   i2c_put_adapter(hdmi->connector.ddc);
 err_del_i2c_adapter:
i2c_del_adapter(hdmi->i2c);
 err_disable_mod_clk:
@@ -684,7 +684,7 @@ static void sun4i_hdmi_unbind(struct device *dev, struct 
device *master,
drm_connector_cleanup(>connector);
drm_encoder_cleanup(>encoder);
i2c_del_adapter(hdmi->i2c);
-   i2c_put_adapter(hdmi->ddc_i2c);
+   i2c_put_adapter(hdmi->connector.ddc);
clk_disable_unprepare(hdmi->mod_clk);
clk_disable_unprepare(hdmi->bus_clk);
 }
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH v4 08/23] drm/tegra: Provide ddc symlink in output connector sysfs directory

2019-07-11 Thread Andrzej Pietrasiewicz
Use the ddc pointer provided by the generic connector.

Signed-off-by: Andrzej Pietrasiewicz 
---
 drivers/gpu/drm/tegra/drm.h|  1 -
 drivers/gpu/drm/tegra/output.c | 12 ++--
 drivers/gpu/drm/tegra/sor.c|  6 +++---
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h
index 86daa19fcf24..9bf72bcd3ec1 100644
--- a/drivers/gpu/drm/tegra/drm.h
+++ b/drivers/gpu/drm/tegra/drm.h
@@ -120,7 +120,6 @@ struct tegra_output {
struct device *dev;
 
struct drm_panel *panel;
-   struct i2c_adapter *ddc;
const struct edid *edid;
struct cec_notifier *cec;
unsigned int hpd_irq;
diff --git a/drivers/gpu/drm/tegra/output.c b/drivers/gpu/drm/tegra/output.c
index 274cb955e2e1..0b5037a29c63 100644
--- a/drivers/gpu/drm/tegra/output.c
+++ b/drivers/gpu/drm/tegra/output.c
@@ -30,8 +30,8 @@ int tegra_output_connector_get_modes(struct drm_connector 
*connector)
 
if (output->edid)
edid = kmemdup(output->edid, sizeof(*edid), GFP_KERNEL);
-   else if (output->ddc)
-   edid = drm_get_edid(connector, output->ddc);
+   else if (connector->ddc)
+   edid = drm_get_edid(connector, connector->ddc);
 
cec_notifier_set_phys_addr_from_edid(output->cec, edid);
drm_connector_update_edid_property(connector, edid);
@@ -111,8 +111,8 @@ int tegra_output_probe(struct tegra_output *output)
 
ddc = of_parse_phandle(output->of_node, "nvidia,ddc-i2c-bus", 0);
if (ddc) {
-   output->ddc = of_find_i2c_adapter_by_node(ddc);
-   if (!output->ddc) {
+   output->connector.ddc = of_find_i2c_adapter_by_node(ddc);
+   if (!output->connector.ddc) {
err = -EPROBE_DEFER;
of_node_put(ddc);
return err;
@@ -174,8 +174,8 @@ void tegra_output_remove(struct tegra_output *output)
if (output->hpd_gpio)
free_irq(output->hpd_irq, output);
 
-   if (output->ddc)
-   put_device(>ddc->dev);
+   if (output->connector.ddc)
+   put_device(>connector.ddc->dev);
 }
 
 int tegra_output_init(struct drm_device *drm, struct tegra_output *output)
diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c
index 4ffe3794e6d3..77e61f98de07 100644
--- a/drivers/gpu/drm/tegra/sor.c
+++ b/drivers/gpu/drm/tegra/sor.c
@@ -2311,7 +2311,7 @@ static void tegra_sor_hdmi_disable_scrambling(struct 
tegra_sor *sor)
 
 static void tegra_sor_hdmi_scdc_disable(struct tegra_sor *sor)
 {
-   struct i2c_adapter *ddc = sor->output.ddc;
+   struct i2c_adapter *ddc = sor->output.connector.ddc;
 
drm_scdc_set_high_tmds_clock_ratio(ddc, false);
drm_scdc_set_scrambling(ddc, false);
@@ -2339,7 +2339,7 @@ static void tegra_sor_hdmi_enable_scrambling(struct 
tegra_sor *sor)
 
 static void tegra_sor_hdmi_scdc_enable(struct tegra_sor *sor)
 {
-   struct i2c_adapter *ddc = sor->output.ddc;
+   struct i2c_adapter *ddc = sor->output.connector.ddc;
 
drm_scdc_set_high_tmds_clock_ratio(ddc, true);
drm_scdc_set_scrambling(ddc, true);
@@ -2350,7 +2350,7 @@ static void tegra_sor_hdmi_scdc_enable(struct tegra_sor 
*sor)
 static void tegra_sor_hdmi_scdc_work(struct work_struct *work)
 {
struct tegra_sor *sor = container_of(work, struct tegra_sor, scdc.work);
-   struct i2c_adapter *ddc = sor->output.ddc;
+   struct i2c_adapter *ddc = sor->output.connector.ddc;
 
if (!drm_scdc_get_scrambling_status(ddc)) {
DRM_DEBUG_KMS("SCDC not scrambled\n");
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH v4 01/23] drm: Include ddc adapter pointer in struct drm_connector

2019-07-11 Thread Andrzej Pietrasiewicz
Add generic code which creates symbolic links in sysfs, pointing to ddc
interface used by a particular video output. For example:

ls -l /sys/class/drm/card0-HDMI-A-1/ddc
lrwxrwxrwx 1 root root 0 Jun 24 10:42 /sys/class/drm/card0-HDMI-A-1/ddc \
-> ../../../../soc/1388.i2c/i2c-2

This makes it easy for user to associate a display with its ddc adapter
and use e.g. ddcutil to control the chosen monitor.

This patch adds an i2c_adapter pointer to struct drm_connector. Particular
drivers can then use it instead of using their own private instance. If a
connector contains a ddc, then create a symbolic link in sysfs.

Signed-off-by: Andrzej Pietrasiewicz 
Acked-by: Daniel Vetter 
Reviewed-by: Andrzej Hajda 
---
 drivers/gpu/drm/drm_sysfs.c |  7 +++
 include/drm/drm_connector.h | 11 +++
 2 files changed, 18 insertions(+)

diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index ad10810bc972..26d359b39785 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -294,6 +294,9 @@ int drm_sysfs_connector_add(struct drm_connector *connector)
/* Let userspace know we have a new connector */
drm_sysfs_hotplug_event(dev);
 
+   if (connector->ddc)
+   return sysfs_create_link(>kdev->kobj,
+>ddc->dev.kobj, "ddc");
return 0;
 }
 
@@ -301,6 +304,10 @@ void drm_sysfs_connector_remove(struct drm_connector 
*connector)
 {
if (!connector->kdev)
return;
+
+   if (connector->ddc)
+   sysfs_remove_link(>kdev->kobj, "ddc");
+
DRM_DEBUG("removing \"%s\" from sysfs\n",
  connector->name);
 
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index ca745d9feaf5..1ad3d1d54ba7 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -23,6 +23,7 @@
 #ifndef __DRM_CONNECTOR_H__
 #define __DRM_CONNECTOR_H__
 
+#include 
 #include 
 #include 
 #include 
@@ -1308,6 +1309,16 @@ struct drm_connector {
 * [0]: progressive, [1]: interlaced
 */
int audio_latency[2];
+
+   /**
+* @ddc: associated ddc adapter.
+* A connector usually has its associated ddc adapter. If a driver uses
+* this field, then an appropriate symbolic link is created in connector
+* sysfs directory to make it easy for the user to tell which i2c
+* adapter is for a particular display.
+*/
+   struct i2c_adapter *ddc;
+
/**
 * @null_edid_counter: track sinks that give us all zeros for the EDID.
 * Needed to workaround some HW bugs where we get all 0s
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH v4 04/23] drm: rockchip: Provide ddc symlink in inno_hdmi sysfs directory

2019-07-11 Thread Andrzej Pietrasiewicz
Use the ddc pointer provided by the generic connector.

Signed-off-by: Andrzej Pietrasiewicz 
---
 drivers/gpu/drm/rockchip/inno_hdmi.c | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c 
b/drivers/gpu/drm/rockchip/inno_hdmi.c
index f8ca98d294d0..d64b119c2649 100644
--- a/drivers/gpu/drm/rockchip/inno_hdmi.c
+++ b/drivers/gpu/drm/rockchip/inno_hdmi.c
@@ -59,7 +59,6 @@ struct inno_hdmi {
struct drm_encoder  encoder;
 
struct inno_hdmi_i2c *i2c;
-   struct i2c_adapter *ddc;
 
unsigned int tmds_rate;
 
@@ -552,10 +551,10 @@ static int inno_hdmi_connector_get_modes(struct 
drm_connector *connector)
struct edid *edid;
int ret = 0;
 
-   if (!hdmi->ddc)
+   if (!hdmi->connector.ddc)
return 0;
 
-   edid = drm_get_edid(connector, hdmi->ddc);
+   edid = drm_get_edid(connector, hdmi->connector.ddc);
if (edid) {
hdmi->hdmi_data.sink_is_hdmi = drm_detect_hdmi_monitor(edid);
hdmi->hdmi_data.sink_has_audio = drm_detect_monitor_audio(edid);
@@ -850,10 +849,10 @@ static int inno_hdmi_bind(struct device *dev, struct 
device *master,
 
inno_hdmi_reset(hdmi);
 
-   hdmi->ddc = inno_hdmi_i2c_adapter(hdmi);
-   if (IS_ERR(hdmi->ddc)) {
-   ret = PTR_ERR(hdmi->ddc);
-   hdmi->ddc = NULL;
+   hdmi->connector.ddc = inno_hdmi_i2c_adapter(hdmi);
+   if (IS_ERR(hdmi->connector.ddc)) {
+   ret = PTR_ERR(hdmi->connector.ddc);
+   hdmi->connector.ddc = NULL;
goto err_disable_clk;
}
 
@@ -886,7 +885,7 @@ static int inno_hdmi_bind(struct device *dev, struct device 
*master,
hdmi->connector.funcs->destroy(>connector);
hdmi->encoder.funcs->destroy(>encoder);
 err_put_adapter:
-   i2c_put_adapter(hdmi->ddc);
+   i2c_put_adapter(hdmi->connector.ddc);
 err_disable_clk:
clk_disable_unprepare(hdmi->pclk);
return ret;
@@ -900,7 +899,7 @@ static void inno_hdmi_unbind(struct device *dev, struct 
device *master,
hdmi->connector.funcs->destroy(>connector);
hdmi->encoder.funcs->destroy(>encoder);
 
-   i2c_put_adapter(hdmi->ddc);
+   i2c_put_adapter(hdmi->connector.ddc);
clk_disable_unprepare(hdmi->pclk);
 }
 
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH v4 03/23] drm: rockchip: Provide ddc symlink in rk3066_hdmi sysfs directory

2019-07-11 Thread Andrzej Pietrasiewicz
Use the ddc pointer provided by the generic connector.

Signed-off-by: Andrzej Pietrasiewicz 
---
 drivers/gpu/drm/rockchip/rk3066_hdmi.c | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rk3066_hdmi.c 
b/drivers/gpu/drm/rockchip/rk3066_hdmi.c
index 85fc5f01f761..1f3e630ecdab 100644
--- a/drivers/gpu/drm/rockchip/rk3066_hdmi.c
+++ b/drivers/gpu/drm/rockchip/rk3066_hdmi.c
@@ -49,7 +49,6 @@ struct rk3066_hdmi {
struct drm_encoder encoder;
 
struct rk3066_hdmi_i2c *i2c;
-   struct i2c_adapter *ddc;
 
unsigned int tmdsclk;
 
@@ -470,10 +469,10 @@ static int rk3066_hdmi_connector_get_modes(struct 
drm_connector *connector)
struct edid *edid;
int ret = 0;
 
-   if (!hdmi->ddc)
+   if (!connector->ddc)
return 0;
 
-   edid = drm_get_edid(connector, hdmi->ddc);
+   edid = drm_get_edid(connector, connector->ddc);
if (edid) {
hdmi->hdmi_data.sink_is_hdmi = drm_detect_hdmi_monitor(edid);
drm_connector_update_edid_property(connector, edid);
@@ -789,10 +788,10 @@ static int rk3066_hdmi_bind(struct device *dev, struct 
device *master,
/* internal hclk = hdmi_hclk / 25 */
hdmi_writeb(hdmi, HDMI_INTERNAL_CLK_DIVIDER, 25);
 
-   hdmi->ddc = rk3066_hdmi_i2c_adapter(hdmi);
-   if (IS_ERR(hdmi->ddc)) {
-   ret = PTR_ERR(hdmi->ddc);
-   hdmi->ddc = NULL;
+   hdmi->connector.ddc = rk3066_hdmi_i2c_adapter(hdmi);
+   if (IS_ERR(hdmi->connector.ddc)) {
+   ret = PTR_ERR(hdmi->connector.ddc);
+   hdmi->connector.ddc = NULL;
goto err_disable_hclk;
}
 
@@ -824,7 +823,7 @@ static int rk3066_hdmi_bind(struct device *dev, struct 
device *master,
hdmi->connector.funcs->destroy(>connector);
hdmi->encoder.funcs->destroy(>encoder);
 err_disable_i2c:
-   i2c_put_adapter(hdmi->ddc);
+   i2c_put_adapter(hdmi->connector.ddc);
 err_disable_hclk:
clk_disable_unprepare(hdmi->hclk);
 
@@ -839,7 +838,7 @@ static void rk3066_hdmi_unbind(struct device *dev, struct 
device *master,
hdmi->connector.funcs->destroy(>connector);
hdmi->encoder.funcs->destroy(>encoder);
 
-   i2c_put_adapter(hdmi->ddc);
+   i2c_put_adapter(hdmi->connector.ddc);
clk_disable_unprepare(hdmi->hclk);
 }
 
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH v4 02/23] drm/exynos: Provide ddc symlink in connector's sysfs

2019-07-11 Thread Andrzej Pietrasiewicz
Switch to using the ddc provided by the generic connector.

Signed-off-by: Andrzej Pietrasiewicz 
---
 drivers/gpu/drm/exynos/exynos_hdmi.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c 
b/drivers/gpu/drm/exynos/exynos_hdmi.c
index bc1565f1822a..b4332dae6ed5 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -125,7 +125,6 @@ struct hdmi_context {
void __iomem*regs;
void __iomem*regs_hdmiphy;
struct i2c_client   *hdmiphy_port;
-   struct i2c_adapter  *ddc_adpt;
struct gpio_desc*hpd_gpio;
int irq;
struct regmap   *pmureg;
@@ -871,10 +870,10 @@ static int hdmi_get_modes(struct drm_connector *connector)
struct edid *edid;
int ret;
 
-   if (!hdata->ddc_adpt)
+   if (!connector->ddc)
return -ENODEV;
 
-   edid = drm_get_edid(connector, hdata->ddc_adpt);
+   edid = drm_get_edid(connector, connector->ddc);
if (!edid)
return -ENODEV;
 
@@ -1892,7 +1891,7 @@ static int hdmi_get_ddc_adapter(struct hdmi_context 
*hdata)
return -EPROBE_DEFER;
}
 
-   hdata->ddc_adpt = adpt;
+   hdata->connector.ddc = adpt;
 
return 0;
 }
@@ -2044,7 +2043,7 @@ static int hdmi_probe(struct platform_device *pdev)
if (hdata->regs_hdmiphy)
iounmap(hdata->regs_hdmiphy);
 err_ddc:
-   put_device(>ddc_adpt->dev);
+   put_device(>connector.ddc->dev);
 
return ret;
 }
@@ -2071,7 +2070,7 @@ static int hdmi_remove(struct platform_device *pdev)
if (hdata->regs_hdmiphy)
iounmap(hdata->regs_hdmiphy);
 
-   put_device(>ddc_adpt->dev);
+   put_device(>connector.ddc->dev);
 
mutex_destroy(>mutex);
 
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH v4 00/23] Associate ddc adapters with connectors

2019-07-11 Thread Andrzej Pietrasiewicz
It is difficult for a user to know which of the i2c adapters is for which
drm connector. This series addresses this problem.

The idea is to have a symbolic link in connector's sysfs directory, e.g.:

ls -l /sys/class/drm/card0-HDMI-A-1/ddc
lrwxrwxrwx 1 root root 0 Jun 24 10:42 /sys/class/drm/card0-HDMI-A-1/ddc \
-> ../../../../soc/1388.i2c/i2c-2

The user then knows that their card0-HDMI-A-1 uses i2c-2 and can e.g. run
ddcutil:

ddcutil -b 2 getvcp 0x10
VCP code 0x10 (Brightness): current value =90, max 
value =   100

The first patch in the series adds struct i2c_adapter pointer to struct
drm_connector. If the field is used by a particular driver, then an
appropriate symbolic link is created by the generic code, which is also added
by this patch.

The next 22 patches is an example of how to convert a driver to this new scheme.

v1..v2:

- used fixed name "ddc" for the symbolic link in order to make it easy for
userspace to find the i2c adapter

v2..v3:

- converted as many drivers as possible.

v3..v4:

- added Reviewed-by for patch 01/23
- moved "ddc" field assignment to before drm_connector_init() is called
in msm, vc4, sti, mgag200, ast, amdgpu, radeon
- simplified the code in amdgpu and radeon at the expense of some lines
exceeding 80 characters as per Alex Deucher's suggestion
- added i915

TODO: nouveau, gma500, omapdrm, panel-simple - if applicable.
Other drivers are either already converted or don't mention neither
"ddc" nor "i2c_adapter".

Andrzej Pietrasiewicz (23):
  drm: Include ddc adapter pointer in struct drm_connector
  drm/exynos: Provide ddc symlink in connector's sysfs
  drm: rockchip: Provide ddc symlink in rk3066_hdmi sysfs directory
  drm: rockchip: Provide ddc symlink in inno_hdmi sysfs directory
  drm/msm/hdmi: Provide ddc symlink in hdmi connector sysfs directory
  drm/sun4i: hdmi: Provide ddc symlink in sun4i hdmi connector sysfs
directory
  drm/mediatek: Provide ddc symlink in hdmi connector sysfs directory
  drm/tegra: Provide ddc symlink in output connector sysfs directory
  drm/imx: imx-ldb: Provide ddc symlink in connector's sysfs
  drm/imx: imx-tve: Provide ddc symlink in connector's sysfs
  drm/vc4: Provide ddc symlink in connector sysfs directory
  drm: zte: Provide ddc symlink in hdmi connector sysfs directory
  drm: zte: Provide ddc symlink in vga connector sysfs directory
  drm/tilcdc: Provide ddc symlink in connector sysfs directory
  drm: sti: Provide ddc symlink in hdmi connector sysfs directory
  drm/mgag200: Provide ddc symlink in connector sysfs directory
  drm/ast: Provide ddc symlink in connector sysfs directory
  drm/bridge: dumb-vga-dac: Provide ddc symlink in connector sysfs
directory
  drm/bridge: dw-hdmi: Provide ddc symlink in connector sysfs directory
  drm/bridge: ti-tfp410: Provide ddc symlink in connector sysfs
directory
  drm/amdgpu: Provide ddc symlink in connector sysfs directory
  drm/radeon: Provide ddc symlink in connector sysfs directory
  drm/i915: Provide ddc symlink in hdmi connector sysfs directory

 .../gpu/drm/amd/amdgpu/amdgpu_connectors.c| 56 -
 drivers/gpu/drm/ast/ast_mode.c|  9 ++-
 drivers/gpu/drm/bridge/dumb-vga-dac.c | 19 +++--
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 40 +-
 drivers/gpu/drm/bridge/ti-tfp410.c| 19 +++--
 drivers/gpu/drm/drm_sysfs.c   |  7 ++
 drivers/gpu/drm/exynos/exynos_hdmi.c  | 11 ++-
 drivers/gpu/drm/i915/display/intel_hdmi.c |  5 +-
 drivers/gpu/drm/imx/imx-ldb.c | 13 ++-
 drivers/gpu/drm/imx/imx-tve.c |  8 +-
 drivers/gpu/drm/mediatek/mtk_hdmi.c   |  9 +--
 drivers/gpu/drm/mgag200/mgag200_mode.c|  9 ++-
 drivers/gpu/drm/msm/hdmi/hdmi_connector.c |  1 +
 drivers/gpu/drm/radeon/radeon_connectors.c| 80 ---
 drivers/gpu/drm/rockchip/inno_hdmi.c  | 17 ++--
 drivers/gpu/drm/rockchip/rk3066_hdmi.c| 17 ++--
 drivers/gpu/drm/sti/sti_hdmi.c|  1 +
 drivers/gpu/drm/sun4i/sun4i_hdmi.h|  1 -
 drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c| 14 ++--
 drivers/gpu/drm/tegra/drm.h   |  1 -
 drivers/gpu/drm/tegra/output.c| 12 +--
 drivers/gpu/drm/tegra/sor.c   |  6 +-
 drivers/gpu/drm/tilcdc/tilcdc_tfp410.c|  1 +
 drivers/gpu/drm/vc4/vc4_hdmi.c| 21 ++---
 drivers/gpu/drm/zte/zx_hdmi.c | 25 +++---
 drivers/gpu/drm/zte/zx_vga.c  | 25 +++---
 include/drm/drm_connector.h   | 11 +++
 27 files changed, 240 insertions(+), 198 deletions(-)

-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

RE: [PATCH 1/2] drm/amdgpu: switch to macro for psp bootloader command

2019-07-11 Thread Zhang, Hawking
I get the confirmation from PSP team that below command are deprecated.  I will 
drop them when push the patch
+   PSP_BL__NO_ECC  = 0x4,
+   PSP_BL__PARTIAL_ECC = 0x5,
+   PSP_BL__FULL_ECC= 0x6,

Regards,
Hawking
-Original Message-
From: amd-gfx  On Behalf Of Zhang, 
Hawking
Sent: 2019年7月11日 12:13
To: Alex Deucher 
Cc: Deucher, Alexander ; Clements, John 
; amd-gfx list ; Yuan, 
Xiaojie 
Subject: RE: [PATCH 1/2] drm/amdgpu: switch to macro for psp bootloader command

RE - Maybe this would be better in psp_gfx_if.h since it's sort of part of the 
firmware interface, but I guess it's not really part of the psp ring interface.

Yes, these cmds are not submitted to the psp ring and actually issued before 
the psp ring setup. They are not in the internal psp_gfx_if.h files, so I put 
them in general psp header.

Regards,
Hawking
-Original Message-
From: Alex Deucher 
Sent: 2019年7月11日 1:25
To: Zhang, Hawking 
Cc: amd-gfx list ; Yuan, Xiaojie 
; Clements, John ; Deucher, 
Alexander 
Subject: Re: [PATCH 1/2] drm/amdgpu: switch to macro for psp bootloader command

On Wed, Jul 10, 2019 at 11:59 AM Hawking Zhang  wrote:
>

Please add a patch description.

> Change-Id: Ief4c1e5ca01df0a028a784c0faf37544939733a3
> Signed-off-by: Hawking Zhang 
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 9 + 
> drivers/gpu/drm/amd/amdgpu/psp_v11_0.c  | 4 ++--
>  drivers/gpu/drm/amd/amdgpu/psp_v3_1.c   | 4 ++--
>  3 files changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
> index e28cf5e..8ddcec1 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
> @@ -42,6 +42,15 @@ struct psp_context;  struct psp_xgmi_node_info; 
> struct psp_xgmi_topology_info;
>
> +enum psp_bootloader_cmd {
> +   PSP_BL__LOAD_SYSDRV = 0x1,
> +   PSP_BL__LOAD_SOSDRV = 0x2,
> +   PSP_BL__NO_ECC  = 0x4,
> +   PSP_BL__PARTIAL_ECC = 0x5,
> +   PSP_BL__FULL_ECC= 0x6,
> +   PSP_BL__LOAD_KEY_DATABASE   = 0x8,
> +};
> +

Maybe this would be better in psp_gfx_if.h since it's sort of part of the 
firmware interface, but I guess it's not really part of the psp ring interface. 
 Either way, with the patch description added, the series is:
Reviewed-by: Alex Deucher 

>  enum psp_ring_type
>  {
> PSP_RING_TYPE__INVALID = 0,
> diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
> b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
> index 1b6c20c..e784091 100644
> --- a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
> @@ -212,7 +212,7 @@ static int psp_v11_0_bootloader_load_sysdrv(struct 
> psp_context *psp)
> /* Provide the sys driver to bootloader */
> WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_36,
>(uint32_t)(psp->fw_pri_mc_addr >> 20));
> -   psp_gfxdrv_command_reg = 1 << 16;
> +   psp_gfxdrv_command_reg = PSP_BL__LOAD_SYSDRV;
> WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_35,
>psp_gfxdrv_command_reg);
>
> @@ -253,7 +253,7 @@ static int psp_v11_0_bootloader_load_sos(struct 
> psp_context *psp)
> /* Provide the PSP secure OS to bootloader */
> WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_36,
>(uint32_t)(psp->fw_pri_mc_addr >> 20));
> -   psp_gfxdrv_command_reg = 2 << 16;
> +   psp_gfxdrv_command_reg = PSP_BL__LOAD_SOSDRV;
> WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_35,
>psp_gfxdrv_command_reg);
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c
> b/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c
> index 3f58277..ec3a056 100644
> --- a/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c
> +++ b/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c
> @@ -153,7 +153,7 @@ static int psp_v3_1_bootloader_load_sysdrv(struct 
> psp_context *psp)
> /* Provide the sys driver to bootloader */
> WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_36,
>(uint32_t)(psp->fw_pri_mc_addr >> 20));
> -   psp_gfxdrv_command_reg = 1 << 16;
> +   psp_gfxdrv_command_reg = PSP_BL__LOAD_SYSDRV;
> WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_35,
>psp_gfxdrv_command_reg);
>
> @@ -216,7 +216,7 @@ static int psp_v3_1_bootloader_load_sos(struct 
> psp_context *psp)
> /* Provide the PSP secure OS to bootloader */
> WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_36,
>(uint32_t)(psp->fw_pri_mc_addr >> 20));
> -   psp_gfxdrv_command_reg = 2 << 16;
> +   psp_gfxdrv_command_reg = PSP_BL__LOAD_SOSDRV;
> WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_35,
>psp_gfxdrv_command_reg);
>
> --
> 2.7.4
>
> ___
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Re: [PATCH 1/3] drm/amdgpu: Add flag for allocating memory for sensitive data

2019-07-11 Thread Michel Dänzer
On 2019-07-10 8:58 p.m., Kuehling, Felix wrote:
> On 2019-07-10 3:22 a.m., Michel Dänzer wrote:
>> On 2019-07-09 9:00 p.m., Kuehling, Felix wrote:
>>> On 2019-07-09 6:34 a.m., Michel Dänzer wrote:
 On 2019-07-09 7:32 a.m., Kuehling, Felix wrote:
> This memory allocation flag will be used to indicate BOs containing
> sensitive data that should not be leaked to other processes.
>
> Signed-off-by: Felix Kuehling 
> ---
>include/uapi/drm/amdgpu_drm.h | 4 
>1 file changed, 4 insertions(+)
>
> diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h
> index 61870478bc9c..58659c28c26e 100644
> --- a/include/uapi/drm/amdgpu_drm.h
> +++ b/include/uapi/drm/amdgpu_drm.h
> @@ -131,6 +131,10 @@ extern "C" {
> * for the second page onward should be set to NC.
> */
>#define AMDGPU_GEM_CREATE_MQD_GFX9 (1 << 8)
> +/* Flag that BO may contain sensitive data that must be cleared before
> + * releasing the memory
> + */
> +#define AMDGPU_GEM_CREATE_VRAM_SENSITIVE (1 << 9)
>
>struct drm_amdgpu_gem_create_in  {
>   /** the requested memory size */
>
 This flag essentially means "Please don't leak my BO contents".
 Similarly, AMDGPU_GEM_CREATE_VRAM_CLEARED essentially means "Please
 don't let me see previous memory contents".

 I'd argue that neither flag should really be needed; BO contents
 shouldn't be leaked by default.
>>> My conclusion from previous discussions was that CREATE_VRAM_CLEARED has
>>> no security implications. It's basically completely ineffective as a
>>> security measure.
>> Absolutely, which is why I argued against it when it was proposed.
>>
>>> It's more a convenience feature. Therefore I think it still has a place
>>> as that.
>> It'd be a no-op if memory was always cleared. :)
>>
>>
>>> I'd agree on principle that data shouldn't be leaked by default, but it
>>> has been the default for a long time. My impression was that graphics
>>> guys cared more about performance than security. So changing the default
>>> may be a hard sell. On the compute side we already took a big
>>> performance hit by clearing all our VRAM, so this change would be an
>>> improvement for us. Therefore I think it still makes sense to let the
>>> application choose.
>> What exactly could userspace be allowed to choose though? I can only
>> think of disabling the clearing of memory it allocates ("Please leak my
>> BO contents"), which seems of rather dubious value.
> 
> I'm not insisting to leave it to user mode. But I think it makes sense 
> to have the choice per BO. The GEM ioctl could set the flag by default 
> for all user mode allocations. But some kernel mode BOs may not need it. 
> E.g. firmware, page tables, etc.

Leaking page table contents sounds risky to me. There may be other cases
where it's really not needed, but it tends to be hard to predict how
leaked data could be exploited.


> There are other AMDGPU_GEM_CREATE_ flags that don't make sense for user 
> mode to choose. This just adds one more.

As a general note not specific to this patch, it would be better if such
flags weren't in the UAPI header (and maybe not named AMDGPU_GEM_*).


-- 
Earthling Michel Dänzer   |  https://www.amd.com
Libre software enthusiast | Mesa and X developer
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Re: [PATCH] drm/amdgpu/discovery: fix DCE_HWIP mapping error in hw_id_map array

2019-07-11 Thread Yin, Tianci (Rico)
Thanks Feifei and Xiaojie!

From: Xu, Feifei
Sent: Thursday, July 11, 2019 16:28
To: Yin, Tianci (Rico); amd-gfx@lists.freedesktop.org
Cc: Xiao, Jack; Yuan, Xiaojie; Yin, Tianci (Rico); Zhang, Hawking
Subject: RE: [PATCH] drm/amdgpu/discovery: fix DCE_HWIP mapping error in 
hw_id_map array

Reviewed-by: Feifei Xu 

Regards,
Feifei

-Original Message-
From: amd-gfx  On Behalf Of Tianci Yin
Sent: 2019年7月11日 16:01
To: amd-gfx@lists.freedesktop.org
Cc: Xiao, Jack ; Yuan, Xiaojie ; Yin, 
Tianci (Rico) ; Zhang, Hawking 
Subject: [PATCH] drm/amdgpu/discovery: fix DCE_HWIP mapping error in hw_id_map 
array

From: tiancyin 

ID of DCE_HWIP from vbios is DMU_HWID,
mismatch cause null pointer crash in navi10 modprobe.

Change-Id: I3be363cf5248de904b3bdae2f34d3bbe0bbbc07d
Signed-off-by: tiancyin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
index e049ae6..1481899 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
@@ -123,7 +123,7 @@ static int hw_id_map[MAX_HWIP] = {
 [UVD_HWIP]  = UVD_HWID,
 [VCE_HWIP]  = VCE_HWID,
 [DF_HWIP]   = DF_HWID,
-   [DCE_HWIP]  = DCEAZ_HWID,
+   [DCE_HWIP]  = DMU_HWID,
 [OSSSYS_HWIP]   = OSSSYS_HWID,
 [SMUIO_HWIP]= SMUIO_HWID,
 [PWR_HWIP]  = PWR_HWID,
--
2.7.4

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Re: [PATCH] drm/amdgpu/discovery: fix DCE_HWIP mapping error in hw_id_map array

2019-07-11 Thread Yuan, Xiaojie
Reviewed-by: Xiaojie Yuan 

BR,
Xiaojie


From: amd-gfx  on behalf of Tianci Yin 

Sent: Thursday, July 11, 2019 4:00 PM
To: amd-gfx@lists.freedesktop.org
Cc: Xiao, Jack; Yuan, Xiaojie; Yin, Tianci (Rico); Zhang, Hawking
Subject: [PATCH] drm/amdgpu/discovery: fix DCE_HWIP mapping error in hw_id_map 
array

From: tiancyin 

ID of DCE_HWIP from vbios is DMU_HWID,
mismatch cause null pointer crash in navi10 modprobe.

Change-Id: I3be363cf5248de904b3bdae2f34d3bbe0bbbc07d
Signed-off-by: tiancyin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
index e049ae6..1481899 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
@@ -123,7 +123,7 @@ static int hw_id_map[MAX_HWIP] = {
[UVD_HWIP]  = UVD_HWID,
[VCE_HWIP]  = VCE_HWID,
[DF_HWIP]   = DF_HWID,
-   [DCE_HWIP]  = DCEAZ_HWID,
+   [DCE_HWIP]  = DMU_HWID,
[OSSSYS_HWIP]   = OSSSYS_HWID,
[SMUIO_HWIP]= SMUIO_HWID,
[PWR_HWIP]  = PWR_HWID,
--
2.7.4

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

RE: [PATCH] drm/amdgpu/discovery: fix DCE_HWIP mapping error in hw_id_map array

2019-07-11 Thread Xu, Feifei
Reviewed-by: Feifei Xu 

Regards,
Feifei

-Original Message-
From: amd-gfx  On Behalf Of Tianci Yin
Sent: 2019年7月11日 16:01
To: amd-gfx@lists.freedesktop.org
Cc: Xiao, Jack ; Yuan, Xiaojie ; Yin, 
Tianci (Rico) ; Zhang, Hawking 
Subject: [PATCH] drm/amdgpu/discovery: fix DCE_HWIP mapping error in hw_id_map 
array

From: tiancyin 

ID of DCE_HWIP from vbios is DMU_HWID,
mismatch cause null pointer crash in navi10 modprobe.

Change-Id: I3be363cf5248de904b3bdae2f34d3bbe0bbbc07d
Signed-off-by: tiancyin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
index e049ae6..1481899 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
@@ -123,7 +123,7 @@ static int hw_id_map[MAX_HWIP] = {
[UVD_HWIP]  = UVD_HWID,
[VCE_HWIP]  = VCE_HWID,
[DF_HWIP]   = DF_HWID,
-   [DCE_HWIP]  = DCEAZ_HWID,
+   [DCE_HWIP]  = DMU_HWID,
[OSSSYS_HWIP]   = OSSSYS_HWID,
[SMUIO_HWIP]= SMUIO_HWID,
[PWR_HWIP]  = PWR_HWID,
-- 
2.7.4

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Re: [PATCH] drm/amd/powerplay: bug fix for sysfs

2019-07-11 Thread Wang, Kevin(Yang)
Reviewed-by: Kevin Wang 


Best Regards,
Kevin


From: amd-gfx  on behalf of Quan, Evan 

Sent: Thursday, July 11, 2019 4:14:11 PM
To: Feng, Kenneth; amd-gfx@lists.freedesktop.org
Cc: Feng, Kenneth
Subject: RE: [PATCH] drm/amd/powerplay: bug fix for sysfs

Reviewed-by: Evan Quan 

> -Original Message-
> From: amd-gfx  On Behalf Of
> Kenneth Feng
> Sent: Thursday, July 11, 2019 3:45 PM
> To: amd-gfx@lists.freedesktop.org
> Cc: Feng, Kenneth 
> Subject: [PATCH] drm/amd/powerplay: bug fix for sysfs
>
> when we set profile_peak to sysfs:power_dpm_force_performance_level,
> we gets the wrong socclk level and mclk level.this patch fix this issue.
>
> Signed-off-by: Kenneth Feng 
> ---
>  drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
> b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
> index 5ee6508..cd32b20 100644
> --- a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
> +++ b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
> @@ -1157,14 +1157,14 @@ static int navi10_get_profiling_clk_mask(struct
> smu_context *smu,
>ret = smu_get_dpm_level_count(smu, SMU_MCLK,
> _count);
>if (ret)
>return ret;
> - *sclk_mask = level_count - 1;
> + *mclk_mask = level_count - 1;
>}
>
>if(soc_mask) {
>ret = smu_get_dpm_level_count(smu, SMU_SOCCLK,
> _count);
>if (ret)
>return ret;
> - *sclk_mask = level_count - 1;
> + *soc_mask = level_count - 1;
>}
>}
>
> --
> 2.7.4
>
> ___
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

RE: [PATCH] drm/amd/powerplay: bug fix for sysfs

2019-07-11 Thread Quan, Evan
Reviewed-by: Evan Quan 

> -Original Message-
> From: amd-gfx  On Behalf Of
> Kenneth Feng
> Sent: Thursday, July 11, 2019 3:45 PM
> To: amd-gfx@lists.freedesktop.org
> Cc: Feng, Kenneth 
> Subject: [PATCH] drm/amd/powerplay: bug fix for sysfs
> 
> when we set profile_peak to sysfs:power_dpm_force_performance_level,
> we gets the wrong socclk level and mclk level.this patch fix this issue.
> 
> Signed-off-by: Kenneth Feng 
> ---
>  drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
> b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
> index 5ee6508..cd32b20 100644
> --- a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
> +++ b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
> @@ -1157,14 +1157,14 @@ static int navi10_get_profiling_clk_mask(struct
> smu_context *smu,
>   ret = smu_get_dpm_level_count(smu, SMU_MCLK,
> _count);
>   if (ret)
>   return ret;
> - *sclk_mask = level_count - 1;
> + *mclk_mask = level_count - 1;
>   }
> 
>   if(soc_mask) {
>   ret = smu_get_dpm_level_count(smu, SMU_SOCCLK,
> _count);
>   if (ret)
>   return ret;
> - *sclk_mask = level_count - 1;
> + *soc_mask = level_count - 1;
>   }
>   }
> 
> --
> 2.7.4
> 
> ___
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH] drm/amdgpu/discovery: fix DCE_HWIP mapping error in hw_id_map array

2019-07-11 Thread Tianci Yin
From: tiancyin 

ID of DCE_HWIP from vbios is DMU_HWID,
mismatch cause null pointer crash in navi10 modprobe.

Change-Id: I3be363cf5248de904b3bdae2f34d3bbe0bbbc07d
Signed-off-by: tiancyin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
index e049ae6..1481899 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
@@ -123,7 +123,7 @@ static int hw_id_map[MAX_HWIP] = {
[UVD_HWIP]  = UVD_HWID,
[VCE_HWIP]  = VCE_HWID,
[DF_HWIP]   = DF_HWID,
-   [DCE_HWIP]  = DCEAZ_HWID,
+   [DCE_HWIP]  = DMU_HWID,
[OSSSYS_HWIP]   = OSSSYS_HWID,
[SMUIO_HWIP]= SMUIO_HWID,
[PWR_HWIP]  = PWR_HWID,
-- 
2.7.4

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

RE: [PATCH] drm/amd/powerplay: bug fix for sysfs

2019-07-11 Thread Xu, Feifei
Reviewed-by: Feifei Xu 

-Original Message-
From: amd-gfx  On Behalf Of Kenneth Feng
Sent: Thursday, July 11, 2019 3:45 PM
To: amd-gfx@lists.freedesktop.org
Cc: Feng, Kenneth 
Subject: [PATCH] drm/amd/powerplay: bug fix for sysfs

when we set profile_peak to sysfs:power_dpm_force_performance_level,
we gets the wrong socclk level and mclk level.this patch fix this issue.

Signed-off-by: Kenneth Feng 
---
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c 
b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
index 5ee6508..cd32b20 100644
--- a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
@@ -1157,14 +1157,14 @@ static int navi10_get_profiling_clk_mask(struct 
smu_context *smu,
ret = smu_get_dpm_level_count(smu, SMU_MCLK, 
_count);
if (ret)
return ret;
-   *sclk_mask = level_count - 1;
+   *mclk_mask = level_count - 1;
}
 
if(soc_mask) {
ret = smu_get_dpm_level_count(smu, SMU_SOCCLK, 
_count);
if (ret)
return ret;
-   *sclk_mask = level_count - 1;
+   *soc_mask = level_count - 1;
}
}
 
-- 
2.7.4

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH] drm/amd/powerplay: bug fix for sysfs

2019-07-11 Thread Kenneth Feng
when we set profile_peak to sysfs:power_dpm_force_performance_level,
we gets the wrong socclk level and mclk level.this patch fix this issue.

Signed-off-by: Kenneth Feng 
---
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c 
b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
index 5ee6508..cd32b20 100644
--- a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
@@ -1157,14 +1157,14 @@ static int navi10_get_profiling_clk_mask(struct 
smu_context *smu,
ret = smu_get_dpm_level_count(smu, SMU_MCLK, 
_count);
if (ret)
return ret;
-   *sclk_mask = level_count - 1;
+   *mclk_mask = level_count - 1;
}
 
if(soc_mask) {
ret = smu_get_dpm_level_count(smu, SMU_SOCCLK, 
_count);
if (ret)
return ret;
-   *sclk_mask = level_count - 1;
+   *soc_mask = level_count - 1;
}
}
 
-- 
2.7.4

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Re: [PATCH 1/2] drm/amdgpu: switch to macro for psp bootloader command

2019-07-11 Thread Yuan, Xiaojie
Reviewed-by: Xiaojie Yuan 

BR,
Xiaojie


From: amd-gfx  on behalf of Hawking 
Zhang 
Sent: Wednesday, July 10, 2019 11:58 PM
To: amd-gfx@lists.freedesktop.org; Yuan, Xiaojie; Clements, John; Deucher, 
Alexander
Cc: Zhang, Hawking
Subject: [PATCH 1/2] drm/amdgpu: switch to macro for psp bootloader command

Change-Id: Ief4c1e5ca01df0a028a784c0faf37544939733a3
Signed-off-by: Hawking Zhang 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 9 +
 drivers/gpu/drm/amd/amdgpu/psp_v11_0.c  | 4 ++--
 drivers/gpu/drm/amd/amdgpu/psp_v3_1.c   | 4 ++--
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
index e28cf5e..8ddcec1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
@@ -42,6 +42,15 @@ struct psp_context;
 struct psp_xgmi_node_info;
 struct psp_xgmi_topology_info;

+enum psp_bootloader_cmd {
+   PSP_BL__LOAD_SYSDRV = 0x1,
+   PSP_BL__LOAD_SOSDRV = 0x2,
+   PSP_BL__NO_ECC  = 0x4,
+   PSP_BL__PARTIAL_ECC = 0x5,
+   PSP_BL__FULL_ECC= 0x6,
+   PSP_BL__LOAD_KEY_DATABASE   = 0x8,
+};
+
 enum psp_ring_type
 {
PSP_RING_TYPE__INVALID = 0,
diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c 
b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
index 1b6c20c..e784091 100644
--- a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
@@ -212,7 +212,7 @@ static int psp_v11_0_bootloader_load_sysdrv(struct 
psp_context *psp)
/* Provide the sys driver to bootloader */
WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_36,
   (uint32_t)(psp->fw_pri_mc_addr >> 20));
-   psp_gfxdrv_command_reg = 1 << 16;
+   psp_gfxdrv_command_reg = PSP_BL__LOAD_SYSDRV;
WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_35,
   psp_gfxdrv_command_reg);

@@ -253,7 +253,7 @@ static int psp_v11_0_bootloader_load_sos(struct psp_context 
*psp)
/* Provide the PSP secure OS to bootloader */
WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_36,
   (uint32_t)(psp->fw_pri_mc_addr >> 20));
-   psp_gfxdrv_command_reg = 2 << 16;
+   psp_gfxdrv_command_reg = PSP_BL__LOAD_SOSDRV;
WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_35,
   psp_gfxdrv_command_reg);

diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c 
b/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c
index 3f58277..ec3a056 100644
--- a/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c
+++ b/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c
@@ -153,7 +153,7 @@ static int psp_v3_1_bootloader_load_sysdrv(struct 
psp_context *psp)
/* Provide the sys driver to bootloader */
WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_36,
   (uint32_t)(psp->fw_pri_mc_addr >> 20));
-   psp_gfxdrv_command_reg = 1 << 16;
+   psp_gfxdrv_command_reg = PSP_BL__LOAD_SYSDRV;
WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_35,
   psp_gfxdrv_command_reg);

@@ -216,7 +216,7 @@ static int psp_v3_1_bootloader_load_sos(struct psp_context 
*psp)
/* Provide the PSP secure OS to bootloader */
WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_36,
   (uint32_t)(psp->fw_pri_mc_addr >> 20));
-   psp_gfxdrv_command_reg = 2 << 16;
+   psp_gfxdrv_command_reg = PSP_BL__LOAD_SOSDRV;
WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_35,
   psp_gfxdrv_command_reg);

--
2.7.4

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Re: [PATCH 2/2] drm/amdgpu: support key database loading for navi10

2019-07-11 Thread Yuan, Xiaojie
Reviewed-by: Xiaojie Yuan 

BR,
Xiaojie


From: amd-gfx  on behalf of Hawking 
Zhang 
Sent: Wednesday, July 10, 2019 11:58 PM
To: amd-gfx@lists.freedesktop.org; Yuan, Xiaojie; Clements, John; Deucher, 
Alexander
Cc: Zhang, Hawking
Subject: [PATCH 2/2] drm/amdgpu: support key database loading for navi10

Starting from navi10, driver should send Key Database Load command
to Bootloader before loading sys_drv and sos

Change-Id: Ib82d21840fb77da2217dd8b8f013177e61d72990
Signed-off-by: John Clements 
Signed-off-by: Hawking Zhang 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c   | 10 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h   |  5 
 drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c |  6 
 drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h |  3 ++
 drivers/gpu/drm/amd/amdgpu/psp_v11_0.c| 49 ++-
 5 files changed, 72 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index ed580e8b..3378cb38 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -770,6 +770,16 @@ static int psp_hw_start(struct psp_context *psp)
int ret;

if (!amdgpu_sriov_vf(adev) || !adev->in_gpu_reset) {
+
+   if (psp->kdb_start_addr &&
+   (psp->funcs->bootloader_load_kdb != NULL)) {
+   ret = psp_bootloader_load_kdb(psp);
+   if (ret) {
+   DRM_ERROR("PSP load kdb failed!\n");
+   return ret;
+   }
+   }
+
ret = psp_bootloader_load_sysdrv(psp);
if (ret) {
DRM_ERROR("PSP load sysdrv failed!\n");
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
index 8ddcec1..6f1746b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
@@ -82,6 +82,7 @@ enum psp_reg_prog_id {
 struct psp_funcs
 {
int (*init_microcode)(struct psp_context *psp);
+   int (*bootloader_load_kdb)(struct psp_context *psp);
int (*bootloader_load_sysdrv)(struct psp_context *psp);
int (*bootloader_load_sos)(struct psp_context *psp);
int (*ring_init)(struct psp_context *psp, enum psp_ring_type ring_type);
@@ -165,9 +166,11 @@ struct psp_context
uint32_tsys_bin_size;
uint32_tsos_bin_size;
uint32_ttoc_bin_size;
+   uint32_tkdb_bin_size;
uint8_t *sys_start_addr;
uint8_t *sos_start_addr;
uint8_t *toc_start_addr;
+   uint8_t *kdb_start_addr;

/* tmr buffer */
struct amdgpu_bo*tmr_bo;
@@ -229,6 +232,8 @@ struct amdgpu_psp_funcs {
(psp)->funcs->compare_sram_data((psp), (ucode), (type))
 #define psp_init_microcode(psp) \
((psp)->funcs->init_microcode ? 
(psp)->funcs->init_microcode((psp)) : 0)
+#define psp_bootloader_load_kdb(psp) \
+   ((psp)->funcs->bootloader_load_kdb ? 
(psp)->funcs->bootloader_load_kdb((psp)) : 0)
 #define psp_bootloader_load_sysdrv(psp) \
((psp)->funcs->bootloader_load_sysdrv ? 
(psp)->funcs->bootloader_load_sysdrv((psp)) : 0)
 #define psp_bootloader_load_sos(psp) \
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
index bf7e8ba..2042b60 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
@@ -262,6 +262,12 @@ void amdgpu_ucode_print_psp_hdr(const struct 
common_firmware_header *hdr)
  le32_to_cpu(psp_hdr_v1_1->toc_offset_bytes));
DRM_DEBUG("toc_size_bytes: %u\n",
  le32_to_cpu(psp_hdr_v1_1->toc_size_bytes));
+   DRM_DEBUG("kdb_header_version: %u\n",
+ 
le32_to_cpu(psp_hdr_v1_1->kdb_header_version));
+   DRM_DEBUG("kdb_offset_bytes: %u\n",
+ le32_to_cpu(psp_hdr_v1_1->kdb_offset_bytes));
+   DRM_DEBUG("kdb_size_bytes: %u\n",
+ le32_to_cpu(psp_hdr_v1_1->kdb_size_bytes));
}
} else {
DRM_ERROR("Unknown PSP ucode version: %u.%u\n",
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h
index f4694445..c1fb6dc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h
@@ -85,6 +85,9 @@ struct psp_firmware_header_v1_1 {
uint32_t toc_header_version;
uint32_t toc_offset_bytes;
uint32_t toc_size_bytes;
+   uint32_t