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=1796105703; b=wzsGnMhuQqtFXuk06PuVLFeE4AqOQnC01owW5ofbM4Aj0KkqbyCW5qRJ0k9nXpIAqcBr aBMIa719lqS3N5tWP+tT7rqtZ3001HVmFHtiFe167EB2dNGztJSsKu5018UBv9SlSOIJm wu/VaCTaV5J7hrsMVIIpE9jsI/U3mx/pIWbY4ZGH1fdMBv+j31/DEEI4gBUJ3VhljyAc5 d6heg5SxCFzPXidwlF8V0+w9yzl3A+iRFpNdVFUZ9jzXyuWLPCTM2BY2L0SoMSkMvQar4 DWtFUrznAjaimf6FCRdocp/xHO3lsLRi/V0dRJDE7XVPM11pKSY8w2sxLlsF67T3UzA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796105703; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=lBI1yA9235RtKxpKiJe/QQp0CtQSU7jhOM2v8b0P8SY=; b=oRrFbymIiqrZBVvp05Osh6EGNYYSku8iJiFx0iHxoU7bTH1koO6Ooy1w77TlhTof5Y7H vVWxQt34i1ZpaqEHV3flo0K2vn3ee1gaOVTM6EcIhYyXcdiSBGYRE67qKmHxpudN65Upv Mx6vy59kadRvMMuFjKc7mOzWqXNpVmMhGn+uLw5LV/8n/WWxeHoy6P0U8/UlPqqk4qIqU nbKuoWT4VHbL5NJJeXXUfnRQal76XCmN0hZGOa/WBJOnPlQ+I2piczkGDlE7cPa6sMfmn K3Jhhnw+8af3Njnr0xSI20LzwkrU0IS6yrEiKgiFeTAD9UtMdDYkeTA9mo9ytLXuyNg== 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=M+EWIalJ; 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 C5F6E606A332 for ; Tue, 1 Dec 2026 06:15:03 +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=M+EWIalJ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 006E21F000C1; Tue, 1 Dec 2026 06:15:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796105703; bh=lBI1yA9235RtKxpKiJe/QQp0CtQSU7jhOM2v8b0P8SY=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=M+EWIalJcl2FfbKXNoz/8ExNsKb7IpnUtX/wr3V/DyluMVT5xiBZkJawRR7xaVw4/ X+JPU/444+v/ISe/2ZEoKlepqJGGGQclMbtpifWXMs8JYpfNVKGDX1/O6SYOerAIbQ VatuawKn6gCkAIan1cQKbAz3Axoh6v2gpLtko83o4PfG4QYA3SCHJzYZFPWMhwFY3+ MVSOe4LdMI3k8F6WRmT3txhy0/IpLqzjoVZCxwrFCbdv6Ty96b6tGBhAazu24FzyTy tGrvSJE2pk78+nkZ1ZYyRsnFHmcQVtVT2fw56Rl8ZIZOaTSy5HTFOBF1HZR+VRmnoo IrhD4HyRGafBg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v6 2/3] 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: <20261201-b4-cs7542-nand-v6-2-e6b0d712745b@gmail.com> References: <20261201-b4-cs7542-nand-v6-0-e6b0d712745b@gmail.com> <20261201-b4-cs7542-nand-v6-2-e6b0d712745b@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 06:15:02 +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 1 potential issue to consider: - [High] mtd: rawnand: cs752x: PIO deadline overwritten by WAITRDY timeout -- commit 95d3ff6afab1a14e1b8da8939e0a268251a75175 Author: Fil Dunsky mtd: rawnand: Add Cortina CS7542 controller support This commit adds a raw NAND controller driver for the Cortina Systems CS7542 SoC using programmed I/O, software ECC, and 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..dfd6cbae7bc78 > --- /dev/null > +++ b/drivers/mtd/nand/raw/cs752x_nand.c [ ... ] > +static int cs752x_nand_words(struct cs752x_nand_host *h, u8 *buf, > + unsigned int len, bool write) > +{ > + u32 value; > + unsigned int i; > + int ret; > + > + if (len % sizeof(u32)) > + return -EINVAL; > + for (i =3D 0; i < len; i +=3D sizeof(u32)) { > + if (write) > + fl_writel(h, FLASH_NF_DATA, get_unaligned_le32(buf + i)); > + 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), 1, 10000); [ ... ] > +static int cs752x_nand_supports_op(const struct nand_operation *op, > + struct cs752x_nand_op *p) > +{ > + unsigned int i, state =3D 0; > + > + memset(p, 0, sizeof(*p)); > + p->timeout_ms =3D 100; > + if (op->cs || !op->ninstrs || op->ninstrs > 8) > + return -EOPNOTSUPP; > + for (i =3D 0; i < op->ninstrs; i++) { > + const struct nand_op_instr *in =3D &op->instrs[i]; > + unsigned int j; > + > + p->delay_ns =3D max(p->delay_ns, in->delay_ns); > + switch (in->type) { [ ... ] > + case NAND_OP_WAITRDY_INSTR: > + if (p->wait_ready || !in->ctx.waitrdy.timeout_ms || > + state =3D=3D 3 || state =3D=3D 4) > + return -EOPNOTSUPP; > + p->wait_ready =3D true; > + p->timeout_ms =3D in->ctx.waitrdy.timeout_ms; > + break; > + default: > + return -EOPNOTSUPP; > + } > + } [ ... ] > +static int cs752x_nand_pio(struct cs752x_nand_host *h, > + const struct cs752x_nand_op *p, u8 *buf, > + unsigned int len, bool write) > +{ [ ... ] > + /* The PIO transfer has one budget, independent of the NAND R/B wait. */ > + deadline =3D ktime_get_ns() + p->timeout_ms * (u64)NSEC_PER_MSEC; > + for (i =3D 0; i < max(len, 1U); i +=3D step) { > + u64 now =3D ktime_get_ns(); > + > + if (now >=3D deadline) { > + ret =3D -ETIMEDOUT; > + goto out; > + } > + if (write && len) > + fl_writel(h, FLASH_NF_DATA, get_unaligned_le32(buf + i)); > + fl_writel(h, FLASH_FLASH_ACCESS_START, > + FLASH_START_REGREQ | FLASH_START_CMD(write ? FLASH_WT : FLASH_RD)); > + /* Byte PIO completes in microseconds, below scheduler granularity. */ > + ret =3D readl_poll_timeout_atomic(h->iobase_fl + FLASH_FLASH_ACCESS_ST= ART, > + value, !(value & FLASH_START_REGREQ), 1, > + DIV_ROUND_UP_ULL(deadline - now, NSEC_PER_USEC)); [Severity: High] Does overwriting p->timeout_ms with in->ctx.waitrdy.timeout_ms clobber the 100 ms PIO transfer deadline in cs752x_nand_pio()? Standard NAND read operations such as nand_read_param_page_op() and nand_lp_exec_read_page_op() pass NAND_COMMON_TIMING_MS(conf, tR_max) as the WAITRDY timeout, which is 1 ms in SDR mode 0 (tR_max =3D 200 us). cs752x_nand_pio() then uses that 1 ms p->timeout_ms as the wall-clock deadline for the entire byte-PIO loop (up to 4,608 single-byte iterations for NAND_CMD_PARAM or 4,224 iterations for a 4KiB page read). Because readl_poll_timeout_atomic() is called with delay_us =3D 1 on every byte (and on every 32-bit word in cs752x_nand_words()), each poll iteration that sees FLASH_START_REGREQ still set executes udelay(1), adding 2.1 to 4.6 ms of busy-wait across a single page or parameter read and causing cs752x_nand_pio() to fail with -ETIMEDOUT before the transfer finishes (or whenever the preemptible caller is delayed by 1 ms). Keeping the WAITRDY timeout in a separate field from the PIO transfer budget and passing 0 for delay_us in readl_poll_timeout_atomic() would avoid both the premature timeout and the per-byte udelay(1) overhead. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201-b4-cs7542-= nand-v6-0-e6b0d712745b@gmail.com?part=3D2