X-Received: by 2002:a17:903:18d:b0:150:b6d:64cd with SMTP id z13-20020a170903018d00b001500b6d64cdmr1894036plg.123.1645659554295; Wed, 23 Feb 2022 15:39:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645659554; cv=none; d=google.com; s=arc-20160816; b=LQFqVrbUVu852+7VgwpiCdcCbODvvXK1VYwg3+J7HaquXoxbyyFwhOLMKA+TSsr3jk W3c1J6KwrZreLraBjWpx5B6rIW2211OD/fxEsTte8taJN7/Z+E35gqcsUNBcUl1DTM/m maLDlYMiObYLWs7160GHt3Ja+wdq14Y0tQuY3bsvIi+eXIliJrXcpreAWKgY1Q4JuKRQ 0OdaLvKjAFxE5A14t/vEm6EtgIugrWnfiPmvXKDFig/DuNkJPOQLeELP8VJsvoBAO/nK a0PqqLNhFC8+O1cDuMC3IHVga0Rl/QRjSuZQv0M9SHpqGWUodrBC+i+yIAFs5jskzi3D GDMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=VlmLvNgPCe5L7g2q46zh3SU4EKwQf3NcvwX8kmi+hUA=; b=vXv2ZHvxX/EXDzVPamgVzFoXeB+lOGLCLKrgjK6GvNeTsS4K82wfW4qEIYvRp+csau TDTcyTUR560H1Nt+LuPWgPHUy1Ei4Boinm54+M7eDubE+6ZXFSxLnsRN8jtdi4j61b50 G/Wt5AWWbEGSHnlExsie4ad7RbKyt0AxSK2Di4IM9E50anEO+fLkddVr/ylgyiKmO+5u LXDG4OXt38RefU0tD0eUwPPJd8gZGQvx4UouO+oBMvGr25b8Es9r89dSDGh0U5m+AGg2 qbZigsG3LQ0KTnKU7J4+bD5SNZS9lIkeCPXM8+LGMT7g1iHeizbuW4S50bHJ91UyYneZ i5MQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=xKURzZxv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j14si966058pfc.94.2022.02.23.15.38.58; Wed, 23 Feb 2022 15:39:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=xKURzZxv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243999AbiBWSjl (ORCPT + 99 others); Wed, 23 Feb 2022 13:39:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237880AbiBWSjk (ORCPT ); Wed, 23 Feb 2022 13:39:40 -0500 Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 543F449CBA; Wed, 23 Feb 2022 10:39:11 -0800 (PST) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 21NIcp5C012312; Wed, 23 Feb 2022 12:38:51 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1645641531; bh=VlmLvNgPCe5L7g2q46zh3SU4EKwQf3NcvwX8kmi+hUA=; h=Date:From:To:CC:Subject:References:In-Reply-To; b=xKURzZxvW+WP32Fpl1fCWJ3EEqsRpzEMUb/t94kLSXojbDmZkQY40tDTRrLPsy3Ys px4LKDr3kAHZKAL36DRdY80IxrkvrMLIolj5woEvWL7Cn9bvGT8eaQGrwxL93v4Y8P wUeSKqdkX3cQHB33RXSXLTu4V/qcTuLjiFt5T+NE= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 21NIcpQO112522 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 23 Feb 2022 12:38:51 -0600 Received: from DLEE113.ent.ti.com (157.170.170.24) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Wed, 23 Feb 2022 12:38:50 -0600 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via Frontend Transport; Wed, 23 Feb 2022 12:38:50 -0600 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 21NIcoo4017359; Wed, 23 Feb 2022 12:38:50 -0600 Date: Thu, 24 Feb 2022 00:08:49 +0530 From: Pratyush Yadav To: CC: , , , , , , , , , , Subject: Re: [PATCH 0/4] spi-mem: Allow specifying the byte order in DTR mode Message-ID: <20220223183849.xcwciv2ybnkdnauk@ti.com> References: <20220218145900.1440045-1-tudor.ambarus@microchip.com> <44f655d027b49b87065915f6ba2744d2@walle.cc> <81d7c569-d6c2-9167-e007-eda72f34842b@microchip.com> <23fbbf2dde387e3832b4ca23d46816c0@walle.cc> <7cd74ef3-5a7d-4e65-3436-ee3399ca56a3@microchip.com> <3cd510ad-a6ab-d4a0-92e3-9156a0c7ddbf@microchip.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <3cd510ad-a6ab-d4a0-92e3-9156a0c7ddbf@microchip.com> X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Tudor, On 22/02/22 02:43PM, Tudor.Ambarus@microchip.com wrote: > On 2/22/22 16:27, Michael Walle wrote: > > EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe > > > > Am 2022-02-22 15:23, schrieb Tudor.Ambarus@microchip.com: > >> On 2/22/22 16:13, Michael Walle wrote: > >>> EXTERNAL EMAIL: Do not click links or open attachments unless you know > >>> the content is safe > >>> > >>> Am 2022-02-22 14:54, schrieb Tudor.Ambarus@microchip.com: > >>>> On 2/21/22 09:44, Michael Walle wrote: > >>>>> EXTERNAL EMAIL: Do not click links or open attachments unless you > >>>>> know > >>>>> the content is safe > >>>>> > >>>>> Am 2022-02-18 15:58, schrieb Tudor Ambarus: > >>>>>> Fortunately there are controllers > >>>>>> that can swap back the bytes at runtime, fixing the endiannesses. > >>>>>> Provide > >>>>>> a way for the upper layers to specify the byte order in DTR mode. > >>>>> > >>>>> Are there any patches for the atmel-quadspi yet? What happens if > >>>> > >>>> not public, but will publish them these days. > >>>> > >>>>> the controller doesn't support it? Will there be a software > >>>>> fallback? > >>>> > >>>> no need for a fallback, the controller can ignore > >>>> op->data.dtr_bswap16 > >>>> if > >>>> it can't swap bytes. > >>> > >>> I don't understand. If the controller doesn't swap the 16bit values, > >>> you will read the wrong content, no? > >>> > >> > >> In linux no, because macronix swaps bytes on a 2 byte boundary both on > >> reads and on page program. The problem is when you mix 8D-8D-8D mode > >> and > >> 1-1-1 mode along the boot stages. Let's assume you write all boot > >> binaries > >> in 1-1-1 mode. When reaching u-boot if you enable 8D-8D-8D mode, when > >> u-boot > >> will try to get the kernel it will fail, as the flash swaps the bytes > >> compared > >> to what was written with 1-1-1 mode. You write D0 D1 D2 D3 in 1-1-1 > >> mode and > >> when reaching u-boot you will read D1 D0 D3 D2 and it will mess the > >> kernel image. > > > > But you have to consider also 3rd parties, like an external programmer > > or > > Why? If you use the same mode when reading and writing, everything is fine. > I'm not sure what's your suggestion here. So our stance here is that we don't care about external programs? If that is the case then why bother with all this anyway? Since the swap happens at both page program and read, what you write is what you read back. Who cares the order stored in the actual flash memory as long as the data read is correct? If we do care about external programs, then what would happen if the external program writes data in 8D-8D-8D mode _without_ swapping the bytes? This would also cause data corruption. You can't control what they mode they use, and you can't detect it later either. I think there is no winning here. You just have to say that external programs should write in 8D-8D-8D mode or it won't boot. > > > another OS. So, there has to be *one correct* way of writing/reading > > these > > bytes. > > > > -- Regards, Pratyush Yadav Texas Instruments Inc.