From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 99F1E158D98; Mon, 12 Aug 2024 07:46:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723448794; cv=none; b=gl9PgfaKE23CqVyvCfcDSoJ6KozKXHHymXlydOxFFjzmhfZYF+UTNIAKiJCACSlwxO4Plbe4aCdq35Nx/UN6rT74FUfa8CyiLFuPpc5mvYWoNN3zOX2URsxZIFY2S7F14S11t0jjcsLyIqDVElGecyMLQZi9rvgXZklKcTk/wUI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723448794; c=relaxed/simple; bh=JwipMYReCtFtkI5rIct0HTrq5vaYhQxFIjXpOW2cNW4=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cDs/i/GnXEutH186tZWyv68ckM4LZbZ8nSguYKaRfPr4YfD1VQ8GaXHMRILJDY+rdKXzVvfZgTuL3bhLUYCA2XyyzW6F5EkWHvLeyo8Y1TTVYhAnhBkna+D2NvWdCVkjjQWV47wx5VQte9wY9DBa5yX35eUTULE9Lj+glbZEaAQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=Z4mW4LdR; arc=none smtp.client-ip=217.70.183.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="Z4mW4LdR" Received: by mail.gandi.net (Postfix) with ESMTPSA id C0BAA60002; Mon, 12 Aug 2024 07:46:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1723448783; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EYJhz07idCmll0VNWnjmDisDihkjE0werNys1pVEO3Q=; b=Z4mW4LdRNvEZqdaZMcyTuoJ7VIbeeqc2hHDGsKNErW76JnRwY5FwmpMf+Yh+wWhT62BoZo VRn71biGCirvzb/WFkktT/vY8XMYPaLERYFBoD43yk+O1ad2nJIbTMiWdyc13CguY/RU/+ kkG2AE9qoqiioGlJO144gJkUBblehNG8ZDzghMNO1MVwHVN75m6NeQ+5K7XsNvMe19gsf+ NcMb9hghIJ9plw1Bxl2T6zC7EzpqPvpXcqi1WUeDqgOtFZpXtQ7YjQQzHT8j78pGCw0sVE ZKIq3ZDtUnUqynJRm8ObF/CH1NWfKNyxdM13zCav9u4dKssOoKvxS34BXohEsQ== Date: Mon, 12 Aug 2024 09:46:21 +0200 From: Miquel Raynal To: Keguang Zhang Cc: Keguang Zhang via B4 Relay , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, devicetree@vger.kernel.org Subject: Re: [PATCH v7 3/3] mtd: rawnand: Add Loongson-1 NAND Controller driver Message-ID: <20240812094621.1f4954d4@xps-13> In-Reply-To: References: <20240430-loongson1-nand-v7-0-60787c314fa4@gmail.com> <20240430-loongson1-nand-v7-3-60787c314fa4@gmail.com> <20240506095938.4a910adc@xps-13> Organization: Bootlin X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: miquel.raynal@bootlin.com Hi Keguang, > > > + > > > + nfc->data->parse_address(chip, addrs, naddrs, c= md); > > > + /* set NAND address */ > > > + nand_writel(nfc, NAND_ADDR1, nfc->addr1_reg); > > > + nand_writel(nfc, NAND_ADDR2, nfc->addr2_reg); > > > + break; > > > + case NAND_OP_DATA_IN_INSTR: > > > + case NAND_OP_DATA_OUT_INSTR: > > > + offset =3D nand_subop_get_data_start_off(subop,= op_id); > > > + nfc->len =3D nand_subop_get_data_len(subop, op_= id); > > > + if (instr->type =3D=3D NAND_OP_DATA_IN_INSTR) > > > + nfc->buf =3D > > > + (void *)instr->ctx.data.buf.in + of= fset; > > > + else if (instr->type =3D=3D NAND_OP_DATA_OUT_IN= STR) > > > + nfc->buf =3D > > > + (void *)instr->ctx.data.buf.out + o= ffset; =20 > > > > The buf pointer feels clunky. You don't know for how long the buffer > > you point to will be valid, please don't do that. > > =20 > The buf pointer is used for DMA transfer afterwards. > I referred to other drivers, and they used the same approach. > https://elixir.bootlin.com/linux/v6.8.9/source/drivers/mtd/nand/raw/arasa= n-nand-controller.c#L647 nfc_op is a local variable, it doesn't live past the function call. > https://elixir.bootlin.com/linux/v6.8.9/source/drivers/mtd/nand/raw/rockc= hip-nand-controller.c#L366 Thanks, Miqu=C3=A8l