From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DB603C54E94 for ; Thu, 26 Jan 2023 08:04:10 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0BC1E854CE; Thu, 26 Jan 2023 09:04:08 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="BWbBxj+m"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 95DC2856C7; Thu, 26 Jan 2023 09:04:06 +0100 (CET) Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id AC59084DDE for ; Thu, 26 Jan 2023 09:04:03 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=zajec5@gmail.com Received: by mail-ej1-x62b.google.com with SMTP id kt14so2996998ejc.3 for ; Thu, 26 Jan 2023 00:04:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=7gvLabpmMmoDxkkMdQkoLoJi6+y8E5lpWp7BJpDxURU=; b=BWbBxj+mKl1wCD2Ownh1MN3rwryjr2o4Y9DSNukwY8a7CxSJ6vuK7RdaW62+fF0xLp pOCPT4Z0G6BdKC0ZbLgDhKVbl+xgDJojyW5G10PMBbq+3Ioh93THnXoIgXTtpyxcg+9g GOuWDc2ptdorvnkDNIptnc4T9RD0CMG8IMpiqILMVCOQpoPm+GHuD+9J7DepNMmlyqZp BSfuAGsob53TfNXc8e9rKcqx013W/iE4B+H844vIZ55qsbKm5HA8/xdJJZdA/AB0nkXs I+2EoFUoCVeEwjd2WPmRuQ3lBQAR3bo4Njhwldn+tB8Ffa2CxYDtSQ9iRp/Gpyeq8iTa 9DBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=7gvLabpmMmoDxkkMdQkoLoJi6+y8E5lpWp7BJpDxURU=; b=jV0CI1+Gc+1wVfw+GR1Vd57BdiP1J5iu+14df7Mm6IcDToO9Uswk+tEjj9aYktbSPF 9Wxw7i1NsizEzJtdbmAnVrnL9I0KfuUS+GMePmDTeDKOCBFTyIm/ZsTi5Eih1JIb9xwY KsJwgwTVYDi6KZZazbUwtaJWt6+QlCK32ReFswiWsetgX5I238S9mN+OTzuTkK2zRKNw KhVNbLJDF2G+Jgjzk2EAb2Ih7rKM5+5EiMefnB1VE1GPnANCVi1pjKQ27Zmv/jLcikCR 49psP/zuuei/wFxJb9E7tCX3Ps5Z+Q1knFj0dzkSJBua22NAakezFXJn/EjA8Yp85101 6e2A== X-Gm-Message-State: AO0yUKVH3gjfFjSQAng3jvMQfWcUuOg+6Kqvdgto7cxSEq6+iSzh9f4c pRNfNXo5Mk3znzatvTGMsCk= X-Google-Smtp-Source: AK7set+pXABw4yIZAGKHE4/BQhS++1Vt+P0MrQLQVf5I7SSv8lYRqAf/DEnympFWoSYlpo1tw5C5Ug== X-Received: by 2002:a17:906:960d:b0:878:4dd1:5161 with SMTP id s13-20020a170906960d00b008784dd15161mr2836123ejx.11.1674720243069; Thu, 26 Jan 2023 00:04:03 -0800 (PST) Received: from [192.168.26.149] (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.googlemail.com with ESMTPSA id c7-20020a170906d18700b00871f66bf354sm201383ejz.204.2023.01.26.00.04.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Jan 2023 00:04:02 -0800 (PST) Message-ID: Date: Thu, 26 Jan 2023 09:04:00 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:96.0) Gecko/20100101 Thunderbird/96.0 Subject: Re: [PATCH] mtd: rawnand: nand_base: Handle algorithm selection To: William Zhang , Linus Walleij , u-boot@lists.denx.de, Tom Rini Cc: Anand Gore , Kursad Oney , Joel Peshkin , Philippe Reynes , Brian Norris References: <20230121234338.2242486-1-linus.walleij@linaro.org> <67b8db8e-0cd9-b2d1-19ff-ba9afdab15d2@broadcom.com> From: =?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?= In-Reply-To: <67b8db8e-0cd9-b2d1-19ff-ba9afdab15d2@broadcom.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean On 26.01.2023 02:14, William Zhang wrote: > On 01/21/2023 03:43 PM, Linus Walleij wrote: >> For BRCMNAND with 1-bit BCH ECC (BCH-1) such as used on the >> D-Link DIR-885L and DIR-890L routers, we need to explicitly >> select the ECC like this in the device tree: >> >>    nand-ecc-algo = "bch"; >>    nand-ecc-strength = <1>; >>    nand-ecc-step-size = <512>; >> >> This is handled by the Linux kernel but U-Boot core does >> not respect this. Fix it up by parsing the algorithm and >> preserve the behaviour using this property to select >> software BCH as far as possible. > > For 1 bit HW ECC, the BRCMNAND driver only uses HAMMING ECC.  The brcmnand_setup_dev function should take care of it with just these two properties in the device tress without any code changes: >     nand-ecc-strength = <1>; >     nand-ecc-step-size = <512>; > unless these D-Link device has always been using software BCH-1 and wants to continue to use software BCH-1. Please check arch/arm/boot/dts/bcm5301x-nand-cs0-bch1.dtsi https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm/boot/dts/bcm5301x-nand-cs0-bch1.dtsi It's included by arch/arm/boot/dts/bcm47094-dlink-dir-885l.dts https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm/boot/dts/bcm47094-dlink-dir-885l.dts I can confirm D-Link decided to use BCH-1 for some of its devices. I didn't expect it neither and that required fixing up brcmnand driver in Linux actually. > BTW,  I didn't see this change from master branch of linux nand base driver. The "nand-ecc-algo" is only used by the ecc engine code(ecc.c) but this code is not in the u-boot obviously. Were you porting this from a different version of linux nand driver? My original proposal for brcmnand looked like this: [PATCH 3/3] mtd: brcmnand: respect ECC algorithm set by NAND subsystem https://lore.kernel.org/lkml/1461324197-1333-3-git-send-email-zajec5@gmail.com/ It was reworked by Brian to a more backward compatible solution that got accepted: [PATCH] mtd: brcmnand: respect ECC algorithm set by the NAND subsystem https://lore.kernel.org/lkml/20160426055355.GA25981@localhost/ https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=666b65683dad9aa90efaa4aad24ef3710101e3aa