Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp507203ybj; Tue, 5 May 2020 02:47:26 -0700 (PDT) X-Google-Smtp-Source: APiQypIvwouoLj2ZYZaHsasn4NMMJu5Q0O8Z3cqzugXjnOXiV0SUnTPQmAY0JO3EOwueCz5FdzTo X-Received: by 2002:a17:906:d14b:: with SMTP id br11mr1821996ejb.213.1588672046613; Tue, 05 May 2020 02:47:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588672046; cv=none; d=google.com; s=arc-20160816; b=DX2Gyb1+BUZWwGokFvKk5FdjoS42zK+ElcHS3SG5VaxQPbPwXfS2NTu7MbD9Rid4q7 7NXSQYdXWKbAZZvmFxRSu5FtJgJ3bhXmVdMg7L+SnP/HsYDtdtBoO7iKbucmYHmGezU7 4z2gw0vgt/veSs8NUtHaMT41C9zM5A5LQJIg99cCuPVrAd/qXelaeE7Yeb3kIikCvwRx bEbNgB0AUSbNbqSKwfD+uR3YHXfPHxLuI8IelQGeG4WYjSWy0S90RuVSkiqrl/pm9GON hjJGFbAOF/hOAIzHk92yru/gQ14ceH4rdCv4iz0TDPrJiahyU3EkJZALzphogC4s2ZdG f+0A== 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=SpoCrXnc1DXA14+OGA01mylCdCRxong25BVHMqFkVuw=; b=Z4aHRfkifA9KQ8lAUWU37zmm1T92G59fZxUqW1MWTX4OHRePVF43KXs7Ro55AvVsnF wttqHwL7WxXGDL/L40Oxs5hdCbi61dqjdBIIMf3QCrMxx0kvlE4tykeMqC6qTuYQVqSE z8+PIBtTjdiglkLHUWR66/ZgyoS5dDn+bWGiV8PPw4hpAFxZA84o8lARQkhNcU5xSyXY N1QJDqlQH+yvEmEg95S8FDmopzs8lWBOPhuyNqW6LhjtWljKxETLA8xITDGw1pjIX0hz Hl0j9Qt7EkpEnVx5tF1oYygu1YLJjrSrqOTDdUrd2cKSi5omaPcmrj3a1VdaUGNPZWk6 tshA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q18si813721eju.4.2020.05.05.02.47.03; Tue, 05 May 2020 02:47:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728675AbgEEJot (ORCPT + 99 others); Tue, 5 May 2020 05:44:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726568AbgEEJos (ORCPT ); Tue, 5 May 2020 05:44:48 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0FBFC061A0F; Tue, 5 May 2020 02:44:47 -0700 (PDT) Received: from localhost (unknown [IPv6:2a01:e0a:2c:6930:d3ea:1c7:41fd:3038]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: bbrezillon) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 143F32A1B43; Tue, 5 May 2020 10:44:46 +0100 (BST) Date: Tue, 5 May 2020 11:44:43 +0200 From: Boris Brezillon To: masonccyang@mxic.com.tw Cc: "Pratyush Yadav" , broonie@kernel.org, juliensu@mxic.com.tw, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-spi@vger.kernel.org, miquel.raynal@bootlin.com, "Pratyush Yadav" , richard@nod.at, tudor.ambarus@microchip.com, vigneshr@ti.com Subject: Re: [PATCH v2 0/5] mtd: spi-nor: Add support for Octal 8D-8D-8D mode Message-ID: <20200505114443.6ebd5d3c@collabora.com> In-Reply-To: References: <1587451187-6889-1-git-send-email-masonccyang@mxic.com.tw> <20200421092328.129308f6@collabora.com> <20200427175536.2mmei2fy6f7bg6jm@yadavpratyush.com> <20200428085401.574wmo6qddmumd7q@yadavpratyush.com> <20200429181856.kkavelcczylg4yxf@yadavpratyush.com> Organization: Collabora X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-redhat-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 Tue, 5 May 2020 17:31:45 +0800 masonccyang@mxic.com.tw wrote: > > > > > I quickly went through your patches but can't reply them in each > your > > > > > patches. > > > > > > > > > > i.e,. > > > > > 1) [v4,03/16] spi: spi-mem: allow specifying a command's extension > > > > > > > > > > - u8 opcode; > > > > > + u16 opcode; > > > > > > > > > > big/little Endian issue, right? > > > > > why not just u8 ext_opcode; > > > > > No any impact for exist code and actually only xSPI device use > > > extension > > > > > command. > > > > > > > > Boris already explained the reasoning behind it. > > > > > > yup, I got his point and please make sure CPU data access. > > > > > > i.e,. > > > Fix endianness of the BFPT DWORDs and xSPI in sfdp.c > > > > > > and your patch, > > > + ext = spi_nor_get_cmd_ext(nor, op); > > > + op->cmd.opcode = (op->cmd.opcode << > 8) | > > > ext; > > > + op->cmd.nbytes = 2; > > > > > > I think maybe using u8 opcode[2] could avoid endianness. > > > > Again, thanks Boris for answering this. FWIW, I don't see anything wrong > > > with his suggestion. > > > > To clarify a bit more, the idea is that we transmit the opcode MSB > > first, just we do for the address. Assume we want to issue the command > > 0x05. In 1S mode, we set cmd.opcode to 0x05. Here cmd.nbytes == 1. Treat > > > is as a 1-byte value, so the MSB is the same as the LSB. We directly > > send 0x5 on the bus. > > There are many SPI controllers driver use "op->cmd.opcode" directly, > so is spi-mxic.c. > > i.e,. > ret = mxic_spi_data_xfer(mxic, &op->cmd.opcode, NULL, op->cmd.nbytes); Just because you do it doesn't mean it's right. And most controllers use the opcode value, they don't dereference the pointer as you do here. > > > > > If cmd.nbytes == 2, then the opcode would be 0x05FA (assuming extension > > is invert of command). So we send the MSB (0x05) first, and LSB (0xFA) > > next. > > My platform is Xilinx Zynq platform which CPU is ARMv7 processor. > > In 1-1-1 mode, it's OK to send 1 byte command by u16 opcode but > in 8D-8D-8D mode, I need to patch > > i.e., > op->cmd.opcode = op->cmd.opcode | (ext << 8); > > rather than your patch. Seriously, how hard is it to extract each byte from the u16 if your controller needs to pass things in a different order? I mean, that's already how it's done for the address cycle, so why is it a problem here? This sounds like bikeshedding to me. If the order is properly documented in the kernel doc, I see no problem having it grouped in one u16, with the first cmd cycle placed in the MSB and the second one in the LSB.