From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796396734; b=PJuUXvI5+mPB3Umd4NIPGwWcoPCdW1299X9Zt0GPcLm+VvZ9shsv58BHeZ4LoCwJZSjQ 5CwIDNA5uM58EY0HE9Bx2qc7dwinRqhIeTtUAFmysXIyT281/YtChwTkgOo+Zj0u3cLqT hZkON0Qljl6FVHFNpmTvh74GyjTpBShWFWJVobjxM2S57jCppBPjSG1Gm/NsM3GqZIGBh 1lFwBtGji9L5bHLd/OPmS8LlqM0Ro0Bj23ruEULBLYXTDOnDDT+jco4pozrRanA1zKrcv hFKZRf4kNgYugIcBEsVb1O/rvWP+PmQ8k0ArIZuIuEJs02Koy4VGGJdz62FBjk7uLPQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796396734; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=6MpZq/Upcz6MVW1KmTUUPcwCbNGgOTlBNaBRkY6MEco=; b=qFvWVK/n/h/8+GGBqrPmGIQ3Q3vSV4ksoX1KFrh085wQsHVYfsH7dD/GAYi5/xnFd1o4 XXr7mzbauIqOhavCUZWQtO3IUAAicgJGFao5eihjF1sWkOao4Q42/guJ3T3+QC2ydumxa yp0S9HZo+7+N4r8oF2goCbKHys8tXhMieCqheljbZe93xIheZbdTAFc6nBeERMD0q5Klk CDOald8rCe6H5e+aSjk15KYQ5Emp52ekYkOA0v/8T2U3Dw9s93twUZpRaTto8TYB2XLDN OicMua2a55VnpgAEHA+ziJhBY/5bZbKKuTAS9R/R1iBf6hyvKa0WDBAZCCSnCSB27Ug== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UH3VDb0y; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9749B606A32D for ; Fri, 4 Dec 2026 15:05:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UH3VDb0y Received: by smtp.kernel.org (Postfix) with ESMTPSA id D704C1F0092C; Fri, 4 Dec 2026 15:05:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796396734; bh=6MpZq/Upcz6MVW1KmTUUPcwCbNGgOTlBNaBRkY6MEco=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=UH3VDb0yScGPGZbM/hu6ksQeyg1Q5kjJe5Q9CdBITzVm30Y/XS59LwAmrvrlW6nUs RhfmfIjR0TuzXIUcIl9p1Zxr3Lk3YvWbA45YAZw/jclRtdjGg2kdqxrXydvUn1X74K qMQ6Afe7WZzeZOBddgYljg3wJO5TadQENeOjXI26O+9NHRhJHCTM6lUx//4aq1Xz7J i/fN9mlQGinFbotkW+n3HPS3rpI/QCDOgOD8r6e9y9iP9SrzNKyi6P88AzNR/uyAwt vTJ7x2oqqGQNYw/bpnbIafgd0mi+P4Ep/PcdYOciLmKTMvQMSH7za2tP/lPWUecS2m +ISeatfLhHSbQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v8 3/4] mtd: rawnand: Add Cortina CS7542 controller support Reply-To: sashiko-reviews@lists.linux.dev To: "Fil Dunsky" , "Miquel Raynal" , "Richard Weinberger" , "Vignesh Raghavendra" , "Rob Herring" , "Krzysztof Kozlowski" , "Conor Dooley" , "Philipp Zabel" Cc: linux-mtd@lists.infradead.org, devicetree@vger.kernel.org In-Reply-To: <20261204-b4-cs7542-nand-v8-3-bb068644f71f@gmail.com> References: <20261204-b4-cs7542-nand-v8-0-bb068644f71f@gmail.com> <20261204-b4-cs7542-nand-v8-3-bb068644f71f@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 15:05:33 +0000 X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 6 potential issues to consider: - [High] mtd: rawnand: cs752x_nand_probe() takes and pulses shared reset exclusively - [Medium] mtd: rawnand: missing FSM reset on timeout in cs752x_nand_pio() and ECC - [Medium] mtd: rawnand: sleeping readl_poll_timeout() in mtd_panic_write() context - [Medium] mtd: rawnand: cs752x: per-word udelay(1) in cs752x_nand_words() - [Medium] mtd: rawnand: cs752x: zero-slack usleep_range(1, 1) hrtimer storms - [Low] mtd: rawnand: cs752x_nand_exec_op() rejects op->cs on check_only probes -- commit 65996877e86929ea6a1fd88c61cb2bb3794c71d1 Author: Fil Dunsky mtd: rawnand: Add Cortina CS7542 controller support This commit adds a raw NAND controller driver for the Cortina CS7542 using programmed I/O, software ECC, and 256-byte hardware Hamming ECC. > diff --git a/drivers/mtd/nand/raw/cs752x_nand.c b/drivers/mtd/nand/raw/cs= 752x_nand.c > new file mode 100644 > index 0000000000000..690067b9bafa7 > --- /dev/null > +++ b/drivers/mtd/nand/raw/cs752x_nand.c > @@ -0,0 +1,756 @@ [ ... ] > +static int check_flash_ctrl_status(struct cs752x_nand_host *h) > +{ > + u32 val; > + int ret; > + > + ret =3D readl_poll_timeout(h->iobase_fl + FLASH_STATUS, val, > + !(val & FLASH_STATUS_NSTATE_MASK), 1, 1000000); > + if (ret) > + dev_err(h->dev, "FLASH_STATUS busy: 0x%x\n", val); > + return ret; > +} > + > +static int wait_reg(struct cs752x_nand_host *h, u32 reg, u32 bit, const = char *what) > +{ > + u32 val; > + int ret; > + > + ret =3D readl_poll_timeout(h->iobase_fl + reg, val, val & bit, 1, 20000= 00); > + if (ret) > + dev_err(h->dev, "%s timeout\n", what); > + return ret; > +} [Severity: Medium] Can check_flash_ctrl_status(), wait_reg(), and cs752x_nand_wait_ready() sleep in atomic context during mtd_panic_write()? nand_scan_tail() sets mtd->_panic_write =3D panic_nand_write, which reaches these helpers via nand_do_write_ops() during a panic dump (e.g. mtdoops). With sleep_us =3D 1, readl_poll_timeout() invokes might_sleep_if() and usleep_range(), risking scheduling-while-atomic warnings or a hang. Checking mtd->oops_panic_write to use readl_poll_timeout_atomic() (or clearing mtd->_panic_write if panic writes are not supported) avoids this. [ ... ] > + fl_writel(h, FLASH_FLASH_ACCESS_START, > + FLASH_START_REGREQ | FLASH_START_CMD(write ? FLASH_WT : FLASH_RD)); > + ret =3D readl_poll_timeout_atomic(h->iobase_fl + FLASH_FLASH_ACCESS_ST= ART, > + value, !(value & FLASH_START_REGREQ) || > + ktime_get_ns() >=3D deadline, 1, 10000); [Severity: Medium] Does passing delay_us =3D 1 to readl_poll_timeout_atomic() force a udelay(1) busy-wait on every 4-byte word in cs752x_nand_words()? Four 8-bit NAND bus cycles take longer than one MMIO turnaround, so the first read usually sees FLASH_START_REGREQ set and stalls in udelay(1), adding over 1 ms of busy-waiting per 4KB+128B page. Tight-polling with delay_us =3D 0, as in cs752x_nand_pio(), avoids this per-word stall. [ ... ] > +static int cs752x_nand_wait_ready(struct cs752x_nand_host *h, > + unsigned int timeout_ms) > +{ > + const struct nand_interface_config *conf; > + u32 value; > + > + /* R/B can remain high for tWB after a command has been issued. */ > + conf =3D nand_get_interface_config(&h->chip); > + ndelay(NAND_COMMON_TIMING_NS(conf, tWB_max)); > + > + /* nflash_rbIn_d is the sampled NAND R/B input, not the FSM state. */ > + return readl_poll_timeout(h->iobase_fl + FLASH_STATUS, value, > + value & BIT(26), 1, (u64)timeout_ms * 1000); > +} [Severity: Medium] Will passing sleep_us =3D 1 to readl_poll_timeout() here (and in check_flash_ctrl_status() and wait_reg()) cause hrtimer interrupt storms? poll_timeout_us() converts sleep_us =3D 1 to usleep_range(1, 1), which arms a zero-slack hrtimer 1 us ahead on every iteration. Across a multi-ms block erase or multi-hundred-us page program, that fires hundreds to thousands of back-to-back timer interrupts and context switches. Using a larger sleep_us (such as 20 us, giving usleep_range(6, 20) with slack) reduces timer overhead while waiting on R/B. [ ... ] > +static int cs752x_nand_pio(struct cs752x_nand_host *h, > + const struct cs752x_nand_op *p, u8 *buf, > + unsigned int len, bool write) > +{ > + u64 deadline; > + u32 value; > + unsigned int i, step =3D write && len ? sizeof(u32) : 1; > + int ret; > + > + ret =3D check_flash_ctrl_status(h); > + if (ret) > + return ret; > + reset_ecc_bch_registers(h); [Severity: Medium] Should cs752x_nand_pio() use cs752x_page_op_begin() so a busy timeout resets the controller FSM? Unlike cs752x_page_op_begin(), returning directly here skips writing ECC_RESET_NF_RESET to FLASH_NF_ECC_RESET. If the FSM wedges busy (for example in software-ECC mode where cs752x_page_op_begin() is never called), subsequent PIO and nand_reset_op() calls fail with -ETIMEDOUT. Similarly, if wait_reg() times out in hamming_correct(), it returns early without clearing ECC_CTL_EN or asserting FLASH_NF_ECC_RESET, leaving the ECC engine active after cs752x_nand_hwecc_op(). [ ... ] > +static int cs752x_nand_exec_op(struct nand_chip *chip, > + const struct nand_operation *op, bool check_only) > +{ > + unsigned int i; > + int ret; > + > + if (op->cs || !op->ninstrs) > + return -EOPNOTSUPP; [Severity: Low] Does rejecting non-zero op->cs unconditionally break nand_check_op() probes when no target is selected? nand_scan_tail() deselects the target (chip->cur_cs =3D -1) before rawnand_late_check_supported_ops() probes continuous cached reads via nand_check_op(). Checking op->cs only when !check_only avoids silently disabling continuous reads on read-cache-capable chips under software ECC. [ ... ] > + reset =3D devm_reset_control_get_optional_exclusive(dev, NULL); > + if (IS_ERR(reset)) > + return dev_err_probe(dev, PTR_ERR(reset), "flash reset\n"); > + > + if (reset) { > + err =3D reset_control_assert(reset); > + if (err) > + return dev_err_probe(dev, err, "assert flash reset\n"); > + > + udelay(2); > + err =3D reset_control_deassert(reset); > + if (err) > + return dev_err_probe(dev, err, "release flash reset\n"); > + } [Severity: High] Can cs752x_nand_probe() request and pulse the flash controller reset exclusively when the DT binding documents it as shared? Documentation/devicetree/bindings/mtd/cortina,cs7542-nand.yaml defines resets as "Shared flash controller reset". When another driver shares the line, __reset_control_get_internal() triggers WARN_ON() and returns -EBUSY; if this driver probes first, it blocks and resets active siblings. Asserting the reset before validating the NAND child node also pulses the shared line even on an invalid DT configuration. Requesting a shared reset (e.g. devm_reset_control_get_optional_shared()) matches the binding. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204-b4-cs7542-= nand-v8-0-bb068644f71f@gmail.com?part=3D3