All of lore.kernel.org
 help / color / mirror / Atom feed
From: Georgi Djakov <georgi.djakov@linaro.org>
To: Henry Chen <henryc.chen@mediatek.com>,
	Rob Herring <robh+dt@kernel.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Stephen Boyd <swboyd@chromium.org>,
	Ryan Case <ryandcase@chromium.org>,
	Mark Brown <broonie@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>,
	Nicolas Boichat <drinkcat@google.com>,
	Fan Chen <fan.chen@mediatek.com>,
	James Liao <jamesjj.liao@mediatek.com>,
	Arvin Wang <arvin.wang@mediatek.com>,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org,
	linux-pm@vger.kernel.org
Subject: Re: [PATCH V6 08/13] interconnect: mediatek: Add interconnect provider driver
Date: Mon, 4 Jan 2021 20:36:04 +0200	[thread overview]
Message-ID: <c8b951b0-6412-d905-99e1-6350283b57c1@linaro.org> (raw)
In-Reply-To: <1608790134-27425-9-git-send-email-henryc.chen@mediatek.com>

On 12/24/20 08:08, Henry Chen wrote:
> Introduce Mediatek MT6873/MT8183/MT8192 specific provider driver
> using the interconnect framework.
> 
>               ICC provider         ICC Nodes
>                                ----          ----
>               ---------       |CPU |   |--- |VPU |
>      -----   |         |-----  ----    |     ----
>     |DRAM |--|DRAM     |       ----    |     ----
>     |     |--|scheduler|----- |GPU |   |--- |DISP|
>     |     |--|(EMI)    |       ----    |     ----
>     |     |--|         |       -----   |     ----
>      -----   |         |----- |MMSYS|--|--- |VDEC|
>               ---------        -----   |     ----
>                 /|\                    |     ----
>                  |change DRAM freq     |--- |VENC|
>               ----------               |     ----
>              |  DVFSR   |              |
>              |          |              |     ----
>               ----------               |--- |IMG |
>                                        |     ----
>                                        |     ----
>                                        |--- |CAM |
>                                              ----
> 
> Signed-off-by: Henry Chen <henryc.chen@mediatek.com>
> ---
>   drivers/interconnect/Kconfig            |   1 +
>   drivers/interconnect/Makefile           |   1 +
>   drivers/interconnect/mediatek/Kconfig   |  13 ++
>   drivers/interconnect/mediatek/Makefile  |   3 +
>   drivers/interconnect/mediatek/mtk-emi.c | 330 ++++++++++++++++++++++++++++++++
>   5 files changed, 348 insertions(+)
>   create mode 100644 drivers/interconnect/mediatek/Kconfig
>   create mode 100644 drivers/interconnect/mediatek/Makefile
>   create mode 100644 drivers/interconnect/mediatek/mtk-emi.c
> 
> diff --git a/drivers/interconnect/Kconfig b/drivers/interconnect/Kconfig
> index 5b7204e..e939f5a 100644
> --- a/drivers/interconnect/Kconfig
> +++ b/drivers/interconnect/Kconfig
> @@ -13,5 +13,6 @@ if INTERCONNECT
>   
>   source "drivers/interconnect/imx/Kconfig"
>   source "drivers/interconnect/qcom/Kconfig"
> +source "drivers/interconnect/mediatek/Kconfig"

Sort alphabetically please.

>   
>   endif
> diff --git a/drivers/interconnect/Makefile b/drivers/interconnect/Makefile
> index d203520..0643a24 100644
> --- a/drivers/interconnect/Makefile
> +++ b/drivers/interconnect/Makefile
> @@ -6,3 +6,4 @@ icc-core-objs				:= core.o bulk.o
>   obj-$(CONFIG_INTERCONNECT)		+= icc-core.o
>   obj-$(CONFIG_INTERCONNECT_IMX)		+= imx/
>   obj-$(CONFIG_INTERCONNECT_QCOM)		+= qcom/
> +obj-$(CONFIG_INTERCONNECT_MTK)		+= mediatek/

Ditto.

