Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1414075imm; Sun, 23 Sep 2018 03:40:06 -0700 (PDT) X-Google-Smtp-Source: ACcGV61wzepiyNU009gFX70a6+XZ3BuCbmROfO6Ttq1seEkk0MW/+FySn9VW1KVzHuVY4+GVNLYb X-Received: by 2002:a17:902:4201:: with SMTP id g1-v6mr6184046pld.203.1537699206431; Sun, 23 Sep 2018 03:40:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537699206; cv=none; d=google.com; s=arc-20160816; b=JO6mDCx6K8n7W5CgHGvQUcQfExNc604o2lnv/WYcA9ZJQlql5ZBqq2SH/55TsFy2fH 7e3MCQI1QCVLvdU39Ukx+SkqQehqEdz2Y1uF3+sBf5xetTyVLIvL2txz1ehgp8+YD9Mq fYyp7gECAu911taBOlga+3VnBYrqsFAYxCpYXykWYa5qURu0B9zxIBQOO/rpCPXFN1cd EbdExW5djdNOz4tW2/Hpo6rFI69rAmsi2j1h98hyxnioALBXllFkD29HUnj4OZrDRd67 1tiYbLYTRGWDNxmA4Rmy+NHrZ0jCLfpAM+dS+LLJAqVlgkZTSZawWhWWbFNwasjd7bny 4WSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature:dkim-filter; bh=pa/jP2LMB4EsNqAo1vydB5oZns6ko4DZvNfPjwxB9Jc=; b=qi2+NTlnerF5yKZ0L0jxbe/x03uU6yT3Djk0MfiIwWYWBKKAx/IdLUeJR83P5m4Lqr QKY+QEra6PuLxknqkzL0of78Q/Kv8TYu6ji70oKZAuaEboJcmcMcKy9b7qJHfzbyGmU7 BlPSD/JxPCVhVJfrckFIKS3TeW0os/pr+fJi+PsTruQAC0MqXcN4aF05Sdu5oUrnIZfy pjyLyGI5aEEP/0u5s8850g6/KvaJhj3bcTYZeJrIxuXM9xoZK/xxwfUU8liDRbVC4l4G 8fBIND3eM4YTpH2+mdmLCBBHly+n7Gh81hj2jHbRu3EaqtrWQZHccdfmlAS7no2J/u/V h05g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=yiyxxQdm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f17-v6si5951907pgf.660.2018.09.23.03.39.50; Sun, 23 Sep 2018 03:40:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=yiyxxQdm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726133AbeIWQgr (ORCPT + 99 others); Sun, 23 Sep 2018 12:36:47 -0400 Received: from conssluserg-03.nifty.com ([210.131.2.82]:56245 "EHLO conssluserg-03.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726054AbeIWQgr (ORCPT ); Sun, 23 Sep 2018 12:36:47 -0400 Received: from mail-ua1-f41.google.com (mail-ua1-f41.google.com [209.85.222.41]) (authenticated) by conssluserg-03.nifty.com with ESMTP id w8NAdLQc010501; Sun, 23 Sep 2018 19:39:22 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-03.nifty.com w8NAdLQc010501 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1537699162; bh=pa/jP2LMB4EsNqAo1vydB5oZns6ko4DZvNfPjwxB9Jc=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=yiyxxQdmj69ZNloDE3GqylJpd1AxRk5atQtLHq2nhOdBvEccMRLDbvf4uJpTdsW3s nQbkAF32JGnmdsMZkSI/mXgWW9Y/9houwFi+7jm+wf9p4JkeVcv8mZGm9hrIfsOyX9 D15cxdZlDEjTk8xauwRBlZOd/ObysAmYxF/LUf+RE6FtterFNfgwGkW6hsl3ISswaH c8xGBv1K6F4VLgi3KCSLAO6lub4lQJSljHQoDOK866TtPN8y02MvrdDDraROM5e9DF E4PC85AQ/zJeNCie0QK92Ud1l1xJKMBwaWkmepfhELYGoEyBw00bgW8Z51a3nMSd9A /BBNsKJxvI1zw== X-Nifty-SrcIP: [209.85.222.41] Received: by mail-ua1-f41.google.com with SMTP id f4-v6so7308603uao.10; Sun, 23 Sep 2018 03:39:22 -0700 (PDT) X-Gm-Message-State: ABuFfogs4WvP8kGbPCnQFY6gze+p6s+WczkVlkvJw1LI7/RViEXYbC/j Fz53E2ySQd9E49orf7+uUz+1pvohYvH+Cau2h/A= X-Received: by 2002:a9f:3826:: with SMTP id p35-v6mr1364584uad.42.1537699161027; Sun, 23 Sep 2018 03:39:21 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ab0:7111:0:0:0:0:0 with HTTP; Sun, 23 Sep 2018 03:38:40 -0700 (PDT) In-Reply-To: <20180922101116.7c9b4767@bbrezillon> References: <1536317783-4942-1-git-send-email-yamada.masahiro@socionext.com> <20180907160822.319047c8@bbrezillon> <20180907165348.3e0027ee@bbrezillon> <20180922094111.1c2969e8@xps13> <20180922101116.7c9b4767@bbrezillon> From: Masahiro Yamada Date: Sun, 23 Sep 2018 06:38:40 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] mtd: rawnand: denali: add DT property to specify skipped bytes in OOB To: Boris Brezillon Cc: Miquel Raynal , Mark Rutland , DTML , Dinh Nguyen , Richard Weinberger , Linux Kernel Mailing List , Rob Herring , linux-mtd , Brian Norris , David Woodhouse , Marek Vasut Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2018-09-22 4:11 GMT-04:00 Boris Brezillon : > On Sat, 22 Sep 2018 09:41:11 +0200 > Miquel Raynal wrote: > >> Hi Masahiro, >> >> Masahiro Yamada wrote on Sat, 8 Sep >> 2018 01:10:25 +0900: >> >> > Hi Boris, >> > >> > 2018-09-07 23:53 GMT+09:00 Boris Brezillon : >> > > On Fri, 7 Sep 2018 23:42:53 +0900 >> > > Masahiro Yamada wrote: >> > > >> > >> Hi Boris, >> > >> >> > >> 2018-09-07 23:08 GMT+09:00 Boris Brezillon : >> > >> > Hi Masahiro, >> > >> > >> > >> > On Fri, 7 Sep 2018 19:56:23 +0900 >> > >> > Masahiro Yamada wrote: >> > >> > >> > >> >> NAND devices need additional data area (OOB) for error correction, >> > >> >> but it is also used for Bad Block Marker (BBM). In many cases, the >> > >> >> first byte in OOB is used for BBM, but the location actually depends >> > >> >> on chip vendors. The NAND controller should preserve the precious >> > >> >> BBM to keep track of bad blocks. >> > >> >> >> > >> >> In Denali IP, the SPARE_AREA_SKIP_BYTES register is used to specify >> > >> >> the number of bytes to skip from the start of OOB. The ECC engine >> > >> >> will automatically skip the specified number of bytes when it gets >> > >> >> access to OOB area. >> > >> >> >> > >> >> The same value for SPARE_AREA_SKIP_BYTES should be used between >> > >> >> firmware and the operating system if you intend to use the NAND >> > >> >> device across the control hand-off. >> > >> >> >> > >> >> In fact, the current denali.c code expects firmware to have already >> > >> >> set the SPARE_AREA_SKIP_BYTES register, then reads the value out. >> > >> >> >> > >> >> If no firmware (or bootloader) has initialized the controller, the >> > >> >> register value is zero, which is the default after power-on-reset. >> > >> >> >> > >> >> In other words, the Linux driver cannot initialize the controller >> > >> >> by itself. You cannot support the reset control either because >> > >> >> resetting the controller will get register values lost. >> > >> >> >> > >> >> This commit adds a way to specify it via DT. If the property >> > >> >> "denali,oob-skip-bytes" exists, the value will be set to the register. >> > >> > >> > >> > Hm, do we really need to make this config customizable? I mean, either >> > >> > you have a large-page NAND (page > 512 bytes) and the 2 first bytes >> > >> > must be reserved for the BBM or you have a small-page NAND and the BBM >> > >> > is at position 4 and 5. Are you sure people configure that differently? >> > >> > Don't you always have SPARE_AREA_SKIP_BYTES set to 6 or 2? >> > >> >> > >> >> > >> As I said in the patch description, >> > >> I need to use the same SPARE_AREA_SKIP_BYTES value >> > >> across firmware, boot-loader, Linux, and whatever. >> > >> >> > >> I want to set the value to 8 for my platform >> > >> because the on-chip boot ROM expects 8. >> > >> I cannot change it since the boot ROM is hard-wired. >> > >> >> > >> >> > >> The boot ROM skips 8 bytes in OOB >> > >> when it loads images from the on-board NAND device. >> > >> >> > >> So, when I update the image from U-Boot or Linux, >> > >> I need to make sure to set the register to 8. >> > >> >> > >> If I update the image with a different value, >> > >> the Boot ROM fails to boot. >> > >> >> > >> >> > >> >> > >> When the system has booted from NAND, >> > >> the register is already set to 8. It works. >> > >> >> > >> However, when the system has booted from eMMC, >> > >> the register is not initialized by anyone. >> > >> I am searching for a way to set the register to 8 >> > >> in this case. > > Maybe there's a solution which does not involve attaching a per-compat > value or adding a DT prop. If the FW/bootloader has not initialized this > register the value is 0, right? Why not testing the value and > assigning it to the default (8) if it's not been initialized by the > bootloader. That shouldn't break existing platforms since I don't think > 0 is a valid value anyway. > > denali->oob_skip_bytes = ioread32(denali->reg + > SPARE_AREA_SKIP_BYTES); > if (!denali->oob_skip_bytes) { > denali->oob_skip_bytes = DEFAULT_OOB_SKIP_BYTES; > iowrite32(denali->oob_skip_bytes, > denali->reg + SPARE_AREA_SKIP_BYTES); > } > I prefer per-compatible values to a fixed default. I'd like to set the register to 8 unless set otherwise because the boot ROM on my platform (Socionext UniPhier SoCs) uses that value. Other platforms like Altera SOCFPGA may want to use a different value (at least, I do not know what is the preferred value). -- Best Regards Masahiro Yamada