linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bryan O'Donoghue <bryan.odonoghue@linaro.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 08/29] media: iris: implement boot sequence of the firmware
Date: Thu, 5 Sep 2024 13:34:48 +0100	[thread overview]
Message-ID: <3b578b1b-53d5-4f2d-a2b8-8483a4051a24@linaro.org> (raw)
In-Reply-To: <20240827-iris_v3-v3-8-c5fdbbe65e70@quicinc.com>

On 27/08/2024 11:05, Dikshita Agarwal via B4 Relay wrote:
> From: Dikshita Agarwal <quic_dikshita@quicinc.com>
> 
> Set memory region to firmware and implement boot sequence.
> 
> Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
> ---
>   drivers/media/platform/qcom/iris/Makefile          |  1 +
>   drivers/media/platform/qcom/iris/iris_core.c       |  7 ++
>   .../platform/qcom/iris/iris_platform_common.h      |  1 +
>   .../platform/qcom/iris/iris_platform_sm8550.c      |  3 +
>   drivers/media/platform/qcom/iris/iris_vpu_common.c | 87 ++++++++++++++++++++++
>   drivers/media/platform/qcom/iris/iris_vpu_common.h | 13 ++++
>   6 files changed, 112 insertions(+)
> 
> diff --git a/drivers/media/platform/qcom/iris/Makefile b/drivers/media/platform/qcom/iris/Makefile
> index ddd4c994a0b9..95f4e92fe085 100644
> --- a/drivers/media/platform/qcom/iris/Makefile
> +++ b/drivers/media/platform/qcom/iris/Makefile
> @@ -8,5 +8,6 @@ iris-objs += iris_core.o \
>                iris_probe.o \
>                iris_resources.o \
>                iris_vidc.o \
> +             iris_vpu_common.o \
>   
>   obj-$(CONFIG_VIDEO_QCOM_IRIS) += iris.o
> diff --git a/drivers/media/platform/qcom/iris/iris_core.c b/drivers/media/platform/qcom/iris/iris_core.c
> index 8c7d53c57086..5ad66ac113ae 100644
> --- a/drivers/media/platform/qcom/iris/iris_core.c
> +++ b/drivers/media/platform/qcom/iris/iris_core.c
> @@ -6,6 +6,7 @@
>   #include "iris_core.h"
>   #include "iris_firmware.h"
>   #include "iris_state.h"
> +#include "iris_vpu_common.h"
>   
>   void iris_core_deinit(struct iris_core *core)
>   {
> @@ -39,10 +40,16 @@ int iris_core_init(struct iris_core *core)
>   	if (ret)
>   		goto error_queue_deinit;
>   
> +	ret = iris_vpu_boot_firmware(core);
> +	if (ret)
> +		goto error_unload_fw;
> +
>   	mutex_unlock(&core->lock);
>   
>   	return 0;
>   
> +error_unload_fw:
> +	iris_fw_unload(core);
>   error_queue_deinit:
>   	iris_hfi_queues_deinit(core);
>   error:
> diff --git a/drivers/media/platform/qcom/iris/iris_platform_common.h b/drivers/media/platform/qcom/iris/iris_platform_common.h
> index 9c919367f9d7..47fdebd8135c 100644
> --- a/drivers/media/platform/qcom/iris/iris_platform_common.h
> +++ b/drivers/media/platform/qcom/iris/iris_platform_common.h
> @@ -45,6 +45,7 @@ struct iris_platform_data {
>   	const char *fwname;
>   	u32 pas_id;
>   	struct tz_cp_config *tz_cp_config_data;
> +	u32 core_arch;
>   };
>   
>   #endif
> diff --git a/drivers/media/platform/qcom/iris/iris_platform_sm8550.c b/drivers/media/platform/qcom/iris/iris_platform_sm8550.c
> index 1bb34c3e6e18..a559e095fefc 100644
> --- a/drivers/media/platform/qcom/iris/iris_platform_sm8550.c
> +++ b/drivers/media/platform/qcom/iris/iris_platform_sm8550.c
> @@ -8,6 +8,8 @@
>   #include "iris_platform_common.h"
>   #include "iris_resources.h"
>   
> +#define VIDEO_ARCH_LX 1
> +
>   static const struct icc_info sm8550_icc_table[] = {
>   	{ "cpu-cfg",    1000, 1000     },
>   	{ "video-mem",  1000, 15000000 },
> @@ -48,4 +50,5 @@ struct iris_platform_data sm8550_data = {
>   	.fwname = "qcom/vpu/vpu30_p4.mbn",
>   	.pas_id = IRIS_PAS_ID,
>   	.tz_cp_config_data = &tz_cp_config_sm8550,
> +	.core_arch = VIDEO_ARCH_LX,
>   };
> diff --git a/drivers/media/platform/qcom/iris/iris_vpu_common.c b/drivers/media/platform/qcom/iris/iris_vpu_common.c
> new file mode 100644
> index 000000000000..df87b1b719a9
> --- /dev/null
> +++ b/drivers/media/platform/qcom/iris/iris_vpu_common.c
> @@ -0,0 +1,87 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
> + */
> +
> +#include <linux/iopoll.h>
> +
> +#include "iris_core.h"
> +#include "iris_vpu_common.h"
> +
> +#define CPU_BASE_OFFS				0x000A0000
> +
> +#define CPU_CS_BASE_OFFS			(CPU_BASE_OFFS)
> +
> +#define CTRL_INIT				(CPU_CS_BASE_OFFS + 0x48)
> +#define CTRL_STATUS				(CPU_CS_BASE_OFFS + 0x4C)
> +
> +#define CTRL_ERROR_STATUS__M			0xfe
> +
> +#define QTBL_INFO				(CPU_CS_BASE_OFFS + 0x50)
> +#define QTBL_ADDR				(CPU_CS_BASE_OFFS + 0x54)
> +#define CPU_CS_SCIACMDARG3			(CPU_CS_BASE_OFFS + 0x58)
> +#define SFR_ADDR				(CPU_CS_BASE_OFFS + 0x5C)
> +#define UC_REGION_ADDR				(CPU_CS_BASE_OFFS + 0x64)
> +#define UC_REGION_SIZE				(CPU_CS_BASE_OFFS + 0x68)
> +
> +#define CPU_CS_H2XSOFTINTEN			(CPU_CS_BASE_OFFS + 0x148)
> +#define CPU_CS_X2RPMH				(CPU_CS_BASE_OFFS + 0x168)
> +
> +static void iris_vpu_setup_ucregion_memory_map(struct iris_core *core)
> +{
> +	u32 queue_size, value;
> +
> +	/* Iris hardware requires 4K queue alignment */
> +	queue_size = ALIGN(sizeof(struct iris_hfi_queue_table_header) +
> +		(IFACEQ_QUEUE_SIZE * IFACEQ_NUMQ), SZ_4K);
> +
> +	value = (u32)core->iface_q_table_daddr;
> +	writel(value, core->reg_base + UC_REGION_ADDR);
> +
> +	/* Iris hardware requires 1M queue alignment */
> +	value = ALIGN(SFR_SIZE + queue_size, SZ_1M);
> +	writel(value, core->reg_base + UC_REGION_SIZE);
> +
> +	value = (u32)core->iface_q_table_daddr;
> +	writel(value, core->reg_base + QTBL_ADDR);
> +
> +	writel(0x01, core->reg_base + QTBL_INFO);

A general comment I have is instead of writing hard-coded values to 
registers we should define at a minimum the bit-fields we use if not the 
entire set of bits-fields for the register.

The only exception to this is when we don't know what those values are - 
for example receiving a magic write sequence for a camera sensor.

In this case though we have full access to enumerate the register 
bit-fields.

Without looking at the register descriptions I guess this bit is an 
enable or a startup bit =>

#define QTBL_INFO_EN BIT(0)

I'll not go through this series reiterating this comment but, it 
certainly applies to any bit-field/register in the same => please define 
at least the bits used if not the full set of bits for register writes 
instead of using magic numbers.

---
bod

  reply	other threads:[~2024-09-05 12:34 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
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 [this message]
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=3b578b1b-53d5-4f2d-a2b8-8483a4051a24@linaro.org \
    --to=bryan.odonoghue@linaro.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).