Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp27494692rwd; Tue, 4 Jul 2023 03:56:38 -0700 (PDT) X-Google-Smtp-Source: APBJJlFp9ZH2yUBn3ddAqAd6ZoQA8vIliPW7dpusmYPYVkEAdH1pjxbsIdemAYtCtWP4IxDZaogo X-Received: by 2002:a17:90b:3a8e:b0:263:4815:cb9a with SMTP id om14-20020a17090b3a8e00b002634815cb9amr12776696pjb.41.1688468198646; Tue, 04 Jul 2023 03:56:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688468198; cv=none; d=google.com; s=arc-20160816; b=yvmkEvsaI+OM7ype+/fm9ps3zNtep+8w4ARFyyKYecWu1ojqC1pW87c/q9nQkB5s1g oIqTbhutlmZZqB0TFjLWa+Qsd17Z79uDpjIGKsWM1uNHut+4LRix/zIknSMNZK101SWZ yKwjTrkSZZqxCR7TMBnOHiPIdc2k2uz7x2MjTWW/Nzdv+7+v6EbaAg/2KJzxDgqPXL0a ydi6N4SK1v+6WoH49TAKNjD3nvbvg9ZC/Aqcxbc2uKa8IrBrNKFv3j7wfPQl4TEawaOc gJJQCDpIPbwWG35lAT8Rz9H/KsOPvqrQWGCFXOwQILtX3pVpl2PZtTVZXYmMvf4p9+XA S64g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:message-id:subject:cc:to:from:date; bh=bkdQo0ViZjVo7XlLbYmNSqvOdmOJOspPGp6iV1gqxWY=; fh=BEy9a7B+7+OqKw0/6qRoGVPoASJis0BxUCCtV6D5MnA=; b=cuoi6/+MxxWklLVDZelRt27MPW8N/184C+FOsSskfm77qGDD1sXGF6pakuI7KrnkUY U808v8dwgeutq3+LmXgomZviag85+AAJnFXfTIDFDQEP6IHXqjYgIHiAkF+nPNE7hE7b v9QTEzZTexFKtCk3vHVghoQslO046cBU0xi0dd0MTng2CvAIvfseET/v/z67PXAAIJ5L aOUMXvnOmOqsd3lJ9UdicLJdA0qUdNDbayIm4QtM+9vU0jtv3SGfCOlJC1wUHvKEsiJH wSTKPe1mxa3N76bPkaWHrdK4JxuN8n6edyRCH/pfWuPZGFW+EN12fY1heLWxnrt78yG5 LVpQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nu14-20020a17090b1b0e00b00261266bf8b8si8292421pjb.179.2023.07.04.03.56.23; Tue, 04 Jul 2023 03:56:38 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230273AbjGDKjJ convert rfc822-to-8bit (ORCPT + 99 others); Tue, 4 Jul 2023 06:39:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229451AbjGDKjJ (ORCPT ); Tue, 4 Jul 2023 06:39:09 -0400 X-Greylist: delayed 79 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 04 Jul 2023 03:39:07 PDT Received: from smtprelay07.ispgateway.de (smtprelay07.ispgateway.de [134.119.228.97]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5981187 for ; Tue, 4 Jul 2023 03:39:07 -0700 (PDT) Received: from [89.1.81.74] (helo=ipc1.ka-ro) by smtprelay07.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qGdPk-00012Z-CS; Tue, 04 Jul 2023 12:37:44 +0200 Date: Tue, 4 Jul 2023 12:37:43 +0200 From: Lothar =?UTF-8?B?V2HDn21hbm4=?= To: Felix Matouschek Cc: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC] Bad ecc layout in drivers/mtd/nand/spi/xtx.c Message-ID: <20230704123743.7f4c87af@ipc1.ka-ro> Organization: Ka-Ro electronics GmbH MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Df-Sender: bHdAa2Fyby1lbGVjdHJvbmljcy5kb21haW5mYWN0b3J5LWt1bmRlLmRl X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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, while trying to add support for the 'XT26G01C' variant of the XTX SPI-nand chip I noticed a flaw in the ECC layout of the existing driver. According to the XT26G01A datasheet the first eight bytes of the OOB area are not protected by ECC: Offset ECC Bytes Area Description 800H 807H No 8 Spare 4, Group E This Area is not covered by internal ECC, 800H is reserved for bad block mark 808H 82FH Yes 40 Spare 5 , Group F User Meta Data Area covered by internal ECC. 830H 83FH No 16 Spare 6 , Group G ECC_EN=1: this area contains Internal ECC Data, Read-Only, Programming to this area will be ignored ECC_EN=0: this area is writable for user But the driver defines bytes 1..47 as user OOB area: |static int xt26g0xa_ooblayout_free(struct mtd_info *mtd, int section, | struct mtd_oob_region *region) |{ | if (section) | return -ERANGE; | | region->offset = 1; | region->length = 47; | | return 0; |} IMO this should be: | region->offset = 8; | region->length = 40; to have the whole user oob area protected by ECC. Obviously this cannot simply be changed in the driver because it would break access to flash that was programmed with the current parameters. Since the data structures that provide the oob layout are completely static and cannot be modified at runtime (e.g. depending on some DTB property) the only way I see to provide a layout with ECC protection for the whole user metadata would be a Kconfig option to select one or the other layout at compile time. Any comments or better ideas? Lothar Waßmann -- ___________________________________________________________ Ka-Ro electronics GmbH | Pascalstraße 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Geschäftsführer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | info@karo-electronics.de ___________________________________________________________