public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH 0/3] mtd: nand: sunxi: Perfs improvements
@ 2017-01-06  9:42 Boris Brezillon
  2017-01-06  9:42 ` [PATCH 1/3] mtd: nand: sunxi: Fix the non-polling case in sunxi_nfc_wait_events() Boris Brezillon
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Boris Brezillon @ 2017-01-06  9:42 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

These 3 patches aims at improving the sunxi NAND driver perfs and
avoiding busy waits on long operations to improve system reactivity.

Regards,

Boris

Boris Brezillon (3):
  mtd: nand: sunxi: Fix the non-polling case in sunxi_nfc_wait_events()
  mtd: nand: sunxi: Stop using polling mode when waiting for long
    operations
  mtd: nand: sunxi: Improve sunxi_nfc_cmd_ctrl()

 drivers/mtd/nand/sunxi_nand.c | 36 ++++++++++++++++++++++++++----------
 1 file changed, 26 insertions(+), 10 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] mtd: nand: sunxi: Fix the non-polling case in sunxi_nfc_wait_events()
  2017-01-06  9:42 [PATCH 0/3] mtd: nand: sunxi: Perfs improvements Boris Brezillon
@ 2017-01-06  9:42 ` Boris Brezillon
  2017-01-06  9:42 ` [PATCH 2/3] mtd: nand: sunxi: Stop using polling mode when waiting for long operations Boris Brezillon
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Boris Brezillon @ 2017-01-06  9:42 UTC (permalink / raw)
  To: linux-arm-kernel

wait_for_completion_timeout() returns 0 if a timeout occurred, 1
otherwise. Fix the sunxi_nfc_wait_events() accordingly.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
 drivers/mtd/nand/sunxi_nand.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
index e40482a65de6..ba78e13a3570 100644
--- a/drivers/mtd/nand/sunxi_nand.c
+++ b/drivers/mtd/nand/sunxi_nand.c
@@ -321,6 +321,10 @@ static int sunxi_nfc_wait_events(struct sunxi_nfc *nfc, u32 events,
 
 		ret = wait_for_completion_timeout(&nfc->complete,
 						msecs_to_jiffies(timeout_ms));
+		if (!ret)
+			ret = -ETIMEDOUT;
+		else
+			ret = 0;
 
 		writel(0, nfc->regs + NFC_REG_INT);
 	} else {
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] mtd: nand: sunxi: Stop using polling mode when waiting for long operations
  2017-01-06  9:42 [PATCH 0/3] mtd: nand: sunxi: Perfs improvements Boris Brezillon
  2017-01-06  9:42 ` [PATCH 1/3] mtd: nand: sunxi: Fix the non-polling case in sunxi_nfc_wait_events() Boris Brezillon
