linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: quic_dikshita@quicinc.com,
	Vikash Garodia <quic_vgarodia@quicinc.com>,
	Abhinav Kumar <quic_abhinavk@quicinc.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Philipp Zabel <p.zabel@pengutronix.de>
Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 04/29] media: iris: initialize power resources
Date: Tue, 27 Aug 2024 12:51:45 +0200	[thread overview]
Message-ID: <81fd218f-aa0f-4710-b832-cab927bfab9d@kernel.org> (raw)
In-Reply-To: <20240827-iris_v3-v3-4-c5fdbbe65e70@quicinc.com>

On 27/08/2024 12:05, Dikshita Agarwal via B4 Relay wrote:
> From: Dikshita Agarwal <quic_dikshita@quicinc.com>
> 
> Add support for initializing Iris "resources", which are clocks,
> interconnects, power domains, reset clocks, and clock frequencies
> used for iris hardware.
> 
> Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
> ---

...

> +struct iris_platform_data sm8550_data = {
> +	.icc_tbl = sm8550_icc_table,
> +	.icc_tbl_size = ARRAY_SIZE(sm8550_icc_table),
> +	.clk_rst_tbl = sm8550_clk_reset_table,
> +	.clk_rst_tbl_size = ARRAY_SIZE(sm8550_clk_reset_table),
> +	.pmdomain_tbl = sm8550_pmdomain_table,
> +	.pmdomain_tbl_size = ARRAY_SIZE(sm8550_pmdomain_table),
> +	.opp_pd_tbl = sm8550_opp_pd_table,
> +	.opp_pd_tbl_size = ARRAY_SIZE(sm8550_opp_pd_table),
> +	.clk_tbl = sm8550_clk_table,
> +	.clk_tbl_size = ARRAY_SIZE(sm8550_clk_table),
> +};
> diff --git a/drivers/media/platform/qcom/iris/iris_probe.c b/drivers/media/platform/qcom/iris/iris_probe.c
> index 0a54fdaa1ab5..2616a31224f9 100644
> --- a/drivers/media/platform/qcom/iris/iris_probe.c
> +++ b/drivers/media/platform/qcom/iris/iris_probe.c
> @@ -69,6 +69,19 @@ static int iris_probe(struct platform_device *pdev)
>  	if (core->irq < 0)
>  		return core->irq;
>  
> +	core->iris_platform_data = of_device_get_match_data(core->dev);
> +	if (!core->iris_platform_data) {
> +		ret = -ENODEV;
> +		dev_err_probe(core->dev, ret, "init platform failed\n");

That's not even possible. I would suggest dropping entire if. But if yoi
insist, then without this weird redundant code. return -EINVAL.

> +		return ret;
> +	}
> +
> +	ret = iris_init_resources(core);
> +	if (ret) {
> +		dev_err_probe(core->dev, ret, "init resource failed\n");
> +		return ret;

How many same errors are you printing? Not mentioning that syntax of
dev_errp_rpboe is different...


> +	}
> +
>  	ret = v4l2_device_register(dev, &core->v4l2_dev);
>  	if (ret)
>  		return ret;
> @@ -88,8 +101,14 @@ static int iris_probe(struct platform_device *pdev)
>  }
>  
>  static const struct of_device_id iris_dt_match[] = {
> -	{ .compatible = "qcom,sm8550-iris", },
> -	{ .compatible = "qcom,sm8250-venus", },
> +	{
> +		.compatible = "qcom,sm8550-iris",
> +		.data = &sm8550_data,
> +	},
> +	{
> +		.compatible = "qcom,sm8250-venus",
> +		.data = &sm8250_data,

You just added this. No, please do not add code which is immediatly
incorrect.

> +	},
>  	{ },
>  };
>  MODULE_DEVICE_TABLE(of, iris_dt_match);
> diff --git a/drivers/media/platform/qcom/iris/iris_resources.c b/drivers/media/platform/qcom/iris/iris_resources.c
> new file mode 100644
> index 000000000000..57c6f9f3449b
> --- /dev/null
> +++ b/drivers/media/platform/qcom/iris/iris_resources.c
> @@ -0,0 +1,171 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
> + */
> +
> +#include <linux/clk.h>
> +#include <linux/interconnect.h>
> +#include <linux/pm_domain.h>
> +#include <linux/pm_opp.h>
> +#include <linux/reset.h>
> +
> +#include "iris_core.h"
> +#include "iris_resources.h"
> +
> +static int iris_init_icc(struct iris_core *core)
> +{
> +	const struct icc_info *icc_tbl;
> +	u32 ret, i = 0;
> +
> +	icc_tbl = core->iris_platform_data->icc_tbl;
> +
> +	core->icc_count = core->iris_platform_data->icc_tbl_size;
> +	core->icc_tbl = devm_kzalloc(core->dev,
> +				     sizeof(struct icc_bulk_data) * core->icc_count,
> +				     GFP_KERNEL);
> +	if (!core->icc_tbl)
> +		return -ENOMEM;
> +
> +	for (i = 0; i < core->icc_count; i++) {
> +		core->icc_tbl[i].name = icc_tbl[i].name;
> +		core->icc_tbl[i].avg_bw = icc_tbl[i].bw_min_kbps;
> +		core->icc_tbl[i].peak_bw = 0;
> +	}
> +
> +	ret = devm_of_icc_bulk_get(core->dev, core->icc_count, core->icc_tbl);
> +	if (ret)
> +		dev_err(core->dev, "failed to get interconnect paths, NoC will stay unconfigured!\n");
> +
> +	return ret;
> +}
> +
> +static int iris_pd_get(struct iris_core *core)
> +{
> +	int ret;
> +
> +	struct dev_pm_domain_attach_data iris_pd_data = {
> +		.pd_names = core->iris_platform_data->pmdomain_tbl,
> +		.num_pd_names = core->iris_platform_data->pmdomain_tbl_size,
> +		.pd_flags = PD_FLAG_NO_DEV_LINK,
> +	};
> +
> +	ret = devm_pm_domain_attach_list(core->dev, &iris_pd_data, &core->pmdomain_tbl);
> +	if (ret < 0)
> +		return ret;
> +
> +	return 0;
> +}
> +
> +static int iris_opp_pd_get(struct iris_core *core)
> +{
> +	int ret;
> +
> +	struct dev_pm_domain_attach_data iris_opp_pd_data = {
> +		.pd_names = core->iris_platform_data->opp_pd_tbl,
> +		.num_pd_names = core->iris_platform_data->opp_pd_tbl_size,
> +		.pd_flags = PD_FLAG_DEV_LINK_ON,
> +	};
> +
> +	ret = devm_pm_domain_attach_list(core->dev, &iris_opp_pd_data, &core->opp_pmdomain_tbl);
> +	if (ret < 0)
> +		return ret;
> +
> +	return 0;
> +}
> +
> +static int iris_init_power_domains(struct iris_core *core)
> +{
> +	const struct platform_clk_data *clk_tbl;
> +	u32 clk_cnt, i;
> +	int ret;
> +
> +	ret = iris_pd_get(core);
> +	if (ret)
> +		return ret;
> +
> +	ret = iris_opp_pd_get(core);
> +	if (ret)
> +		return ret;
> +
> +	clk_tbl = core->iris_platform_data->clk_tbl;
> +	clk_cnt = core->iris_platform_data->clk_tbl_size;
> +
> +	for (i = 0; i < clk_cnt; i++) {
> +		if (clk_tbl[i].clk_type == IRIS_HW_CLK) {
> +			ret = devm_pm_opp_set_clkname(core->dev, clk_tbl[i].clk_name);
> +			if (ret)
> +				return ret;
> +		}
> +	}
> +
> +	ret = devm_pm_opp_of_add_table(core->dev);
> +	if (ret) {
> +		dev_err(core->dev, "failed to add opp table\n");
> +		return ret;
> +	}
> +
> +	return ret;
> +}
> +
> +static int iris_init_clocks(struct iris_core *core)
> +{
> +	int ret;
> +
> +	ret = devm_clk_bulk_get_all(core->dev, &core->clock_tbl);
> +	if (ret < 0) {
> +		dev_err(core->dev, "failed to get bulk clock\n");

Syntax is:
return dev_err_probe(). If this is probe path. Is it?

> +		return ret;
> +	}
> +
> +	core->clk_count = ret;
> +
> +	return 0;
> +}
> +
> +static int iris_init_resets(struct iris_core *core)
> +{
> +	const char * const *rst_tbl;
> +	u32 rst_tbl_size;
> +	u32 i = 0, ret;
> +
> +	rst_tbl = core->iris_platform_data->clk_rst_tbl;
> +	rst_tbl_size = core->iris_platform_data->clk_rst_tbl_size;
> +
> +	core->resets = devm_kzalloc(core->dev,
> +				    sizeof(*core->resets) * rst_tbl_size,
> +				    GFP_KERNEL);
> +	if (rst_tbl_size && !core->resets)
> +		return -ENOMEM;
> +
> +	for (i = 0; i < rst_tbl_size; i++)
> +		core->resets[i].id = rst_tbl[i];
> +
> +	ret = devm_reset_control_bulk_get_exclusive(core->dev, rst_tbl_size, core->resets);
> +	if (ret) {
> +		dev_err(core->dev, "failed to get resets\n");

Syntax is:
return dev_err_probe(). If this is probe path. Is it?

> +		return ret;
> +	}
> +
> +	return 0;
> +}
> +
> +int iris_init_resources(struct iris_core *core)
> +{
> +	int ret;
> +
> +	ret = iris_init_icc(core);
> +	if (ret)
> +		return ret;
> +
> +	ret = iris_init_power_domains(core);
> +	if (ret)
> +		return ret;
> +
> +	ret = iris_init_clocks(core);
> +	if (ret)
> +		return ret;
> +
> +	ret = iris_init_resets(core);
> +
> +	return ret;
> +}

