All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Roman Vivchar" <rva333@protonmail.com>
Cc: conor+dt@kernel.org, robh@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v2 2/3] soc: mediatek: cmdq-helper: add legacy GCE ISA support
Date: Mon, 07 Sep 2026 18:16:24 +0000	[thread overview]
Message-ID: <20260907181624.EF94C1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260907-6572-gce-v2-2-412a5b037290@protonmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Missing Hardware Capability Validation for Legacy ISA APIs
--

commit 28dadad6fede624ec82b707f4b97ba89645a0db7
Author: Roman Vivchar <rva333@protonmail.com>

soc: mediatek: cmdq-helper: add legacy GCE ISA support

Some SoCs, such as mt6572, have different WRITE and POLL instruction
encoding. Instead of 16-bit offset and 8-bit subsystem ID, old GCEs have
22-bit offset and 2-bit subsystem ID.

> diff --git a/drivers/soc/mediatek/mtk-cmdq-helper.c b/drivers/soc/mediatek/mtk-cmdq-helper.c
> index f8ee6c9ade898..fb82f2a85a210 100644
> --- a/drivers/soc/mediatek/mtk-cmdq-helper.c
> +++ b/drivers/soc/mediatek/mtk-cmdq-helper.c

[ ... ]

> @@ -86,7 +95,7 @@ int cmdq_dev_get_client_reg(struct device *dev,
>  		client_reg->subsys = CMDQ_SUBSYS_INVALID;
>  
>  		/*
> -		 * All GCEs support writing register PA with mask without subsys,
> +		 * GCE v2/v3 support writing register PA with mask without subsys,
>  		 * but this requires extra GCE instructions to convert the PA into
>  		 * a format that GCE can handle, which is less performance than
>  		 * directly using subsys. Therefore, when subsys is available,

[Severity: Medium]
When a client device on a legacy GCE is missing the mediatek,gce-client-reg
property, cmdq_dev_get_client_reg() defaults to assigning cmdq_pkt_write_pa
as the write function:

drivers/soc/mediatek/mtk-cmdq-helper.c:cmdq_dev_get_client_reg() {
    ...
		/*
		 * GCE v2/v3 support writing register PA with mask without subsys,
		 * but this requires extra GCE instructions to convert the PA into
		 * a format that GCE can handle, which is less performance than
		 * directly using subsys. Therefore, when subsys is available,
		 * we prefer to use subsys for writing register PA.
		 */
		client_reg->pkt_write = cmdq_pkt_write_pa;
    ...
}

However, cmdq_pkt_write_pa() unconditionally uses SPRs, which legacy GCE
hardware does not support:

drivers/soc/mediatek/mtk-cmdq-helper.c:cmdq_pkt_write_pa() {
    ...
	err = cmdq_pkt_assign(pkt, CMDQ_THR_SPR_IDX0, CMDQ_ADDR_HIGH(pa_base));
    ...
}

Does this code need a check for pkt->priv.legacy_isa in cmdq_pkt_write_pa()
to prevent generating unsupported instructions that could cause silent queue
corruption or a GCE hardware fault?

[ ... ]

> @@ -459,10 +474,16 @@ int cmdq_pkt_poll(struct cmdq_pkt *pkt, u8 subsys,
>  {
>  	struct cmdq_instruction inst = {
>  		.op = CMDQ_CODE_POLL,
> -		.value = value,
> -		.offset = offset,
> -		.subsys = subsys
> +		.value = value
>  	};
> +
> +	if (pkt->priv.legacy_isa) {
> +		inst.offset_legacy = offset;
> +		inst.subsys_legacy = subsys;
> +	} else {
> +		inst.offset = offset;
> +		inst.subsys = subsys;
> +	}
>  	return cmdq_pkt_append_command(pkt, inst);
>  }

[Severity: Medium]
Similarly, cmdq_pkt_poll_addr() unconditionally relies on GPR registers, which
legacy hardware does not implement:

drivers/soc/mediatek/mtk-cmdq-helper.c:cmdq_pkt_poll_addr() {
    ...
	inst.op = CMDQ_CODE_POLL;
	inst.dst_t = CMDQ_REG_TYPE;
	inst.sop = CMDQ_POLL_ADDR_GPR;
    ...
}

Should there be a capability validation for legacy_isa in
cmdq_pkt_poll_addr() as well to avoid generating invalid microcode
instructions?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260907-6572-gce-v2-0-412a5b037290@protonmail.com?part=2

  reply	other threads:[~2026-09-07 18:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-07 18:03 [PATCH v2 0/3] MediaTek mt6572 GCE support Roman Vivchar via B4 Relay
2026-09-07 18:03 ` Roman Vivchar
2026-09-07 18:03 ` [PATCH v2 1/3] dt-bindings: mailbox: mediatek,gce-mailbox: add mt6572 Roman Vivchar via B4 Relay
2026-09-07 18:03   ` Roman Vivchar
2026-09-07 18:03 ` [PATCH v2 2/3] soc: mediatek: cmdq-helper: add legacy GCE ISA support Roman Vivchar via B4 Relay
2026-09-07 18:03   ` Roman Vivchar
2026-09-07 18:16   ` sashiko-bot [this message]
2026-09-09  9:57   ` AngeloGioacchino Del Regno
2026-09-07 18:03 ` [PATCH v2 3/3] mailbox: mtk-cmdq: add mt6572 support Roman Vivchar via B4 Relay
2026-09-07 18:03   ` Roman Vivchar
2026-09-07 18:17   ` sashiko-bot
2026-09-08  7:01 ` [PATCH v2 0/3] MediaTek mt6572 GCE support AngeloGioacchino Del Regno

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=20260907181624.EF94C1F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=rva333@protonmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.