From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
To: Junhao Xie <bigfoot@radxa.com>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>
Cc: Xilin Wu <sophon@radxa.com>,
Miquel Raynal <miquel.raynal@bootlin.com>,
Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
Tomas Winkler <tomasw@gmail.com>,
Raag Jadav <raag.jadav@intel.com>,
Krzysztof Kozlowski <krzk@kernel.org>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Alexander Usyskin <alexander.usyskin@intel.com>,
linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-mtd@lists.infradead.org
Subject: Re: [PATCH 2/2] mtd: devices: Add Qualcomm SCM storage driver
Date: Fri, 19 Dec 2025 13:05:41 +0100 [thread overview]
Message-ID: <b14c51a0-7e87-4eb2-ae52-caf90f1bf545@oss.qualcomm.com> (raw)
In-Reply-To: <A41171D3EA8B583B+20251218180205.930961-3-bigfoot@radxa.com>
On 12/18/25 7:02 PM, Junhao Xie wrote:
> Add MTD driver for accessing storage devices managed by Qualcomm's
> TrustZone firmware. On some platforms, BIOS/firmware storage (typically
> SPI NOR flash) is not directly accessible from the non-secure world and
> all operations must go through SCM (Secure Channel Manager) calls.
>
> Signed-off-by: Junhao Xie <bigfoot@radxa.com>
> Tested-by: Xilin Wu <sophon@radxa.com>
> ---
[...]
> +struct qcom_scm_storage {
> + struct device *dev;
> + struct mutex lock; /* Protects SCM storage operations */
> + struct mtd_info mtd;
> + struct qcom_scm_storage_info info;
> + size_t buffer_size;
> + u8 *buffer;
> +};
> +
> +static int qcom_scm_storage_erase(struct mtd_info *mtd,
> + struct erase_info *instr)
> +{
> + struct qcom_scm_storage *host =
> + container_of(mtd, struct qcom_scm_storage, mtd);
> +
> + if (instr->addr % host->info.block_size ||
> + instr->len % host->info.block_size)
While it's the same value, it seems like mtd->erasesize would be
"idiomatic" here
> + return -EINVAL;
> +
> + guard(mutex)(&host->lock);
> +
> + return qcom_scm_storage_send_cmd(QCOM_SCM_STORAGE_SPINOR,
> + QCOM_SCM_STORAGE_ERASE,
> + instr->addr / host->info.block_size,
> + 0, instr->len);
> +}
> +
> +static int qcom_scm_storage_read(struct mtd_info *mtd,
> + loff_t from, size_t len,
> + size_t *retlen, u_char *buf)
> +{
> + struct qcom_scm_storage *host =
> + container_of(mtd, struct qcom_scm_storage, mtd);
Feel free to unwrap this line
> + size_t block_size = host->info.block_size;
> + loff_t block_start, block_off, lba;
> + size_t chunk, to_read;
> + int ret = 0;
This initialization seems unnecessary
[...]
> +static int qcom_scm_storage_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + struct qcom_scm_storage *host;
> + int ret;
> +
> + host = devm_kzalloc(dev, sizeof(*host), GFP_KERNEL);
> + if (!host)
> + return -ENOMEM;
> +
> + platform_set_drvdata(pdev, host);
> + host->dev = dev;
> +
> + ret = devm_mutex_init(dev, &host->lock);
> + if (ret)
> + return ret;
> +
> + host->buffer_size = SZ_256K;
Should this just be = host->info->page_size?
[...]
> + dev_info(dev, "scm storage 0x%llx registered with size %llu bytes\n",
> + host->info.serial_num, host->mtd.size);
dev_dbg()?
Konrad
next prev parent reply other threads:[~2025-12-19 12:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20251218180205.930961-1-bigfoot@radxa.com>
2025-12-18 18:02 ` [PATCH 1/2] firmware: qcom: scm: Add SCM storage interface support Junhao Xie
2025-12-19 11:45 ` Konrad Dybcio
2025-12-19 17:16 ` Junhao Xie
2026-01-03 17:22 ` Bjorn Andersson
2026-01-05 14:00 ` Junhao Xie
2025-12-18 18:02 ` [PATCH 2/2] mtd: devices: Add Qualcomm SCM storage driver Junhao Xie
2025-12-19 12:05 ` Konrad Dybcio [this message]
2025-12-19 17:12 ` Junhao Xie
2025-12-22 9:43 ` Konrad Dybcio
2025-12-24 11:26 ` Junhao Xie
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=b14c51a0-7e87-4eb2-ae52-caf90f1bf545@oss.qualcomm.com \
--to=konrad.dybcio@oss.qualcomm.com \
--cc=alexander.usyskin@intel.com \
--cc=andersson@kernel.org \
--cc=bigfoot@radxa.com \
--cc=geert+renesas@glider.be \
--cc=konradybcio@kernel.org \
--cc=krzk@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=raag.jadav@intel.com \
--cc=richard@nod.at \
--cc=rodrigo.vivi@intel.com \
--cc=sophon@radxa.com \
--cc=tomasw@gmail.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®