> diff --git a/drivers/interconnect/mediatek/Kconfig b/drivers/interconnect/mediatek/Kconfig
> new file mode 100644
> index 0000000..972d3bb
> --- /dev/null
> +++ b/drivers/interconnect/mediatek/Kconfig
> @@ -0,0 +1,13 @@
> +config INTERCONNECT_MTK
> +	bool "Mediatek Network-on-Chip interconnect drivers"
> +	depends on ARCH_MEDIATEK
> +	help
> +	  Support for Mediatek's Network-on-Chip interconnect hardware.
> +
> +config INTERCONNECT_MTK_EMI
> +	tristate "Mediatek EMI interconnect driver"
> +	depends on INTERCONNECT_MTK
> +	depends on (MTK_DVFSRC && OF)

Would it be possible to enable COMPILE_TEST?

> +	help
> +	  This is a driver for the Mediatek Network-on-Chip on DVFSRC-based
> +	  platforms.
> diff --git a/drivers/interconnect/mediatek/Makefile b/drivers/interconnect/mediatek/Makefile
> new file mode 100644
> index 0000000..353842b
> --- /dev/null
> +++ b/drivers/interconnect/mediatek/Makefile
> @@ -0,0 +1,3 @@
> +# SPDX-License-Identifier: GPL-2.0
> +
> +obj-$(CONFIG_INTERCONNECT_MTK_EMI) += mtk-emi.o
> \ No newline at end of file
> diff --git a/drivers/interconnect/mediatek/mtk-emi.c b/drivers/interconnect/mediatek/mtk-emi.c
> new file mode 100644
> index 0000000..9670077
> --- /dev/null
> +++ b/drivers/interconnect/mediatek/mtk-emi.c
> @@ -0,0 +1,330 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2020, The Linux Foundation. All rights reserved.

Just a reminder that the year should be updated when you re-submit.

> + *
> + */
> +
> +#include <linux/device.h>
> +#include <linux/interconnect-provider.h>
> +#include <linux/module.h>
> +#include <linux/of_device.h>
> +#include <linux/platform_device.h>
> +#include <linux/soc/mediatek/mtk_dvfsrc.h>
> +#include <dt-bindings/interconnect/mtk,mt8183-emi.h>
> +#include <dt-bindings/interconnect/mtk,mt6873-emi.h>

Nit: Alphanumeric order please.

[..]
> +static int emi_icc_remove(struct platform_device *pdev);
> +static int emi_icc_probe(struct platform_device *pdev)
> +{
> +	const struct of_device_id *match;
> +	const struct mtk_icc_desc *desc;
> +	struct device *dev = &pdev->dev;
> +	struct icc_node *node;
> +	struct icc_onecell_data *data;
> +	struct icc_provider *provider;
> +	struct mtk_icc_node **mnodes;
> +	size_t num_nodes, i, j;
> +	int ret;
> +
> +	match = of_match_node(emi_icc_of_match, dev->parent->of_node);
> +
> +	if (!match) {
> +		dev_err(dev, "invalid compatible string\n");
> +		return -ENODEV;
> +	}
> +
> +	desc = match->data;
> +	mnodes = desc->nodes;
> +	num_nodes = desc->num_nodes;
> +
> +	provider = devm_kzalloc(dev, sizeof(*provider), GFP_KERNEL);
> +	if (!provider)
> +		return -ENOMEM;
> +
> +	data = devm_kzalloc(dev, struct_size(data, nodes, num_nodes),
> +			    GFP_KERNEL);
> +	if (!data)
> +		return -ENOMEM;
> +
> +	provider->dev = pdev->dev.parent;
> +	provider->set = emi_icc_set;
> +	provider->aggregate = emi_icc_aggregate;
> +	provider->xlate = of_icc_xlate_onecell;
> +	INIT_LIST_HEAD(&provider->nodes);
> +	provider->data = data;
> +
> +	ret = icc_provider_add(provider);
> +	if (ret) {
> +		dev_err(&pdev->dev, "error adding interconnect provider\n");
> +		return ret;
> +	}
> +
> +	for (i = 0; i < num_nodes; i++) {
> +		node = icc_node_create(mnodes[i]->id);
> +		if (IS_ERR(node)) {
> +			ret = PTR_ERR(node);
> +			goto err;
> +		}
> +
> +		node->name = mnodes[i]->name;
> +		node->data = mnodes[i];
> +		icc_node_add(node, provider);
> +
> +		for (j = 0; j < mnodes[i]->num_links; j++)
> +			icc_link_create(node, mnodes[i]->links[j]);
> +
> +		data->nodes[i] = node;
> +	}
> +	data->num_nodes = num_nodes;
> +
> +	platform_set_drvdata(pdev, provider);
> +
> +	return 0;
> +err:
> +	icc_nodes_remove(provider);

Also call icc_provider_del() to restore the original state on error.

Thanks,
Georgi

> +	return ret;
> +}
> +
> +static int emi_icc_remove(struct platform_device *pdev)
> +{
> +	struct icc_provider *provider = platform_get_drvdata(pdev);
> +
> +	icc_nodes_remove(provider);
> +	return icc_provider_del(provider);
> +}
> +

