[{"id":1780336,"web_url":"http://patchwork.ozlabs.org/comment/1780336/","msgid":"<20171005092249.103518f8@bbrezillon>","list_archive_url":null,"date":"2017-10-05T07:22:49","subject":"Re: [PATCH v4 4/8] mtd: nand: atmel: Avoid ECC errors when leaving\n\tbackup mode","submitter":{"id":63120,"url":"http://patchwork.ozlabs.org/api/people/63120/","name":"Boris Brezillon","email":"boris.brezillon@free-electrons.com"},"content":"On Thu, 28 Sep 2017 11:46:23 +0200\nRomain Izard <romain.izard.pro@gmail.com> wrote:\n\n> During backup mode, the contents of all registers will be cleared as the\n> SoC will be completely powered down. For a product that boots on NAND\n> Flash memory, the bootloader will obviously use the related controller\n> to read the Flash and correct any detected error in the memory, before\n> handling back control to the kernel's resuming entry point.\n> \n> But it does not clean the NAND controller registers after use and on its\n> side the kernel driver expects the error locator to be powered down and\n> in a clean state. Add a resume hook for the PMECC error locator, and\n> reset its registers.\n> \n> Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>\n\nApplied.\n\nThanks,\n\nBoris\n\n> ---\n> Changes in v3:\n> * keep the PMECC disabled when not in use, and use atmel_pmecc_resume to\n>   reset the controller after the bootloader has left it enabled.\n> \n> Changes in v4:\n> * export atmel_pmecc_reset instead of atmel_pmecc_resume\n> * use the correct pointer in atmel_nand_controller_resume\n> \n>  drivers/mtd/nand/atmel/nand-controller.c |  3 +++\n>  drivers/mtd/nand/atmel/pmecc.c           | 17 +++++++++--------\n>  drivers/mtd/nand/atmel/pmecc.h           |  1 +\n>  3 files changed, 13 insertions(+), 8 deletions(-)\n> \n> diff --git a/drivers/mtd/nand/atmel/nand-controller.c b/drivers/mtd/nand/atmel/nand-controller.c\n> index f25eca79f4e5..8afcff9a66ea 100644\n> --- a/drivers/mtd/nand/atmel/nand-controller.c\n> +++ b/drivers/mtd/nand/atmel/nand-controller.c\n> @@ -2530,6 +2530,9 @@ static __maybe_unused int atmel_nand_controller_resume(struct device *dev)\n>  \tstruct atmel_nand_controller *nc = dev_get_drvdata(dev);\n>  \tstruct atmel_nand *nand;\n>  \n> +\tif (nc->pmecc)\n> +\t\tatmel_pmecc_reset(nc->pmecc);\n> +\n>  \tlist_for_each_entry(nand, &nc->chips, node) {\n>  \t\tint i;\n>  \n> diff --git a/drivers/mtd/nand/atmel/pmecc.c b/drivers/mtd/nand/atmel/pmecc.c\n> index 146af8218314..0a3f12141c45 100644\n> --- a/drivers/mtd/nand/atmel/pmecc.c\n> +++ b/drivers/mtd/nand/atmel/pmecc.c\n> @@ -765,6 +765,13 @@ void atmel_pmecc_get_generated_eccbytes(struct atmel_pmecc_user *user,\n>  }\n>  EXPORT_SYMBOL_GPL(atmel_pmecc_get_generated_eccbytes);\n>  \n> +void atmel_pmecc_reset(struct atmel_pmecc *pmecc)\n> +{\n> +\twritel(PMECC_CTRL_RST, pmecc->regs.base + ATMEL_PMECC_CTRL);\n> +\twritel(PMECC_CTRL_DISABLE, pmecc->regs.base + ATMEL_PMECC_CTRL);\n> +}\n> +EXPORT_SYMBOL_GPL(atmel_pmecc_reset);\n> +\n>  int atmel_pmecc_enable(struct atmel_pmecc_user *user, int op)\n>  {\n>  \tstruct atmel_pmecc *pmecc = user->pmecc;\n> @@ -797,10 +804,7 @@ EXPORT_SYMBOL_GPL(atmel_pmecc_enable);\n>  \n>  void atmel_pmecc_disable(struct atmel_pmecc_user *user)\n>  {\n> -\tstruct atmel_pmecc *pmecc = user->pmecc;\n> -\n> -\twritel(PMECC_CTRL_RST, pmecc->regs.base + ATMEL_PMECC_CTRL);\n> -\twritel(PMECC_CTRL_DISABLE, pmecc->regs.base + ATMEL_PMECC_CTRL);\n> +\tatmel_pmecc_reset(user->pmecc);\n>  \tmutex_unlock(&user->pmecc->lock);\n>  }\n>  EXPORT_SYMBOL_GPL(atmel_pmecc_disable);\n> @@ -855,10 +859,7 @@ static struct atmel_pmecc *atmel_pmecc_create(struct platform_device *pdev,\n>  \n>  \t/* Disable all interrupts before registering the PMECC handler. */\n>  \twritel(0xffffffff, pmecc->regs.base + ATMEL_PMECC_IDR);\n> -\n> -\t/* Reset the ECC engine */\n> -\twritel(PMECC_CTRL_RST, pmecc->regs.base + ATMEL_PMECC_CTRL);\n> -\twritel(PMECC_CTRL_DISABLE, pmecc->regs.base + ATMEL_PMECC_CTRL);\n> +\tatmel_pmecc_reset(pmecc);\n>  \n>  \treturn pmecc;\n>  }\n> diff --git a/drivers/mtd/nand/atmel/pmecc.h b/drivers/mtd/nand/atmel/pmecc.h\n> index a8ddbfca2ea5..817e0dd9fd15 100644\n> --- a/drivers/mtd/nand/atmel/pmecc.h\n> +++ b/drivers/mtd/nand/atmel/pmecc.h\n> @@ -61,6 +61,7 @@ atmel_pmecc_create_user(struct atmel_pmecc *pmecc,\n>  \t\t\tstruct atmel_pmecc_user_req *req);\n>  void atmel_pmecc_destroy_user(struct atmel_pmecc_user *user);\n>  \n> +void atmel_pmecc_reset(struct atmel_pmecc *pmecc);\n>  int atmel_pmecc_enable(struct atmel_pmecc_user *user, int op);\n>  void atmel_pmecc_disable(struct atmel_pmecc_user *user);\n>  int atmel_pmecc_wait_rdy(struct atmel_pmecc_user *user);\n\n--\nTo unsubscribe from this list: send the line \"unsubscribe linux-pwm\" in\nthe body of a message to majordomo@vger.kernel.org\nMore majordomo info at  http://vger.kernel.org/majordomo-info.html","headers":{"Return-Path":"<linux-pwm-owner@vger.kernel.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=linux-pwm-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3y745Z0JPSz9t2Z\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu,  5 Oct 2017 18:24:18 +1100 (AEDT)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751432AbdJEHWz (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tThu, 5 Oct 2017 03:22:55 -0400","from mail.free-electrons.com ([62.4.15.54]:33794 \"EHLO\n\tmail.free-electrons.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751419AbdJEHWw (ORCPT\n\t<rfc822;linux-pwm@vger.kernel.org>); Thu, 5 Oct 2017 03:22:52 -0400","by mail.free-electrons.com (Postfix, from userid 110)\n\tid BB19820961; Thu,  5 Oct 2017 09:22:49 +0200 (CEST)","from bbrezillon (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr\n\t[90.63.216.87])\n\tby mail.free-electrons.com (Postfix) with ESMTPSA id 331A82095E;\n\tThu,  5 Oct 2017 09:22:49 +0200 (CEST)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on\n\tmail.free-electrons.com","X-Spam-Level":"","X-Spam-Status":"No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT\n\tshortcircuit=ham autolearn=disabled version=3.4.0","Date":"Thu, 5 Oct 2017 09:22:49 +0200","From":"Boris Brezillon <boris.brezillon@free-electrons.com>","To":"Romain Izard <romain.izard.pro@gmail.com>","Cc":"Michael Turquette <mturquette@baylibre.com>,\n\tStephen Boyd <sboyd@codeaurora.org>, Lee Jones <lee.jones@linaro.org>,\n\tWenyou Yang <wenyou.yang@atmel.com>, Josh Wu <rainyfeeling@outlook.com>,\n\tRichard Weinberger <richard@nod.at>,\n\tDavid Woodhouse <dwmw2@infradead.org>,\n\tBrian Norris <computersforpeace@gmail.com>,\n\tMarek Vasut <marek.vasut@gmail.com>,\n\tCyrille Pitchen <cyrille.pitchen@wedev4u.fr>,\n\tThierry Reding <thierry.reding@gmail.com>,\n\tRichard Genoud <richard.genoud@gmail.com>,\n\tGreg Kroah-Hartman <gregkh@linuxfoundation.org>,\n\tJiri Slaby <jslaby@suse.com>, Alan Stern <stern@rowland.harvard.edu>,\n\tLudovic Desroches <ludovic.desroches@microchip.com>,\n\tNicolas Ferre <nicolas.ferre@microchip.com>,\n\tAlexandre Belloni <alexandre.belloni@free-electrons.com>,\n\tlinux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,\n\tlinux-mtd@lists.infradead.org, linux-pwm@vger.kernel.org,\n\tlinux-serial@vger.kernel.org, linux-usb@vger.kernel.org","Subject":"Re: [PATCH v4 4/8] mtd: nand: atmel: Avoid ECC errors when leaving\n\tbackup mode","Message-ID":"<20171005092249.103518f8@bbrezillon>","In-Reply-To":"<20170928094627.31017-5-romain.izard.pro@gmail.com>","References":"<20170928094627.31017-1-romain.izard.pro@gmail.com>\n\t<20170928094627.31017-5-romain.izard.pro@gmail.com>","X-Mailer":"Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu)","MIME-Version":"1.0","Content-Type":"text/plain; charset=US-ASCII","Content-Transfer-Encoding":"7bit","Sender":"linux-pwm-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<linux-pwm.vger.kernel.org>","X-Mailing-List":"linux-pwm@vger.kernel.org"}}]