Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2907972iog; Mon, 27 Jun 2022 05:32:44 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uzW5wffX7FJjrZp7BR2QdmwfzPzxTvbkIOGdbDd+1Yi4CqCY8DrA4tEGhfG6xuONqeVPP1 X-Received: by 2002:a17:907:6289:b0:6e0:eb0c:8ee7 with SMTP id nd9-20020a170907628900b006e0eb0c8ee7mr12064918ejc.245.1656333164686; Mon, 27 Jun 2022 05:32:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656333164; cv=none; d=google.com; s=arc-20160816; b=lz2M94I5cT9Y9jiY0pqZc5KjrsqzMdfSSqQW+K5e71tHtzfAUEnFEnQrE6QAm3voPF IP4YWRGPhk3zQGYKYKGmZDmrmgP6kDk2T9gJmGY6giZHF8MndcET5lmMerpUFJfZrxH4 Ea71IqqKQMblN6KMOCEQZZMR/asZbtNi6gM3DDnQ9PWPnUC+LGQeUgtBvk5HNZlqIFZJ epXWkMlPmdLgHsvGtieZXFRgkvQr1Zyip7KtIasqosIUBQBDNrEAV4mP+ta10GC0vFit Jfwsa7mXta3oXccziQxA6QOsWf36DqmIn9OAOWMLh/17tOJinmA9PU1LFzoFrJFKmvqR 29Bg== 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=SE3bMOMZq91qMw4jXGDrOPxkYwEvilTnpAzVYFLZcwg=; b=OUYiXjgG5kelJ+IEC9mwoHqmdZ8jRyhypfmk8B2oeG0vpXL2CV7DU6YCi94IxYV+3D qoYi8eqUdJL+47RUA+hQmFa2BSFDGVKzST3eTy38pa23znU1eaPohz2rGB1tX4OiaqU1 OPj9vuetQH/5LlordE7dMpl+YMK+7nHvFAa0MFQIVUber64FFXdF6rYhGOMoK1NlUWRc p4/hNbKSN5M5sYaHYT+3WTWJfKjYIrhCncxhYsawoqnQO5z0MKivYqAKskbxsSi8Ddgz KZcMDTiDYvIpfWQEH5rVm3ecJtalRzpfLv3slLWkoV3tUI92JaVnWDdpHUNGKroFxgP3 0JZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=k3OKmUKJ; 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 z14-20020a1709063ace00b0071199fd04dbsi9707989ejd.654.2022.06.27.05.32.17; Mon, 27 Jun 2022 05:32:44 -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=k3OKmUKJ; 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 S237930AbiF0Lrd (ORCPT + 99 others); Mon, 27 Jun 2022 07:47:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237061AbiF0Ln1 (ORCPT ); Mon, 27 Jun 2022 07:43:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9ADBFB1DD; Mon, 27 Jun 2022 04:38:53 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 63F406114E; Mon, 27 Jun 2022 11:38:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C2B0C3411D; Mon, 27 Jun 2022 11:38:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656329931; bh=cyWN9GSpE86TC4Bmzj5vuAOc7rdJAmxOqjl8jaBSi5k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k3OKmUKJ8ifHIzZvTW6VD1ayT+xpD7ZhNNEZ4Ztn87c1KSvwTVrfFM2hRcl6LA+A5 xNsyHQ4+pHrirlxaWeW26Yi8FYAt2iyim1hURgh8FvVwYeqV2576Mv50anAJd6CWl/ u2ZkaL8mQEafuxfBOqfcEjxB1UssfGt+xm/maPQM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sascha Hauer , Miquel Raynal Subject: [PATCH 5.18 027/181] mtd: rawnand: gpmi: Fix setting busy timeout setting Date: Mon, 27 Jun 2022 13:20:00 +0200 Message-Id: <20220627111945.351432536@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627111944.553492442@linuxfoundation.org> References: <20220627111944.553492442@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.5 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: Sascha Hauer commit 06781a5026350cde699d2d10c9914a25c1524f45 upstream. The DEVICE_BUSY_TIMEOUT value is described in the Reference Manual as: | Timeout waiting for NAND Ready/Busy or ATA IRQ. Used in WAIT_FOR_READY | mode. This value is the number of GPMI_CLK cycles multiplied by 4096. So instead of multiplying the value in cycles with 4096, we have to divide it by that value. Use DIV_ROUND_UP to make sure we are on the safe side, especially when the calculated value in cycles is smaller than 4096 as typically the case. This bug likely never triggered because any timeout != 0 usually will do. In my case the busy timeout in cycles was originally calculated as 2408, which multiplied with 4096 is 0x968000. The lower 16 bits were taken for the 16 bit wide register field, so the register value was 0x8000. With 2970bf5a32f0 ("mtd: rawnand: gpmi: fix controller timings setting") however the value in cycles became 2384, which multiplied with 4096 is 0x950000. The lower 16 bit are 0x0 now resulting in an intermediate timeout when reading from NAND. Fixes: b1206122069aa ("mtd: rawnand: gpmi: use core timings instead of an empirical derivation") Cc: stable@vger.kernel.org Signed-off-by: Sascha Hauer Signed-off-by: Miquel Raynal Link: https://lore.kernel.org/linux-mtd/20220614083138.3455683-1-s.hauer@pengutronix.de Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c @@ -695,7 +695,7 @@ static int gpmi_nfc_compute_timings(stru hw->timing0 = BF_GPMI_TIMING0_ADDRESS_SETUP(addr_setup_cycles) | BF_GPMI_TIMING0_DATA_HOLD(data_hold_cycles) | BF_GPMI_TIMING0_DATA_SETUP(data_setup_cycles); - hw->timing1 = BF_GPMI_TIMING1_BUSY_TIMEOUT(busy_timeout_cycles * 4096); + hw->timing1 = BF_GPMI_TIMING1_BUSY_TIMEOUT(DIV_ROUND_UP(busy_timeout_cycles, 4096)); /* * Derive NFC ideal delay from {3}: