From patchwork Fri Apr 2 15:01:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 414375 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1479006jai; Fri, 2 Apr 2021 08:01:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzS5MTBl3sIV8c2L7bswKTsMyB5lkraw7WJYfKOIP9EMjs7bAHGw05OgD3PjMfD/4vALWYk X-Received: by 2002:a05:6830:12d5:: with SMTP id a21mr11411603otq.34.1617375708223; Fri, 02 Apr 2021 08:01:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617375708; cv=none; d=google.com; s=arc-20160816; b=oUFDXW/RZpR6W1OgvaGBowjiRDeUnax+i0P91NExg6gvjBvy0jfAKSiAaMn0RvK+7z JUAWh+ZhbiOtlJ8batWFFF7we5PTIueYENYqCEnHDmqVOkpZHixzY9GfynbTeA+lTA9D 0EvC8iyCDyAbr7CRxW4Uia172XS+CuvZPCsmESR1776tI8+ZABz2vCfK3nuTdbCUC2A9 DOp5COeDOVIYRCwNo7gxX0Lmm0gjf47WdNnyK7cJWYds1tu2XVYHlr0MI65TUoQcA/Ko xVpwRBmHHHLpp8lWTmV1Z67BPXrLAF2W5aiZKnug+hgoz1Do4qtvyHrc/ekT+G03kSWe 6vHg== 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=ldZzMYp9rBIEkuelFhL1o+s+U9zYs7UBzeIApWLg0og=; b=YXaU+p4rBfHd7RSfVOmXrJfXBsTzW8Ry7ynech77jMiG0EwTHP/BGll7daMf8NoJX1 hmYInSMk4wcmjIQQDZv5qpOeqr5SAqus+t4JI77XJMPEa1ilyZ5DvguGiJ9JZ474UOm/ cF4SmIrn7N4qEG+Kn9oUg8i7s5I1zV11EQfnXOj5Goit8Ir3+eIUj2SfNhQrB1Dxl7/o Qbl7ortun+L8ln4tr2Z949czsjWUy8SmGyIEVbM5oWGAyUK0HhhtSvnV7X8L3ptbYjXr k9pROslDTrff1g4vD+MBQZy5oisz51LrIFi+gLSK/QFbWxnAhQqWs/H1Yaaz0G4oc4fm 3duA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=n6RIi2rO; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 4si9122999ois.89.2021.04.02.08.01.47; Fri, 02 Apr 2021 08:01:48 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=n6RIi2rO; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234628AbhDBPBr (ORCPT + 6 others); Fri, 2 Apr 2021 11:01:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231160AbhDBPBq (ORCPT ); Fri, 2 Apr 2021 11:01:46 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF082C061788 for ; Fri, 2 Apr 2021 08:01:43 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id l1so2619042plg.12 for ; Fri, 02 Apr 2021 08:01:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ldZzMYp9rBIEkuelFhL1o+s+U9zYs7UBzeIApWLg0og=; b=n6RIi2rOaJ2VF59xOiWxOs+AUToxL9jEvdKG47HKc6iG15nkn0+iwj7DezBguhzxZ+ JKO+naDulBdXIQyejCZ1GOKRxR7GzHxhUvEM/VOx0tpqj95rE3tt7Dv1MM6WPbIiKYhh 7th+iejlGRsQTYTzRQFUPiRPFHBGWhsj+FtKmqVlNBShm1m5D2Ssnn+ieyK3pY0Hdnph sf2iQ18tsjcAYdnxeL8iTkLTlW7D4OkARNbWSH76eoaTck5nyF5yckrdIKtDyKu59R6f wbZNPtsN/S9qRMJoKRVUxfymcM5FYvOY6Qqql7zlRFwgy4Os6GV7KXNL5W5B4iMIasAs 5xJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ldZzMYp9rBIEkuelFhL1o+s+U9zYs7UBzeIApWLg0og=; b=e3ZvBgjwSv+h4XbyXpDD5xWE0czRccOzhqWL+1quXcjLiuVfgJ1kxrJ+/YxHZ5WJb7 P7QLFD+VpXw/a3MkY4O380sx4LVVibcC7LpV6P0CMrtJTng3VjR+H5Ti/PCabtGSAwpu mV1rUi6W3ekfrLhruqYWbUP2zszhWyrtrdDXnDSKFe2CCiOzpbg0ZbI53ERT7YrJuf/a lfYNA3ikyC0gnhWNR5Ni6rAyb7ODJLg/vD4XchkWc7M0/F0jUGzftBk+/ipOei9XEEmj xeBZOTwTjHokyUn8g2QsYPwbEc080HPBBozo02w5yNl/MB+wfPS6lVQbg6Uk0QCAVxq8 OzWA== X-Gm-Message-State: AOAM530z/ZqzDQ1xUqe/IqtYMH4dqLn+l2ELl8mhEM19YylJxZbG+n37 zRReQSVlijA9MzAmXovgMCRK X-Received: by 2002:a17:902:bb8e:b029:e6:3b2:5834 with SMTP id m14-20020a170902bb8eb02900e603b25834mr13267915pls.38.1617375702769; Fri, 02 Apr 2021 08:01:42 -0700 (PDT) Received: from localhost.localdomain ([103.77.37.174]) by smtp.gmail.com with ESMTPSA id x7sm8773647pff.12.2021.04.02.08.01.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Apr 2021 08:01:42 -0700 (PDT) From: Manivannan Sadhasivam To: miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, robh+dt@kernel.org Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, boris.brezillon@collabora.com, Daniele.Palmas@telit.com, bjorn.andersson@linaro.org, Manivannan Sadhasivam Subject: [PATCH v11 0/4] Add support for secure regions in NAND Date: Fri, 2 Apr 2021 20:31:24 +0530 Message-Id: <20210402150128.29128-1-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On a typical end product, a vendor may choose to secure some regions in the NAND memory which are supposed to stay intact between FW upgrades. The access to those regions will be blocked by a secure element like Trustzone. So the normal world software like Linux kernel should not touch these regions (including reading). So this series adds a property for declaring such secure regions in DT so that the driver can skip touching them. While at it, the Qcom NANDc DT binding is also converted to YAML format. Thanks, Mani Changes in v11: * Removed unneeded check in nand_block_isreserved() * Used mtd->erasesize as the size in nand_isbad_bbm() Changes in v10: * Added Rob's review tag for binding Changes in v9: Based on review comments from Miquel: * Fixed the secure-regions check * Renamed the function to nand_region_is_secured() and used bool return * Moved the parsing function to nand_scan() * Added a patch to fix nand_cleanup in qcom driver Changes in v8: * Reworked the secure region check logic based on input from Boris * Removed the check where unnecessary in rawnand core. Changes in v7: * Made "size" u64 and fixed a warning reported by Kernel test bot Changes in v6: * Made use of "size" of the regions for comparision * Used "secure" instead of "sec" * Fixed the sizeof parameter in of_get_nand_secure_regions() Changes in v5: * Switched to "uint64-matrix" as suggested by Rob * Moved the whole logic from qcom driver to nand core as suggested by Boris Changes in v4: * Used "uint32-matrix" instead of "uint32-array" as per Rob's review. * Collected Rob's review tag for binding conversion patch Changes in v3: * Removed the nand prefix from DT property and moved the property parsing logic before nand_scan() in driver. Changes in v2: * Moved the secure-regions property to generic NAND binding as a NAND chip property and renamed it as "nand-secure-regions". Manivannan Sadhasivam (4): dt-bindings: mtd: Convert Qcom NANDc binding to YAML dt-bindings: mtd: Add a property to declare secure regions in NAND chips mtd: rawnand: Add support for secure regions in NAND memory mtd: rawnand: qcom: Add missing nand_cleanup() in error path .../bindings/mtd/nand-controller.yaml | 7 + .../devicetree/bindings/mtd/qcom,nandc.yaml | 196 ++++++++++++++++++ .../devicetree/bindings/mtd/qcom_nandc.txt | 142 ------------- drivers/mtd/nand/raw/nand_base.c | 100 ++++++++- drivers/mtd/nand/raw/qcom_nandc.c | 1 + include/linux/mtd/rawnand.h | 14 ++ 6 files changed, 317 insertions(+), 143 deletions(-) create mode 100644 Documentation/devicetree/bindings/mtd/qcom,nandc.yaml delete mode 100644 Documentation/devicetree/bindings/mtd/qcom_nandc.txt -- 2.25.1