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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D4FEC433FE for ; Fri, 26 Nov 2021 14:53:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346117AbhKZO45 convert rfc822-to-8bit (ORCPT ); Fri, 26 Nov 2021 09:56:57 -0500 Received: from relay10.mail.gandi.net ([217.70.178.230]:33781 "EHLO relay10.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239892AbhKZOy4 (ORCPT ); Fri, 26 Nov 2021 09:54:56 -0500 Received: (Authenticated sender: miquel.raynal@bootlin.com) by relay10.mail.gandi.net (Postfix) with ESMTPSA id E6C5724000F; Fri, 26 Nov 2021 14:51:30 +0000 (UTC) Date: Fri, 26 Nov 2021 15:51:28 +0100 From: Miquel Raynal To: Boris Brezillon Cc: Richard Weinberger , Vignesh Raghavendra , Tudor Ambarus , Pratyush Yadav , Michael Walle , , Rob Herring , , Mark Brown , , Xiangsheng Hou , Julien Su , Jaime Liao , Boris Brezillon , Thomas Petazzoni Subject: Re: [PATCH v2 15/20] mtd: spinand: Create direct mapping descriptors for ECC operations Message-ID: <20211126155128.5fba7ec0@xps13> In-Reply-To: <20211126154706.2a528e72@collabora.com> References: <20211126113924.310459-1-miquel.raynal@bootlin.com> <20211126113924.310459-16-miquel.raynal@bootlin.com> <20211126151352.3bdd2c1a@collabora.com> <20211126154223.28c71271@xps13> <20211126154706.2a528e72@collabora.com> Organization: Bootlin X-Mailer: Claws Mail 3.17.7 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Hi Boris, boris.brezillon@collabora.com wrote on Fri, 26 Nov 2021 15:47:06 +0100: > On Fri, 26 Nov 2021 15:42:23 +0100 > Miquel Raynal wrote: > > > > > @@ -866,6 +872,24 @@ static int spinand_create_dirmap(struct spinand_device *spinand, > > > > > > > > spinand->dirmaps[plane].rdesc = desc; > > > > > > > > + info.op_tmpl = *spinand->op_templates.update_cache; > > > > + info.op_tmpl.ecc_en = true; > > > > + desc = devm_spi_mem_dirmap_create(&spinand->spimem->spi->dev, > > > > + spinand->spimem, &info); > > > > + if (IS_ERR(desc)) > > > > + return PTR_ERR(desc); > > > > + > > > > + spinand->dirmaps[plane].wdesc_ecc = desc; > > > > + > > > > + info.op_tmpl = *spinand->op_templates.read_cache; > > > > + info.op_tmpl.ecc_en = true; > > > > + desc = devm_spi_mem_dirmap_create(&spinand->spimem->spi->dev, > > > > + spinand->spimem, &info); > > > > + if (IS_ERR(desc)) > > > > + return PTR_ERR(desc); > > > > + > > > > + spinand->dirmaps[plane].rdesc_ecc = desc; > > > > + > > > > > > Direct mappings are not free (they might reserve a piece of MMIO > > > address space depending on the spi-mem controller implementation), so > > > I'd recommend creating those mapping only when strictly needed, that > > > is, when dealing with a pipelined ECC. > > > > That's what I tried to do in the first place, but unfortunately the > > direct mappings are instantiated at the time the SPI controller gets > > probed, which happens before the NAND flash being initialized and its > > ECC engine being picked. Hence, at this point, we don't really know what > > engine will be used with this ECC engine. I finally gave up and ended > > up creating 4 dirmaps (per lun). I know it's not optimal and in most > > cases consume more address space than needed but couldn't find a > > better solution yet :/ > > Why do you have to create the ECC mappings that early? Can't you just > create them after the ECC initialization is done? AFAICT, they won't be > used before that anyway. Yeah that's right, maybe we don't need them that early. I'll move things around and try that out. Thanks! Miquèl