Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3475041imu; Mon, 10 Dec 2018 02:52:28 -0800 (PST) X-Google-Smtp-Source: AFSGD/W7FcTcR6oLw0IpDxlQtZe/htLH2iDZkmLKTasE38tM7JTZGmMb0UlkAlOGL5j3a/HRl2aG X-Received: by 2002:a17:902:6502:: with SMTP id b2mr11526216plk.44.1544439148557; Mon, 10 Dec 2018 02:52:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544439148; cv=none; d=google.com; s=arc-20160816; b=wvxc/oFvUqoJ+dCP7Hqg9QDANMH85agqVBTFtfW39jJ0NR/aXsBivXo8jj/IWXxdtv GZNihTIycxYh+chw7Rzka4XHLGzZQu/eZklZP+Wa6PRltX2XUEcuGziDj86CM33isyFd iueSshGqJCSk9C/kQs/y1KmQbT8+4rhVjvnSZP9gGg1R66XFmXgq/xjU6PcNW7WU5GJS Kgl45isVp41AFtEMN0DGRTGz+qet5NWqd8g6b3CYsDeVPSNZdmcCkdpZUsBe4gtCDBgT LS8ZkPEmecEemIWR4JmFYglL0A8+LK5wX2GIxXvGaKaoy6yVoQqBUCdawnwBDvyVWp4Q xQew== 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 :references:in-reply-to:message-id:subject:cc:to:from:date; bh=+2XIEMRty4ez3gXj3Ark8Hk/Qqi+nLvtssTwkAnE3xE=; b=rt6dvm9TNrMNS0A0CEaUTF35pRQW4DtjrcDNDSFwNxYkb1YZJdl2JiSOsDI1NBksI4 ivfzoagf7WoPRMvkWGxweYW4gL+7UNG7Gh3gUUkC1Buqr+TP/bsUkADlQrM28k4Uuhov ZgqhcLwEUbSlqb9u2QlvSA2Tdd/ohK6S9UIXIMvXlkwFai9IRI45mBgjk+1bqu+mN0xL 28y+FTvV0cQ0LlrHC+40KAX2aDSmx0CbJhW+eMTAZb7ATE/Q8igAYgCP7NBYKNNzaH37 EOAlg7ZGJ0mEsTAqAaORvL9XEA0pdTSMtusWfp9PnaygUCuElHMeaPR3FxjdnZEhQ+i1 Tc8Q== 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 m65si10894535pfg.282.2018.12.10.02.52.13; Mon, 10 Dec 2018 02:52:28 -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 S1727119AbeLJKu0 (ORCPT + 99 others); Mon, 10 Dec 2018 05:50:26 -0500 Received: from mail.bootlin.com ([62.4.15.54]:55711 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726614AbeLJKuZ (ORCPT ); Mon, 10 Dec 2018 05:50:25 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id B9FAB20CEB; Mon, 10 Dec 2018 11:50:22 +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 bbrezillon (unknown [91.160.177.164]) by mail.bootlin.com (Postfix) with ESMTPSA id 2EE5820DC0; Mon, 10 Dec 2018 11:50:01 +0100 (CET) Date: Mon, 10 Dec 2018 11:50:01 +0100 From: Boris Brezillon To: Yogesh Narayan Gaur Cc: Schrempf Frieder , "linux-mtd@lists.infradead.org" , "marek.vasut@gmail.com" , "broonie@kernel.org" , "linux-spi@vger.kernel.org" , "devicetree@vger.kernel.org" , "robh@kernel.org" , "mark.rutland@arm.com" , "shawnguo@kernel.org" , "linux-arm-kernel@lists.infradead.org" , "computersforpeace@gmail.com" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v5 1/5] spi: spi-mem: Add driver for NXP FlexSPI controller Message-ID: <20181210115001.6c7af1d7@bbrezillon> In-Reply-To: References: <1542366701-16065-1-git-send-email-yogeshnarayan.gaur@nxp.com> <1542366701-16065-2-git-send-email-yogeshnarayan.gaur@nxp.com> <20181210111909.35384eee@bbrezillon> 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=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 10 Dec 2018 10:43:56 +0000 Yogesh Narayan Gaur wrote: > > > Thus, in LUT preparation we have assigned only the base address. > > > Now if I have assigned ahb_buf_size to FSPI_FLSHXXCR0 register then for > > read/write data beyond limit of ahb_buf_size offset I get data corruption. > > > > Why would you do that? We have the ->adjust_op_size() exactly for this reason, > > so, if someone tries to do a spi_mem_op with data.nbytes > ahb_buf_size you > > should return an error. > > > Let me explain my implementation with example. If I have to write data of size 0x100 bytes at offset 0x1200 for CS1, I would program as below: > In func nxp_fspi_select_mem(), would set value of controller address space size, memmap_phy_size, to FSPI_FLSHA2CR0 and rest all FSPI_FLSHXXCR0 as 0. > Value of memmap_phy_size is 0x10000000 i.e. 256 MB for my LX2160ARDB target. > Then in nxp_fspi_prepare_lut(), I would prepare LUT ADDR with address length requirement 3/4 byte for NOR or 1/2/3/4 bytes for NAND flash. > Also for LUT_NXP_WRITE would program data bytes as 0. > > Then inside func nxp_fspi_do_op(), set register FSPI_IPCR0 as the address offset i.e. 0x1200 and in register FSPI_IPCR1 program the data size to write i.e. 0x100 > > If, as suggested if I tries to mark value of register FSPI_FLSHA2CR0 equal to ahb_buf_size (0x800), then access for address 0x1200 gives me wrong data. This is because as per the controller specification access to flash connected at CS1 can be performed under range of FSPI_ FLSHA1CR0 and FSPI_ FLSHA2CR0. Don't you have a way to set an offset to apply to the address accessed through the AHB? And if you don't, how will it work if your mapping is smaller than the flash size?