This should be just part of of main unit file, next to probe. It is
unusual to see probe parts not next to probe. Sorry, that's wrong.

Best regards,
Krzysztof


  reply	other threads:[~2024-08-27 10:51 UTC|newest]

Thread overview: 93+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-27 10:05 [PATCH v3 00/29] Qualcomm iris video decoder driver Dikshita Agarwal via B4 Relay
2024-08-27 10:05 ` [PATCH v3 01/29] dt-bindings: media: Add sm8550 dt schema Dikshita Agarwal via B4 Relay
2024-08-27 10:42   ` Krzysztof Kozlowski
2024-09-05  5:41     ` Dikshita Agarwal
2024-08-27 10:05 ` [PATCH v3 02/29] media: MAINTAINERS: Add Qualcomm Iris video accelerator driver Dikshita Agarwal via B4 Relay
2024-08-27 10:42   ` Krzysztof Kozlowski
2024-09-05  5:47     ` Dikshita Agarwal
2024-09-05 10:10       ` Dmitry Baryshkov
2024-09-05 11:02         ` Dikshita Agarwal
2024-09-05 11:02           ` Dmitry Baryshkov
2024-09-05 11:14             ` Dikshita Agarwal
2024-08-27 10:05 ` [PATCH v3 03/29] media: iris: add platform driver for iris video device Dikshita Agarwal via B4 Relay
2024-08-27 14:08   ` Bryan O'Donoghue
2024-08-29  9:13     ` Dmitry Baryshkov
2024-08-29  9:36       ` Bryan O'Donoghue
2024-09-05  6:12       ` Dikshita Agarwal
2024-09-05  6:15         ` Dikshita Agarwal
2024-09-05 10:11           ` Dmitry Baryshkov
2024-09-05 10:59             ` Dikshita Agarwal
2024-09-05 11:07               ` Dmitry Baryshkov
2024-09-05 11:13                 ` Dikshita Agarwal
2024-08-27 10:05 ` [PATCH v3 04/29] media: iris: initialize power resources Dikshita Agarwal via B4 Relay
2024-08-27 10:51   ` Krzysztof Kozlowski [this message]
2024-09-05 11:53     ` Dikshita Agarwal
2024-09-05 11:57       ` Krzysztof Kozlowski
2024-09-06 11:21         ` Vikash Garodia
2024-09-06 12:04           ` Krzysztof Kozlowski
2024-09-06 19:47             ` Vikash Garodia
2024-09-07  9:07               ` Krzysztof Kozlowski
2024-08-27 10:05 ` [PATCH v3 05/29] media: iris: implement iris v4l2 file ops Dikshita Agarwal via B4 Relay
2024-09-06 19:05   ` Markus Elfring
2024-09-07  8:52   ` Markus Elfring
2024-08-27 10:05 ` [PATCH v3 06/29] media: iris: introduce iris core state management with shared queues Dikshita Agarwal via B4 Relay
2024-08-28  2:38   ` kernel test robot
2024-08-27 10:05 ` [PATCH v3 07/29] media: iris: implement video firmware load/unload Dikshita Agarwal via B4 Relay
2024-08-27 23:13   ` kernel test robot
2024-08-31 13:18   ` Bryan O'Donoghue
2024-09-02  0:04     ` Dmitry Baryshkov
2024-09-05  6:17       ` Dikshita Agarwal
2024-08-27 10:05 ` [PATCH v3 08/29] media: iris: implement boot sequence of the firmware Dikshita Agarwal via B4 Relay
2024-09-05 12:34   ` Bryan O'Donoghue
2024-09-06 11:27     ` Vikash Garodia
2024-08-27 10:05 ` [PATCH v3 09/29] media: iris: introduce Host firmware interface with necessary hooks Dikshita Agarwal via B4 Relay
2024-09-05 12:36   ` Bryan O'Donoghue
2024-09-24  9:13     ` Dikshita Agarwal
2024-09-05 13:10   ` Bryan O'Donoghue
2024-09-06 13:31     ` Vikash Garodia
2024-08-27 10:05 ` [PATCH v3 10/29] media: iris: implement power management Dikshita Agarwal via B4 Relay
2024-09-05 13:23   ` Bryan O'Donoghue
2024-09-05 13:46     ` Krzysztof Kozlowski
2024-09-24  8:38       ` Dikshita Agarwal
2024-09-24  8:36     ` Dikshita Agarwal
2024-08-27 10:05 ` [PATCH v3 11/29] media: iris: implement reqbuf ioctl with vb2_queue_setup Dikshita Agarwal via B4 Relay
2024-09-06 12:50   ` Bryan O'Donoghue
2024-09-06 13:05     ` Bryan O'Donoghue
2024-09-26 10:47     ` Dikshita Agarwal
2024-08-27 10:05 ` [PATCH v3 12/29] media: iris: implement s_fmt, g_fmt and try_fmt ioctls Dikshita Agarwal via B4 Relay
2024-09-24 14:41   ` Bryan O'Donoghue
2024-09-26 10:49     ` Dikshita Agarwal
2024-08-27 10:05 ` [PATCH v3 13/29] media: iris: implement g_selection ioctl Dikshita Agarwal via B4 Relay
2024-08-27 10:05 ` [PATCH v3 14/29] media: iris: implement enum_fmt and enum_frameintervals ioctls Dikshita Agarwal via B4 Relay
2024-08-27 10:05 ` [PATCH v3 15/29] media: iris: implement subscribe_event and unsubscribe_event ioctls Dikshita Agarwal via B4 Relay
2024-08-27 10:05 ` [PATCH v3 16/29] media: iris: implement iris v4l2_ctrl_ops and prepare capabilities Dikshita Agarwal via B4 Relay
2024-08-29  9:33   ` Dmitry Baryshkov
2024-10-01 13:01     ` Vedang Nagar
2024-10-06 16:46       ` Dmitry Baryshkov
2024-08-27 10:05 ` [PATCH v3 17/29] media: iris: implement query_cap, query_ctrl and query_menu ioctls Dikshita Agarwal via B4 Relay
2024-09-24 14:49   ` Bryan O'Donoghue
2024-09-26 10:50     ` Dikshita Agarwal
2024-08-27 10:05 ` [PATCH v3 18/29] media: iris: implement vb2 streaming ops Dikshita Agarwal via B4 Relay
2024-08-28  0:26   ` kernel test robot
2024-08-27 10:05 ` [PATCH v3 19/29] media: iris: implement set properties to firmware during streamon Dikshita Agarwal via B4 Relay
2024-09-24 15:09   ` Bryan O'Donoghue
2024-08-27 10:05 ` [PATCH v3 20/29] media: iris: subscribe parameters and properties to firmware for hfi_gen2 Dikshita Agarwal via B4 Relay
2024-09-24 15:16   ` Bryan O'Donoghue
2024-09-26 10:55     ` Dikshita Agarwal
2024-08-27 10:05 ` [PATCH v3 21/29] media: iris: allocate, initialize and queue internal buffers Dikshita Agarwal via B4 Relay
2024-08-27 10:05 ` [PATCH v3 22/29] media: iris: implement vb2 ops for buf_queue and firmware response Dikshita Agarwal via B4 Relay
2024-08-27 10:05 ` [PATCH v3 23/29] media: iris: add support for dynamic resolution change Dikshita Agarwal via B4 Relay
2024-08-27 10:05 ` [PATCH v3 24/29] media: iris: handle streamoff/on from client in " Dikshita Agarwal via B4 Relay
2024-08-27 10:05 ` [PATCH v3 25/29] media: iris: add support for drain sequence Dikshita Agarwal via B4 Relay
2024-08-27 10:05 ` [PATCH v3 26/29] media: iris: add check whether the video session is supported or not Dikshita Agarwal via B4 Relay
2024-08-27 10:05 ` [PATCH v3 27/29] media: iris: implement power scaling for vpu2 and vpu3 Dikshita Agarwal via B4 Relay
2024-08-27 10:05 ` [PATCH v3 28/29] media: iris: add allow checks for v4l2 ioctls Dikshita Agarwal via B4 Relay
2024-08-27 10:05 ` [PATCH v3 29/29] media: iris: add check to allow sub states transitions Dikshita Agarwal via B4 Relay
2024-08-27 13:41 ` [PATCH v3 00/29] Qualcomm iris video decoder driver neil.armstrong
2024-09-24  9:13   ` Dikshita Agarwal
2024-10-01 13:28     ` Neil Armstrong
2024-08-31 15:18 ` Bryan O'Donoghue
2024-09-02  0:02   ` Dmitry Baryshkov
2024-09-06 14:19     ` Nicolas Dufresne
2024-09-06 19:26       ` Vikash Garodia
2024-09-06 16:28     ` Abhinav Kumar

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=81fd218f-aa0f-4710-b832-cab927bfab9d@kernel.org \
    --to=krzk@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=quic_abhinavk@quicinc.com \
    --cc=quic_dikshita@quicinc.com \
    --cc=quic_vgarodia@quicinc.com \
    --cc=robh@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).