Message ID | beddbc374557e44ceec897e68c4a5d12764ddbb9.1676459308.git.christophe.jaillet@wanadoo.fr |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp141189wrn; Wed, 15 Feb 2023 03:41:52 -0800 (PST) X-Google-Smtp-Source: AK7set+LAa3Ri20BPh4oXdZaYDrS1pRePNR9LKYxUIbJLaAqKbwhS0L+ZS1m+OSho8KiIfRfEINP X-Received: by 2002:a05:6402:614:b0:4ac:da71:2723 with SMTP id n20-20020a056402061400b004acda712723mr1274221edv.38.1676461312425; Wed, 15 Feb 2023 03:41:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676461312; cv=none; d=google.com; s=arc-20160816; b=xk7aDFqoLCaY2B5efyH53vgK+jl+0iVkYgiLJomRk2VQE6vCnqQIOOd8M2hOtV4o0Q mez2KX/jnUH42ferGKYkz7NRxgVV/7rjgfJe7V0Gd9EP2jvHqnRhBWvE5527wIeE37Sn w/cP12vdLhTXPcvbs0e6BqV3CM87hPKnDc6lKklsi0OAinUfEX+EVm2N0ADYg8DMzRUs EfDzX597UcB5EGna8Nq3mpg1tUKUI/bnqPT2P3SpT92u7Fcsnhzff2Fja7wjKHCeKucY Bs6kKC8OfgN+O09iWscCl44INTFrEjClXh7xbzbIV2HRTB1Oz9FDfB00hNFZI582Ws2L b8EQ== 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 :message-id:date:subject:cc:to:from; bh=PMp4vHiUQodXtgZuhcWM7EMGp3oZWph6cWpLsCbKIr0=; b=MxXolmY08SyEjnVXGNyjSyfUgaSV8JvV+/NZnuqlMsL85UMbaSiPI4Hqqwiq/yFfbA cjX4lO15dfCcivzZEcljfYKIuNCK6iQcmKpa19Xe5SQSrpcnTBjI4OmGUQXoKNhCHgIX fUH86gLHPtmkuEYZen9mnuUteTgNgmtyyaTmEJK0yI7e8rh3a5pX6u9DsgWMpyx787h0 eTeQOK/mY4suKemqeiquY13sZccHUnOWu06EJXcO3HeZM9LZBKXalOkpCOy1CGdhkIKd dYARyhwsDzhzTJapUD+VpdP8+FaZGcYgypCu9Pr9RiELhCDJRgw5sEWb53EVuxd/kmMS nGsw== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l15-20020a056402344f00b004ace3ece9f8si4958345edc.504.2023.02.15.03.41.29; Wed, 15 Feb 2023 03:41:52 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229908AbjBOLJF (ORCPT <rfc822;tebrre53rla2o@gmail.com> + 99 others); Wed, 15 Feb 2023 06:09:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229503AbjBOLJC (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 15 Feb 2023 06:09:02 -0500 Received: from smtp.smtpout.orange.fr (smtp-19.smtpout.orange.fr [80.12.242.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00CB62914A for <linux-kernel@vger.kernel.org>; Wed, 15 Feb 2023 03:08:55 -0800 (PST) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id SFebpT64kwevESFebpYEea; Wed, 15 Feb 2023 12:08:54 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Wed, 15 Feb 2023 12:08:54 +0100 X-ME-IP: 86.243.2.178 From: Christophe JAILLET <christophe.jaillet@wanadoo.fr> To: Miquel Raynal <miquel.raynal@bootlin.com>, Richard Weinberger <richard@nod.at>, Vignesh Raghavendra <vigneshr@ti.com> Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET <christophe.jaillet@wanadoo.fr>, linux-mtd@lists.infradead.org Subject: [PATCH] mtd: nand: mxic-ecc: Fix mxic_ecc_data_xfer_wait_for_completion() when irq is used Date: Wed, 15 Feb 2023 12:08:45 +0100 Message-Id: <beddbc374557e44ceec897e68c4a5d12764ddbb9.1676459308.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757897096909043302?= X-GMAIL-MSGID: =?utf-8?q?1757897096909043302?= |
Series |
mtd: nand: mxic-ecc: Fix mxic_ecc_data_xfer_wait_for_completion() when irq is used
|
|
Commit Message
Christophe JAILLET
Feb. 15, 2023, 11:08 a.m. UTC
wait_for_completion_timeout() and readl_poll_timeout() don't handle their
return value the same way.
wait_for_completion_timeout() returns 0 on time out (and >0 in all other
cases)
readl_poll_timeout() returns 0 on success and -ETIMEDOUT upon a timeout.
In order for the error handling path to work in both cases, the logic
against wait_for_completion_timeout() needs to be inverted.
Fixes: 48e6633a9fa2 ("mtd: nand: mxic-ecc: Add Macronix external ECC engine support")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested only.
This is really spurious.
If I'm right, this means that it never worked!
Can any one with the hardware test?
---
drivers/mtd/nand/ecc-mxic.c | 1 +
1 file changed, 1 insertion(+)
Comments
Hi Christophe, christophe.jaillet@wanadoo.fr wrote on Wed, 15 Feb 2023 12:08:45 +0100: > wait_for_completion_timeout() and readl_poll_timeout() don't handle their > return value the same way. > > wait_for_completion_timeout() returns 0 on time out (and >0 in all other > cases) > readl_poll_timeout() returns 0 on success and -ETIMEDOUT upon a timeout. That's a shame, but yeah, excellent catch! > In order for the error handling path to work in both cases, the logic > against wait_for_completion_timeout() needs to be inverted. > > Fixes: 48e6633a9fa2 ("mtd: nand: mxic-ecc: Add Macronix external ECC engine support") > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > --- > Compile tested only. > > This is really spurious. > If I'm right, this means that it never worked! > > Can any one with the hardware test? The design I used for development and testing had no interrupt line available for that IIRC, so I only tested the polling case ('else' side) and completely overlooked that difference. I might have mentioned it in the cover letter, if I didn't, it's an oversight. > --- > drivers/mtd/nand/ecc-mxic.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/mtd/nand/ecc-mxic.c b/drivers/mtd/nand/ecc-mxic.c > index 8afdca731b87..6b487ffe2f2d 100644 > --- a/drivers/mtd/nand/ecc-mxic.c > +++ b/drivers/mtd/nand/ecc-mxic.c > @@ -429,6 +429,7 @@ static int mxic_ecc_data_xfer_wait_for_completion(struct mxic_ecc_engine *mxic) > mxic_ecc_enable_int(mxic); > ret = wait_for_completion_timeout(&mxic->complete, > msecs_to_jiffies(1000)); > + ret = ret ? 0 : -ETIMEDOUT; > mxic_ecc_disable_int(mxic); > } else { > ret = readl_poll_timeout(mxic->regs + INTRPT_STS, val, Thanks, Miquèl
On Wed, 2023-02-15 at 11:08:45 UTC, Christophe JAILLET wrote: > wait_for_completion_timeout() and readl_poll_timeout() don't handle their > return value the same way. > > wait_for_completion_timeout() returns 0 on time out (and >0 in all other > cases) > readl_poll_timeout() returns 0 on success and -ETIMEDOUT upon a timeout. > > In order for the error handling path to work in both cases, the logic > against wait_for_completion_timeout() needs to be inverted. > > Fixes: 48e6633a9fa2 ("mtd: nand: mxic-ecc: Add Macronix external ECC engine support") > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/fixes, thanks. Miquel
diff --git a/drivers/mtd/nand/ecc-mxic.c b/drivers/mtd/nand/ecc-mxic.c index 8afdca731b87..6b487ffe2f2d 100644 --- a/drivers/mtd/nand/ecc-mxic.c +++ b/drivers/mtd/nand/ecc-mxic.c @@ -429,6 +429,7 @@ static int mxic_ecc_data_xfer_wait_for_completion(struct mxic_ecc_engine *mxic) mxic_ecc_enable_int(mxic); ret = wait_for_completion_timeout(&mxic->complete, msecs_to_jiffies(1000)); + ret = ret ? 0 : -ETIMEDOUT; mxic_ecc_disable_int(mxic); } else { ret = readl_poll_timeout(mxic->regs + INTRPT_STS, val,