Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1443142imm; Sun, 27 May 2018 07:07:20 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp/KnoSC3UQILcrCQ9BXyhCq5cuQknXjmvAOnZs+9rLneMOI6TXq2fMxOJsQdDT7azsO3LQ X-Received: by 2002:a17:902:2f84:: with SMTP id t4-v6mr10310939plb.24.1527430040845; Sun, 27 May 2018 07:07:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527430040; cv=none; d=google.com; s=arc-20160816; b=KTsfNB1jdKvsAPDmsxg8rmLvsPUrQyyQiUCG5OH0XpP9cins0LH6ofbgH2KUUDWo7x 81NYMsEPcFalPtSLcDxD2/ch23PXjNRkHGT+OeJ3xiCojDOTUk82O4O5FihK6Dj5uJj5 XK9ovf6jj99T+i5nlO/BK9MccFAMNjDWsAzkrepqbbfReBaZNSU88J5XHimj5AfJyseB mSuo+qVw3JZ4/sw3IP8qyavpq08KpMKbWnYqKH25G2SlSOqVAMbMk+MdegLRtq5I84T0 VaOrNzACt9n1fbIXpBbSwm4vgMJP1iDisaRmI+wvCExh+VZmXhUVp07vkR7FNcg4boqK FwBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:arc-authentication-results; bh=vKIHjYsXzvBW/otDsC2Guxbkf5RWRgHlC6gKrR09FZE=; b=AEg0X1NUE4ZXw11biY2oUJgEUouhn+OrL2N6v4lUEfXN1wiqRqKJA4j6bVAheV8Rzi VEhXkF763KNo6ZflGkUfzT4VRJR+fJs8EcKldidwkirlGY8oYvZ2v7B5BtW1s2dVeMoZ zSgQ5pAUD6FbiKDf95lq9rhP8bOmt0HCAo0+Rvd/3LsxTEN0W+3bTLwmzyIOekCxryGx N4T7D2z9sTlqOKYmzCJYRFfLtSzAxw563GNzPZjj/Yab9g4CccQ9U4qMt64g8NQ7a+Io 35p/LlrWfOHsbgeSF1OJMt/gcEYlaINW65WmDF4H+IVpUpd7gfkIqA7A5klnHKFCNy68 nUOQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o1-v6si17553334pga.261.2018.05.27.07.07.05; Sun, 27 May 2018 07:07:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S968429AbeE0OGz convert rfc822-to-8bit (ORCPT + 99 others); Sun, 27 May 2018 10:06:55 -0400 Received: from mail.bootlin.com ([62.4.15.54]:50915 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965011AbeE0OGy (ORCPT ); Sun, 27 May 2018 10:06:54 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 0AD2E20787; Sun, 27 May 2018 16:06:53 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from xps13 (unknown [37.169.232.104]) by mail.bootlin.com (Postfix) with ESMTPSA id 102AE2055A; Sun, 27 May 2018 16:06:50 +0200 (CEST) Date: Sun, 27 May 2018 16:06:48 +0200 From: Miquel Raynal To: Stefan Agner Cc: Boris Brezillon , dwmw2@infradead.org, computersforpeace@gmail.com, marek.vasut@gmail.com, robh+dt@kernel.org, mark.rutland@arm.com, thierry.reding@gmail.com, mturquette@baylibre.com, sboyd@kernel.org, dev@lynxeye.de, richard@nod.at, marcel@ziswiler.com, krzk@kernel.org, digetx@gmail.com, benjamin.lindqvist@endian.se, jonathanh@nvidia.com, pdeschrijver@nvidia.com, pgaikwad@nvidia.com, mirza.krak@gmail.com, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [RESEND PATCH 2/5] mtd: rawnand: add NVIDIA Tegra NAND Flash controller driver Message-ID: <20180527160648.0f368563@xps13> In-Reply-To: <78b7b43b4284e73cd6a3255e4e5075ed@agner.ch> References: <86fdf19ec92b732709732fb60199f16488b4b727.1526990589.git.stefan@agner.ch> <20180523161810.0ed9fe80@bbrezillon> <2d8107f0e6568512d691e9ea25a1e4e5@agner.ch> <20180524105614.3c51736c@bbrezillon> <7b3cc3991fb054130fd54c6fdfec5097@agner.ch> <20180524142356.0fc68797@bbrezillon> <20180524144134.41a71063@bbrezillon> <78b7b43b4284e73cd6a3255e4e5075ed@agner.ch> Organization: Bootlin X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Stefan, On Fri, 25 May 2018 00:56:23 +0200, Stefan Agner wrote: > On 24.05.2018 14:41, Boris Brezillon wrote: > > On Thu, 24 May 2018 14:23:56 +0200 > > Boris Brezillon wrote: > > > >> On Thu, 24 May 2018 13:09:53 +0200 > >> Stefan Agner wrote: > >> > >> > On 24.05.2018 10:56, Boris Brezillon wrote: > >> > > On Thu, 24 May 2018 10:46:27 +0200 > >> > > Stefan Agner wrote: > >> > > > >> > >> Hi Boris, > >> > >> > >> > >> Thanks for the initial review! One small question below: > >> > >> > >> > >> On 23.05.2018 16:18, Boris Brezillon wrote: > >> > >> > Hi Stefan, > >> > >> > > >> > >> > On Tue, 22 May 2018 14:07:06 +0200 > >> > >> > Stefan Agner wrote: > >> > >> >> + > >> > >> >> +struct tegra_nand { > >> > >> >> + void __iomem *regs; > >> > >> >> + struct clk *clk; > >> > >> >> + struct gpio_desc *wp_gpio; > >> > >> >> + > >> > >> >> + struct nand_chip chip; > >> > >> >> + struct device *dev; > >> > >> >> + > >> > >> >> + struct completion command_complete; > >> > >> >> + struct completion dma_complete; > >> > >> >> + bool last_read_error; > >> > >> >> + > >> > >> >> + dma_addr_t data_dma; > >> > >> >> + void *data_buf; > >> > >> >> + dma_addr_t oob_dma; > >> > >> >> + void *oob_buf; > >> > >> >> + > >> > >> >> + int cur_chip; > >> > >> >> +}; > >> > >> > > >> > >> > This struct should be split in 2 structures: one representing the NAND > >> > >> > controller and one representing the NAND chip: > >> > >> > > >> > >> > struct tegra_nand_controller { > >> > >> > struct nand_hw_control base; > >> > >> > void __iomem *regs; > >> > >> > struct clk *clk; > >> > >> > struct device *dev; > >> > >> > struct completion command_complete; > >> > >> > struct completion dma_complete; > >> > >> > bool last_read_error; > >> > >> > int cur_chip; > >> > >> > }; > >> > >> > > >> > >> > struct tegra_nand { > >> > >> > struct nand_chip base; > >> > >> > dma_addr_t data_dma; > >> > >> > void *data_buf; > >> > >> > dma_addr_t oob_dma; > >> > >> > void *oob_buf; > >> > >> > }; > >> > >> > >> > >> Is there a particular reason why you would leave DMA buffers in the chip > >> > >> structure? It seems that is more a controller thing... > >> > > > >> > > The size of those buffers is likely to be device dependent, so if you > >> > > have several NANDs connected to the controller, you'll either have to > >> > > have one buffer at the controller level which is max(all-chip-buf-size) > >> > > or a buffer per device. > >> > > > >> > > Also, do you really need these buffers? The core already provide some > >> > > which are suitable for DMA (chip->oob_poi and chip->data_buf). > >> > > > >> > > >> > Good question, I am not sure, that was existing code. > >> > > >> > Are you sure data_buf it is DMA capable? > >> > > >> > nand_scan_tail allocates with kmalloc: > >> > > >> > chip->data_buf = kmalloc(mtd->writesize + mtd->oobsize, GFP_KERNEL); > >> > >> Yes, kmalloc() allocates DMA-able buffers, so those are DMA-safe. > > > > Hm, that's not exactly true. It depends on the dma_mask attached to the > > device. > > It seems to work (tm). > > I am not sure how to deal with the OOB buffer. I now use the given > pointer also for oob (offset writesize). I think mtk_nand does the same > thing. > > dma_len = mtd->writesize + (oob_required ? mtd->oobsize : 0); > dma_addr = dma_map_single(ctrl->dev, buf, dma_len, DMA_FROM_DEVICE); > > ... > > Is there a test which allows to test my (read|write)_page implementation > with oob_required set? I don't think there is a test in mtd-utils that does train both implementations with oob_required set, but you should be able to test it manually with nanddump/nandwrite --oob. Thanks, Miquèl