From: Neil Armstrong <neil.armstrong@linaro.org>
To: petr.hodina@protonmail.com, u-boot@lists.u-boot-project.org,
Sumit Garg <sumit.garg@kernel.org>,
u-boot-qcom@groups.io
Cc: Bhupesh Sharma <bhupesh.linux@gmail.com>,
Neha Malcom Francis <n-francis@ti.com>,
Casey Connolly <casey.connolly@linaro.org>,
Tom Rini <trini@konsulko.com>,
Angelo Gioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
David Heidelberg <david@ixit.cz>,
Marek Vasut <marek.vasut+renesas@mailbox.org>,
Padmarao Begari <padmarao.begari@amd.com>,
Macpaul Lin <macpaul.lin@mediatek.com>,
Julien Stephan <jstephan@baylibre.com>,
Kunihiko Hayashi <hayashi.kunihiko@socionext.com>,
Shawn Lin <shawn.lin@rock-chips.com>,
Jared McArthur <j-mcarthur@ti.com>,
Michal Simek <michal.simek@amd.com>, Udit Kumar <u-kumar1@ti.com>,
Igor Belwon <igor.belwon@mentallysanemainliners.org>,
Tuyen Dang <tuyen.dang.xa@renesas.com>,
Alexey Charkov <alchark@gmail.com>,
Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>,
Simon Glass <sjg@chromium.org>,
Aswin Murugan <aswin.murugan@oss.qualcomm.com>,
Bin Meng <bmeng.cn@gmail.com>,
Marek Vasut <marek.vasut@mailbox.org>,
David Lechner <dlechner@baylibre.com>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Kory Maincent <kory.maincent@bootlin.com>,
Peng Fan <peng.fan@nxp.com>, Kuan-Wei Chiu <visitorckw@gmail.com>,
Janne Grunau <j@jannau.net>, Julien Masson <jmasson@baylibre.com>,
Raymond Mao <raymond.mao@riscstar.com>,
Quentin Schulz <quentin.schulz@cherry.de>,
Philip Molloy <philip.molloy@analog.com>,
Jerome Forissier <jerome.forissier@arm.com>,
Markus Niebel <Markus.Niebel@ew.tq-group.com>,
Petr Pavlata <petr@acrux.cz>
Subject: Re: [PATCH u-boot 5/8] scsi: ufs: refuse erase/UNMAP on NO_PURGE devices
Date: Mon, 5 Oct 2026 11:37:47 +0200 [thread overview]
Message-ID: <66a2ec2d-ae66-483d-9506-658cdb7c2e1e@linaro.org> (raw)
In-Reply-To: <20261004-b4-ufs-sony-v1-5-54e71c95ba62@protonmail.com>
Hi,
On 10/4/26 21:22, Petr Hodina via B4 Relay wrote:
> From: Petr Hodina <petr.hodina@protonmail.com>
>
> Enforce the UFS_DEVICE_QUIRK_NO_PURGE quirk on U-Boot's only path that
> can reach a UFS device with a destructive UNMAP: the block-device erase
> op (scsi_erase() -> SCSI_UNMAP). On Sony Yoshino/Tama a PURGE/UNMAP
> erases the bootloader and permanently bricks the device.
>
> Signed-off-by: Petr Hodina <petr.hodina@protonmail.com>
> ---
> drivers/scsi/scsi.c | 5 +++++
> drivers/ufs/ufs-uclass.c | 12 ++++++++++++
> include/scsi.h | 5 +++++
> 3 files changed, 22 insertions(+)
>
> diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
> index 50e7d749921..ba7834ea035 100644
> --- a/drivers/scsi/scsi.c
> +++ b/drivers/scsi/scsi.c
> @@ -300,6 +300,11 @@ static ulong scsi_erase(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt)
> lbaint_t start, blks, max_blks, blocks;
> struct scsi_cmd *pccb = (struct scsi_cmd *)&tempccb;
>
> + if (uc_plat->no_erase) {
> + printf("%s: erase not supported on this device\n", __func__);
> + return 0;
> + }
> +
> /* Setup device */
> pccb->target = block_dev->target;
> pccb->lun = block_dev->lun;
> diff --git a/drivers/ufs/ufs-uclass.c b/drivers/ufs/ufs-uclass.c
> index 977ffebc21f..7dfba3ac1ac 100644
> --- a/drivers/ufs/ufs-uclass.c
> +++ b/drivers/ufs/ufs-uclass.c
> @@ -2366,6 +2366,18 @@ int ufshcd_probe(struct udevice *ufs_dev, struct ufs_hba_ops *hba_ops)
> if (err)
> return err;
>
> + /*
> + * Some devices must never receive a PURGE / UNMAP (secure erase): on
> + * the affected platforms it erases the bootloader and permanently
> + * bricks the device. Disable the SCSI erase op for the whole UFS
> + * device in that case.
> + */
> + if (hba->dev_quirks & UFS_DEVICE_QUIRK_NO_PURGE) {
> + scsi_plat->no_erase = true;
> + dev_info(hba->dev,
> + "NO_PURGE quirk active: SCSI erase/UNMAP disabled\n");
> + }
> +
> return 0;
> }
>
> diff --git a/include/scsi.h b/include/scsi.h
> index 2520a8b8fe6..fc296285dd5 100644
> --- a/include/scsi.h
> +++ b/include/scsi.h
> @@ -275,6 +275,11 @@ struct scsi_plat {
> unsigned long max_lun;
> unsigned long max_id;
> unsigned long max_bytes_per_req;
> + /*
> + * Set by the controller driver to forbid the erase (UNMAP) operation,
> + * e.g. for UFS devices whose PURGE/UNMAP would erase the bootloader.
> + */
> + bool no_erase;
To avoid proliferation of variables here, could you add a quirks variable instead and
move the no_erase into a SCSI quirk define.
Thanks,
Neil
> };
>
> /* Operations for SCSI */
>
next prev parent reply other threads:[~2026-10-05 13:31 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-04 19:22 [PATCH u-boot 0/8] ufs: Sony Yoshino/Tama (MSM8998 / SDM845) UFS bring-up Petr Hodina via B4 Relay
2026-10-04 19:22 ` Petr Hodina
2026-10-04 19:22 ` [PATCH u-boot 1/8] ufs: read product revision and spec version into ufs_dev_desc Petr Hodina via B4 Relay
2026-10-04 19:22 ` Petr Hodina
2026-10-04 19:22 ` [PATCH u-boot 2/8] ufs: add device-quirk infrastructure Petr Hodina via B4 Relay
2026-10-04 19:22 ` Petr Hodina
2026-10-05 9:40 ` Neil Armstrong
2026-10-06 13:23 ` phodina
2026-10-06 13:31 ` Neil Armstrong
2026-10-06 13:39 ` phodina
2026-10-04 19:22 ` [PATCH u-boot 3/8] ufs: program extended HS sync length for SK Hynix devices Petr Hodina via B4 Relay
2026-10-04 19:22 ` Petr Hodina
2026-10-04 19:22 ` [PATCH u-boot 4/8] ufs: add CONFIG_UFS_RESTRICT_TX_LANES Petr Hodina via B4 Relay
2026-10-04 19:22 ` Petr Hodina
2026-10-05 9:41 ` Neil Armstrong
2026-10-04 19:22 ` [PATCH u-boot 5/8] scsi: ufs: refuse erase/UNMAP on NO_PURGE devices Petr Hodina via B4 Relay
2026-10-04 19:22 ` Petr Hodina
2026-10-05 9:37 ` Neil Armstrong [this message]
2026-10-04 19:22 ` [PATCH u-boot 6/8] ufs: print device information at probe Petr Hodina via B4 Relay
2026-10-04 19:22 ` Petr Hodina
2026-10-05 9:36 ` Neil Armstrong
2026-10-04 19:22 ` [PATCH u-boot 7/8] ufs: gate NO_PURGE on Sony Yoshino/Tama platform compatible Petr Hodina via B4 Relay
2026-10-04 19:22 ` Petr Hodina
2026-10-04 19:22 ` [PATCH u-boot 8/8] arm: dts: qcom: akatsuki: re-enable the UFS controller node Petr Hodina via B4 Relay
2026-10-04 19:22 ` Petr Hodina
2026-10-04 19:30 ` [PATCH u-boot 0/8] ufs: Sony Yoshino/Tama (MSM8998 / SDM845) UFS bring-up David Heidelberg
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=66a2ec2d-ae66-483d-9506-658cdb7c2e1e@linaro.org \
--to=neil.armstrong@linaro.org \
--cc=Markus.Niebel@ew.tq-group.com \
--cc=alchark@gmail.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=aswin.murugan@oss.qualcomm.com \
--cc=balaji.selvanathan@oss.qualcomm.com \
--cc=bhupesh.linux@gmail.com \
--cc=bmeng.cn@gmail.com \
--cc=casey.connolly@linaro.org \
--cc=david@ixit.cz \
--cc=dlechner@baylibre.com \
--cc=hayashi.kunihiko@socionext.com \
--cc=igor.belwon@mentallysanemainliners.org \
--cc=ilias.apalodimas@linaro.org \
--cc=j-mcarthur@ti.com \
--cc=j@jannau.net \
--cc=jerome.forissier@arm.com \
--cc=jmasson@baylibre.com \
--cc=jstephan@baylibre.com \
--cc=kory.maincent@bootlin.com \
--cc=macpaul.lin@mediatek.com \
--cc=marek.vasut+renesas@mailbox.org \
--cc=marek.vasut@mailbox.org \
--cc=michal.simek@amd.com \
--cc=n-francis@ti.com \
--cc=padmarao.begari@amd.com \
--cc=peng.fan@nxp.com \
--cc=petr.hodina@protonmail.com \
--cc=petr@acrux.cz \
--cc=philip.molloy@analog.com \
--cc=quentin.schulz@cherry.de \
--cc=raymond.mao@riscstar.com \
--cc=shawn.lin@rock-chips.com \
--cc=sjg@chromium.org \
--cc=sumit.garg@kernel.org \
--cc=trini@konsulko.com \
--cc=tuyen.dang.xa@renesas.com \
--cc=u-boot-qcom@groups.io \
--cc=u-boot@lists.u-boot-project.org \
--cc=u-kumar1@ti.com \
--cc=visitorckw@gmail.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 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.