[PATCH] drm/amd: fix potential memory leak

2022-08-24 Thread Bernard Zhao
This patch fix potential memory leak (clk_src) when function run
into last return NULL.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c
index 85f32206a766..76f263846c6b 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c
@@ -1715,6 +1715,7 @@ static struct clock_source *dcn30_clock_source_create(
}
 
BREAK_TO_DEBUGGER();
+   free(clk_src);
return NULL;
 }
 
-- 
2.33.1



[PATCH] drm/amd: remove possible condition with no effect (if == else)

2022-08-24 Thread Bernard Zhao
This patch fix cocci warning:
drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c:1816:6-8:
WARNING: possible condition with no effect (if == else).

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c
index 85f32206a766..dccc9794e6a2 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c
@@ -1813,8 +1813,6 @@ static bool dcn314_resource_construct(
 
if (dc->ctx->dce_environment == DCE_ENV_PRODUCTION_DRV)
dc->debug = debug_defaults_drv;
-   else if (dc->ctx->dce_environment == DCE_ENV_FPGA_MAXIMUS)
-   dc->debug = debug_defaults_diags;
else
dc->debug = debug_defaults_diags;
// Init the vm_helper
-- 
2.33.1



[PATCH v2] drm/amd: remove duplicated argument to &

2022-08-23 Thread Bernard Zhao
This patch trf to fis cocci warning:
drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_32.c:
2349:8-34: duplicated argument to && or ||
drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_32.c:
3680:8-55: duplicated argument to && or ||

Signed-off-by: Bernard Zhao 
---
 .../gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_32.c| 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_32.c 
b/drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_32.c
index cb2025771646..f99c1696a1f6 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_32.c
+++ b/drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_32.c
@@ -2346,8 +2346,7 @@ void dml32_ModeSupportAndSystemConfigurationFull(struct 
display_mode_lib *mode_l
 
if (mode_lib->vba.DSCEnable[k] && 
mode_lib->vba.ForcedOutputLinkBPP[k] != 0)
mode_lib->vba.DSCOnlyIfNecessaryWithBPP = true;
-   if ((mode_lib->vba.DSCEnable[k] || 
mode_lib->vba.DSCEnable[k])
-   && mode_lib->vba.OutputFormat[k] == 
dm_n422
+   if (mode_lib->vba.DSCEnable[k] && 
mode_lib->vba.OutputFormat[k] == dm_n422
&& !mode_lib->vba.DSC422NativeSupport)
mode_lib->vba.DSC422NativeNotSupported = true;
 
@@ -3678,7 +3677,6 @@ void dml32_ModeSupportAndSystemConfigurationFull(struct 
display_mode_lib *mode_l
if (mode_lib->vba.SourcePixelFormat[k] != dm_444_64
&& mode_lib->vba.SourcePixelFormat[k] 
!= dm_444_32
&& mode_lib->vba.SourcePixelFormat[k] 
!= dm_444_16
-   && mode_lib->vba.SourcePixelFormat[k] 
!= dm_444_16
&& mode_lib->vba.SourcePixelFormat[k] 
!= dm_444_8
&& mode_lib->vba.SourcePixelFormat[k] 
!= dm_rgbe) {
if (mode_lib->vba.ViewportWidthChroma[k] > 
mode_lib->vba.SurfaceWidthC[k]
-- 
2.33.1



[PATCH] drm/amd: remove duplicated argument to &

2022-08-23 Thread Bernard Zhao
This patch trf to fis cocci warning:
drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_32.c:
2349:8-34: duplicated argument to && or ||
drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_32.c:
3680:8-55: duplicated argument to && or ||

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_32.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_32.c 
b/drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_32.c
index cb2025771646..fa26834daf56 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_32.c
+++ b/drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_32.c
@@ -2346,8 +2346,7 @@ void dml32_ModeSupportAndSystemConfigurationFull(struct 
display_mode_lib *mode_l
 
if (mode_lib->vba.DSCEnable[k] && 
mode_lib->vba.ForcedOutputLinkBPP[k] != 0)
mode_lib->vba.DSCOnlyIfNecessaryWithBPP = true;
-   if ((mode_lib->vba.DSCEnable[k] || 
mode_lib->vba.DSCEnable[k])
-   && mode_lib->vba.OutputFormat[k] == 
dm_n422
+   if (mode_lib->vba.DSCEnable[k] && 
mode_lib->vba.OutputFormat[k] == dm_n422
&& !mode_lib->vba.DSC422NativeSupport)
mode_lib->vba.DSC422NativeNotSupported = true;
 
-- 
2.33.1



[PATCH] drm/amd: remove possible condition with no effect (if == else)

2022-08-23 Thread Bernard Zhao
This patch fix cocci warning:
drivers/gpu/drm/amd/display/dc/core/dc.c:3335:2-4: WARNING:
possible condition with no effect (if == else).

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/amd/display/dc/core/dc.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc.c
index aeecca68dea7..2d4c44083d79 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -3332,13 +3332,8 @@ static void commit_planes_for_stream(struct dc *dc,
/* Since phantom pipe programming is moved to 
post_unlock_program_front_end,
 * move the SubVP lock to after the phantom pipes have been 
setup
 */
-   if (should_lock_all_pipes && 
dc->hwss.interdependent_update_lock) {
-   if (dc->hwss.subvp_pipe_control_lock)
-   dc->hwss.subvp_pipe_control_lock(dc, context, 
false, should_lock_all_pipes, NULL, subvp_prev_use);
-   } else {
-   if (dc->hwss.subvp_pipe_control_lock)
-   dc->hwss.subvp_pipe_control_lock(dc, context, 
false, should_lock_all_pipes, NULL, subvp_prev_use);
-   }
+   if (dc->hwss.subvp_pipe_control_lock)
+   dc->hwss.subvp_pipe_control_lock(dc, context, false, 
should_lock_all_pipes, NULL, subvp_prev_use);
return;
}
 
-- 
2.33.1



[PATCH] drm/amd: fix potential memory leak

2022-08-23 Thread Bernard Zhao
This patch fix potential memory leak (clk_src) when function run
into last return NULL.
Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c
index 85f32206a766..c7bb76a2a8c2 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c
@@ -1643,6 +1643,7 @@ static struct clock_source *dcn31_clock_source_create(
}
 
BREAK_TO_DEBUGGER();
+   kfree(clk_src);
return NULL;
 }
 
-- 
2.33.1



[PATCH] drm/tegra: remove useless if check before kfree

2022-04-13 Thread Bernard Zhao
This patch remove useless if check before kfree.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/tegra/submit.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/tegra/submit.c b/drivers/gpu/drm/tegra/submit.c
index 6d6dd8c35475..54ac31bc80f6 100644
--- a/drivers/gpu/drm/tegra/submit.c
+++ b/drivers/gpu/drm/tegra/submit.c
@@ -639,8 +639,7 @@ int tegra_drm_ioctl_channel_submit(struct drm_device *drm, 
void *data,
kfree(job_data->used_mappings);
}
 
-   if (job_data)
-   kfree(job_data);
+   kfree(job_data);
 put_bo:
gather_bo_put(>base);
 unlock:
-- 
2.33.1



[PATCH] gpu/host1x: remove useless if(ptr) check to kfree

2022-04-13 Thread Bernard Zhao
This patch remove useless if(ptr) check to kfree.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/host1x/fence.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/host1x/fence.c b/drivers/gpu/host1x/fence.c
index ecab72882192..05b36bfc8b74 100644
--- a/drivers/gpu/host1x/fence.c
+++ b/drivers/gpu/host1x/fence.c
@@ -93,8 +93,7 @@ static void host1x_syncpt_fence_release(struct dma_fence *f)
 {
struct host1x_syncpt_fence *sf = to_host1x_fence(f);
 
-   if (sf->waiter)
-   kfree(sf->waiter);
+   kfree(sf->waiter);
 
dma_fence_free(f);
 }
-- 
2.33.1



[PATCH v2] gpu/drm: fix potential memleak in error branch

2022-01-05 Thread Bernard Zhao
This patch try to fix potential memleak in error branch.
For example:
nv50_sor_create ->nv50_mstm_new-> drm_dp_mst_topology_mgr_init,
In function drm_dp_mst_topology_mgr_init, there are five error
branches, error branch just return error code, no free called.
And we see that the caller didn`t do the drm_dp_mst_topology_mgr_destroy job.
In this case, this may bring in the risk of memleak issue.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/drm_dp_mst_topology.c | 22 --
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c 
b/drivers/gpu/drm/drm_dp_mst_topology.c
index f3d79eda94bb..f73b180dee73 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -5501,7 +5501,10 @@ int drm_dp_mst_topology_mgr_init(struct 
drm_dp_mst_topology_mgr *mgr,
 int max_lane_count, int max_link_rate,
 int conn_base_id)
 {
-   struct drm_dp_mst_topology_state *mst_state;
+   struct drm_dp_mst_topology_state *mst_state = NULL;
+
+   mgr->payloads = NULL;
+   mgr->proposed_vcpis = NULL;
 
mutex_init(>lock);
mutex_init(>qlock);
@@ -5523,7 +5526,7 @@ int drm_dp_mst_topology_mgr_init(struct 
drm_dp_mst_topology_mgr *mgr,
 */
mgr->delayed_destroy_wq = alloc_ordered_workqueue("drm_dp_mst_wq", 0);
if (mgr->delayed_destroy_wq == NULL)
-   return -ENOMEM;
+   goto out;
 
INIT_WORK(>work, drm_dp_mst_link_probe_work);
INIT_WORK(>tx_work, drm_dp_tx_work);
@@ -5539,18 +5542,18 @@ int drm_dp_mst_topology_mgr_init(struct 
drm_dp_mst_topology_mgr *mgr,
mgr->conn_base_id = conn_base_id;
if (max_payloads + 1 > sizeof(mgr->payload_mask) * 8 ||
max_payloads + 1 > sizeof(mgr->vcpi_mask) * 8)
-   return -EINVAL;
+   goto failed;
mgr->payloads = kcalloc(max_payloads, sizeof(struct drm_dp_payload), 
GFP_KERNEL);
if (!mgr->payloads)
-   return -ENOMEM;
+   goto failed;
mgr->proposed_vcpis = kcalloc(max_payloads, sizeof(struct drm_dp_vcpi 
*), GFP_KERNEL);
if (!mgr->proposed_vcpis)
-   return -ENOMEM;
+   goto failed;
set_bit(0, >payload_mask);
 
mst_state = kzalloc(sizeof(*mst_state), GFP_KERNEL);
if (mst_state == NULL)
-   return -ENOMEM;
+   goto failed;
 
mst_state->total_avail_slots = 63;
mst_state->start_slot = 1;
@@ -5563,6 +5566,13 @@ int drm_dp_mst_topology_mgr_init(struct 
drm_dp_mst_topology_mgr *mgr,
_dp_mst_topology_state_funcs);
 
return 0;
+
+failed:
+   kfree(mgr->proposed_vcpis);
+   kfree(mgr->payloads);
+   destroy_workqueue(mgr->delayed_destroy_wq);
+out:
+   return -ENOMEM;
 }
 EXPORT_SYMBOL(drm_dp_mst_topology_mgr_init);
 
-- 
2.33.1



[PATCH] drm/kmb: fix potential memleak in error branch

2021-11-17 Thread Bernard Zhao
This patch try to fix coccicheck warning:
./drivers/gpu/drm/kmb/kmb_drv.c:519:2-8: ERROR: missing put_device; call 
of_find_device_by_node on line 506, but without a corresponding object release 
within this function.
./drivers/gpu/drm/kmb/kmb_drv.c:522:2-8: ERROR: missing put_device; call 
of_find_device_by_node on line 506, but without a corresponding object release 
within this function.
./drivers/gpu/drm/kmb/kmb_drv.c:529:2-8: ERROR: missing put_device; call 
of_find_device_by_node on line 506, but without a corresponding object release 
within this function.
./drivers/gpu/drm/kmb/kmb_drv.c:579:1-7: ERROR: missing put_device; call 
of_find_device_by_node on line 506, but without a corresponding object release 
within this function.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/kmb/kmb_drv.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/kmb/kmb_drv.c b/drivers/gpu/drm/kmb/kmb_drv.c
index 961ac6fb5fcf..4a7178288ecf 100644
--- a/drivers/gpu/drm/kmb/kmb_drv.c
+++ b/drivers/gpu/drm/kmb/kmb_drv.c
@@ -514,8 +514,10 @@ static int kmb_probe(struct platform_device *pdev)
ret = kmb_dsi_host_bridge_init(get_device(_pdev->dev));
 
if (ret == -EPROBE_DEFER) {
+   of_dev_put(dsi_pdev);
return -EPROBE_DEFER;
} else if (ret) {
+   of_dev_put(dsi_pdev);
DRM_ERROR("probe failed to initialize DSI host bridge\n");
return ret;
}
@@ -523,8 +525,10 @@ static int kmb_probe(struct platform_device *pdev)
/* Create DRM device */
kmb = devm_drm_dev_alloc(dev, _driver,
 struct kmb_drm_private, drm);
-   if (IS_ERR(kmb))
+   if (IS_ERR(kmb)) {
+   of_dev_put(dsi_pdev);
return PTR_ERR(kmb);
+   }
 
dev_set_drvdata(dev, >drm);
 
@@ -572,6 +576,8 @@ static int kmb_probe(struct platform_device *pdev)
dev_set_drvdata(dev, NULL);
kmb_dsi_host_unregister(kmb->kmb_dsi);
 
+   of_dev_put(dsi_pdev);
+
return ret;
 }
 
-- 
2.33.1



[PATCH] drm/selftest: fix potential memleak in error branch

2021-11-16 Thread Bernard Zhao
This patch try to fix the potential memleak in error branch.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c 
b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
index 6b4759ed6bfd..dbac073ed385 100644
--- a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
+++ b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
@@ -131,8 +131,10 @@ sideband_msg_req_encode_decode(struct 
drm_dp_sideband_msg_req_body *in)
return false;
 
txmsg = kzalloc(sizeof(*txmsg), GFP_KERNEL);
-   if (!txmsg)
-   return false;
+   if (!txmsg) {
+   result = false;
+   goto out;
+   }
 
drm_dp_encode_sideband_req(in, txmsg);
ret = drm_dp_decode_sideband_req(txmsg, out);
-- 
2.33.1



[PATCH] gpu/drm: fix potential memleak in error branch

2021-11-16 Thread Bernard Zhao
This patch try to fix potential memleak in error branch.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/drm_dp_mst_topology.c | 22 --
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c 
b/drivers/gpu/drm/drm_dp_mst_topology.c
index f3d79eda94bb..f73b180dee73 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -5501,7 +5501,10 @@ int drm_dp_mst_topology_mgr_init(struct 
drm_dp_mst_topology_mgr *mgr,
 int max_lane_count, int max_link_rate,
 int conn_base_id)
 {
-   struct drm_dp_mst_topology_state *mst_state;
+   struct drm_dp_mst_topology_state *mst_state = NULL;
+
+   mgr->payloads = NULL;
+   mgr->proposed_vcpis = NULL;
 
mutex_init(>lock);
mutex_init(>qlock);
@@ -5523,7 +5526,7 @@ int drm_dp_mst_topology_mgr_init(struct 
drm_dp_mst_topology_mgr *mgr,
 */
mgr->delayed_destroy_wq = alloc_ordered_workqueue("drm_dp_mst_wq", 0);
if (mgr->delayed_destroy_wq == NULL)
-   return -ENOMEM;
+   goto out;
 
INIT_WORK(>work, drm_dp_mst_link_probe_work);
INIT_WORK(>tx_work, drm_dp_tx_work);
@@ -5539,18 +5542,18 @@ int drm_dp_mst_topology_mgr_init(struct 
drm_dp_mst_topology_mgr *mgr,
mgr->conn_base_id = conn_base_id;
if (max_payloads + 1 > sizeof(mgr->payload_mask) * 8 ||
max_payloads + 1 > sizeof(mgr->vcpi_mask) * 8)
-   return -EINVAL;
+   goto failed;
mgr->payloads = kcalloc(max_payloads, sizeof(struct drm_dp_payload), 
GFP_KERNEL);
if (!mgr->payloads)
-   return -ENOMEM;
+   goto failed;
mgr->proposed_vcpis = kcalloc(max_payloads, sizeof(struct drm_dp_vcpi 
*), GFP_KERNEL);
if (!mgr->proposed_vcpis)
-   return -ENOMEM;
+   goto failed;
set_bit(0, >payload_mask);
 
mst_state = kzalloc(sizeof(*mst_state), GFP_KERNEL);
if (mst_state == NULL)
-   return -ENOMEM;
+   goto failed;
 
mst_state->total_avail_slots = 63;
mst_state->start_slot = 1;
@@ -5563,6 +5566,13 @@ int drm_dp_mst_topology_mgr_init(struct 
drm_dp_mst_topology_mgr *mgr,
_dp_mst_topology_state_funcs);
 
return 0;
+
+failed:
+   kfree(mgr->proposed_vcpis);
+   kfree(mgr->payloads);
+   destroy_workqueue(mgr->delayed_destroy_wq);
+out:
+   return -ENOMEM;
 }
 EXPORT_SYMBOL(drm_dp_mst_topology_mgr_init);
 
-- 
2.33.1



[PATCH] drm/sun4i: remove no need type conversion to bool

2021-11-15 Thread Bernard Zhao
This change is to cleanup the code a bit.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c 
b/drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c
index fbf7da9d9592..25e6f85fed0b 100644
--- a/drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c
+++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c
@@ -49,7 +49,7 @@ static unsigned long sun4i_tmds_calc_divider(unsigned long 
rate,
(rate - tmp_rate) < (rate - best_rate)) {
best_rate = tmp_rate;
best_m = m;
-   is_double = (d == 2) ? true : false;
+   is_double = (d == 2);
}
}
}
-- 
2.33.1



[PATCH] drm/tegra: remove no need NULL check before kfree

2021-11-15 Thread Bernard Zhao
This change is to cleanup the code a bit.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/tegra/submit.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/tegra/submit.c b/drivers/gpu/drm/tegra/submit.c
index 776f825df52f..c2fc9677742e 100644
--- a/drivers/gpu/drm/tegra/submit.c
+++ b/drivers/gpu/drm/tegra/submit.c
@@ -608,12 +608,10 @@ int tegra_drm_ioctl_channel_submit(struct drm_device 
*drm, void *data,
if (job_data && job_data->used_mappings) {
for (i = 0; i < job_data->num_used_mappings; i++)

tegra_drm_mapping_put(job_data->used_mappings[i].mapping);
-
-   kfree(job_data->used_mappings);
}
 
-   if (job_data)
-   kfree(job_data);
+   kfree(job_data->used_mappings);
+   kfree(job_data);
 put_bo:
gather_bo_put(>base);
 unlock:
-- 
2.33.1



[PATCH] drm/amd/display: remove no need NULL check before kfree

2021-11-15 Thread Bernard Zhao
This change is to cleanup the code a bit.

Signed-off-by: Bernard Zhao 
---
 .../drm/amd/display/dc/dcn10/dcn10_resource.c  | 18 ++
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
index f37551e00023..0090550d4aee 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
@@ -978,10 +978,8 @@ static void dcn10_resource_destruct(struct 
dcn10_resource_pool *pool)
pool->base.mpc = NULL;
}
 
-   if (pool->base.hubbub != NULL) {
-   kfree(pool->base.hubbub);
-   pool->base.hubbub = NULL;
-   }
+   kfree(pool->base.hubbub);
+   pool->base.hubbub = NULL;
 
for (i = 0; i < pool->base.pipe_count; i++) {
if (pool->base.opps[i] != NULL)
@@ -1011,14 +1009,10 @@ static void dcn10_resource_destruct(struct 
dcn10_resource_pool *pool)
for (i = 0; i < pool->base.res_cap->num_ddc; i++) {
if (pool->base.engines[i] != NULL)
dce110_engine_destroy(>base.engines[i]);
-   if (pool->base.hw_i2cs[i] != NULL) {
-   kfree(pool->base.hw_i2cs[i]);
-   pool->base.hw_i2cs[i] = NULL;
-   }
-   if (pool->base.sw_i2cs[i] != NULL) {
-   kfree(pool->base.sw_i2cs[i]);
-   pool->base.sw_i2cs[i] = NULL;
-   }
+   kfree(pool->base.hw_i2cs[i]);
+   pool->base.hw_i2cs[i] = NULL;
+   kfree(pool->base.sw_i2cs[i]);
+   pool->base.sw_i2cs[i] = NULL;
}
 
for (i = 0; i < pool->base.audio_count; i++) {
-- 
2.33.1



[PATCH] drm/amd/display: cleanup the code a bit

2021-11-15 Thread Bernard Zhao
In function dc_sink_destruct, kfree will check pointer, no need
to check again.
This change is to cleanup the code a bit.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/amd/display/dc/core/dc_sink.c | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_sink.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_sink.c
index a249a0e5edd0..4b5e4d8e7735 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_sink.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_sink.c
@@ -33,14 +33,6 @@
  * Private functions
  
**/
 
-static void dc_sink_destruct(struct dc_sink *sink)
-{
-   if (sink->dc_container_id) {
-   kfree(sink->dc_container_id);
-   sink->dc_container_id = NULL;
-   }
-}
-
 static bool dc_sink_construct(struct dc_sink *sink, const struct 
dc_sink_init_data *init_params)
 {
 
@@ -75,7 +67,7 @@ void dc_sink_retain(struct dc_sink *sink)
 static void dc_sink_free(struct kref *kref)
 {
struct dc_sink *sink = container_of(kref, struct dc_sink, refcount);
-   dc_sink_destruct(sink);
+   kfree(sink->dc_container_id);
kfree(sink);
 }
 
-- 
2.33.1



[PATCH v2] drm/amd/amdgpu: cleanup the code style a bit

2021-11-15 Thread Bernard Zhao
This change is to cleanup the code style a bit.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 21 +
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
index 04cf9b207e62..3fc49823f527 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
@@ -283,17 +283,15 @@ static int amdgpu_virt_init_ras_err_handler_data(struct 
amdgpu_device *adev)
 
*data = kmalloc(sizeof(struct amdgpu_virt_ras_err_handler_data), 
GFP_KERNEL);
if (!*data)
-   return -ENOMEM;
+   goto data_failure;
 
bps = kmalloc_array(align_space, sizeof((*data)->bps), GFP_KERNEL);
-   bps_bo = kmalloc_array(align_space, sizeof((*data)->bps_bo), 
GFP_KERNEL);
+   if (!bps)
+   goto bps_failure;
 
-   if (!bps || !bps_bo) {
-   kfree(bps);
-   kfree(bps_bo);
-   kfree(*data);
-   return -ENOMEM;
-   }
+   bps_bo = kmalloc_array(align_space, sizeof((*data)->bps_bo), 
GFP_KERNEL);
+   if (!bps_bo)
+   goto bps_bo_failure;
 
(*data)->bps = bps;
(*data)->bps_bo = bps_bo;
@@ -303,6 +301,13 @@ static int amdgpu_virt_init_ras_err_handler_data(struct 
amdgpu_device *adev)
virt->ras_init_done = true;
 
return 0;
+
+bps_bo_failure:
+   kfree(bps);
+bps_failure:
+   kfree(*data);
+data_failure:
+   return -ENOMEM;
 }
 
 static void amdgpu_virt_ras_release_bp(struct amdgpu_device *adev)
-- 
2.33.1



[PATCH] drm/exynos: remove useless type conversion

2021-11-14 Thread Bernard Zhao
This change is to cleanup the code a bit.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/exynos/exynos_drm_fimc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimc.c 
b/drivers/gpu/drm/exynos/exynos_drm_fimc.c
index ecfd82d0afb7..023f54ee61a8 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimc.c
@@ -782,8 +782,8 @@ static int fimc_set_prescaler(struct fimc_context *ctx, 
struct fimc_scaler *sc,
 
sc->hratio = (src_w << 14) / (dst_w << hfactor);
sc->vratio = (src_h << 14) / (dst_h << vfactor);
-   sc->up_h = (dst_w >= src_w) ? true : false;
-   sc->up_v = (dst_h >= src_h) ? true : false;
+   sc->up_h = (dst_w >= src_w);
+   sc->up_v = (dst_h >= src_h);
DRM_DEV_DEBUG_KMS(ctx->dev, "hratio[%d]vratio[%d]up_h[%d]up_v[%d]\n",
  sc->hratio, sc->vratio, sc->up_h, sc->up_v);
 
-- 
2.33.1



[PATCH] drm/amd/amdgpu: remove useless break after return

2021-11-14 Thread Bernard Zhao
This change is to remove useless break after return.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c 
b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
index b200b9e722d9..8318ee8339f1 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
@@ -2092,22 +2092,18 @@ static int dce_v8_0_pick_dig_encoder(struct drm_encoder 
*encoder)
return 1;
else
return 0;
-   break;
case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
if (dig->linkb)
return 3;
else
return 2;
-   break;
case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
if (dig->linkb)
return 5;
else
return 4;
-   break;
case ENCODER_OBJECT_ID_INTERNAL_UNIPHY3:
return 6;
-   break;
default:
DRM_ERROR("invalid encoder_id: 0x%x\n", 
amdgpu_encoder->encoder_id);
return 0;
-- 
2.33.1



[PATCH] drm/amd/amdgpu: cleanup the code style a bit

2021-11-14 Thread Bernard Zhao
This change is to cleanup the code style a bit.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
index 04cf9b207e62..90070b41136a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
@@ -286,12 +286,14 @@ static int amdgpu_virt_init_ras_err_handler_data(struct 
amdgpu_device *adev)
return -ENOMEM;
 
bps = kmalloc_array(align_space, sizeof((*data)->bps), GFP_KERNEL);
+   if (!bps) {
+   kfree(*data);
+   return -ENOMEM;
+   }
bps_bo = kmalloc_array(align_space, sizeof((*data)->bps_bo), 
GFP_KERNEL);
-
-   if (!bps || !bps_bo) {
-   kfree(bps);
-   kfree(bps_bo);
+   if (!bps_bo) {
kfree(*data);
+   kfree(bps);
return -ENOMEM;
}
 
-- 
2.33.1



[PATCH] drm/xen: fix potential memleak in error branch

2021-11-14 Thread Bernard Zhao
In function xen_drm_front_gem_import_sg_table, if in error branch,
there maybe potential memleak if not call gem_free_pages_array.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/xen/xen_drm_front_gem.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/xen/xen_drm_front_gem.c 
b/drivers/gpu/drm/xen/xen_drm_front_gem.c
index b293c67230ef..732c3eec0666 100644
--- a/drivers/gpu/drm/xen/xen_drm_front_gem.c
+++ b/drivers/gpu/drm/xen/xen_drm_front_gem.c
@@ -222,15 +222,19 @@ xen_drm_front_gem_import_sg_table(struct drm_device *dev,
 
ret = drm_prime_sg_to_page_array(sgt, xen_obj->pages,
 xen_obj->num_pages);
-   if (ret < 0)
+   if (ret < 0) {
+   gem_free_pages_array(xen_obj);
return ERR_PTR(ret);
+   }
 
ret = xen_drm_front_dbuf_create(drm_info->front_info,

xen_drm_front_dbuf_to_cookie(_obj->base),
0, 0, 0, size, sgt->sgl->offset,
xen_obj->pages);
-   if (ret < 0)
+   if (ret < 0) {
+   gem_free_pages_array(xen_obj);
return ERR_PTR(ret);
+   }
 
DRM_DEBUG("Imported buffer of size %zu with nents %u\n",
  size, sgt->orig_nents);
-- 
2.33.1



[PATCH] drm/amd/amdgpu: fix potential memleak

2021-11-14 Thread Bernard Zhao
In function amdgpu_get_xgmi_hive, when kobject_init_and_add failed
There is a potential memleak if not call kobject_put.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
index 0fad2bf854ae..567df2db23ac 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
@@ -386,6 +386,7 @@ struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct 
amdgpu_device *adev)
"%s", "xgmi_hive_info");
if (ret) {
dev_err(adev->dev, "XGMI: failed initializing kobject for xgmi 
hive\n");
+   kobject_put(>kobj);
kfree(hive);
hive = NULL;
goto pro_end;
-- 
2.33.1



[PATCH] gpu/drm: fix potential memory leak

2021-10-22 Thread Bernard Zhao
This patch try to fix memory leak reported by syzbot:
BUG: memory leak
unreferenced object 0x888127338180 (size 64):
  comm "syz-executor.6", pid 11434, jiffies 4294961165 (age 15.480s)
  hex dump (first 32 bytes):
01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  
00 00 00 00 00 00 00 00 00 4a 0d 28 81 88 ff ff  .J.(
  backtrace:
[] kmalloc include/linux/slab.h:591 [inline]
[] drm_vma_node_allow+0x32/0x120 
drivers/gpu/drm/drm_vma_manager.c:274
[] drm_gem_handle_create_tail+0x107/0x250 
drivers/gpu/drm/drm_gem.c:390
[] vgem_gem_create drivers/gpu/drm/vgem/vgem_drv.c:203 
[inline]
[] vgem_gem_dumb_create+0x8d/0x240 
drivers/gpu/drm/vgem/vgem_drv.c:223
[] drm_mode_create_dumb+0x121/0x150 
drivers/gpu/drm/drm_dumb_buffers.c:96
[] drm_ioctl_kernel+0xf0/0x160 
drivers/gpu/drm/drm_ioctl.c:795
[] drm_ioctl+0x2ea/0x4f0 drivers/gpu/drm/drm_ioctl.c:898
[] vfs_ioctl fs/ioctl.c:51 [inline]
[] __do_sys_ioctl fs/ioctl.c:1069 [inline]
[] __se_sys_ioctl fs/ioctl.c:1055 [inline]
[] __x64_sys_ioctl+0xfc/0x140 fs/ioctl.c:1055
[] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
[] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
[] entry_SYSCALL_64_after_hwframe+0x44/0xae
The link is:
https://syzkaller.appspot.com/bug?id=bd059c6ee8aee1d3af51cff3a2849b8c0027b822

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/drm_vma_manager.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_vma_manager.c 
b/drivers/gpu/drm/drm_vma_manager.c
index 7de37f8c68fd..870d5bc7f1fa 100644
--- a/drivers/gpu/drm/drm_vma_manager.c
+++ b/drivers/gpu/drm/drm_vma_manager.c
@@ -300,11 +300,11 @@ int drm_vma_node_allow(struct drm_vma_offset_node *node, 
struct drm_file *tag)
new->vm_count = 1;
rb_link_node(>vm_rb, parent, iter);
rb_insert_color(>vm_rb, >vm_files);
-   new = NULL;
 
 unlock:
write_unlock(>vm_lock);
kfree(new);
+   new = NULL;
return ret;
 }
 EXPORT_SYMBOL(drm_vma_node_allow);
-- 
2.33.1



[PATCH] drm/radeon: delete useless function return values & remove meaningless if(r) check code

2021-06-21 Thread Bernard Zhao
Function radeon_fence_driver_init always returns success,
the function type maybe coule be changed to void.
This patch first delete the check of the return
value of the function call radeon_fence_driver_init, then,
optimise the function declaration and function to void type.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/radeon/cik.c  | 4 +---
 drivers/gpu/drm/radeon/evergreen.c| 4 +---
 drivers/gpu/drm/radeon/ni.c   | 4 +---
 drivers/gpu/drm/radeon/r100.c | 4 +---
 drivers/gpu/drm/radeon/r300.c | 4 +---
 drivers/gpu/drm/radeon/r420.c | 5 +
 drivers/gpu/drm/radeon/r520.c | 4 +---
 drivers/gpu/drm/radeon/r600.c | 4 +---
 drivers/gpu/drm/radeon/radeon.h   | 2 +-
 drivers/gpu/drm/radeon/radeon_fence.c | 5 +
 drivers/gpu/drm/radeon/rs400.c| 4 +---
 drivers/gpu/drm/radeon/rs600.c| 4 +---
 drivers/gpu/drm/radeon/rs690.c| 4 +---
 drivers/gpu/drm/radeon/rv515.c| 4 +---
 drivers/gpu/drm/radeon/rv770.c| 4 +---
 drivers/gpu/drm/radeon/si.c   | 4 +---
 16 files changed, 16 insertions(+), 48 deletions(-)

diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c
index 42a8afa839cb..f6cf0b8fdd83 100644
--- a/drivers/gpu/drm/radeon/cik.c
+++ b/drivers/gpu/drm/radeon/cik.c
@@ -8584,9 +8584,7 @@ int cik_init(struct radeon_device *rdev)
radeon_get_clock_info(rdev->ddev);
 
/* Fence driver */
-   r = radeon_fence_driver_init(rdev);
-   if (r)
-   return r;
+   radeon_fence_driver_init(rdev);
 
/* initialize memory controller */
r = cik_mc_init(rdev);
diff --git a/drivers/gpu/drm/radeon/evergreen.c 
b/drivers/gpu/drm/radeon/evergreen.c
index 8e9e88bf1f43..36a888e1b179 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -5208,9 +5208,7 @@ int evergreen_init(struct radeon_device *rdev)
/* Initialize clocks */
radeon_get_clock_info(rdev->ddev);
/* Fence driver */
-   r = radeon_fence_driver_init(rdev);
-   if (r)
-   return r;
+   radeon_fence_driver_init(rdev);
/* initialize AGP */
if (rdev->flags & RADEON_IS_AGP) {
r = radeon_agp_init(rdev);
diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
index ab7bd3080217..4a364ca7a1be 100644
--- a/drivers/gpu/drm/radeon/ni.c
+++ b/drivers/gpu/drm/radeon/ni.c
@@ -2375,9 +2375,7 @@ int cayman_init(struct radeon_device *rdev)
/* Initialize clocks */
radeon_get_clock_info(rdev->ddev);
/* Fence driver */
-   r = radeon_fence_driver_init(rdev);
-   if (r)
-   return r;
+   radeon_fence_driver_init(rdev);
/* initialize memory controller */
r = evergreen_mc_init(rdev);
if (r)
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index fcfcaec25a9e..aa6800b0e198 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -4056,9 +4056,7 @@ int r100_init(struct radeon_device *rdev)
/* initialize VRAM */
r100_mc_init(rdev);
/* Fence driver */
-   r = radeon_fence_driver_init(rdev);
-   if (r)
-   return r;
+   radeon_fence_driver_init(rdev);
/* Memory manager */
r = radeon_bo_init(rdev);
if (r)
diff --git a/drivers/gpu/drm/radeon/r300.c b/drivers/gpu/drm/radeon/r300.c
index 92643dfdd8a8..621ff174dff3 100644
--- a/drivers/gpu/drm/radeon/r300.c
+++ b/drivers/gpu/drm/radeon/r300.c
@@ -1549,9 +1549,7 @@ int r300_init(struct radeon_device *rdev)
/* initialize memory controller */
r300_mc_init(rdev);
/* Fence driver */
-   r = radeon_fence_driver_init(rdev);
-   if (r)
-   return r;
+   radeon_fence_driver_init(rdev);
/* Memory manager */
r = radeon_bo_init(rdev);
if (r)
diff --git a/drivers/gpu/drm/radeon/r420.c b/drivers/gpu/drm/radeon/r420.c
index 1ed4407b91aa..7e6320e8c6a0 100644
--- a/drivers/gpu/drm/radeon/r420.c
+++ b/drivers/gpu/drm/radeon/r420.c
@@ -425,10 +425,7 @@ int r420_init(struct radeon_device *rdev)
r300_mc_init(rdev);
r420_debugfs(rdev);
/* Fence driver */
-   r = radeon_fence_driver_init(rdev);
-   if (r) {
-   return r;
-   }
+   radeon_fence_driver_init(rdev);
/* Memory manager */
r = radeon_bo_init(rdev);
if (r) {
diff --git a/drivers/gpu/drm/radeon/r520.c b/drivers/gpu/drm/radeon/r520.c
index fc78e64ae727..6cbcaa845192 100644
--- a/drivers/gpu/drm/radeon/r520.c
+++ b/drivers/gpu/drm/radeon/r520.c
@@ -299,9 +299,7 @@ int r520_init(struct radeon_device *rdev)
r520_mc_init(rdev);
rv515_debugfs(rdev);
/* Fence driver */
-   r = radeon_fence_driver_init(rdev);
-   if (r)
-   return r;
+   radeon_fence_driver_init(rdev);
/* Memory manager */
r = rad

Re:Re: [PATCH 0/4] delete useless function return values & remove meaningless if(r) check code

2021-06-20 Thread Bernard

From: "Christian König" 
Date: 2021-06-21 00:59:27
To:  Bernard Zhao ,Alex Deucher 
,David Airlie ,Daniel Vetter 
,amd-...@lists.freedesktop.org,dri-devel@lists.freedesktop.org,linux-ker...@vger.kernel.org
Subject: Re: [PATCH 0/4] delete useless function return values & remove 
meaningless if(r) check code>Am 19.06.21 um 08:43 schrieb Bernard Zhao:
>> Function radeon_fence_driver_init always returns success,
>> the function type maybe coule be changed to void.
>> This patch series will first delete the check of the return
>> value of the function call radeon_fence_driver_init, then,
>> optimise the function declaration and function to void type.
>
>Please merge all of this into a single patch, I don't see any point 
>separating this.
>
>Christian.

Hi
Sure, i will resubmit one new ptach, thanks!
BR//Bernard

>>
>> Signed-off-by: Bernard Zhao 
>>
>> Bernard Zhao (4):
>>drm/radeon: remove meaningless if(r) check code
>>drm/radeon: remove meaningless if(r) check code
>>drm/radeon: remove meaningless if(r) check code
>>drm/radeon: delete useless return values
>>
>>   drivers/gpu/drm/radeon/cik.c  | 4 +---
>>   drivers/gpu/drm/radeon/evergreen.c| 4 +---
>>   drivers/gpu/drm/radeon/ni.c   | 4 +---
>>   drivers/gpu/drm/radeon/r100.c | 4 +---
>>   drivers/gpu/drm/radeon/r300.c | 4 +---
>>   drivers/gpu/drm/radeon/r420.c | 5 +
>>   drivers/gpu/drm/radeon/r520.c | 4 +---
>>   drivers/gpu/drm/radeon/r600.c | 4 +---
>>   drivers/gpu/drm/radeon/radeon.h   | 2 +-
>>   drivers/gpu/drm/radeon/radeon_fence.c | 5 +
>>   drivers/gpu/drm/radeon/rs400.c| 4 +---
>>   drivers/gpu/drm/radeon/rs600.c| 4 +---
>>   drivers/gpu/drm/radeon/rs690.c| 4 +---
>>   drivers/gpu/drm/radeon/rv515.c| 4 +---
>>   drivers/gpu/drm/radeon/rv770.c| 4 +---
>>   drivers/gpu/drm/radeon/si.c   | 4 +---
>>   16 files changed, 16 insertions(+), 48 deletions(-)
>>
>




[PATCH 4/4] drm/radeon: delete useless return values

2021-06-19 Thread Bernard Zhao
Function radeon_fence_driver_init always returns success,
the function type maybe coule be changed to void.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/radeon/radeon.h   | 2 +-
 drivers/gpu/drm/radeon/radeon_fence.c | 5 +
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 56ed5634cebe..8a15f490a390 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -384,7 +384,7 @@ struct radeon_fence {
 };
 
 int radeon_fence_driver_start_ring(struct radeon_device *rdev, int ring);
-int radeon_fence_driver_init(struct radeon_device *rdev);
+void radeon_fence_driver_init(struct radeon_device *rdev);
 void radeon_fence_driver_fini(struct radeon_device *rdev);
 void radeon_fence_driver_force_completion(struct radeon_device *rdev, int 
ring);
 int radeon_fence_emit(struct radeon_device *rdev, struct radeon_fence **fence, 
int ring);
diff --git a/drivers/gpu/drm/radeon/radeon_fence.c 
b/drivers/gpu/drm/radeon/radeon_fence.c
index 0d8ef2368adf..b2ce642ca4fa 100644
--- a/drivers/gpu/drm/radeon/radeon_fence.c
+++ b/drivers/gpu/drm/radeon/radeon_fence.c
@@ -905,9 +905,8 @@ static void radeon_fence_driver_init_ring(struct 
radeon_device *rdev, int ring)
  * Not all asics have all rings, so each asic will only
  * start the fence driver on the rings it has using
  * radeon_fence_driver_start_ring().
- * Returns 0 for success.
  */
-int radeon_fence_driver_init(struct radeon_device *rdev)
+void radeon_fence_driver_init(struct radeon_device *rdev)
 {
int ring;
 
@@ -917,8 +916,6 @@ int radeon_fence_driver_init(struct radeon_device *rdev)
}
 
radeon_debugfs_fence_init(rdev);
-
-   return 0;
 }
 
 /**
-- 
2.31.0



[PATCH 2/4] drm/radeon: remove meaningless if(r) check code

2021-06-19 Thread Bernard Zhao
Function radeon_fence_driver_init always returns success,
remove meaningless if(r) check code.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/radeon/r100.c | 4 +---
 drivers/gpu/drm/radeon/r300.c | 4 +---
 drivers/gpu/drm/radeon/r420.c | 5 +
 drivers/gpu/drm/radeon/r520.c | 4 +---
 drivers/gpu/drm/radeon/r600.c | 4 +---
 5 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index fcfcaec25a9e..aa6800b0e198 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -4056,9 +4056,7 @@ int r100_init(struct radeon_device *rdev)
/* initialize VRAM */
r100_mc_init(rdev);
/* Fence driver */
-   r = radeon_fence_driver_init(rdev);
-   if (r)
-   return r;
+   radeon_fence_driver_init(rdev);
/* Memory manager */
r = radeon_bo_init(rdev);
if (r)
diff --git a/drivers/gpu/drm/radeon/r300.c b/drivers/gpu/drm/radeon/r300.c
index 92643dfdd8a8..621ff174dff3 100644
--- a/drivers/gpu/drm/radeon/r300.c
+++ b/drivers/gpu/drm/radeon/r300.c
@@ -1549,9 +1549,7 @@ int r300_init(struct radeon_device *rdev)
/* initialize memory controller */
r300_mc_init(rdev);
/* Fence driver */
-   r = radeon_fence_driver_init(rdev);
-   if (r)
-   return r;
+   radeon_fence_driver_init(rdev);
/* Memory manager */
r = radeon_bo_init(rdev);
if (r)
diff --git a/drivers/gpu/drm/radeon/r420.c b/drivers/gpu/drm/radeon/r420.c
index 1ed4407b91aa..7e6320e8c6a0 100644
--- a/drivers/gpu/drm/radeon/r420.c
+++ b/drivers/gpu/drm/radeon/r420.c
@@ -425,10 +425,7 @@ int r420_init(struct radeon_device *rdev)
r300_mc_init(rdev);
r420_debugfs(rdev);
/* Fence driver */
-   r = radeon_fence_driver_init(rdev);
-   if (r) {
-   return r;
-   }
+   radeon_fence_driver_init(rdev);
/* Memory manager */
r = radeon_bo_init(rdev);
if (r) {
diff --git a/drivers/gpu/drm/radeon/r520.c b/drivers/gpu/drm/radeon/r520.c
index fc78e64ae727..6cbcaa845192 100644
--- a/drivers/gpu/drm/radeon/r520.c
+++ b/drivers/gpu/drm/radeon/r520.c
@@ -299,9 +299,7 @@ int r520_init(struct radeon_device *rdev)
r520_mc_init(rdev);
rv515_debugfs(rdev);
/* Fence driver */
-   r = radeon_fence_driver_init(rdev);
-   if (r)
-   return r;
+   radeon_fence_driver_init(rdev);
/* Memory manager */
r = radeon_bo_init(rdev);
if (r)
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index 7444dc0e0c0e..ca3fcae2adb5 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -3282,9 +3282,7 @@ int r600_init(struct radeon_device *rdev)
/* Initialize clocks */
radeon_get_clock_info(rdev->ddev);
/* Fence driver */
-   r = radeon_fence_driver_init(rdev);
-   if (r)
-   return r;
+   radeon_fence_driver_init(rdev);
if (rdev->flags & RADEON_IS_AGP) {
r = radeon_agp_init(rdev);
if (r)
-- 
2.31.0



[PATCH 3/4] drm/radeon: remove meaningless if(r) check code

2021-06-19 Thread Bernard Zhao
Function radeon_fence_driver_init always returns success,
remove meaningless if(r) check code.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/radeon/rs400.c | 4 +---
 drivers/gpu/drm/radeon/rs600.c | 4 +---
 drivers/gpu/drm/radeon/rs690.c | 4 +---
 drivers/gpu/drm/radeon/rv515.c | 4 +---
 drivers/gpu/drm/radeon/rv770.c | 4 +---
 5 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/radeon/rs400.c b/drivers/gpu/drm/radeon/rs400.c
index 8423bcc3302b..6383f7a34bd8 100644
--- a/drivers/gpu/drm/radeon/rs400.c
+++ b/drivers/gpu/drm/radeon/rs400.c
@@ -555,9 +555,7 @@ int rs400_init(struct radeon_device *rdev)
/* initialize memory controller */
rs400_mc_init(rdev);
/* Fence driver */
-   r = radeon_fence_driver_init(rdev);
-   if (r)
-   return r;
+   radeon_fence_driver_init(rdev);
/* Memory manager */
r = radeon_bo_init(rdev);
if (r)
diff --git a/drivers/gpu/drm/radeon/rs600.c b/drivers/gpu/drm/radeon/rs600.c
index 5bf26058eec0..b2d22e25eee1 100644
--- a/drivers/gpu/drm/radeon/rs600.c
+++ b/drivers/gpu/drm/radeon/rs600.c
@@ -1132,9 +1132,7 @@ int rs600_init(struct radeon_device *rdev)
rs600_mc_init(rdev);
r100_debugfs_rbbm_init(rdev);
/* Fence driver */
-   r = radeon_fence_driver_init(rdev);
-   if (r)
-   return r;
+   radeon_fence_driver_init(rdev);
/* Memory manager */
r = radeon_bo_init(rdev);
if (r)
diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
index 7bc302a89232..14fb0819b8c1 100644
--- a/drivers/gpu/drm/radeon/rs690.c
+++ b/drivers/gpu/drm/radeon/rs690.c
@@ -850,9 +850,7 @@ int rs690_init(struct radeon_device *rdev)
rs690_mc_init(rdev);
rv515_debugfs(rdev);
/* Fence driver */
-   r = radeon_fence_driver_init(rdev);
-   if (r)
-   return r;
+   radeon_fence_driver_init(rdev);
/* Memory manager */
r = radeon_bo_init(rdev);
if (r)
diff --git a/drivers/gpu/drm/radeon/rv515.c b/drivers/gpu/drm/radeon/rv515.c
index 46a53dd38079..63fb06e8e2d7 100644
--- a/drivers/gpu/drm/radeon/rv515.c
+++ b/drivers/gpu/drm/radeon/rv515.c
@@ -648,9 +648,7 @@ int rv515_init(struct radeon_device *rdev)
rv515_mc_init(rdev);
rv515_debugfs(rdev);
/* Fence driver */
-   r = radeon_fence_driver_init(rdev);
-   if (r)
-   return r;
+   radeon_fence_driver_init(rdev);
/* Memory manager */
r = radeon_bo_init(rdev);
if (r)
diff --git a/drivers/gpu/drm/radeon/rv770.c b/drivers/gpu/drm/radeon/rv770.c
index 88e29ebaad46..74499307285b 100644
--- a/drivers/gpu/drm/radeon/rv770.c
+++ b/drivers/gpu/drm/radeon/rv770.c
@@ -1941,9 +1941,7 @@ int rv770_init(struct radeon_device *rdev)
/* Initialize clocks */
radeon_get_clock_info(rdev->ddev);
/* Fence driver */
-   r = radeon_fence_driver_init(rdev);
-   if (r)
-   return r;
+   radeon_fence_driver_init(rdev);
/* initialize AGP */
if (rdev->flags & RADEON_IS_AGP) {
r = radeon_agp_init(rdev);
-- 
2.31.0



[PATCH 1/4] drm/radeon: remove meaningless if(r) check code

2021-06-19 Thread Bernard Zhao
Function radeon_fence_driver_init always returns success,
remove meaningless if(r) check code.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/radeon/cik.c   | 4 +---
 drivers/gpu/drm/radeon/evergreen.c | 4 +---
 drivers/gpu/drm/radeon/ni.c| 4 +---
 drivers/gpu/drm/radeon/si.c| 4 +---
 4 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c
index 42a8afa839cb..f6cf0b8fdd83 100644
--- a/drivers/gpu/drm/radeon/cik.c
+++ b/drivers/gpu/drm/radeon/cik.c
@@ -8584,9 +8584,7 @@ int cik_init(struct radeon_device *rdev)
radeon_get_clock_info(rdev->ddev);
 
/* Fence driver */
-   r = radeon_fence_driver_init(rdev);
-   if (r)
-   return r;
+   radeon_fence_driver_init(rdev);
 
/* initialize memory controller */
r = cik_mc_init(rdev);
diff --git a/drivers/gpu/drm/radeon/evergreen.c 
b/drivers/gpu/drm/radeon/evergreen.c
index 8e9e88bf1f43..36a888e1b179 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -5208,9 +5208,7 @@ int evergreen_init(struct radeon_device *rdev)
/* Initialize clocks */
radeon_get_clock_info(rdev->ddev);
/* Fence driver */
-   r = radeon_fence_driver_init(rdev);
-   if (r)
-   return r;
+   radeon_fence_driver_init(rdev);
/* initialize AGP */
if (rdev->flags & RADEON_IS_AGP) {
r = radeon_agp_init(rdev);
diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
index ab7bd3080217..4a364ca7a1be 100644
--- a/drivers/gpu/drm/radeon/ni.c
+++ b/drivers/gpu/drm/radeon/ni.c
@@ -2375,9 +2375,7 @@ int cayman_init(struct radeon_device *rdev)
/* Initialize clocks */
radeon_get_clock_info(rdev->ddev);
/* Fence driver */
-   r = radeon_fence_driver_init(rdev);
-   if (r)
-   return r;
+   radeon_fence_driver_init(rdev);
/* initialize memory controller */
r = evergreen_mc_init(rdev);
if (r)
diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
index d0e94b10e4c0..013e44ed0f39 100644
--- a/drivers/gpu/drm/radeon/si.c
+++ b/drivers/gpu/drm/radeon/si.c
@@ -6857,9 +6857,7 @@ int si_init(struct radeon_device *rdev)
radeon_get_clock_info(rdev->ddev);
 
/* Fence driver */
-   r = radeon_fence_driver_init(rdev);
-   if (r)
-   return r;
+   radeon_fence_driver_init(rdev);
 
/* initialize memory controller */
r = si_mc_init(rdev);
-- 
2.31.0



[PATCH 0/4] delete useless function return values & remove meaningless if(r) check code

2021-06-19 Thread Bernard Zhao
Function radeon_fence_driver_init always returns success,
the function type maybe coule be changed to void.
This patch series will first delete the check of the return
value of the function call radeon_fence_driver_init, then,
optimise the function declaration and function to void type.

Signed-off-by: Bernard Zhao 

Bernard Zhao (4):
  drm/radeon: remove meaningless if(r) check code
  drm/radeon: remove meaningless if(r) check code
  drm/radeon: remove meaningless if(r) check code
  drm/radeon: delete useless return values

 drivers/gpu/drm/radeon/cik.c  | 4 +---
 drivers/gpu/drm/radeon/evergreen.c| 4 +---
 drivers/gpu/drm/radeon/ni.c   | 4 +---
 drivers/gpu/drm/radeon/r100.c | 4 +---
 drivers/gpu/drm/radeon/r300.c | 4 +---
 drivers/gpu/drm/radeon/r420.c | 5 +
 drivers/gpu/drm/radeon/r520.c | 4 +---
 drivers/gpu/drm/radeon/r600.c | 4 +---
 drivers/gpu/drm/radeon/radeon.h   | 2 +-
 drivers/gpu/drm/radeon/radeon_fence.c | 5 +
 drivers/gpu/drm/radeon/rs400.c| 4 +---
 drivers/gpu/drm/radeon/rs600.c| 4 +---
 drivers/gpu/drm/radeon/rs690.c| 4 +---
 drivers/gpu/drm/radeon/rv515.c| 4 +---
 drivers/gpu/drm/radeon/rv770.c| 4 +---
 drivers/gpu/drm/radeon/si.c   | 4 +---
 16 files changed, 16 insertions(+), 48 deletions(-)

-- 
2.31.0



[PATCH] drm/msm: cleanup coding style a bit

2021-06-07 Thread Bernard Zhao
cleanup coding style a bit

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/msm/adreno/a4xx_gpu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a4xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a4xx_gpu.c
index 82bebb40234d..87e834850e44 100644
--- a/drivers/gpu/drm/msm/adreno/a4xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a4xx_gpu.c
@@ -655,13 +655,13 @@ struct msm_gpu *a4xx_gpu_init(struct drm_device *dev)
if (!pdev) {
DRM_DEV_ERROR(dev->dev, "no a4xx device\n");
ret = -ENXIO;
-   goto fail;
+   return ERR_PTR(ret);
}
 
a4xx_gpu = kzalloc(sizeof(*a4xx_gpu), GFP_KERNEL);
if (!a4xx_gpu) {
ret = -ENOMEM;
-   goto fail;
+   return ERR_PTR(ret);
}
 
adreno_gpu = _gpu->base;
-- 
2.31.0



[PATCH] drm/msm: remove no need local variable

2021-06-05 Thread Bernard Zhao
Unneeded variable: "ret". Return "0" on line 880

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/msm/dp/dp_panel.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/msm/dp/dp_panel.c 
b/drivers/gpu/drm/msm/dp/dp_panel.c
index 9cc816663668..8cb3d016101c 100644
--- a/drivers/gpu/drm/msm/dp/dp_panel.c
+++ b/drivers/gpu/drm/msm/dp/dp_panel.c
@@ -351,7 +351,6 @@ void dp_panel_dump_regs(struct dp_panel *dp_panel)
 
 int dp_panel_timing_cfg(struct dp_panel *dp_panel)
 {
-   int rc = 0;
u32 data, total_ver, total_hor;
struct dp_catalog *catalog;
struct dp_panel_private *panel;
@@ -404,7 +403,7 @@ int dp_panel_timing_cfg(struct dp_panel *dp_panel)
dp_catalog_panel_timing_cfg(catalog);
panel->panel_on = true;
 
-   return rc;
+   return 0;
 }
 
 int dp_panel_init_panel_info(struct dp_panel *dp_panel)
-- 
2.31.0



[PATCH] drm/amd/display: remove no need variable

2021-06-05 Thread Bernard Zhao
remove no need variable, just return the DC_OK

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
index f962b905e79e..7daadb6a5233 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
@@ -1266,8 +1266,6 @@ static enum dc_status dcn10_validate_global(struct dc 
*dc, struct dc_state *cont
 
 static enum dc_status dcn10_patch_unknown_plane_state(struct dc_plane_state 
*plane_state)
 {
-   enum dc_status result = DC_OK;
-
enum surface_pixel_format surf_pix_format = plane_state->format;
unsigned int bpp = resource_pixel_format_to_bpp(surf_pix_format);
 
@@ -1279,7 +1277,7 @@ static enum dc_status 
dcn10_patch_unknown_plane_state(struct dc_plane_state *pla
swizzle = DC_SW_64KB_S;
 
plane_state->tiling_info.gfx9.swizzle = swizzle;
-   return result;
+   return DC_OK;
 }
 
 struct stream_encoder *dcn10_find_first_free_match_stream_enc_for_link(
-- 
2.31.0



[PATCH] drm/etnaviv: remove no need NULL check

2021-06-05 Thread Bernard Zhao
NULL check before kvfree functions is not needed.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 12 
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c 
b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
index d05c35994579..bd0d66ebf314 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
@@ -612,14 +612,10 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void 
*data,
 err_submit_cmds:
if (ret && (out_fence_fd >= 0))
put_unused_fd(out_fence_fd);
-   if (stream)
-   kvfree(stream);
-   if (bos)
-   kvfree(bos);
-   if (relocs)
-   kvfree(relocs);
-   if (pmrs)
-   kvfree(pmrs);
+   kvfree(stream);
+   kvfree(bos);
+   kvfree(relocs);
+   kvfree(pmrs);
 
return ret;
 }
-- 
2.31.0



[PATCH] drm/etnaviv: remove NULL check which is not needed

2021-06-05 Thread Bernard Zhao
NULL check before kvfree functions is not needed.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c 
b/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c
index b390dd4d60b7..d741b1d735f7 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c
@@ -80,8 +80,7 @@ static void etnaviv_gem_prime_release(struct 
etnaviv_gem_object *etnaviv_obj)
/* Don't drop the pages for imported dmabuf, as they are not
 * ours, just free the array we allocated:
 */
-   if (etnaviv_obj->pages)
-   kvfree(etnaviv_obj->pages);
+   kvfree(etnaviv_obj->pages);
 
drm_prime_gem_destroy(_obj->base, etnaviv_obj->sgt);
 }
-- 
2.31.0



[PATCH] drm/mediatek: remove redundant error log print

2021-06-03 Thread Bernard Zhao
Fix coccicheck warning:
drivers/gpu/drm/mediatek/mtk_dsi.c:1074:2-9: line 1074 is
redundant because platform_get_irq() already prints an error.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/mediatek/mtk_dsi.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c 
b/drivers/gpu/drm/mediatek/mtk_dsi.c
index ae403c67cbd9..e2e4fc8b1360 100644
--- a/drivers/gpu/drm/mediatek/mtk_dsi.c
+++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
@@ -1082,10 +1082,8 @@ static int mtk_dsi_probe(struct platform_device *pdev)
 
ret = devm_request_irq(>dev, irq_num, mtk_dsi_irq,
   IRQF_TRIGGER_NONE, dev_name(>dev), dsi);
-   if (ret) {
-   dev_err(>dev, "failed to request mediatek dsi irq\n");
+   if (ret)
goto err_unregister_host;
-   }
 
init_waitqueue_head(>irq_wait_queue);
 
-- 
2.31.0



[PATCH] drm/msm: fix warning "using plain integer as NULL pointer"

2021-05-09 Thread Bernard Zhao
Fix sparse warning:
drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c:1195:41: warning: Using plain integer 
as NULL pointer
drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c:1348:32: warning: Using plain integer 
as NULL pointer

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
index df7f3d3afd8b..cc5cceae80f4 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
@@ -1196,7 +1196,7 @@ static void dpu_plane_sspp_atomic_update(struct drm_plane 
*plane)
if (DPU_FORMAT_IS_YUV(fmt))
_dpu_plane_setup_csc(pdpu);
else
-   pdpu->csc_ptr = 0;
+   pdpu->csc_ptr = NULL;
}
 
_dpu_plane_set_qos_lut(plane, fb);
@@ -1349,7 +1349,7 @@ static void dpu_plane_reset(struct drm_plane *plane)
/* remove previous state, if present */
if (plane->state) {
dpu_plane_destroy_state(plane, plane->state);
-   plane->state = 0;
+   plane->state = NULL;
}
 
pstate = kzalloc(sizeof(*pstate), GFP_KERNEL);
-- 
2.31.0



Re:Re: [PATCH] drm/i915: Use might_alloc()

2021-05-07 Thread Bernard

From: Daniel Vetter 
Date: 2021-05-01 01:42:20
To:  kernel test robot 
Cc:  Bernard Zhao ,Jani Nikula 
,Joonas Lahtinen 
,Rodrigo Vivi ,David 
Airlie ,Daniel Vetter 
,intel-...@lists.freedesktop.org,dri-devel@lists.freedesktop.org,linux-ker...@vger.kernel.org,kbuild-...@lists.01.org
Subject: Re: [PATCH] drm/i915: Use might_alloc()>On Fri, Apr 30, 2021 at 
12:31:27AM +0800, kernel test robot wrote:
>> Hi Bernard,
>> 
>> Thank you for the patch! Yet something to improve:
>> 
>> [auto build test ERROR on drm-intel/for-linux-next]
>> [also build test ERROR on v5.12 next-20210429]
>> [If your patch is applied to the wrong git tree, kindly drop us a note.
>> And when submitting patch, we suggest to use '--base' as documented in
>> https://git-scm.com/docs/git-format-patch]
>> 
>> url:
>> https://github.com/0day-ci/linux/commits/Bernard-Zhao/drm-i915-Use-might_alloc/20210429-104516
>> base:   git://anongit.freedesktop.org/drm-intel for-linux-next
>> config: x86_64-rhel-8.3-kselftests (attached as .config)
>> compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
>> reproduce (this is a W=1 build):
>> # 
>> https://github.com/0day-ci/linux/commit/9fbd0c1741ce06241105d753ff3432ab55f3e94a
>>     git remote add linux-review https://github.com/0day-ci/linux
>> git fetch --no-tags linux-review 
>> Bernard-Zhao/drm-i915-Use-might_alloc/20210429-104516
>> git checkout 9fbd0c1741ce06241105d753ff3432ab55f3e94a
>> # save the attached .config to linux build tree
>> make W=1 W=1 ARCH=x86_64 
>> 
>> If you fix the issue, kindly add following tag as appropriate
>> Reported-by: kernel test robot 
>> 
>> All errors (new ones prefixed by >>):
>> 
>>drivers/gpu/drm/i915/i915_sw_fence.c: In function 
>> '__i915_sw_fence_await_sw_fence':
>> >> drivers/gpu/drm/i915/i915_sw_fence.c:344:2: error: implicit declaration 
>> >> of function 'might_alloc'; did you mean 'might_lock'? 
>> >> [-Werror=implicit-function-declaration]
>>  344 |  might_alloc(gfp);
>>  |  ^~~
>>  |  might_lock
>>cc1: some warnings being treated as errors
>
>I think you're missing an include or something. The other patch you've
>done seems good, I queued that up in drm-intel-gt-next for 5.14.
>
>Thanks, Daniel

Hi
It looks like I did not include the header file 
I will resubmit one patch, thanks!
BR//Bernard

>> 
>> 
>> vim +344 drivers/gpu/drm/i915/i915_sw_fence.c
>> 
>>335   
>>336   static int __i915_sw_fence_await_sw_fence(struct i915_sw_fence 
>> *fence,
>>337 struct i915_sw_fence 
>> *signaler,
>>338 wait_queue_entry_t 
>> *wq, gfp_t gfp)
>>339   {
>>340   unsigned int pending;
>>341   unsigned long flags;
>>342   
>>343   debug_fence_assert(fence);
>>  > 344   might_alloc(gfp);
>>345   
>>346   if (i915_sw_fence_done(signaler)) {
>>347   i915_sw_fence_set_error_once(fence, 
>> signaler->error);
>>348   return 0;
>>349   }
>>350   
>>351   debug_fence_assert(signaler);
>>352   
>>353   /* The dependency graph must be acyclic. */
>>354   if (unlikely(i915_sw_fence_check_if_after(fence, 
>> signaler)))
>>355   return -EINVAL;
>>356   
>>357   pending = I915_SW_FENCE_FLAG_FENCE;
>>358   if (!wq) {
>>359   wq = kmalloc(sizeof(*wq), gfp);
>>360   if (!wq) {
>>361   if (!gfpflags_allow_blocking(gfp))
>>362   return -ENOMEM;
>>363   
>>364   i915_sw_fence_wait(signaler);
>>365   i915_sw_fence_set_error_once(fence, 
>> signaler->error);
>>366   return 0;
>>367   }
>>368   
>>369   pending |= I915_SW_FENCE_FLAG_ALLOC;
>>370   }
>>371   
>>372   INIT_LIST_HEAD(>entry);
>>373   wq->flags = pending;
>>374   wq->func = i915_sw_fence_wake;
>>375  

[PATCH] drm/i915: Use might_alloc()

2021-04-28 Thread Bernard Zhao
This maybe used lockdep through the fs_reclaim annotations.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/i915/i915_sw_fence.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_sw_fence.c 
b/drivers/gpu/drm/i915/i915_sw_fence.c
index 2744558f3050..cc1b49cabb6c 100644
--- a/drivers/gpu/drm/i915/i915_sw_fence.c
+++ b/drivers/gpu/drm/i915/i915_sw_fence.c
@@ -341,7 +341,7 @@ static int __i915_sw_fence_await_sw_fence(struct 
i915_sw_fence *fence,
unsigned long flags;
 
debug_fence_assert(fence);
-   might_sleep_if(gfpflags_allow_blocking(gfp));
+   might_alloc(gfp);
 
if (i915_sw_fence_done(signaler)) {
i915_sw_fence_set_error_once(fence, signaler->error);
@@ -477,7 +477,7 @@ int i915_sw_fence_await_dma_fence(struct i915_sw_fence 
*fence,
int ret;
 
debug_fence_assert(fence);
-   might_sleep_if(gfpflags_allow_blocking(gfp));
+   might_alloc(gfp);
 
if (dma_fence_is_signaled(dma)) {
i915_sw_fence_set_error_once(fence, dma->error);
@@ -576,7 +576,7 @@ int i915_sw_fence_await_reservation(struct i915_sw_fence 
*fence,
int ret = 0, pending;
 
debug_fence_assert(fence);
-   might_sleep_if(gfpflags_allow_blocking(gfp));
+   might_alloc(gfp);
 
if (write) {
struct dma_fence **shared;
-- 
2.31.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/i915: Use might_alloc()

2021-04-28 Thread Bernard Zhao
This maybe uses lockdep through the fs_reclaim annotations.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/i915/i915_request.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_request.c 
b/drivers/gpu/drm/i915/i915_request.c
index 9165971c3c47..7e1aa540aa0d 100644
--- a/drivers/gpu/drm/i915/i915_request.c
+++ b/drivers/gpu/drm/i915/i915_request.c
@@ -928,7 +928,7 @@ __i915_request_create(struct intel_context *ce, gfp_t gfp)
u32 seqno;
int ret;
 
-   might_sleep_if(gfpflags_allow_blocking(gfp));
+   might_alloc(gfp);
 
/* Check that the caller provided an already pinned context */
__intel_context_pin(ce);
-- 
2.31.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/msm: remove unneeded variable ret

2021-04-07 Thread Bernard Zhao
This patch fix coccicheck warning:
drivers/gpu/drm/msm/dp/dp_link.c:848:5-8: Unneeded variable: "ret". Return "0" 
on line 880
Also remove unneeded function return value check.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/msm/dp/dp_link.c | 15 +++
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/msm/dp/dp_link.c b/drivers/gpu/drm/msm/dp/dp_link.c
index be986da78c4a..3395b08155a6 100644
--- a/drivers/gpu/drm/msm/dp/dp_link.c
+++ b/drivers/gpu/drm/msm/dp/dp_link.c
@@ -843,10 +843,8 @@ bool dp_link_send_edid_checksum(struct dp_link *dp_link, 
u8 checksum)
return ret == 1;
 }
 
-static int dp_link_parse_vx_px(struct dp_link_private *link)
+static void dp_link_parse_vx_px(struct dp_link_private *link)
 {
-   int ret = 0;
-
DRM_DEBUG_DP("vx: 0=%d, 1=%d, 2=%d, 3=%d\n",
drm_dp_get_adjust_request_voltage(link->link_status, 0),
drm_dp_get_adjust_request_voltage(link->link_status, 1),
@@ -876,8 +874,6 @@ static int dp_link_parse_vx_px(struct dp_link_private *link)
DRM_DEBUG_DP("Requested: v_level = 0x%x, p_level = 0x%x\n",
link->dp_link.phy_params.v_level,
link->dp_link.phy_params.p_level);
-
-   return ret;
 }
 
 /**
@@ -891,8 +887,6 @@ static int dp_link_parse_vx_px(struct dp_link_private *link)
 static int dp_link_process_phy_test_pattern_request(
struct dp_link_private *link)
 {
-   int ret = 0;
-
if (!(link->request.test_requested & DP_TEST_LINK_PHY_TEST_PATTERN)) {
DRM_DEBUG_DP("no phy test\n");
return -EINVAL;
@@ -918,12 +912,9 @@ static int dp_link_process_phy_test_pattern_request(
link->dp_link.link_params.rate =
drm_dp_bw_code_to_link_rate(link->request.test_link_rate);
 
-   ret = dp_link_parse_vx_px(link);
-
-   if (ret)
-   DRM_ERROR("parse_vx_px failed. ret=%d\n", ret);
+   dp_link_parse_vx_px(link);
 
-   return ret;
+   return 0;
 }
 
 static u8 get_link_status(const u8 link_status[DP_LINK_STATUS_SIZE], int r)
-- 
2.31.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/nouveau: fix potential abnormal lock/unlock

2021-04-02 Thread Bernard Zhao
Fix coccicheck warning:
drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c:115:3-9: preceding lock on line 
109
drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c:98:2-8: preceding lock on line 
95

As we see, function nvkm_fifo_chan_inst & nvkm_fifo_chan_chid both
use spin_lock_irqsave, but no spin_unlock_irqrestore in if/return
branch, seems like a potential bug?

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c 
b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c
index 2ed4ff05d207..e3f624d97644 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c
@@ -95,6 +95,7 @@ nvkm_fifo_chan_inst(struct nvkm_fifo *fifo, u64 inst, 
unsigned long *rflags)
spin_lock_irqsave(>lock, flags);
if ((chan = nvkm_fifo_chan_inst_locked(fifo, inst))) {
*rflags = flags;
+   spin_unlock_irqrestore(>lock, flags);
return chan;
}
spin_unlock_irqrestore(>lock, flags);
@@ -112,6 +113,7 @@ nvkm_fifo_chan_chid(struct nvkm_fifo *fifo, int chid, 
unsigned long *rflags)
list_del(>head);
list_add(>head, >chan);
*rflags = flags;
+   spin_unlock_irqrestore(>lock, flags);
return chan;
}
}
-- 
2.31.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/kmb: cleanup coding style a bit

2021-04-02 Thread Bernard Zhao
Fix coccicheck warning:
drivers/gpu/drm/kmb/kmb_dsi.c:284:3-4: Unneeded semicolon
drivers/gpu/drm/kmb/kmb_dsi.c:304:3-4: Unneeded semicolon
drivers/gpu/drm/kmb/kmb_dsi.c:321:3-4: Unneeded semicolon
drivers/gpu/drm/kmb/kmb_dsi.c:340:3-4: Unneeded semicolon
drivers/gpu/drm/kmb/kmb_dsi.c:364:2-3: Unneeded semicolon

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/kmb/kmb_dsi.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/kmb/kmb_dsi.c b/drivers/gpu/drm/kmb/kmb_dsi.c
index 4b5d82af84b3..231041b269f5 100644
--- a/drivers/gpu/drm/kmb/kmb_dsi.c
+++ b/drivers/gpu/drm/kmb/kmb_dsi.c
@@ -281,7 +281,7 @@ static u32 mipi_get_datatype_params(u32 data_type, u32 
data_mode,
default:
DRM_ERROR("DSI: Invalid data_mode %d\n", data_mode);
return -EINVAL;
-   };
+   }
break;
case DSI_LP_DT_PPS_YCBCR422_16B:
data_type_param.size_constraint_pixels = 2;
@@ -301,7 +301,7 @@ static u32 mipi_get_datatype_params(u32 data_type, u32 
data_mode,
default:
DRM_ERROR("DSI: Invalid data_mode %d\n", data_mode);
return -EINVAL;
-   };
+   }
break;
case DSI_LP_DT_LPPS_YCBCR422_20B:
case DSI_LP_DT_PPS_YCBCR422_24B:
@@ -318,7 +318,7 @@ static u32 mipi_get_datatype_params(u32 data_type, u32 
data_mode,
default:
DRM_ERROR("DSI: Invalid data_mode %d\n", data_mode);
return -EINVAL;
-   };
+   }
break;
case DSI_LP_DT_PPS_RGB565_16B:
data_type_param.size_constraint_pixels = 1;
@@ -337,7 +337,7 @@ static u32 mipi_get_datatype_params(u32 data_type, u32 
data_mode,
default:
DRM_ERROR("DSI: Invalid data_mode %d\n", data_mode);
return -EINVAL;
-   };
+   }
break;
case DSI_LP_DT_PPS_RGB666_18B:
data_type_param.size_constraint_pixels = 4;
@@ -361,7 +361,7 @@ static u32 mipi_get_datatype_params(u32 data_type, u32 
data_mode,
default:
DRM_ERROR("DSI: Invalid data_type %d\n", data_type);
return -EINVAL;
-   };
+   }
 
*params = data_type_param;
return 0;
-- 
2.31.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/gud: cleanup coding style a bit

2021-04-02 Thread Bernard Zhao
Fix coccicheck warning:
drivers/gpu/drm/gud/gud_internal.h:89:2-3: Unneeded semicolon
drivers/gpu/drm/gud/gud_internal.h:107:2-3: Unneeded semicolon

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/gud/gud_internal.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/gud/gud_internal.h 
b/drivers/gpu/drm/gud/gud_internal.h
index de2f2d2dbc60..b65105585578 100644
--- a/drivers/gpu/drm/gud/gud_internal.h
+++ b/drivers/gpu/drm/gud/gud_internal.h
@@ -86,7 +86,7 @@ static inline u8 gud_from_fourcc(u32 fourcc)
return GUD_PIXEL_FORMAT_XRGB;
case DRM_FORMAT_ARGB:
return GUD_PIXEL_FORMAT_ARGB;
-   };
+   }
 
return 0;
 }
@@ -104,7 +104,7 @@ static inline u32 gud_to_fourcc(u8 format)
return DRM_FORMAT_XRGB;
case GUD_PIXEL_FORMAT_ARGB:
return DRM_FORMAT_ARGB;
-   };
+   }
 
return 0;
 }
-- 
2.31.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/amd: remove not needed conversion to bool

2021-04-02 Thread Bernard Zhao
Fix coccicheck warning:
drivers/gpu/drm/amd/amdgpu/mmhub_v2_3.c:573:39-44: WARNING: conversion to bool 
not needed here
drivers/gpu/drm/amd/amdgpu/mmhub_v2_3.c:575:39-44: WARNING: conversion to bool 
not needed here

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/amd/amdgpu/mmhub_v2_3.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/mmhub_v2_3.c 
b/drivers/gpu/drm/amd/amdgpu/mmhub_v2_3.c
index ab9be5ad5a5f..0734e8ef5e41 100644
--- a/drivers/gpu/drm/amd/amdgpu/mmhub_v2_3.c
+++ b/drivers/gpu/drm/amd/amdgpu/mmhub_v2_3.c
@@ -570,9 +570,9 @@ static int mmhub_v2_3_set_clockgating(struct amdgpu_device 
*adev,
return 0;
 
mmhub_v2_3_update_medium_grain_clock_gating(adev,
-   state == AMD_CG_STATE_GATE ? true : false);
+   (state == AMD_CG_STATE_GATE));
mmhub_v2_3_update_medium_grain_light_sleep(adev,
-   state == AMD_CG_STATE_GATE ? true : false);
+   (state == AMD_CG_STATE_GATE));
 
return 0;
 }
-- 
2.31.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re:Re: [PATCH] drm/ttm: cleanup coding style a bit

2021-03-31 Thread Bernard


From: "Christian König" 
Date: 2021-03-31 21:15:22
To:  Bernard Zhao ,Huang Rui ,David Airlie 
,Daniel Vetter 
,dri-devel@lists.freedesktop.org,linux-ker...@vger.kernel.org
Cc:  opensource.ker...@vivo.com
Subject: Re: [PATCH] drm/ttm: cleanup coding style a bit>Am 31.03.21 um 15:12 
schrieb Bernard Zhao:
>> Fix sparse warning:
>> drivers/gpu/drm/ttm/ttm_bo.c:52:1: warning: symbol 'ttm_global_mutex' was 
>> not declared. Should it be static?
>> drivers/gpu/drm/ttm/ttm_bo.c:53:10: warning: symbol 'ttm_bo_glob_use_count' 
>> was not declared. Should it be static?
>>
>> Signed-off-by: Bernard Zhao 
>
>You are based on an outdated branch, please rebase on top of drm-misc-next.
>

Hi

Sure, thanks for your review!
I will fix this and resubmit this patch.

BR//Bernard

>Regards,
>Christian.
>
>> ---
>>   drivers/gpu/drm/ttm/ttm_bo.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
>> index 101a68dc615b..eab21643edfb 100644
>> --- a/drivers/gpu/drm/ttm/ttm_bo.c
>> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
>> @@ -49,8 +49,8 @@ static void ttm_bo_global_kobj_release(struct kobject 
>> *kobj);
>>   /*
>>* ttm_global_mutex - protecting the global BO state
>>*/
>> -DEFINE_MUTEX(ttm_global_mutex);
>> -unsigned ttm_bo_glob_use_count;
>> +static DEFINE_MUTEX(ttm_global_mutex);
>> +static unsigned int ttm_bo_glob_use_count;
>>   struct ttm_bo_global ttm_bo_glob;
>>   EXPORT_SYMBOL(ttm_bo_glob);
>>   
>


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] amd/amdgpu: code refactoring to clean code style a bit

2021-03-31 Thread Bernard Zhao
Fix checkpatch.pl warning:
Too many leading tabs - consider code refactoring
WARNING: Too many leading tabs - consider code refactoring
+   for (j = 0; j < 
profile->ucLeakageBinNum; j++) {

WARNING: Too many leading tabs - consider code refactoring
+   if (vbios_voltage_id <= 
leakage_bin[j]) {

WARNING: Too many leading tabs - consider code refactoring
+   for (j = 0; j < 
profile->ucLeakageBinNum; j++) {

WARNING: Too many leading tabs - consider code refactoring
+   if (vbios_voltage_id <= 
leakage_bin[j]) {

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c | 84 
 1 file changed, 35 insertions(+), 49 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
index 86add0f4ea4d..9968ff8ddc9c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
@@ -1283,65 +1283,51 @@ int 
amdgpu_atombios_get_leakage_vddc_based_on_leakage_params(struct amdgpu_devic
profile = (ATOM_ASIC_PROFILING_INFO_V2_1 *)
(adev->mode_info.atom_context->bios + data_offset);
 
-   switch (frev) {
-   case 1:
+   if ((frev != 2) || (crev != 1)) {
+   DRM_ERROR("Unknown table version %d, %d\n", frev, crev);
return -EINVAL;
-   case 2:
-   switch (crev) {
-   case 1:
-   if (size < sizeof(ATOM_ASIC_PROFILING_INFO_V2_1))
-   return -EINVAL;
-   leakage_bin = (u16 *)
-   (adev->mode_info.atom_context->bios + 
data_offset +
-le16_to_cpu(profile->usLeakageBinArrayOffset));
-   vddc_id_buf = (u16 *)
-   (adev->mode_info.atom_context->bios + 
data_offset +
-le16_to_cpu(profile->usElbVDDC_IdArrayOffset));
-   vddc_buf = (u16 *)
-   (adev->mode_info.atom_context->bios + 
data_offset +
-
le16_to_cpu(profile->usElbVDDC_LevelArrayOffset));
-   vddci_id_buf = (u16 *)
-   (adev->mode_info.atom_context->bios + 
data_offset +
-
le16_to_cpu(profile->usElbVDDCI_IdArrayOffset));
-   vddci_buf = (u16 *)
-   (adev->mode_info.atom_context->bios + 
data_offset +
-
le16_to_cpu(profile->usElbVDDCI_LevelArrayOffset));
-
-   if (profile->ucElbVDDC_Num > 0) {
-   for (i = 0; i < profile->ucElbVDDC_Num; i++) {
-   if (vddc_id_buf[i] == 
virtual_voltage_id) {
-   for (j = 0; j < 
profile->ucLeakageBinNum; j++) {
-   if (vbios_voltage_id <= 
leakage_bin[j]) {
-   *vddc = 
vddc_buf[j * profile->ucElbVDDC_Num + i];
-   break;
-   }
-   }
+   }
+
+   if (size < sizeof(ATOM_ASIC_PROFILING_INFO_V2_1))
+   return -EINVAL;
+
+   leakage_bin = (u16 *)(adev->mode_info.atom_context->bios + data_offset +
+le16_to_cpu(profile->usLeakageBinArrayOffset));
+   vddc_id_buf = (u16 *)(adev->mode_info.atom_context->bios + data_offset +
+le16_to_cpu(profile->usElbVDDC_IdArrayOffset));
+   vddc_buf = (u16 *)(adev->mode_info.atom_context->bios + data_offset +
+le16_to_cpu(profile->usElbVDDC_LevelArrayOffset));
+   vddci_id_buf = (u16 *)(adev->mode_info.atom_context->bios + data_offset 
+
+le16_to_cpu(profile->usElbVDDCI_IdArrayOffset));
+   vddci_buf = (u16 *)(adev->mode_info.atom_context->bios + data_offset +
+le16_to_cpu(profile->usElbVDDCI_LevelArrayOffset));
+
+   if (profile->ucElbVDDC_Num > 0) {
+   for (i = 0; i < profile->ucElbVDDC_Num; i++) {
+   if (vddc_id_buf[i] == virtual_voltage_id) {
+   for (j = 0; j < profile->ucLeakageBinNum; j++) {
+   if (vbios_voltage_id <= leakage_bin[j]) 
{
+   *vddc = vddc_buf[j * 
profile->ucElbVDDC_

[PATCH] /msm/adreno: fix different address spaces warning

2021-03-31 Thread Bernard Zhao
Fixes the following sparse warnings:
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:189:9:expected void [noderef] 
__iomem *addr
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:189:9:got void *
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:190:9: warning: incorrect type in 
argument 2 (different address spaces)
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:190:9:expected void [noderef] 
__iomem *addr
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:190:9:got void *
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:191:9: warning: incorrect type in 
argument 2 (different address spaces)
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:191:9:expected void [noderef] 
__iomem *addr
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:191:9:got void *
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:192:9: warning: incorrect type in 
argument 2 (different address spaces)
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:192:9:expected void [noderef] 
__iomem *addr
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:192:9:got void *
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:197:19: warning: incorrect type in 
argument 1 (different address spaces)
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:197:19:expected void const 
[noderef] __iomem *addr
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:197:19:got void *
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:198:19: warning: incorrect type in 
argument 1 (different address spaces)
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:198:19:expected void const 
[noderef] __iomem *addr
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:198:19:got void *
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:315:41: warning: incorrect type in 
argument 1 (different address spaces)
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:315:41:expected void *[noderef] 
__iomem cxdbg
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:315:41:got void [noderef] 
__iomem *cxdbg
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:189:9: warning: dereference of 
noderef expression
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:190:9: warning: dereference of 
noderef expression
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:191:9: warning: dereference of 
noderef expression
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:192:9: warning: dereference of 
noderef expression
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:197:19: warning: dereference of 
noderef expression
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:198:19: warning: dereference of 
noderef expression

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c | 36 ++---
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c
index c1699b4f9a89..e5558d09ddf9 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c
@@ -186,16 +186,16 @@ static int cx_debugbus_read(void *__iomem cxdbg, u32 
block, u32 offset,
u32 reg = A6XX_CX_DBGC_CFG_DBGBUS_SEL_A_PING_INDEX(offset) |
A6XX_CX_DBGC_CFG_DBGBUS_SEL_A_PING_BLK_SEL(block);
 
-   cxdbg_write(cxdbg, REG_A6XX_CX_DBGC_CFG_DBGBUS_SEL_A, reg);
-   cxdbg_write(cxdbg, REG_A6XX_CX_DBGC_CFG_DBGBUS_SEL_B, reg);
-   cxdbg_write(cxdbg, REG_A6XX_CX_DBGC_CFG_DBGBUS_SEL_C, reg);
-   cxdbg_write(cxdbg, REG_A6XX_CX_DBGC_CFG_DBGBUS_SEL_D, reg);
+   cxdbg_write(cxdbg, (void __iomem *)REG_A6XX_CX_DBGC_CFG_DBGBUS_SEL_A, 
reg);
+   cxdbg_write(cxdbg, (void __iomem *)REG_A6XX_CX_DBGC_CFG_DBGBUS_SEL_B, 
reg);
+   cxdbg_write(cxdbg, (void __iomem *)REG_A6XX_CX_DBGC_CFG_DBGBUS_SEL_C, 
reg);
+   cxdbg_write(cxdbg, (void __iomem *)REG_A6XX_CX_DBGC_CFG_DBGBUS_SEL_D, 
reg);
 
/* Wait 1 us to make sure the data is flowing */
udelay(1);
 
-   data[0] = cxdbg_read(cxdbg, REG_A6XX_CX_DBGC_CFG_DBGBUS_TRACE_BUF2);
-   data[1] = cxdbg_read(cxdbg, REG_A6XX_CX_DBGC_CFG_DBGBUS_TRACE_BUF1);
+   data[0] = cxdbg_read(cxdbg, (void __iomem 
*)REG_A6XX_CX_DBGC_CFG_DBGBUS_TRACE_BUF2);
+   data[1] = cxdbg_read(cxdbg, (void __iomem 
*)REG_A6XX_CX_DBGC_CFG_DBGBUS_TRACE_BUF1);
 
return 2;
 }
@@ -353,26 +353,26 @@ static void a6xx_get_debugbus(struct msm_gpu *gpu,
cxdbg = ioremap(res->start, resource_size(res));
 
if (cxdbg) {
-   cxdbg_write(cxdbg, REG_A6XX_CX_DBGC_CFG_DBGBUS_CNTLT,
+   cxdbg_write(cxdbg, (void __iomem 
*)REG_A6XX_CX_DBGC_CFG_DBGBUS_CNTLT,
A6XX_DBGC_CFG_DBGBUS_CNTLT_SEGT(0xf));
 
-   cxdbg_write(cxdbg, REG_A6XX_CX_DBGC_CFG_DBGBUS_CNTLM,
+   cxdbg_write(cxdbg, (void __iomem 
*)REG_A6XX_CX_DBGC_CFG_DBGBUS_CNTLM,
A6XX_DBGC_CFG_DBGBUS_CNTLM_ENABLE(0xf));
 
-   cxdbg_write(cxdbg, REG_A6XX_CX_DBGC_CFG_DBGBUS_IVTL_0, 0);
-   cxdbg_write(cxdbg, REG_A6XX_CX_DBGC_CFG_DBGBUS_IVTL_1, 0);
-   cxdbg_write(cxdbg, REG_A6XX_CX_DBGC_CFG_DBGBUS_IVTL_2

[PATCH] drm/ttm: cleanup coding style a bit

2021-03-31 Thread Bernard Zhao
Fix sparse warning:
drivers/gpu/drm/ttm/ttm_bo.c:52:1: warning: symbol 'ttm_global_mutex' was not 
declared. Should it be static?
drivers/gpu/drm/ttm/ttm_bo.c:53:10: warning: symbol 'ttm_bo_glob_use_count' was 
not declared. Should it be static?

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/ttm/ttm_bo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 101a68dc615b..eab21643edfb 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -49,8 +49,8 @@ static void ttm_bo_global_kobj_release(struct kobject *kobj);
 /*
  * ttm_global_mutex - protecting the global BO state
  */
-DEFINE_MUTEX(ttm_global_mutex);
-unsigned ttm_bo_glob_use_count;
+static DEFINE_MUTEX(ttm_global_mutex);
+static unsigned int ttm_bo_glob_use_count;
 struct ttm_bo_global ttm_bo_glob;
 EXPORT_SYMBOL(ttm_bo_glob);
 
-- 
2.31.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] msm/disp: dpu_plane cleanup-coding-style-a-bit

2021-03-31 Thread Bernard Zhao
Fix sparse warning:
drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c:1195:41: warning: Using plain integer 
as NULL pointer

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
index f898a8f67b7f..687a57850405 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
@@ -1223,7 +1223,7 @@ static void _dpu_plane_atomic_disable(struct drm_plane 
*plane)
 {
struct dpu_plane *pdpu = to_dpu_plane(plane);
struct drm_plane_state *state = plane->state;
-   struct dpu_plane_state *pstate = to_dpu_plane_state(state);
+   struct dpu_plane_state *pstate = (struct dpu_plane_state 
*)to_dpu_plane_state(state);
 
trace_dpu_plane_disable(DRMID(plane), is_dpu_plane_virtual(plane),
pstate->multirect_mode);
-- 
2.31.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/amd: use kmalloc_array over kmalloc with multiply

2021-03-31 Thread Bernard Zhao
Fix patch check warning:
WARNING: Prefer kmalloc_array over kmalloc with multiply
+   buf = kmalloc(MAX_KFIFO_SIZE * sizeof(*buf), GFP_KERNEL);

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c
index 17d1736367ea..246522423559 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c
@@ -81,7 +81,7 @@ static ssize_t kfd_smi_ev_read(struct file *filep, char 
__user *user,
struct kfd_smi_client *client = filep->private_data;
unsigned char *buf;
 
-   buf = kmalloc(MAX_KFIFO_SIZE * sizeof(*buf), GFP_KERNEL);
+   buf = kmalloc_array(MAX_KFIFO_SIZE, sizeof(*buf), GFP_KERNEL);
if (!buf)
return -ENOMEM;
 
-- 
2.31.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/amd: cleanup coding style a bit

2021-03-31 Thread Bernard Zhao
Fix patch check warning:
WARNING: suspect code indent for conditional statements (8, 17)
+   if (obj && obj->use < 0) {
+DRM_ERROR("RAS ERROR: Unbalance obj(%s) use\n", 
obj->head.name);

WARNING: braces {} are not necessary for single statement blocks
+   if (obj && obj->use < 0) {
+DRM_ERROR("RAS ERROR: Unbalance obj(%s) use\n", 
obj->head.name);
+   }

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
index 1fb2a91ad30a..43d17b72c265 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
@@ -449,11 +449,10 @@ static ssize_t amdgpu_ras_sysfs_read(struct device *dev,
 
 static inline void put_obj(struct ras_manager *obj)
 {
-   if (obj && --obj->use == 0)
+   if (obj && (--obj->use == 0))
list_del(>node);
-   if (obj && obj->use < 0) {
-DRM_ERROR("RAS ERROR: Unbalance obj(%s) use\n", 
obj->head.name);
-   }
+   if (obj && (obj->use < 0))
+   DRM_ERROR("RAS ERROR: Unbalance obj(%s) use\n", obj->head.name);
 }
 
 /* make one obj and return it. */
-- 
2.31.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/nouveau: cleanup-coding-style-a-bit

2021-03-31 Thread Bernard Zhao
This change is to make the code a bit readable.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c | 44 ++---
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c 
b/drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c
index 57df997c5ff3..053e86845d63 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/wndwc37e.c
@@ -41,9 +41,9 @@ static int
 wndwc37e_csc_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
struct nvif_push *push = wndw->wndw.push;
-   int ret;
+   int ret = PUSH_WAIT(push, 13);
 
-   if ((ret = PUSH_WAIT(push, 13)))
+   if (ret)
return ret;
 
PUSH_MTHD(push, NVC37E, SET_CSC_RED2RED, asyw->csc.matrix, 12);
@@ -54,9 +54,9 @@ static int
 wndwc37e_ilut_clr(struct nv50_wndw *wndw)
 {
struct nvif_push *push = wndw->wndw.push;
-   int ret;
+   int ret = PUSH_WAIT(push, 2);
 
-   if ((ret = PUSH_WAIT(push, 2)))
+   if (ret)
return ret;
 
PUSH_MTHD(push, NVC37E, SET_CONTEXT_DMA_INPUT_LUT, 0x);
@@ -67,9 +67,9 @@ static int
 wndwc37e_ilut_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
struct nvif_push *push = wndw->wndw.push;
-   int ret;
+   int ret = PUSH_WAIT(push, 4);
 
-   if ((ret = PUSH_WAIT(push, 4)))
+   if (ret)
return ret;
 
PUSH_MTHD(push, NVC37E, SET_CONTROL_INPUT_LUT,
@@ -100,9 +100,9 @@ int
 wndwc37e_blend_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
struct nvif_push *push = wndw->wndw.push;
-   int ret;
+   int ret = PUSH_WAIT(push, 8);
 
-   if ((ret = PUSH_WAIT(push, 8)))
+   if (ret)
return ret;
 
PUSH_MTHD(push, NVC37E, SET_COMPOSITION_CONTROL,
@@ -145,9 +145,9 @@ int
 wndwc37e_image_clr(struct nv50_wndw *wndw)
 {
struct nvif_push *push = wndw->wndw.push;
-   int ret;
+   int ret = PUSH_WAIT(push, 4);
 
-   if ((ret = PUSH_WAIT(push, 4)))
+   if (ret)
return ret;
 
PUSH_MTHD(push, NVC37E, SET_PRESENT_CONTROL,
@@ -162,9 +162,9 @@ static int
 wndwc37e_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
struct nvif_push *push = wndw->wndw.push;
-   int ret;
+   int ret = PUSH_WAIT(push, 17);
 
-   if ((ret = PUSH_WAIT(push, 17)))
+   if (ret)
return ret;
 
PUSH_MTHD(push, NVC37E, SET_PRESENT_CONTROL,
@@ -215,9 +215,9 @@ int
 wndwc37e_ntfy_clr(struct nv50_wndw *wndw)
 {
struct nvif_push *push = wndw->wndw.push;
-   int ret;
+   int ret = PUSH_WAIT(push, 2);
 
-   if ((ret = PUSH_WAIT(push, 2)))
+   if (ret)
return ret;
 
PUSH_MTHD(push, NVC37E, SET_CONTEXT_DMA_NOTIFIER, 0x);
@@ -228,9 +228,9 @@ int
 wndwc37e_ntfy_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
struct nvif_push *push = wndw->wndw.push;
-   int ret;
+   int ret = PUSH_WAIT(push, 3);
 
-   if ((ret = PUSH_WAIT(push, 3)))
+   if (ret)
return ret;
 
PUSH_MTHD(push, NVC37E, SET_CONTEXT_DMA_NOTIFIER, asyw->ntfy.handle,
@@ -245,9 +245,9 @@ int
 wndwc37e_sema_clr(struct nv50_wndw *wndw)
 {
struct nvif_push *push = wndw->wndw.push;
-   int ret;
+   int ret = PUSH_WAIT(push, 2);
 
-   if ((ret = PUSH_WAIT(push, 2)))
+   if (ret)
return ret;
 
PUSH_MTHD(push, NVC37E, SET_CONTEXT_DMA_SEMAPHORE, 0x);
@@ -258,9 +258,9 @@ int
 wndwc37e_sema_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
 {
struct nvif_push *push = wndw->wndw.push;
-   int ret;
+   int ret = PUSH_WAIT(push, 5);
 
-   if ((ret = PUSH_WAIT(push, 5)))
+   if (ret)
return ret;
 
PUSH_MTHD(push, NVC37E, SET_SEMAPHORE_CONTROL, asyw->sema.offset,
@@ -274,9 +274,9 @@ int
 wndwc37e_update(struct nv50_wndw *wndw, u32 *interlock)
 {
struct nvif_push *push = wndw->wndw.push;
-   int ret;
+   int ret = PUSH_WAIT(push, 5);
 
-   if ((ret = PUSH_WAIT(push, 5)))
+   if (ret)
return ret;
 
PUSH_MTHD(push, NVC37E, SET_INTERLOCK_FLAGS, 
interlock[NV50_DISP_INTERLOCK_CURS] << 1 |
-- 
2.31.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/msm: remove unneeded variable: "rc"

2021-02-03 Thread Bernard Zhao
remove unneeded variable: "rc".

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/msm/dp/dp_panel.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/msm/dp/dp_panel.c 
b/drivers/gpu/drm/msm/dp/dp_panel.c
index d1780bcac8cc..9cc816663668 100644
--- a/drivers/gpu/drm/msm/dp/dp_panel.c
+++ b/drivers/gpu/drm/msm/dp/dp_panel.c
@@ -409,7 +409,6 @@ int dp_panel_timing_cfg(struct dp_panel *dp_panel)
 
 int dp_panel_init_panel_info(struct dp_panel *dp_panel)
 {
-   int rc = 0;
struct drm_display_mode *drm_mode;
 
drm_mode = _panel->dp_mode.drm_mode;
@@ -436,7 +435,7 @@ int dp_panel_init_panel_info(struct dp_panel *dp_panel)
min_t(u32, dp_panel->dp_mode.bpp, 30));
DRM_DEBUG_DP("updated bpp = %d\n", dp_panel->dp_mode.bpp);
 
-   return rc;
+   return 0;
 }
 
 struct dp_panel *dp_panel_get(struct dp_panel_in *in)
-- 
2.29.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/hisilicon: remove redundant when devm_kzalloc failed

2021-02-03 Thread Bernard Zhao
Line 852 DRM_ERROR is redundant because memory alloc already
prints an error when failed.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c 
b/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c
index 00e87c290796..8491d8267f07 100644
--- a/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c
+++ b/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c
@@ -852,10 +852,9 @@ static int dsi_probe(struct platform_device *pdev)
int ret;
 
data = devm_kzalloc(>dev, sizeof(*data), GFP_KERNEL);
-   if (!data) {
-   DRM_ERROR("failed to allocate dsi data.\n");
+   if (!data)
return -ENOMEM;
-   }
+
dsi = >dsi;
ctx = >ctx;
dsi->ctx = ctx;
-- 
2.29.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] amd/display: remove unneeded variable: "pattern"

2021-02-03 Thread Bernard Zhao
Remove unneeded variable: "pattern".

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
index f95bade59624..d77ae58210f6 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
@@ -126,9 +126,7 @@ static void dpcd_set_training_pattern(
 static enum dc_dp_training_pattern decide_cr_training_pattern(
const struct dc_link_settings *link_settings)
 {
-   enum dc_dp_training_pattern pattern = DP_TRAINING_PATTERN_SEQUENCE_1;
-
-   return pattern;
+   return DP_TRAINING_PATTERN_SEQUENCE_1;
 }
 
 static enum dc_dp_training_pattern decide_eq_training_pattern(struct dc_link 
*link,
-- 
2.29.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] gpu/drm/msm: remove redundant when devm_kzalloc failed

2021-02-03 Thread Bernard Zhao
Line 1826 pr_err is redundant because memory alloc already
prints an error when failed.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/msm/dsi/dsi_host.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c 
b/drivers/gpu/drm/msm/dsi/dsi_host.c
index ab281cba0f08..246d3f06f3ef 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -1826,8 +1826,6 @@ int msm_dsi_host_init(struct msm_dsi *msm_dsi)
 
msm_host = devm_kzalloc(>dev, sizeof(*msm_host), GFP_KERNEL);
if (!msm_host) {
-   pr_err("%s: FAILED: cannot alloc dsi host\n",
-  __func__);
ret = -ENOMEM;
goto fail;
}
-- 
2.29.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/tegra: remove unneeded variable: "ret"

2021-02-03 Thread Bernard Zhao
remove unneeded variable: "ret".

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/tegra/dpaux.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/tegra/dpaux.c b/drivers/gpu/drm/tegra/dpaux.c
index 105fb9cdbb3b..b8abd55f3ef8 100644
--- a/drivers/gpu/drm/tegra/dpaux.c
+++ b/drivers/gpu/drm/tegra/dpaux.c
@@ -279,7 +279,6 @@ static void tegra_dpaux_hotplug(struct work_struct *work)
 static irqreturn_t tegra_dpaux_irq(int irq, void *data)
 {
struct tegra_dpaux *dpaux = data;
-   irqreturn_t ret = IRQ_HANDLED;
u32 value;
 
/* clear interrupts */
@@ -296,7 +295,7 @@ static irqreturn_t tegra_dpaux_irq(int irq, void *data)
if (value & DPAUX_INTR_AUX_DONE)
complete(>complete);
 
-   return ret;
+   return IRQ_HANDLED;
 }
 
 enum tegra_dpaux_functions {
-- 
2.29.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/vc4: remove unneeded variable: "ret"

2021-02-03 Thread Bernard Zhao
remove unneeded variable: "ret".

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/vc4/vc4_gem.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c
index b641252939d8..445d3bab89e0 100644
--- a/drivers/gpu/drm/vc4/vc4_gem.c
+++ b/drivers/gpu/drm/vc4/vc4_gem.c
@@ -1026,7 +1026,6 @@ int vc4_queue_seqno_cb(struct drm_device *dev,
   void (*func)(struct vc4_seqno_cb *cb))
 {
struct vc4_dev *vc4 = to_vc4_dev(dev);
-   int ret = 0;
unsigned long irqflags;
 
cb->func = func;
@@ -1041,7 +1040,7 @@ int vc4_queue_seqno_cb(struct drm_device *dev,
}
spin_unlock_irqrestore(>job_lock, irqflags);
 
-   return ret;
+   return 0;
 }
 
 /* Scheduled when any job has been completed, this walks the list of
-- 
2.29.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/bridge/analogix: remove redundant when devm_kzalloc failed

2021-02-03 Thread Bernard Zhao
Line 1590 DRM_ERROR is redundant because devm_kzalloc() already
prints an error.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c 
b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index aa1bb86293fd..8f6258eb9960 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -1586,10 +1586,8 @@ static int analogix_dp_create_bridge(struct drm_device 
*drm_dev,
int ret;
 
bridge = devm_kzalloc(drm_dev->dev, sizeof(*bridge), GFP_KERNEL);
-   if (!bridge) {
-   DRM_ERROR("failed to allocate for drm bridge\n");
+   if (!bridge)
return -ENOMEM;
-   }
 
dp->bridge = bridge;
 
-- 
2.29.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/via: fix assignment in if condition

2020-11-19 Thread Bernard Zhao
Fix check_patch.pl warning:
ERROR: do not use assignment in if condition
+   if ((HALCYON_HEADER2 == (cmd = *buf)) &&

ERROR: do not use assignment in if condition
+   if (HALCYON_HEADER2 == (cmd = *buf))

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/via/via_verifier.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/via/via_verifier.c 
b/drivers/gpu/drm/via/via_verifier.c
index 8d8135f424ef..3d6e3a70f318 100644
--- a/drivers/gpu/drm/via/via_verifier.c
+++ b/drivers/gpu/drm/via/via_verifier.c
@@ -1001,8 +1001,8 @@ via_verify_command_stream(const uint32_t * buf, unsigned 
int size,
state = via_check_vheader6(, buf_end);
break;
case state_command:
-   if ((HALCYON_HEADER2 == (cmd = *buf)) &&
-   supported_3d)
+   cmd = *buf;
+   if ((cmd == HALCYON_HEADER2) && supported_3d)
state = state_header2;
else if ((cmd & HALCYON_HEADER1MASK) == HALCYON_HEADER1)
state = state_header1;
@@ -1064,7 +1064,8 @@ via_parse_command_stream(struct drm_device *dev, const 
uint32_t *buf,
state = via_parse_vheader6(dev_priv, , buf_end);
break;
case state_command:
-   if (HALCYON_HEADER2 == (cmd = *buf))
+   cmd = *buf;
+   if (cmd == HALCYON_HEADER2)
state = state_header2;
else if ((cmd & HALCYON_HEADER1MASK) == HALCYON_HEADER1)
state = state_header1;
-- 
2.29.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2] drm/vmwgfx: use min_t to replace min

2020-11-19 Thread Bernard Zhao
Use min_t to replace min, min_t is a bit fast because min use
twice typeof.
This patch also fix check_patch.pl warning:
WARNING: min() should probably be min_t(unsigned long, num_pages,
VMW_PPN_PER_REMAP)
+unsigned long nr = min(num_pages, (unsigned long)
VMW_PPN_PER_REMAP);

Signed-off-by: Bernard Zhao 
Reported-by: kernel test robot 
---
Changes since V1:
*fix compile error reported by kernel test robot

Link for V1:
*https://lore.kernel.org/patchwork/patch/1340996/
---
 drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c
index 83c0d5a3e4fd..525d5e1227e8 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c
@@ -72,7 +72,7 @@ static int vmw_gmr2_bind(struct vmw_private *dev_priv,
SVGA_REMAP_GMR2_PPN64 : SVGA_REMAP_GMR2_PPN32;
 
while (num_pages > 0) {
-   unsigned long nr = min(num_pages, (unsigned 
long)VMW_PPN_PER_REMAP);
+   unsigned long nr = min_t(unsigned long, num_pages, 
VMW_PPN_PER_REMAP);
 
remap_cmd.offsetPages = remap_pos;
remap_cmd.numPages = nr;
-- 
2.29.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/vmwgfx: use min_t to replace min

2020-11-19 Thread Bernard Zhao
Use min_t to replace min, min_t is a bit fast because min use
twice typeof.
This patch also fix check_patch.pl warning:
WARNING: min() should probably be min_t(unsigned long, num_pages,
VMW_PPN_PER_REMAP)
+unsigned long nr = min(num_pages, (unsigned long)
VMW_PPN_PER_REMAP);

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c
index 83c0d5a3e4fd..b8f6fe1a71e6 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c
@@ -72,7 +72,7 @@ static int vmw_gmr2_bind(struct vmw_private *dev_priv,
SVGA_REMAP_GMR2_PPN64 : SVGA_REMAP_GMR2_PPN32;
 
while (num_pages > 0) {
-   unsigned long nr = min(num_pages, (unsigned 
long)VMW_PPN_PER_REMAP);
+   unsigned long nr = min_t((unsigned long), num_pages, 
VMW_PPN_PER_REMAP);
 
remap_cmd.offsetPages = remap_pos;
remap_cmd.numPages = nr;
-- 
2.29.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] via/via_irq: use __func__ to replace string function name

2020-11-19 Thread Bernard Zhao
This change also fix checkpatch.pl warning:
WARNING: Prefer using '"%s...", __func__' to using
'via_driver_irq_postinstall', this function's name, in a string
+   DRM_DEBUG("via_driver_irq_postinstall\n");

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/via/via_irq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
index 24cc445169e2..56ce5d4ee24a 100644
--- a/drivers/gpu/drm/via/via_irq.c
+++ b/drivers/gpu/drm/via/via_irq.c
@@ -308,7 +308,7 @@ int via_driver_irq_postinstall(struct drm_device *dev)
drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
u32 status;
 
-   DRM_DEBUG("via_driver_irq_postinstall\n");
+   DRM_DEBUG("fun: %s\n", __func__);
if (!dev_priv)
return -EINVAL;
 
-- 
2.29.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] amdgpu/amdgpu_ids: fix kmalloc_array not uses number as first arg

2020-11-18 Thread Bernard Zhao
Fix check_patch.pl warning:
kmalloc_array uses number as first arg, sizeof is generally wrong.
+fences = kmalloc_array(sizeof(void *), id_mgr->num_ids,
GFP_KERNEL);

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
index 6e9a9e5dbea0..f2bd4b0e06f6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
@@ -208,7 +208,7 @@ static int amdgpu_vmid_grab_idle(struct amdgpu_vm *vm,
if (ring->vmid_wait && !dma_fence_is_signaled(ring->vmid_wait))
return amdgpu_sync_fence(sync, ring->vmid_wait);
 
-   fences = kmalloc_array(sizeof(void *), id_mgr->num_ids, GFP_KERNEL);
+   fences = kmalloc_array(id_mgr->num_ids, sizeof(void *), GFP_KERNEL);
if (!fences)
return -ENOMEM;
 
-- 
2.29.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] amd/amdgpu: use kmalloc_array to replace kmalloc with multiply

2020-11-18 Thread Bernard Zhao
Fix check_patch.pl warning:
WARNING: Prefer kmalloc_array over kmalloc with multiply
+bps = kmalloc(align_space * sizeof((*data)->bps), GFP_KERNEL);
WARNING: Prefer kmalloc_array over kmalloc with multiply
+bps_bo = kmalloc(align_space * sizeof((*data)->bps_bo),
GFP_KERNEL);
kmalloc_array has multiply overflow check, which will be safer.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
index d0aea5e39531..f2a0851c804f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
@@ -280,8 +280,8 @@ static int amdgpu_virt_init_ras_err_handler_data(struct 
amdgpu_device *adev)
if (!*data)
return -ENOMEM;
 
-   bps = kmalloc(align_space * sizeof((*data)->bps), GFP_KERNEL);
-   bps_bo = kmalloc(align_space * sizeof((*data)->bps_bo), GFP_KERNEL);
+   bps = kmalloc_array(align_space, sizeof((*data)->bps), GFP_KERNEL);
+   bps_bo = kmalloc_array(align_space, sizeof((*data)->bps_bo), 
GFP_KERNEL);
 
if (!bps || !bps_bo) {
kfree(bps);
-- 
2.29.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] amd/amdgpu: optimise CONFIG_X||CONFIG_X_MODULE to IS_ENABLED(X)

2020-11-18 Thread Bernard Zhao
Optimise CONFIG_ || CONFIG__MODULE to IS_ENABLED().
This change also fix check_patch.pl warning:
WARNING: Prefer IS_ENABLED() to CONFIG_ ||
CONFIG__MODULE
+#if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || defined
(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
index 165b02e267b0..f1980cd1f402 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
@@ -64,7 +64,7 @@ struct amdgpu_atif {
struct amdgpu_atif_notifications notifications;
struct amdgpu_atif_functions functions;
struct amdgpu_atif_notification_cfg notification_cfg;
-#if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || 
defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
+#if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE)
struct backlight_device *bd;
 #endif
struct amdgpu_dm_backlight_caps backlight_caps;
@@ -447,7 +447,7 @@ static int amdgpu_atif_handler(struct amdgpu_device *adev,
DRM_DEBUG_DRIVER("ATIF: %d pending SBIOS requests\n", count);
 
if (req.pending & ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST) {
-#if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || 
defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
+#if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE)
if (atif->bd) {
DRM_DEBUG_DRIVER("Changing brightness to %d\n",
 req.backlight_level);
@@ -806,7 +806,7 @@ int amdgpu_acpi_init(struct amdgpu_device *adev)
}
adev->atif = atif;
 
-#if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || 
defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
+#if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE)
if (atif->notifications.brightness_change) {
if (amdgpu_device_has_dc_support(adev)) {
 #if defined(CONFIG_DRM_AMD_DC)
-- 
2.29.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 0/5] add KERN_LEVEL to printk

2020-11-12 Thread Bernard Zhao
Hi:

When call printk, set the KERN_LEVEL is suggested by the community.
This patch sereies add KERN_* level to printk which do not set
this level.

Bernard Zhao (5):
  adreno/a2xx_gpu.c: add KERN_LEVEL to printk
  adreno/a3xx_gpu.c: add KERN_LEVEL to printk
  adreno/a4xx_gpu.c: add KERN_LEVEL to printk
  adreno/a5xx_gpu.c: add KERN_LEVEL to printk
  adreno/adreno_gpu.c: add KERN_LEVEL to printk

 drivers/gpu/drm/msm/adreno/a2xx_gpu.c   |  4 ++--
 drivers/gpu/drm/msm/adreno/a3xx_gpu.c   |  4 ++--
 drivers/gpu/drm/msm/adreno/a4xx_gpu.c   |  6 +++---
 drivers/gpu/drm/msm/adreno/a5xx_gpu.c   |  2 +-
 drivers/gpu/drm/msm/adreno/adreno_gpu.c | 12 ++--
 5 files changed, 14 insertions(+), 14 deletions(-)

-- 
2.29.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 2/5] adreno/a3xx_gpu.c: add KERN_LEVEL to printk

2020-11-12 Thread Bernard Zhao
Add KERN_LEVEL to printk.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/msm/adreno/a3xx_gpu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a3xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a3xx_gpu.c
index f29c77d9cd42..64c9a9448f53 100644
--- a/drivers/gpu/drm/msm/adreno/a3xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a3xx_gpu.c
@@ -356,7 +356,7 @@ static void a3xx_recover(struct msm_gpu *gpu)
adreno_dump_info(gpu);
 
for (i = 0; i < 8; i++) {
-   printk("CP_SCRATCH_REG%d: %u\n", i,
+   printk(KERN_DEBUG "CP_SCRATCH_REG%d: %u\n", i,
gpu_read(gpu, REG_AXXX_CP_SCRATCH_REG0 + i));
}
 
@@ -459,7 +459,7 @@ static const unsigned int a3xx_registers[] = {
 /* would be nice to not have to duplicate the _show() stuff with printk(): */
 static void a3xx_dump(struct msm_gpu *gpu)
 {
-   printk("status:   %08x\n",
+   printk(KERN_DEBUG "status:   %08x\n",
gpu_read(gpu, REG_A3XX_RBBM_STATUS));
adreno_dump(gpu);
 }
-- 
2.29.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 1/5] adreno/a2xx_gpu.c: add KERN_LEVEL to printk

2020-11-12 Thread Bernard Zhao
Add KERN_LEVEL to printk.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/msm/adreno/a2xx_gpu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a2xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a2xx_gpu.c
index 7e82c41a85f1..33b45d237e56 100644
--- a/drivers/gpu/drm/msm/adreno/a2xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a2xx_gpu.c
@@ -252,7 +252,7 @@ static void a2xx_recover(struct msm_gpu *gpu)
adreno_dump_info(gpu);
 
for (i = 0; i < 8; i++) {
-   printk("CP_SCRATCH_REG%d: %u\n", i,
+   printk(KERN_DEBUG "CP_SCRATCH_REG%d: %u\n", i,
gpu_read(gpu, REG_AXXX_CP_SCRATCH_REG0 + i));
}
 
@@ -429,7 +429,7 @@ static const unsigned int a225_registers[] = {
 /* would be nice to not have to duplicate the _show() stuff with printk(): */
 static void a2xx_dump(struct msm_gpu *gpu)
 {
-   printk("status:   %08x\n",
+   printk(KERN_DEBUG "status:   %08x\n",
gpu_read(gpu, REG_A2XX_RBBM_STATUS));
adreno_dump(gpu);
 }
-- 
2.29.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 4/5] adreno/a5xx_gpu.c: add KERN_LEVEL to printk

2020-11-12 Thread Bernard Zhao
Add KERN_LEVEL to printk.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
index d6804a802355..c3ac78a32caf 100644
--- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
@@ -847,7 +847,7 @@ static void a5xx_recover(struct msm_gpu *gpu)
adreno_dump_info(gpu);
 
for (i = 0; i < 8; i++) {
-   printk("CP_SCRATCH_REG%d: %u\n", i,
+   printk(KERN_DEBUG "CP_SCRATCH_REG%d: %u\n", i,
gpu_read(gpu, REG_A5XX_CP_SCRATCH_REG(i)));
}
 
-- 
2.29.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 5/5] adreno/adreno_gpu.c: add KERN_LEVEL to printk

2020-11-12 Thread Bernard Zhao
Add KERN_LEVEL to printk.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/msm/adreno/adreno_gpu.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c 
b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
index 458b5b26d3c2..be752db5abed 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
@@ -725,7 +725,7 @@ void adreno_dump_info(struct msm_gpu *gpu)
struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
int i;
 
-   printk("revision: %d (%d.%d.%d.%d)\n",
+   printk(KERN_DEBUG "revision: %d (%d.%d.%d.%d)\n",
adreno_gpu->info->revn, adreno_gpu->rev.core,
adreno_gpu->rev.major, adreno_gpu->rev.minor,
adreno_gpu->rev.patchid);
@@ -733,12 +733,12 @@ void adreno_dump_info(struct msm_gpu *gpu)
for (i = 0; i < gpu->nr_rings; i++) {
struct msm_ringbuffer *ring = gpu->rb[i];
 
-   printk("rb %d: fence:%d/%d\n", i,
+   printk(KERN_DEBUG "rb %d: fence:%d/%d\n", i,
ring->memptrs->fence,
ring->seqno);
 
-   printk("rptr: %d\n", get_rptr(adreno_gpu, ring));
-   printk("rb wptr:  %d\n", get_wptr(ring));
+   printk(KERN_DEBUG "rptr: %d\n", get_rptr(adreno_gpu, ring));
+   printk(KERN_DEBUG "rb wptr:  %d\n", get_wptr(ring));
}
 }
 
@@ -752,7 +752,7 @@ void adreno_dump(struct msm_gpu *gpu)
return;
 
/* dump these out in a form that can be parsed by demsm: */
-   printk("IO:region %s  0002\n", gpu->name);
+   printk(KERN_DEBUG "IO:region %s  0002\n", gpu->name);
for (i = 0; adreno_gpu->registers[i] != ~0; i += 2) {
uint32_t start = adreno_gpu->registers[i];
uint32_t end   = adreno_gpu->registers[i+1];
@@ -760,7 +760,7 @@ void adreno_dump(struct msm_gpu *gpu)
 
for (addr = start; addr <= end; addr++) {
uint32_t val = gpu_read(gpu, addr);
-   printk("IO:R %08x %08x\n", addr<<2, val);
+   printk(KERN_DEBUG "IO:R %7x %08x\n", addr<<2, val);
}
}
 }
-- 
2.29.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 3/5] adreno/a4xx_gpu.c: add KERN_LEVEL to printk

2020-11-12 Thread Bernard Zhao
Add KERN_LEVEL to printk.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/msm/adreno/a4xx_gpu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a4xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a4xx_gpu.c
index 2b93b33b05e4..2206b3b4b191 100644
--- a/drivers/gpu/drm/msm/adreno/a4xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a4xx_gpu.c
@@ -355,7 +355,7 @@ static void a4xx_recover(struct msm_gpu *gpu)
adreno_dump_info(gpu);
 
for (i = 0; i < 8; i++) {
-   printk("CP_SCRATCH_REG%d: %u\n", i,
+   printk(KERN_DEBUG "CP_SCRATCH_REG%d: %u\n", i,
gpu_read(gpu, REG_AXXX_CP_SCRATCH_REG0 + i));
}
 
@@ -409,7 +409,7 @@ static irqreturn_t a4xx_irq(struct msm_gpu *gpu)
 
if (status & A4XX_INT0_CP_REG_PROTECT_FAULT) {
uint32_t reg = gpu_read(gpu, REG_A4XX_CP_PROTECT_STATUS);
-   printk("CP | Protected mode error| %s | addr=%x\n",
+   printk(KERN_DEBUG "CP | Protected mode error| %s | addr=%x\n",
reg & (1 << 24) ? "WRITE" : "READ",
(reg & 0xF) >> 2);
}
@@ -565,7 +565,7 @@ static struct msm_gpu_state *a4xx_gpu_state_get(struct 
msm_gpu *gpu)
 
 static void a4xx_dump(struct msm_gpu *gpu)
 {
-   printk("status:   %08x\n",
+   printk(KERN_DEBUG "status:   %08x\n",
gpu_read(gpu, REG_A4XX_RBBM_STATUS));
adreno_dump(gpu);
 }
-- 
2.29.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Resend][PATCH] drm/msm: delete conversion from bool value to bool return

2020-11-10 Thread Bernard
Delete the conversion from bool value to bool function return.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c
index 8493d68ad841..411222f4cd6f 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c
@@ -37,7 +37,7 @@
 
 static bool dpu_encoder_phys_cmd_is_master(struct dpu_encoder_phys *phys_enc)
 {
-   return (phys_enc->split_role != ENC_ROLE_SLAVE) ? true : false;
+   return (phys_enc->split_role != ENC_ROLE_SLAVE);
 }
 
 static bool dpu_encoder_phys_cmd_mode_fixup(
-- 
2.29.0



___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] amd/display/amdgpu_dm: delete same check in if condition

2020-11-10 Thread Bernard Zhao
In function amdgpu_dm_connector_get_modes, drm_edid_is_valid
will check weather (!edid), no need to check again in the if
branch.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index e93e18c06c0e..0a283d07fe10 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -6352,7 +6352,7 @@ static int amdgpu_dm_connector_get_modes(struct 
drm_connector *connector)
 
encoder = amdgpu_dm_connector_to_encoder(connector);
 
-   if (!edid || !drm_edid_is_valid(edid)) {
+   if (!drm_edid_is_valid(edid)) {
amdgpu_dm_connector->num_modes =
drm_add_modes_noedid(connector, 640, 480);
} else {
-- 
2.29.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Resend][PATCH] drm/msm: delete conversion from bool value to bool variable

2020-11-10 Thread Bernard
Remove the conversion from bool value to bool variable.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
index f7f5c258b553..e99a543da243 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
@@ -1362,7 +1362,7 @@ void dpu_encoder_register_frame_event_callback(struct 
drm_encoder *drm_enc,
unsigned long lock_flags;
bool enable;
 
-   enable = frame_event_cb ? true : false;
+   enable = (frame_event_cb != NULL);
 
if (!drm_enc) {
DPU_ERROR("invalid encoder\n");
-- 
2.29.0



___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re:Re: [PATCH] gpu/drm: make crtc check before new_connector circle

2020-11-02 Thread Bernard



From: Daniel Vetter 
Date: 2020-11-02 18:17:24
To:  Bernard Zhao 
Cc:  Maarten Lankhorst ,Maxime Ripard 
,Thomas Zimmermann ,David Airlie 
,Daniel Vetter 
,dri-devel@lists.freedesktop.org,linux-ker...@vger.kernel.org,opensource.ker...@vivo.com
Subject: Re: [PATCH] gpu/drm: make crtc check before new_connector circle>On 
Sun, Nov 01, 2020 at 06:58:51PM -0800, Bernard Zhao wrote:
>> In function prepare_signaling, crtc check (c==0) is not related
>> with the next new_connector circle, maybe we can put the crtc
>> check just after the crtc circle and before new_connector circle.
>> This change is to make the code to run a bit first.
>
>I'm a bit confused here with your explanation, I'm not understanding why
>you do this change ... Can you pls elaborate? Maybe give an example or
>something of the problem this patch solves, that often helps.
>
>Thanks, Daniel

Hi:

This change is to make the function return error earlier when run into the 
error branch:
if (c == 0 && (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
return -EINVAL;
There two main FOR circles in this function, and the second FOR circle never 
changes the if condition("(c == 0 && (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))") 
variable`s value, like c & arg->flags.
So I think maybe we can check this condition before the second for circle, and 
return the error earlier when run into this error branch.

BR//Bernard

>> 
>> Signed-off-by: Bernard Zhao 
>> ---
>>  drivers/gpu/drm/drm_atomic_uapi.c | 13 ++---
>>  1 file changed, 6 insertions(+), 7 deletions(-)
>> 
>> diff --git a/drivers/gpu/drm/drm_atomic_uapi.c 
>> b/drivers/gpu/drm/drm_atomic_uapi.c
>> index 25c269bc4681..566110996474 100644
>> --- a/drivers/gpu/drm/drm_atomic_uapi.c
>> +++ b/drivers/gpu/drm/drm_atomic_uapi.c
>> @@ -1182,6 +1182,12 @@ static int prepare_signaling(struct drm_device *dev,
>>  
>>  c++;
>>  }
>> +/*
>> + * Having this flag means user mode pends on event which will never
>> + * reach due to lack of at least one CRTC for signaling
>> + */
>> +if (c == 0 && (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
>> +return -EINVAL;
>>  
>>  for_each_new_connector_in_state(state, conn, conn_state, i) {
>>  struct drm_writeback_connector *wb_conn;
>> @@ -1220,13 +1226,6 @@ static int prepare_signaling(struct drm_device *dev,
>>  conn_state->writeback_job->out_fence = fence;
>>  }
>>  
>> -/*
>> - * Having this flag means user mode pends on event which will never
>> - * reach due to lack of at least one CRTC for signaling
>> - */
>> -if (c == 0 && (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
>> -return -EINVAL;
>> -
>>  return 0;
>>  }
>>  
>> -- 
>> 2.29.0
>> 
>
>-- 
>Daniel Vetter
>Software Engineer, Intel Corporation
>http://blog.ffwll.ch


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/msm: delete conversion from bool value to bool return

2020-11-02 Thread Bernard Zhao
Delete the conversion from bool value to bool function return.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c
index 8493d68ad841..411222f4cd6f 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c
@@ -37,7 +37,7 @@
 
 static bool dpu_encoder_phys_cmd_is_master(struct dpu_encoder_phys *phys_enc)
 {
-   return (phys_enc->split_role != ENC_ROLE_SLAVE) ? true : false;
+   return (phys_enc->split_role != ENC_ROLE_SLAVE);
 }
 
 static bool dpu_encoder_phys_cmd_mode_fixup(
-- 
2.29.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/amd: fix typoes

2020-11-02 Thread Bernard Zhao
Fix typoes.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c 
b/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c
index 2c6db379afae..e994d233aa21 100644
--- a/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c
+++ b/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c
@@ -1980,7 +1980,7 @@ static void calculate_bandwidth(
else {
data->latency_for_non_mcifwr_clients = bw_int_to_fixed(0);
}
-   /*dmif mc urgent latency suppported in high sclk and yclk*/
+   /*dmif mc urgent latency supported in high sclk and yclk*/
data->dmifmc_urgent_latency_supported_in_high_sclk_and_yclk = 
bw_div((bw_sub(data->min_read_buffer_size_in_time, 
data->dmif_burst_time[high][s_high])), data->total_dmifmc_urgent_trips);
/*dram speed/p-state change margin*/
/*in the multi-display case the nb p-state change watermark cannot 
exceed the average lb size plus the dmif size or the cursor dcp buffer size*/
-- 
2.29.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/msm: delete conversion from bool value to bool variable

2020-11-02 Thread Bernard Zhao
Remove the conversion from bool value to bool variable.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
index f7f5c258b553..e99a543da243 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
@@ -1362,7 +1362,7 @@ void dpu_encoder_register_frame_event_callback(struct 
drm_encoder *drm_enc,
unsigned long lock_flags;
bool enable;
 
-   enable = frame_event_cb ? true : false;
+   enable = (frame_event_cb != NULL);
 
if (!drm_enc) {
DPU_ERROR("invalid encoder\n");
-- 
2.29.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/amd: move DRM_ERROR log out of the mutex protect area

2020-11-02 Thread Bernard Zhao
In function amdgpu_register_gpu_instance, there is no need to
protect DRM_ERROR in mutex mgpu_info.mutex.
This change is to make the code to run a bit fast.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index efda38349a03..cc61b0a5b8d1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -104,8 +104,8 @@ void amdgpu_register_gpu_instance(struct amdgpu_device 
*adev)
mutex_lock(_info.mutex);
 
if (mgpu_info.num_gpu >= MAX_GPU_INSTANCE) {
-   DRM_ERROR("Cannot register more gpu instance\n");
mutex_unlock(_info.mutex);
+   DRM_ERROR("Cannot register more gpu instance\n");
return;
}
 
-- 
2.29.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] gpu/drm: make crtc check before new_connector circle

2020-11-02 Thread Bernard Zhao
In function prepare_signaling, crtc check (c==0) is not related
with the next new_connector circle, maybe we can put the crtc
check just after the crtc circle and before new_connector circle.
This change is to make the code to run a bit first.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/drm_atomic_uapi.c | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic_uapi.c 
b/drivers/gpu/drm/drm_atomic_uapi.c
index 25c269bc4681..566110996474 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -1182,6 +1182,12 @@ static int prepare_signaling(struct drm_device *dev,
 
c++;
}
+   /*
+* Having this flag means user mode pends on event which will never
+* reach due to lack of at least one CRTC for signaling
+*/
+   if (c == 0 && (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
+   return -EINVAL;
 
for_each_new_connector_in_state(state, conn, conn_state, i) {
struct drm_writeback_connector *wb_conn;
@@ -1220,13 +1226,6 @@ static int prepare_signaling(struct drm_device *dev,
conn_state->writeback_job->out_fence = fence;
}
 
-   /*
-* Having this flag means user mode pends on event which will never
-* reach due to lack of at least one CRTC for signaling
-*/
-   if (c == 0 && (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
-   return -EINVAL;
-
return 0;
 }
 
-- 
2.29.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] gpu/drm: delete same check in if condition

2020-11-02 Thread Bernard Zhao
In function drm_bridge_connector_get_modes_edid, drm_edid_is_valid
will check weather (!edid), no need to check again in the if
branch.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/drm_bridge_connector.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_bridge_connector.c 
b/drivers/gpu/drm/drm_bridge_connector.c
index a58cbde59c34..791379816837 100644
--- a/drivers/gpu/drm/drm_bridge_connector.c
+++ b/drivers/gpu/drm/drm_bridge_connector.c
@@ -241,7 +241,7 @@ static int drm_bridge_connector_get_modes_edid(struct 
drm_connector *connector,
goto no_edid;
 
edid = bridge->funcs->get_edid(bridge, connector);
-   if (!edid || !drm_edid_is_valid(edid)) {
+   if (!drm_edid_is_valid(edid)) {
kfree(edid);
goto no_edid;
}
-- 
2.29.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re:Re: Re: [PATCH] gpu/drm/mgag200:remove break after return

2020-10-28 Thread Bernard

From: Sam Ravnborg 
Date: 2020-10-25 01:14:57
To:  Bernard 
Cc:  Thomas Zimmermann ,opensource.ker...@vivo.com,David 
Airlie 
,linux-ker...@vger.kernel.org,dri-devel@lists.freedesktop.org,Dave
 Airlie 
Subject: Re: Re: [PATCH] gpu/drm/mgag200:remove break after return>Hi Bernard.
>
>On Fri, Oct 23, 2020 at 03:48:49PM +0800, Bernard wrote:
>> 
>> 
>> From: Thomas Zimmermann 
>> Date: 2020-10-23 15:13:30
>> To:  Bernard Zhao ,Dave Airlie ,David 
>> Airlie ,Daniel Vetter 
>> ,dri-devel@lists.freedesktop.org,linux-ker...@vger.kernel.org
>> Cc:  opensource.ker...@vivo.com
>> Subject: Re: [PATCH] gpu/drm/mgag200:remove break after return>Hi
>> >
>> >On 23.10.20 09:00, Bernard Zhao wrote:
>> >> In function mgag200_set_pci_regs, there are some switch cases
>> >> returned, then break. These break will never run.
>> >> This patch is to make the code a bit readable.
>> >> 
>> >> Signed-off-by: Bernard Zhao 
>> >> ---
>> >>  drivers/gpu/drm/mgag200/mgag200_mode.c | 5 +
>> >>  1 file changed, 1 insertion(+), 4 deletions(-)
>> >> 
>> >> diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c 
>> >> b/drivers/gpu/drm/mgag200/mgag200_mode.c
>> >> index 38672f9e5c4f..de873a5d276e 100644
>> >> --- a/drivers/gpu/drm/mgag200/mgag200_mode.c
>> >> +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
>> >> @@ -794,20 +794,17 @@ static int mgag200_crtc_set_plls(struct mga_device 
>> >> *mdev, long clock)
>> >>   case G200_SE_A:
>> >>   case G200_SE_B:
>> >>   return mga_g200se_set_plls(mdev, clock);
>> >> - break;
>> >>   case G200_WB:
>> >>   case G200_EW3:
>> >>   return mga_g200wb_set_plls(mdev, clock);
>> >> - break;
>> >>   case G200_EV:
>> >>   return mga_g200ev_set_plls(mdev, clock);
>> >> - break;
>> >>   case G200_EH:
>> >>   case G200_EH3:
>> >>   return mga_g200eh_set_plls(mdev, clock);
>> >> - break;
>> >>   case G200_ER:
>> >>   return mga_g200er_set_plls(mdev, clock);
>> >> + default:
>> >
>> >No default case here. If one of the enum values is not handled by the
>> >switch, the compiler should warn about it.
>> 
>> Hi
>> 
>> For this point I was a little confused, about this switch variable 
>> "mdev->type", my understanding is that this variable`s value can be certain 
>> only when the code is running.
>> How does the compiler warn this("If one of the enum values is not handled") 
>> before the code runs?
>
>If the switch/case does not include "G200_ER" then the compiler can see
>one enum value is missing from the list and can warn.
>As a test - Try to drop the default and drop G200_ER - then the
>compiler (hopefully) will warn.

Hi, Sam & Thomas:

  Thank you very much for your kind comments, I learned new useful knowledge.
  I will resubmit the patch.

BR//Bernard

>   Sam


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re:Re: [PATCH] gpu/drm/mgag200:remove break after return

2020-10-24 Thread Bernard


From: Thomas Zimmermann 
Date: 2020-10-23 15:13:30
To:  Bernard Zhao ,Dave Airlie ,David 
Airlie ,Daniel Vetter 
,dri-devel@lists.freedesktop.org,linux-ker...@vger.kernel.org
Cc:  opensource.ker...@vivo.com
Subject: Re: [PATCH] gpu/drm/mgag200:remove break after return>Hi
>
>On 23.10.20 09:00, Bernard Zhao wrote:
>> In function mgag200_set_pci_regs, there are some switch cases
>> returned, then break. These break will never run.
>> This patch is to make the code a bit readable.
>> 
>> Signed-off-by: Bernard Zhao 
>> ---
>>  drivers/gpu/drm/mgag200/mgag200_mode.c | 5 +
>>  1 file changed, 1 insertion(+), 4 deletions(-)
>> 
>> diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c 
>> b/drivers/gpu/drm/mgag200/mgag200_mode.c
>> index 38672f9e5c4f..de873a5d276e 100644
>> --- a/drivers/gpu/drm/mgag200/mgag200_mode.c
>> +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
>> @@ -794,20 +794,17 @@ static int mgag200_crtc_set_plls(struct mga_device 
>> *mdev, long clock)
>>  case G200_SE_A:
>>  case G200_SE_B:
>>  return mga_g200se_set_plls(mdev, clock);
>> -break;
>>  case G200_WB:
>>  case G200_EW3:
>>  return mga_g200wb_set_plls(mdev, clock);
>> -break;
>>  case G200_EV:
>>  return mga_g200ev_set_plls(mdev, clock);
>> -break;
>>  case G200_EH:
>>  case G200_EH3:
>>  return mga_g200eh_set_plls(mdev, clock);
>> -break;
>>  case G200_ER:
>>  return mga_g200er_set_plls(mdev, clock);
>> +default:
>
>No default case here. If one of the enum values is not handled by the
>switch, the compiler should warn about it.

Hi

For this point I was a little confused, about this switch variable 
"mdev->type", my understanding is that this variable`s value can be certain 
only when the code is running.
How does the compiler warn this("If one of the enum values is not handled") 
before the code runs?

BR//Bernard

>Best regards
>Thomas
>
>>  break;
>>  }
>>  
>> 
>
>-- 
>Thomas Zimmermann
>Graphics Driver Developer
>SUSE Software Solutions Germany GmbH
>Maxfeldstr. 5, 90409 Nürnberg, Germany
>(HRB 36809, AG Nürnberg)
>Geschäftsführer: Felix Imendörffer


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] gpu/drm/mgag200:remove break after return

2020-10-23 Thread Bernard Zhao
In function mgag200_set_pci_regs, there are some switch cases
returned, then break. These break will never run.
This patch is to make the code a bit readable.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/mgag200/mgag200_mode.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c 
b/drivers/gpu/drm/mgag200/mgag200_mode.c
index 38672f9e5c4f..de873a5d276e 100644
--- a/drivers/gpu/drm/mgag200/mgag200_mode.c
+++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
@@ -794,20 +794,17 @@ static int mgag200_crtc_set_plls(struct mga_device *mdev, 
long clock)
case G200_SE_A:
case G200_SE_B:
return mga_g200se_set_plls(mdev, clock);
-   break;
case G200_WB:
case G200_EW3:
return mga_g200wb_set_plls(mdev, clock);
-   break;
case G200_EV:
return mga_g200ev_set_plls(mdev, clock);
-   break;
case G200_EH:
case G200_EH3:
return mga_g200eh_set_plls(mdev, clock);
-   break;
case G200_ER:
return mga_g200er_set_plls(mdev, clock);
+   default:
break;
}
 
-- 
2.28.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/amd: remove unnecessary conversion from bool value to bool

2020-10-15 Thread Bernard Zhao
In functions vegam_is_dpm_running & vegam_populate_avfs_parameters,
maybe there is no need to conver bool condition to bool variable
or bool return value.
This change is to make the code a bit more readable.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c 
b/drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c
index 0ecc18b55ffb..32ca472f58a6 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c
@@ -296,8 +296,9 @@ static int vegam_process_firmware_header(struct pp_hwmgr 
*hwmgr)
 static bool vegam_is_dpm_running(struct pp_hwmgr *hwmgr)
 {
return (1 == PHM_READ_INDIRECT_FIELD(hwmgr->device,
-   CGS_IND_REG__SMC, FEATURE_STATUS, 
VOLTAGE_CONTROLLER_ON))
-   ? true : false;
+CGS_IND_REG__SMC,
+FEATURE_STATUS,
+VOLTAGE_CONTROLLER_ON));
 }
 
 static uint32_t vegam_get_mac_definition(uint32_t value)
@@ -1661,7 +1662,7 @@ static int vegam_populate_avfs_parameters(struct pp_hwmgr 
*hwmgr)
(avfs_params.ucEnableGB_FUSE_TABLE_CKSON << 
AVFSGB0_Vdroop_Enable_SHIFT) |
(avfs_params.ucEnableGB_FUSE_TABLE_CKSOFF << 
AVFSGB1_Vdroop_Enable_SHIFT);
data->apply_avfs_cks_off_voltage =
-   (avfs_params.ucEnableApplyAVFS_CKS_OFF_Voltage 
== 1) ? true : false;
+   (avfs_params.ucEnableApplyAVFS_CKS_OFF_Voltage 
== 1);
}
return result;
 }
-- 
2.28.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/mediatek: Optimize functions which do not need to return

2020-10-14 Thread Bernard Zhao
Function mtk_hdmi_aud_set_input always return 0, no need to
keep the return value. Functions mtk_hdmi_aud_enable_packet &
mtk_hdmi_aud_on_off_hw_ncts are the same, these two functions
just call next functions. Maybe it`s a bit better to just call
the inner function.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/mediatek/mtk_hdmi.c | 27 +++
 1 file changed, 7 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c 
b/drivers/gpu/drm/mediatek/mtk_hdmi.c
index a97725680d4e..f1d987df0550 100644
--- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
+++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
@@ -870,19 +870,8 @@ static void mtk_hdmi_video_set_display_mode(struct 
mtk_hdmi *hdmi,
mtk_hdmi_hw_msic_setting(hdmi, mode);
 }
 
-static int mtk_hdmi_aud_enable_packet(struct mtk_hdmi *hdmi, bool enable)
-{
-   mtk_hdmi_hw_send_aud_packet(hdmi, enable);
-   return 0;
-}
 
-static int mtk_hdmi_aud_on_off_hw_ncts(struct mtk_hdmi *hdmi, bool on)
-{
-   mtk_hdmi_hw_ncts_enable(hdmi, on);
-   return 0;
-}
-
-static int mtk_hdmi_aud_set_input(struct mtk_hdmi *hdmi)
+static void mtk_hdmi_aud_set_input(struct mtk_hdmi *hdmi)
 {
enum hdmi_aud_channel_type chan_type;
u8 chan_count;
@@ -912,8 +901,6 @@ static int mtk_hdmi_aud_set_input(struct mtk_hdmi *hdmi)
chan_count = mtk_hdmi_aud_get_chnl_count(chan_type);
mtk_hdmi_hw_aud_set_i2s_chan_num(hdmi, chan_type, chan_count);
mtk_hdmi_hw_aud_set_input_type(hdmi, hdmi->aud_param.aud_input_type);
-
-   return 0;
 }
 
 static int mtk_hdmi_aud_set_src(struct mtk_hdmi *hdmi,
@@ -921,7 +908,7 @@ static int mtk_hdmi_aud_set_src(struct mtk_hdmi *hdmi,
 {
unsigned int sample_rate = hdmi->aud_param.codec_params.sample_rate;
 
-   mtk_hdmi_aud_on_off_hw_ncts(hdmi, false);
+   mtk_hdmi_hw_ncts_enable(hdmi, false);
mtk_hdmi_hw_aud_src_disable(hdmi);
mtk_hdmi_clear_bits(hdmi, GRL_CFG2, CFG2_ACLK_INV);
 
@@ -959,7 +946,7 @@ static int mtk_hdmi_aud_output_config(struct mtk_hdmi *hdmi,
  struct drm_display_mode *display_mode)
 {
mtk_hdmi_hw_aud_mute(hdmi);
-   mtk_hdmi_aud_enable_packet(hdmi, false);
+   mtk_hdmi_hw_send_aud_packet(hdmi, false);
 
mtk_hdmi_aud_set_input(hdmi);
mtk_hdmi_aud_set_src(hdmi, display_mode);
@@ -968,8 +955,8 @@ static int mtk_hdmi_aud_output_config(struct mtk_hdmi *hdmi,
 
usleep_range(50, 100);
 
-   mtk_hdmi_aud_on_off_hw_ncts(hdmi, true);
-   mtk_hdmi_aud_enable_packet(hdmi, true);
+   mtk_hdmi_hw_ncts_enable(hdmi, true);
+   mtk_hdmi_hw_send_aud_packet(hdmi, true);
mtk_hdmi_hw_aud_unmute(hdmi);
return 0;
 }
@@ -1097,13 +1084,13 @@ static int mtk_hdmi_output_init(struct mtk_hdmi *hdmi)
 
 static void mtk_hdmi_audio_enable(struct mtk_hdmi *hdmi)
 {
-   mtk_hdmi_aud_enable_packet(hdmi, true);
+   mtk_hdmi_hw_send_aud_packet(hdmi, true);
hdmi->audio_enable = true;
 }
 
 static void mtk_hdmi_audio_disable(struct mtk_hdmi *hdmi)
 {
-   mtk_hdmi_aud_enable_packet(hdmi, false);
+   mtk_hdmi_hw_send_aud_packet(hdmi, false);
hdmi->audio_enable = false;
 }
 
-- 
2.28.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] gpu/drm/armada: fix unused parameter warning

2020-10-13 Thread Bernard Zhao
Functions armada_drm_crtc_atomic_flush &
armada_drm_crtc_atomic_enable don`t use the second parameter.
So we may get warning like :
warning: unused parameter ‘***’ [-Wunused-parameter].
This change is to fix the compile warning with -Wunused-parameter.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/armada/armada_crtc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/armada/armada_crtc.c 
b/drivers/gpu/drm/armada/armada_crtc.c
index 38dfaa46d306..fc8b922c3e44 100644
--- a/drivers/gpu/drm/armada/armada_crtc.c
+++ b/drivers/gpu/drm/armada/armada_crtc.c
@@ -427,7 +427,7 @@ static int armada_drm_crtc_atomic_check(struct drm_crtc 
*crtc,
 }
 
 static void armada_drm_crtc_atomic_begin(struct drm_crtc *crtc,
-struct drm_crtc_state *old_crtc_state)
+   struct drm_crtc_state __attribute__((unused)) 
*old_crtc_state)
 {
struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
 
@@ -441,7 +441,7 @@ static void armada_drm_crtc_atomic_begin(struct drm_crtc 
*crtc,
 }
 
 static void armada_drm_crtc_atomic_flush(struct drm_crtc *crtc,
-struct drm_crtc_state *old_crtc_state)
+   struct drm_crtc_state __attribute__((unused)) 
*old_crtc_state)
 {
struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
 
-- 
2.28.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/amd/display: remove no need return value

2020-10-13 Thread Bernard Zhao
Functions (disable_all_writeback_pipes_for_stream &
dc_enable_stereo & dc_post_update_surfaces_to_stream)
always return true, there is no need to keep the return value.
This change is to make the code a bit more readable.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/amd/display/dc/core/dc.c   | 17 +
 drivers/gpu/drm/amd/display/dc/dc.h|  2 +-
 drivers/gpu/drm/amd/display/dc/dc_stream.h |  2 +-
 3 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 92eb1ca1634f..8dc598a632b5 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -761,7 +761,7 @@ static bool dc_construct(struct dc *dc,
return false;
 }
 
-static bool disable_all_writeback_pipes_for_stream(
+static void disable_all_writeback_pipes_for_stream(
const struct dc *dc,
struct dc_stream_state *stream,
struct dc_state *context)
@@ -770,8 +770,6 @@ static bool disable_all_writeback_pipes_for_stream(
 
for (i = 0; i < stream->num_wb_info; i++)
stream->writeback_info[i].wb_enabled = false;
-
-   return true;
 }
 
 void apply_ctx_interdependent_lock(struct dc *dc, struct dc_state *context, 
struct dc_stream_state *stream, bool lock)
@@ -1213,13 +1211,12 @@ bool dc_validate_seamless_boot_timing(const struct dc 
*dc,
return true;
 }
 
-bool dc_enable_stereo(
+void dc_enable_stereo(
struct dc *dc,
struct dc_state *context,
struct dc_stream_state *streams[],
uint8_t stream_count)
 {
-   bool ret = true;
int i, j;
struct pipe_ctx *pipe;
 
@@ -1234,8 +1231,6 @@ bool dc_enable_stereo(
dc->hwss.setup_stereo(pipe, dc);
}
}
-
-   return ret;
 }
 
 /*
@@ -1448,18 +1443,18 @@ static bool is_flip_pending_in_pipes(struct dc *dc, 
struct dc_state *context)
return false;
 }
 
-bool dc_post_update_surfaces_to_stream(struct dc *dc)
+void dc_post_update_surfaces_to_stream(struct dc *dc)
 {
int i;
struct dc_state *context = dc->current_state;
 
if ((!dc->optimized_required) || dc->optimize_seamless_boot_streams > 0)
-   return true;
+   return;
 
post_surface_trace(dc);
 
if (is_flip_pending_in_pipes(dc, context))
-   return true;
+   return;
 
for (i = 0; i < dc->res_pool->pipe_count; i++)
if (context->res_ctx.pipe_ctx[i].stream == NULL ||
@@ -1472,8 +1467,6 @@ bool dc_post_update_surfaces_to_stream(struct dc *dc)
 
dc->optimized_required = false;
dc->wm_optimized_required = false;
-
-   return true;
 }
 
 struct dc_state *dc_create_state(struct dc *dc)
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h 
b/drivers/gpu/drm/amd/display/dc/dc.h
index f50ef4255020..f79a3c318757 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -962,7 +962,7 @@ struct dc_flip_addrs {
bool triplebuffer_flips;
 };
 
-bool dc_post_update_surfaces_to_stream(
+void dc_post_update_surfaces_to_stream(
struct dc *dc);
 
 #include "dc_stream.h"
diff --git a/drivers/gpu/drm/amd/display/dc/dc_stream.h 
b/drivers/gpu/drm/amd/display/dc/dc_stream.h
index d9888f316da6..0047ab33f88e 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_stream.h
+++ b/drivers/gpu/drm/amd/display/dc/dc_stream.h
@@ -391,7 +391,7 @@ enum dc_status dc_validate_stream(struct dc *dc, struct 
dc_stream_state *stream)
  * Enable stereo when commit_streams is not required,
  * for example, frame alternate.
  */
-bool dc_enable_stereo(
+void dc_enable_stereo(
struct dc *dc,
struct dc_state *context,
struct dc_stream_state *streams[],
-- 
2.28.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] gpu/drm/mediatek: fix unused parameter warning

2020-10-13 Thread Bernard Zhao
Functions mtk_drm_crtc_atomic_flush & mtk_drm_crtc_atomic_enable
& mtk_drm_crtc_atomic_disable don`t use the second parameter.
So we may get warning like : warning: unused parameter '***'
[-Wunused-parameter].
This change is to fix the compile warning with -Wunused-parameter.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c 
b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
index 4d29568be3f5..6e55ec0e80bb 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
@@ -542,7 +542,7 @@ static void mtk_drm_crtc_atomic_enable(struct drm_crtc 
*crtc,
 }
 
 static void mtk_drm_crtc_atomic_disable(struct drm_crtc *crtc,
-   struct drm_crtc_state *old_state)
+   struct drm_crtc_state 
__attribute__((unused)) *old_state)
 {
struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[0];
@@ -575,7 +575,7 @@ static void mtk_drm_crtc_atomic_disable(struct drm_crtc 
*crtc,
 }
 
 static void mtk_drm_crtc_atomic_begin(struct drm_crtc *crtc,
- struct drm_crtc_state *old_crtc_state)
+ struct drm_crtc_state 
__attribute__((unused)) *old_crtc_state)
 {
struct mtk_crtc_state *state = to_mtk_crtc_state(crtc->state);
struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
@@ -592,7 +592,7 @@ static void mtk_drm_crtc_atomic_begin(struct drm_crtc *crtc,
 }
 
 static void mtk_drm_crtc_atomic_flush(struct drm_crtc *crtc,
- struct drm_crtc_state *old_crtc_state)
+ struct drm_crtc_state 
__attribute__((unused)) *old_crtc_state)
 {
struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
int i;
-- 
2.28.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH RFC PKS/PMEM 10/58] drivers/rdma: Utilize new kmap_thread()

2020-10-12 Thread Bernard Metzler
-ira.we...@intel.com wrote: -

>To: "Andrew Morton" , "Thomas Gleixner"
>, "Ingo Molnar" , "Borislav
>Petkov" , "Andy Lutomirski" , "Peter
>Zijlstra" 
>From: ira.we...@intel.com
>Date: 10/09/2020 09:52PM
>Cc: "Ira Weiny" , "Mike Marciniszyn"
>, "Dennis Dalessandro"
>, "Doug Ledford" ,
>"Jason Gunthorpe" , "Faisal Latif"
>, "Shiraz Saleem" ,
>"Bernard Metzler" , x...@kernel.org, "Dave Hansen"
>, "Dan Williams"
>, "Fenghua Yu" ,
>linux-...@vger.kernel.org, linux-ker...@vger.kernel.org,
>linux-nvd...@lists.01.org, linux-fsde...@vger.kernel.org,
>linux...@kvack.org, linux-kselft...@vger.kernel.org,
>linuxppc-...@lists.ozlabs.org, k...@vger.kernel.org,
>net...@vger.kernel.org, b...@vger.kernel.org,
>ke...@lists.infradead.org, linux-bca...@vger.kernel.org,
>linux-...@lists.infradead.org, de...@driverdev.osuosl.org,
>linux-...@vger.kernel.org, linux-...@vger.kernel.org,
>linux-s...@vger.kernel.org, target-de...@vger.kernel.org,
>linux-...@vger.kernel.org, ceph-de...@vger.kernel.org,
>linux-e...@vger.kernel.org, linux-...@kvack.org,
>io-ur...@vger.kernel.org, linux-er...@lists.ozlabs.org,
>linux...@lists.infradead.org, linux-ntfs-...@lists.sourceforge.net,
>reiserfs-de...@vger.kernel.org,
>linux-f2fs-de...@lists.sourceforge.net, linux-ni...@vger.kernel.org,
>cluster-de...@redhat.com, ecryp...@vger.kernel.org,
>linux-c...@vger.kernel.org, linux-bt...@vger.kernel.org,
>linux-...@lists.infradead.org, linux-r...@vger.kernel.org,
>amd-...@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
>intel-...@lists.freedesktop.org, drbd-...@tron.linbit.com,
>linux-bl...@vger.kernel.org, xen-de...@lists.xenproject.org,
>linux-cach...@redhat.com, samba-techni...@lists.samba.org,
>intel-wired-...@lists.osuosl.org
>Subject: [EXTERNAL] [PATCH RFC PKS/PMEM 10/58] drivers/rdma: Utilize
>new kmap_thread()
>
>From: Ira Weiny 
>
>The kmap() calls in these drivers are localized to a single thread.
>To
>avoid the over head of global PKRS updates use the new kmap_thread()
>call.
>
>Cc: Mike Marciniszyn 
>Cc: Dennis Dalessandro 
>Cc: Doug Ledford 
>Cc: Jason Gunthorpe 
>Cc: Faisal Latif 
>Cc: Shiraz Saleem 
>Cc: Bernard Metzler 
>Signed-off-by: Ira Weiny 
>---
> drivers/infiniband/hw/hfi1/sdma.c  |  4 ++--
> drivers/infiniband/hw/i40iw/i40iw_cm.c | 10 +-
> drivers/infiniband/sw/siw/siw_qp_tx.c  | 14 +++---
> 3 files changed, 14 insertions(+), 14 deletions(-)
>
>diff --git a/drivers/infiniband/hw/hfi1/sdma.c
>b/drivers/infiniband/hw/hfi1/sdma.c
>index 04575c9afd61..09d206e3229a 100644
>--- a/drivers/infiniband/hw/hfi1/sdma.c
>+++ b/drivers/infiniband/hw/hfi1/sdma.c
>@@ -3130,7 +3130,7 @@ int ext_coal_sdma_tx_descs(struct hfi1_devdata
>*dd, struct sdma_txreq *tx,
>   }
> 
>   if (type == SDMA_MAP_PAGE) {
>-  kvaddr = kmap(page);
>+  kvaddr = kmap_thread(page);
>   kvaddr += offset;
>   } else if (WARN_ON(!kvaddr)) {
>   __sdma_txclean(dd, tx);
>@@ -3140,7 +3140,7 @@ int ext_coal_sdma_tx_descs(struct hfi1_devdata
>*dd, struct sdma_txreq *tx,
>   memcpy(tx->coalesce_buf + tx->coalesce_idx, kvaddr, len);
>   tx->coalesce_idx += len;
>   if (type == SDMA_MAP_PAGE)
>-  kunmap(page);
>+  kunmap_thread(page);
> 
>   /* If there is more data, return */
>   if (tx->tlen - tx->coalesce_idx)
>diff --git a/drivers/infiniband/hw/i40iw/i40iw_cm.c
>b/drivers/infiniband/hw/i40iw/i40iw_cm.c
>index a3b95805c154..122d7a5642a1 100644
>--- a/drivers/infiniband/hw/i40iw/i40iw_cm.c
>+++ b/drivers/infiniband/hw/i40iw/i40iw_cm.c
>@@ -3721,7 +3721,7 @@ int i40iw_accept(struct iw_cm_id *cm_id, struct
>iw_cm_conn_param *conn_param)
>   ibmr->device = iwpd->ibpd.device;
>   iwqp->lsmm_mr = ibmr;
>   if (iwqp->page)
>-  iwqp->sc_qp.qp_uk.sq_base = kmap(iwqp->page);
>+  iwqp->sc_qp.qp_uk.sq_base = kmap_thread(iwqp->page);
>   dev->iw_priv_qp_ops->qp_send_lsmm(>sc_qp,
>   iwqp->ietf_mem.va,
>   (accept.size + 
> conn_param->private_data_len),
>@@ -3729,12 +3729,12 @@ int i40iw_accept(struct iw_cm_id *cm_id,
>struct iw_cm_conn_param *conn_param)
> 
>   } else {
>   if (iwqp->page)
>

[PATCH] drm/amd/display: remove no need return value

2020-10-10 Thread Bernard Zhao
Functions (disable_all_writeback_pipes_for_stream &
dc_enable_stereo & dc_post_update_surfaces_to_stream)
always return true, there is no need to keep the return value.
This change is to make the code a bit more readable.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/amd/display/dc/core/dc.c   | 17 +
 drivers/gpu/drm/amd/display/dc/dc.h|  2 +-
 drivers/gpu/drm/amd/display/dc/dc_stream.h |  2 +-
 3 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 92eb1ca1634f..8dc598a632b5 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -761,7 +761,7 @@ static bool dc_construct(struct dc *dc,
return false;
 }
 
-static bool disable_all_writeback_pipes_for_stream(
+static void disable_all_writeback_pipes_for_stream(
const struct dc *dc,
struct dc_stream_state *stream,
struct dc_state *context)
@@ -770,8 +770,6 @@ static bool disable_all_writeback_pipes_for_stream(
 
for (i = 0; i < stream->num_wb_info; i++)
stream->writeback_info[i].wb_enabled = false;
-
-   return true;
 }
 
 void apply_ctx_interdependent_lock(struct dc *dc, struct dc_state *context, 
struct dc_stream_state *stream, bool lock)
@@ -1213,13 +1211,12 @@ bool dc_validate_seamless_boot_timing(const struct dc 
*dc,
return true;
 }
 
-bool dc_enable_stereo(
+void dc_enable_stereo(
struct dc *dc,
struct dc_state *context,
struct dc_stream_state *streams[],
uint8_t stream_count)
 {
-   bool ret = true;
int i, j;
struct pipe_ctx *pipe;
 
@@ -1234,8 +1231,6 @@ bool dc_enable_stereo(
dc->hwss.setup_stereo(pipe, dc);
}
}
-
-   return ret;
 }
 
 /*
@@ -1448,18 +1443,18 @@ static bool is_flip_pending_in_pipes(struct dc *dc, 
struct dc_state *context)
return false;
 }
 
-bool dc_post_update_surfaces_to_stream(struct dc *dc)
+void dc_post_update_surfaces_to_stream(struct dc *dc)
 {
int i;
struct dc_state *context = dc->current_state;
 
if ((!dc->optimized_required) || dc->optimize_seamless_boot_streams > 0)
-   return true;
+   return;
 
post_surface_trace(dc);
 
if (is_flip_pending_in_pipes(dc, context))
-   return true;
+   return;
 
for (i = 0; i < dc->res_pool->pipe_count; i++)
if (context->res_ctx.pipe_ctx[i].stream == NULL ||
@@ -1472,8 +1467,6 @@ bool dc_post_update_surfaces_to_stream(struct dc *dc)
 
dc->optimized_required = false;
dc->wm_optimized_required = false;
-
-   return true;
 }
 
 struct dc_state *dc_create_state(struct dc *dc)
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h 
b/drivers/gpu/drm/amd/display/dc/dc.h
index f50ef4255020..f79a3c318757 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -962,7 +962,7 @@ struct dc_flip_addrs {
bool triplebuffer_flips;
 };
 
-bool dc_post_update_surfaces_to_stream(
+void dc_post_update_surfaces_to_stream(
struct dc *dc);
 
 #include "dc_stream.h"
diff --git a/drivers/gpu/drm/amd/display/dc/dc_stream.h 
b/drivers/gpu/drm/amd/display/dc/dc_stream.h
index d9888f316da6..0047ab33f88e 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_stream.h
+++ b/drivers/gpu/drm/amd/display/dc/dc_stream.h
@@ -391,7 +391,7 @@ enum dc_status dc_validate_stream(struct dc *dc, struct 
dc_stream_state *stream)
  * Enable stereo when commit_streams is not required,
  * for example, frame alternate.
  */
-bool dc_enable_stereo(
+void dc_enable_stereo(
struct dc *dc,
struct dc_state *context,
struct dc_stream_state *streams[],
-- 
2.28.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/msm/disp: add error value record in for circle`s error index

2020-10-10 Thread Bernard Zhao
In function dpu_core_irq_enable & dpu_core_irq_disable, when
some index enable or disable failed, return value will be
covered by next success index. Upper call function will not
catch this error, this maybe does not meet the expectation.
This change is to make the code a bit more readable.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_core_irq.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_irq.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_irq.c
index f1bc6a1af7a7..e6da0469b743 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_irq.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_irq.c
@@ -123,8 +123,8 @@ int dpu_core_irq_enable(struct dpu_kms *dpu_kms, int 
*irq_idxs, u32 irq_count)
DRM_ERROR("irq_idx=%d enable_count=%d\n", irq_idxs[0], counts);
 
for (i = 0; (i < irq_count) && !ret; i++)
-   ret = _dpu_core_irq_enable(dpu_kms, irq_idxs[i]);
-
+   if (_dpu_core_irq_enable(dpu_kms, irq_idxs[i]) != 0)
+   ret = -EINVAL;
return ret;
 }
 
@@ -178,8 +178,8 @@ int dpu_core_irq_disable(struct dpu_kms *dpu_kms, int 
*irq_idxs, u32 irq_count)
DRM_ERROR("irq_idx=%d enable_count=%d\n", irq_idxs[0], counts);
 
for (i = 0; (i < irq_count) && !ret; i++)
-   ret = _dpu_core_irq_disable(dpu_kms, irq_idxs[i]);
-
+   if (_dpu_core_irq_disable(dpu_kms, irq_idxs[i]) != 0)
+   ret = -EINVAL;
return ret;
 }
 
-- 
2.28.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/radeon:fix typoes in comments

2020-09-23 Thread Bernard Zhao
Change the comment typo: "programm" -> "program".

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/radeon/uvd_v1_0.c | 4 ++--
 drivers/gpu/drm/radeon/uvd_v2_2.c | 2 +-
 drivers/gpu/drm/radeon/uvd_v4_2.c | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/radeon/uvd_v1_0.c 
b/drivers/gpu/drm/radeon/uvd_v1_0.c
index 800721153d51..58557c2263a7 100644
--- a/drivers/gpu/drm/radeon/uvd_v1_0.c
+++ b/drivers/gpu/drm/radeon/uvd_v1_0.c
@@ -117,7 +117,7 @@ int uvd_v1_0_resume(struct radeon_device *rdev)
if (r)
return r;
 
-   /* programm the VCPU memory controller bits 0-27 */
+   /* program the VCPU memory controller bits 0-27 */
addr = (rdev->uvd.gpu_addr >> 3) + 16;
size = RADEON_GPU_PAGE_ALIGN(rdev->uvd_fw->size) >> 3;
WREG32(UVD_VCPU_CACHE_OFFSET0, addr);
@@ -360,7 +360,7 @@ int uvd_v1_0_start(struct radeon_device *rdev)
/* Set the write pointer delay */
WREG32(UVD_RBC_RB_WPTR_CNTL, 0);
 
-   /* programm the 4GB memory segment for rptr and ring buffer */
+   /* program the 4GB memory segment for rptr and ring buffer */
WREG32(UVD_LMI_EXT40_ADDR, upper_32_bits(ring->gpu_addr) |
   (0x7 << 16) | (0x1 << 31));
 
diff --git a/drivers/gpu/drm/radeon/uvd_v2_2.c 
b/drivers/gpu/drm/radeon/uvd_v2_2.c
index 23b18edda20e..6266167886d9 100644
--- a/drivers/gpu/drm/radeon/uvd_v2_2.c
+++ b/drivers/gpu/drm/radeon/uvd_v2_2.c
@@ -109,7 +109,7 @@ int uvd_v2_2_resume(struct radeon_device *rdev)
if (r)
return r;
 
-   /* programm the VCPU memory controller bits 0-27 */
+   /* program the VCPU memory controller bits 0-27 */
addr = rdev->uvd.gpu_addr >> 3;
size = RADEON_GPU_PAGE_ALIGN(rdev->uvd_fw->size + 4) >> 3;
WREG32(UVD_VCPU_CACHE_OFFSET0, addr);
diff --git a/drivers/gpu/drm/radeon/uvd_v4_2.c 
b/drivers/gpu/drm/radeon/uvd_v4_2.c
index dc54fa4aaea8..f9e97fa63674 100644
--- a/drivers/gpu/drm/radeon/uvd_v4_2.c
+++ b/drivers/gpu/drm/radeon/uvd_v4_2.c
@@ -40,7 +40,7 @@ int uvd_v4_2_resume(struct radeon_device *rdev)
uint64_t addr;
uint32_t size;
 
-   /* programm the VCPU memory controller bits 0-27 */
+   /* program the VCPU memory controller bits 0-27 */
 
/* skip over the header of the new firmware format */
if (rdev->uvd.fw_header_present)
-- 
2.28.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/amd:fix typoes in comments

2020-09-23 Thread Bernard Zhao
Change the comment typo: "programm" -> "program".

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 2 +-
 drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c  | 4 ++--
 drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c  | 4 ++--
 drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c  | 4 ++--
 drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c  | 2 +-
 drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c  | 4 ++--
 drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c  | 4 ++--
 drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c  | 4 ++--
 8 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
index 770025a5e500..7c46937c1c0e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
@@ -98,7 +98,7 @@ struct amdgpu_bo_list_entry;
 #define AMDGPU_PTE_MTYPE_NV10(a)   ((uint64_t)(a) << 48)
 #define AMDGPU_PTE_MTYPE_NV10_MASK AMDGPU_PTE_MTYPE_NV10(7ULL)
 
-/* How to programm VM fault handling */
+/* How to program VM fault handling */
 #define AMDGPU_VM_FAULT_STOP_NEVER 0
 #define AMDGPU_VM_FAULT_STOP_FIRST 1
 #define AMDGPU_VM_FAULT_STOP_ALWAYS2
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c 
b/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c
index 3cafba726587..b0c0c438fc93 100644
--- a/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c
+++ b/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c
@@ -348,7 +348,7 @@ static int uvd_v4_2_start(struct amdgpu_device *adev)
/* Set the write pointer delay */
WREG32(mmUVD_RBC_RB_WPTR_CNTL, 0);
 
-   /* programm the 4GB memory segment for rptr and ring buffer */
+   /* program the 4GB memory segment for rptr and ring buffer */
WREG32(mmUVD_LMI_EXT40_ADDR, upper_32_bits(ring->gpu_addr) |
   (0x7 << 16) | (0x1 << 31));
 
@@ -541,7 +541,7 @@ static void uvd_v4_2_mc_resume(struct amdgpu_device *adev)
uint64_t addr;
uint32_t size;
 
-   /* programm the VCPU memory controller bits 0-27 */
+   /* program the VCPU memory controller bits 0-27 */
addr = (adev->uvd.inst->gpu_addr + AMDGPU_UVD_FIRMWARE_OFFSET) >> 3;
size = AMDGPU_UVD_FIRMWARE_SIZE(adev) >> 3;
WREG32(mmUVD_VCPU_CACHE_OFFSET0, addr);
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c 
b/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c
index a566ff926e90..6e57001f6d0a 100644
--- a/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c
@@ -253,7 +253,7 @@ static void uvd_v5_0_mc_resume(struct amdgpu_device *adev)
uint64_t offset;
uint32_t size;
 
-   /* programm memory controller bits 0-27 */
+   /* program memory controller bits 0-27 */
WREG32(mmUVD_LMI_VCPU_CACHE_64BIT_BAR_LOW,
lower_32_bits(adev->uvd.inst->gpu_addr));
WREG32(mmUVD_LMI_VCPU_CACHE_64BIT_BAR_HIGH,
@@ -404,7 +404,7 @@ static int uvd_v5_0_start(struct amdgpu_device *adev)
/* set the wb address */
WREG32(mmUVD_RBC_RB_RPTR_ADDR, (upper_32_bits(ring->gpu_addr) >> 2));
 
-   /* programm the RB_BASE for ring buffer */
+   /* program the RB_BASE for ring buffer */
WREG32(mmUVD_LMI_RBC_RB_64BIT_BAR_LOW,
lower_32_bits(ring->gpu_addr));
WREG32(mmUVD_LMI_RBC_RB_64BIT_BAR_HIGH,
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c 
b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
index 0a880bc101b8..d2d90fe5c6f8 100644
--- a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
@@ -583,7 +583,7 @@ static void uvd_v6_0_mc_resume(struct amdgpu_device *adev)
uint64_t offset;
uint32_t size;
 
-   /* programm memory controller bits 0-27 */
+   /* program memory controller bits 0-27 */
WREG32(mmUVD_LMI_VCPU_CACHE_64BIT_BAR_LOW,
lower_32_bits(adev->uvd.inst->gpu_addr));
WREG32(mmUVD_LMI_VCPU_CACHE_64BIT_BAR_HIGH,
@@ -825,7 +825,7 @@ static int uvd_v6_0_start(struct amdgpu_device *adev)
/* set the wb address */
WREG32(mmUVD_RBC_RB_RPTR_ADDR, (upper_32_bits(ring->gpu_addr) >> 2));
 
-   /* programm the RB_BASE for ring buffer */
+   /* program the RB_BASE for ring buffer */
WREG32(mmUVD_LMI_RBC_RB_64BIT_BAR_LOW,
lower_32_bits(ring->gpu_addr));
WREG32(mmUVD_LMI_RBC_RB_64BIT_BAR_HIGH,
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c 
b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
index e07e3fae99b5..b44c8677ce8d 100644
--- a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
@@ -1073,7 +1073,7 @@ static int uvd_v7_0_start(struct amdgpu_device *adev)
WREG32_SOC15(UVD, k, mmUVD_RBC_RB_RPTR_ADDR,
(upper_32_bits(ring->gpu_addr) >> 2));
 
-   /* programm the RB_BASE for ring buffer */
+   /* program the RB_BASE for ring buffer */

[PATCH v2] drm/amd/display: optimize code runtime a bit

2020-09-22 Thread Bernard Zhao
In the function dal_ddc_service_query_ddc_data,
get rid of dal_ddc_i2c_payloads_destroy, call
dal_vector_destruct() directly.
This change is to make the code run a bit fast.

Signed-off-by: Bernard Zhao 
Changes since V1:
*get rid of dal_ddc_i2c_payloads_destroy, call
dal_vector_destruct() directly.

Link for V1:
*https://lore.kernel.org/patchwork/patch/1309014/
---
 drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c
index b984eecca58b..dec12de37642 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c
@@ -148,14 +148,6 @@ static uint32_t dal_ddc_i2c_payloads_get_count(struct 
i2c_payloads *p)
return p->payloads.count;
 }
 
-static void dal_ddc_i2c_payloads_destroy(struct i2c_payloads *p)
-{
-   if (!p)
-   return;
-
-   dal_vector_destruct(>payloads);
-}
-
 #define DDC_MIN(a, b) (((a) < (b)) ? (a) : (b))
 
 void dal_ddc_i2c_payloads_add(
@@ -582,7 +574,7 @@ bool dal_ddc_service_query_ddc_data(
ddc->link,
);
 
-   dal_ddc_i2c_payloads_destroy();
+   dal_vector_destruct();
}
 
return success;
-- 
2.28.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re:Re: [PATCH] drm/amd/display: optimize code runtime a bit

2020-09-22 Thread Bernard

From: Alex Deucher 
Date: 2020-09-22 03:33:20
To:  Bernard Zhao 
Cc:  Harry Wentland ,Leo Li ,Alex 
Deucher ,"Christian König" 
,David Airlie ,Daniel Vetter 
,Rodrigo Siqueira ,Jun Lei 
,Aric Cyr ,Wenjing Liu 
,abdoulaye berthe ,Michael 
Strauss ,Brandon Syu ,Martin 
Leung ,amd-gfx list 
,Maling list - DRI developers 
,LKML 
,opensource.ker...@vivo.com
Subject: Re: [PATCH] drm/amd/display: optimize code runtime a bit>On Mon, Sep 
21, 2020 at 9:14 AM Bernard Zhao  wrote:
>>
>> Static function dal_ddc_i2c_payloads_destroy is only called
>> in dal_ddc_service_query_ddc_data, the parameter is 
>> , there is no point NULL risk, so no need to check.
>> This change is to make the code run a bit fast.
>>
>
>How about just getting rid of dal_ddc_i2c_payloads_destroy() and just
>call dal_vector_destruct() directly.

Good idea, I will resubmit a patch, thanks!

BR//Bernard

>Alex
>
>
>> Signed-off-by: Bernard Zhao 
>> ---
>>  drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c | 3 ---
>>  1 file changed, 3 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c 
>> b/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c
>> index b984eecca58b..6dcc666738fc 100644
>> --- a/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c
>> +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c
>> @@ -150,9 +150,6 @@ static uint32_t dal_ddc_i2c_payloads_get_count(struct 
>> i2c_payloads *p)
>>
>>  static void dal_ddc_i2c_payloads_destroy(struct i2c_payloads *p)
>>  {
>> -   if (!p)
>> -   return;
>> -
>> dal_vector_destruct(>payloads);
>>  }
>>
>> --
>> 2.28.0
>>
>> ___
>> amd-gfx mailing list
>> amd-...@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/amd-gfx


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Re-send][PATCH] gpu/ipu-v3:reduce protected code area in ipu idmac get/put

2020-09-22 Thread Bernard
This change will speed-up a bit these ipu_idmac_get &
ipu_idmac_put processing and there is no need to protect
kzalloc & kfree.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/ipu-v3/ipu-common.c | 24 +---
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/ipu-v3/ipu-common.c b/drivers/gpu/ipu-v3/ipu-common.c
index b3dae9ec1a38..8b3a57864c2e 100644
--- a/drivers/gpu/ipu-v3/ipu-common.c
+++ b/drivers/gpu/ipu-v3/ipu-common.c
@@ -267,29 +267,30 @@ EXPORT_SYMBOL_GPL(ipu_rot_mode_to_degrees);
 struct ipuv3_channel *ipu_idmac_get(struct ipu_soc *ipu, unsigned num)
 {
struct ipuv3_channel *channel;
+   struct ipuv3_channel *entry;
 
dev_dbg(ipu->dev, "%s %d\n", __func__, num);
 
if (num > 63)
return ERR_PTR(-ENODEV);
 
+   channel = kzalloc(sizeof(*channel), GFP_KERNEL);
+   if (!channel)
+   return ERR_PTR(-ENOMEM);
+
+   channel->num = num;
+   channel->ipu = ipu;
+
mutex_lock(>channel_lock);
 
-   list_for_each_entry(channel, >channels, list) {
-   if (channel->num == num) {
+   list_for_each_entry(entry, >channels, list) {
+   if (entry->num == num) {
+   kfree(channel);
channel = ERR_PTR(-EBUSY);
goto out;
}
}
 
-   channel = kzalloc(sizeof(*channel), GFP_KERNEL);
-   if (!channel) {
-   channel = ERR_PTR(-ENOMEM);
-   goto out;
-   }
-
-   channel->num = num;
-   channel->ipu = ipu;
list_add(>list, >channels);
 
 out:
@@ -308,9 +309,10 @@ void ipu_idmac_put(struct ipuv3_channel *channel)
mutex_lock(>channel_lock);
 
list_del(>list);
-   kfree(channel);
 
mutex_unlock(>channel_lock);
+
+   kfree(channel);
 }
 EXPORT_SYMBOL_GPL(ipu_idmac_put);
 
-- 
2.28.0



___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/amd/display: optimize code runtime a bit

2020-09-22 Thread Bernard Zhao
Static function dal_ddc_i2c_payloads_destroy is only called
in dal_ddc_service_query_ddc_data, the parameter is 
, there is no point NULL risk, so no need to check.
This change is to make the code run a bit fast.

Signed-off-by: Bernard Zhao 
---
 drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c
index b984eecca58b..6dcc666738fc 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c
@@ -150,9 +150,6 @@ static uint32_t dal_ddc_i2c_payloads_get_count(struct 
i2c_payloads *p)
 
 static void dal_ddc_i2c_payloads_destroy(struct i2c_payloads *p)
 {
-   if (!p)
-   return;
-
dal_vector_destruct(>payloads);
 }
 
-- 
2.28.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


  1   2   >