@ 2017-01-06  9:42 ` Boris Brezillon
  2017-01-06  9:42 ` [PATCH 3/3] mtd: nand: sunxi: Improve sunxi_nfc_cmd_ctrl() Boris Brezillon
  2017-02-06 19:44 ` [PATCH 0/3] mtd: nand: sunxi: Perfs improvements Boris Brezillon
  3 siblings, 0 replies; 5+ messages in thread
From: Boris Brezillon @ 2017-01-06  9:42 UTC (permalink / raw)
  To: linux-arm-kernel

Some operations, like read/write an entire page of data with the ECC
engine enabled, are known to take a lot of time. Use the interrupt-based
waiting mode in these situation.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
 drivers/mtd/nand/sunxi_nand.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
index ba78e13a3570..76449f79d4c5 100644
--- a/drivers/mtd/nand/sunxi_nand.c
+++ b/drivers/mtd/nand/sunxi_nand.c
@@ -522,6 +522,8 @@ static void sunxi_nfc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
 	u32 tmp;
 
 	while (len > offs) {
+		bool poll = false;
+
 		cnt = min(len - offs, NFC_SRAM_SIZE);
 
 		ret = sunxi_nfc_wait_cmd_fifo_empty(nfc);
@@ -532,7 +534,11 @@ static void sunxi_nfc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
 		tmp = NFC_DATA_TRANS | NFC_DATA_SWAP_METHOD;
 		writel(tmp, nfc->regs + NFC_REG_CMD);
 
-		ret = sunxi_nfc_wait_events(nfc, NFC_CMD_INT_FLAG, true, 0);
+		/* Arbitrary limit for polling mode */
+		if (cnt < 64)
+			poll = true;
+
+		ret = sunxi_nfc_wait_events(nfc, NFC_CMD_INT_FLAG, poll, 0);
 		if (ret)
 			break;
 
@@ -555,6 +561,8 @@ static void sunxi_nfc_write_buf(struct mtd_info *mtd, const uint8_t *buf,
 	u32 tmp;
 
 	while (len > offs) {
+		bool poll = false;
+
 		cnt = min(len - offs, NFC_SRAM_SIZE);
 
 		ret = sunxi_nfc_wait_cmd_fifo_empty(nfc);
@@ -567,7 +575,11 @@ static void sunxi_nfc_write_buf(struct mtd_info *mtd, const uint8_t *buf,
 		      NFC_ACCESS_DIR;
 		writel(tmp, nfc->regs + NFC_REG_CMD);
 
-		ret = sunxi_nfc_wait_events(nfc, NFC_CMD_INT_FLAG, true, 0);
+		/* Arbitrary limit for polling mode */
+		if (cnt < 64)
+			poll = true;
+
+		ret = sunxi_nfc_wait_events(nfc, NFC_CMD_INT_FLAG, poll, 0);
 		if (ret)
 			break;
 
@@ -961,7 +973,7 @@ static int sunxi_nfc_hw_ecc_read_chunk(struct mtd_info *mtd,
 	writel(NFC_DATA_TRANS | NFC_DATA_SWAP_METHOD | NFC_ECC_OP,
 	       nfc->regs + NFC_REG_CMD);
 
-	ret = sunxi_nfc_wait_events(nfc, NFC_CMD_INT_FLAG, true, 0);
+	ret = sunxi_nfc_wait_events(nfc, NFC_CMD_INT_FLAG, false, 0);
 	sunxi_nfc_randomizer_disable(mtd);
 	if (ret)
 		return ret;
@@ -1073,7 +1085,7 @@ static int sunxi_nfc_hw_ecc_read_chunks_dma(struct mtd_info *mtd, uint8_t *buf,
 	writel(NFC_PAGE_OP | NFC_DATA_SWAP_METHOD | NFC_DATA_TRANS,
 	       nfc->regs + NFC_REG_CMD);
 
-	ret = sunxi_nfc_wait_events(nfc, NFC_CMD_INT_FLAG, true, 0);
+	ret = sunxi_nfc_wait_events(nfc, NFC_CMD_INT_FLAG, false, 0);
 	if (ret)
 		dmaengine_terminate_all(nfc->dmac);
 
@@ -1193,7 +1205,7 @@ static int sunxi_nfc_hw_ecc_write_chunk(struct mtd_info *mtd,
 	       NFC_ACCESS_DIR | NFC_ECC_OP,
 	       nfc->regs + NFC_REG_CMD);
 
-	ret = sunxi_nfc_wait_events(nfc, NFC_CMD_INT_FLAG, true, 0);
+	ret = sunxi_nfc_wait_events(nfc, NFC_CMD_INT_FLAG, false, 0);
 	sunxi_nfc_randomizer_disable(mtd);
 	if (ret)
 		return ret;
@@ -1432,7 +1444,7 @@ static int sunxi_nfc_hw_ecc_write_page_dma(struct mtd_info *mtd,
 	       NFC_DATA_TRANS | NFC_ACCESS_DIR,
 	       nfc->regs + NFC_REG_CMD);
 
-	ret = sunxi_nfc_wait_events(nfc, NFC_CMD_INT_FLAG, true, 0);
+	ret = sunxi_nfc_wait_events(nfc, NFC_CMD_INT_FLAG, false, 0);
 	if (ret)
 		dmaengine_terminate_all(nfc->dmac);
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] mtd: nand: sunxi: Improve sunxi_nfc_cmd_ctrl()
  2017-01-06  9:42 [PATCH 0/3] mtd: nand: sunxi: Perfs improvements Boris Brezillon
  2017-01-06  9:42 ` [PATCH 1/3] mtd: nand: sunxi: Fix the non-polling case in sunxi_nfc_wait_events() Boris Brezillon
  2017-01-06  9:42 ` [PATCH 2/3] mtd: nand: sunxi: Stop using polling mode when waiting for long operations Boris Brezillon
@ 2017-01-06  9:42 ` Boris Brezillon
  2017-02-06 19:44 ` [PATCH 0/3] mtd: nand: sunxi: Perfs improvements Boris Brezillon
  3 siblings, 0 replies; 5+ messages in thread
From: Boris Brezillon @ 2017-01-06  9:42 UTC (permalink / raw)
  To: linux-arm-kernel

We only need to call sunxi_nfc_wait_cmd_fifo_empty() if we want to send
a new command. Move the sunxi_nfc_wait_cmd_fifo_empty() call to right
place to avoid extra register reads.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
 drivers/mtd/nand/sunxi_nand.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
index 76449f79d4c5..0eeeb8b889ea 100644
--- a/drivers/mtd/nand/sunxi_nand.c
+++ b/drivers/mtd/nand/sunxi_nand.c
@@ -604,10 +604,6 @@ static void sunxi_nfc_cmd_ctrl(struct mtd_info *mtd, int dat,
 	struct sunxi_nfc *nfc = to_sunxi_nfc(sunxi_nand->nand.controller);
 	int ret;
 
-	ret = sunxi_nfc_wait_cmd_fifo_empty(nfc);
-	if (ret)
-		return;
-
 	if (dat == NAND_CMD_NONE && (ctrl & NAND_NCE) &&
 	    !(ctrl & (NAND_CLE | NAND_ALE))) {
 		u32 cmd = 0;
@@ -637,6 +633,10 @@ static void sunxi_nfc_cmd_ctrl(struct mtd_info *mtd, int dat,
 			writel(sunxi_nand->addr[1],
 			       nfc->regs + NFC_REG_ADDR_HIGH);
 
+		ret = sunxi_nfc_wait_cmd_fifo_empty(nfc);
+		if (ret)
+			return;
+
 		writel(cmd, nfc->regs + NFC_REG_CMD);
 		sunxi_nand->addr[0] = 0;
 		sunxi_nand->addr[1] = 0;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 0/3] mtd: nand: sunxi: Perfs improvements
  2017-01-06  9:42 [PATCH 0/3] mtd: nand: sunxi: Perfs improvements Boris Brezillon
                   ` (2 preceding siblings ...)
  2017-01-06  9:42 ` [PATCH 3/3] mtd: nand: sunxi: Improve sunxi_nfc_cmd_ctrl() Boris Brezillon
@ 2017-02-06 19:44 ` Boris Brezillon
  3 siblings, 0 replies; 5+ messages in thread