WARNING: multiple messages have this Message-ID (diff)
From: Georgi Djakov <georgi.djakov@linaro.org>
To: Henry Chen <henryc.chen@mediatek.com>,
	Rob Herring <robh+dt@kernel.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Stephen Boyd <swboyd@chromium.org>,
	Ryan Case <ryandcase@chromium.org>,
	Mark Brown <broonie@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>,
	Nicolas Boichat <drinkcat@google.com>,
	devicetree@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org, Fan Chen <fan.chen@mediatek.com>,
	linux-mediatek@lists.infradead.org,
	Arvin Wang <arvin.wang@mediatek.com>,
	James Liao <jamesjj.liao@mediatek.com>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH V6 08/13] interconnect: mediatek: Add interconnect provider driver
Date: Mon, 4 Jan 2021 20:36:04 +0200	[thread overview]
Message-ID: <c8b951b0-6412-d905-99e1-6350283b57c1@linaro.org> (raw)
In-Reply-To: <1608790134-27425-9-git-send-email-henryc.chen@mediatek.com>

On 12/24/20 08:08, Henry Chen wrote:
> Introduce Mediatek MT6873/MT8183/MT8192 specific provider driver
> using the interconnect framework.
> 
>               ICC provider         ICC Nodes
>                                ----          ----
>               ---------       |CPU |   |--- |VPU |
>      -----   |         |-----  ----    |     ----
>     |DRAM |--|DRAM     |       ----    |     ----
>     |     |--|scheduler|----- |GPU |   |--- |DISP|
>     |     |--|(EMI)    |       ----    |     ----
>     |     |--|         |       -----   |     ----
>      -----   |         |----- |MMSYS|--|--- |VDEC|
>               ---------        -----   |     ----
>                 /|\                    |     ----
>                  |change DRAM freq     |--- |VENC|
>               ----------               |     ----
>              |  DVFSR   |              |
>              |          |              |     ----
>               ----------               |--- |IMG |
>                                        |     ----
>                                        |     ----
>                                        |--- |CAM |
>                                              ----
> 
> Signed-off-by: Henry Chen <henryc.chen@mediatek.com>
> ---
>   drivers/interconnect/Kconfig            |   1 +
>   drivers/interconnect/Makefile           |   1 +
>   drivers/interconnect/mediatek/Kconfig   |  13 ++
>   drivers/interconnect/mediatek/Makefile  |   3 +
>   drivers/interconnect/mediatek/mtk-emi.c | 330 ++++++++++++++++++++++++++++++++
>   5 files changed, 348 insertions(+)
>   create mode 100644 drivers/interconnect/mediatek/Kconfig
>   create mode 100644 drivers/interconnect/mediatek/Makefile
>   create mode 100644 drivers/interconnect/mediatek/mtk-emi.c
> 
> diff --git a/drivers/interconnect/Kconfig b/drivers/interconnect/Kconfig
> index 5b7204e..e939f5a 100644
> --- a/drivers/interconnect/Kconfig
> +++ b/drivers/interconnect/Kconfig
> @@ -13,5 +13,6 @@ if INTERCONNECT
>   
>   source "drivers/interconnect/imx/Kconfig"
>   source "drivers/interconnect/qcom/Kconfig"
> +source "drivers/interconnect/mediatek/Kconfig"

