[linux-next:master] BUILD SUCCESS WITH WARNING e922ba281a8d84f640d8c8e18a385d032c19e185

2023-05-12 Thread kernel test robot
tree/branch: 
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
branch HEAD: e922ba281a8d84f640d8c8e18a385d032c19e185  Add linux-next specific 
files for 20230512

Warning reports:

https://lore.kernel.org/oe-kbuild-all/202305130809.sjnm01fl-...@intel.com

Warning: (recently discovered and may have been fixed)

drivers/base/regmap/regcache-maple.c:113:23: warning: 'lower_index' is used 
uninitialized [-Wuninitialized]
drivers/base/regmap/regcache-maple.c:113:36: warning: 'lower_last' is used 
uninitialized [-Wuninitialized]
drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:6396:21: warning: 
variable 'count' set but not used [-Wunused-but-set-variable]
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c:499:13: warning: variable 'j' set but 
not used [-Wunused-but-set-variable]
lib/maple_tree.c:4707:7: warning: no previous prototype for 'mas_next_slot' 
[-Wmissing-prototypes]

Unverified Warning (likely false positive, please contact us if interested):

drivers/crypto/intel/qat/qat_common/adf_cfg.c:262 adf_cfg_add_key_value_param() 
warn: argument 4 to %lx specifier is cast from pointer
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c:648:3-9: preceding lock on line 640
drivers/gpu/drm/i915/display/intel_psr.c:2999:0-23: WARNING: 
i915_edp_psr_debug_fops should be defined with DEFINE_DEBUGFS_ATTRIBUTE

Warning ids grouped by kconfigs:

gcc_recent_errors
|-- alpha-allyesconfig
|   |-- 
drivers-gpu-drm-amd-amdgpu-..-display-amdgpu_dm-amdgpu_dm.c:warning:variable-count-set-but-not-used
|   `-- 
drivers-gpu-drm-amd-amdgpu-amdgpu_gfx.c:warning:variable-j-set-but-not-used
|-- alpha-randconfig-r013-20230511
|   |-- 
drivers-gpu-drm-amd-amdgpu-..-display-amdgpu_dm-amdgpu_dm.c:warning:variable-count-set-but-not-used
|   `-- 
drivers-gpu-drm-amd-amdgpu-amdgpu_gfx.c:warning:variable-j-set-but-not-used
|-- alpha-randconfig-s043-20230510
|   |-- 
drivers-gpu-drm-amd-amdgpu-..-display-amdgpu_dm-amdgpu_dm.c:warning:variable-count-set-but-not-used
|   `-- 
drivers-gpu-drm-amd-amdgpu-amdgpu_gfx.c:warning:variable-j-set-but-not-used
|-- arc-allyesconfig
|   |-- 
drivers-base-regmap-regcache-maple.c:warning:lower_index-is-used-uninitialized
|   |-- 
drivers-base-regmap-regcache-maple.c:warning:lower_last-is-used-uninitialized
|   |-- 
drivers-gpu-drm-amd-amdgpu-..-display-amdgpu_dm-amdgpu_dm.c:warning:variable-count-set-but-not-used
|   `-- 
drivers-gpu-drm-amd-amdgpu-amdgpu_gfx.c:warning:variable-j-set-but-not-used
|-- arc-randconfig-r011-20230509
|   `-- 
drivers-gpu-drm-amd-amdgpu-amdgpu_gfx.c:warning:variable-j-set-but-not-used
|-- arc-randconfig-r011-20230511
|   |-- 
drivers-base-regmap-regcache-maple.c:warning:lower_index-is-used-uninitialized
|   `-- 
drivers-base-regmap-regcache-maple.c:warning:lower_last-is-used-uninitialized
|-- arc-randconfig-r043-20230511
|   |-- 
drivers-base-regmap-regcache-maple.c:warning:lower_index-is-used-uninitialized
|   |-- 
drivers-base-regmap-regcache-maple.c:warning:lower_last-is-used-uninitialized
|   `-- 
drivers-gpu-drm-amd-amdgpu-amdgpu_gfx.c:warning:variable-j-set-but-not-used
|-- arm-allmodconfig
|   |-- 
drivers-gpu-drm-amd-amdgpu-..-display-amdgpu_dm-amdgpu_dm.c:warning:variable-count-set-but-not-used
|   `-- 
drivers-gpu-drm-amd-amdgpu-amdgpu_gfx.c:warning:variable-j-set-but-not-used
|-- arm-allyesconfig
|   |-- 
drivers-gpu-drm-amd-amdgpu-..-display-amdgpu_dm-amdgpu_dm.c:warning:variable-count-set-but-not-used
|   `-- 
drivers-gpu-drm-amd-amdgpu-amdgpu_gfx.c:warning:variable-j-set-but-not-used
|-- arm64-allyesconfig
|   |-- 
drivers-gpu-drm-amd-amdgpu-..-display-amdgpu_dm-amdgpu_dm.c:warning:variable-count-set-but-not-used
|   `-- 
drivers-gpu-drm-amd-amdgpu-amdgpu_gfx.c:warning:variable-j-set-but-not-used
|-- arm64-randconfig-c004-20230509
|   |-- drivers-gpu-drm-amd-amdgpu-amdgpu_gfx.c:preceding-lock-on-line
|   `-- 
drivers-gpu-drm-amd-amdgpu-amdgpu_gfx.c:warning:variable-j-set-but-not-used
|-- csky-randconfig-s041-20230510
|   `-- 
drivers-gpu-drm-amd-amdgpu-amdgpu_gfx.c:warning:variable-j-set-but-not-used
|-- i386-allyesconfig
|   |-- 
drivers-gpu-drm-amd-amdgpu-..-display-amdgpu_dm-amdgpu_dm.c:warning:variable-count-set-but-not-used
|   `-- 
drivers-gpu-drm-amd-amdgpu-amdgpu_gfx.c:warning:variable-j-set-but-not-used
|-- i386-randconfig-m021
|   `-- 
drivers-crypto-intel-qat-qat_common-adf_cfg.c-adf_cfg_add_key_value_param()-warn:argument-to-lx-specifier-is-cast-from-pointer
|-- ia64-allmodconfig
|   |-- 
drivers-gpu-drm-amd-amdgpu-..-display-amdgpu_dm-amdgpu_dm.c:warning:variable-count-set-but-not-used
|   `-- 
drivers-gpu-drm-amd-amdgpu-amdgpu_gfx.c:warning:variable-j-set-but-not-used
|-- ia64-randconfig-r006-20230511
|   |-- 
drivers-gpu-drm-amd-amdgpu-..-display-amdgpu_dm-amdgpu_dm.c:warning:variable-count-set-but-not-used
|   `-- 
drivers-gpu-drm-amd-amdgpu-amdgpu_gfx.c:warning:variable-j-set-but-not-used
|-- loongarch-allmodconfig
|   |-- 
drivers-gpu-drm-amd-amdgpu-..-display-amdgpu_dm-amdgpu_dm.c:warning:variable-count-set-but-not-used

[PATCH 10/10] drm/amdgpu: initialize RAS for gfx_v9_4_3

2023-05-12 Thread Alex Deucher
From: Tao Zhou 

Register GFX RAS functions and initialize GFX RAS.

v2: remove xcp operations.
v3: reuse the return value of gfx_ras_sw_init.

Signed-off-by: Tao Zhou 
Reviewed-by: Hawking Zhang 
Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 18 +-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
index 5bd2f40a817e..e5cfb3adb3b3 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
@@ -47,6 +47,8 @@ MODULE_FIRMWARE("amdgpu/gc_9_4_3_rlc.bin");
 #define GFX9_MEC_HPD_SIZE 4096
 #define RLCG_UCODE_LOADING_START_ADDRESS 0x2000L
 
+struct amdgpu_gfx_ras gfx_v9_4_3_ras;
+
 static void gfx_v9_4_3_set_ring_funcs(struct amdgpu_device *adev);
 static void gfx_v9_4_3_set_irq_funcs(struct amdgpu_device *adev);
 static void gfx_v9_4_3_set_gds_init(struct amdgpu_device *adev);
@@ -659,6 +661,7 @@ static int gfx_v9_4_3_gpu_early_init(struct amdgpu_device 
*adev)
u32 gb_addr_config;
 
adev->gfx.funcs = _v9_4_3_gfx_funcs;
+   adev->gfx.ras = _v9_4_3_ras;
 
switch (adev->ip_versions[GC_HWIP][0]) {
case IP_VERSION(9, 4, 3):
@@ -845,7 +848,7 @@ static int gfx_v9_4_3_sw_init(void *handle)
if (r)
return r;
 
-   return 0;
+   return amdgpu_gfx_ras_sw_init(adev);
 }
 
 static int gfx_v9_4_3_sw_fini(void *handle)
@@ -4342,3 +4345,16 @@ struct amdgpu_xcp_ip_funcs gfx_v9_4_3_xcp_funcs = {
.suspend = _v9_4_3_xcp_suspend,
.resume = _v9_4_3_xcp_resume
 };
+
+struct amdgpu_ras_block_hw_ops  gfx_v9_4_3_ras_ops = {
+   .query_ras_error_count = _v9_4_3_query_ras_error_count,
+   .reset_ras_error_count = _v9_4_3_reset_ras_error_count,
+   .query_ras_error_status = _v9_4_3_query_ras_error_status,
+   .reset_ras_error_status = _v9_4_3_reset_ras_error_status,
+};
+
+struct amdgpu_gfx_ras gfx_v9_4_3_ras = {
+   .ras_block = {
+   .hw_ops = _v9_4_3_ras_ops,
+   },
+};
-- 
2.40.1



[PATCH 07/10] drm/amdgpu: add RAS error count query for gfx_v9_4_3

2023-05-12 Thread Alex Deucher
From: Tao Zhou 

Query GFX RAS ce/ue count.

Signed-off-by: Tao Zhou 
Reviewed-by: Hawking Zhang 
Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 56 +
 1 file changed, 56 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
index 188b4d9a2cbb..bfd041ba51d6 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
@@ -3724,6 +3724,55 @@ static const struct soc15_reg_entry 
gfx_v9_4_3_ea_err_status_regs = {
SOC15_REG_ENTRY(GC, 0, regGCEA_ERR_STATUS), 0, 1, 16
 };
 
