From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751287AbdCVVM1 (ORCPT ); Wed, 22 Mar 2017 17:12:27 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:50482 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750955AbdCVVMV (ORCPT ); Wed, 22 Mar 2017 17:12:21 -0400 Date: Wed, 22 Mar 2017 22:12:16 +0100 From: Boris Brezillon To: Masahiro Yamada Cc: linux-mtd@lists.infradead.org, laurent.monat@idquantique.com, thorsten.christiansson@idquantique.com, Enrico Jorns , Jason Roberts , Artem Bityutskiy , Dinh Nguyen , Marek Vasut , Brian Norris , Graham Moore , David Woodhouse , Masami Hiramatsu , Chuanxiao Dong , Jassi Brar , linux-kernel@vger.kernel.org, Richard Weinberger , Cyrille Pitchen Subject: Re: [PATCH v2 12/53] mtd: nand: denali: support HW_ECC_FIXUP capability Message-ID: <20170322221216.26539147@bbrezillon> In-Reply-To: <1490191680-14481-13-git-send-email-yamada.masahiro@socionext.com> References: <1490191680-14481-1-git-send-email-yamada.masahiro@socionext.com> <1490191680-14481-13-git-send-email-yamada.masahiro@socionext.com> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 22 Mar 2017 23:07:19 +0900 Masahiro Yamada wrote: > +static int denali_hw_ecc_fixup(struct mtd_info *mtd, > + struct denali_nand_info *denali) > +{ > + int bank = denali->flash_bank; > + uint32_t ecc_cor; > + unsigned int max_bitflips; > + > + ecc_cor = ioread32(denali->flash_reg + ECC_COR_INFO(bank)); > + ecc_cor >>= ECC_COR_INFO__SHIFT(bank); > + > + if (ecc_cor & ECC_COR_INFO__UNCOR_ERR) > + return -EBADMSG; As previously mentioned, just increment ecc_stats.failed. > + > + max_bitflips = ecc_cor & ECC_COR_INFO__MAX_ERRORS; > + > + /* > + * The register holds the maximum of the number of corrected bitflips > + * per sector. This can be returned from ecc->read_page() as-is. > + * Unfortunately, we can not know the total number of corrected bits > + * in the page. mtd->ecc_stats.corrected is compromised here. > + */ > + mtd->ecc_stats.corrected += max_bitflips; > + > + return max_bitflips; > +}