Sort alphabetically please.

>   
>   endif
> diff --git a/drivers/interconnect/Makefile b/drivers/interconnect/Makefile
> index d203520..0643a24 100644
> --- a/drivers/interconnect/Makefile
> +++ b/drivers/interconnect/Makefile
> @@ -6,3 +6,4 @@ icc-core-objs				:= core.o bulk.o
>   obj-$(CONFIG_INTERCONNECT)		+= icc-core.o
>   obj-$(CONFIG_INTERCONNECT_IMX)		+= imx/
>   obj-$(CONFIG_INTERCONNECT_QCOM)		+= qcom/
> +obj-$(CONFIG_INTERCONNECT_MTK)		+= mediatek/

Ditto.

> diff --git a/drivers/interconnect/mediatek/Kconfig b/drivers/interconnect/mediatek/Kconfig
> new file mode 100644
> index 0000000..972d3bb
> --- /dev/null
> +++ b/drivers/interconnect/mediatek/Kconfig
> @@ -0,0 +1,13 @@
> +config INTERCONNECT_MTK
> +	bool "Mediatek Network-on-Chip interconnect drivers"
> +	depends on ARCH_MEDIATEK
> +	help
> +	  Support for Mediatek's Network-on-Chip interconnect hardware.
> +
> +config INTERCONNECT_MTK_EMI
> +	tristate "Mediatek EMI interconnect driver"
> +	depends on INTERCONNECT_MTK
> +	depends on (MTK_DVFSRC && OF)

Would it be possible to enable COMPILE_TEST?

> +	help
> +	  This is a driver for the Mediatek Network-on-Chip on DVFSRC-based
> +	  platforms.
> diff --git a/drivers/interconnect/mediatek/Makefile b/drivers/interconnect/mediatek/Makefile
> new file mode 100644
> index 0000000..353842b
> --- /dev/null
> +++ b/drivers/interconnect/mediatek/Makefile
> @@ -0,0 +1,3 @@
> +# SPDX-License-Identifier: GPL-2.0
> +
> +obj-$(CONFIG_INTERCONNECT_MTK_EMI) += mtk-emi.o
> \ No newline at end of file
> diff --git a/drivers/interconnect/mediatek/mtk-emi.c b/drivers/interconnect/mediatek/mtk-emi.c
> new file mode 100644
> index 0000000..9670077
> --- /dev/null
> +++ b/drivers/interconnect/mediatek/mtk-emi.c
> @@ -0,0 +1,330 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2020, The Linux Foundation. All rights reserved.

Just a reminder that the year should be updated when you re-submit.

> + *
> + */
> +
> +#include <linux/device.h>
> +#include <linux/interconnect-provider.h>
> +#include <linux/module.h>
> +#include <linux/of_device.h>
> +#include <linux/platform_device.h>
> +#include <linux/soc/mediatek/mtk_dvfsrc.h>
> +#include <dt-bindings/interconnect/mtk,mt8183-emi.h>
> +#include <dt-bindings/interconnect/mtk,mt6873-emi.h>

Nit: Alphanumeric order please.