+static void gfx_v9_4_3_inst_query_ras_err_count(struct amdgpu_device *adev,
+   void *ras_error_status, int xcc_id)
+{
+   struct ras_err_data *err_data = (struct ras_err_data *)ras_error_status;
+   unsigned long ce_count = 0, ue_count = 0;
+   uint32_t i, j, k;
+
+   mutex_lock(>grbm_idx_mutex);
+
+   for (i = 0; i < ARRAY_SIZE(gfx_v9_4_3_ce_reg_list); i++) {
+   for (j = 0; j < gfx_v9_4_3_ce_reg_list[i].se_num; j++) {
+   for (k = 0; k < 
gfx_v9_4_3_ce_reg_list[i].reg_entry.reg_inst; k++) {
+   /* no need to select if instance number is 1 */
+   if (gfx_v9_4_3_ce_reg_list[i].se_num > 1 ||
+   
gfx_v9_4_3_ce_reg_list[i].reg_entry.reg_inst > 1)
+   gfx_v9_4_3_xcc_select_se_sh(adev, j, 0, 
k, xcc_id);
+
+   amdgpu_ras_inst_query_ras_error_count(adev,
+   &(gfx_v9_4_3_ce_reg_list[i].reg_entry),
+   1,
+   
gfx_v9_4_3_ras_mem_list_array[gfx_v9_4_3_ce_reg_list[i].mem_id_type].mem_id_ent,
+   
gfx_v9_4_3_ras_mem_list_array[gfx_v9_4_3_ce_reg_list[i].mem_id_type].size,
+   GET_INST(GC, xcc_id),
+   AMDGPU_RAS_ERROR__SINGLE_CORRECTABLE,
+   _count);
+
+   amdgpu_ras_inst_query_ras_error_count(adev,
+   &(gfx_v9_4_3_ue_reg_list[i].reg_entry),
+   1,
+   
gfx_v9_4_3_ras_mem_list_array[gfx_v9_4_3_ue_reg_list[i].mem_id_type].mem_id_ent,
+   
gfx_v9_4_3_ras_mem_list_array[gfx_v9_4_3_ue_reg_list[i].mem_id_type].size,
+   GET_INST(GC, xcc_id),
+   AMDGPU_RAS_ERROR__MULTI_UNCORRECTABLE,
+   _count);
+   }
+   }
+   }
+
+   gfx_v9_4_3_xcc_select_se_sh(adev, 0x, 0x, 0x,
+   xcc_id);
+   mutex_unlock(>grbm_idx_mutex);
+
+   /* the caller should make sure initialize value of
+* err_data->ue_count and err_data->ce_count
+*/
+   err_data->ce_count += ce_count;
+   err_data->ue_count += ue_count;
+}
+
 static void gfx_v9_4_3_inst_query_ea_err_status(struct amdgpu_device *adev,
int xcc_id)
 {
@@ -3826,6 +3875,13 @@ static void gfx_v9_4_3_inst_reset_ras_err_status(struct 
amdgpu_device *adev,
gfx_v9_4_3_inst_reset_ea_err_status(adev, xcc_id);
 }
 
+static void gfx_v9_4_3_query_ras_error_count(struct amdgpu_device *adev,
+   void *ras_error_status)
+{
+   amdgpu_gfx_ras_error_func(adev, ras_error_status,
+   gfx_v9_4_3_inst_query_ras_err_count);
+}
+
 static void gfx_v9_4_3_query_ras_error_status(struct amdgpu_device *adev)
 {
amdgpu_gfx_ras_error_func(adev, NULL, 
gfx_v9_4_3_inst_query_ras_err_status);
-- 
2.40.1



[PATCH 09/10] drm/amdgpu: add sq timeout status functions for gfx_v9_4_3

2023-05-12 Thread Alex Deucher
From: Tao Zhou 

Query and reset sq timeout status.

v2: change instance from 0 to xcc_id for register access.

Signed-off-by: Tao Zhou 
Reviewed-by: Hawking Zhang 
Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 98 +
 1 file changed, 98 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
index ac5270d5eff4..5bd2f40a817e 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
@@ -3865,11 +3865,87 @@ static void gfx_v9_4_3_inst_query_utc_err_status(struct 
amdgpu_device *adev,
}
 }
 
+static void gfx_v9_4_3_log_cu_timeout_status(struct amdgpu_device *adev,
+   uint32_t status, int xcc_id)
+{
+   struct amdgpu_cu_info *cu_info = >gfx.cu_info;
+   uint32_t i, simd, wave;
+   uint32_t wave_status;
+   uint32_t wave_pc_lo, wave_pc_hi;
+   uint32_t wave_exec_lo, wave_exec_hi;
+   uint32_t wave_inst_dw0, wave_inst_dw1;
+   uint32_t wave_ib_sts;
+
+   for (i = 0; i < 32; i++) {
+   if (!((i << 1) & status))
+   continue;
+
+   simd = i / cu_info->max_waves_per_simd;
+   wave = i % cu_info->max_waves_per_simd;
+
+   wave_status = wave_read_ind(adev, xcc_id, simd, wave, 
ixSQ_WAVE_STATUS);
+   wave_pc_lo = wave_read_ind(adev, xcc_id, simd, wave, 
ixSQ_WAVE_PC_LO);
+   wave_pc_hi = wave_read_ind(adev, xcc_id, simd, wave, 
ixSQ_WAVE_PC_HI);
+   wave_exec_lo =
+   wave_read_ind(adev, xcc_id, simd, wave, 
ixSQ_WAVE_EXEC_LO);
+   wave_exec_hi =
+   wave_read_ind(adev, xcc_id, simd, wave, 
ixSQ_WAVE_EXEC_HI);
+   wave_inst_dw0 =
+   wave_read_ind(adev, xcc_id, simd, wave, 
ixSQ_WAVE_INST_DW0);
+   wave_inst_dw1 =
+   wave_read_ind(adev, xcc_id, simd, wave, 
ixSQ_WAVE_INST_DW1);
+   wave_ib_sts = wave_read_ind(adev, xcc_id, simd, wave, 
ixSQ_WAVE_IB_STS);
+
+   dev_info(
+   adev->dev,
+   "\t SIMD %d, Wave %d: status 0x%x, pc 0x%llx, exec 
0x%llx, inst 0x%llx, ib_sts 0x%x\n",
+   simd, wave, wave_status,
+   ((uint64_t)wave_pc_hi << 32 | wave_pc_lo),
+   ((uint64_t)wave_exec_hi << 32 | wave_exec_lo),
+   ((uint64_t)wave_inst_dw1 << 32 | wave_inst_dw0),
+   wave_ib_sts);
+   }
+}
+
+static void gfx_v9_4_3_inst_query_sq_timeout_status(struct amdgpu_device *adev,
+   int xcc_id)
+{
+   uint32_t se_idx, sh_idx, cu_idx;
+   uint32_t status;
+
+   mutex_lock(>grbm_idx_mutex);
+   for (se_idx = 0; se_idx < adev->gfx.config.max_shader_engines; 
se_idx++) {
+   for (sh_idx = 0; sh_idx < adev->gfx.config.max_sh_per_se; 
sh_idx++) {
+   for (cu_idx = 0; cu_idx < 
adev->gfx.config.max_cu_per_sh; cu_idx++) {
+   gfx_v9_4_3_xcc_select_se_sh(adev, se_idx, 
sh_idx,
+   cu_idx, xcc_id);
+   status = RREG32_SOC15(GC, GET_INST(GC, xcc_id),
+ regSQ_TIMEOUT_STATUS);
+   if (status != 0) {
+   dev_info(
+   adev->dev,
+   "GFX Watchdog Timeout: SE %d, 
SH %d, CU %d\n",
+   se_idx, sh_idx, cu_idx);
+   gfx_v9_4_3_log_cu_timeout_status(
+   adev, status, xcc_id);
+   }
+   /* clear old status */
+   WREG32_SOC15(GC, GET_INST(GC, xcc_id),
+   regSQ_TIMEOUT_STATUS, 0);
+   }
+   }
+   }
+   gfx_v9_4_3_xcc_select_se_sh(adev, 0x, 0x, 0x,
+   xcc_id);
+   mutex_unlock(>grbm_idx_mutex);
+}
+
 static void gfx_v9_4_3_inst_query_ras_err_status(struct amdgpu_device *adev,
void *ras_error_status, int xcc_id)
 {
gfx_v9_4_3_inst_query_ea_err_status(adev, xcc_id);
gfx_v9_4_3_inst_query_utc_err_status(adev, xcc_id);
+   gfx_v9_4_3_inst_query_sq_timeout_status(adev, xcc_id);
 }
 
 static void gfx_v9_4_3_inst_reset_utc_err_status(struct amdgpu_device *adev,
@@ -3901,11 +3977,33 @@ static void gfx_v9_4_3_inst_reset_ea_err_status(struct 
amdgpu_device *adev,
mutex_unlock(>grbm_idx_mutex);
 }
 
+static void gfx_v9_4_3_inst_reset_sq_timeout_status(struct amdgpu_device 

[PATCH 08/10] drm/amdgpu: add RAS error count reset for gfx_v9_4_3

2023-05-12 Thread Alex Deucher
From: Tao Zhou 

Add GFX RAS error count reset function.

v2: remove xcp operation.
only select_se_sh when instance number is more than 1.
v3: add check for se_num before select_se_sh.
change instance from 0 to xcc_id for register access.

Signed-off-by: Tao Zhou 
Reviewed-by: Hawking Zhang 
Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 38 +
 1 file changed, 38 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
index bfd041ba51d6..ac5270d5eff4 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
@@ -3773,6 +3773,39 @@ static void gfx_v9_4_3_inst_query_ras_err_count(struct 
amdgpu_device *adev,
err_data->ue_count += ue_count;
 }
 
+static void gfx_v9_4_3_inst_reset_ras_err_count(struct amdgpu_device *adev,
+   void *ras_error_status, int xcc_id)
+{
+   uint32_t i, j, k;
+
+   mutex_lock(>grbm_idx_mutex);
+
+   for (i = 0; i < ARRAY_SIZE(gfx_v9_4_3_ce_reg_list); i++) {
+   for (j = 0; j < gfx_v9_4_3_ce_reg_list[i].se_num; j++) {
+   for (k = 0; k < 
gfx_v9_4_3_ce_reg_list[i].reg_entry.reg_inst; k++) {
+   /* no need to select if instance number is 1 */
+   if (gfx_v9_4_3_ce_reg_list[i].se_num > 1 ||
+   
gfx_v9_4_3_ce_reg_list[i].reg_entry.reg_inst > 1)
+   gfx_v9_4_3_xcc_select_se_sh(adev, j, 0, 
k, xcc_id);
+
+   amdgpu_ras_inst_reset_ras_error_count(adev,
+   &(gfx_v9_4_3_ce_reg_list[i].reg_entry),
+   1,
+   GET_INST(GC, xcc_id));
+
+   amdgpu_ras_inst_reset_ras_error_count(adev,
+   &(gfx_v9_4_3_ue_reg_list[i].reg_entry),
+   1,
+   GET_INST(GC, xcc_id));
+   }
+   }
+   }
+
+   gfx_v9_4_3_xcc_select_se_sh(adev, 0x, 0x, 0x,
+   xcc_id);
+   mutex_unlock(>grbm_idx_mutex);
+}
+
 static void gfx_v9_4_3_inst_query_ea_err_status(struct amdgpu_device *adev,
int xcc_id)
 {
@@ -3882,6 +3915,11 @@ static void gfx_v9_4_3_query_ras_error_count(struct 
amdgpu_device *adev,
gfx_v9_4_3_inst_query_ras_err_count);
 }
 
+static void gfx_v9_4_3_reset_ras_error_count(struct amdgpu_device *adev)
+{
+   amdgpu_gfx_ras_error_func(adev, NULL, 
gfx_v9_4_3_inst_reset_ras_err_count);
+}
+
 static void gfx_v9_4_3_query_ras_error_status(struct amdgpu_device *adev)
 {
amdgpu_gfx_ras_error_func(adev, NULL, 
gfx_v9_4_3_inst_query_ras_err_status);
-- 
2.40.1



[PATCH 06/10] drm/amdgpu: add RAS error count definitions for gfx_v9_4_3

2023-05-12 Thread Alex Deucher
From: Tao Zhou 

Prepare for the query of GFX RAS ce/ue count.

v2: remove xcp operation.
only select_se_sh when instance number is more than 1.
v3: add more CE/UE registsers to query list.
add check for se_num before select_se_sh.
change instance from 0 to xcc_id for register access.
v4: move gfx memory id definitions to gfx_v9_4_3.
v5: create a dedicated patch for adding error count query function.

Signed-off-by: Tao Zhou 
Reviewed-by: Hawking Zhang 
Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 740 
 1 file changed, 740 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
index e6069d081f71..188b4d9a2cbb 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
@@ -2980,6 +2980,746 @@ static void gfx_v9_4_3_emit_wave_limit(struct 
amdgpu_ring *ring, bool enable)
}
 }
 
+enum amdgpu_gfx_cp_ras_mem_id {
+   AMDGPU_GFX_CP_MEM1 = 1,
+   AMDGPU_GFX_CP_MEM2,
+   AMDGPU_GFX_CP_MEM3,
+   AMDGPU_GFX_CP_MEM4,
+   AMDGPU_GFX_CP_MEM5,
+};
+
+enum amdgpu_gfx_gcea_ras_mem_id {
+   AMDGPU_GFX_GCEA_IOWR_CMDMEM = 4,
+   AMDGPU_GFX_GCEA_IORD_CMDMEM,
+   AMDGPU_GFX_GCEA_GMIWR_CMDMEM,
+   AMDGPU_GFX_GCEA_GMIRD_CMDMEM,
+   AMDGPU_GFX_GCEA_DRAMWR_CMDMEM,
+   AMDGPU_GFX_GCEA_DRAMRD_CMDMEM,
+   AMDGPU_GFX_GCEA_MAM_DMEM0,
+   AMDGPU_GFX_GCEA_MAM_DMEM1,
+   AMDGPU_GFX_GCEA_MAM_DMEM2,
+   AMDGPU_GFX_GCEA_MAM_DMEM3,
+   AMDGPU_GFX_GCEA_MAM_AMEM0,
+   AMDGPU_GFX_GCEA_MAM_AMEM1,
+   AMDGPU_GFX_GCEA_MAM_AMEM2,
+   AMDGPU_GFX_GCEA_MAM_AMEM3,
+   AMDGPU_GFX_GCEA_MAM_AFLUSH_BUFFER,
+   AMDGPU_GFX_GCEA_WRET_TAGMEM,
+   AMDGPU_GFX_GCEA_RRET_TAGMEM,
+   AMDGPU_GFX_GCEA_IOWR_DATAMEM,
+   AMDGPU_GFX_GCEA_GMIWR_DATAMEM,
+   AMDGPU_GFX_GCEA_DRAM_DATAMEM,
+};
+
+enum amdgpu_gfx_gc_cane_ras_mem_id {
+   AMDGPU_GFX_GC_CANE_MEM0 = 0,
+};
+
+enum amdgpu_gfx_gcutcl2_ras_mem_id {
+   AMDGPU_GFX_GCUTCL2_MEM2P512X95 = 160,
+};
+
+enum amdgpu_gfx_gds_ras_mem_id {
+   AMDGPU_GFX_GDS_MEM0 = 0,
+};
+
+enum amdgpu_gfx_lds_ras_mem_id {
+   AMDGPU_GFX_LDS_BANK0 = 0,
+   AMDGPU_GFX_LDS_BANK1,
+   AMDGPU_GFX_LDS_BANK2,
+   AMDGPU_GFX_LDS_BANK3,
+   AMDGPU_GFX_LDS_BANK4,
+   AMDGPU_GFX_LDS_BANK5,
+   AMDGPU_GFX_LDS_BANK6,
+   AMDGPU_GFX_LDS_BANK7,
+   AMDGPU_GFX_LDS_BANK8,
+   AMDGPU_GFX_LDS_BANK9,
+   AMDGPU_GFX_LDS_BANK10,
+   AMDGPU_GFX_LDS_BANK11,
+   AMDGPU_GFX_LDS_BANK12,
+   AMDGPU_GFX_LDS_BANK13,
+   AMDGPU_GFX_LDS_BANK14,
+   AMDGPU_GFX_LDS_BANK15,
+   AMDGPU_GFX_LDS_BANK16,
+   AMDGPU_GFX_LDS_BANK17,
+   AMDGPU_GFX_LDS_BANK18,
+   AMDGPU_GFX_LDS_BANK19,
+   AMDGPU_GFX_LDS_BANK20,
+   AMDGPU_GFX_LDS_BANK21,
+   AMDGPU_GFX_LDS_BANK22,
+   AMDGPU_GFX_LDS_BANK23,
+   AMDGPU_GFX_LDS_BANK24,
+   AMDGPU_GFX_LDS_BANK25,
+   AMDGPU_GFX_LDS_BANK26,
+   AMDGPU_GFX_LDS_BANK27,
+   AMDGPU_GFX_LDS_BANK28,
+   AMDGPU_GFX_LDS_BANK29,
+   AMDGPU_GFX_LDS_BANK30,
+   AMDGPU_GFX_LDS_BANK31,
+   AMDGPU_GFX_LDS_SP_BUFFER_A,
+   AMDGPU_GFX_LDS_SP_BUFFER_B,
+};
+
+enum amdgpu_gfx_rlc_ras_mem_id {
+   AMDGPU_GFX_RLC_GPMF32 = 1,
+   AMDGPU_GFX_RLC_RLCVF32,
+   AMDGPU_GFX_RLC_SCRATCH,
+   AMDGPU_GFX_RLC_SRM_ARAM,
+   AMDGPU_GFX_RLC_SRM_DRAM,
+   AMDGPU_GFX_RLC_TCTAG,
+   AMDGPU_GFX_RLC_SPM_SE,
+   AMDGPU_GFX_RLC_SPM_GRBMT,
+};
+
+enum amdgpu_gfx_sp_ras_mem_id {
+   AMDGPU_GFX_SP_SIMDID0 = 0,
+};
+
+enum amdgpu_gfx_spi_ras_mem_id {
+   AMDGPU_GFX_SPI_MEM0 = 0,
+   AMDGPU_GFX_SPI_MEM1,
+   AMDGPU_GFX_SPI_MEM2,
+   AMDGPU_GFX_SPI_MEM3,
+};
+
+enum amdgpu_gfx_sqc_ras_mem_id {
+   AMDGPU_GFX_SQC_INST_CACHE_A = 100,
+   AMDGPU_GFX_SQC_INST_CACHE_B = 101,
+   AMDGPU_GFX_SQC_INST_CACHE_TAG_A = 102,
+   AMDGPU_GFX_SQC_INST_CACHE_TAG_B = 103,
+   AMDGPU_GFX_SQC_INST_CACHE_MISS_FIFO_A = 104,
+   AMDGPU_GFX_SQC_INST_CACHE_MISS_FIFO_B = 105,
+   AMDGPU_GFX_SQC_INST_CACHE_GATCL1_MISS_FIFO_A = 106,
+   AMDGPU_GFX_SQC_INST_CACHE_GATCL1_MISS_FIFO_B = 107,
+   AMDGPU_GFX_SQC_DATA_CACHE_A = 200,
+   AMDGPU_GFX_SQC_DATA_CACHE_B = 201,
+   AMDGPU_GFX_SQC_DATA_CACHE_TAG_A = 202,
+   AMDGPU_GFX_SQC_DATA_CACHE_TAG_B = 203,
+   AMDGPU_GFX_SQC_DATA_CACHE_MISS_FIFO_A = 204,
+   AMDGPU_GFX_SQC_DATA_CACHE_MISS_FIFO_B = 205,
+   AMDGPU_GFX_SQC_DATA_CACHE_HIT_FIFO_A = 206,
+   AMDGPU_GFX_SQC_DATA_CACHE_HIT_FIFO_B = 207,
+   AMDGPU_GFX_SQC_DIRTY_BIT_A = 208,
+   AMDGPU_GFX_SQC_DIRTY_BIT_B = 209,
+   AMDGPU_GFX_SQC_WRITE_DATA_BUFFER_CU0 = 210,
+   AMDGPU_GFX_SQC_WRITE_DATA_BUFFER_CU1 = 211,
+   AMDGPU_GFX_SQC_UTCL1_MISS_LFIFO_DATA_CACHE_A = 212,
+   AMDGPU_GFX_SQC_UTCL1_MISS_LFIFO_DATA_CACHE_B = 213,
+   AMDGPU_GFX_SQC_UTCL1_MISS_LFIFO_INST_CACHE = 108,

[PATCH 05/10] drm/amdgpu: add RAS definitions for GFX

2023-05-12 Thread Alex Deucher
From: Tao Zhou 

Add common GFX RAS definitions.

v2: remove instance from amdgpu_gfx_ras_reg_entry,
amdgpu_ras_err_status_reg_entry has already defined it.
v3: remove memory id definitions from amdgpu_gfx.h, they are
related to IP version.

Signed-off-by: Tao Zhou 
Reviewed-by: Hawking Zhang 
Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 39 +
 1 file changed, 39 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
index f07117d8959b..7422db02aeda 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
@@ -75,6 +75,32 @@ enum amdgpu_pkg_type {
AMDGPU_PKG_TYPE_UNKNOWN,
 };
 
+enum amdgpu_gfx_ras_mem_id_type {
+   AMDGPU_GFX_CP_MEM = 0,
+   AMDGPU_GFX_GCEA_MEM,
+   AMDGPU_GFX_GC_CANE_MEM,
+   AMDGPU_GFX_GCUTCL2_MEM,
+   AMDGPU_GFX_GDS_MEM,
+   AMDGPU_GFX_LDS_MEM,
+   AMDGPU_GFX_RLC_MEM,
+   AMDGPU_GFX_SP_MEM,
+   AMDGPU_GFX_SPI_MEM,
+   AMDGPU_GFX_SQC_MEM,
+   AMDGPU_GFX_SQ_MEM,
+   AMDGPU_GFX_TA_MEM,
+   AMDGPU_GFX_TCC_MEM,
+   AMDGPU_GFX_TCA_MEM,
+   AMDGPU_GFX_TCI_MEM,
+   AMDGPU_GFX_TCP_MEM,
+   AMDGPU_GFX_TD_MEM,
+   AMDGPU_GFX_TCX_MEM,
+   AMDGPU_GFX_ATC_L2_MEM,
+   AMDGPU_GFX_UTCL2_MEM,
+   AMDGPU_GFX_VML2_MEM,
+   AMDGPU_GFX_VML2_WALKER_MEM,
+   AMDGPU_GFX_MEM_TYPE_NUM
+};
+
 struct amdgpu_mec {
struct amdgpu_bo*hpd_eop_obj;
u64 hpd_eop_gpu_addr;
@@ -412,6 +438,19 @@ struct amdgpu_gfx {
struct mutexpartition_mutex;
 };
 
+struct amdgpu_gfx_ras_reg_entry {
+   struct amdgpu_ras_err_status_reg_entry reg_entry;
+   enum amdgpu_gfx_ras_mem_id_type mem_id_type;
+   uint32_t se_num;
+};
+
+struct amdgpu_gfx_ras_mem_id_entry {
+   const struct amdgpu_ras_memory_id_entry *mem_id_ent;
+   uint32_t size;
+};
+
+#define AMDGPU_GFX_MEMID_ENT(x) {(x), ARRAY_SIZE(x)},
+
 #define amdgpu_gfx_get_gpu_clock_counter(adev) 
(adev)->gfx.funcs->get_gpu_clock_counter((adev))
 #define amdgpu_gfx_select_se_sh(adev, se, sh, instance, xcc_id) 
((adev)->gfx.funcs->select_se_sh((adev), (se), (sh), (instance), (xcc_id)))
 #define amdgpu_gfx_select_me_pipe_q(adev, me, pipe, q, vmid, xcc_id) 
((adev)->gfx.funcs->select_me_pipe_q((adev), (me), (pipe), (q), (vmid), 
(xcc_id)))
-- 
2.40.1



[PATCH 03/10] drm/amdgpu: add RAS status reset for gfx_v9_4_3

2023-05-12 Thread Alex Deucher
From: Tao Zhou 

Reset GFX RAS status registers.

v2: fix typo in title.
remove xcp operation.
v3: change instance from 0 to xcc_id for register access.

Signed-off-by: Tao Zhou 
Reviewed-by: Hawking Zhang 
Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 41 +
 1 file changed, 41 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
index f178e3f565e9..e6069d081f71 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
@@ -3050,11 +3050,52 @@ static void gfx_v9_4_3_inst_query_ras_err_status(struct 
amdgpu_device *adev,
gfx_v9_4_3_inst_query_utc_err_status(adev, xcc_id);
 }
 
+static void gfx_v9_4_3_inst_reset_utc_err_status(struct amdgpu_device *adev,
+   int xcc_id)
+{
+   WREG32_SOC15(GC, GET_INST(GC, xcc_id), regUTCL2_MEM_ECC_STATUS, 0x3);
+   WREG32_SOC15(GC, GET_INST(GC, xcc_id), regVML2_MEM_ECC_STATUS, 0x3);
+   WREG32_SOC15(GC, GET_INST(GC, xcc_id), regVML2_WALKER_MEM_ECC_STATUS, 
0x3);
+}
+
+static void gfx_v9_4_3_inst_reset_ea_err_status(struct amdgpu_device *adev,
+   int xcc_id)
+{
+   uint32_t i, j;
+   uint32_t value;
+
+   mutex_lock(>grbm_idx_mutex);
+   for (i = 0; i < gfx_v9_4_3_ea_err_status_regs.se_num; i++) {
+   for (j = 0; j < gfx_v9_4_3_ea_err_status_regs.instance; j++) {
+   gfx_v9_4_3_xcc_select_se_sh(adev, i, 0, j, xcc_id);
+   value = RREG32_SOC15(GC, GET_INST(GC, xcc_id), 
regGCEA_ERR_STATUS);
+   value = REG_SET_FIELD(value, GCEA_ERR_STATUS,
+   CLEAR_ERROR_STATUS, 0x1);
+   WREG32_SOC15(GC, GET_INST(GC, xcc_id), 
regGCEA_ERR_STATUS, value);
+   }
+   }
+   gfx_v9_4_3_xcc_select_se_sh(adev, 0x, 0x, 0x,
+   xcc_id);
+   mutex_unlock(>grbm_idx_mutex);
+}
+
+static void gfx_v9_4_3_inst_reset_ras_err_status(struct amdgpu_device *adev,
+   void *ras_error_status, int xcc_id)
+{
+   gfx_v9_4_3_inst_reset_utc_err_status(adev, xcc_id);
+   gfx_v9_4_3_inst_reset_ea_err_status(adev, xcc_id);
+}
+
 static void gfx_v9_4_3_query_ras_error_status(struct amdgpu_device *adev)
 {
amdgpu_gfx_ras_error_func(adev, NULL, 
gfx_v9_4_3_inst_query_ras_err_status);
 }
 
+static void gfx_v9_4_3_reset_ras_error_status(struct amdgpu_device *adev)
+{
+   amdgpu_gfx_ras_error_func(adev, NULL, 
gfx_v9_4_3_inst_reset_ras_err_status);
+}
+
 static const struct amd_ip_funcs gfx_v9_4_3_ip_funcs = {
.name = "gfx_v9_4_3",
.early_init = gfx_v9_4_3_early_init,
-- 
2.40.1



[PATCH 02/10] drm/amdgpu: add RAS status query for gfx_v9_4_3

2023-05-12 Thread Alex Deucher
From: Tao Zhou 

Query GFX RAS status.

v2: remove xcp operation.
v3: change instance from 0 to xcc_id for register access.

Signed-off-by: Tao Zhou 
Reviewed-by: Hawking Zhang 
Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 75 +
 1 file changed, 75 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
index 6cde05421a10..f178e3f565e9 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
@@ -2980,6 +2980,81 @@ static void gfx_v9_4_3_emit_wave_limit(struct 
amdgpu_ring *ring, bool enable)
}
 }
 
+static const struct soc15_reg_entry gfx_v9_4_3_ea_err_status_regs = {
+   SOC15_REG_ENTRY(GC, 0, regGCEA_ERR_STATUS), 0, 1, 16
+};
+
+static void gfx_v9_4_3_inst_query_ea_err_status(struct amdgpu_device *adev,
+   int xcc_id)
+{
+   uint32_t i, j;
+   uint32_t reg_value;
+
+   mutex_lock(>grbm_idx_mutex);
+
+   for (i = 0; i < gfx_v9_4_3_ea_err_status_regs.se_num; i++) {
+   for (j = 0; j < gfx_v9_4_3_ea_err_status_regs.instance; j++) {
+   gfx_v9_4_3_xcc_select_se_sh(adev, i, 0, j, xcc_id);
+   reg_value = RREG32_SOC15(GC, GET_INST(GC, xcc_id),
+   regGCEA_ERR_STATUS);
+   if (REG_GET_FIELD(reg_value, GCEA_ERR_STATUS, 
SDP_RDRSP_STATUS) ||
+   REG_GET_FIELD(reg_value, GCEA_ERR_STATUS, 
SDP_WRRSP_STATUS) ||
+   REG_GET_FIELD(reg_value, GCEA_ERR_STATUS, 
SDP_RDRSP_DATAPARITY_ERROR)) {
+   dev_warn(adev->dev,
+   "GCEA err detected at instance: %d, 
status: 0x%x!\n",
+   j, reg_value);
+   }
+   /* clear after read */
+   reg_value = REG_SET_FIELD(reg_value, GCEA_ERR_STATUS,
+ CLEAR_ERROR_STATUS, 0x1);
+   WREG32_SOC15(GC, GET_INST(GC, xcc_id), 
regGCEA_ERR_STATUS,
+   reg_value);
+   }
+   }
+
+   gfx_v9_4_3_xcc_select_se_sh(adev, 0x, 0x, 0x,
+   xcc_id);
+   mutex_unlock(>grbm_idx_mutex);
+}
+
+static void gfx_v9_4_3_inst_query_utc_err_status(struct amdgpu_device *adev,
+   int xcc_id)
+{
+   uint32_t data;
+
+   data = RREG32_SOC15(GC, GET_INST(GC, xcc_id), regUTCL2_MEM_ECC_STATUS);
+   if (data) {
+   dev_warn(adev->dev, "GFX UTCL2 Mem Ecc Status: 0x%x!\n", data);
+   WREG32_SOC15(GC, GET_INST(GC, xcc_id), regUTCL2_MEM_ECC_STATUS, 
0x3);
+   }
+
+   data = RREG32_SOC15(GC, GET_INST(GC, xcc_id), regVML2_MEM_ECC_STATUS);
+   if (data) {
+   dev_warn(adev->dev, "GFX VML2 Mem Ecc Status: 0x%x!\n", data);
+   WREG32_SOC15(GC, GET_INST(GC, xcc_id), regVML2_MEM_ECC_STATUS, 
0x3);
+   }
+
+   data = RREG32_SOC15(GC, GET_INST(GC, xcc_id),
+   regVML2_WALKER_MEM_ECC_STATUS);
+   if (data) {
+   dev_warn(adev->dev, "GFX VML2 Walker Mem Ecc Status: 0x%x!\n", 
data);
+   WREG32_SOC15(GC, GET_INST(GC, xcc_id), 
regVML2_WALKER_MEM_ECC_STATUS,
+   0x3);
+   }
+}
+
+static void gfx_v9_4_3_inst_query_ras_err_status(struct amdgpu_device *adev,
+   void *ras_error_status, int xcc_id)
+{
+   gfx_v9_4_3_inst_query_ea_err_status(adev, xcc_id);
+   gfx_v9_4_3_inst_query_utc_err_status(adev, xcc_id);
+}
+
+static void gfx_v9_4_3_query_ras_error_status(struct amdgpu_device *adev)
+{
+   amdgpu_gfx_ras_error_func(adev, NULL, 
gfx_v9_4_3_inst_query_ras_err_status);
+}
+
 static const struct amd_ip_funcs gfx_v9_4_3_ip_funcs = {
.name = "gfx_v9_4_3",
.early_init = gfx_v9_4_3_early_init,
-- 
2.40.1



[PATCH 01/10] drm/amdgpu: add GFX RAS common function

2023-05-12 Thread Alex Deucher
From: Tao Zhou 

The common function can help reduce redundant code.

v2: remove xcp operation, only need to do RAS operations for all
instances.
v3: remove check for GFX RAS support, will be checked in higher level.
add amdgpu prefix for the function name.

Signed-off-by: Tao Zhou 
Reviewed-by: Hawking Zhang 
Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 19 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h |  4 
 2 files changed, 23 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
index 2ebf5c6f4ff7..7b072413e576 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
@@ -878,6 +878,25 @@ int amdgpu_gfx_cp_ecc_error_irq(struct amdgpu_device *adev,
return 0;
 }
 
+void amdgpu_gfx_ras_error_func(struct amdgpu_device *adev,
+   void *ras_error_status,
+   void (*func)(struct amdgpu_device *adev, void *ras_error_status,
+   int xcc_id))
+{
+   int i;
+   int num_xcc = adev->gfx.xcc_mask ? NUM_XCC(adev->gfx.xcc_mask) : 1;
+   uint32_t xcc_mask = GENMASK(num_xcc - 1, 0);
+   struct ras_err_data *err_data = (struct ras_err_data *)ras_error_status;
+
+   if (err_data) {
+   err_data->ue_count = 0;
+   err_data->ce_count = 0;
+   }
+
+   for_each_inst(i, xcc_mask)
+   func(adev, ras_error_status, i);
+}
+
 uint32_t amdgpu_kiq_rreg(struct amdgpu_device *adev, uint32_t reg)
 {
signed long r, cnt = 0;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
index ba5f417146d3..f07117d8959b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
@@ -496,6 +496,10 @@ int amdgpu_gfx_poison_consumption_handler(struct 
amdgpu_device *adev,
 bool amdgpu_gfx_is_master_xcc(struct amdgpu_device *adev, int xcc_id);
 int amdgpu_gfx_sysfs_init(struct amdgpu_device *adev);
 void amdgpu_gfx_sysfs_fini(struct amdgpu_device *adev);
+void amdgpu_gfx_ras_error_func(struct amdgpu_device *adev,
+   void *ras_error_status,
+   void (*func)(struct amdgpu_device *adev, void *ras_error_status,
+   int xcc_id));
 
 static inline const char *amdgpu_gfx_compute_mode_desc(int mode)
 {
-- 
2.40.1



Re: [PATCH 2/2] drm/amdgpu/gfx11: Adjust gfxoff before powergating on gfx11 as well

2023-05-12 Thread Guilherme G. Piccoli
On 12/05/2023 10:29, Alex Deucher wrote:
> [...]
>> BTW, I couldn't test this one since I don't have GFX11 HW, so appreciate
>> if anyone from AMD (or any community member) could give it a try...
> 
> We've tested this on gfx11 and applied the patches.  Thanks!
> 
> Alex
> 

That's great, thanks a lot Alex!


Re: [PATCH] drm/amdgpu: improve wait logic at fence polling

2023-05-12 Thread Alex Deucher
On Mon, May 1, 2023 at 11:13 AM Felix Kuehling  wrote:
>
> Am 2023-04-26 um 12:15 schrieb Alex Sierra:
> > Accomplish this by reading the seq number right away instead of sleep
> > for 5us. There are certain cases where the fence is ready almost
> > immediately. Sleep number granularity was also reduced as the majority
> > of the kiq tlb flush takes between 2us to 6us.
> >
> > Signed-off-by: Alex Sierra 
>
> I'm not sure I have authority to give an R-b for this. But the change
> and the explanation sound reasonable to me. Doing the first check before
> waiting is a no-brainer. Reducing the delay can increase CPU usage or
> bus traffic and may be more controversial.
>

The fences should be in system memory, so it shouldn't affect bus
traffic, but there could be more CPU usage.  The change seems fine to
me.
Reviewed-by: Alex Deucher 

> FWIW, this patch is
>
> Acked-by: Felix Kuehling 
>
>
> > ---
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 11 ---
> >   1 file changed, 4 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c 
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
> > index a7627cc0118d..9192896239e9 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
> > @@ -377,14 +377,11 @@ signed long amdgpu_fence_wait_polling(struct 
> > amdgpu_ring *ring,
> > uint32_t wait_seq,
> > signed long timeout)
> >   {
> > - uint32_t seq;
> > -
> > - do {
> > - seq = amdgpu_fence_read(ring);
> > - udelay(5);
> > - timeout -= 5;
> > - } while ((int32_t)(wait_seq - seq) > 0 && timeout > 0);
> >
> > + while ((int32_t)(wait_seq - amdgpu_fence_read(ring)) > 0 && timeout > 
> > 0) {
> > + udelay(2);
> > + timeout -= 2;
> > + }
> >   return timeout > 0 ? timeout : 0;
> >   }
> >   /**


Re: [Intel-gfx] [PATCH 07/11] drm/omapdrm: Use regular fbdev I/O helpers

2023-05-12 Thread kernel test robot
Hi Thomas,

kernel test robot noticed the following build errors:

[auto build test ERROR on 451e49cfbaa90720149e63f4fa9c7824013c783d]

url:
https://github.com/intel-lab-lkp/linux/commits/Thomas-Zimmermann/drm-armada-Use-regular-fbdev-I-O-helpers/20230512-164432
base:   451e49cfbaa90720149e63f4fa9c7824013c783d
patch link:
https://lore.kernel.org/r/20230512084152.31233-8-tzimmermann%40suse.de
patch subject: [Intel-gfx] [PATCH 07/11] drm/omapdrm: Use regular fbdev I/O 
helpers
config: arm-allmodconfig 
(https://download.01.org/0day-ci/archive/20230513/202305130058.vuw3nbps-...@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# 
https://github.com/intel-lab-lkp/linux/commit/f9113ec6815b748d0b917f78527582b8b08deb40
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review 
Thomas-Zimmermann/drm-armada-Use-regular-fbdev-I-O-helpers/20230512-164432
git checkout f9113ec6815b748d0b917f78527582b8b08deb40
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 
O=build_dir ARCH=arm olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 
O=build_dir ARCH=arm SHELL=/bin/bash drivers/gpu/drm/omapdrm/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot 
| Link: 
https://lore.kernel.org/oe-kbuild-all/202305130058.vuw3nbps-...@intel.com/

All errors (new ones prefixed by >>):

>> drivers/gpu/drm/omapdrm/omap_fbdev.c:306:6: error: redefinition of 
>> 'omap_fbdev_setup'
 306 | void omap_fbdev_setup(struct drm_device *dev)
 |  ^~~~
   In file included from drivers/gpu/drm/omapdrm/omap_fbdev.c:19:
   drivers/gpu/drm/omapdrm/omap_fbdev.h:17:20: note: previous definition of 
'omap_fbdev_setup' with type 'void(struct drm_device *)'
  17 | static inline void omap_fbdev_setup(struct drm_device *dev)
 |^~~~


vim +/omap_fbdev_setup +306 drivers/gpu/drm/omapdrm/omap_fbdev.c

9e69bcd88e4593 Thomas Zimmermann 2023-04-03  305  
9e69bcd88e4593 Thomas Zimmermann 2023-04-03 @306  void omap_fbdev_setup(struct 
drm_device *dev)

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests


Re: Fwd: Linux 6.3.1 + AMD RX 570 on ppc64le 4K: Kernel attempted to read user page (1128) - exploit attempt? (uid: 0)

2023-05-12 Thread Christophe Leroy


Le 12/05/2023 à 17:16, Christophe Leroy a écrit :
> 
> 
> Le 11/05/2023 à 19:25, Niccolò Belli a écrit :
>> [Vous ne recevez pas souvent de courriers de 
>> darkba...@linuxsystems.it. D?couvrez pourquoi ceci est important ? 
>> https://aka.ms/LearnAboutSenderIdentification ]
>>
>> Il 2023-05-12 10:32 Bagas Sanjaya ha scritto:
>>> #regzbot introduced: f4f3b7dedbe849
>>> #regzbot link: https://gitlab.freedesktop.org/drm/amd/-/issues/2553
>>
>> It doesn't look like the aforementioned patch made its way into 6.3 yet:
>>
>> niko@talos2 ~/devel/linux-stable $ git branch
>> * linux-6.3.y
>>    master
>> niko@talos2 ~/devel/linux-stable $ git show f4f3b7dedbe8 | patch -p1
>> patching file
>> drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
>> Hunk #1 succeeded at 227 (offset 15 lines).
>> Hunk #2 succeeded at 269 with fuzz 2 (offset 19 lines).
>> patching file
>> drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.h
>> Hunk #1 succeeded at 49 with fuzz 2 (offset 15 lines).
> 
> As far as I can see that patch has no Fixes: tag, so it will unlikely be 
> automatically merged into stable.
> 
> Has anybody requested greg/sasha to get it into 6.3 ?
> 

In fact, it seems that patch is already part of 6.3:

$ git tag --contains f4f3b7dedbe8
v6.3
v6.3-rc5
v6.3-rc6
v6.3-rc7
v6.3.1
v6.3.2
v6.4-rc1


Re: Fwd: Linux 6.3.1 + AMD RX 570 on ppc64le 4K: Kernel attempted to read user page (1128) - exploit attempt? (uid: 0)

2023-05-12 Thread Alex Deucher
On Fri, May 12, 2023 at 11:16 AM Christophe Leroy
 wrote:
>
>
>
> Le 11/05/2023 à 19:25, Niccolò Belli a écrit :
> > [Vous ne recevez pas souvent de courriers de darkba...@linuxsystems.it.
> > D?couvrez pourquoi ceci est important ?
> > https://aka.ms/LearnAboutSenderIdentification ]
> >
> > Il 2023-05-12 10:32 Bagas Sanjaya ha scritto:
> >> #regzbot introduced: f4f3b7dedbe849
> >> #regzbot link: https://gitlab.freedesktop.org/drm/amd/-/issues/2553
> >
> > It doesn't look like the aforementioned patch made its way into 6.3 yet:
> >
> > niko@talos2 ~/devel/linux-stable $ git branch
> > * linux-6.3.y
> >master
> > niko@talos2 ~/devel/linux-stable $ git show f4f3b7dedbe8 | patch -p1
> > patching file
> > drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
> > Hunk #1 succeeded at 227 (offset 15 lines).
> > Hunk #2 succeeded at 269 with fuzz 2 (offset 19 lines).
> > patching file
> > drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.h
> > Hunk #1 succeeded at 49 with fuzz 2 (offset 15 lines).
>
> As far as I can see that patch has no Fixes: tag, so it will unlikely be
> automatically merged into stable.
>
> Has anybody requested greg/sasha to get it into 6.3 ?

This is no fix identified yet.

Alex


Re: Fwd: Linux 6.3.1 + AMD RX 570 on ppc64le 4K: Kernel attempted to read user page (1128) - exploit attempt? (uid: 0)

2023-05-12 Thread Christophe Leroy


Le 11/05/2023 à 19:25, Niccolò Belli a écrit :
> [Vous ne recevez pas souvent de courriers de darkba...@linuxsystems.it. 
> D?couvrez pourquoi ceci est important ? 
> https://aka.ms/LearnAboutSenderIdentification ]
> 
> Il 2023-05-12 10:32 Bagas Sanjaya ha scritto:
>> #regzbot introduced: f4f3b7dedbe849
>> #regzbot link: https://gitlab.freedesktop.org/drm/amd/-/issues/2553
> 
> It doesn't look like the aforementioned patch made its way into 6.3 yet:
> 
> niko@talos2 ~/devel/linux-stable $ git branch
> * linux-6.3.y
>    master
> niko@talos2 ~/devel/linux-stable $ git show f4f3b7dedbe8 | patch -p1
> patching file
> drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
> Hunk #1 succeeded at 227 (offset 15 lines).
> Hunk #2 succeeded at 269 with fuzz 2 (offset 19 lines).
> patching file
> drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.h
> Hunk #1 succeeded at 49 with fuzz 2 (offset 15 lines).

As far as I can see that patch has no Fixes: tag, so it will unlikely be 
automatically merged into stable.

Has anybody requested greg/sasha to get it into 6.3 ?

Christophe


Re: [PATCH] amd/amdgpu: perform soft reset for sdma fed error

2023-05-12 Thread Alex Deucher
On Fri, May 12, 2023 at 3:49 AM YiPeng Chai  wrote:
>
> When testing sdma ib ring fails to detect sdma
> hang for sdma fed error, force to perform soft
> reset.
>
> Signed-off-by: YiPeng Chai 

Acked-by: Alex Deucher 

> ---
>  drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c | 16 
>  1 file changed, 16 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c 
> b/drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c
> index 3d9a80511a45..1d463e1fd3ae 100644
> --- a/drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c
> @@ -53,6 +53,12 @@ MODULE_FIRMWARE("amdgpu/sdma_6_0_3.bin");
>  #define SDMA0_HYP_DEC_REG_START 0x5880
>  #define SDMA0_HYP_DEC_REG_END 0x589a
>  #define SDMA1_HYP_DEC_REG_OFFSET 0x20
> +#define regRLC_RLCS_FED_STATUS_0 0x4eff
> +#define regRLC_RLCS_FED_STATUS_0_BASE_IDX1
> +#define RLC_RLCS_FED_STATUS_0__SDMA0_FED_ERR_MASK0x0040L
> +#define RLC_RLCS_FED_STATUS_0__SDMA1_FED_ERR_MASK0x0080L
> +#define RLC_RLCS_FED_STATUS_0__SDMA0_FED_ERR__SHIFT  0x6
> +#define RLC_RLCS_FED_STATUS_0__SDMA1_FED_ERR__SHIFT  0x7
>
>  static void sdma_v6_0_set_ring_funcs(struct amdgpu_device *adev);
>  static void sdma_v6_0_set_buffer_funcs(struct amdgpu_device *adev);
> @@ -760,6 +766,7 @@ static bool sdma_v6_0_check_soft_reset(void *handle)
> struct amdgpu_ring *ring;
> int i, r;
> long tmo = msecs_to_jiffies(1000);
> +   uint32_t rlc_status0 = 0;
>
> for (i = 0; i < adev->sdma.num_instances; i++) {
> ring = >sdma.instance[i].ring;
> @@ -768,6 +775,15 @@ static bool sdma_v6_0_check_soft_reset(void *handle)
> return true;
> }
>
> +   /* Soft reset should be performed for sdma fed error to
> +* recover sdma engine, so when testing sdma ib ring fails
> +* to detect sdma hang, force to perform soft reset.
> +*/
> +   rlc_status0 = RREG32_SOC15(GC, 0, regRLC_RLCS_FED_STATUS_0);
> +   if (REG_GET_FIELD(rlc_status0, RLC_RLCS_FED_STATUS_0, SDMA0_FED_ERR) 
> ||
> +   REG_GET_FIELD(rlc_status0, RLC_RLCS_FED_STATUS_0, SDMA1_FED_ERR))
> +   return true;
> +
> return false;
>  }
>
> --
> 2.34.1
>


Re: [PATCH] drm/amd/display: Simplify the calculation of variables

2023-05-12 Thread Hamza Mahfooz

On 5/12/23 03:04, Jiapeng Chong wrote:

./drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.c:586:37-39: WARNING !A || A 
&& B is equivalent to !A || B.
./drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.c:595:37-39: WARNING !A || A 
&& B is equivalent to !A || B.

Reported-by: Abaci Robot 
Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=4941
Signed-off-by: Jiapeng Chong 


Applied, thanks!


---
  drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.c 
b/drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.c
index 4950eaa4406b..2de910e0ce75 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.c
@@ -583,8 +583,8 @@ void dcn32_update_force_pstate(struct dc *dc, struct 
dc_state *context)
struct pipe_ctx *pipe = >res_ctx.pipe_ctx[i];
struct hubp *hubp = pipe->plane_res.hubp;
  
-		if (!pipe->stream || (pipe->stream && !(pipe->stream->mall_stream_config.type == SUBVP_MAIN ||

-   pipe->stream->fpo_in_use))) {
+   if (!pipe->stream || !(pipe->stream->mall_stream_config.type == 
SUBVP_MAIN ||
+   pipe->stream->fpo_in_use)) {
if (hubp && 
hubp->funcs->hubp_update_force_pstate_disallow)

hubp->funcs->hubp_update_force_pstate_disallow(hubp, false);
}
@@ -592,7 +592,7 @@ void dcn32_update_force_pstate(struct dc *dc, struct 
dc_state *context)
/* Today only FPO uses cursor P-State force. Only clear cursor 
P-State force
 * if it's not FPO.
 */
-   if (!pipe->stream || (pipe->stream && 
!pipe->stream->fpo_in_use)) {
+   if (!pipe->stream || !pipe->stream->fpo_in_use) {
if (hubp && 
hubp->funcs->hubp_update_force_cursor_pstate_disallow)

hubp->funcs->hubp_update_force_cursor_pstate_disallow(hubp, false);
}

--
Hamza



RE: [PATCH 04/11] drm/radeon: Use regular fbdev I/O helpers

2023-05-12 Thread Deucher, Alexander
[Public]

> -Original Message-
> From: Thomas Zimmermann 
> Sent: Friday, May 12, 2023 4:42 AM
> To: dan...@ffwll.ch; airl...@gmail.com; maarten.lankho...@linux.intel.com;
> mrip...@kernel.org; javi...@redhat.com
> Cc: dri-de...@lists.freedesktop.org; linux-arm-ker...@lists.infradead.org;
> linux-samsung-...@vger.kernel.org; intel-...@lists.freedesktop.org; linux-
> arm-...@vger.kernel.org; freedr...@lists.freedesktop.org; amd-
> g...@lists.freedesktop.org; linux-te...@vger.kernel.org; Thomas
> Zimmermann ; Deucher, Alexander
> ; Koenig, Christian
> ; Pan, Xinhui 
> Subject: [PATCH 04/11] drm/radeon: Use regular fbdev I/O helpers
> 
> Use the regular fbdev helpers for framebuffer I/O instead of DRM's helpers.
> Radeon does not use damage handling, so DRM's fbdev helpers are mere
> wrappers around the fbdev code.
> 
> Add CONFIG_DRM_RADEON_FBDEV_EMULATION to select the necessary
> Kconfig options automatically. Make fbdev emulation depend on the new
> config option.
> 
> By using fbdev helpers directly within each DRM fbdev emulation, we can
> eventually remove DRM's wrapper functions entirely.
> 
> Signed-off-by: Thomas Zimmermann 
> Cc: Alex Deucher 
> Cc: "Christian König" 
> Cc: "Pan, Xinhui" 

Feel free to take this through whatever tree makes sense.
Acked-by: Alex Deucher 

> ---
>  drivers/gpu/drm/radeon/Kconfig| 8 
>  drivers/gpu/drm/radeon/Makefile   | 2 +-
>  drivers/gpu/drm/radeon/radeon_fbdev.c | 9 -
> drivers/gpu/drm/radeon/radeon_mode.h  | 2 +-
>  4 files changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/radeon/Kconfig
> b/drivers/gpu/drm/radeon/Kconfig index e19d77d58810..66b741d96cc4
> 100644
> --- a/drivers/gpu/drm/radeon/Kconfig
> +++ b/drivers/gpu/drm/radeon/Kconfig
> @@ -8,6 +8,7 @@ config DRM_RADEON
>   select DRM_DISPLAY_DP_HELPER
>   select DRM_DISPLAY_HELPER
>  select DRM_KMS_HELPER
> + select DRM_RADEON_FBDEV_EMULATION if
> DRM_FBDEV_EMULATION
>   select DRM_SUBALLOC_HELPER
>  select DRM_TTM
>   select DRM_TTM_HELPER
> @@ -39,3 +40,10 @@ config DRM_RADEON_USERPTR
>   help
> This option selects CONFIG_MMU_NOTIFIER if it isn't already
> selected to enabled full userptr support.
> +
> +config DRM_RADEON_FBDEV_EMULATION
> + bool
> + depends on DRM_RADEON
> + select FB_CFB_COPYAREA
> + select FB_CFB_FILLRECT
> + select FB_CFB_IMAGEBLIT
> diff --git a/drivers/gpu/drm/radeon/Makefile
> b/drivers/gpu/drm/radeon/Makefile index a8734b7d0485..46c1446196a9
> 100644
> --- a/drivers/gpu/drm/radeon/Makefile
> +++ b/drivers/gpu/drm/radeon/Makefile
> @@ -76,7 +76,7 @@ radeon-y += \
>   vce_v1_0.o \
>   vce_v2_0.o
> 
> -radeon-$(CONFIG_DRM_FBDEV_EMULATION) += radeon_fbdev.o
> +radeon-$(CONFIG_DRM_RADEON_FBDEV_EMULATION) +=
> radeon_fbdev.o
>  radeon-$(CONFIG_VGA_SWITCHEROO) += radeon_atpx_handler.o
>  radeon-$(CONFIG_ACPI) += radeon_acpi.o
> 
> diff --git a/drivers/gpu/drm/radeon/radeon_fbdev.c
> b/drivers/gpu/drm/radeon/radeon_fbdev.c
> index fe76e29910ef..dcabe527f9c0 100644
> --- a/drivers/gpu/drm/radeon/radeon_fbdev.c
> +++ b/drivers/gpu/drm/radeon/radeon_fbdev.c
> @@ -24,6 +24,7 @@
>   * David Airlie
>   */
> 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -193,11 +194,9 @@ static const struct fb_ops radeon_fbdev_fb_ops = {
>   DRM_FB_HELPER_DEFAULT_OPS,
>   .fb_open = radeon_fbdev_fb_open,
>   .fb_release = radeon_fbdev_fb_release,
> - .fb_read = drm_fb_helper_cfb_read,
> - .fb_write = drm_fb_helper_cfb_write,
> - .fb_fillrect = drm_fb_helper_cfb_fillrect,
> - .fb_copyarea = drm_fb_helper_cfb_copyarea,
> - .fb_imageblit = drm_fb_helper_cfb_imageblit,
> + .fb_fillrect = cfb_fillrect,
> + .fb_copyarea = cfb_copyarea,
> + .fb_imageblit = cfb_imageblit,
>   .fb_destroy = radeon_fbdev_fb_destroy,  };
> 
> diff --git a/drivers/gpu/drm/radeon/radeon_mode.h
> b/drivers/gpu/drm/radeon/radeon_mode.h
> index 1decdcec0264..c5a8e25a4c97 100644
> --- a/drivers/gpu/drm/radeon/radeon_mode.h
> +++ b/drivers/gpu/drm/radeon/radeon_mode.h
> @@ -939,7 +939,7 @@ void dce4_program_fmt(struct drm_encoder
> *encoder);  void dce8_program_fmt(struct drm_encoder *encoder);
> 
>  /* fbdev layer */
> -#if defined(CONFIG_DRM_FBDEV_EMULATION)
> +#if defined(CONFIG_DRM_RADEON_FBDEV_EMULATION)
>  void radeon_fbdev_setup(struct radeon_device *rdev);  void
> radeon_fbdev_set_suspend(struct radeon_device *rdev, int state);  bool
> radeon_fbdev_robj_is_fb(struct radeon_device *rdev, struct radeon_bo
> *robj);
> --
> 2.40.1


Re: [PATCH 00/11] drm/fbdev: Remove DRM's helpers for fbdev I/O

2023-05-12 Thread Sam Ravnborg
Hi Thomas,
> > 
> > Nice cleanup.
> > 
> >  From one of the patches:
> > 
> > > +config DRM_ARMADA_FBDEV_EMULATION
> > > + bool
> > > + depends on DRM_ARMADA
> > > + select FB_CFB_COPYAREA
> > > + select FB_CFB_FILLRECT
> > > + select FB_CFB_IMAGEBLIT
> > 
> > This seems like a hard to maintain way to select a few helper functions.
> > Today we have LD_DEAD_CODE_DATA_ELIMINATION for the configs that care
> > about size - and that should work here as well.
> 
> I wasn't too happy about this solution either as it is quite verbose. But I
> don't want to rely on the linker either. It certainly cannot remove exported
> symbols.
I forgot about exported symbols - that makes the idea futile.

> 
> But the pattern is very common among the fbdev drivers. We could introduce
> common Kconfig options in fbdev and selcet those instead. Like this:
> 
> const FB_IO_HELPERS
>   bool
>   depends on FB
>   select FB_CFB_COPYAREA
>   select FB_CFB_FILLRECT
>   select FB_CFB_IMAGEBLIT
> 
> const FB_SYS_HELPERS
>   bool
>   depends on FB
>   select FB_SYS_COPYAREA
>   select FB_SYS_FILLRECT
>   select FB_SYS_FOPS
>   select FB_SYS_IMAGEBLIT
> 
> Apart from DRM, most of the fbdev drivers could use these as well.
That's a much nicer way to express it - and with this we do not introduce
the IMO confusing CFB (Color Frame Buffer) abbreviation in every driver.

Sam


Re: [PATCH 2/2] drm/amdgpu/gfx11: Adjust gfxoff before powergating on gfx11 as well

2023-05-12 Thread Alex Deucher
On Tue, May 9, 2023 at 1:04 PM Guilherme G. Piccoli  wrote:
>
> On 09/05/2023 13:49, Bas Nieuwenhuizen wrote:
> > From: "Guilherme G. Piccoli" 
> >
> > (Bas: speculative change to mirror gfx10/gfx9)
> >
> > Signed-off-by: Guilherme G. Piccoli 
> > Cc: Alex Deucher 
> > ---
>
> Thanks a lot for both patches Bas! This second one, despite I've
> attached it on gitlab, you should also Sign-off since you're the one
> sending it to the ML (I guess heh)
>
> BTW, I couldn't test this one since I don't have GFX11 HW, so appreciate
> if anyone from AMD (or any community member) could give it a try...

We've tested this on gfx11 and applied the patches.  Thanks!

Alex

>
> Cheers,
>
>
> Guilherme


Re: drm/amdgpu: Differentiate between Raven2 and Raven/Picasso according to revision id.

2023-05-12 Thread Alex Deucher
Acked-by: Alex Deucher 

On Thu, May 11, 2023 at 9:20 PM Zhang, Jesse(Jie)  wrote:
>
> [AMD Official Use Only - General]
>
>
> drm/amdgpu: Differentiate between Raven2 and Raven/Picasso according to 
> revision id.
>
>
>
> Due to the raven2 and raven/picasso maybe have the same GC_HWIP version.
>
> So differentiate them by revision id.
>
>
>
> Signed-off-by: shanshengwang 
>
> Signed-off-by: Jesse Zhang 
>
>
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c 
> b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
>
> index e093e83ae739..1f4edfb96636 100644
>
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
>
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
>
> @@ -4000,30 +4000,27 @@ static uint64_t gfx_v9_0_get_gpu_clock_counter(struct 
> amdgpu_device *adev)
>
> clock = clock_lo | (clock_hi << 32ULL);
>
> break;
>
> case IP_VERSION(9, 1, 0):
>
> +   case IP_VERSION(9, 2, 2):
>
> preempt_disable();
>
> -   clock_hi = RREG32_SOC15_NO_KIQ(PWR, 0, 
> mmGOLDEN_TSC_COUNT_UPPER_Raven);
>
> -   clock_lo = RREG32_SOC15_NO_KIQ(PWR, 0, 
> mmGOLDEN_TSC_COUNT_LOWER_Raven);
>
> -   hi_check = RREG32_SOC15_NO_KIQ(PWR, 0, 
> mmGOLDEN_TSC_COUNT_UPPER_Raven);
>
> -   /* The PWR TSC clock frequency is 100MHz, which sets 32-bit 
> carry over
>
> -* roughly every 42 seconds.
>
> -*/
>
> -   if (hi_check != clock_hi) {
>
> +   if (adev->rev_id >= 0x8)
>
> +   {
>
> +   clock_hi = RREG32_SOC15_NO_KIQ(PWR, 0, 
> mmGOLDEN_TSC_COUNT_UPPER_Raven2);
>
> +   clock_lo = RREG32_SOC15_NO_KIQ(PWR, 0, 
> mmGOLDEN_TSC_COUNT_LOWER_Raven2);
>
> +   hi_check = RREG32_SOC15_NO_KIQ(PWR, 0, 
> mmGOLDEN_TSC_COUNT_UPPER_Raven2);
>
> +   }else{
>
> +   clock_hi = RREG32_SOC15_NO_KIQ(PWR, 0, 
> mmGOLDEN_TSC_COUNT_UPPER_Raven);
>
> clock_lo = RREG32_SOC15_NO_KIQ(PWR, 0, 
> mmGOLDEN_TSC_COUNT_LOWER_Raven);
>
> -   clock_hi = hi_check;
>
> +   hi_check = RREG32_SOC15_NO_KIQ(PWR, 0, 
> mmGOLDEN_TSC_COUNT_UPPER_Raven);
>
> }
>
> -   preempt_enable();
>
> -   clock = clock_lo | (clock_hi << 32ULL);
>
> -   break;
>
> -   case IP_VERSION(9, 2, 2):
>
> -   preempt_disable();
>
> -   clock_hi = RREG32_SOC15_NO_KIQ(PWR, 0, 
> mmGOLDEN_TSC_COUNT_UPPER_Raven2);
>
> -   clock_lo = RREG32_SOC15_NO_KIQ(PWR, 0, 
> mmGOLDEN_TSC_COUNT_LOWER_Raven2);
>
> -   hi_check = RREG32_SOC15_NO_KIQ(PWR, 0, 
> mmGOLDEN_TSC_COUNT_UPPER_Raven2);
>
> /* The PWR TSC clock frequency is 100MHz, which sets 32-bit 
> carry over
>
> -* roughly every 42 seconds.
>
> -*/
>
> +   * roughly every 42 seconds.
>
> +   */
>
> if (hi_check != clock_hi) {
>
> -   clock_lo = RREG32_SOC15_NO_KIQ(PWR, 0, 
> mmGOLDEN_TSC_COUNT_LOWER_Raven2);
>
> +   if (adev->rev_id >= 0x8) {
>
> +   clock_lo = RREG32_SOC15_NO_KIQ(PWR, 0, 
> mmGOLDEN_TSC_COUNT_LOWER_Raven2);
>
> +   }else{
>
> +   clock_lo = RREG32_SOC15_NO_KIQ(PWR, 0, 
> mmGOLDEN_TSC_COUNT_LOWER_Raven);
>
> +   }
>
> clock_hi = hi_check;
>
> }
>
> preempt_enable();
>
>


Re: [PATCH 06/11] drm/msm: Use regular fbdev I/O helpers

2023-05-12 Thread Dmitry Baryshkov
On Fri, 12 May 2023 at 11:41, Thomas Zimmermann  wrote:
>
> Use the regular fbdev helpers for framebuffer I/O instead of DRM's
> helpers. Msm does not use damage handling, so DRM's fbdev helpers
> are mere wrappers around the fbdev code.
>
> Add CONFIG_DRM_MSM_FBDEV_EMULATION to select the necessary
> Kconfig options automatically. Make fbdev emulation depend on
> the new config option.
>
> By using fbdev helpers directly within each DRM fbdev emulation,
> we can eventually remove DRM's wrapper functions entirely.
>
> Signed-off-by: Thomas Zimmermann 
> Cc: Rob Clark 
> Cc: Abhinav Kumar 
> Cc: Dmitry Baryshkov 
> Cc: Sean Paul 
> ---
>  drivers/gpu/drm/msm/Kconfig |  9 +
>  drivers/gpu/drm/msm/Makefile|  2 +-
>  drivers/gpu/drm/msm/msm_drv.h   |  2 +-
>  drivers/gpu/drm/msm/msm_fbdev.c | 12 +++-
>  4 files changed, 18 insertions(+), 7 deletions(-)


Reviewed-by: Dmitry Baryshkov 

-- 
With best wishes
Dmitry


Re: [PATCH] drm/amdgpu: fix S3 issue if MQD in VRAM

2023-05-12 Thread Alex Deucher
On Fri, May 12, 2023 at 4:16 AM Jack Xiao  wrote:
>
> Make the preemption optimization effect only for SRIOV,
> for it caused failure to resume from S3.

Can you elaborate?  We ultimately want MQDs in VRAM for performance
reasons even for bare metal.

Alex

>
> Signed-off-by: Jack Xiao 
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 3 ++-
>  drivers/gpu/drm/amd/amdgpu/mes_v10_1.c  | 7 +--
>  drivers/gpu/drm/amd/amdgpu/mes_v11_0.c  | 7 +--
>  3 files changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
> index a22d88a4178a..1b795b7bbf38 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
> @@ -385,7 +385,8 @@ int amdgpu_gfx_mqd_sw_init(struct amdgpu_device *adev,
> u32 domain = AMDGPU_GEM_DOMAIN_GTT;
>
> /* Only enable on gfx10 and 11 for now to avoid changing behavior on 
> older chips */
> -   if (adev->ip_versions[GC_HWIP][0] >= IP_VERSION(10, 0, 0))
> +   if (adev->ip_versions[GC_HWIP][0] >= IP_VERSION(10, 0, 0) &&
> +   amdgpu_sriov_vf(adev))
> domain |= AMDGPU_GEM_DOMAIN_VRAM;
>
> /* create MQD for KIQ */
> diff --git a/drivers/gpu/drm/amd/amdgpu/mes_v10_1.c 
> b/drivers/gpu/drm/amd/amdgpu/mes_v10_1.c
> index 4560476c7c31..5c3d3f6c7ebd 100644
> --- a/drivers/gpu/drm/amd/amdgpu/mes_v10_1.c
> +++ b/drivers/gpu/drm/amd/amdgpu/mes_v10_1.c
> @@ -889,6 +889,7 @@ static int mes_v10_1_mqd_sw_init(struct amdgpu_device 
> *adev,
>  {
> int r, mqd_size = sizeof(struct v10_compute_mqd);
> struct amdgpu_ring *ring;
> +   u32 domain = AMDGPU_GEM_DOMAIN_GTT;
>
> if (pipe == AMDGPU_MES_KIQ_PIPE)
> ring = >gfx.kiq[0].ring;
> @@ -900,9 +901,11 @@ static int mes_v10_1_mqd_sw_init(struct amdgpu_device 
> *adev,
> if (ring->mqd_obj)
> return 0;
>
> +   if (amdgpu_sriov_vf(adev))
> +   domain |= AMDGPU_GEM_DOMAIN_VRAM;
> +
> r = amdgpu_bo_create_kernel(adev, mqd_size, PAGE_SIZE,
> -   AMDGPU_GEM_DOMAIN_VRAM |
> -   AMDGPU_GEM_DOMAIN_GTT, >mqd_obj,
> +   domain, >mqd_obj,
> >mqd_gpu_addr, >mqd_ptr);
> if (r) {
> dev_warn(adev->dev, "failed to create ring mqd bo (%d)", r);
> diff --git a/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c 
> b/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c
> index 3adb450eec07..79a4d2bfd94a 100644
> --- a/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c
> @@ -987,6 +987,7 @@ static int mes_v11_0_mqd_sw_init(struct amdgpu_device 
> *adev,
>  {
> int r, mqd_size = sizeof(struct v11_compute_mqd);
> struct amdgpu_ring *ring;
> +   u32 domain = AMDGPU_GEM_DOMAIN_GTT;
>
> if (pipe == AMDGPU_MES_KIQ_PIPE)
> ring = >gfx.kiq[0].ring;
> @@ -998,9 +999,11 @@ static int mes_v11_0_mqd_sw_init(struct amdgpu_device 
> *adev,
> if (ring->mqd_obj)
> return 0;
>
> +   if (amdgpu_sriov_vf(adev))
> +   domain |= AMDGPU_GEM_DOMAIN_VRAM;
> +
> r = amdgpu_bo_create_kernel(adev, mqd_size, PAGE_SIZE,
> -   AMDGPU_GEM_DOMAIN_VRAM |
> -   AMDGPU_GEM_DOMAIN_GTT, >mqd_obj,
> +   domain, >mqd_obj,
> >mqd_gpu_addr, >mqd_ptr);
> if (r) {
> dev_warn(adev->dev, "failed to create ring mqd bo (%d)", r);
> --
> 2.37.3
>


Re: [PATCH 00/11] drm/fbdev: Remove DRM's helpers for fbdev I/O

2023-05-12 Thread Thomas Zimmermann

Hi Sam

Am 12.05.23 um 12:29 schrieb Sam Ravnborg:

Hi Thomas,

On Fri, May 12, 2023 at 10:41:41AM +0200, Thomas Zimmermann wrote:

DRM provides a number of wrappers around fbdev cfb_() sys_(), fb_io_()
and fb_sys_() helpers. The DRM functions don't provide any additional
functionality for most DRM drivers. So remove them and call the fbdev
I/O helpers directly.

The DRM fbdev I/O wrappers were originally added because 
does not protect its content with CONFIG_FB. DRM fbdev emulation did
not build if the the config option had been disabled. This has been
fixed. For fbdev-generic and i915, the wrappers added support for damage
handling. But this is better handled within the two callers, as each
is special in its damage handling.

Patches 1 to 8 replace the DRM wrappers in a number of fbdev emulations.
Patch 9 exports two helpers for damage handling. Patches 10 and 11
update fbdev-generic and i915 with the help of the exported functions.
The patches also remove DRM's fbdev I/O helpers, which are now unused.

DRM's fbdev helpers had to select fbdev I/O helpers for I/O and for
system memory. Each fbdev emulation now selects the correct helpers
for itself. Depending on the selected DRM drivers, kernel builds will
now only contain the necessary fbdev I/O helpers and might be slightly
smaller in size.


Nice cleanup.

 From one of the patches:


+config DRM_ARMADA_FBDEV_EMULATION
+ bool
+ depends on DRM_ARMADA
+ select FB_CFB_COPYAREA
+ select FB_CFB_FILLRECT
+ select FB_CFB_IMAGEBLIT


This seems like a hard to maintain way to select a few helper functions.
Today we have LD_DEAD_CODE_DATA_ELIMINATION for the configs that care
about size - and that should work here as well.


I wasn't too happy about this solution either as it is quite verbose. 
But I don't want to rely on the linker either. It certainly cannot 
remove exported symbols.


But the pattern is very common among the fbdev drivers. We could 
introduce common Kconfig options in fbdev and selcet those instead. Like 
this:


const FB_IO_HELPERS
bool
depends on FB
select FB_CFB_COPYAREA
select FB_CFB_FILLRECT
select FB_CFB_IMAGEBLIT

const FB_SYS_HELPERS
bool
depends on FB
select FB_SYS_COPYAREA
select FB_SYS_FILLRECT
select FB_SYS_FOPS
select FB_SYS_IMAGEBLIT

Apart from DRM, most of the fbdev drivers could use these as well.

Best regards
Thomas



I understand where this comes from and I am not against the
solution, but wanted to point at a more modern approach to deal with the
bloat.

Maybe some of the embbedded folks can tell if LD_DEAD_CODE_DATA_ELIMINATION
can be trusted yet or that is something for the future.

In barebox -ffunction-section (what LD_DEAD_CODE_DATA_ELIMINATION
enables) is used with success - there it really helps when generating
different barebox images where size matters a lot.

Sam


--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)


OpenPGP_signature
Description: OpenPGP digital signature


RE: [PATCH] drm/amdgpu: Remove IMU ucode in vf2pf

2023-05-12 Thread Chen, Horace
[AMD Official Use Only - General]

Reviewed-By: Horace Chen 

-Original Message-
From: YuanShang Mao (River) 
Sent: Tuesday, May 9, 2023 3:32 PM
To: amd-gfx@lists.freedesktop.org
Cc: Yin, ZhenGuo (Chris) ; Chen, Horace 
; YuanShang Mao (River) 
Subject: [PATCH] drm/amdgpu: Remove IMU ucode in vf2pf

The IMU firmware is loaded on the host side, not the guest.
Remove IMU in vf2pf ucode id enum.

Signed-off-by: YuanShang 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c| 1 -
 drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h | 1 -
 2 files changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
index 1311e42ab8e9..0af871735a74 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
@@ -557,7 +557,6 @@ static void amdgpu_virt_populate_vf2pf_ucode_info(struct 
amdgpu_device *adev)
POPULATE_UCODE_INFO(vf2pf_info, AMD_SRIOV_UCODE_ID_RLC_SRLS, 
adev->gfx.rlc_srls_fw_version);
POPULATE_UCODE_INFO(vf2pf_info, AMD_SRIOV_UCODE_ID_MEC,  
adev->gfx.mec_fw_version);
POPULATE_UCODE_INFO(vf2pf_info, AMD_SRIOV_UCODE_ID_MEC2, 
adev->gfx.mec2_fw_version);
-   POPULATE_UCODE_INFO(vf2pf_info, AMD_SRIOV_UCODE_ID_IMU,  
adev->gfx.imu_fw_version);
POPULATE_UCODE_INFO(vf2pf_info, AMD_SRIOV_UCODE_ID_SOS,  
adev->psp.sos.fw_version);
POPULATE_UCODE_INFO(vf2pf_info, AMD_SRIOV_UCODE_ID_ASD,
adev->psp.asd_context.bin_desc.fw_version);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h 
b/drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h
index 24d42d24e6a0..104a5ad8397d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h
@@ -70,7 +70,6 @@ enum amd_sriov_ucode_engine_id {
AMD_SRIOV_UCODE_ID_RLC_SRLS,
AMD_SRIOV_UCODE_ID_MEC,
AMD_SRIOV_UCODE_ID_MEC2,
-   AMD_SRIOV_UCODE_ID_IMU,
AMD_SRIOV_UCODE_ID_SOS,
AMD_SRIOV_UCODE_ID_ASD,
AMD_SRIOV_UCODE_ID_TA_RAS,
--
2.25.1



Re: [PATCH 00/11] drm/fbdev: Remove DRM's helpers for fbdev I/O

2023-05-12 Thread Sam Ravnborg
Hi Thomas,

On Fri, May 12, 2023 at 10:41:41AM +0200, Thomas Zimmermann wrote:
> DRM provides a number of wrappers around fbdev cfb_() sys_(), fb_io_()
> and fb_sys_() helpers. The DRM functions don't provide any additional
> functionality for most DRM drivers. So remove them and call the fbdev
> I/O helpers directly.
> 
> The DRM fbdev I/O wrappers were originally added because 
> does not protect its content with CONFIG_FB. DRM fbdev emulation did
> not build if the the config option had been disabled. This has been
> fixed. For fbdev-generic and i915, the wrappers added support for damage
> handling. But this is better handled within the two callers, as each
> is special in its damage handling.
> 
> Patches 1 to 8 replace the DRM wrappers in a number of fbdev emulations.
> Patch 9 exports two helpers for damage handling. Patches 10 and 11
> update fbdev-generic and i915 with the help of the exported functions.
> The patches also remove DRM's fbdev I/O helpers, which are now unused.
> 
> DRM's fbdev helpers had to select fbdev I/O helpers for I/O and for
> system memory. Each fbdev emulation now selects the correct helpers
> for itself. Depending on the selected DRM drivers, kernel builds will
> now only contain the necessary fbdev I/O helpers and might be slightly
> smaller in size.

Nice cleanup.

>From one of the patches:

> +config DRM_ARMADA_FBDEV_EMULATION
> + bool
> + depends on DRM_ARMADA
> + select FB_CFB_COPYAREA
> + select FB_CFB_FILLRECT
> + select FB_CFB_IMAGEBLIT

This seems like a hard to maintain way to select a few helper functions.
Today we have LD_DEAD_CODE_DATA_ELIMINATION for the configs that care
about size - and that should work here as well.

I understand where this comes from and I am not against the
solution, but wanted to point at a more modern approach to deal with the
bloat.

Maybe some of the embbedded folks can tell if LD_DEAD_CODE_DATA_ELIMINATION
can be trusted yet or that is something for the future.

In barebox -ffunction-section (what LD_DEAD_CODE_DATA_ELIMINATION
enables) is used with success - there it really helps when generating
different barebox images where size matters a lot.

Sam


Re: Fwd: Linux 6.3.1 + AMD RX 570 on ppc64le 4K: Kernel attempted to read user page (1128) - exploit attempt? (uid: 0)

2023-05-12 Thread Michael Ellerman
Bagas Sanjaya  writes:
> Hi,
>
> I notice a regression report on bugzilla ([1]). As many developers
> don't keep an eye on it, I decide to forward it by email.

Bugs filed against powerpc do get Cc'ed to linuxppc-dev, so we do see
them. Though that doesn't always mean we have time to fix them :)

I have a talos machine with an AMD GPU, but not this model, and mainline
is booting fine for me. So we'll need the original reporter to do some
more debugging.

Looks like there's a possible culprit identified on the gitlab issue:
https://gitlab.freedesktop.org/drm/amd/-/issues/2553

cheers

> Quoting from it:
>
>>  darkbasic 2023-05-10 13:36:37 UTC
>> 
>> I'm using Gentoo Linux on a Raptor CS Talos 2 ppc64le, GPU is an AMD RX 570. 
>> So far the past dozen of kernels (up to 6.2.14) worked flawlessly, but with 
>> 6.3.1 I don't get any video output and I get the following in journalctl:
>> 
>> May 10 15:09:01 talos2 kernel: Kernel attempted to read user page (1128) - 
>> exploit attempt? (uid: 0)
>> May 10 15:09:01 talos2 kernel: BUG: Unable to handle kernel data access on 
>> read at 0x1128
>> May 10 15:09:01 talos2 kernel: Faulting instruction address: 
>> 0xc0080d1a805c
>> May 10 15:09:01 talos2 kernel: Oops: Kernel access of bad area, sig: 11 [#1]
>> May 10 15:09:01 talos2 kernel: LE PAGE_SIZE=4K MMU=Radix SMP NR_CPUS=512 
>> NUMA PowerNV
>> May 10 15:09:01 talos2 kernel: Modules linked in: rfkill(+) 8021q garp mrp 
>> stp llc binfmt_misc amdgpu uvcvideo uvc videobuf2_vmalloc videobuf2_memops 
>> gpu_sched snd_hda_codec_hdmi i2c_algo_bit at24(+) videobuf2_v4l2 
>> drm_ttm_helper regmap_i2c videobuf2_common ttm snd_usb_audio drm_di>
>> May 10 15:09:01 talos2 kernel: CPU: 0 PID: 188 Comm: kworker/0:3 Not tainted 
>> 6.3.1-gentoo-dist #1
>> May 10 15:09:01 talos2 kernel: Hardware name: T2P9S01 REV 1.01 POWER9 
>> 0x4e1202 opal:skiboot-9858186 PowerNV
>> May 10 15:09:01 talos2 kernel: Workqueue: events_long 
>> drm_dp_check_and_send_link_address [drm_display_helper]
>> May 10 15:09:01 talos2 kernel: NIP:  c0080d1a805c LR: c0080d1a8018 
>> CTR: c0c87900
>> May 10 15:09:01 talos2 kernel: REGS: cbeb3370 TRAP: 0300   Not 
>> tainted  (6.3.1-gentoo-dist)
>> May 10 15:09:01 talos2 kernel: MSR:  9280b033 
>>   CR: 88048223  XER: 005a
>> May 10 15:09:01 talos2 kernel: CFAR: c0c87980 DAR: 1128 
>> DSISR: 4000 IRQMASK: 0 
>>GPR00: c0080d1a8018 cbeb3610 
>> c0080d690f00  
>>GPR04: 0002 c0080d6297c0 
>>  c0002a00b740 
>>GPR08:  1124 
>>  c0080d431560 
>>GPR12: c0c87900 c2a6b000 
>> c0170ad8 c0001a460310 
>>GPR16: 0045 c00022858388 
>> c00026000340 0001 
>>GPR20:  0001 
>> c000260001a0 4000 
>>GPR24: 4000 c0002610 
>> c000228580b8 fffd 
>>GPR28:  c000228580a0 
>> c00022856000 c00022858000 
>> May 10 15:09:01 talos2 kernel: NIP [c0080d1a805c] 
>> is_synaptics_cascaded_panamera+0x244/0x600 [amdgpu]
>> May 10 15:09:01 talos2 kernel: LR [c0080d1a8018] 
>> is_synaptics_cascaded_panamera+0x200/0x600 [amdgpu]
>> May 10 15:09:01 talos2 kernel: Call Trace:
>> May 10 15:09:01 talos2 kernel: [cbeb3610] [c0080d1a8018] 
>> is_synaptics_cascaded_panamera+0x200/0x600 [amdgpu] (unreliable)
>> May 10 15:09:01 talos2 kernel: [cbeb36d0] [c0080b7c2b18] 
>> drm_helper_probe_single_connector_modes+0x230/0x698 [drm_kms_helper]
>> May 10 15:09:01 talos2 kernel: [cbeb3810] [c0c57174] 
>> drm_client_modeset_probe+0x2b4/0x16c0
>> May 10 15:09:01 talos2 kernel: [cbeb3a10] [c0080b7c7a30] 
>> __drm_fb_helper_initial_config_and_unlock+0x68/0x640 [drm_kms_helper]
>> May 10 15:09:01 talos2 kernel: [cbeb3af0] [c0080b7c5b08] 
>> drm_fbdev_client_hotplug+0x40/0x1d0 [drm_kms_helper]
>> May 10 15:09:01 talos2 kernel: [cbeb3b70] [c0c55480] 
>> drm_client_dev_hotplug+0x120/0x1b0
>> May 10 15:09:01 talos2 kernel: [cbeb3c00] [c0080b7c1130] 
>> drm_kms_helper_hotplug_event+0x58/0x80 [drm_kms_helper]
>> May 10 15:09:01 talos2 kernel: [cbeb3c30] [c0080b80b298] 
>> drm_dp_check_and_send_link_address+0x330/0x3a0 [drm_display_helper]
>> May 10 15:09:01 talos2 kernel: [cbeb3cd0] [c0162d84] 
>> process_one_work+0x2f4/0x580
>> May 10 15:09:01 talos2 kernel: [cbeb3d70] [c01630b8] 
>> worker_thread+0xa8/0x600
>> May 10 15:09:01 talos2 kernel: [cbeb3e00] [c0170bf4] 
>> kthread+0x124/0x130
>> May 10 15:09:01 talos2 kernel: 

[PATCH] drm/amd/display: Simplify the calculation of variables

2023-05-12 Thread Jiapeng Chong
./drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.c:586:37-39: WARNING !A || A 
&& B is equivalent to !A || B.
./drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.c:595:37-39: WARNING !A || A 
&& B is equivalent to !A || B.

Reported-by: Abaci Robot 
Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=4941
Signed-off-by: Jiapeng Chong 
---
 drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.c 
b/drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.c
index 4950eaa4406b..2de910e0ce75 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.c
@@ -583,8 +583,8 @@ void dcn32_update_force_pstate(struct dc *dc, struct 
dc_state *context)
struct pipe_ctx *pipe = >res_ctx.pipe_ctx[i];
struct hubp *hubp = pipe->plane_res.hubp;
 
-   if (!pipe->stream || (pipe->stream && 
!(pipe->stream->mall_stream_config.type == SUBVP_MAIN ||
-   pipe->stream->fpo_in_use))) {
+   if (!pipe->stream || !(pipe->stream->mall_stream_config.type == 
SUBVP_MAIN ||
+   pipe->stream->fpo_in_use)) {
if (hubp && 
hubp->funcs->hubp_update_force_pstate_disallow)

hubp->funcs->hubp_update_force_pstate_disallow(hubp, false);
}
@@ -592,7 +592,7 @@ void dcn32_update_force_pstate(struct dc *dc, struct 
dc_state *context)
/* Today only FPO uses cursor P-State force. Only clear cursor 
P-State force
 * if it's not FPO.
 */
-   if (!pipe->stream || (pipe->stream && 
!pipe->stream->fpo_in_use)) {
+   if (!pipe->stream || !pipe->stream->fpo_in_use) {
if (hubp && 
hubp->funcs->hubp_update_force_cursor_pstate_disallow)

hubp->funcs->hubp_update_force_cursor_pstate_disallow(hubp, false);
}
-- 
2.20.1.7.g153144c



Re: Fwd: Linux 6.3.1 + AMD RX 570 on ppc64le 4K: Kernel attempted to read user page (1128) - exploit attempt? (uid: 0)

2023-05-12 Thread Bagas Sanjaya
On 5/11/23 15:06, Bagas Sanjaya wrote:
> Hi,
> 
> I notice a regression report on bugzilla ([1]). As many developers
> don't keep an eye on it, I decide to forward it by email.
> 
> Quoting from it:
> 
>>  darkbasic 2023-05-10 13:36:37 UTC
>>
>> I'm using Gentoo Linux on a Raptor CS Talos 2 ppc64le, GPU is an AMD RX 570. 
>> So far the past dozen of kernels (up to 6.2.14) worked flawlessly, but with 
>> 6.3.1 I don't get any video output and I get the following in journalctl:
>>
>> May 10 15:09:01 talos2 kernel: Kernel attempted to read user page (1128) - 
>> exploit attempt? (uid: 0)
>> May 10 15:09:01 talos2 kernel: BUG: Unable to handle kernel data access on 
>> read at 0x1128
>> May 10 15:09:01 talos2 kernel: Faulting instruction address: 
>> 0xc0080d1a805c
>> May 10 15:09:01 talos2 kernel: Oops: Kernel access of bad area, sig: 11 [#1]
>> May 10 15:09:01 talos2 kernel: LE PAGE_SIZE=4K MMU=Radix SMP NR_CPUS=512 
>> NUMA PowerNV
>> May 10 15:09:01 talos2 kernel: Modules linked in: rfkill(+) 8021q garp mrp 
>> stp llc binfmt_misc amdgpu uvcvideo uvc videobuf2_vmalloc videobuf2_memops 
>> gpu_sched snd_hda_codec_hdmi i2c_algo_bit at24(+) videobuf2_v4l2 
>> drm_ttm_helper regmap_i2c videobuf2_common ttm snd_usb_audio drm_di>
>> May 10 15:09:01 talos2 kernel: CPU: 0 PID: 188 Comm: kworker/0:3 Not tainted 
>> 6.3.1-gentoo-dist #1
>> May 10 15:09:01 talos2 kernel: Hardware name: T2P9S01 REV 1.01 POWER9 
>> 0x4e1202 opal:skiboot-9858186 PowerNV
>> May 10 15:09:01 talos2 kernel: Workqueue: events_long 
>> drm_dp_check_and_send_link_address [drm_display_helper]
>> May 10 15:09:01 talos2 kernel: NIP:  c0080d1a805c LR: c0080d1a8018 
>> CTR: c0c87900
>> May 10 15:09:01 talos2 kernel: REGS: cbeb3370 TRAP: 0300   Not 
>> tainted  (6.3.1-gentoo-dist)
>> May 10 15:09:01 talos2 kernel: MSR:  9280b033 
>>   CR: 88048223  XER: 005a
>> May 10 15:09:01 talos2 kernel: CFAR: c0c87980 DAR: 1128 
>> DSISR: 4000 IRQMASK: 0 
>>GPR00: c0080d1a8018 cbeb3610 
>> c0080d690f00  
>>GPR04: 0002 c0080d6297c0 
>>  c0002a00b740 
>>GPR08:  1124 
>>  c0080d431560 
>>GPR12: c0c87900 c2a6b000 
>> c0170ad8 c0001a460310 
>>GPR16: 0045 c00022858388 
>> c00026000340 0001 
>>GPR20:  0001 
>> c000260001a0 4000 
>>GPR24: 4000 c0002610 
>> c000228580b8 fffd 
>>GPR28:  c000228580a0 
>> c00022856000 c00022858000 
>> May 10 15:09:01 talos2 kernel: NIP [c0080d1a805c] 
>> is_synaptics_cascaded_panamera+0x244/0x600 [amdgpu]
>> May 10 15:09:01 talos2 kernel: LR [c0080d1a8018] 
>> is_synaptics_cascaded_panamera+0x200/0x600 [amdgpu]
>> May 10 15:09:01 talos2 kernel: Call Trace:
>> May 10 15:09:01 talos2 kernel: [cbeb3610] [c0080d1a8018] 
>> is_synaptics_cascaded_panamera+0x200/0x600 [amdgpu] (unreliable)
>> May 10 15:09:01 talos2 kernel: [cbeb36d0] [c0080b7c2b18] 
>> drm_helper_probe_single_connector_modes+0x230/0x698 [drm_kms_helper]
>> May 10 15:09:01 talos2 kernel: [cbeb3810] [c0c57174] 
>> drm_client_modeset_probe+0x2b4/0x16c0
>> May 10 15:09:01 talos2 kernel: [cbeb3a10] [c0080b7c7a30] 
>> __drm_fb_helper_initial_config_and_unlock+0x68/0x640 [drm_kms_helper]
>> May 10 15:09:01 talos2 kernel: [cbeb3af0] [c0080b7c5b08] 
>> drm_fbdev_client_hotplug+0x40/0x1d0 [drm_kms_helper]
>> May 10 15:09:01 talos2 kernel: [cbeb3b70] [c0c55480] 
>> drm_client_dev_hotplug+0x120/0x1b0
>> May 10 15:09:01 talos2 kernel: [cbeb3c00] [c0080b7c1130] 
>> drm_kms_helper_hotplug_event+0x58/0x80 [drm_kms_helper]
>> May 10 15:09:01 talos2 kernel: [cbeb3c30] [c0080b80b298] 
>> drm_dp_check_and_send_link_address+0x330/0x3a0 [drm_display_helper]
>> May 10 15:09:01 talos2 kernel: [cbeb3cd0] [c0162d84] 
>> process_one_work+0x2f4/0x580
>> May 10 15:09:01 talos2 kernel: [cbeb3d70] [c01630b8] 
>> worker_thread+0xa8/0x600
>> May 10 15:09:01 talos2 kernel: [cbeb3e00] [c0170bf4] 
>> kthread+0x124/0x130
>> May 10 15:09:01 talos2 kernel: [cbeb3e50] [c000dd14] 
>> ret_from_kernel_thread+0x5c/0x64
>> May 10 15:09:01 talos2 kernel: --- interrupt: 0 at 0x0
>> May 10 15:09:01 talos2 kernel: NIP:   LR:  
>> CTR: 
>> May 10 15:09:01 talos2 kernel: REGS: cbeb3e80 TRAP:    Not 
>> tainted  (6.3.1-gentoo-dist)
>> May 10 15:09:01 talos2 kernel: MSR:   <>  CR: 

Re: Fwd: Linux 6.3.1 + AMD RX 570 on ppc64le 4K: Kernel attempted to read user page (1128) - exploit attempt? (uid: 0)

2023-05-12 Thread Niccolò Belli

Il 2023-05-12 10:32 Bagas Sanjaya ha scritto:

#regzbot introduced: f4f3b7dedbe849
#regzbot link: https://gitlab.freedesktop.org/drm/amd/-/issues/2553


It doesn't look like the aforementioned patch made its way into 6.3 yet:

niko@talos2 ~/devel/linux-stable $ git branch
* linux-6.3.y
  master
niko@talos2 ~/devel/linux-stable $ git show f4f3b7dedbe8 | patch -p1
patching file 
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c

Hunk #1 succeeded at 227 (offset 15 lines).
Hunk #2 succeeded at 269 with fuzz 2 (offset 19 lines).
patching file 
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.h

Hunk #1 succeeded at 49 with fuzz 2 (offset 15 lines).


[PATCH 05/11] drm/fbdev-dma: Use regular fbdev I/O helpers

2023-05-12 Thread Thomas Zimmermann
Use the regular fbdev helpers for framebuffer I/O instead of DRM's
helpers. Fbdev-dma does not use damage handling, so DRM's fbdev helpers
are mere wrappers around the fbdev code.

Add CONFIG_DRM_FBDEV_DMA_EMULATION to select the necessary
Kconfig options automatically. Make fbdev emulation depend on
the new config option.

By using fbdev helpers directly within each DRM fbdev emulation,
we can eventually remove DRM's wrapper functions entirely.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/Kconfig |  9 +
 drivers/gpu/drm/Makefile|  2 +-
 drivers/gpu/drm/drm_fbdev_dma.c | 12 +++-
 include/drm/drm_fbdev_dma.h |  2 +-
 4 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index ba3fb04bb691..c007cb75715e 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -223,9 +223,18 @@ config DRM_TTM_HELPER
 config DRM_GEM_DMA_HELPER
tristate
depends on DRM
+   select DRM_FBDEV_DMA_EMULATION if DRM_FBDEV_EMULATION
help
  Choose this if you need the GEM DMA helper functions
 
+config DRM_FBDEV_DMA_EMULATION
+   bool
+   depends on DRM_GEM_DMA_HELPER
+   select FB_SYS_COPYAREA
+   select FB_SYS_FILLRECT
+   select FB_SYS_FOPS
+   select FB_SYS_IMAGEBLIT
+
 config DRM_GEM_SHMEM_HELPER
tristate
depends on DRM && MMU
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index a33257d2bc7f..d94821d37c2d 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -82,7 +82,7 @@ obj-$(CONFIG_DRM_PANEL_ORIENTATION_QUIRKS) += 
drm_panel_orientation_quirks.o
 obj-$(CONFIG_DRM_BUDDY) += drm_buddy.o
 
 drm_dma_helper-y := drm_gem_dma_helper.o
-drm_dma_helper-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fbdev_dma.o
+drm_dma_helper-$(CONFIG_DRM_FBDEV_DMA_EMULATION) += drm_fbdev_dma.o
 drm_dma_helper-$(CONFIG_DRM_KMS_HELPER) += drm_fb_dma_helper.o
 obj-$(CONFIG_DRM_GEM_DMA_HELPER) += drm_dma_helper.o
 
diff --git a/drivers/gpu/drm/drm_fbdev_dma.c b/drivers/gpu/drm/drm_fbdev_dma.c
index 728deffcc0d9..09a36dc38c43 100644
--- a/drivers/gpu/drm/drm_fbdev_dma.c
+++ b/drivers/gpu/drm/drm_fbdev_dma.c
@@ -1,5 +1,7 @@
 // SPDX-License-Identifier: MIT
 
+#include 
+
 #include 
 #include 
 #include 
@@ -64,12 +66,12 @@ static const struct fb_ops drm_fbdev_dma_fb_ops = {
.owner = THIS_MODULE,
.fb_open = drm_fbdev_dma_fb_open,
.fb_release = drm_fbdev_dma_fb_release,
-   .fb_read = drm_fb_helper_sys_read,
-   .fb_write = drm_fb_helper_sys_write,
+   .fb_read = fb_sys_read,
+   .fb_write = fb_sys_write,
DRM_FB_HELPER_DEFAULT_OPS,
-   .fb_fillrect = drm_fb_helper_sys_fillrect,
-   .fb_copyarea = drm_fb_helper_sys_copyarea,
-   .fb_imageblit = drm_fb_helper_sys_imageblit,
+   .fb_fillrect = sys_fillrect,
+   .fb_copyarea = sys_copyarea,
+   .fb_imageblit = sys_imageblit,
.fb_destroy = drm_fbdev_dma_fb_destroy,
.fb_mmap = drm_fbdev_dma_fb_mmap,
 };
diff --git a/include/drm/drm_fbdev_dma.h b/include/drm/drm_fbdev_dma.h
index 2da7ee784133..3e96ad069136 100644
--- a/include/drm/drm_fbdev_dma.h
+++ b/include/drm/drm_fbdev_dma.h
@@ -5,7 +5,7 @@
 
 struct drm_device;
 
-#ifdef CONFIG_DRM_FBDEV_EMULATION
+#if defined(CONFIG_DRM_FBDEV_DMA_EMULATION)
 void drm_fbdev_dma_setup(struct drm_device *dev, unsigned int preferred_bpp);
 #else
 static inline void drm_fbdev_dma_setup(struct drm_device *dev, unsigned int 
preferred_bpp)
-- 
2.40.1



[PATCH 10/11] drm/fbdev-generic: Implement dedicated fbdev I/O helpers

2023-05-12 Thread Thomas Zimmermann
Implement dedicated fbdev helpers for framebuffer I/O instead
of using DRM's helpers. Fbdev-generic was the only caller of the
DRM helpers, so remove them from the helper module.

Add CONFIG_DRM_FBDEV_GENERIC_EMULATION to select the necessary
Kconfig options automatically. Make fbdev emulation depend on
the new config option.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/Kconfig |  15 ++--
 drivers/gpu/drm/Makefile|   5 +-
 drivers/gpu/drm/drm_fb_helper.c | 107 
 drivers/gpu/drm/drm_fbdev_generic.c |  47 ++--
 include/drm/drm_fb_helper.h |  41 ---
 include/drm/drm_fbdev_generic.h |   2 +-
 6 files changed, 55 insertions(+), 162 deletions(-)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index c007cb75715e..c67c97471b3c 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -95,9 +95,19 @@ config DRM_KUNIT_TEST
 config DRM_KMS_HELPER
tristate
depends on DRM
+   select DRM_FBDEV_GENERIC_EMULATION if DRM_FBDEV_EMULATION
help
  CRTC helpers for KMS drivers.
 
+config DRM_FBDEV_GENERIC_EMULATION
+   bool
+   depends on DRM_KMS_HELPER
+   select FB_DEFERRED_IO
+   select FB_SYS_COPYAREA
+   select FB_SYS_FILLRECT
+   select FB_SYS_FOPS
+   select FB_SYS_IMAGEBLIT
+
 config DRM_DEBUG_DP_MST_TOPOLOGY_REFS
 bool "Enable refcount backtrace history in the DP MST helpers"
depends on STACKTRACE_SUPPORT
@@ -135,11 +145,6 @@ config DRM_FBDEV_EMULATION
select FB_CFB_FILLRECT
select FB_CFB_COPYAREA
select FB_CFB_IMAGEBLIT
-   select FB_DEFERRED_IO
-   select FB_SYS_FOPS
-   select FB_SYS_FILLRECT
-   select FB_SYS_COPYAREA
-   select FB_SYS_IMAGEBLIT
select FRAMEBUFFER_CONSOLE if !EXPERT
select FRAMEBUFFER_CONSOLE_DETECT_PRIMARY if FRAMEBUFFER_CONSOLE
default y
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index d94821d37c2d..f737f0e476b5 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -121,9 +121,8 @@ drm_kms_helper-y := \
drm_self_refresh_helper.o \
drm_simple_kms_helper.o
 drm_kms_helper-$(CONFIG_DRM_PANEL_BRIDGE) += bridge/panel.o
-drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += \
-   drm_fbdev_generic.o \
-   drm_fb_helper.o
+drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fb_helper.o
+drm_kms_helper-$(CONFIG_DRM_FBDEV_GENERIC_EMULATION) += drm_fbdev_generic.o
 obj-$(CONFIG_DRM_KMS_HELPER) += drm_kms_helper.o
 
 #
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 8724e08c518b..ba0a808f14ee 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -729,113 +729,6 @@ void drm_fb_helper_deferred_io(struct fb_info *info, 
struct list_head *pagerefli
 }
 EXPORT_SYMBOL(drm_fb_helper_deferred_io);
 
-/**
- * drm_fb_helper_sys_read - Implements struct _ops.fb_read for system memory
- * @info: fb_info struct pointer
- * @buf: userspace buffer to read from framebuffer memory
- * @count: number of bytes to read from framebuffer memory
- * @ppos: read offset within framebuffer memory
- *
- * Returns:
- * The number of bytes read on success, or an error code otherwise.
- */
-ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf,
-  size_t count, loff_t *ppos)
-{
-   return fb_sys_read(info, buf, count, ppos);
-}
-EXPORT_SYMBOL(drm_fb_helper_sys_read);
-
-/**
- * drm_fb_helper_sys_write - Implements struct _ops.fb_write for system 
memory
- * @info: fb_info struct pointer
- * @buf: userspace buffer to write to framebuffer memory
- * @count: number of bytes to write to framebuffer memory
- * @ppos: write offset within framebuffer memory
- *
- * Returns:
- * The number of bytes written on success, or an error code otherwise.
- */
-ssize_t drm_fb_helper_sys_write(struct fb_info *info, const char __user *buf,
-   size_t count, loff_t *ppos)
-{
-   struct drm_fb_helper *helper = info->par;
-   loff_t pos = *ppos;
-   ssize_t ret;
-   struct drm_rect damage_area;
-
-   ret = fb_sys_write(info, buf, count, ppos);
-   if (ret <= 0)
-   return ret;
-
-   if (helper->funcs->fb_dirty) {
-   drm_fb_helper_memory_range_to_clip(info, pos, ret, 
_area);
-   drm_fb_helper_damage(helper, damage_area.x1, damage_area.y1,
-drm_rect_width(_area),
-drm_rect_height(_area));
-   }
-
-   return ret;
-}
-EXPORT_SYMBOL(drm_fb_helper_sys_write);
-
-/**
- * drm_fb_helper_sys_fillrect - wrapper around sys_fillrect
- * @info: fbdev registered by the helper
- * @rect: info about rectangle to fill
- *
- * A wrapper around sys_fillrect implemented by fbdev core
- */
-void drm_fb_helper_sys_fillrect(struct fb_info *info,
-

[PATCH 06/11] drm/msm: Use regular fbdev I/O helpers

2023-05-12 Thread Thomas Zimmermann
Use the regular fbdev helpers for framebuffer I/O instead of DRM's
helpers. Msm does not use damage handling, so DRM's fbdev helpers
are mere wrappers around the fbdev code.

Add CONFIG_DRM_MSM_FBDEV_EMULATION to select the necessary
Kconfig options automatically. Make fbdev emulation depend on
the new config option.

By using fbdev helpers directly within each DRM fbdev emulation,
we can eventually remove DRM's wrapper functions entirely.

Signed-off-by: Thomas Zimmermann 
Cc: Rob Clark 
Cc: Abhinav Kumar 
Cc: Dmitry Baryshkov 
Cc: Sean Paul 
---
 drivers/gpu/drm/msm/Kconfig |  9 +
 drivers/gpu/drm/msm/Makefile|  2 +-
 drivers/gpu/drm/msm/msm_drv.h   |  2 +-
 drivers/gpu/drm/msm/msm_fbdev.c | 12 +++-
 4 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/msm/Kconfig b/drivers/gpu/drm/msm/Kconfig
index 85f5ab1d552c..91a20cd77b83 100644
--- a/drivers/gpu/drm/msm/Kconfig
+++ b/drivers/gpu/drm/msm/Kconfig
@@ -17,6 +17,7 @@ config DRM_MSM
select DRM_DISPLAY_DP_HELPER
select DRM_DISPLAY_HELPER
select DRM_KMS_HELPER
+   select DRM_MSM_FBDEV_EMULATION if DRM_FBDEV_EMULATION
select DRM_PANEL
select DRM_BRIDGE
select DRM_PANEL_BRIDGE
@@ -165,3 +166,11 @@ config DRM_MSM_HDMI_HDCP
default y
help
  Choose this option to enable HDCP state machine
+
+config DRM_MSM_FBDEV_EMULATION
+   bool
+   depends on DRM_MSM
+   select FB_SYS_COPYAREA
+   select FB_SYS_FILLRECT
+   select FB_SYS_FOPS
+   select FB_SYS_IMAGEBLIT
diff --git a/drivers/gpu/drm/msm/Makefile b/drivers/gpu/drm/msm/Makefile
index 7274c41228ed..552491ab4f4f 100644
--- a/drivers/gpu/drm/msm/Makefile
+++ b/drivers/gpu/drm/msm/Makefile
@@ -129,7 +129,7 @@ msm-$(CONFIG_DRM_MSM_DP)+= dp/dp_aux.o \
dp/dp_power.o \
dp/dp_audio.o
 
-msm-$(CONFIG_DRM_FBDEV_EMULATION) += msm_fbdev.o
+msm-$(CONFIG_DRM_MSM_FBDEV_EMULATION) += msm_fbdev.o
 
 msm-$(CONFIG_DRM_MSM_HDMI_HDCP) += hdmi/hdmi_hdcp.o
 
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
index e13a8cbd61c9..eb09589fc9f7 100644
--- a/drivers/gpu/drm/msm/msm_drv.h
+++ b/drivers/gpu/drm/msm/msm_drv.h
@@ -304,7 +304,7 @@ struct drm_framebuffer *msm_framebuffer_create(struct 
drm_device *dev,
 struct drm_framebuffer * msm_alloc_stolen_fb(struct drm_device *dev,
int w, int h, int p, uint32_t format);
 
-#ifdef CONFIG_DRM_FBDEV_EMULATION
+#if defined(CONFIG_DRM_MSM_FBDEV_EMULATION)
 void msm_fbdev_setup(struct drm_device *dev);
 #else
 static inline void msm_fbdev_setup(struct drm_device *dev)
diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c
index 2ebc86381e1c..fc0353a4160e 100644
--- a/drivers/gpu/drm/msm/msm_fbdev.c
+++ b/drivers/gpu/drm/msm/msm_fbdev.c
@@ -4,6 +4,8 @@
  * Author: Rob Clark 
  */
 
+#include 
+
 #include 
 #include 
 #include 
@@ -57,11 +59,11 @@ static const struct fb_ops msm_fb_ops = {
/* Note: to properly handle manual update displays, we wrap the
 * basic fbdev ops which write to the framebuffer
 */
-   .fb_read = drm_fb_helper_sys_read,
-   .fb_write = drm_fb_helper_sys_write,
-   .fb_fillrect = drm_fb_helper_sys_fillrect,
-   .fb_copyarea = drm_fb_helper_sys_copyarea,
-   .fb_imageblit = drm_fb_helper_sys_imageblit,
+   .fb_read = fb_sys_read,
+   .fb_write = fb_sys_write,
+   .fb_fillrect = sys_fillrect,
+   .fb_copyarea = sys_copyarea,
+   .fb_imageblit = sys_imageblit,
.fb_mmap = msm_fbdev_mmap,
.fb_destroy = msm_fbdev_fb_destroy,
 };
-- 
2.40.1



[PATCH 09/11] drm/fb-helper: Export helpers for marking damage areas

2023-05-12 Thread Thomas Zimmermann
Export drm_fb_helper_damage() and drm_fb_helper_damage_range(), which
handle damage areas for fbdev emulation. This is a temporary export
that allows to move the DRM I/O helpers for fbdev into drivers. Only
fbdev-generic and i915 need them. Both will be updated to implement
damage handling by themselves and the exported functions will be removed.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/drm_fb_helper.c | 19 +--
 include/drm/drm_fb_helper.h |  4 
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index f0e9549b6bd7..8724e08c518b 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -625,13 +625,15 @@ static void drm_fb_helper_add_damage_clip(struct 
drm_fb_helper *helper, u32 x, u
spin_unlock_irqrestore(>damage_lock, flags);
 }
 
-static void drm_fb_helper_damage(struct drm_fb_helper *helper, u32 x, u32 y,
-u32 width, u32 height)
+/* Don't use in new code. */
+void drm_fb_helper_damage(struct drm_fb_helper *helper, u32 x, u32 y,
+ u32 width, u32 height)
 {
drm_fb_helper_add_damage_clip(helper, x, y, width, height);
 
schedule_work(>damage_work);
 }
+EXPORT_SYMBOL(drm_fb_helper_damage);
 
 /*
  * Convert memory region into area of scanlines and pixels per
@@ -670,6 +672,19 @@ static void drm_fb_helper_memory_range_to_clip(struct 
fb_info *info, off_t off,
drm_rect_init(clip, x1, y1, x2 - x1, y2 - y1);
 }
 
+/* Don't use in new code. */
+void drm_fb_helper_damage_range(struct drm_fb_helper *fb_helper, off_t off, 
size_t len)
+{
+   struct fb_info *info = fb_helper->info;
+   struct drm_rect damage_area;
+
+   drm_fb_helper_memory_range_to_clip(info, off, len, _area);
+   drm_fb_helper_damage(fb_helper, damage_area.x1, damage_area.y1,
+drm_rect_width(_area),
+drm_rect_height(_area));
+}
+EXPORT_SYMBOL(drm_fb_helper_damage_range);
+
 /**
  * drm_fb_helper_deferred_io() - fbdev deferred_io callback function
  * @info: fb_info struct pointer
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index 72032c354a30..80c402f4e379 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -253,6 +253,10 @@ void drm_fb_helper_fill_info(struct fb_info *info,
 struct drm_fb_helper *fb_helper,
 struct drm_fb_helper_surface_size *sizes);
 
+void drm_fb_helper_damage(struct drm_fb_helper *helper, u32 x, u32 y,
+ u32 width, u32 height);
+void drm_fb_helper_damage_range(struct drm_fb_helper *helper, off_t off, 
size_t len);
+
 void drm_fb_helper_deferred_io(struct fb_info *info, struct list_head 
*pagereflist);
 
 ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf,
-- 
2.40.1



[PATCH 08/11] drm/tegra: Use regular fbdev I/O helpers

2023-05-12 Thread Thomas Zimmermann
Use the regular fbdev helpers for framebuffer I/O instead of DRM's
helpers. Tegra does not use damage handling, so DRM's fbdev helpers
are mere wrappers around the fbdev code.

Add CONFIG_DRM_TEGRA_FBDEV_EMULATION to select the necessary
Kconfig options automatically. Make fbdev emulation depend on
the new config option.

By using fbdev helpers directly within each DRM fbdev emulation,
we can eventually remove DRM's wrapper functions entirely.

Signed-off-by: Thomas Zimmermann 
Cc: Thierry Reding 
Cc: Mikko Perttunen 
Cc: Jonathan Hunter 
---
 drivers/gpu/drm/tegra/Kconfig  |  9 +
 drivers/gpu/drm/tegra/Makefile |  2 +-
 drivers/gpu/drm/tegra/drm.h|  2 +-
 drivers/gpu/drm/tegra/fbdev.c  | 11 ++-
 4 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/tegra/Kconfig b/drivers/gpu/drm/tegra/Kconfig
index 56453ca277c2..8d04549ad671 100644
--- a/drivers/gpu/drm/tegra/Kconfig
+++ b/drivers/gpu/drm/tegra/Kconfig
@@ -12,6 +12,7 @@ config DRM_TEGRA
select DRM_KMS_HELPER
select DRM_MIPI_DSI
select DRM_PANEL
+   select DRM_TEGRA_FBDEV_EMULATION if DRM_FBDEV_EMULATION
select TEGRA_HOST1X
select INTERCONNECT
select IOMMU_IOVA
@@ -41,3 +42,11 @@ config DRM_TEGRA_STAGING
  If unsure, choose N.
 
 endif
+
+config DRM_TEGRA_FBDEV_EMULATION
+   bool
+   depends on DRM_TEGRA
+   select FB_SYS_COPYAREA
+   select FB_SYS_FILLRECT
+   select FB_SYS_FOPS
+   select FB_SYS_IMAGEBLIT
diff --git a/drivers/gpu/drm/tegra/Makefile b/drivers/gpu/drm/tegra/Makefile
index 6fc4b504e786..2ae9fb5d9213 100644
--- a/drivers/gpu/drm/tegra/Makefile
+++ b/drivers/gpu/drm/tegra/Makefile
@@ -29,6 +29,6 @@ tegra-drm-y := \
 
 tegra-drm-y += trace.o
 
-tegra-drm-$(CONFIG_DRM_FBDEV_EMULATION) += fbdev.o
+tegra-drm-$(CONFIG_DRM_TEGRA_FBDEV_EMULATION) += fbdev.o
 
 obj-$(CONFIG_DRM_TEGRA) += tegra-drm.o
diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h
index f9d18e8cf6ab..874e93ef4e47 100644
--- a/drivers/gpu/drm/tegra/drm.h
+++ b/drivers/gpu/drm/tegra/drm.h
@@ -192,7 +192,7 @@ struct drm_framebuffer *tegra_fb_create(struct drm_device 
*drm,
struct drm_file *file,
const struct drm_mode_fb_cmd2 *cmd);
 
-#ifdef CONFIG_DRM_FBDEV_EMULATION
+#if defined(CONFIG_DRM_TEGRA_FBDEV_EMULATION)
 void tegra_fbdev_setup(struct drm_device *drm);
 #else
 static inline void tegra_fbdev_setup(struct drm_device *drm)
diff --git a/drivers/gpu/drm/tegra/fbdev.c b/drivers/gpu/drm/tegra/fbdev.c
index dca9eccae466..144d851e566f 100644
--- a/drivers/gpu/drm/tegra/fbdev.c
+++ b/drivers/gpu/drm/tegra/fbdev.c
@@ -8,6 +8,7 @@
  */
 
 #include 
+#include 
 #include 
 
 #include 
@@ -59,11 +60,11 @@ static void tegra_fbdev_fb_destroy(struct fb_info *info)
 static const struct fb_ops tegra_fb_ops = {
.owner = THIS_MODULE,
DRM_FB_HELPER_DEFAULT_OPS,
-   .fb_read = drm_fb_helper_sys_read,
-   .fb_write = drm_fb_helper_sys_write,
-   .fb_fillrect = drm_fb_helper_sys_fillrect,
-   .fb_copyarea = drm_fb_helper_sys_copyarea,
-   .fb_imageblit = drm_fb_helper_sys_imageblit,
+   .fb_read = fb_sys_read,
+   .fb_write = fb_sys_write,
+   .fb_fillrect = sys_fillrect,
+   .fb_copyarea = sys_copyarea,
+   .fb_imageblit = sys_imageblit,
.fb_mmap = tegra_fb_mmap,
.fb_destroy = tegra_fbdev_fb_destroy,
 };
-- 
2.40.1



[PATCH 02/11] drm/exynos: Use regular fbdev I/O helpers

2023-05-12 Thread Thomas Zimmermann
Use the regular fbdev helpers for framebuffer I/O instead of DRM's
helpers. Exynos does not use damage handling, so DRM's fbdev helpers
are mere wrappers around the fbdev code.

Add CONFIG_DRM_EXYNOS_FBDEV_EMULATION to select the necessary
Kconfig options automatically. Make fbdev emulation depend on
the new config option.

By using fbdev helpers directly within each DRM fbdev emulation,
we can eventually remove DRM's wrapper functions entirely.

Signed-off-by: Thomas Zimmermann 
Cc: Inki Dae 
Cc: Seung-Woo Kim 
Cc: Kyungmin Park 
Cc: Krzysztof Kozlowski 
Cc: Alim Akhtar 
---
 drivers/gpu/drm/exynos/Kconfig|  8 
 drivers/gpu/drm/exynos/Makefile   |  2 +-
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 10 +-
 drivers/gpu/drm/exynos/exynos_drm_fbdev.h |  2 +-
 4 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/exynos/Kconfig b/drivers/gpu/drm/exynos/Kconfig
index 0cb92d651ff1..c7ac07220e26 100644
--- a/drivers/gpu/drm/exynos/Kconfig
+++ b/drivers/gpu/drm/exynos/Kconfig
@@ -5,6 +5,7 @@ config DRM_EXYNOS
depends on ARCH_S3C64XX || ARCH_S5PV210 || ARCH_EXYNOS || COMPILE_TEST
depends on MMU
select DRM_DISPLAY_HELPER if DRM_EXYNOS_DP
+   select DRM_EXYNOS_FBDEV_EMULATION if DRM_FBDEV_EMULATION
select DRM_KMS_HELPER
select VIDEOMODE_HELPERS
select SND_SOC_HDMI_CODEC if SND_SOC
@@ -12,6 +13,13 @@ config DRM_EXYNOS
  Choose this option if you have a Samsung SoC Exynos chipset.
  If M is selected the module will be called exynosdrm.
 
+config DRM_EXYNOS_FBDEV_EMULATION
+   bool
+   depends on DRM_EXYNOS
+   select FB_CFB_COPYAREA
+   select FB_CFB_FILLRECT
+   select FB_CFB_IMAGEBLIT
+
 if DRM_EXYNOS
 
 comment "CRTCs"
diff --git a/drivers/gpu/drm/exynos/Makefile b/drivers/gpu/drm/exynos/Makefile
index 2fd2f3ee4fcf..a9278be4daf3 100644
--- a/drivers/gpu/drm/exynos/Makefile
+++ b/drivers/gpu/drm/exynos/Makefile
@@ -6,7 +6,7 @@
 exynosdrm-y := exynos_drm_drv.o exynos_drm_crtc.o exynos_drm_fb.o \
exynos_drm_gem.o exynos_drm_plane.o exynos_drm_dma.o
 
-exynosdrm-$(CONFIG_DRM_FBDEV_EMULATION) += exynos_drm_fbdev.o
+exynosdrm-$(CONFIG_DRM_EXYNOS_FBDEV_EMULATION) += exynos_drm_fbdev.o
 exynosdrm-$(CONFIG_DRM_EXYNOS_FIMD)+= exynos_drm_fimd.o
 exynosdrm-$(CONFIG_DRM_EXYNOS5433_DECON)   += exynos5433_drm_decon.o
 exynosdrm-$(CONFIG_DRM_EXYNOS7_DECON)  += exynos7_drm_decon.o
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c 
b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
index ea4b3d248aac..bdd1d087 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
@@ -8,6 +8,8 @@
  * Seung-Woo Kim 
  */
 
+#include 
+
 #include 
 #include 
 #include 
@@ -49,11 +51,9 @@ static const struct fb_ops exynos_drm_fb_ops = {
.owner  = THIS_MODULE,
DRM_FB_HELPER_DEFAULT_OPS,
.fb_mmap= exynos_drm_fb_mmap,
-   .fb_read= drm_fb_helper_cfb_read,
-   .fb_write   = drm_fb_helper_cfb_write,
-   .fb_fillrect= drm_fb_helper_cfb_fillrect,
-   .fb_copyarea= drm_fb_helper_cfb_copyarea,
-   .fb_imageblit   = drm_fb_helper_cfb_imageblit,
+   .fb_fillrect= cfb_fillrect,
+   .fb_copyarea= cfb_copyarea,
+   .fb_imageblit   = cfb_imageblit,
.fb_destroy = exynos_drm_fb_destroy,
 };
 
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.h 
b/drivers/gpu/drm/exynos/exynos_drm_fbdev.h
index 1e1dea627cd9..9a8425881ff1 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.h
@@ -11,7 +11,7 @@
 #ifndef _EXYNOS_DRM_FBDEV_H_
 #define _EXYNOS_DRM_FBDEV_H_
 
-#ifdef CONFIG_DRM_FBDEV_EMULATION
+#if defined(CONFIG_DRM_EXYNOS_FBDEV_EMULATION)
 void exynos_drm_fbdev_setup(struct drm_device *dev);
 #else
 static inline void exynos_drm_fbdev_setup(struct drm_device *dev)
-- 
2.40.1



[PATCH 01/11] drm/armada: Use regular fbdev I/O helpers

2023-05-12 Thread Thomas Zimmermann
Use the regular fbdev helpers for framebuffer I/O instead of DRM's
helpers. Armada does not use damage handling, so DRM's fbdev helpers
are mere wrappers around the fbdev code.

Add CONFIG_DRM_ARMADA_FBDEV_EMULATION to select the necessary
Kconfig options automatically. Make fbdev emulation depend on
the new config option.

By using fbdev helpers directly within each DRM fbdev emulation,
we can eventually remove DRM's wrapper functions entirely.

Signed-off-by: Thomas Zimmermann 
Cc: Russell King 
---
 drivers/gpu/drm/armada/Kconfig| 8 
 drivers/gpu/drm/armada/Makefile   | 2 +-
 drivers/gpu/drm/armada/armada_drm.h   | 2 +-
 drivers/gpu/drm/armada/armada_fbdev.c | 9 -
 4 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/armada/Kconfig b/drivers/gpu/drm/armada/Kconfig
index f5c66d89ba99..054265d6fd26 100644
--- a/drivers/gpu/drm/armada/Kconfig
+++ b/drivers/gpu/drm/armada/Kconfig
@@ -2,6 +2,7 @@
 config DRM_ARMADA
tristate "DRM support for Marvell Armada SoCs"
depends on DRM && HAVE_CLK && ARM && MMU
+   select DRM_ARMADA_FBDEV_EMULATION if DRM_FBDEV_EMULATION
select DRM_KMS_HELPER
help
  Support the "LCD" controllers found on the Marvell Armada 510
@@ -11,3 +12,10 @@ config DRM_ARMADA
  This driver provides no built-in acceleration; acceleration is
  performed by other IP found on the SoC.  This driver provides
  kernel mode setting and buffer management to userspace.
+
+config DRM_ARMADA_FBDEV_EMULATION
+   bool
+   depends on DRM_ARMADA
+   select FB_CFB_COPYAREA
+   select FB_CFB_FILLRECT
+   select FB_CFB_IMAGEBLIT
diff --git a/drivers/gpu/drm/armada/Makefile b/drivers/gpu/drm/armada/Makefile
index dc75a7db9ed3..1c5671c94506 100644
--- a/drivers/gpu/drm/armada/Makefile
+++ b/drivers/gpu/drm/armada/Makefile
@@ -3,6 +3,6 @@ armada-y:= armada_crtc.o armada_drv.o armada_fb.o \
   armada_gem.o armada_overlay.o armada_plane.o armada_trace.o
 armada-y   += armada_510.o
 armada-$(CONFIG_DEBUG_FS) += armada_debugfs.o
-armada-$(CONFIG_DRM_FBDEV_EMULATION) += armada_fbdev.o
+armada-$(CONFIG_DRM_ARMADA_FBDEV_EMULATION) += armada_fbdev.o
 
 obj-$(CONFIG_DRM_ARMADA) := armada.o
diff --git a/drivers/gpu/drm/armada/armada_drm.h 
b/drivers/gpu/drm/armada/armada_drm.h
index c303e8c7ff6c..23a21c0fbd16 100644
--- a/drivers/gpu/drm/armada/armada_drm.h
+++ b/drivers/gpu/drm/armada/armada_drm.h
@@ -73,7 +73,7 @@ struct armada_private {
 
 #define drm_to_armada_dev(dev) container_of(dev, struct armada_private, drm)
 
-#if defined(CONFIG_DRM_FBDEV_EMULATION)
+#if defined(CONFIG_DRM_ARMADA_FBDEV_EMULATION)
 void armada_fbdev_setup(struct drm_device *dev);
 #else
 static inline void armada_fbdev_setup(struct drm_device *dev)
diff --git a/drivers/gpu/drm/armada/armada_fbdev.c 
b/drivers/gpu/drm/armada/armada_fbdev.c
index 0a5fd1aa86eb..6c3bbaf53569 100644
--- a/drivers/gpu/drm/armada/armada_fbdev.c
+++ b/drivers/gpu/drm/armada/armada_fbdev.c
@@ -5,6 +5,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 
@@ -34,11 +35,9 @@ static void armada_fbdev_fb_destroy(struct fb_info *info)
 static const struct fb_ops armada_fb_ops = {
.owner  = THIS_MODULE,
DRM_FB_HELPER_DEFAULT_OPS,
-   .fb_read= drm_fb_helper_cfb_read,
-   .fb_write   = drm_fb_helper_cfb_write,
-   .fb_fillrect= drm_fb_helper_cfb_fillrect,
-   .fb_copyarea= drm_fb_helper_cfb_copyarea,
-   .fb_imageblit   = drm_fb_helper_cfb_imageblit,
+   .fb_fillrect= cfb_fillrect,
+   .fb_copyarea= cfb_copyarea,
+   .fb_imageblit   = cfb_imageblit,
.fb_destroy = armada_fbdev_fb_destroy,
 };
 
-- 
2.40.1



[PATCH 11/11] drm/i915: Implement dedicated fbdev I/O helpers

2023-05-12 Thread Thomas Zimmermann
Implement dedicated fbdev helpers for framebuffer I/O instead
of using DRM's helpers. i915 was the only caller of the DRM
helpers, so remove them from the helper module.

Add CONFIG_DRM_I915_FBDEV_EMULATION to select the necessary
Kconfig options automatically. Make fbdev emulation depend on
the new config option.

Signed-off-by: Thomas Zimmermann 
Cc: Jani Nikula 
Cc: Joonas Lahtinen 
Cc: Rodrigo Vivi 
Cc: Tvrtko Ursulin 
Cc: "Ville Syrjälä" 
---
 drivers/gpu/drm/Kconfig   |   3 -
 drivers/gpu/drm/drm_fb_helper.c   | 107 --
 drivers/gpu/drm/i915/Kconfig  |   8 ++
 drivers/gpu/drm/i915/Makefile |   2 +-
 .../drm/i915/display/intel_display_debugfs.c  |   2 +-
 drivers/gpu/drm/i915/display/intel_fbdev.c|  51 -
 drivers/gpu/drm/i915/display/intel_fbdev.h|   2 +-
 include/drm/drm_fb_helper.h   |  39 ---
 8 files changed, 56 insertions(+), 158 deletions(-)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index c67c97471b3c..cf8d5ec5a654 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -142,9 +142,6 @@ config DRM_FBDEV_EMULATION
bool "Enable legacy fbdev support for your modesetting driver"
depends on DRM_KMS_HELPER
depends on FB=y || FB=DRM_KMS_HELPER
-   select FB_CFB_FILLRECT
-   select FB_CFB_COPYAREA
-   select FB_CFB_IMAGEBLIT
select FRAMEBUFFER_CONSOLE if !EXPERT
select FRAMEBUFFER_CONSOLE_DETECT_PRIMARY if FRAMEBUFFER_CONSOLE
default y
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index ba0a808f14ee..5927896ad8f6 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -729,113 +729,6 @@ void drm_fb_helper_deferred_io(struct fb_info *info, 
struct list_head *pagerefli
 }
 EXPORT_SYMBOL(drm_fb_helper_deferred_io);
 
-/**
- * drm_fb_helper_cfb_read - Implements struct _ops.fb_read for I/O memory
- * @info: fb_info struct pointer
- * @buf: userspace buffer to read from framebuffer memory
- * @count: number of bytes to read from framebuffer memory
- * @ppos: read offset within framebuffer memory
- *
- * Returns:
- * The number of bytes read on success, or an error code otherwise.
- */
-ssize_t drm_fb_helper_cfb_read(struct fb_info *info, char __user *buf,
-  size_t count, loff_t *ppos)
-{
-   return fb_io_read(info, buf, count, ppos);
-}
-EXPORT_SYMBOL(drm_fb_helper_cfb_read);
-
-/**
- * drm_fb_helper_cfb_write - Implements struct _ops.fb_write for I/O memory
- * @info: fb_info struct pointer
- * @buf: userspace buffer to write to framebuffer memory
- * @count: number of bytes to write to framebuffer memory
- * @ppos: write offset within framebuffer memory
- *
- * Returns:
- * The number of bytes written on success, or an error code otherwise.
- */
-ssize_t drm_fb_helper_cfb_write(struct fb_info *info, const char __user *buf,
-   size_t count, loff_t *ppos)
-{
-   struct drm_fb_helper *helper = info->par;
-   loff_t pos = *ppos;
-   ssize_t ret;
-   struct drm_rect damage_area;
-
-   ret = fb_io_write(info, buf, count, ppos);
-   if (ret <= 0)
-   return ret;
-
-   if (helper->funcs->fb_dirty) {
-   drm_fb_helper_memory_range_to_clip(info, pos, ret, 
_area);
-   drm_fb_helper_damage(helper, damage_area.x1, damage_area.y1,
-drm_rect_width(_area),
-drm_rect_height(_area));
-   }
-
-   return ret;
-}
-EXPORT_SYMBOL(drm_fb_helper_cfb_write);
-
-/**
- * drm_fb_helper_cfb_fillrect - wrapper around cfb_fillrect
- * @info: fbdev registered by the helper
- * @rect: info about rectangle to fill
- *
- * A wrapper around cfb_fillrect implemented by fbdev core
- */
-void drm_fb_helper_cfb_fillrect(struct fb_info *info,
-   const struct fb_fillrect *rect)
-{
-   struct drm_fb_helper *helper = info->par;
-
-   cfb_fillrect(info, rect);
-
-   if (helper->funcs->fb_dirty)
-   drm_fb_helper_damage(helper, rect->dx, rect->dy, rect->width, 
rect->height);
-}
-EXPORT_SYMBOL(drm_fb_helper_cfb_fillrect);
-
-/**
- * drm_fb_helper_cfb_copyarea - wrapper around cfb_copyarea
- * @info: fbdev registered by the helper
- * @area: info about area to copy
- *
- * A wrapper around cfb_copyarea implemented by fbdev core
- */
-void drm_fb_helper_cfb_copyarea(struct fb_info *info,
-   const struct fb_copyarea *area)
-{
-   struct drm_fb_helper *helper = info->par;
-
-   cfb_copyarea(info, area);
-
-   if (helper->funcs->fb_dirty)
-   drm_fb_helper_damage(helper, area->dx, area->dy, area->width, 
area->height);
-}
-EXPORT_SYMBOL(drm_fb_helper_cfb_copyarea);
-
-/**
- * drm_fb_helper_cfb_imageblit - wrapper around cfb_imageblit
- * @info: fbdev registered by the helper
- * 

[PATCH 03/11] drm/gma500: Use regular fbdev I/O helpers

2023-05-12 Thread Thomas Zimmermann
Use the regular fbdev helpers for framebuffer I/O instead of DRM's
helpers. Gma500 does not use damage handling, so DRM's fbdev helpers
are mere wrappers around the fbdev code.

Add CONFIG_DRM_GMA500_FBDEV_EMULATION to select the necessary
Kconfig options automatically. Make fbdev emulation depend on
the new config option.

By using fbdev helpers directly within each DRM fbdev emulation,
we can eventually remove DRM's wrapper functions entirely.

Signed-off-by: Thomas Zimmermann 
Cc: Patrik Jakobsson 
---
 drivers/gpu/drm/gma500/Kconfig   | 8 
 drivers/gpu/drm/gma500/Makefile  | 2 +-
 drivers/gpu/drm/gma500/fbdev.c   | 9 -
 drivers/gpu/drm/gma500/psb_drv.h | 2 +-
 4 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/gma500/Kconfig b/drivers/gpu/drm/gma500/Kconfig
index 2efc0eb41c64..b9655e01b0af 100644
--- a/drivers/gpu/drm/gma500/Kconfig
+++ b/drivers/gpu/drm/gma500/Kconfig
@@ -3,6 +3,7 @@ config DRM_GMA500
tristate "Intel GMA500/600/3600/3650 KMS Framebuffer"
depends on DRM && PCI && X86 && MMU
select DRM_KMS_HELPER
+   select DRM_GMA500_FBDEV_EMULATION if DRM_FBDEV_EMULATION
select I2C
select I2C_ALGOBIT
# GMA500 depends on ACPI_VIDEO when ACPI is enabled, just like i915
@@ -15,3 +16,10 @@ config DRM_GMA500
  Say yes for an experimental 2D KMS framebuffer driver for the
  Intel GMA500 (Poulsbo), Intel GMA600 (Moorestown/Oak Trail) and
  Intel GMA3600/3650 (Cedar Trail).
+
+config DRM_GMA500_FBDEV_EMULATION
+   bool
+   depends on DRM_GMA500
+   select FB_CFB_COPYAREA
+   select FB_CFB_FILLRECT
+   select FB_CFB_IMAGEBLIT
diff --git a/drivers/gpu/drm/gma500/Makefile b/drivers/gpu/drm/gma500/Makefile
index 4f302cd5e1a6..ea86d6627c51 100644
--- a/drivers/gpu/drm/gma500/Makefile
+++ b/drivers/gpu/drm/gma500/Makefile
@@ -38,6 +38,6 @@ gma500_gfx-y += \
  psb_irq.o
 
 gma500_gfx-$(CONFIG_ACPI) +=  opregion.o
-gma500_gfx-$(CONFIG_DRM_FBDEV_EMULATION) +=  fbdev.o
+gma500_gfx-$(CONFIG_DRM_GMA500_FBDEV_EMULATION) +=  fbdev.o
 
 obj-$(CONFIG_DRM_GMA500) += gma500_gfx.o
diff --git a/drivers/gpu/drm/gma500/fbdev.c b/drivers/gpu/drm/gma500/fbdev.c
index 62287407e717..60005c3d01d0 100644
--- a/drivers/gpu/drm/gma500/fbdev.c
+++ b/drivers/gpu/drm/gma500/fbdev.c
@@ -5,6 +5,7 @@
  *
  **/
 
+#include 
 #include 
 
 #include 
@@ -136,11 +137,9 @@ static const struct fb_ops psb_fbdev_fb_ops = {
.owner = THIS_MODULE,
DRM_FB_HELPER_DEFAULT_OPS,
.fb_setcolreg = psb_fbdev_fb_setcolreg,
-   .fb_read = drm_fb_helper_cfb_read,
-   .fb_write = drm_fb_helper_cfb_write,
-   .fb_fillrect = drm_fb_helper_cfb_fillrect,
-   .fb_copyarea = drm_fb_helper_cfb_copyarea,
-   .fb_imageblit = drm_fb_helper_cfb_imageblit,
+   .fb_fillrect = cfb_fillrect,
+   .fb_copyarea = cfb_copyarea,
+   .fb_imageblit = cfb_imageblit,
.fb_mmap = psb_fbdev_fb_mmap,
.fb_destroy = psb_fbdev_fb_destroy,
 };
diff --git a/drivers/gpu/drm/gma500/psb_drv.h b/drivers/gpu/drm/gma500/psb_drv.h
index f7f709df99b4..aa2922a0ebf6 100644
--- a/drivers/gpu/drm/gma500/psb_drv.h
+++ b/drivers/gpu/drm/gma500/psb_drv.h
@@ -612,7 +612,7 @@ struct drm_framebuffer *psb_framebuffer_create(struct 
drm_device *dev,
   struct drm_gem_object *obj);
 
 /* fbdev */
-#if defined(CONFIG_DRM_FBDEV_EMULATION)
+#if defined(CONFIG_DRM_GMA500_FBDEV_EMULATION)
 void psb_fbdev_setup(struct drm_psb_private *dev_priv);
 #else
 static inline void psb_fbdev_setup(struct drm_psb_private *dev_priv)
-- 
2.40.1



[PATCH 04/11] drm/radeon: Use regular fbdev I/O helpers

2023-05-12 Thread Thomas Zimmermann
Use the regular fbdev helpers for framebuffer I/O instead of DRM's
helpers. Radeon does not use damage handling, so DRM's fbdev helpers
are mere wrappers around the fbdev code.

Add CONFIG_DRM_RADEON_FBDEV_EMULATION to select the necessary
Kconfig options automatically. Make fbdev emulation depend on
the new config option.

By using fbdev helpers directly within each DRM fbdev emulation,
we can eventually remove DRM's wrapper functions entirely.

Signed-off-by: Thomas Zimmermann 
Cc: Alex Deucher 
Cc: "Christian König" 
Cc: "Pan, Xinhui" 
---
 drivers/gpu/drm/radeon/Kconfig| 8 
 drivers/gpu/drm/radeon/Makefile   | 2 +-
 drivers/gpu/drm/radeon/radeon_fbdev.c | 9 -
 drivers/gpu/drm/radeon/radeon_mode.h  | 2 +-
 4 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/radeon/Kconfig b/drivers/gpu/drm/radeon/Kconfig
index e19d77d58810..66b741d96cc4 100644
--- a/drivers/gpu/drm/radeon/Kconfig
+++ b/drivers/gpu/drm/radeon/Kconfig
@@ -8,6 +8,7 @@ config DRM_RADEON
select DRM_DISPLAY_DP_HELPER
select DRM_DISPLAY_HELPER
 select DRM_KMS_HELPER
+   select DRM_RADEON_FBDEV_EMULATION if DRM_FBDEV_EMULATION
select DRM_SUBALLOC_HELPER
 select DRM_TTM
select DRM_TTM_HELPER
@@ -39,3 +40,10 @@ config DRM_RADEON_USERPTR
help
  This option selects CONFIG_MMU_NOTIFIER if it isn't already
  selected to enabled full userptr support.
+
+config DRM_RADEON_FBDEV_EMULATION
+   bool
+   depends on DRM_RADEON
+   select FB_CFB_COPYAREA
+   select FB_CFB_FILLRECT
+   select FB_CFB_IMAGEBLIT
diff --git a/drivers/gpu/drm/radeon/Makefile b/drivers/gpu/drm/radeon/Makefile
index a8734b7d0485..46c1446196a9 100644
--- a/drivers/gpu/drm/radeon/Makefile
+++ b/drivers/gpu/drm/radeon/Makefile
@@ -76,7 +76,7 @@ radeon-y += \
vce_v1_0.o \
vce_v2_0.o
 
-radeon-$(CONFIG_DRM_FBDEV_EMULATION) += radeon_fbdev.o
+radeon-$(CONFIG_DRM_RADEON_FBDEV_EMULATION) += radeon_fbdev.o
 radeon-$(CONFIG_VGA_SWITCHEROO) += radeon_atpx_handler.o
 radeon-$(CONFIG_ACPI) += radeon_acpi.o
 
diff --git a/drivers/gpu/drm/radeon/radeon_fbdev.c 
b/drivers/gpu/drm/radeon/radeon_fbdev.c
index fe76e29910ef..dcabe527f9c0 100644
--- a/drivers/gpu/drm/radeon/radeon_fbdev.c
+++ b/drivers/gpu/drm/radeon/radeon_fbdev.c
@@ -24,6 +24,7 @@
  * David Airlie
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -193,11 +194,9 @@ static const struct fb_ops radeon_fbdev_fb_ops = {
DRM_FB_HELPER_DEFAULT_OPS,
.fb_open = radeon_fbdev_fb_open,
.fb_release = radeon_fbdev_fb_release,
-   .fb_read = drm_fb_helper_cfb_read,
-   .fb_write = drm_fb_helper_cfb_write,
-   .fb_fillrect = drm_fb_helper_cfb_fillrect,
-   .fb_copyarea = drm_fb_helper_cfb_copyarea,
-   .fb_imageblit = drm_fb_helper_cfb_imageblit,
+   .fb_fillrect = cfb_fillrect,
+   .fb_copyarea = cfb_copyarea,
+   .fb_imageblit = cfb_imageblit,
.fb_destroy = radeon_fbdev_fb_destroy,
 };
 
diff --git a/drivers/gpu/drm/radeon/radeon_mode.h 
b/drivers/gpu/drm/radeon/radeon_mode.h
index 1decdcec0264..c5a8e25a4c97 100644
--- a/drivers/gpu/drm/radeon/radeon_mode.h
+++ b/drivers/gpu/drm/radeon/radeon_mode.h
@@ -939,7 +939,7 @@ void dce4_program_fmt(struct drm_encoder *encoder);
 void dce8_program_fmt(struct drm_encoder *encoder);
 
 /* fbdev layer */
-#if defined(CONFIG_DRM_FBDEV_EMULATION)
+#if defined(CONFIG_DRM_RADEON_FBDEV_EMULATION)
 void radeon_fbdev_setup(struct radeon_device *rdev);
 void radeon_fbdev_set_suspend(struct radeon_device *rdev, int state);
 bool radeon_fbdev_robj_is_fb(struct radeon_device *rdev, struct radeon_bo 
*robj);
-- 
2.40.1



[PATCH 07/11] drm/omapdrm: Use regular fbdev I/O helpers

2023-05-12 Thread Thomas Zimmermann
Use the regular fbdev helpers for framebuffer I/O instead of DRM's
helpers. Omapdrm does not use damage handling, so DRM's fbdev helpers
are mere wrappers around the fbdev code.

Add CONFIG_DRM_OMAP_FBDEV_EMULATION to select the necessary
Kconfig options automatically. Make fbdev emulation depend on
the new config option.

By using fbdev helpers directly within each DRM fbdev emulation,
we can eventually remove DRM's wrapper functions entirely.

Signed-off-by: Thomas Zimmermann 
Cc: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/Kconfig|  9 +
 drivers/gpu/drm/omapdrm/Makefile   |  2 +-
 drivers/gpu/drm/omapdrm/omap_debugfs.c |  4 ++--
 drivers/gpu/drm/omapdrm/omap_fbdev.c   | 12 +++-
 drivers/gpu/drm/omapdrm/omap_fbdev.h   |  2 +-
 drivers/gpu/drm/omapdrm/omap_gem.c |  4 ++--
 6 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/Kconfig b/drivers/gpu/drm/omapdrm/Kconfig
index 76ded1568bd0..7f7efc302752 100644
--- a/drivers/gpu/drm/omapdrm/Kconfig
+++ b/drivers/gpu/drm/omapdrm/Kconfig
@@ -4,6 +4,7 @@ config DRM_OMAP
depends on DRM && OF
depends on ARCH_OMAP2PLUS
select DRM_KMS_HELPER
+   select DRM_OMAP_FBDEV_EMULATION if DRM_FBDEV_EMULATION
select VIDEOMODE_HELPERS
select HDMI
default n
@@ -130,3 +131,11 @@ config OMAP2_DSS_SLEEP_AFTER_VENC_RESET
  disable the sleep if it doesn't cause problems on your platform.
 
 endif
+
+config DRM_OMAP_FBDEV_EMULATION
+   tristate
+   depends on DRM_OMAP
+   select FB_SYS_COPYAREA
+   select FB_SYS_FILLRECT
+   select FB_SYS_FOPS
+   select FB_SYS_IMAGEBLIT
diff --git a/drivers/gpu/drm/omapdrm/Makefile b/drivers/gpu/drm/omapdrm/Makefile
index 710b4e0abcf0..917fcafc77c1 100644
--- a/drivers/gpu/drm/omapdrm/Makefile
+++ b/drivers/gpu/drm/omapdrm/Makefile
@@ -17,7 +17,7 @@ omapdrm-y := omap_drv.o \
omap_dmm_tiler.o \
tcm-sita.o
 
-omapdrm-$(CONFIG_DRM_FBDEV_EMULATION) += omap_fbdev.o
+omapdrm-$(CONFIG_DRM_OMAP_FBDEV_EMULATION) += omap_fbdev.o
 
 omapdrm-y += dss/base.o dss/output.o dss/dss.o dss/dispc.o \
dss/dispc_coefs.o dss/pll.o dss/video-pll.o
diff --git a/drivers/gpu/drm/omapdrm/omap_debugfs.c 
b/drivers/gpu/drm/omapdrm/omap_debugfs.c
index a3d470468e5b..796d20d010c0 100644
--- a/drivers/gpu/drm/omapdrm/omap_debugfs.c
+++ b/drivers/gpu/drm/omapdrm/omap_debugfs.c
@@ -42,7 +42,7 @@ static int mm_show(struct seq_file *m, void *arg)
return 0;
 }
 
-#ifdef CONFIG_DRM_FBDEV_EMULATION
+#ifdef CONFIG_DRM_OMAP_FBDEV_EMULATION
 static int fb_show(struct seq_file *m, void *arg)
 {
struct drm_info_node *node = (struct drm_info_node *) m->private;
@@ -71,7 +71,7 @@ static int fb_show(struct seq_file *m, void *arg)
 static struct drm_info_list omap_debugfs_list[] = {
{"gem", gem_show, 0},
{"mm", mm_show, 0},
-#ifdef CONFIG_DRM_FBDEV_EMULATION
+#ifdef CONFIG_DRM_OMAP_FBDEV_EMULATION
{"fb", fb_show, 0},
 #endif
 };
diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.c 
b/drivers/gpu/drm/omapdrm/omap_fbdev.c
index b950e93b3846..55a65b81ccdc 100644
--- a/drivers/gpu/drm/omapdrm/omap_fbdev.c
+++ b/drivers/gpu/drm/omapdrm/omap_fbdev.c
@@ -4,6 +4,8 @@
  * Author: Rob Clark 
  */
 
+#include 
+
 #include 
 #include 
 #include 
@@ -103,11 +105,11 @@ static const struct fb_ops omap_fb_ops = {
.fb_pan_display = omap_fbdev_pan_display,
.fb_ioctl   = drm_fb_helper_ioctl,
 
-   .fb_read = drm_fb_helper_sys_read,
-   .fb_write = drm_fb_helper_sys_write,
-   .fb_fillrect = drm_fb_helper_sys_fillrect,
-   .fb_copyarea = drm_fb_helper_sys_copyarea,
-   .fb_imageblit = drm_fb_helper_sys_imageblit,
+   .fb_read = fb_sys_read,
+   .fb_write = fb_sys_write,
+   .fb_fillrect = sys_fillrect,
+   .fb_copyarea = sys_copyarea,
+   .fb_imageblit = sys_imageblit,
 
.fb_destroy = omap_fbdev_fb_destroy,
 };
diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.h 
b/drivers/gpu/drm/omapdrm/omap_fbdev.h
index 74c691a8d45f..ee65bc05f34e 100644
--- a/drivers/gpu/drm/omapdrm/omap_fbdev.h
+++ b/drivers/gpu/drm/omapdrm/omap_fbdev.h
@@ -11,7 +11,7 @@
 
 struct drm_device;
 
-#ifdef CONFIG_DRM_FBDEV_EMULATION
+#ifdef CONFIG_DRM_OMAP_FBDEV_EMULATION
 void omap_fbdev_setup(struct drm_device *dev);
 #else
 static inline void omap_fbdev_setup(struct drm_device *dev)
diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c 
b/drivers/gpu/drm/omapdrm/omap_gem.c
index 6b58a5bb7b44..96e8135f127b 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem.c
@@ -634,7 +634,7 @@ int omap_gem_dumb_map_offset(struct drm_file *file, struct 
drm_device *dev,
return ret;
 }
 
-#ifdef CONFIG_DRM_FBDEV_EMULATION
+#ifdef CONFIG_DRM_OMAP_FBDEV_EMULATION
 /* Set scrolling position.  This allows us to implement fast scrolling
  * for console.
  *
@@ -1067,7 +1067,7 @@ void omap_gem_put_sg(struct drm_gem_object *obj, struct 
sg_table *sgt)
 

[PATCH 00/11] drm/fbdev: Remove DRM's helpers for fbdev I/O

2023-05-12 Thread Thomas Zimmermann
DRM provides a number of wrappers around fbdev cfb_() sys_(), fb_io_()
and fb_sys_() helpers. The DRM functions don't provide any additional
functionality for most DRM drivers. So remove them and call the fbdev
I/O helpers directly.

The DRM fbdev I/O wrappers were originally added because 
does not protect its content with CONFIG_FB. DRM fbdev emulation did
not build if the the config option had been disabled. This has been
fixed. For fbdev-generic and i915, the wrappers added support for damage
handling. But this is better handled within the two callers, as each
is special in its damage handling.

Patches 1 to 8 replace the DRM wrappers in a number of fbdev emulations.
Patch 9 exports two helpers for damage handling. Patches 10 and 11
update fbdev-generic and i915 with the help of the exported functions.
The patches also remove DRM's fbdev I/O helpers, which are now unused.

DRM's fbdev helpers had to select fbdev I/O helpers for I/O and for
system memory. Each fbdev emulation now selects the correct helpers
for itself. Depending on the selected DRM drivers, kernel builds will
now only contain the necessary fbdev I/O helpers and might be slightly
smaller in size.

Thomas Zimmermann (11):
  drm/armada: Use regular fbdev I/O helpers
  drm/exynos: Use regular fbdev I/O helpers
  drm/gma500: Use regular fbdev I/O helpers
  drm/radeon: Use regular fbdev I/O helpers
  drm/fbdev-dma: Use regular fbdev I/O helpers
  drm/msm: Use regular fbdev I/O helpers
  drm/omapdrm: Use regular fbdev I/O helpers
  drm/tegra: Use regular fbdev I/O helpers
  drm/fb-helper: Export helpers for marking damage areas
  drm/fbdev-generic: Implement dedicated fbdev I/O helpers
  drm/i915: Implement dedicated fbdev I/O helpers

 drivers/gpu/drm/Kconfig   |  27 +-
 drivers/gpu/drm/Makefile  |   7 +-
 drivers/gpu/drm/armada/Kconfig|   8 +
 drivers/gpu/drm/armada/Makefile   |   2 +-
 drivers/gpu/drm/armada/armada_drm.h   |   2 +-
 drivers/gpu/drm/armada/armada_fbdev.c |   9 +-
 drivers/gpu/drm/drm_fb_helper.c   | 233 ++
 drivers/gpu/drm/drm_fbdev_dma.c   |  12 +-
 drivers/gpu/drm/drm_fbdev_generic.c   |  47 +++-
 drivers/gpu/drm/exynos/Kconfig|   8 +
 drivers/gpu/drm/exynos/Makefile   |   2 +-
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c |  10 +-
 drivers/gpu/drm/exynos/exynos_drm_fbdev.h |   2 +-
 drivers/gpu/drm/gma500/Kconfig|   8 +
 drivers/gpu/drm/gma500/Makefile   |   2 +-
 drivers/gpu/drm/gma500/fbdev.c|   9 +-
 drivers/gpu/drm/gma500/psb_drv.h  |   2 +-
 drivers/gpu/drm/i915/Kconfig  |   8 +
 drivers/gpu/drm/i915/Makefile |   2 +-
 .../drm/i915/display/intel_display_debugfs.c  |   2 +-
 drivers/gpu/drm/i915/display/intel_fbdev.c|  51 +++-
 drivers/gpu/drm/i915/display/intel_fbdev.h|   2 +-
 drivers/gpu/drm/msm/Kconfig   |   9 +
 drivers/gpu/drm/msm/Makefile  |   2 +-
 drivers/gpu/drm/msm/msm_drv.h |   2 +-
 drivers/gpu/drm/msm/msm_fbdev.c   |  12 +-
 drivers/gpu/drm/omapdrm/Kconfig   |   9 +
 drivers/gpu/drm/omapdrm/Makefile  |   2 +-
 drivers/gpu/drm/omapdrm/omap_debugfs.c|   4 +-
 drivers/gpu/drm/omapdrm/omap_fbdev.c  |  12 +-
 drivers/gpu/drm/omapdrm/omap_fbdev.h  |   2 +-
 drivers/gpu/drm/omapdrm/omap_gem.c|   4 +-
 drivers/gpu/drm/radeon/Kconfig|   8 +
 drivers/gpu/drm/radeon/Makefile   |   2 +-
 drivers/gpu/drm/radeon/radeon_fbdev.c |   9 +-
 drivers/gpu/drm/radeon/radeon_mode.h  |   2 +-
 drivers/gpu/drm/tegra/Kconfig |   9 +
 drivers/gpu/drm/tegra/Makefile|   2 +-
 drivers/gpu/drm/tegra/drm.h   |   2 +-
 drivers/gpu/drm/tegra/fbdev.c |  11 +-
 include/drm/drm_fb_helper.h   |  84 +--
 include/drm/drm_fbdev_dma.h   |   2 +-
 include/drm/drm_fbdev_generic.h   |   2 +-
 43 files changed, 264 insertions(+), 382 deletions(-)


base-commit: 451e49cfbaa90720149e63f4fa9c7824013c783d
-- 
2.40.1



[PATCH] drm/amdgpu: fix S3 issue if MQD in VRAM

2023-05-12 Thread Jack Xiao
Make the preemption optimization effect only for SRIOV,
for it caused failure to resume from S3.

Signed-off-by: Jack Xiao 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 3 ++-
 drivers/gpu/drm/amd/amdgpu/mes_v10_1.c  | 7 +--
 drivers/gpu/drm/amd/amdgpu/mes_v11_0.c  | 7 +--
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
index a22d88a4178a..1b795b7bbf38 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
@@ -385,7 +385,8 @@ int amdgpu_gfx_mqd_sw_init(struct amdgpu_device *adev,
u32 domain = AMDGPU_GEM_DOMAIN_GTT;
 
/* Only enable on gfx10 and 11 for now to avoid changing behavior on 
older chips */
-   if (adev->ip_versions[GC_HWIP][0] >= IP_VERSION(10, 0, 0))
+   if (adev->ip_versions[GC_HWIP][0] >= IP_VERSION(10, 0, 0) &&
+   amdgpu_sriov_vf(adev))
domain |= AMDGPU_GEM_DOMAIN_VRAM;
 
/* create MQD for KIQ */
diff --git a/drivers/gpu/drm/amd/amdgpu/mes_v10_1.c 
b/drivers/gpu/drm/amd/amdgpu/mes_v10_1.c
index 4560476c7c31..5c3d3f6c7ebd 100644
--- a/drivers/gpu/drm/amd/amdgpu/mes_v10_1.c
+++ b/drivers/gpu/drm/amd/amdgpu/mes_v10_1.c
@@ -889,6 +889,7 @@ static int mes_v10_1_mqd_sw_init(struct amdgpu_device *adev,
 {
int r, mqd_size = sizeof(struct v10_compute_mqd);
struct amdgpu_ring *ring;
+   u32 domain = AMDGPU_GEM_DOMAIN_GTT;
 
if (pipe == AMDGPU_MES_KIQ_PIPE)
ring = >gfx.kiq[0].ring;
@@ -900,9 +901,11 @@ static int mes_v10_1_mqd_sw_init(struct amdgpu_device 
*adev,
if (ring->mqd_obj)
return 0;
 
+   if (amdgpu_sriov_vf(adev))
+   domain |= AMDGPU_GEM_DOMAIN_VRAM;
+
r = amdgpu_bo_create_kernel(adev, mqd_size, PAGE_SIZE,
-   AMDGPU_GEM_DOMAIN_VRAM |
-   AMDGPU_GEM_DOMAIN_GTT, >mqd_obj,
+   domain, >mqd_obj,
>mqd_gpu_addr, >mqd_ptr);
if (r) {
dev_warn(adev->dev, "failed to create ring mqd bo (%d)", r);
diff --git a/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c 
b/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c
index 3adb450eec07..79a4d2bfd94a 100644
--- a/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c
@@ -987,6 +987,7 @@ static int mes_v11_0_mqd_sw_init(struct amdgpu_device *adev,
 {
int r, mqd_size = sizeof(struct v11_compute_mqd);
struct amdgpu_ring *ring;
+   u32 domain = AMDGPU_GEM_DOMAIN_GTT;
 
if (pipe == AMDGPU_MES_KIQ_PIPE)
ring = >gfx.kiq[0].ring;
@@ -998,9 +999,11 @@ static int mes_v11_0_mqd_sw_init(struct amdgpu_device 
*adev,
if (ring->mqd_obj)
return 0;
 
+   if (amdgpu_sriov_vf(adev))
+   domain |= AMDGPU_GEM_DOMAIN_VRAM;
+
r = amdgpu_bo_create_kernel(adev, mqd_size, PAGE_SIZE,
-   AMDGPU_GEM_DOMAIN_VRAM |
-   AMDGPU_GEM_DOMAIN_GTT, >mqd_obj,
+   domain, >mqd_obj,
>mqd_gpu_addr, >mqd_ptr);
if (r) {
dev_warn(adev->dev, "failed to create ring mqd bo (%d)", r);
-- 
2.37.3



[PATCH] amd/amdgpu: perform soft reset for sdma fed error

2023-05-12 Thread YiPeng Chai
When testing sdma ib ring fails to detect sdma
hang for sdma fed error, force to perform soft
reset.

Signed-off-by: YiPeng Chai 
---
 drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c 
b/drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c
index 3d9a80511a45..1d463e1fd3ae 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c
@@ -53,6 +53,12 @@ MODULE_FIRMWARE("amdgpu/sdma_6_0_3.bin");
 #define SDMA0_HYP_DEC_REG_START 0x5880
 #define SDMA0_HYP_DEC_REG_END 0x589a
 #define SDMA1_HYP_DEC_REG_OFFSET 0x20
+#define regRLC_RLCS_FED_STATUS_0 0x4eff
+#define regRLC_RLCS_FED_STATUS_0_BASE_IDX1
+#define RLC_RLCS_FED_STATUS_0__SDMA0_FED_ERR_MASK0x0040L
+#define RLC_RLCS_FED_STATUS_0__SDMA1_FED_ERR_MASK0x0080L
+#define RLC_RLCS_FED_STATUS_0__SDMA0_FED_ERR__SHIFT  0x6
+#define RLC_RLCS_FED_STATUS_0__SDMA1_FED_ERR__SHIFT  0x7
 
 static void sdma_v6_0_set_ring_funcs(struct amdgpu_device *adev);
 static void sdma_v6_0_set_buffer_funcs(struct amdgpu_device *adev);
@@ -760,6 +766,7 @@ static bool sdma_v6_0_check_soft_reset(void *handle)
struct amdgpu_ring *ring;
int i, r;
long tmo = msecs_to_jiffies(1000);
+   uint32_t rlc_status0 = 0;
 
for (i = 0; i < adev->sdma.num_instances; i++) {
ring = >sdma.instance[i].ring;
@@ -768,6 +775,15 @@ static bool sdma_v6_0_check_soft_reset(void *handle)
return true;
}
 
+   /* Soft reset should be performed for sdma fed error to
+* recover sdma engine, so when testing sdma ib ring fails
+* to detect sdma hang, force to perform soft reset.
+*/
+   rlc_status0 = RREG32_SOC15(GC, 0, regRLC_RLCS_FED_STATUS_0);
+   if (REG_GET_FIELD(rlc_status0, RLC_RLCS_FED_STATUS_0, SDMA0_FED_ERR) ||
+   REG_GET_FIELD(rlc_status0, RLC_RLCS_FED_STATUS_0, SDMA1_FED_ERR))
+   return true;
+
return false;
 }
 
-- 
2.34.1



RE: [PATCH] drm/amdgpu/gmc11: implement get_vbios_fb_size()

2023-05-12 Thread Khatri, Sunil
[AMD Official Use Only - General]

Acked-by: Sunil Khatri 

-Original Message-
From: amd-gfx  On Behalf Of Alex Deucher
Sent: Thursday, May 11, 2023 8:13 PM
To: amd-gfx@lists.freedesktop.org
Cc: Deucher, Alexander 
Subject: [PATCH] drm/amdgpu/gmc11: implement get_vbios_fb_size()

Implement get_vbios_fb_size() so we can properly reserve the vbios splash 
screen to avoid potential artifacts on the screen during the transition from 
the pre-OS console to the OS console.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c | 21 -
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c 
b/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
index f73c238f3145..2f570fb5febe 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
@@ -31,6 +31,8 @@
 #include "umc_v8_10.h"
 #include "athub/athub_3_0_0_sh_mask.h"
 #include "athub/athub_3_0_0_offset.h"
+#include "dcn/dcn_3_2_0_offset.h"
+#include "dcn/dcn_3_2_0_sh_mask.h"
 #include "oss/osssys_6_0_0_offset.h"
 #include "ivsrcid/vmc/irqsrcs_vmc_1_0.h"
 #include "navi10_enum.h"
@@ -546,7 +548,24 @@ static void gmc_v11_0_get_vm_pte(struct amdgpu_device 
*adev,
 
 static unsigned gmc_v11_0_get_vbios_fb_size(struct amdgpu_device *adev)  {
-   return 0;
+   u32 d1vga_control = RREG32_SOC15(DCE, 0, regD1VGA_CONTROL);
+   unsigned size;
+
+   if (REG_GET_FIELD(d1vga_control, D1VGA_CONTROL, D1VGA_MODE_ENABLE)) {
+   size = AMDGPU_VBIOS_VGA_ALLOCATION;
+   } else {
+   u32 viewport;
+   u32 pitch;
+
+   viewport = RREG32_SOC15(DCE, 0, 
regHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION);
+   pitch = RREG32_SOC15(DCE, 0, regHUBPREQ0_DCSURF_SURFACE_PITCH);
+   size = (REG_GET_FIELD(viewport,
+   HUBP0_DCSURF_PRI_VIEWPORT_DIMENSION, 
PRI_VIEWPORT_HEIGHT) *
+   REG_GET_FIELD(pitch, 
HUBPREQ0_DCSURF_SURFACE_PITCH, PITCH) *
+   4);
+   }
+
+   return size;
 }
 
 static const struct amdgpu_gmc_funcs gmc_v11_0_gmc_funcs = {
--
2.40.1