Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp429634iol; Thu, 9 Jun 2022 06:43:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9f1Th5nzMEWd7BgTFjrZLa2DwZDP4dY4UVtG042nrMGEMPeJE6vtmhPY5/8HE5dg+I1Pf X-Received: by 2002:a17:902:bb92:b0:153:4eae:c77e with SMTP id m18-20020a170902bb9200b001534eaec77emr38979441pls.93.1654782209472; Thu, 09 Jun 2022 06:43:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654782209; cv=none; d=google.com; s=arc-20160816; b=tOep5pmGUQYpjHTeJ1eh3huwPvlGa3rufjCMfCHOZ980vT2B+h00Q2Bxs7iMWg5TCr 9s/ugt9fGcjMIAQSDRdujiwHNdGnip1hDmplyLSAK5NrcgUHRa7Qw69qIBA1oMXek9yv RhVRC2V2u6GJlKk48gGGOW5EsblaiKHYV5oGoohJnCRQMKp62Kor1Db8M+2HPgBD5hrr Cvrv7QucMuaXZsVyiTLen1uwU5+almqrWTOf3LGqi7UMPKO8VPI5sHX1El0epTaikZgx dfBdlPcDxSF8sWmKfDJ8pSXGPl4UBf8RsxcQny9sYKBcoJ7b5iToIr3uLCIIFAWHAqeY Tzqw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=xOp49jraaiqTwhYF0mD/jVJfnTt8MnTWTGqz+xRTGq0=; b=oZUjkAGmvj3K+3iqB9+Kn3rrAQqu6W2sGS0TsiQ4fGoz3U7es4RmkdR70+JbMx6QOs 9h8wXqMLZC9jAbNwZS+9D2tDNPxIUE2BsFfpO8WB2QcQBRqmcCbjmmKmtVnmFSxpbHAY FYe7UWQvBHjMaYNnCVZ4yPL5GYOBKaDbB5lXQTa+oaKugM3XchJvao9AMGiWfeaf9lWf WPAJZ7FiwtAS1OPmWS7l+Uber2wHL4tD2dmGLf2Sx0QKWnM7bNc+lkv+ykMJvJNgrX3J FTzCsVu4HRZORvelB+/J3voNYQkwo5qLczvGDeAitI/1lqwztt1wdUZXV8TuU/4HQWek jO6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=d4kQYyM0; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mi4-20020a17090b4b4400b001e881637bd7si16665919pjb.77.2022.06.09.06.43.16; Thu, 09 Jun 2022 06:43:29 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=d4kQYyM0; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343774AbiFINYS (ORCPT + 99 others); Thu, 9 Jun 2022 09:24:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238780AbiFINYR (ORCPT ); Thu, 9 Jun 2022 09:24:17 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C13FD1B781; Thu, 9 Jun 2022 06:24:15 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id d14so5638272eda.12; Thu, 09 Jun 2022 06:24:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xOp49jraaiqTwhYF0mD/jVJfnTt8MnTWTGqz+xRTGq0=; b=d4kQYyM0yvnckDXPuCHW9lAxap+AYxbPdjcG00CMIxwFvwa/g8Lxynqud3+wQGqBLU l8a4gAg0NSFJoO6339vafPYusRxUSh6YDbuyRNfn4RVLpOGnfLpbUoik54Z8DTlfZxqi 6DZukQ43NvrbT3hKz311Ic9q+3xU7uF/NQOO1ocqqS58t5IGbzguWrhy3We2UUerPuOZ IiHpqMebjgvBXHOYsvnH0Jw0gDcU7RqdY4DXI0vBpS4+b1dbjEaYrx03NiEXLHnCEhvq k8XD2H2ERMGyz2vwABv7WCt1fXyoy/mbnkuxV7lUFTP7pVmvKZagNZY/vpVp7TXCObcf YJXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xOp49jraaiqTwhYF0mD/jVJfnTt8MnTWTGqz+xRTGq0=; b=CMc3Y4RiJb9nQTFNCE3F1IcTL7JVheMUpQuv5A4Ez3Taw8fCMBgo9H/UIxfCUodAIK 4sAfrDSNjyUc+4cOwQ4lu/a/mMr5aaatkCoDiBWF2mtaQxTaw9a9yTRv8OWzbNKUBGaT o9B8mTjd1u+XlVrxfMmsegPDTtv1ZveaB8R/BWBsQg2na4WNw8bQmFegM06FUaj17ueH 9G2mkCFFoVw7KIdIVWvLOtXnurUKpZ1HsNcn/9RvCflEMvH723Zt/Wlm1L9yb+yh165V UrwBcIwxDWNP6wIZzxzscj1Lpfsxj81/OR2dZ84a4uNcoTGzI9OmrdZHGUrlgDicRWEe 5l2A== X-Gm-Message-State: AOAM531L3h3BiqfXat9Nuxic66YjmCAJwJu2eQHdr0HJjNa832QUOWun xCArX95IraQkmJfhkO+nBIN9IDRwBnc= X-Received: by 2002:a05:6402:3207:b0:42d:dba6:8ef0 with SMTP id g7-20020a056402320700b0042ddba68ef0mr45929939eda.410.1654781054042; Thu, 09 Jun 2022 06:24:14 -0700 (PDT) Received: from localhost.localdomain (93-42-70-190.ip85.fastwebnet.it. [93.42.70.190]) by smtp.googlemail.com with ESMTPSA id i2-20020a056402054200b004315050d7dfsm8360263edx.81.2022.06.09.06.24.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 06:24:13 -0700 (PDT) From: Ansuel Smith To: Manivannan Sadhasivam , Andy Gross , Bjorn Andersson , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski , linux-mtd@lists.infradead.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ansuel Smith Subject: [PATCH v6 0/3] Add support for unprotected spare data page Date: Thu, 9 Jun 2022 15:23:41 +0200 Message-Id: <20220609132344.17548-1-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 Some background about this. On original qsdk ipq8064 based firmware there was a big separation from boot partition and user partition. With boot partition we refer to partition used to init the router (bootloader, spm firmware and other internal stuff) With user partition we refer to linux partition and data partition not used to init the router. When someone had to write to these boot partition a special mode was needed, to switch the nand driver to this special configuration. Upstream version of the nandc driver totally dropped this and the result is that if someone try to read data from these partition a CRC warning is printed and if someone try to write that (if for example someone wants to replace the bootloader) result is a broken system as the data is badly written. This series comes to fix this. A user can declare offset and size of these special partition using the qcom,boot-pages binding. An initial implementation of this assumed that the boot-pages started from the start of the nand but we discover that some device have backup of these special partition and we can have situation where we have this partition scheme - APPSBL (require special mode) - APPSBLENV (doesn't require special mode) - ART - APPSBLBK (back of APPSBL require special mode) - APPSBLENVBK (back of APPSBLENV doesn't require special mode) With this configuration we need to declare sparse boot page and we can't assume boot-pages always starts from the start of the nand. A user can use this form to declare sparse boot pages qcom,boot-partitions = <0x0 0x0c80000 0x0c80000 0x0500000>; The driver internally will parse this array, convert it to nand pages and check internally on every read/write if this special configuration should used for that page or the normal one. The reason for all of this is that qcom FOR SOME REASON, disable ECC for spare data only for these boot partition and we need to reflect this special configuration to mute these warning and to permit actually writing to these pages. v6: - Add additional comments on boot partition check - First reorder struct then make change - Add additional changes request from Manivannan - Add review tag for dt commit v5: - Rename boot-pages to boot-partitions - Add additional check to parsing function - Rename unprotect_spare_data to codeword_fixup - Add additional info from Manivannan - Add patch to remove holes in qcom_nand_host struct v4: - Fix wrong compatible set for boot-pages (ipq8074 instead of ipq806x) v3: - Fix typo in Docmunetation commit desription - Add items description for uint32-matrix v2: - Add fixes from Krzysztof in Documentation Ansuel Smith (3): mtd: nand: raw: qcom_nandc: reorder qcom_nand_host struct mtd: nand: raw: qcom_nandc: add support for unprotected spare data pages dt-bindings: mtd: qcom_nandc: document qcom,boot-partitions binding .../devicetree/bindings/mtd/qcom,nandc.yaml | 27 +++ drivers/mtd/nand/raw/qcom_nandc.c | 214 +++++++++++++++++- 2 files changed, 232 insertions(+), 9 deletions(-) -- 2.36.1