Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3058637imu; Wed, 7 Nov 2018 04:27:25 -0800 (PST) X-Google-Smtp-Source: AJdET5czs7/rFtaPpnSOtlVzBPUE/HLU/djzVYHFpzmECZ1fusIiiGv/BXoG/mCvXQdf92YrdS04 X-Received: by 2002:a17:902:6b88:: with SMTP id p8-v6mr7441plk.19.1541593645573; Wed, 07 Nov 2018 04:27:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541593645; cv=none; d=google.com; s=arc-20160816; b=UKpp+HIhgC4otksxvAiziDxDl3HvT0pHj63ynj2qC9jRZFKYGdSORgUOSHVWSRzcCV +2eWSLuSh48qhLViPaNHyo596WWjdbS/6C4bid/dE+8fB1d8VoI9BlBRG/MG8JmjeJEv D05p9cr+kgsohcQ/YRft1M9XwtEN05j3iMwaZW8fiFoSi2t1TtpDpgNj8MVwClibkBoq mf1U2e+V5fL+rwu/DwBaobXeuzhlpgudV+IQoDuY0efTLkqLkcWiLDr9S6Cpwm3EcsJz Ycaex0rprsczNmO2UuyNCigIu5SRvLXDNYyXFB4ZBkAigtX7HkGGWKd4tfS/K/C4511u Wqog== 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; bh=ODox0V+uO9406CKP1xvwM5OQXGZKkuLsnHgfy3pBfto=; b=TsRKMlHrrypkMMU79c8kEc2YLTNYRpF92jEZJa4K0Nd15o8cLi1/IVj3kTjYgzRP4W NiLkYsh3Z0Uq97D/uq/gHAcOzAoi+k8mASqeWh3n3jHhzUDKRxU5UjF/DO1DrwBZ9N+N F+SdV5OEw/gpbKN/dBCBJbl7gawGmPi0JMzhlE9a+Sm1jA1ojTvEognPysnC36Zk23ij 2/WAffIFEJhBpX/83L55gfVin4nmE9Oxm6GrNHEPXEiFJrlIdq57z7NGxXm96A8XqOfH l2L7VIx+qHWFbv6SlYvDXgKvMbNJ0evvdObkVY94oymGVu6yVulHZA+07FzQaiQWCeGk O/2A== 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 a11si393866pga.198.2018.11.07.04.27.10; Wed, 07 Nov 2018 04:27:25 -0800 (PST) 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 S1730896AbeKGV46 convert rfc822-to-8bit (ORCPT + 99 others); Wed, 7 Nov 2018 16:56:58 -0500 Received: from mail.bootlin.com ([62.4.15.54]:55631 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726388AbeKGV46 (ORCPT ); Wed, 7 Nov 2018 16:56:58 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id 837C4208CB; Wed, 7 Nov 2018 13:26:46 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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.2 Received: from xps13 (aaubervilliers-681-1-93-44.w90-88.abo.wanadoo.fr [90.88.34.44]) by mail.bootlin.com (Postfix) with ESMTPSA id 20F6A206D8; Wed, 7 Nov 2018 13:26:46 +0100 (CET) Date: Wed, 7 Nov 2018 13:26:45 +0100 From: Miquel Raynal To: Boris Brezillon Cc: Christophe Kerello , , , , , , , , , , Subject: Re: [PATCH v2 2/3] mtd: rawnand: stm32_fmc2: add STM32 FMC2 NAND flash controller driver Message-ID: <20181107132645.7271e705@xps13> In-Reply-To: <20181107132342.33790247@bbrezillon> References: <1538732520-2800-1-git-send-email-christophe.kerello@st.com> <1538732520-2800-3-git-send-email-christophe.kerello@st.com> <20181105173905.385dd06e@bbrezillon> <70f99d79-a9d8-0651-d464-2d81b334dbfb@st.com> <20181107132342.33790247@bbrezillon> Organization: Bootlin X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; 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 Christophe, Boris Brezillon wrote on Wed, 7 Nov 2018 13:23:42 +0100: > On Wed, 7 Nov 2018 12:08:58 +0100 > Christophe Kerello wrote: > > > >> + > > >> +write_8bit: > > >> + for (i = 0; i < len; i++) > > >> + writeb_relaxed(p[i], io_addr_w); > > > > > > Is 8bit access really enforced by the byte accessor? In this case, how > > > can you be sure 32-bit accesses are doing the right thing? Isn't there > > > a bit somewhere in the config reg to configure the bus width? > > > > > > > I have checked the framework after Miquèl comment sent on v1 => "If you > > selected BOUNCE_BUFFER in the options, buf is supposedly > > aligned, or am I missing something?". > > > > After checking the framework, my understanding was: > > - In case of 8-bit access is requested, the framework provides no > > guarantee on buf. To avoid any issue, I write byte per byte. > > - In case of 8-bit access is not requested, it means that the > > framework will try to write data in the page or in the oob. When writing > > to oob, chip->oob_poi will be used and this buffer is aligned. When > > writing to the page, as the driver enables NAND_USE_BOUNCE_BUFFER > > option, buf is guarantee aligned. > > It's probably what happens right now, but there's no guarantee that all > non-8-bit accesses will be provided a 32-bit aligned buffer. The only > guarantee we provide is on buffer passed to the > chip->ecc.read/write_xxx() hooks, and ->exec_op() can be used outside > of the "page access" path. > > > > > But, I agree that it would be safe to reconfigure the bus width in 8-bit > > before writing byte per byte in case of a 16-bit NAND is used. > > Yes, and I also think you should not base your is-aligned check on the > force_8bit value. Use IS_ALIGNED() instead. Maybe the "configure the bus in 8/16-bit" blocks could deserve a helper. There is probably other locations within this driver with the same logic? Thanks, Miquèl