Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp4708472ima; Mon, 4 Feb 2019 23:21:28 -0800 (PST) X-Google-Smtp-Source: AHgI3IYd9PQb6572GPYpSla1pr+x4K06DyIAx25GQfCQYiKtn4kOe2lF6YJbQyuC29Y7641q6ets X-Received: by 2002:a63:c848:: with SMTP id l8mr3218210pgi.78.1549351288780; Mon, 04 Feb 2019 23:21:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549351288; cv=none; d=google.com; s=arc-20160816; b=XEefW7kuXFUtFY4qIfKEosjUGnwhYva9D+oMcdPJD8sDHlH0kJnEI2tUq7lzmIJbwO 5AgTxmCyHMYYyC3Uk53+cCw4BHhQj0GyvODzi8uRpiroszXU8KffOygmLtkY3XntWdE5 J//2CH1M5XsJVpUeqErLdWQkm/4sxpFX3/noyuBuX/qnSOTteGjnOYn78y6d9RNlOIuw Z1ptfolPHwWPeXRy0hlLmHyrupcQGnC9E6wCdBczAE/ESxxH9zfH1L0LV+/GvQmigfeS uA8BZctKRrUg1PuZ3UXxyo9JI/tKoSmUMkqXLnnWwN4EZ6ekEH9QrEf6Nh+de3rNpWJL OV/g== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=ztTY8WwNnXOVJYZM+SMYS5+xVaobOF0ZyFb3L+aI3Ro=; b=eUKTHxpCEt+2EH4M6gJcueMcHwi4reuktxTRLOVU5mSwpuzob3dqI/DHaBPcXvuJqi ulsVuWlTHdQ/FDq4REe2AfoDlQvCEYNU19yrXGmLzDdYbydXzrcPF9DMpQA6IkG+0oNw N0QNqii4h52d1fkt5KIVq8OA+8RG9l+stxGAGRP80gNQBGMjgaFaJIgr4/4CAw8M3kaE OecXPyCjbQTYTppWsYBfw04XuLfM5wuZWKLqtetMb1b5C/vK5ypnKVUUGGzgZHwnouv4 3ekB/c/qazdUhgSMqjwO4ra/WNBp9BJQbqoiClgl+qyvotVjWMCicgm3Dk4jMs5m8tDf HNfA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z11si2569766pfg.107.2019.02.04.23.20.47; Mon, 04 Feb 2019 23:21: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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726032AbfBEHA6 (ORCPT + 99 others); Tue, 5 Feb 2019 02:00:58 -0500 Received: from mga06.intel.com ([134.134.136.31]:52568 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725893AbfBEHA6 (ORCPT ); Tue, 5 Feb 2019 02:00:58 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Feb 2019 23:00:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,562,1539673200"; d="scan'208";a="120043642" Received: from mandalpu-mobl.gar.corp.intel.com (HELO [10.252.77.33]) ([10.252.77.33]) by fmsmga007.fm.intel.com with ESMTP; 04 Feb 2019 23:00:53 -0800 Subject: Re: [PATCH] mtd: spi-nor: cadence-quadspi: write upto 8-bytes data in STIG mode To: Vignesh R , "Tudor.Ambarus@microchip.com" , "f.blogs@napier.co.nz" , "boris.brezillon@bootlin.com" , "richard@nod.at" Cc: "linux-kernel@vger.kernel.org" , "marek.vasut@gmail.com" , "computersforpeace@gmail.com" , "linux-mtd@lists.infradead.org" , "dwmw2@infradead.org" References: <20190128050229.44965-1-purna.chandra.mandal@intel.com> <82eafaf8-803e-36a9-49ca-83d84c55537a@microchip.com> <7655324a-9cd2-7ffe-56bb-83c44740265c@ti.com> From: "Mandal, Purna Chandra" Message-ID: <56748733-74f9-50a6-bcb7-ff4fd878a597@intel.com> Date: Tue, 5 Feb 2019 12:30:51 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.3.3 MIME-Version: 1.0 In-Reply-To: <7655324a-9cd2-7ffe-56bb-83c44740265c@ti.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04-Feb-19 7:07 PM, Vignesh R wrote: > Hi, > > On 03/02/19 5:50 PM, Tudor.Ambarus@microchip.com wrote: >> + Vignesh >> > > Thanks for looping in. > >> On 01/28/2019 07:02 AM, Purna Chandra Mandal wrote: >>> cadence-quadspi controller allows upto eight bytes of data to >>> be written in software Triggered Instruction generator (STIG) mode >>> of operation. Lower 4 bytes are written through writedatalower and >>> upper 4 bytes by writedataupper register. >>> >>> This patch allows all the 8 bytes to be written. >>> > > Code as such looks fine. But, how was this tested? How can I trigger > this new code path with current linux-next? AFAICS, STIG mode write is > used to in nor->write_reg() path, and I dont see any nor->write_reg() > call with >4bytes len. Currently there is no linux user of write_reg() for write_len > 4byte. For volatile and non-volatile sector locking [1], we have one out of tree implementation and that is specific to flash chip "mt25qu02g". In this implementation we need additional sector address (4 byte) to be provided for each lock-bit write/erase operation. So total write len in write_reg() will be 6 bytes (=1 for opcode, 4 for sect addr, 1 for data). We are finalizing the patch for review. Since cadence qspi controller do support the 8-byte read/write in STIG mode, I have tried here to enable that in write_reg(), similar to read_reg(). [1] https://www.micron.com/~/media/documents/products/data-sheet/nor-flash/serial-nor/n25q/n25q_128mb_3v_65nm.pdf > >>> Signed-off-by: Purna Chandra Mandal >> >> Looks good for me: >> Reviewed-by: Tudor Ambarus >> >> Vignesh, can we have your R-b or T-b tag? >> >> Cheers, >> ta >> >>> --- >>> >>> drivers/mtd/spi-nor/cadence-quadspi.c | 15 ++++++++++++--- >>> 1 file changed, 12 insertions(+), 3 deletions(-) >>> >>> diff --git a/drivers/mtd/spi-nor/cadence-quadspi.c b/drivers/mtd/spi-nor/cadence-quadspi.c >>> index 04cedd3a2bf6..7f78f9409ddd 100644 >>> --- a/drivers/mtd/spi-nor/cadence-quadspi.c >>> +++ b/drivers/mtd/spi-nor/cadence-quadspi.c >>> @@ -418,9 +418,10 @@ static int cqspi_command_write(struct spi_nor *nor, const u8 opcode, >>> void __iomem *reg_base = cqspi->iobase; >>> unsigned int reg; >>> unsigned int data; >>> + u32 write_len; >>> int ret; >>> >>> - if (n_tx > 4 || (n_tx && !txbuf)) { >>> + if (n_tx > CQSPI_STIG_DATA_LEN_MAX || (n_tx && !txbuf)) { >>> dev_err(nor->dev, >>> "Invalid input argument, cmdlen %d txbuf 0x%p\n", >>> n_tx, txbuf); >>> @@ -433,10 +434,18 @@ static int cqspi_command_write(struct spi_nor *nor, const u8 opcode, >>> reg |= ((n_tx - 1) & CQSPI_REG_CMDCTRL_WR_BYTES_MASK) >>> << CQSPI_REG_CMDCTRL_WR_BYTES_LSB; >>> data = 0; >>> - memcpy(&data, txbuf, n_tx); >>> + write_len = (n_tx > 4) ? 4 : n_tx; >>> + memcpy(&data, txbuf, write_len); >>> + txbuf += write_len; >>> writel(data, reg_base + CQSPI_REG_CMDWRITEDATALOWER); >>> - } >>> >>> + if (n_tx > 4) { >>> + data = 0; >>> + write_len = n_tx - 4; >>> + memcpy(&data, txbuf, write_len); >>> + writel(data, reg_base + CQSPI_REG_CMDWRITEDATAUPPER); >>> + } >>> + } >>> ret = cqspi_exec_flash_cmd(cqspi, reg); >>> return ret; >>> } >>> >