U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Yalçın Can" <ylcncn@gmail.com>
To: u-boot@lists.u-boot-project.org
Cc: Dario Binacchi <dario.binacchi@amarulasolutions.com>,
	Michael Trimarchi <michael@amarulasolutions.com>,
	Kever Yang <kever.yang@rock-chips.com>,
	Quentin Schulz <u-boot@0leil.net>, Simon Glass <sjg@chromium.org>,
	Tom Rini <trini@konsulko.com>
Subject: [PATCH] mtd: rawnand: rockchip_nfc: set mtd->dev instead of writing through NULL
Date: Fri, 30 Oct 2026 10:37:05 +0300	[thread overview]
Message-ID: <20261030073705.164572-1-ylcncn@gmail.com> (raw)

rk_nfc_nand_chip_init() does `mtd->dev->parent = dev`, taken from Linux,
where the device is embedded in struct mtd_info. In U-Boot mtd->dev is a
pointer and still NULL at this point, so this writes dev to address 0x18.

Harmless while address 0 is RAM; on the RK3066 started from the boot ROM it
is the ROM, and the write ends in an asynchronous external abort.

Set mtd->dev to the controller device instead, as other raw NAND drivers
do.

Tested on an MK808B (RK3066) from the NAND ID blocks (H27UCG8T2BTR).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Yalçın Can <ylcncn@gmail.com>
---
 drivers/mtd/nand/raw/rockchip_nfc.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/rockchip_nfc.c b/drivers/mtd/nand/raw/rockchip_nfc.c
index d23a651f..c134045d 100644
--- a/drivers/mtd/nand/raw/rockchip_nfc.c
+++ b/drivers/mtd/nand/raw/rockchip_nfc.c
@@ -948,7 +948,12 @@ static int rk_nfc_nand_chip_init(ofnode node, struct rk_nfc *nfc, int devnum)
 
 	mtd = nand_to_mtd(chip);
 	mtd->owner = THIS_MODULE;
-	mtd->dev->parent = dev;
+	/*
+	 * mtd->dev is still NULL here: `mtd->dev->parent = dev` (from Linux, where dev is embedded)
+	 * wrote to address 0x18. Harmless only while 0 is RAM; on RK3066 started from the boot ROM
+	 * (soc_remap = 0) it is the ROM, and the write ends in an asynchronous external abort.
+	 */
+	mtd->dev = dev;
 
 	nand_set_controller_data(chip, nfc);
 
-- 
2.47.3


                 reply	other threads:[~2026-10-30 12:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261030073705.164572-1-ylcncn@gmail.com \
    --to=ylcncn@gmail.com \
    --cc=dario.binacchi@amarulasolutions.com \
    --cc=kever.yang@rock-chips.com \
    --cc=michael@amarulasolutions.com \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@0leil.net \
    --cc=u-boot@lists.u-boot-project.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