[PATCH] nvdimm: use kobj_to_dev instead of container_of

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

Signed-off-by: Bernard Zhao 
---
 drivers/nvdimm/dimm_devs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/nvdimm/dimm_devs.c b/drivers/nvdimm/dimm_devs.c
index dc7449a40003..bea41bb5f830 100644
--- a/drivers/nvdimm/dimm_devs.c
+++ b/drivers/nvdimm/dimm_devs.c
@@ -430,7 +430,7 @@ static struct attribute *nvdimm_attributes[] = {
 
 static umode_t nvdimm_visible(struct kobject *kobj, struct attribute *a, int n)
 {
-   struct device *dev = container_of(kobj, typeof(*dev), kobj);
+   struct device *dev = kobj_to_dev(kobj);
struct nvdimm *nvdimm = to_nvdimm(dev);
 
if (a != _attr_security.attr && a != _attr_frozen.attr)
@@ -546,7 +546,7 @@ static struct attribute *nvdimm_firmware_attributes[] = {
 
 static umode_t nvdimm_firmware_visible(struct kobject *kobj, struct attribute 
*a, int n)
 {
-   struct device *dev = container_of(kobj, typeof(*dev), kobj);
+   struct device *dev = kobj_to_dev(kobj);
struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev);
struct nvdimm_bus_descriptor *nd_desc = nvdimm_bus->nd_desc;
struct nvdimm *nvdimm = to_nvdimm(dev);
-- 
2.33.1




[patch v3] translations/zh_CN: add translations to dev-tools gcov

2021-04-14 Thread Bernard Zhao
Add translations to dev-tools gcov

Signed-off-by: Bernard Zhao 

---

Changes since V2:
* fix some inaccurate translation

Changes since V1:
* add index.rst in dev-tools and link to to zh_CN/index.rst
* fix some inaccurate translation
---
 .../translations/zh_CN/dev-tools/gcov.rst | 261 ++
 .../translations/zh_CN/dev-tools/index.rst|  35 +++
 Documentation/translations/zh_CN/index.rst|   1 +
 3 files changed, 297 insertions(+)
 create mode 100644 Documentation/translations/zh_CN/dev-tools/gcov.rst
 create mode 100644 Documentation/translations/zh_CN/dev-tools/index.rst

diff --git a/Documentation/translations/zh_CN/dev-tools/gcov.rst 
b/Documentation/translations/zh_CN/dev-tools/gcov.rst
new file mode 100644
index ..882eee4c75c5
--- /dev/null
+++ b/Documentation/translations/zh_CN/dev-tools/gcov.rst
@@ -0,0 +1,261 @@
+.. include:: ../disclaimer-zh_CN.rst
+
+:Original: Documentation/dev-tools/gcov.rst
+:Translator: ? Bernard Zhao 
+
+???Linux???gcov
+=
+
+gcov???linux???GCC?
+?
+linux?gcovdebug-fs?
+?gcov???``-o``??
+???root?::
+
+# cd /tmp/linux-out
+# gcov -o /sys/kernel/debug/gcov/tmp/linux-out/kernel spinlock.c
+
+???
+?gcov_?lcov_???
+???linux 
HTML???
+
+???:
+
+* ???
+* 
??
+* 
???
+???
+
+_gcov: https://gcc.gnu.org/onlinedocs/gcc/Gcov.html
+_lcov: http://ltp.sourceforge.net/coverage/lcov.php
+
+
+??
+---
+
+::
+
+CONFIG_DEBUG_FS=y
+CONFIG_GCOV_KERNEL=y
+
+??::
+
+CONFIG_GCOV_PROFILE_ALL=y
+
+???
+??
+??
+
+?debugfs??::
+
+mount -t debugfs none /sys/kernel/debug
+
+
+?
+-
+
+??
+??Makefile:
+
+- ?main.o???::
+
+GCOV_PROFILE_main.o := y
+
+- ???::
+
+GCOV_PROFILE := y
+
+???CONFIG_GCOV_PROFILE_ALL??
+?::
+
+GCOV_PROFILE_main.o := n
+
+???::
+
+GCOV_PROFILE := n
+
+???
+
+
+
+-
+
+gcov???debugfs?:
+
+``/sys/kernel/debug/gcov``
+gcov
+
+``/sys/kernel/debug/gcov/reset``
+
??:??gcov???0
+
+``/sys/kernel/debug/gcov/path/to/compile/dir/file.gcda``
+
gcov??
+   ??gcov???0
+
+``/sys/kernel/debug/gcov/path/to/compile/dir/file.gcno``
+
gcov
+???gcc??``-ftest-coverage``???
+
+
+?
+---
+
+
+gcov
+debugfs?
+??debugfs?
+
+???gcov_persist??gcov::
+
+gcov_persist = 0
+
+???gcov???
+?
+
+
+??
+-
+
+gcov

Re:Re: [PATCH v2] Documentation/translations/zh_CN/dev-tools/

2021-04-12 Thread Bernard
Hi Wu X.C :

Thanks for your review!
I will fix this and resubmit this patch.

BR//Bernard

From: "Wu X.C." 
Date: 2021-04-02 11:58:27
To:  Bernard Zhao 
Cc:  Harry Wei ,Alex Shi 
,Alex Shi ,Jonathan Corbet 
,Nathan Chancellor ,Nick Desaulniers 
,linux-...@vger.kernel.org,linux-kernel@vger.kernel.org,clang-built-li...@googlegroups.com,opensource.ker...@vivo.com
Subject: Re: [PATCH v2] Documentation/translations/zh_CN/dev-tools/>Hi Bernard,
>
>On Thu, Apr 01, 2021 at 06:27:16AM -0700, Bernard Zhao wrote:
>
>Why the charset in your email header is 'y' ?
>"Content-Type: text/plain; charset=y"
><https://lore.kernel.org/linux-doc/20210401132732.70612-1-bern...@vivo.com/raw>
>
>> Add translations to dev-tools gcov
>> 
>> Signed-off-by: Bernard Zhao 
>> Reviewed-by: Wu X.C 
>  ^
>  This reviewed-by tag is invalid.
>
>Please do not pick review-by tag before one give it.
>
>> ---
>> Changes since V1:
>> * add index.rst in dev-tools and link to to zh_CN/index.rst
>> * fix some inaccurate translation
>> 
>> Link for V1:
>> *https://lore.kernel.org/patchwork/patch/1405740/
>> ---
>>  .../translations/zh_CN/dev-tools/gcov.rst | 279 ++
>>  .../translations/zh_CN/dev-tools/index.rst|  39 +++
>>  Documentation/translations/zh_CN/index.rst|   1 +
>>  3 files changed, 319 insertions(+)
>>  create mode 100644 Documentation/translations/zh_CN/dev-tools/gcov.rst
>>  create mode 100644 Documentation/translations/zh_CN/dev-tools/index.rst
>> 
>> diff --git a/Documentation/translations/zh_CN/dev-tools/gcov.rst 
>> b/Documentation/translations/zh_CN/dev-tools/gcov.rst
>> new file mode 100644
>> index ..e8ffb99b566d
>
>Why replaced all ',' '。' with ',' '.' in zh_CN/dev-tools/gcov.rst ?
>And also the columns in the v2 are much shorter than v1.
>Please recover the above two points.
>
>> --- /dev/null
>> +++ b/Documentation/translations/zh_CN/dev-tools/gcov.rst
>> @@ -0,0 +1,279 @@
>> +.. SPDX-License-Identifier: GPL-2.0
>> +
>> +.. include:: ../disclaimer-zh_CN.rst
>> +
>> +:Original: :ref:`Documentation/dev-tools/gcov.rst `
>
>the original text have no article tag, simply use this
>:Original: Documentation/dev-tools/gcov.rst
>
>> +:Translator: 赵军奎 Bernard Zhao 
>> +
>> +.. _dev-tools_gcov:
>
>Please remove above line, no need
>
>> +
>> +在Linux内核里使用gcov做代码覆盖率检查
>> +
>
>Still got a lot of warning.
>Please using monospaced font to fix this.
>Build log:
>
>/test/linux/Documentation/translations/zh_CN/dev-tools/gcov.rst:11: WARNING: 
>Title underline too short.
>
>在Linux内核里使用gcov做代码覆盖率检查
>
>/test/linux/Documentation/translations/zh_CN/dev-tools/gcov.rst:110: WARNING: 
>Title underline too short.
>
>针对模块的统计
>---
>/test/linux/Documentation/translations/zh_CN/dev-tools/gcov.rst:110: WARNING: 
>Title underline too short.
>
>针对模块的统计
>---
>/test/linux/Documentation/translations/zh_CN/dev-tools/gcov.rst:154: WARNING: 
>Block quote ends without a blank line; unexpected unindent.
>/test/linux/Documentation/translations/zh_CN/dev-tools/gcov.rst:179: WARNING: 
>Title underline too short.
>
>关于编译器的注意事项
>-
>/test/linux/Documentation/translations/zh_CN/dev-tools/gcov.rst:179: WARNING: 
>Title underline too short.
>
>关于编译器的注意事项
>-
>
>
>> +
>> +gcov是linux中已经集成的一个分析模块,该模块在内核中对
>> +GCC的代码覆盖率统计提供了支持.
>> +linux内核运行时的代码覆盖率数据会以gcov兼容的格式存储
>> +在debug-fs中,可以通过gcov的“-o”选项(如下示例)获得
>> +指定文件的代码运行覆盖率统计数据(需要跳转到内核编
>> +译路径下并且要有root权限)::
>> +
>> +# cd /tmp/linux-out
>> +# gcov -o /sys/kernel/debug/gcov/tmp/linux-out/kernel spinlock.c
>> +
>> +这将在当前目录中创建带有执行计数注释的源代码文件.
>> +在获得这些统计文件后,可以使用图形化的gcov[1]前端工
>> +具(比如lcov[2]),来实现自动化处理linux 内核的覆
>> +盖率运行数据,同时生成易于阅读的HTML格式文件.
>
>Sorry for the inconvenience,
>I test again, found the url tags seems would not make namespace conflicts.
>Thus,
>
>在获得这些统计文件后,可以使用图形化的 gcov_ 前端工
>具(比如 lcov_ ),来实现自动化处理linux 内核的覆
>
>> +
>> +可能的用途:
>> +
>> +* 调试(用来判断每一行的代码是否已经运行过)
>> +* 测试改进(如何修改测试代码,尽可能地覆盖到没有运
>> +  行过的代码)
>> +* 内核配置优化(对于某一个选项配置,如果关联的代码
>> +  从来没有运行过,是否还需要这个配置)
>> +
>> +[1]_gcov: https://gcc.gnu.org/onlinedocs/gcc/Gcov.html
>> +[2]_lcov: http://ltp.sourceforge.net/coverage/lcov.php
>
>.. _gcov: https://gcc.gnu.org/onlinedocs/gcc/Gcov.html
>.. _lcov: http://ltp.sourceforge.net/coverage/lcov.php
>
>> +
>> +
>> +准备
>&

[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



[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



[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



[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



[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



[PATCH v2] Documentation/translations/zh_CN/dev-tools/

2021-04-01 Thread Bernard Zhao
Add translations to dev-tools gcov

Signed-off-by: Bernard Zhao 
Reviewed-by: Wu X.C 
---
Changes since V1:
* add index.rst in dev-tools and link to to zh_CN/index.rst
* fix some inaccurate translation

Link for V1:
*https://lore.kernel.org/patchwork/patch/1405740/
---
 .../translations/zh_CN/dev-tools/gcov.rst | 279 ++
 .../translations/zh_CN/dev-tools/index.rst|  39 +++
 Documentation/translations/zh_CN/index.rst|   1 +
 3 files changed, 319 insertions(+)
 create mode 100644 Documentation/translations/zh_CN/dev-tools/gcov.rst
 create mode 100644 Documentation/translations/zh_CN/dev-tools/index.rst

diff --git a/Documentation/translations/zh_CN/dev-tools/gcov.rst 
b/Documentation/translations/zh_CN/dev-tools/gcov.rst
new file mode 100644
index ..e8ffb99b566d
--- /dev/null
+++ b/Documentation/translations/zh_CN/dev-tools/gcov.rst
@@ -0,0 +1,279 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+.. include:: ../disclaimer-zh_CN.rst
+
+:Original: :ref:`Documentation/dev-tools/gcov.rst `
+:Translator: ? Bernard Zhao 
+
+.. _dev-tools_gcov:
+
+???Linux???gcov
+
+
+gcov???linux,
+GCC???.
+linux?gcov?
+???debug-fs???,gcov??-o?
+???
+root?::
+
+# cd /tmp/linux-out
+# gcov -o /sys/kernel/debug/gcov/tmp/linux-out/kernel spinlock.c
+
+.
+??,gcov[1]?
+lcov[2]???,linux 
+??,???HTML.
+
+???:
+
+* ???
+* ???,??
+  ??
+* ,?
+  ?,??
+
+[1]_gcov: https://gcc.gnu.org/onlinedocs/gcc/Gcov.html
+[2]_lcov: http://ltp.sourceforge.net/coverage/lcov.php
+
+
+??
+---
+
+::
+
+CONFIG_DEBUG_FS=y
+CONFIG_GCOV_KERNEL=y
+
+,???::
+
+CONFIG_GCOV_PROFILE_ALL=y
+
+??,??
+?,???.
+??,??
+
+?debugfs??::
+
+mount -t debugfs none /sys/kernel/debug
+
+
+?
+-
+
+???
+??Makefile:
+
+- ?main.o???::
+
+GCOV_PROFILE_main.o := y
+
+- ???::
+
+GCOV_PROFILE := y
+
+?CONFIG_GCOV_PROFILE_ALL???
+??,???::
+
+GCOV_PROFILE_main.o := n
+
+???::
+
+GCOV_PROFILE := n
+
+.
+
+
+
+-
+
+gcov???debugfs?:
+
+``/sys/kernel/debug/gcov``
+gcov
+
+``/sys/kernel/debug/gcov/reset``
+??:??gcov??
+?0
+
+``/sys/kernel/debug/gcov/path/to/compile/dir/file.gcda``
+gcov,??
+???gcov???0
+
+``/sys/kernel/debug/gcov/path/to/compile/dir/file.gcno``
+gcov??
+,??gcc??
+???-ftest-coverage???.
+
+
+?
+---
+
+?,
+?.
+gcov?,??
+???.
+debugfs??.
+??,???
+??debugfs??.
+
+???gcov_persist??gcov
+::
+
+gcov_persist = 0
+
+,
+gcov

Re:Re: [PATCH] translations/zh_CN: add translations to dev-tools gcov

2021-03-31 Thread Bernard

Hi Wu X.C:

From: "Wu X.C." 
Date: 2021-03-31 23:35:03
To:  Bernard Zhao 
Cc:  Harry Wei ,Alex Shi 
,Alex Shi ,Jonathan Corbet 
,Nathan Chancellor ,Nick Desaulniers 
,linux-...@vger.kernel.org,linux-kernel@vger.kernel.org,clang-built-li...@googlegroups.com,opensource.ker...@vivo.com
Subject: Re: [PATCH] translations/zh_CN: add translations to dev-tools gcov>Hi 
Bernard,
>
>I'd like to help Alex to make a pre-review.
>
>On Wed, Mar 31, 2021 at 06:14:05AM -0700, Bernard Zhao wrote:
>> Add translations to dev-tools gcov
>> 
>> Signed-off-by: Bernard Zhao 
>> ---
>>  .../translations/zh_CN/dev-tools/gcov.rst | 274 ++
>>  1 file changed, 274 insertions(+)
>>  create mode 100644 Documentation/translations/zh_CN/dev-tools/gcov.rst
>
>It seems that you are the first person who add zh translation in
>zh_CN/dev-tools, so please also add the zh_CN/dev-tools/index.rst and link
>it to zh_CN/index.rst, or your work will not appear when building docs.
>
>You could mark the un-translated docs of dev-tools in 'TodoList', just
>as zh_CN/admin-guide/index.rst.

Thanks for your pre-review!
I will fix this and resubmit this patch.

BR//Bernard

>> 
>> diff --git a/Documentation/translations/zh_CN/dev-tools/gcov.rst 
>> b/Documentation/translations/zh_CN/dev-tools/gcov.rst
>> new file mode 100644
>> index ..5ebbc55e5881
>> --- /dev/null
>> +++ b/Documentation/translations/zh_CN/dev-tools/gcov.rst
>> @@ -0,0 +1,274 @@
>
><<<<<<<<<<<<<<<
>
>> +Chinese translated version of Documentation/dev-tools/gcov.rst
>> +
>> +If you have any comment or update to the content, please contact the
>> +original document maintainer directly.  However, if you have a problem
>> +communicating in English you can also ask the Chinese maintainer for
>> +help.  Contact the Chinese maintainer if this translation is outdated
>> +or if there is a problem with the translation.
>> +
>> +Chinese maintainer: Bernard Zhao 
>> +-----
>> +Documentation/dev-tools/gcov.rst 的中文翻译
>> +
>> +如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文
>> +交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻
>> +译存在问题,请联系中文版维护者。
>> +
>> +中文版维护者: 赵军奎 Bernard Zhao 
>> +中文版翻译者: 赵军奎 Bernard Zhao 
>> +
>> +以下为正文
>> +-
>
><<<<<<<<<<<<<<<
>
>You seems use the old style of zh translation header. Please follow this:
>
>.. include:: ../disclaimer-zh_CN.rst
>
>:Original: Documentation/dev-tools/gcov.rst
>
>:Translator: 赵军奎 Bernard Zhao 
>
>The 'include' will give the unified declaration, and use tags for other
>informations.
>
>Example see:
>  Documentation/translations/zh_CN/process/1.Intro.rst
>
>> +
>> +在Linux内核里使用gcov做代码覆盖率检查
>> +===
>
>Here, = line must longer than title text. Please make before send
>patch, will find a warning. And need a empty line under the = line.
>
>Reference:
>  Documentation/doc-guide/sphinx.rst
>
>> +gcov是linux中已经集成的一个分析模块,该模块在内核中对GCC的代码覆盖率统
>> +计提供了支持。
>> +linux内核运行时的代码覆盖率数据会以gcov兼容的格式存储在debug-fs中,可
>> +以通过如下的方式获得指定文件的代码运行覆盖率统计数据(需要跳转到内核
>> +编译路径下并且要有root权限):
>   ^^
>You missed "use gcov with the ``-o`` option as follows"
>
>'::' is a special symbol for ReST, do not use ':' to replace it. 
>Make test will also help with this point.
>
>> +
>> +# cd /tmp/linux-out
>> +# gcov -o /sys/kernel/debug/gcov/tmp/linux-out/kernel spinlock.c
>> +
>> +这个命令会在当前编译路径下创建带有注释的代码实际运行次数的计数源文件。
>
>这将在当前目录中创建带有执行计数注释的源代码文件。
>
>> +在获得这些统计文件后,可以使用图形化的gcov前端工具(比如lcov),
>> +来实现自动化处理linux kernel的覆盖率运行数据,同时生成易于阅读的HTML格
> ^^
> 内核
>
>本文所有kernel是否翻译请注意统一,建议能译全译
>
>> +式文件。
>> +
>> +可能的用途:
>> +
>> +* 调试(用来判断每一行的代码是否已经运行过)
>> +* 测试改进(如何修改测试代码,尽可能地覆盖到没有运行过的代码)
>> +* 内核配置优化(对于某一个config配置,如果关联的代码从来没有运行过,是
> ^^
>   option选项
>
>> +否还需要这个配置)
>> +
>> +gcov和lcov的关联网站
>
>This line no need. Follow two lines are ReST tags.
>
>> +.. _gcov: https://gcc.gnu.org/onlinedocs/gcc/Gcov.html
>> +.. _lcov: http://ltp.sourceforge.net/coverage/lcov.php
>
>Maybe you need to change tags for the two lines, same tag in zh and en will
>cause warning. 
>
>> +
>> +
>> +准备
>> +---
>> +
>> +打开如下配置:
>> +
>> +   

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-de...@lists.freedesktop.org,linux-kernel@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);
>>   
>




[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



[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



[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



[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] 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



[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



[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] translations/zh_CN: add translations to dev-tools gcov

2021-03-31 Thread Bernard Zhao
Add translations to dev-tools gcov

Signed-off-by: Bernard Zhao 
---
 .../translations/zh_CN/dev-tools/gcov.rst | 274 ++
 1 file changed, 274 insertions(+)
 create mode 100644 Documentation/translations/zh_CN/dev-tools/gcov.rst

diff --git a/Documentation/translations/zh_CN/dev-tools/gcov.rst 
b/Documentation/translations/zh_CN/dev-tools/gcov.rst
new file mode 100644
index ..5ebbc55e5881
--- /dev/null
+++ b/Documentation/translations/zh_CN/dev-tools/gcov.rst
@@ -0,0 +1,274 @@
+Chinese translated version of Documentation/dev-tools/gcov.rst
+
+If you have any comment or update to the content, please contact the
+original document maintainer directly.  However, if you have a problem
+communicating in English you can also ask the Chinese maintainer for
+help.  Contact the Chinese maintainer if this translation is outdated
+or if there is a problem with the translation.
+
+Chinese maintainer: Bernard Zhao 
+-
+Documentation/dev-tools/gcov.rst ???
+
+??
+??
+
+
+? ? Bernard Zhao 
+? ? Bernard Zhao 
+
+???
+-
+
+???Linux???gcov
+===
+gcov???linux???GCC?
+?
+linux?gcovdebug-fs?
+??
+???root
+
+# cd /tmp/linux-out
+# gcov -o /sys/kernel/debug/gcov/tmp/linux-out/kernel spinlock.c
+
+?
+?gcov?lcov??
+linux 
kernel??HTML???
+
+
+??
+
+* ???
+* 
??
+* 
config?
+???
+
+gcov???lcov???
+.. _gcov: https://gcc.gnu.org/onlinedocs/gcc/Gcov.html
+.. _lcov: http://ltp.sourceforge.net/coverage/lcov.php
+
+
+??
+---
+
+?
+
+CONFIG_DEBUG_FS=y
+CONFIG_GCOV_KERNEL=y
+
+?
+
+CONFIG_GCOV_PROFILE_ALL=y
+
+???kernel??kernel??
+??kernel??
+kernel
+
+?debugfs?
+
+mount -t debugfs none /sys/kernel/debug
+
+
+?
+-
+
+???kernel?
+??Makefile???
+
+- ?main.o???
+
+   GCOV_PROFILE_main.o := y
+
+- ???
+
+   GCOV_PROFILE := y
+
+??kernel???CONFIG_GCOV_PROFILE_ALL??
+
+
+- ??main.o???
+
+   GCOV_PROFILE_main.o := n
+
+- 
+
+   GCOV_PROFILE := n
+
+
+???
+-
+
+gcov???debugfs?
+
+``/sys/kernel/debug/gcov``
+gcov
+
+``/sys/kernel/debug/gcov/reset``
+gcov???gcov???0
+
+``/sys/kernel/debug/gcov/path/to/compile/dir/file.gcda``
+gcov
+
+``/sys/kernel/debug/gcov/path/to/compile/dir/file.gcno``
+
gcov
+???gcc??-ftest-coverage???
+
+
+??module?
+---
+
+kernel??
+gcov
+debugfs

Re: [PATCH] RDMA/siw: Fix missing check in siw_get_hdr

2021-02-26 Thread Bernard Metzler
-"Dinghao Liu"  wrote: -

>To: dinghao@zju.edu.cn, k...@umn.edu
>From: "Dinghao Liu" 
>Date: 02/26/2021 08:56AM
>Cc: "Bernard Metzler" , "Doug Ledford"
>, "Jason Gunthorpe" ,
>linux-r...@vger.kernel.org, linux-kernel@vger.kernel.org
>Subject: [EXTERNAL] [PATCH] RDMA/siw: Fix missing check in
>siw_get_hdr
>
>We should also check the range of opcode after calling
>__rdmap_get_opcode() in the else branch to prevent potential
>overflow.

Hi Dinghao,
No this is not needed. We always first read the minimum
header information (MPA len, DDP flags, RDMAP opcode,
STag, target offset). Only if we have received that
into local buffer, we check for the opcode this one time.
Now the opcode determines the remaining length of the
variably sized part of the header to be received.

We do not have to check the opcode again, since we
already received and checked it.

Best,
Bernard.

>
>Fixes: 8b6a361b8c482 ("rdma/siw: receive path")
>Signed-off-by: Dinghao Liu 
>---
> drivers/infiniband/sw/siw/siw_qp_rx.c | 10 ++
> 1 file changed, 10 insertions(+)
>
>diff --git a/drivers/infiniband/sw/siw/siw_qp_rx.c
>b/drivers/infiniband/sw/siw/siw_qp_rx.c
>index 60116f20653c..301e7fe2c61a 100644
>--- a/drivers/infiniband/sw/siw/siw_qp_rx.c
>+++ b/drivers/infiniband/sw/siw/siw_qp_rx.c
>@@ -1072,6 +1072,16 @@ static int siw_get_hdr(struct siw_rx_stream
>*srx)
>   siw_dbg_qp(rx_qp(srx), "new header, opcode %u\n", opcode);
>   } else {
>   opcode = __rdmap_get_opcode(c_hdr);
>+
>+  if (opcode > RDMAP_TERMINATE) {
>+  pr_warn("siw: received unknown packet type %u\n",
>+  opcode);
>+
>+  siw_init_terminate(rx_qp(srx), TERM_ERROR_LAYER_RDMAP,
>+ RDMAP_ETYPE_REMOTE_OPERATION,
>+ RDMAP_ECODE_OPCODE, 0);
>+  return -EINVAL;
>+  }
>   }
>   set_rx_fpdu_context(qp, opcode);
>   frx = qp->rx_fpdu;
>-- 
>2.17.1
>
>



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

2021-02-02 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



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

2021-02-02 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



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

2021-02-02 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



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

2021-02-02 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



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

2021-02-02 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



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

2021-02-02 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



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

2021-02-02 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



Re:[RFC PATCH] Add a new "Frozen" status to MAINTAINERS subsystem entries

2020-11-23 Thread Bernard

From: Joe Perches 
Date: 2020-11-24 06:24:07
To:  Sam Ravnborg ,Bernard Zhao 
Cc:  linux-kernel@vger.kernel.org,Andrew Morton 
,Linus Torvalds 
,kernel-janitors 
,Greg KH 
Subject: [RFC PATCH] Add a new "Frozen" status to MAINTAINERS subsystem 
entries>On Mon, 2020-11-23 at 22:42 +0100, Sam Ravnborg wrote:
>> For this old driver we should try to limit patches to bug fixing and
>> infrastructure updates.
>
>It might be useful to add a new "S:" entry type to these old drivers
>as supported/maintained/obsolete may not really be appropriate.
>
>How about something like "S: Frozen" and checkpatch could emit a
>message similar to the one for unnecessary changes to obsolete code?
>
>So using the below would emit:
>
>$ ./scripts/checkpatch.pl -f drivers/gpu/drm/via/via_dma.c
>WARNING: drivers/gpu/drm/via/via_dma.c is marked as 'frozen' in the 
>MAINTAINERS hierarchy.  No unnecessary modifications please.
>
>Maybe like the below (and fyi there's no additional git lookup overhead as
>the initial obsolete check already caches the git result).
>
>---
> MAINTAINERS   | 10 +-
> scripts/checkpatch.pl | 11 +++
> 2 files changed, 16 insertions(+), 5 deletions(-)
>
>diff --git a/MAINTAINERS b/MAINTAINERS
>index 5f10105cac6f..6374d29180b8 100644
>--- a/MAINTAINERS
>+++ b/MAINTAINERS
>@@ -88,7 +88,10 @@ Descriptions of section entries and preferred order
>  Supported:   Someone is actually paid to look after this.
>  Maintained:  Someone actually looks after it.
>  Odd Fixes:   It has a maintainer but they don't have time to do
>-  much other than throw the odd patch in. See below..
>+  much other than throw the odd patch in.
>+ Frozen:  Old code that should not be modified unless changes
>+  are to correct actual defects or API infrastructure.
>+  Cleanup/style changes are not generally accepted.
>  Orphan:  No current maintainer [but maybe you could take the
>   role as you write your new code].
>  Obsolete:Old code. Something tagged obsolete generally means
>@@ -5718,6 +5721,11 @@ S:  Supported
> T:git git://anongit.freedesktop.org/drm/drm-misc
> F:drivers/gpu/drm/udl/
> 
>+DRM DRIVER FOR VIA
>+L:dri-de...@lists.freedesktop.org
>+S:Frozen
>+F:drivers/gpu/drm/via/
>+
> DRM DRIVER FOR VIRTUAL KERNEL MODESETTING (VKMS)
> M:Rodrigo Siqueira 
> M:Melissa Wen 
>diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
>index fdfd5ec09be6..79321cbfb761 100755
>--- a/scripts/checkpatch.pl
>+++ b/scripts/checkpatch.pl
>@@ -902,8 +902,8 @@ sub seed_camelcase_file {
> 
> our %maintained_status = ();
> 
>-sub is_maintained_obsolete {
>-  my ($filename) = @_;
>+sub is_maintained {
>+  my ($filename, $test) = @_;
> 
>   return 0 if (!$tree || !(-e "$root/scripts/get_maintainer.pl"));
> 
>@@ -911,7 +911,7 @@ sub is_maintained_obsolete {
>   $maintained_status{$filename} = `perl 
> $root/scripts/get_maintainer.pl --status --nom --nol --nogit --nogit-fallback 
> -f $filename 2>&1`;
>   }
> 
>-  return $maintained_status{$filename} =~ /obsolete/i;
>+  return $maintained_status{$filename} =~ /$test/i;
> }
> 
> sub is_SPDX_License_valid {
>@@ -2633,9 +2633,12 @@ sub process {
>   }
> 
>   if ($found_file) {
>-  if (is_maintained_obsolete($realfile)) {
>+  if (is_maintained($realfile, "obsolete")) {
>   WARN("OBSOLETE",
>"$realfile is marked as 'obsolete' in the 
> MAINTAINERS hierarchy.  No unnecessary modifications please.\n");
>+  } elsif (is_maintained($realfile, "frozen")) {
>+  WARN("FROZEN",
>+   "$realfile is marked as 'frozen' in the 
>MAINTAINERS hierarchy.  No unnecessary modifications please.\n");
>   }
>   if ($realfile =~ 
> m@^(?:drivers/net/|net/|drivers/staging/)@) {
>   $check = 1;

Hi:

For me, this seems to be a nice idea.
As a  newcomer to the community, maybe I am not sure which drivers are hot and 
which ones do not need too much attention.
With this patch script, it will give us a better guide.

BR//Bernard
>




YOUR FUNDS.

2020-11-20 Thread Mr. Bernard Lauwers (Management Board Of Director)
-- 
WORLD BANK PLC
1225 Connecticut Ave NW,
Washington, DC 20036, USA

Attention,

I am worried over your silence in regards to this pending funds. I hereby
advised you to comply with us to finalized and actualized this payment to
you.

YOU ARE ORDERED TO STOP ANY TRANSACTION. Therefore, bringing to your better
understanding of the new developments as your file payment has been
forwarded to this World Bank to pay you as the Approved Bank in charge of
your funds, this is to avoid any further delay in releasing your funds as
agreed with the United Nations after the recent meeting held in Washington,
DC 20036, USA.

Therefore, you are advised to reconfirm your details as stated below to
enable effect your payment within 72 hours as guaranteed from our previous
meeting

Full Name,
Contact Address,
Cell Phone

As for the processing of your payment within 72hrs. Confirm as well your
payment options

1.ATM
2.SWIFT WIRE TRANSFER (Banking details required)
3.Bank Draft.

I await hearing from you to enable us complete the process and release of
your funds.

Regards,
Mr. Bernard Lauwers
(Acting Managing Director and WBG Chief Financial Officer)


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

2020-11-18 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



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

2020-11-18 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



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

2020-11-18 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



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

2020-11-18 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



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

2020-11-17 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



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

2020-11-17 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



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

2020-11-17 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



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

2020-11-11 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



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

2020-11-11 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



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

2020-11-11 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



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

2020-11-11 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



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

2020-11-11 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



[PATCH 0/5] add KERN_LEVEL to printk

2020-11-11 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



[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





[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





[Resend][PATCH] drivers/thermal: fix potential memleak in error branch

2020-11-10 Thread Bernard
Function __thermal_cooling_device_register, when device_register
failed, cdev is not free after error value return, this may
bring in potential memleak.

Signed-off-by: Bernard Zhao 
---
 drivers/thermal/thermal_core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 3d1e0033bf3e..e4bee15dfa1f 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1125,6 +1125,7 @@ __thermal_cooling_device_register(struct device_node *np,
if (result) {
ida_simple_remove(_cdev_ida, cdev->id);
put_device(>device);
+   kfree(cdev);
return ERR_PTR(result);
}
 
-- 
2.29.0





[Resend][PATCH] drivers/thermal: cleanup coding style a bit

2020-11-10 Thread Bernard
Function thermal_add_hwmon_sysfs, hwmon will be NULL when
new_hwmon_device = 0, so there is no need to check, kfree will
handle NULL point.

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

diff --git a/drivers/thermal/thermal_hwmon.c b/drivers/thermal/thermal_hwmon.c
index 8b92e00ff236..ad03262cca56 100644
--- a/drivers/thermal/thermal_hwmon.c
+++ b/drivers/thermal/thermal_hwmon.c
@@ -206,8 +206,7 @@ int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
if (new_hwmon_device)
hwmon_device_unregister(hwmon->device);
  free_mem:
-   if (new_hwmon_device)
-   kfree(hwmon);
+   kfree(hwmon);
 
return result;
 }
-- 
2.29.0





[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



Re:Re: [PATCH 1/2] tty/serial: delete break after return

2020-11-08 Thread Bernard

From: "Uwe Kleine-König" 
Date: 2020-11-07 22:01:29
To:  Bernard Zhao 
Cc:  Greg Kroah-Hartman ,Jiri Slaby 
,Shawn Guo ,Sascha Hauer 
,Pengutronix Kernel Team ,Fabio 
Estevam ,NXP Linux Team 
,linux-kernel@vger.kernel.org,linux-ser...@vger.kernel.org,linux-arm-ker...@lists.infradead.org,opensource.ker...@vivo.com
Subject: Re: [PATCH 1/2] tty/serial: delete break after return>Hello,
>
>the Subject is wrong, it should use a prefix similar to "serial: imx:".
>It's a good idea to check previous patches to the same file to pick a
>suitable prefix. (E.g. git log --oneline drivers/tty/serial/imx.c)

Hi, Uwe:

Thank you for your suggestion, I will make a more accurate subject in my future 
patches.

>On Fri, Nov 06, 2020 at 07:29:23PM -0800, Bernard Zhao wrote:
>> Delete break after return, which will never run.
>> 
>> Signed-off-by: Bernard Zhao 
>> ---
>>  drivers/tty/serial/imx.c | 5 -
>>  1 file changed, 5 deletions(-)
>> 
>> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
>> index 1731d9728865..09703079db7b 100644
>> --- a/drivers/tty/serial/imx.c
>> +++ b/drivers/tty/serial/imx.c
>> @@ -320,7 +320,6 @@ static u32 imx_uart_readl(struct imx_port *sport, u32 
>> offset)
>>  switch (offset) {
>>  case UCR1:
>>  return sport->ucr1;
>> -break;
>>  case UCR2:
>>  /*
>>   * UCR2_SRST is the only bit in the cached registers that might
>> @@ -331,16 +330,12 @@ static u32 imx_uart_readl(struct imx_port *sport, u32 
>> offset)
>>  if (!(sport->ucr2 & UCR2_SRST))
>>  sport->ucr2 = readl(sport->port.membase + offset);
>>  return sport->ucr2;
>> -break;
>>  case UCR3:
>>  return sport->ucr3;
>> -break;
>>  case UCR4:
>>  return sport->ucr4;
>> -break;
>>  case UFCR:
>>  return sport->ufcr;
>> -break;
>
>you're the third to send this patch since October 20:
>
>   https://lore.kernel.org/r/20201026125142.21105-1-zhangqilo...@huawei.com
>   https://lore.kernel.org/r/20201020130709.28096-1-t...@redhat.com
>
>My comment for these was:
>
>> this might be subjective, but I like the break being there for clearity.
>> So I object to make a patch to remove them. In case I'm outvoted I'd at
>> least want empty lines instead.
>
>Zhang Qilong wrote he found the patch opportunity by manual code
>inspection, I would have expected that there is a tool that identifies a
>break after a return. If you had tool support, please mention the tool
>in the commit log (if you really want to keep following the patch's
>idea).

For this part:
I wrote a python script to check if there is a break after a return or goto.
The script currently has some issues in its handling of special characters, the 
search result is not precise enough. It is still under debugging. 
These are the only places which  the script checks out in path: driver/tty.
I also checked other path(like: driver/vme/, driver/video, driver/usb), these 
paths also have a certain number of similar issues. And I will try to submit 
these patch later.
Thanks!

BR//Bernard

>Best regards
>Uwe
>
>-- 
>Pengutronix e.K.   | Uwe Kleine-König|
>Industrial Linux Solutions | https://www.pengutronix.de/ |




[PATCH 0/2] drivers/tty: delete break after return or goto

2020-11-06 Thread Bernard Zhao
Hi, Greg:

This patch sereies delete code which never run:
{
case XXX:
return XXX;
break; //The break is meanless, so just delete it.
case YYY:
goto YYY;
break; //The break is meanless, so just delete it.
..
}

Bernard Zhao (2):
  tty/serial: delete break after return
  drivers/tty: delete break after goto/return

 drivers/tty/nozomi.c | 4 
 drivers/tty/serial/imx.c | 5 -
 2 files changed, 9 deletions(-)

-- 
2.29.0



[PATCH 1/2] tty/serial: delete break after return

2020-11-06 Thread Bernard Zhao
Delete break after return, which will never run.

Signed-off-by: Bernard Zhao 
---
 drivers/tty/serial/imx.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 1731d9728865..09703079db7b 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -320,7 +320,6 @@ static u32 imx_uart_readl(struct imx_port *sport, u32 
offset)
switch (offset) {
case UCR1:
return sport->ucr1;
-   break;
case UCR2:
/*
 * UCR2_SRST is the only bit in the cached registers that might
@@ -331,16 +330,12 @@ static u32 imx_uart_readl(struct imx_port *sport, u32 
offset)
if (!(sport->ucr2 & UCR2_SRST))
sport->ucr2 = readl(sport->port.membase + offset);
return sport->ucr2;
-   break;
case UCR3:
return sport->ucr3;
-   break;
case UCR4:
return sport->ucr4;
-   break;
case UFCR:
return sport->ufcr;
-   break;
default:
return readl(sport->port.membase + offset);
}
-- 
2.29.0



[PATCH 2/2] drivers/tty: delete break after goto/return

2020-11-06 Thread Bernard Zhao
Delete break after goto/return, which will never run.

Signed-off-by: Bernard Zhao 
---
 drivers/tty/nozomi.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c
index d42b854cb7df..946cc16827aa 100644
--- a/drivers/tty/nozomi.c
+++ b/drivers/tty/nozomi.c
@@ -414,11 +414,9 @@ static void read_mem32(u32 *buf, const void __iomem 
*mem_addr_start,
buf16 = (u16 *) buf;
*buf16 = __le16_to_cpu(readw(ptr));
goto out;
-   break;
case 4: /* 4 bytes */
*(buf) = __le32_to_cpu(readl(ptr));
goto out;
-   break;
}
 
while (i < size_bytes) {
@@ -460,7 +458,6 @@ static u32 write_mem32(void __iomem *mem_addr_start, const 
u32 *buf,
buf16 = (const u16 *)buf;
writew(__cpu_to_le16(*buf16), ptr);
return 2;
-   break;
case 1: /*
 * also needs to write 4 bytes in this case
 * so falling through..
@@ -468,7 +465,6 @@ static u32 write_mem32(void __iomem *mem_addr_start, const 
u32 *buf,
case 4: /* 4 bytes */
writel(__cpu_to_le32(*buf), ptr);
return 4;
-   break;
}
 
while (i < size_bytes) {
-- 
2.29.0



Re:Re: [PATCH 0/2] drivers/tty: delete break after return or goto

2020-11-04 Thread Bernard


From: Greg Kroah-Hartman 
Date: 2020-11-04 19:02:53
To:  Bernard Zhao 
Cc:  Jiri Slaby ,Shawn Guo ,Sascha 
Hauer ,Pengutronix Kernel Team 
,Fabio Estevam ,NXP Linux Team 
,linux-kernel@vger.kernel.org,linux-ser...@vger.kernel.org,linux-arm-ker...@lists.infradead.org,opensource.ker...@vivo.com
Subject: Re: [PATCH 0/2] drivers/tty: delete break after return or goto>On Wed, 
Nov 04, 2020 at 02:53:29AM -0800, Bernard Zhao wrote:
>> This patch sereies optimise code like:
>> {
>> case XXX:
>>  return XXX;
>>  break; //The break is meanless, so just delete it.
>> case YYY:
>>  goto YYY;
>>  break; //The break is meanless, so just delete it.
>> ..
>> }
>> 
>> Signed-off-by: Bernard Zhao 
>> 
>> ---
>> Bernard Zhao (2):
>>   drivers/tty/nozomi.c: delete no use break after goto
>>   drivers/tty/serial/imx.c: delete no use break after return
>
>That is not the subject of the patches you sent out, what broke?

Hi:

I am sorry that I am a little confused:
The patch series`s subject is "drivers/tty: delete break after return or goto"
and the blurb is:
This patch sereies optimise code like:
{
case XXX:
return XXX;
break; //The break is meanless, so just delete it.
case YYY:
    goto YYY;
break; //The break is meanless, so just delete it.
..
}
last, the modified files are:
Bernard Zhao (2):
  drivers/tty/nozomi.c: delete no use break after goto
  drivers/tty/serial/imx.c: delete no use break after return

Is there something wrong that I didn`t catch?

BR//Bernard




[PATCH 2/2] drivers/tty: delete break after return

2020-11-04 Thread Bernard Zhao
Delete break after return, which will never run.

Signed-off-by: Bernard Zhao 
---
 drivers/tty/serial/imx.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 1731d9728865..09703079db7b 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -320,7 +320,6 @@ static u32 imx_uart_readl(struct imx_port *sport, u32 
offset)
switch (offset) {
case UCR1:
return sport->ucr1;
-   break;
case UCR2:
/*
 * UCR2_SRST is the only bit in the cached registers that might
@@ -331,16 +330,12 @@ static u32 imx_uart_readl(struct imx_port *sport, u32 
offset)
if (!(sport->ucr2 & UCR2_SRST))
sport->ucr2 = readl(sport->port.membase + offset);
return sport->ucr2;
-   break;
case UCR3:
return sport->ucr3;
-   break;
case UCR4:
return sport->ucr4;
-   break;
case UFCR:
return sport->ufcr;
-   break;
default:
return readl(sport->port.membase + offset);
}
-- 
2.29.0



[PATCH 1/2] drivers/tty: delete break after goto

2020-11-04 Thread Bernard Zhao
Delete break after goto, which will never run.

Signed-off-by: Bernard Zhao 
---
 drivers/tty/nozomi.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c
index d42b854cb7df..946cc16827aa 100644
--- a/drivers/tty/nozomi.c
+++ b/drivers/tty/nozomi.c
@@ -414,11 +414,9 @@ static void read_mem32(u32 *buf, const void __iomem 
*mem_addr_start,
buf16 = (u16 *) buf;
*buf16 = __le16_to_cpu(readw(ptr));
goto out;
-   break;
case 4: /* 4 bytes */
*(buf) = __le32_to_cpu(readl(ptr));
goto out;
-   break;
}
 
while (i < size_bytes) {
@@ -460,7 +458,6 @@ static u32 write_mem32(void __iomem *mem_addr_start, const 
u32 *buf,
buf16 = (const u16 *)buf;
writew(__cpu_to_le16(*buf16), ptr);
return 2;
-   break;
case 1: /*
 * also needs to write 4 bytes in this case
 * so falling through..
@@ -468,7 +465,6 @@ static u32 write_mem32(void __iomem *mem_addr_start, const 
u32 *buf,
case 4: /* 4 bytes */
writel(__cpu_to_le32(*buf), ptr);
return 4;
-   break;
}
 
while (i < size_bytes) {
-- 
2.29.0



[PATCH 0/2] drivers/tty: delete break after return or goto

2020-11-04 Thread Bernard Zhao
This patch sereies optimise code like:
{
case XXX:
return XXX;
break; //The break is meanless, so just delete it.
case YYY:
goto YYY;
break; //The break is meanless, so just delete it.
..
}

Signed-off-by: Bernard Zhao 

---
Bernard Zhao (2):
  drivers/tty/nozomi.c: delete no use break after goto
  drivers/tty/serial/imx.c: delete no use break after return

 drivers/tty/nozomi.c | 4 
 drivers/tty/serial/imx.c | 5 -
 2 files changed, 9 deletions(-)

-- 
2.29.0



[PATCH 0/2] drivers/tty: delete break after return

2020-11-03 Thread Bernard Zhao
This patch sereies delete break after return, which will never run.

Signed-off-by: Bernard Zhao 
*** BLURB HERE ***

Bernard Zhao (2):
  drivers/tty: delete break after return
  drivers/tty: delete break after return

 drivers/tty/nozomi.c | 4 
 drivers/tty/serial/imx.c | 5 -
 2 files changed, 9 deletions(-)

-- 
2.29.0



[PATCH 2/2] drivers/tty: delete break after return

2020-11-03 Thread Bernard Zhao
Delete break after return, which will never run.

Signed-off-by: Bernard Zhao 
---
 drivers/tty/serial/imx.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 1731d9728865..09703079db7b 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -320,7 +320,6 @@ static u32 imx_uart_readl(struct imx_port *sport, u32 
offset)
switch (offset) {
case UCR1:
return sport->ucr1;
-   break;
case UCR2:
/*
 * UCR2_SRST is the only bit in the cached registers that might
@@ -331,16 +330,12 @@ static u32 imx_uart_readl(struct imx_port *sport, u32 
offset)
if (!(sport->ucr2 & UCR2_SRST))
sport->ucr2 = readl(sport->port.membase + offset);
return sport->ucr2;
-   break;
case UCR3:
return sport->ucr3;
-   break;
case UCR4:
return sport->ucr4;
-   break;
case UFCR:
return sport->ufcr;
-   break;
default:
return readl(sport->port.membase + offset);
}
-- 
2.29.0



[PATCH 1/2] drivers/tty: delete break after return

2020-11-03 Thread Bernard Zhao
Delete break after return, which will never run.

Signed-off-by: Bernard Zhao 
---
 drivers/tty/nozomi.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c
index d42b854cb7df..946cc16827aa 100644
--- a/drivers/tty/nozomi.c
+++ b/drivers/tty/nozomi.c
@@ -414,11 +414,9 @@ static void read_mem32(u32 *buf, const void __iomem 
*mem_addr_start,
buf16 = (u16 *) buf;
*buf16 = __le16_to_cpu(readw(ptr));
goto out;
-   break;
case 4: /* 4 bytes */
*(buf) = __le32_to_cpu(readl(ptr));
goto out;
-   break;
}
 
while (i < size_bytes) {
@@ -460,7 +458,6 @@ static u32 write_mem32(void __iomem *mem_addr_start, const 
u32 *buf,
buf16 = (const u16 *)buf;
writew(__cpu_to_le16(*buf16), ptr);
return 2;
-   break;
case 1: /*
 * also needs to write 4 bytes in this case
 * so falling through..
@@ -468,7 +465,6 @@ static u32 write_mem32(void __iomem *mem_addr_start, const 
u32 *buf,
case 4: /* 4 bytes */
writel(__cpu_to_le32(*buf), ptr);
return 4;
-   break;
}
 
while (i < size_bytes) {
-- 
2.29.0



[PATCH 1/2] drivers/tty: delete break after return

2020-11-03 Thread Bernard Zhao
Delete break after return, which will never run.

Signed-off-by: Bernard Zhao 
---
 drivers/tty/nozomi.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c
index d42b854cb7df..946cc16827aa 100644
--- a/drivers/tty/nozomi.c
+++ b/drivers/tty/nozomi.c
@@ -414,11 +414,9 @@ static void read_mem32(u32 *buf, const void __iomem 
*mem_addr_start,
buf16 = (u16 *) buf;
*buf16 = __le16_to_cpu(readw(ptr));
goto out;
-   break;
case 4: /* 4 bytes */
*(buf) = __le32_to_cpu(readl(ptr));
goto out;
-   break;
}
 
while (i < size_bytes) {
@@ -460,7 +458,6 @@ static u32 write_mem32(void __iomem *mem_addr_start, const 
u32 *buf,
buf16 = (const u16 *)buf;
writew(__cpu_to_le16(*buf16), ptr);
return 2;
-   break;
case 1: /*
 * also needs to write 4 bytes in this case
 * so falling through..
@@ -468,7 +465,6 @@ static u32 write_mem32(void __iomem *mem_addr_start, const 
u32 *buf,
case 4: /* 4 bytes */
writel(__cpu_to_le32(*buf), ptr);
return 4;
-   break;
}
 
while (i < size_bytes) {
-- 
2.29.0



[PATCH 0/2] drivers/tty: delete break after return

2020-11-03 Thread Bernard Zhao
This patch sereies delete break after return, which will never run.

Signed-off-by: Bernard Zhao 
*** BLURB HERE ***

Bernard Zhao (2):
  drivers/tty: delete break after return
  drivers/tty: delete break after return

 drivers/tty/nozomi.c | 4 
 drivers/tty/serial/imx.c | 5 -
 2 files changed, 9 deletions(-)

-- 
2.29.0



[PATCH 2/2] drivers/tty: delete break after return

2020-11-03 Thread Bernard Zhao
Delete break after return, which will never run.

Signed-off-by: Bernard Zhao 
---
 drivers/tty/serial/imx.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 1731d9728865..09703079db7b 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -320,7 +320,6 @@ static u32 imx_uart_readl(struct imx_port *sport, u32 
offset)
switch (offset) {
case UCR1:
return sport->ucr1;
-   break;
case UCR2:
/*
 * UCR2_SRST is the only bit in the cached registers that might
@@ -331,16 +330,12 @@ static u32 imx_uart_readl(struct imx_port *sport, u32 
offset)
if (!(sport->ucr2 & UCR2_SRST))
sport->ucr2 = readl(sport->port.membase + offset);
return sport->ucr2;
-   break;
case UCR3:
return sport->ucr3;
-   break;
case UCR4:
return sport->ucr4;
-   break;
case UFCR:
return sport->ufcr;
-   break;
default:
return readl(sport->port.membase + offset);
}
-- 
2.29.0



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-de...@lists.freedesktop.org,linux-kernel@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




[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



[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



[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



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

2020-11-01 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



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

2020-11-01 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



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

2020-11-01 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



[PATCH] drivers/thermal: cleanup coding style a bit

2020-11-01 Thread Bernard Zhao
Function thermal_add_hwmon_sysfs, hwmon will be NULL when
new_hwmon_device = 0, so there is no need to check, kfree will
handle NULL point.

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

diff --git a/drivers/thermal/thermal_hwmon.c b/drivers/thermal/thermal_hwmon.c
index 8b92e00ff236..ad03262cca56 100644
--- a/drivers/thermal/thermal_hwmon.c
+++ b/drivers/thermal/thermal_hwmon.c
@@ -206,8 +206,7 @@ int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
if (new_hwmon_device)
hwmon_device_unregister(hwmon->device);
  free_mem:
-   if (new_hwmon_device)
-   kfree(hwmon);
+   kfree(hwmon);
 
return result;
 }
-- 
2.29.0



[PATCH] drivers/thermal: fix potential memleak in error branch

2020-11-01 Thread Bernard Zhao
Function __thermal_cooling_device_register, when device_register
failed, cdev is not free after error value return, this may
bring in potential memleak.

Signed-off-by: Bernard Zhao 
---
 drivers/thermal/thermal_core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 3d1e0033bf3e..e4bee15dfa1f 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1125,6 +1125,7 @@ __thermal_cooling_device_register(struct device_node *np,
if (result) {
ida_simple_remove(_cdev_ida, cdev->id);
put_device(>device);
+   kfree(cdev);
return ERR_PTR(result);
}
 
-- 
2.29.0



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

2020-10-27 Thread Bernard

From: Sam Ravnborg 
Date: 2020-10-25 01:14:57
To:  Bernard 
Cc:  Thomas Zimmermann ,opensource.ker...@vivo.com,David 
Airlie 
,linux-kernel@vger.kernel.org,dri-de...@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-de...@lists.freedesktop.org,linux-kernel@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




[PATCH v2] drivers/thermal: optimize the for circle to run a bit fast

2020-10-26 Thread Bernard Zhao
Function thermal_zone_device_register, in the for circle, if the
first if branch set the count bit in tz->trips_disabled, there is
no need to set in the other if branch again.
This change is to make the code run a bit fast and readable.

Signed-off-by: Bernard Zhao 

Changes since V1:
*make the code more clear and readable

Link for V1:
*https://lore.kernel.org/patchwork/patch/1324507/
---
 drivers/thermal/thermal_core.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index c6d74bc1c90b..3d1e0033bf3e 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1446,12 +1446,9 @@ thermal_zone_device_register(const char *type, int 
trips, int mask,
goto release_device;
 
for (count = 0; count < trips; count++) {
-   if (tz->ops->get_trip_type(tz, count, _type))
-   set_bit(count, >trips_disabled);
-   if (tz->ops->get_trip_temp(tz, count, _temp))
-   set_bit(count, >trips_disabled);
-   /* Check for bogus trip points */
-   if (trip_temp == 0)
+   if (tz->ops->get_trip_type(tz, count, _type) ||
+   tz->ops->get_trip_temp(tz, count, _temp) ||
+   !trip_temp)
set_bit(count, >trips_disabled);
}
 
-- 
2.28.0



Re:Re: [Resend][PATCH] drivers/thermal: optimize the for circle to run a bit fast

2020-10-26 Thread Bernard

From: Daniel Lezcano 
Date: 2020-10-27 02:35:18
To:  Bernard ,Zhang Rui ,Amit Kucheria 
,linux...@vger.kernel.org,linux-kernel@vger.kernel.org
Cc:  opensource.ker...@vivo.com
Subject: Re: [Resend][PATCH] drivers/thermal: optimize the for circle to run a 
bit fast>On 26/10/2020 02:49, Bernard wrote:
>> Function thermal_zone_device_register, in the for circle, if the
>> first if branch set the count bit in tz->trips_disabled, there is
>> no need to set in the other if branch again.
>> This change is to make the code run a bit fast and readable.
>> 
>> Signed-off-by: Bernard Zhao 
>> ---
>>  drivers/thermal/thermal_core.c | 8 ++--
>>  1 file changed, 6 insertions(+), 2 deletions(-)
>> 
>> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
>> index c6d74bc1c90b..03577794eea3 100644
>> --- a/drivers/thermal/thermal_core.c
>> +++ b/drivers/thermal/thermal_core.c
>> @@ -1446,10 +1446,14 @@ thermal_zone_device_register(const char *type, int 
>> trips, int mask,
>>  goto release_device;
>>  
>>  for (count = 0; count < trips; count++) {
>> -if (tz->ops->get_trip_type(tz, count, _type))
>> +if (tz->ops->get_trip_type(tz, count, _type)) {
>>  set_bit(count, >trips_disabled);
>> -if (tz->ops->get_trip_temp(tz, count, _temp))
>> +continue;
>> +}
>> +if (tz->ops->get_trip_temp(tz, count, _temp)) {
>>  set_bit(count, >trips_disabled);
>> +continue;
>> +}
>>  /* Check for bogus trip points */
>>  if (trip_temp == 0)
>>  set_bit(count, >trips_disabled);
>
>
>What about ?
>   if (tz->ops->get_trip_type(tz, count, _type) ||
>   tz->ops->get_trip_temp(tz, count, _temp) ||
>   !trip_temp)
>   set_bit(count, >trips_disabled);
>

Hi

  Sure, I will resubmit this patch, thanks!

BR//Bernard

>
>
>-- 
><http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
>
>Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
><http://twitter.com/#!/linaroorg> Twitter |
><http://www.linaro.org/linaro-blog/> Blog




[Resend][PATCH] drivers/thermal: remove unnecessary structure members allocated_tzp

2020-10-25 Thread Bernard
Struct power_allocator_params element allocated_tzp is only used
in unbind to kfree the kzalloc space.
Maybe we don’t have to need this member to mark, also, kfree will
handle NULL point, there is no risk.
This change is to make the code run a bit fast.

Signed-off-by: Bernard Zhao 
---
 drivers/thermal/gov_power_allocator.c | 11 ++-
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/thermal/gov_power_allocator.c 
b/drivers/thermal/gov_power_allocator.c
index 5cb518d8f156..e4672a94e6b1 100644
--- a/drivers/thermal/gov_power_allocator.c
+++ b/drivers/thermal/gov_power_allocator.c
@@ -51,8 +51,6 @@ static inline s64 div_frac(s64 x, s64 y)
 
 /**
  * struct power_allocator_params - parameters for the power allocator governor
- * @allocated_tzp: whether we have allocated tzp for this thermal zone and
- * it needs to be freed on unbind
  * @err_integral:  accumulated error in the PID controller.
  * @prev_err:  error in the previous iteration of the PID controller.
  * Used to calculate the derivative term.
@@ -65,7 +63,6 @@ static inline s64 div_frac(s64 x, s64 y)
  * controlling for.
  */
 struct power_allocator_params {
-   bool allocated_tzp;
s64 err_integral;
s32 prev_err;
int trip_switch_on;
@@ -556,8 +553,6 @@ static int power_allocator_bind(struct thermal_zone_device 
*tz)
ret = -ENOMEM;
goto free_params;
}
-
-   params->allocated_tzp = true;
}
 
if (!tz->tzp->sustainable_power)
@@ -593,10 +588,8 @@ static void power_allocator_unbind(struct 
thermal_zone_device *tz)
 
dev_dbg(>device, "Unbinding from thermal zone %d\n", tz->id);
 
-   if (params->allocated_tzp) {
-   kfree(tz->tzp);
-   tz->tzp = NULL;
-   }
+   kfree(tz->tzp);
+   tz->tzp = NULL;
 
kfree(tz->governor_data);
tz->governor_data = NULL;
-- 
2.28.0





[Resend][PATCH] drivers/thermal: optimize the for circle to run a bit fast

2020-10-25 Thread Bernard
Function thermal_zone_device_register, in the for circle, if the
first if branch set the count bit in tz->trips_disabled, there is
no need to set in the other if branch again.
This change is to make the code run a bit fast and readable.

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

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index c6d74bc1c90b..03577794eea3 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1446,10 +1446,14 @@ thermal_zone_device_register(const char *type, int 
trips, int mask,
goto release_device;
 
for (count = 0; count < trips; count++) {
-   if (tz->ops->get_trip_type(tz, count, _type))
+   if (tz->ops->get_trip_type(tz, count, _type)) {
set_bit(count, >trips_disabled);
-   if (tz->ops->get_trip_temp(tz, count, _temp))
+   continue;
+   }
+   if (tz->ops->get_trip_temp(tz, count, _temp)) {
set_bit(count, >trips_disabled);
+   continue;
+   }
/* Check for bogus trip points */
if (trip_temp == 0)
set_bit(count, >trips_disabled);
-- 
2.28.0





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

2020-10-23 Thread Bernard


From: Thomas Zimmermann 
Date: 2020-10-23 15:13:30
To:  Bernard Zhao ,Dave Airlie ,David 
Airlie ,Daniel Vetter 
,dri-de...@lists.freedesktop.org,linux-kernel@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




[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



[PATCH] drivers/thermal: optimize the for circle to run a bit fast

2020-10-19 Thread Bernard Zhao
Function thermal_zone_device_register, in the for circle, if the
first if branch set the count bit in tz->trips_disabled, there is
no need to set in the other if branch again.
This change is to make the code run a bit fast and readable.

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

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index c6d74bc1c90b..03577794eea3 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1446,10 +1446,14 @@ thermal_zone_device_register(const char *type, int 
trips, int mask,
goto release_device;
 
for (count = 0; count < trips; count++) {
-   if (tz->ops->get_trip_type(tz, count, _type))
+   if (tz->ops->get_trip_type(tz, count, _type)) {
set_bit(count, >trips_disabled);
-   if (tz->ops->get_trip_temp(tz, count, _temp))
+   continue;
+   }
+   if (tz->ops->get_trip_temp(tz, count, _temp)) {
set_bit(count, >trips_disabled);
+   continue;
+   }
/* Check for bogus trip points */
if (trip_temp == 0)
set_bit(count, >trips_disabled);
-- 
2.28.0



[PATCH] drivers/thermal: remove unnecessary structure members allocated_tzp

2020-10-17 Thread Bernard Zhao
Struct power_allocator_params element allocated_tzp is only used
in unbind to kfree the kzalloc space.
Maybe we don’t have to need this member to mark, also, kfree will
handle NULL point, there is no risk.
This change is to make the code run a bit fast.

Signed-off-by: Bernard Zhao 
---
 drivers/thermal/gov_power_allocator.c | 11 ++-
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/thermal/gov_power_allocator.c 
b/drivers/thermal/gov_power_allocator.c
index 5cb518d8f156..e4672a94e6b1 100644
--- a/drivers/thermal/gov_power_allocator.c
+++ b/drivers/thermal/gov_power_allocator.c
@@ -51,8 +51,6 @@ static inline s64 div_frac(s64 x, s64 y)
 
 /**
  * struct power_allocator_params - parameters for the power allocator governor
- * @allocated_tzp: whether we have allocated tzp for this thermal zone and
- * it needs to be freed on unbind
  * @err_integral:  accumulated error in the PID controller.
  * @prev_err:  error in the previous iteration of the PID controller.
  * Used to calculate the derivative term.
@@ -65,7 +63,6 @@ static inline s64 div_frac(s64 x, s64 y)
  * controlling for.
  */
 struct power_allocator_params {
-   bool allocated_tzp;
s64 err_integral;
s32 prev_err;
int trip_switch_on;
@@ -556,8 +553,6 @@ static int power_allocator_bind(struct thermal_zone_device 
*tz)
ret = -ENOMEM;
goto free_params;
}
-
-   params->allocated_tzp = true;
}
 
if (!tz->tzp->sustainable_power)
@@ -593,10 +588,8 @@ static void power_allocator_unbind(struct 
thermal_zone_device *tz)
 
dev_dbg(>device, "Unbinding from thermal zone %d\n", tz->id);
 
-   if (params->allocated_tzp) {
-   kfree(tz->tzp);
-   tz->tzp = NULL;
-   }
+   kfree(tz->tzp);
+   tz->tzp = NULL;
 
kfree(tz->governor_data);
tz->governor_data = NULL;
-- 
2.28.0



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

2020-10-14 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



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

2020-10-13 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



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

2020-10-12 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



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

2020-10-12 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



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

2020-10-12 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



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

2020-10-10 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-kernel@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-de...@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/msm/disp: add error value record in for circle`s error index

2020-10-09 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



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

2020-10-09 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



[PATCH] drm/amd:fix typoes in comments

2020-09-22 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] drm/radeon:fix typoes in comments

2020-09-22 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



[PATCH] mtd/map: fix typoes for struct memcard

2020-09-22 Thread Bernard Zhao
Change struct memcard`s element "removeable" -> "removable".

Signed-off-by: Bernard Zhao 
---
 drivers/mtd/maps/vmu-flash.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/maps/vmu-flash.c b/drivers/mtd/maps/vmu-flash.c
index 177bf134e189..d48ecbdb007a 100644
--- a/drivers/mtd/maps/vmu-flash.c
+++ b/drivers/mtd/maps/vmu-flash.c
@@ -40,7 +40,7 @@ struct memcard {
u32 blocklen;
u32 writecnt;
u32 readcnt;
-   u32 removeable;
+   u32 removable;
int partition;
int read;
unsigned char *blockread;
@@ -619,7 +619,7 @@ static int vmu_connect(struct maple_device *mdev)
card->blocklen = ((basic_flash_data >> 16 & 0xFF) + 1) << 5;
card->writecnt = basic_flash_data >> 12 & 0xF;
card->readcnt = basic_flash_data >> 8 & 0xF;
-   card->removeable = basic_flash_data >> 7 & 1;
+   card->removable = basic_flash_data >> 7 & 1;
 
card->partition = 0;
 
-- 
2.28.0



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

2020-09-21 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



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

2020-09-21 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




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

2020-09-21 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



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

2020-09-21 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





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

2020-09-09 Thread Bernard Zhao
In fnction is_cr_done & is_ch_eq_done, when done = false
happened once, no need to circle left ln_count.
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_dp.c | 14 +-
 1 file changed, 5 insertions(+), 9 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 b2be6ad5101d..53e30be8b66a 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
@@ -373,34 +373,30 @@ static void dpcd_set_lt_pattern_and_lane_settings(
 static bool is_cr_done(enum dc_lane_count ln_count,
union lane_status *dpcd_lane_status)
 {
-   bool done = true;
uint32_t lane;
/*LANEx_CR_DONE bits All 1's?*/
for (lane = 0; lane < (uint32_t)(ln_count); lane++) {
if (!dpcd_lane_status[lane].bits.CR_DONE_0)
-   done = false;
+   return false;
}
-   return done;
-
+   return true;
 }
 
 static bool is_ch_eq_done(enum dc_lane_count ln_count,
union lane_status *dpcd_lane_status,
union lane_align_status_updated *lane_status_updated)
 {
-   bool done = true;
uint32_t lane;
if (!lane_status_updated->bits.INTERLANE_ALIGN_DONE)
-   done = false;
+   return false;
else {
for (lane = 0; lane < (uint32_t)(ln_count); lane++) {
if (!dpcd_lane_status[lane].bits.SYMBOL_LOCKED_0 ||
!dpcd_lane_status[lane].bits.CHANNEL_EQ_DONE_0)
-   done = false;
+   return false;
}
}
-   return done;
-
+   return true;
 }
 
 static void update_drive_settings(
-- 
2.28.0



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

2020-09-07 Thread Bernard Zhao
Remove first assignment to info which is meaningless.
Put the width and higth check first.
This change is to make the code a bit readable.

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

diff --git a/drivers/gpu/drm/drm_framebuffer.c 
b/drivers/gpu/drm/drm_framebuffer.c
index df656366a530..2f5b0c2bb0fe 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -176,8 +176,7 @@ static int framebuffer_check(struct drm_device *dev,
int i;
 
/* check if the format is supported at all */
-   info = __drm_format_info(r->pixel_format);
-   if (!info) {
+   if (!__drm_format_info(r->pixel_format)) {
struct drm_format_name_buf format_name;
 
DRM_DEBUG_KMS("bad framebuffer format %s\n",
@@ -186,9 +185,6 @@ static int framebuffer_check(struct drm_device *dev,
return -EINVAL;
}
 
-   /* now let the driver pick its own format info */
-   info = drm_get_format_info(dev, r);
-
if (r->width == 0) {
DRM_DEBUG_KMS("bad framebuffer width %u\n", r->width);
return -EINVAL;
@@ -199,6 +195,9 @@ static int framebuffer_check(struct drm_device *dev,
return -EINVAL;
}
 
+   /* now let the driver pick its own format info */
+   info = drm_get_format_info(dev, r);
+
for (i = 0; i < info->num_planes; i++) {
unsigned int width = fb_plane_width(r->width, info, i);
unsigned int height = fb_plane_height(r->height, info, i);
-- 
2.28.0



[Re-send][PATCH] gpu/drm: remove drm_modeset_lock protection for drm_error

2020-09-02 Thread Bernard
In function drm_atomic_helper_shutdown, maybe there is no need
to protect DRM_ERROR log in DRM_MODESET_LOCK_ALL_BEGIN &
DRM_MODESET_LOCK_ALL_END. This change is to make code run a bit
fast.

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

diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
b/drivers/gpu/drm/drm_atomic_helper.c
index 85d163f16801..8902fd6316fc 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -3100,12 +3100,10 @@ void drm_atomic_helper_shutdown(struct drm_device *dev)
int ret;
 
DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx, 0, ret);
-
ret = drm_atomic_helper_disable_all(dev, );
+   DRM_MODESET_LOCK_ALL_END(ctx, ret);
if (ret)
DRM_ERROR("Disabling all crtc's during unload failed with 
%i\n", ret);
-
-   DRM_MODESET_LOCK_ALL_END(ctx, ret);
 }
 EXPORT_SYMBOL(drm_atomic_helper_shutdown);
 
-- 
2.17.1





[re-send][PATCH] drm/via: reduce no need mutex_lock area

2020-09-02 Thread Bernard
In function via_mem_alloc`s error branch, DRM_ERROR is protected
in the mutex_lock(>struct_mutex) area.
From the code, we see that DRM_ERROR is just an error log print
without any struct element, there is no need to protect this.

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

diff --git a/drivers/gpu/drm/via/via_mm.c b/drivers/gpu/drm/via/via_mm.c
index 45cc9e900260..dae1bacd86c1 100644
--- a/drivers/gpu/drm/via/via_mm.c
+++ b/drivers/gpu/drm/via/via_mm.c
@@ -129,9 +129,9 @@ int via_mem_alloc(struct drm_device *dev, void *data,
mutex_lock(>struct_mutex);
if (0 == ((mem->type == VIA_MEM_VIDEO) ? dev_priv->vram_initialized :
  dev_priv->agp_initialized)) {
+   mutex_unlock(>struct_mutex);
DRM_ERROR
("Attempt to allocate from uninitialized memory 
manager.\n");
-   mutex_unlock(>struct_mutex);
return -EINVAL;
}
 
-- 
2.26.2





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

2020-08-28 Thread Bernard Zhao
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



[PATCH] drm/via: reduce no need mutex_lock area

2020-08-14 Thread Bernard Zhao
In function via_mem_alloc`s error branch, DRM_ERROR is protected
in the mutex_lock(>struct_mutex) area.
>From the code, we see that DRM_ERROR is just an error log print
without any struct element, there is no need to protect this.

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

diff --git a/drivers/gpu/drm/via/via_mm.c b/drivers/gpu/drm/via/via_mm.c
index 45cc9e900260..dae1bacd86c1 100644
--- a/drivers/gpu/drm/via/via_mm.c
+++ b/drivers/gpu/drm/via/via_mm.c
@@ -129,9 +129,9 @@ int via_mem_alloc(struct drm_device *dev, void *data,
mutex_lock(>struct_mutex);
if (0 == ((mem->type == VIA_MEM_VIDEO) ? dev_priv->vram_initialized :
  dev_priv->agp_initialized)) {
+   mutex_unlock(>struct_mutex);
DRM_ERROR
("Attempt to allocate from uninitialized memory 
manager.\n");
-   mutex_unlock(>struct_mutex);
return -EINVAL;
}
 
-- 
2.26.2



  1   2   3   >