mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
To: Junhao Xie <bigfoot@radxa.com>,
	Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konradybcio@kernel.org>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Richard Weinberger <richard@nod.at>,
	Vignesh Raghavendra <vigneshr@ti.com>
Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-mtd@lists.infradead.org, Xilin Wu <sophon@radxa.com>
Subject: Re: [PATCH v2 1/2] firmware: qcom: scm: Add SCM storage interface support
Date: Wed, 28 Jan 2026 14:39:32 +0100	[thread overview]
Message-ID: <2d28b5d0-c5f4-4085-b2d0-18128b021416@oss.qualcomm.com> (raw)
In-Reply-To: <20260126-scm-storage-v2-v2-1-fa045c7e7699@radxa.com>

On 1/26/26 12:44 PM, Junhao Xie wrote:
> Add infrastructure to support accessing TrustZone-protected storage
> devices through SCM (Secure Channel Manager) calls. Some Qualcomm
> platforms protect their firmware storage (typically SPI NOR flash)
> via TrustZone, making it inaccessible from the non-secure world.
> 
> Signed-off-by: Junhao Xie <bigfoot@radxa.com>
> Tested-by: Xilin Wu <sophon@radxa.com>
> ---

[...]

> +int qcom_scm_storage_send_cmd(enum qcom_scm_storage_type storage_type,
> +			      enum qcom_scm_storage_cmd_id cmd_id,
> +			      u64 lba, void *data, size_t size)

Please add kerneldoc, as this is an exported function

> +{
> +	struct qcom_scm_storage_payload *payload __free(qcom_tzmem) = NULL;
> +	struct qcom_scm_res scm_res = {};
> +	struct qcom_scm_desc desc = {};
> +	phys_addr_t payload_addr;
> +	size_t buf_size;
> +	int ret;
> +
> +	buf_size = sizeof(*payload);
> +	if (data)
> +		buf_size += size;
> +
> +	payload = qcom_tzmem_alloc(__scm->mempool, buf_size, GFP_KERNEL);
> +	if (!payload)
> +		return -ENOMEM;
> +
> +	memset(payload, 0, buf_size);

You're overwriting the data part a line below, let's just zero out the
cmd+details (sizeof(*payload)) part

> +	if (data)

(please add a \n above - normally

foo = xyz;
if (abc)
	...

implies the condition takes into account the previous line)

[...]

> +	if (!__qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_STORAGE,
> +					 QCOM_SCM_STORAGE_CMD))
> +		return;
> +
> +	ret = qcom_scm_storage_send_cmd(QCOM_SCM_STORAGE_SPINOR,
> +					QCOM_SCM_STORAGE_GET_INFO,
> +					0, &info, sizeof(info));

I'm curious what happens if the call is available but SPINOR is not
populated onboard..

I thiiiink it should return STORAGE_RESULT_INVALID_PARAMETER but I'm not
a 100% sure. Guess we'll see down the road.


> +	if (ret < 0) {
> +		dev_warn(scm->dev, "scm storage get info failed: %d\n", ret);
> +		return;
> +	}
> +
> +	total_blocks = le64_to_cpu(info.total_blocks);
> +	block_size = le32_to_cpu(info.block_size);
> +
> +	dev_dbg(scm->dev, "scm storage size %llu bytes\n",
> +		total_blocks * block_size);
> +
> +	storage_dev = platform_device_alloc("qcom_scm_storage", -1);

-1 is PLATFORM_DEVID_NONE

Let's use PLATFORM_DEVID_AUTO to allow potentially multiple instances of
this driver being spawned down the road

Konrad

  reply	other threads:[~2026-01-28 13:39 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-26 11:44 [PATCH v2 0/2] mtd: devices: Qualcomm SCM storage support Junhao Xie
2026-01-26 11:44 ` [PATCH v2 1/2] firmware: qcom: scm: Add SCM storage interface support Junhao Xie
2026-01-28 13:39   ` Konrad Dybcio [this message]
2026-01-30 10:58     ` Junhao Xie
2026-01-26 11:44 ` [PATCH v2 2/2] mtd: devices: Add Qualcomm SCM storage driver Junhao Xie
2026-01-29 19:01   ` Miquel Raynal
2026-01-28 13:26 ` [PATCH v2 0/2] mtd: devices: Qualcomm SCM storage support Konrad Dybcio
2026-01-28 14:13   ` Miquel Raynal
2026-01-28 20:31     ` Bjorn Andersson
2026-01-29 18:38       ` Miquel Raynal
2026-01-29 13:05   ` Junhao Xie
2026-01-28 20:42 ` Bjorn Andersson
2026-01-30 13:39   ` Junhao Xie
2026-01-30 14:10     ` Miquel Raynal
2026-01-30 16:45       ` Junhao Xie
2026-02-03 14:20         ` Miquel Raynal
2026-03-13 10:16           ` Val Packett
2026-01-28 21:43 ` Trilok Soni
2026-01-29 12:47   ` Junhao Xie
2026-01-29 14:17     ` Konrad Dybcio

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=2d28b5d0-c5f4-4085-b2d0-18128b021416@oss.qualcomm.com \
    --to=konrad.dybcio@oss.qualcomm.com \
    --cc=andersson@kernel.org \
    --cc=bigfoot@radxa.com \
    --cc=konradybcio@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=sophon@radxa.com \
    --cc=vigneshr@ti.com \
    /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

all inboxes | Powered by JetHome®