From patchwork Mon Apr 26 14:39:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrice CHOTARD X-Patchwork-Id: 427683 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8318FC433ED for ; Mon, 26 Apr 2021 14:39:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5830F6101B for ; Mon, 26 Apr 2021 14:39:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233794AbhDZOkc (ORCPT ); Mon, 26 Apr 2021 10:40:32 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:24066 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233691AbhDZOkc (ORCPT ); Mon, 26 Apr 2021 10:40:32 -0400 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 13QEcGPU015802; Mon, 26 Apr 2021 16:39:39 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=lFJy9ccCm1PICKyVeTRoH866ML1NyAIfvIYxbbK1sKg=; b=e/XRIiBreWYUI3DY1MdI//XwCqziOHyve4kXKeACbb4ubERoBOwejjF1fQb9vMJEEf2p Jsjz77/9Kx+a4haGwWvYjXC865uDISp5GJK63aywDn0TosIvYLwIpZ/Wz04gVT4wELJE 2avt+QPLxVRqanSvBzwfuEfdBCytEZFwWiEsnNEMqauCj9BQgSs/S+T17a/UrpDLIjmi 4jmSkVasbYBhKAdn8ZBmT11bZ7zm2BituAr/ygCwakevQwGBMQOGxBKaDvcaxiWAgRou OhC1U0JOPH2LyENfhm0qNRP9PKc1R0cvu+bqK32vhuqtpa1BjKOBknCYNPdc9KsgRV4p Ug== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 385b0xx7d1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Apr 2021 16:39:39 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 730F8100038; Mon, 26 Apr 2021 16:39:39 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 643002178E6; Mon, 26 Apr 2021 16:39:39 +0200 (CEST) Received: from localhost (10.75.127.50) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 26 Apr 2021 16:39:39 +0200 From: To: Mark Brown , Miquel Raynal , Vignesh Raghavendra , Boris Brezillon , , Alexandre Torgue , , , , CC: , Subject: [PATCH 2/3] mtd: spinand: use the spi-mem poll status APIs Date: Mon, 26 Apr 2021 16:39:33 +0200 Message-ID: <20210426143934.25275-3-patrice.chotard@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210426143934.25275-1-patrice.chotard@foss.st.com> References: <20210426143934.25275-1-patrice.chotard@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.50] X-ClientProxiedBy: SFHDAG3NODE2.st.com (10.75.127.8) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.761 definitions=2021-04-26_07:2021-04-26,2021-04-26 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org From: Christophe Kerello Make use of spi-mem poll status APIs to let advanced controllers optimize wait operations Signed-off-by: Christophe Kerello Signed-off-by: Patrice Chotard --- drivers/mtd/nand/spi/core.c | 22 ++++++++++++++++++---- include/linux/mtd/spinand.h | 1 + 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c index 17f63f95f4a2..916f435257bd 100644 --- a/drivers/mtd/nand/spi/core.c +++ b/drivers/mtd/nand/spi/core.c @@ -475,18 +475,32 @@ static int spinand_erase_op(struct spinand_device *spinand, static int spinand_wait(struct spinand_device *spinand, u8 *s) { - unsigned long timeo = jiffies + msecs_to_jiffies(400); + struct spi_mem_op op = SPINAND_GET_FEATURE_OP(REG_STATUS, + spinand->scratchbuf); + unsigned long timeo = jiffies + msecs_to_jiffies(SPINAND_STATUS_TIMEOUT_MS); u8 status; int ret; - do { - ret = spinand_read_status(spinand, &status); + ret = spi_mem_poll_status(spinand->spimem, &op, STATUS_BUSY, 0, + SPINAND_STATUS_TIMEOUT_MS); + if (ret != -EOPNOTSUPP) { if (ret) return ret; + status = *spinand->scratchbuf; + if (!(status & STATUS_BUSY)) goto out; - } while (time_before(jiffies, timeo)); + } else { + do { + ret = spinand_read_status(spinand, &status); + if (ret) + return ret; + + if (!(status & STATUS_BUSY)) + goto out; + } while (time_before(jiffies, timeo)); + } /* * Extra read, just in case the STATUS_READY bit has changed diff --git a/include/linux/mtd/spinand.h b/include/linux/mtd/spinand.h index 6bb92f26833e..28ee481d96eb 100644 --- a/include/linux/mtd/spinand.h +++ b/include/linux/mtd/spinand.h @@ -170,6 +170,7 @@ struct spinand_op; struct spinand_device; #define SPINAND_MAX_ID_LEN 4 +#define SPINAND_STATUS_TIMEOUT_MS 400 /** * struct spinand_id - SPI NAND id structure