From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 694FBCED62A for ; Wed, 9 Oct 2024 08:16:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Subject:Cc:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=4ZqUu2zXtpPIFf6u2ipPatyPzUjw/B5iwIYSh3KUBBk=; b=i+MnPl8NqTM6KGEaWisfJBJX8K YSf4xzjGCt1csuHn0BA6UeiQBqdxqAihoR17RXZKio1RBxyctSJMzixBuAIZSXd1wMebgscfP/vAe VYFlzKJ+OjqGkAUL/8zF4D2eH0THOkJWHtsXo46cQIeA44gU6Sc+QVfkZWrJghAcgYohSNahxqo2E qZwCUR9vLnegCwxL+4OHMPln+gmXOZuOmt4yG9N6sF0+ylgmxP28IXfcXCdRl9ltFdGnE9pN+UQWn 55k4TSa87H86Oe/hTeGuZo30v7YAoc/CxIWoneSfem46rrvpAeLggGprx5aYUwxlIPG+DjABknn7e kxTkA+3w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1syRrM-00000008Osm-3DBo; Wed, 09 Oct 2024 08:15:52 +0000 Received: from relay1-d.mail.gandi.net ([2001:4b98:dc4:8::221]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1syRgm-00000008MsA-1jm4; Wed, 09 Oct 2024 08:04:58 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id D55AB240002; Wed, 9 Oct 2024 08:04:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1728461092; 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=4ZqUu2zXtpPIFf6u2ipPatyPzUjw/B5iwIYSh3KUBBk=; b=CET+bD2aQpIFbn83eKT+JAQlvpdrc0gESxRVHARr0UpzskXaayoxehxFYpeqV2I+pGYHf7 xSvkBl7b89C/+0Gdk47ezTrP7u6qPBIGR5kwqsIzgc3ZKH3047DghYSSp6FbBjBZvoxqlu j6zm6Afpuenl/O0Lyd9lpC3DzF1Z91xyY1qE//1L7iEPG9apRogWNH7xuYpKJxsEJ0vFR8 f7awQRGnelx1xTR53a07BHU3UMyrCGrqIJqTl366jh6Nmmxl0DzFyVPbWQkTKSy/mEAo4/ 0QUCeD6U6SN9pWklqIOJ4bFozd3MC1LJrrtFwXUpIuM/vk9XRWdRR6ANHh7WTg== Date: Wed, 9 Oct 2024 10:04:50 +0200 From: Miquel Raynal To: Hui-Ping Chen Cc: richard@nod.at, vigneshr@ti.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, nikita.shubin@maquefel.me, arnd@arndb.de, vkoul@kernel.org, esben@geanix.com, linux-arm-kernel@lists.infradead.org, linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 2/2] mtd: rawnand: nuvoton: add new driver for the Nuvoton MA35 SoC Message-ID: <20241009100450.362e3556@xps-13> In-Reply-To: <02098767-19ce-407e-88be-24c6259c4053@gmail.com> References: <20240927020749.46791-1-hpchen0nvt@gmail.com> <20240927020749.46791-3-hpchen0nvt@gmail.com> <20241001215755.5c2f8465@xps-13> <8d5e7755-17fd-4860-bcb0-8c1de04bf0c5@gmail.com> <20241008105230.7fd25438@xps-13> <02098767-19ce-407e-88be-24c6259c4053@gmail.com> Organization: Bootlin X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: miquel.raynal@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241009_010456_968856_604A98FE X-CRM114-Status: GOOD ( 17.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Hui-Ping, > >>>> + return 0; > >>>> + } > >>>> + > >>>> + ma35_nand_dmac_init(nand); > >>>> + > >>>> + writel(mtd->oobsize, nand->regs + MA35_NFI_REG_NANDRACTL); > >>>> + > >>>> + /* setup and start DMA using dma_addr */ > >>>> + dma_addr =3D dma_map_single(nand->dev, (void *)addr, len, DMA_FROM= _DEVICE); > >>>> + ret =3D dma_mapping_error(nand->dev, dma_addr); > >>>> + if (ret) { > >>>> + dev_err(nand->dev, "dma mapping error\n"); > >>>> + return -EINVAL; > >>>> + } > >>>> + > >>>> + writel((unsigned long)dma_addr, nand->regs + MA35_NFI_REG_DMASA); = =20 > >>> Please enforce a dma mask of 32 (even though it might be the fault). = =20 > >> I will change it to dma_addr & 0xffffffff. =20 > > That's not what I mean, I believe you should use the dma API to ask for > > a mapping within the accessible 32-bit address range. The > > dma_mapping_error() check should return an error if that's not the > > case. Then you can safely write the value. =20 >=20 > Here is my misunderstanding: just fill in the dma_addr directly, >=20 > no type conversion is needed. I have already tested it. FYI, it only works because the default DMA mask for your device is gonna be 32 bits. If the reality (what your peripheral DMA can do) was different than this, you would have to set a different mask explicitly to make sure the dma-mapping step would not provide buffers which are out of reach. Thanks, Miqu=C3=A8l