[..]
> +static int emi_icc_remove(struct platform_device *pdev);
> +static int emi_icc_probe(struct platform_device *pdev)
> +{
> +	const struct of_device_id *match;
> +	const struct mtk_icc_desc *desc;
> +	struct device *dev = &pdev->dev;
> +	struct icc_node *node;
> +	struct icc_onecell_data *data;
> +	struct icc_provider *provider;
> +	struct mtk_icc_node **mnodes;
> +	size_t num_nodes, i, j;
> +	int ret;
> +
> +	match = of_match_node(emi_icc_of_match, dev->parent->of_node);
> +
> +	if (!match) {
> +		dev_err(dev, "invalid compatible string\n");
> +		return -ENODEV;
> +	}
> +
> +	desc = match->data;
> +	mnodes = desc->nodes;
> +	num_nodes = desc->num_nodes;
> +
> +	provider = devm_kzalloc(dev, sizeof(*provider), GFP_KERNEL);
> +	if (!provider)
> +		return -ENOMEM;
> +
> +	data = devm_kzalloc(dev, struct_size(data, nodes, num_nodes),
> +			    GFP_KERNEL);
> +	if (!data)
> +		return -ENOMEM;
> +
> +	provider->dev = pdev->dev.parent;
> +	provider->set = emi_icc_set;
> +	provider->aggregate = emi_icc_aggregate;
> +	provider->xlate = of_icc_xlate_onecell;
> +	INIT_LIST_HEAD(&provider->nodes);
> +	provider->data = data;
> +
> +	ret = icc_provider_add(provider);
> +	if (ret) {
> +		dev_err(&pdev->dev, "error adding interconnect provider\n");
> +		return ret;
> +	}
> +
> +	for (i = 0; i < num_nodes; i++) {
> +		node = icc_node_create(mnodes[i]->id);
> +		if (IS_ERR(node)) {
> +			ret = PTR_ERR(node);
> +			goto err;
> +		}
> +
> +		node->name = mnodes[i]->name;
> +		node->data = mnodes[i];
> +		icc_node_add(node, provider);
> +
> +		for (j = 0; j < mnodes[i]->num_links; j++)
> +			icc_link_create(node, mnodes[i]->links[j]);
> +
> +		data->nodes[i] = node;
> +	}
> +	data->num_nodes = num_nodes;
> +
> +	platform_set_drvdata(pdev, provider);
> +
> +	return 0;
> +err:
> +	icc_nodes_remove(provider);

Also call icc_provider_del() to restore the original state on error.

Thanks,
Georgi

> +	return ret;
> +}
> +
> +static int emi_icc_remove(struct platform_device *pdev)
> +{
> +	struct icc_provider *provider = platform_get_drvdata(pdev);
> +
> +	icc_nodes_remove(provider);
> +	return icc_provider_del(provider);
> +}
> +

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

WARNING: multiple messages have this Message-ID (diff)
From: Georgi Djakov <georgi.djakov@linaro.org>
To: Henry Chen <henryc.chen@mediatek.com>,
	Rob Herring <robh+dt@kernel.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Stephen Boyd <swboyd@chromium.org>,
	Ryan Case <ryandcase@chromium.org>,
	Mark Brown <broonie@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>,
	Nicolas Boichat <drinkcat@google.com>,
	devicetree@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org, Fan Chen <fan.chen@mediatek.com>,
	linux-mediatek@lists.infradead.org,
	Arvin Wang <arvin.wang@mediatek.com>,
	James Liao <jamesjj.liao@mediatek.com>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH V6 08/13] interconnect: mediatek: Add interconnect provider driver
Date: Mon, 4 Jan 2021 20:36:04 +0200	[thread overview]
Message-ID: <c8b951b0-6412-d905-99e1-6350283b57c1@linaro.org> (raw)
In-Reply-To: <1608790134-27425-9-git-send-email-henryc.chen@mediatek.com>

On 12/24/20 08:08, Henry Chen wrote:
> Introduce Mediatek MT6873/MT8183/MT8192 specific provider driver
> using the interconnect framework.
> 
>               ICC provider         ICC Nodes
>                                ----          ----
>               ---------       |CPU |   |--- |VPU |
>      -----   |         |-----  ----    |     ----
>     |DRAM |--|DRAM     |       ----    |     ----
>     |     |--|scheduler|----- |GPU |   |--- |DISP|
>     |     |--|(EMI)    |       ----    |     ----
>     |     |--|         |       -----   |     ----
>      -----   |         |----- |MMSYS|--|--- |VDEC|
>               ---------        -----   |     ----
>                 /|\                    |     ----
>                  |change DRAM freq     |--- |VENC|
>               ----------               |     ----
>              |  DVFSR   |              |
>              |          |              |     ----
>               ----------               |--- |IMG |
>                                        |     ----
>                                        |     ----
>                                        |--- |CAM |
>                                              ----
> 
> Signed-off-by: Henry Chen <henryc.chen@mediatek.com>
> ---
>   drivers/interconnect/Kconfig            |   1 +
>   drivers/interconnect/Makefile           |   1 +
>   drivers/interconnect/mediatek/Kconfig   |  13 ++
>   drivers/interconnect/mediatek/Makefile  |   3 +
>   drivers/interconnect/mediatek/mtk-emi.c | 330 ++++++++++++++++++++++++++++++++
>   5 files changed, 348 insertions(+)
>   create mode 100644 drivers/interconnect/mediatek/Kconfig
>   create mode 100644 drivers/interconnect/mediatek/Makefile
>   create mode 100644 drivers/interconnect/mediatek/mtk-emi.c
> 
> diff --git a/drivers/interconnect/Kconfig b/drivers/interconnect/Kconfig
> index 5b7204e..e939f5a 100644
> --- a/drivers/interconnect/Kconfig
> +++ b/drivers/interconnect/Kconfig
> @@ -13,5 +13,6 @@ if INTERCONNECT
>   
>   source "drivers/interconnect/imx/Kconfig"
>   source "drivers/interconnect/qcom/Kconfig"
> +source "drivers/interconnect/mediatek/Kconfig"