From: Boris Brezillon @ 2017-02-06 19:44 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri,  6 Jan 2017 10:42:04 +0100
Boris Brezillon <boris.brezillon@free-electrons.com> wrote:

> Hello,
> 
> These 3 patches aims at improving the sunxi NAND driver perfs and
> avoiding busy waits on long operations to improve system reactivity.

Applied.

> 
> Regards,
> 
> Boris
> 
> Boris Brezillon (3):
>   mtd: nand: sunxi: Fix the non-polling case in sunxi_nfc_wait_events()
>   mtd: nand: sunxi: Stop using polling mode when waiting for long
>     operations
>   mtd: nand: sunxi: Improve sunxi_nfc_cmd_ctrl()
> 
>  drivers/mtd/nand/sunxi_nand.c | 36 ++++++++++++++++++++++++++----------
>  1 file changed, 26 insertions(+), 10 deletions(-)
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-02-06 19:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-06  9:42 [PATCH 0/3] mtd: nand: sunxi: Perfs improvements Boris Brezillon
2017-01-06  9:42 ` [PATCH 1/3] mtd: nand: sunxi: Fix the non-polling case in sunxi_nfc_wait_events() Boris Brezillon
2017-01-06  9:42 ` [PATCH 2/3] mtd: nand: sunxi: Stop using polling mode when waiting for long operations Boris Brezillon
2017-01-06  9:42 ` [PATCH 3/3] mtd: nand: sunxi: Improve sunxi_nfc_cmd_ctrl() Boris Brezillon
2017-02-06 19:44 ` [PATCH 0/3] mtd: nand: sunxi: Perfs improvements Boris Brezillon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox