2022-06-01 19:37:38

by Peng Fan (OSS)

[permalink] [raw]
Subject: [PATCH 2/8] interconnect: add device managed bulk API

From: Peng Fan <[email protected]>

Add device managed bulk API to simplify driver.

Signed-off-by: Peng Fan <[email protected]>
---
drivers/interconnect/bulk.c | 34 ++++++++++++++++++++++++++++++++++
include/linux/interconnect.h | 6 ++++++
2 files changed, 40 insertions(+)

diff --git a/drivers/interconnect/bulk.c b/drivers/interconnect/bulk.c
index 448cc536aa79..4918844bfe0d 100644
--- a/drivers/interconnect/bulk.c
+++ b/drivers/interconnect/bulk.c
@@ -115,3 +115,37 @@ void icc_bulk_disable(int num_paths, const struct icc_bulk_data *paths)
icc_disable(paths[num_paths].path);
}
EXPORT_SYMBOL_GPL(icc_bulk_disable);
+
+struct icc_bulk_devres {
+ struct icc_bulk_data *paths;
+ int num_paths;
+};
+
+static void devm_icc_bulk_release(struct device *dev, void *res)
+{
+ struct icc_bulk_devres *devres = res;
+
+ icc_bulk_put(devres->num_paths, devres->paths);
+}
+
+int devm_of_icc_bulk_get(struct device *dev, int num_paths, struct icc_bulk_data *paths)
+{
+ struct icc_bulk_devres *devres;
+ int ret;
+
+ devres = devres_alloc(devm_icc_bulk_release, sizeof(*devres), GFP_KERNEL);
+ if (!devres)
+ return -ENOMEM;
+
+ ret = of_icc_bulk_get(dev, num_paths, paths);
+ if (!ret) {
+ devres->paths = paths;
+ devres->num_paths = num_paths;
+ devres_add(dev, devres);
+ } else {
+ devres_free(devres);
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(devm_of_icc_bulk_get);
diff --git a/include/linux/interconnect.h b/include/linux/interconnect.h
index f685777b875e..1a5fdf049edd 100644
--- a/include/linux/interconnect.h
+++ b/include/linux/interconnect.h
@@ -44,6 +44,7 @@ struct icc_path *icc_get(struct device *dev, const int src_id,
const int dst_id);
struct icc_path *of_icc_get(struct device *dev, const char *name);
struct icc_path *devm_of_icc_get(struct device *dev, const char *name);
+int devm_of_icc_bulk_get(struct device *dev, int num_paths, struct icc_bulk_data *paths);
struct icc_path *of_icc_get_by_index(struct device *dev, int idx);
void icc_put(struct icc_path *path);
int icc_enable(struct icc_path *path);
@@ -116,6 +117,11 @@ static inline int of_icc_bulk_get(struct device *dev, int num_paths, struct icc_
return 0;
}

+int devm_of_icc_bulk_get(struct device *dev, int num_paths, struct icc_bulk_data *paths)
+{
+ return 0;
+}
+
static inline void icc_bulk_put(int num_paths, struct icc_bulk_data *paths)
{
}
--
2.25.1



2022-06-01 19:52:25

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 2/8] interconnect: add device managed bulk API

Hi "Peng,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on shawnguo/for-next]
[also build test WARNING on robh/for-next linus/master v5.18 next-20220601]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/intel-lab-lkp/linux/commits/Peng-Fan-OSS/interconnect-support-i-MX8MP/20220601-174431
base: https://git.kernel.org/pub/scm/linux/kernel/git/shawnguo/linux.git for-next
config: parisc-randconfig-r014-20220531 (https://download.01.org/0day-ci/archive/20220601/[email protected]/config)
compiler: hppa-linux-gcc (GCC) 11.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/23ecbba75b21962f25975cb014cf981a0420dae1
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Peng-Fan-OSS/interconnect-support-i-MX8MP/20220601-174431
git checkout 23ecbba75b21962f25975cb014cf981a0420dae1
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross W=1 O=build_dir ARCH=parisc SHELL=/bin/bash drivers/opp/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

In file included from drivers/opp/opp.h:15,
from drivers/opp/core.c:22:
>> include/linux/interconnect.h:120:5: warning: no previous prototype for 'devm_of_icc_bulk_get' [-Wmissing-prototypes]
120 | int devm_of_icc_bulk_get(struct device *dev, int num_paths, struct icc_bulk_data *paths)
| ^~~~~~~~~~~~~~~~~~~~


vim +/devm_of_icc_bulk_get +120 include/linux/interconnect.h

119
> 120 int devm_of_icc_bulk_get(struct device *dev, int num_paths, struct icc_bulk_data *paths)
121 {
122 return 0;
123 }
124

--
0-DAY CI Kernel Test Service
https://01.org/lkp

2022-06-01 21:18:04

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 2/8] interconnect: add device managed bulk API

Hi "Peng,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on shawnguo/for-next]
[also build test WARNING on robh/for-next linus/master v5.18 next-20220601]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/intel-lab-lkp/linux/commits/Peng-Fan-OSS/interconnect-support-i-MX8MP/20220601-174431
base: https://git.kernel.org/pub/scm/linux/kernel/git/shawnguo/linux.git for-next
config: hexagon-randconfig-r041-20220531 (https://download.01.org/0day-ci/archive/20220601/[email protected]/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project c825abd6b0198fb088d9752f556a70705bc99dfd)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/23ecbba75b21962f25975cb014cf981a0420dae1
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Peng-Fan-OSS/interconnect-support-i-MX8MP/20220601-174431
git checkout 23ecbba75b21962f25975cb014cf981a0420dae1
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/opp/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

In file included from drivers/opp/core.c:22:
In file included from drivers/opp/opp.h:15:
>> include/linux/interconnect.h:120:5: warning: no previous prototype for function 'devm_of_icc_bulk_get' [-Wmissing-prototypes]
int devm_of_icc_bulk_get(struct device *dev, int num_paths, struct icc_bulk_data *paths)
^
include/linux/interconnect.h:120:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
int devm_of_icc_bulk_get(struct device *dev, int num_paths, struct icc_bulk_data *paths)
^
static
1 warning generated.


vim +/devm_of_icc_bulk_get +120 include/linux/interconnect.h

119
> 120 int devm_of_icc_bulk_get(struct device *dev, int num_paths, struct icc_bulk_data *paths)
121 {
122 return 0;
123 }
124

--
0-DAY CI Kernel Test Service
https://01.org/lkp

2022-06-13 20:07:33

by Georgi Djakov

[permalink] [raw]
Subject: Re: [PATCH 2/8] interconnect: add device managed bulk API

Hi Peng,

Thanks for the patches!

On 1.06.22 12:41, Peng Fan (OSS) wrote:
> From: Peng Fan <[email protected]>
>
> Add device managed bulk API to simplify driver.
>
> Signed-off-by: Peng Fan <[email protected]>
> ---
> drivers/interconnect/bulk.c | 34 ++++++++++++++++++++++++++++++++++
> include/linux/interconnect.h | 6 ++++++
> 2 files changed, 40 insertions(+)
>
> diff --git a/drivers/interconnect/bulk.c b/drivers/interconnect/bulk.c
> index 448cc536aa79..4918844bfe0d 100644
> --- a/drivers/interconnect/bulk.c
> +++ b/drivers/interconnect/bulk.c
> @@ -115,3 +115,37 @@ void icc_bulk_disable(int num_paths, const struct icc_bulk_data *paths)
> icc_disable(paths[num_paths].path);
> }
> EXPORT_SYMBOL_GPL(icc_bulk_disable);
> +
> +struct icc_bulk_devres {
> + struct icc_bulk_data *paths;
> + int num_paths;
> +};
> +
> +static void devm_icc_bulk_release(struct device *dev, void *res)
> +{
> + struct icc_bulk_devres *devres = res;
> +
> + icc_bulk_put(devres->num_paths, devres->paths);
> +}
> +
> +int devm_of_icc_bulk_get(struct device *dev, int num_paths, struct icc_bulk_data *paths)

Adding a kerneldoc would be nice.

> +{
> + struct icc_bulk_devres *devres;
> + int ret;
> +
> + devres = devres_alloc(devm_icc_bulk_release, sizeof(*devres), GFP_KERNEL);
> + if (!devres)
> + return -ENOMEM;
> +
> + ret = of_icc_bulk_get(dev, num_paths, paths);
> + if (!ret) {
> + devres->paths = paths;
> + devres->num_paths = num_paths;
> + devres_add(dev, devres);
> + } else {
> + devres_free(devres);
> + }
> +
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(devm_of_icc_bulk_get);
> diff --git a/include/linux/interconnect.h b/include/linux/interconnect.h
> index f685777b875e..1a5fdf049edd 100644
> --- a/include/linux/interconnect.h
> +++ b/include/linux/interconnect.h
> @@ -44,6 +44,7 @@ struct icc_path *icc_get(struct device *dev, const int src_id,
> const int dst_id);
> struct icc_path *of_icc_get(struct device *dev, const char *name);
> struct icc_path *devm_of_icc_get(struct device *dev, const char *name);
> +int devm_of_icc_bulk_get(struct device *dev, int num_paths, struct icc_bulk_data *paths);
> struct icc_path *of_icc_get_by_index(struct device *dev, int idx);
> void icc_put(struct icc_path *path);
> int icc_enable(struct icc_path *path);
> @@ -116,6 +117,11 @@ static inline int of_icc_bulk_get(struct device *dev, int num_paths, struct icc_
> return 0;
> }
>
> +int devm_of_icc_bulk_get(struct device *dev, int num_paths, struct icc_bulk_data *paths)

Please make this static inline. The rest looks good!

Thanks,
Georgi

> +{
> + return 0;
> +}
> +
> static inline void icc_bulk_put(int num_paths, struct icc_bulk_data *paths)
> {
> }