Sort alphabetically please.

>   
>   endif
> diff --git a/drivers/interconnect/Makefile b/drivers/interconnect/Makefile
> index d203520..0643a24 100644
> --- a/drivers/interconnect/Makefile
> +++ b/drivers/interconnect/Makefile
> @@ -6,3 +6,4 @@ icc-core-objs				:= core.o bulk.o
>   obj-$(CONFIG_INTERCONNECT)		+= icc-core.o
>   obj-$(CONFIG_INTERCONNECT_IMX)		+= imx/
>   obj-$(CONFIG_INTERCONNECT_QCOM)		+= qcom/
> +obj-$(CONFIG_INTERCONNECT_MTK)		+= mediatek/

Ditto.

> diff --git a/drivers/interconnect/mediatek/Kconfig b/drivers/interconnect/mediatek/Kconfig
> new file mode 100644
> index 0000000..972d3bb
> --- /dev/null
> +++ b/drivers/interconnect/mediatek/Kconfig
> @@ -0,0 +1,13 @@
> +config INTERCONNECT_MTK
> +	bool "Mediatek Network-on-Chip interconnect drivers"
> +	depends on ARCH_MEDIATEK
> +	help
> +	  Support for Mediatek's Network-on-Chip interconnect hardware.
> +
> +config INTERCONNECT_MTK_EMI
> +	tristate "Mediatek EMI interconnect driver"
> +	depends on INTERCONNECT_MTK
> +	depends on (MTK_DVFSRC && OF)

Would it be possible to enable COMPILE_TEST?

> +	help
> +	  This is a driver for the Mediatek Network-on-Chip on DVFSRC-based
> +	  platforms.
> diff --git a/drivers/interconnect/mediatek/Makefile b/drivers/interconnect/mediatek/Makefile
> new file mode 100644
> index 0000000..353842b
> --- /dev/null
> +++ b/drivers/interconnect/mediatek/Makefile
> @@ -0,0 +1,3 @@
> +# SPDX-License-Identifier: GPL-2.0
> +
> +obj-$(CONFIG_INTERCONNECT_MTK_EMI) += mtk-emi.o
> \ No newline at end of file
> diff --git a/drivers/interconnect/mediatek/mtk-emi.c b/drivers/interconnect/mediatek/mtk-emi.c
> new file mode 100644
> index 0000000..9670077
> --- /dev/null
> +++ b/drivers/interconnect/mediatek/mtk-emi.c
> @@ -0,0 +1,330 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2020, The Linux Foundation. All rights reserved.

Just a reminder that the year should be updated when you re-submit.

> + *
> + */
> +
> +#include <linux/device.h>
> +#include <linux/interconnect-provider.h>
> +#include <linux/module.h>
> +#include <linux/of_device.h>
> +#include <linux/platform_device.h>
> +#include <linux/soc/mediatek/mtk_dvfsrc.h>
> +#include <dt-bindings/interconnect/mtk,mt8183-emi.h>
> +#include <dt-bindings/interconnect/mtk,mt6873-emi.h>

Nit: Alphanumeric order please.

