Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1886295rwb; Fri, 19 Aug 2022 11:04:14 -0700 (PDT) X-Google-Smtp-Source: AA6agR55+ibS5mBiK0jAfoeTOO59HFCQyTU7CQg4Dg/XK95p/4O40j+iFgSyAOPrUNHqG744waDf X-Received: by 2002:a63:8b44:0:b0:41c:df4c:7275 with SMTP id j65-20020a638b44000000b0041cdf4c7275mr7358912pge.434.1660932253995; Fri, 19 Aug 2022 11:04:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660932253; cv=none; d=google.com; s=arc-20160816; b=zEWCk/mEIxEpe8TLkp5RG64ga/H1F+9VObOMAVPH9cxSDfE2jESLBo2BqTkHBCIKdH eY0JQSjgMTH3satcUYSvUPL9watjPJBZO15NtXibOgsZYBHgotGFsssEa/RQaB6JUyFC E/Q69BhNWjkc4DUI6fjWXqbfGTWVRNicTfpGbn7KrdX2T6zozROLx/sXaLDcIg/5nJhw k6t8z9Fd/jGgGVlp0aBJ2OxpDu0lafigZBqEccJ1i6OHaR8lgV3He/tMPw0WUdr9ozu4 8v5sYsZLhewCKsaEvoVIWqxvCqJnPhIPkRsnp8fKpYUnwJwDwanNVpmZZKxVR7YmUORV 6ggw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=542S47hAZJZUojwTssNH1bhOlfuCOtDOVs8fGzb36yY=; b=cIiTvJ9rsemQ6J4jI7lIjk4PbuLGd4qus1oGFCpdO67WbkrpYm3yidCtWooJ7jmZZF 7xZalOzUGU1rc2h4At85Tx2UgMP+gi6B10VCdW6vKEEXXnb8MTjemN929zrD9mjzrjpF pRmnJp5wCYcuVqnj1h/OVxeifwkTCxVoFEy+8bFVQ3XVk1Br9qhyrF35deDPFlKLQpJ5 nE5ygP7XXUoWqIblW0zuZL2mv+gFIv9zrqDFHr9y24rOrghtRqCxEf29ElC2J+AQdkfU yMQITrYiihJ25HPwN1+3apD+XzKfyIfwpOXYb03Oi4a2/Gx4gGLbk40ksY79MiAnKX5V RCxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=n5JwbhQv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bc5-20020a170902930500b00172c1c0c117si2156646plb.214.2022.08.19.11.04.01; Fri, 19 Aug 2022 11:04:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=n5JwbhQv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354368AbiHSQyS (ORCPT + 99 others); Fri, 19 Aug 2022 12:54:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354351AbiHSQws (ORCPT ); Fri, 19 Aug 2022 12:52:48 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E038E12CDE3; Fri, 19 Aug 2022 09:14:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 43290CE26B7; Fri, 19 Aug 2022 16:13:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C40FC433D7; Fri, 19 Aug 2022 16:13:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660925612; bh=lwuN6VTFP1zBL9eoIkTQqR16l7lBZMYs5E+TzRiZ2B8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n5JwbhQvLcZf+d3MkT9L4fLOyE1Zx2W9wxCDiB4OkhLpGqoHdR2mOTBhOFIrjBfvH HZ5MFquHOoOVWVpeVb8DrDeVihlHe+yUcM72eXjkKuOaXe6/JG/SqfOyfCxhO6DRGN XH6UG+jNocAYVVFKpVhLn4yQTmmrHg8OTvCcFQ4o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miquel Raynal Subject: [PATCH 5.10 538/545] mtd: rawnand: arasan: Prevent an unsupported configuration Date: Fri, 19 Aug 2022 17:45:08 +0200 Message-Id: <20220819153853.664599425@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miquel Raynal commit fc9e18f9e987ad46722dad53adab1c12148c213c upstream. Under the following conditions: * after rounding up by 4 the number of bytes to transfer (this is related to the controller's internal constraints), * if this (rounded) amount of data is situated beyond the end of the device, * and only in NV-DDR mode, the Arasan NAND controller timeouts. This currently can happen in a particular helper used when picking software ECC algorithms. Let's prevent this situation by refusing to use the NV-DDR interface with software engines. Fixes: 4edde6031458 ("mtd: rawnand: arasan: Support NV-DDR interface") Signed-off-by: Miquel Raynal Link: https://lore.kernel.org/linux-mtd/20211008163640.1753821-1-miquel.raynal@bootlin.com Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/nand/raw/arasan-nand-controller.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) --- a/drivers/mtd/nand/raw/arasan-nand-controller.c +++ b/drivers/mtd/nand/raw/arasan-nand-controller.c @@ -891,6 +891,21 @@ static int anfc_setup_interface(struct n nvddr = nand_get_nvddr_timings(conf); if (IS_ERR(nvddr)) return PTR_ERR(nvddr); + + /* + * The controller only supports data payload requests which are + * a multiple of 4. In practice, most data accesses are 4-byte + * aligned and this is not an issue. However, rounding up will + * simply be refused by the controller if we reached the end of + * the device *and* we are using the NV-DDR interface(!). In + * this situation, unaligned data requests ending at the device + * boundary will confuse the controller and cannot be performed. + * + * This is something that happens in nand_read_subpage() when + * selecting software ECC support and must be avoided. + */ + if (chip->ecc.engine_type == NAND_ECC_ENGINE_TYPE_SOFT) + return -ENOTSUPP; } else { sdr = nand_get_sdr_timings(conf); if (IS_ERR(sdr))