[..]
> +static int emi_icc_remove(struct platform_device *pdev);
> +static int emi_icc_probe(struct platform_device *pdev)
> +{
> +	const struct of_device_id *match;
> +	const struct mtk_icc_desc *desc;
> +	struct device *dev = &pdev->dev;
> +	struct icc_node *node;
> +	struct icc_onecell_data *data;
> +	struct icc_provider *provider;
> +	struct mtk_icc_node **mnodes;
> +	size_t num_nodes, i, j;
> +	int ret;
> +
> +	match = of_match_node(emi_icc_of_match, dev->parent->of_node);
> +
> +	if (!match) {
> +		dev_err(dev, "invalid compatible string\n");
> +		return -ENODEV;
> +	}
> +
> +	desc = match->data;
> +	mnodes = desc->nodes;
> +	num_nodes = desc->num_nodes;
> +
> +	provider = devm_kzalloc(dev, sizeof(*provider), GFP_KERNEL);
> +	if (!provider)
> +		return -ENOMEM;
> +
> +	data = devm_kzalloc(dev, struct_size(data, nodes, num_nodes),
> +			    GFP_KERNEL);
> +	if (!data)
> +		return -ENOMEM;
> +
> +	provider->dev = pdev->dev.parent;
> +	provider->set = emi_icc_set;
> +	provider->aggregate = emi_icc_aggregate;
> +	provider->xlate = of_icc_xlate_onecell;
> +	INIT_LIST_HEAD(&provider->nodes);
> +	provider->data = data;
> +
> +	ret = icc_provider_add(provider);
> +	if (ret) {
> +		dev_err(&pdev->dev, "error adding interconnect provider\n");
> +		return ret;
> +	}
> +
> +	for (i = 0; i < num_nodes; i++) {
> +		node = icc_node_create(mnodes[i]->id);
> +		if (IS_ERR(node)) {
> +			ret = PTR_ERR(node);
> +			goto err;
> +		}
> +
> +		node->name = mnodes[i]->name;
> +		node->data = mnodes[i];
> +		icc_node_add(node, provider);
> +
> +		for (j = 0; j < mnodes[i]->num_links; j++)
> +			icc_link_create(node, mnodes[i]->links[j]);
> +
> +		data->nodes[i] = node;
> +	}
> +	data->num_nodes = num_nodes;
> +
> +	platform_set_drvdata(pdev, provider);
> +
> +	return 0;
> +err:
> +	icc_nodes_remove(provider);

Also call icc_provider_del() to restore the original state on error.

Thanks,
Georgi

> +	return ret;
> +}
> +
> +static int emi_icc_remove(struct platform_device *pdev)
> +{
> +	struct icc_provider *provider = platform_get_drvdata(pdev);
> +
> +	icc_nodes_remove(provider);
> +	return icc_provider_del(provider);
> +}
> +

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-01-04 18:37 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-24  6:08 [PATCH V6 00/13] Add driver for dvfsrc, support for active state of scpsys Henry Chen
2020-12-24  6:08 ` Henry Chen
2020-12-24  6:08 ` Henry Chen
2020-12-24  6:08 ` [PATCH V6 01/13] dt-bindings: soc: Add dvfsrc driver bindings Henry Chen
2020-12-24  6:08   ` Henry Chen
2020-12-24  6:08   ` Henry Chen
2020-12-24 17:01   ` Rob Herring
2020-12-24 17:01     ` Rob Herring
2020-12-24 17:01     ` Rob Herring
2020-12-25  5:12     ` Henry Chen
2020-12-25  5:12       ` Henry Chen
2020-12-25  5:12       ` Henry Chen
2020-12-24  6:08 ` [PATCH V6 02/13] soc: mediatek: add header for mediatek SIP interface Henry Chen
2020-12-24  6:08   ` Henry Chen
2020-12-24  6:08   ` Henry Chen
2020-12-24  6:08 ` [PATCH V6 03/13] soc: mediatek: add driver for dvfsrc support Henry Chen
2020-12-24  6:08   ` Henry Chen
2020-12-24  6:08   ` Henry Chen
2020-12-24 14:33   ` Chun-Kuang Hu
2020-12-24 14:33     ` Chun-Kuang Hu
2020-12-24 14:33     ` Chun-Kuang Hu
2020-12-25  5:14     ` Henry Chen
2020-12-25  5:14       ` Henry Chen
2020-12-25  5:14       ` Henry Chen
2020-12-24  6:08 ` [PATCH V6 04/13] arm64: dts: mt8183: add dvfsrc related nodes Henry Chen
2020-12-24  6:08   ` Henry Chen
2020-12-24  6:08   ` Henry Chen
2020-12-24  6:08 ` [PATCH V6 05/13] arm64: dts: mt8192: " Henry Chen
2020-12-24  6:08   ` Henry Chen
2020-12-24  6:08 ` [PATCH V6 06/13] dt-bindings: interconnect: add MT8183 interconnect dt-bindings Henry Chen
2020-12-24  6:08   ` Henry Chen
2020-12-24  6:08   ` Henry Chen
2021-01-08  2:53   ` Rob Herring
2021-01-08  2:53     ` Rob Herring
2021-01-08  2:53     ` Rob Herring
2020-12-24  6:08 ` [PATCH V6 07/13] dt-bindings: interconnect: add MT6873 " Henry Chen
2020-12-24  6:08   ` Henry Chen
2021-01-04 18:34   ` Georgi Djakov
2021-01-04 18:34     ` Georgi Djakov
2021-01-04 18:34     ` Georgi Djakov
2021-01-06  7:25     ` Henry Chen
2021-01-06  7:25       ` Henry Chen
2020-12-24  6:08 ` [PATCH V6 08/13] interconnect: mediatek: Add interconnect provider driver Henry Chen
2020-12-24  6:08   ` Henry Chen
2020-12-24  6:08   ` Henry Chen
2021-01-04 18:36   ` Georgi Djakov [this message]
2021-01-04 18:36     ` Georgi Djakov
2021-01-04 18:36     ` Georgi Djakov
2021-01-06  7:30     ` Henry Chen
2021-01-06  7:30       ` Henry Chen
2021-01-06  7:30       ` Henry Chen
2021-01-06  8:14       ` Georgi Djakov
2021-01-06  8:14         ` Georgi Djakov
2021-01-06  8:14         ` Georgi Djakov
2021-01-06 10:44         ` HenryC Chen (陳建豪)
2021-01-06 12:49           ` Georgi Djakov
2021-01-06 12:49             ` Georgi Djakov
2021-01-06 12:49             ` Georgi Djakov
2021-01-06 13:11             ` HenryC Chen (陳建豪)
2020-12-24  6:08 ` [PATCH V6 09/13] arm64: dts: mt8183: add dvfsrc related nodes Henry Chen
2020-12-24  6:08   ` Henry Chen
2020-12-24  6:08   ` Henry Chen
2020-12-24  6:08 ` [PATCH V6 10/13] arm64: dts: mt8192: " Henry Chen
2020-12-24  6:08   ` Henry Chen
2020-12-24  6:08   ` Henry Chen
2020-12-24  6:08 ` [PATCH V6 11/13] regulator: Regulator driver for the Mediatek DVFSRC Henry Chen
2020-12-24  6:08   ` Henry Chen
2020-12-24  6:08 ` [PATCH V6 12/13] arm64: dts: mt8183: add dvfsrc regulator nodes Henry Chen
2020-12-24  6:08   ` Henry Chen
2020-12-24  6:08   ` Henry Chen
2020-12-24  6:08 ` [PATCH V6 13/13] arm64: dts: mt8192: " Henry Chen
2020-12-24  6:08   ` Henry Chen
2021-01-05 16:07 ` (subset) [PATCH V6 00/13] Add driver for dvfsrc, support for active state of scpsys Mark Brown
2021-01-05 16:07   ` Mark Brown
2021-01-05 16:07   ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c8b951b0-6412-d905-99e1-6350283b57c1@linaro.org \
    --to=georgi.djakov@linaro.org \
    --cc=arvin.wang@mediatek.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=drinkcat@google.com \
    --cc=fan.chen@mediatek.com \
    --cc=henryc.chen@mediatek.com \
    --cc=jamesjj.liao@mediatek.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=matthias.bgg@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=ryandcase@chromium.org \
    --cc=swboyd@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.