Implement exec_op for GPMI nand driver
Subsystems (5)
Sascha Hauer
maintainerv2 cover Implement exec_op for GPMI nand driver
The GPMI nand driver suffers from very poor performance. The read performance can be roughly doubled with two steps: First is to use runtime PM for controlling the clocks which prevents the driver from spending a good amount of time en/disabling the clocks. The second step is to implement exec_op which allows us to combine the steps necessary to do a page read into a single DMA transaction.
I would prefer to let this go through the mtd tree with the ack of the dmaengine maintainers
changes since v1:
- tested and fixed on i.MX28
- remove debugging leftover
- Add mxs dma specific header files to put the oddities of the mxs dma driver in
- Turn off BCH engine interrupts when not needed as they result in calling complete() on an uninitialized completion. This crashes on i.MX28
-----------------------------8<-------------------------------- Sascha Hauer (14):
mtd: rawnand: export nand operation tracer
mtd: rawnand: fsmc: Use nand_op_trace for operation tracing
mtd: rawnand: gpmi: move all driver code into single file
mtd: rawnand: gpmi: remove unused variable
mtd: rawnand: gpmi: Remove unnecessary variables
mtd: rawnand: gpmi: read buf in nand_read_page_op
mtd: rawnand: gpmi: remove unused parameters
mtd: rawnand: gpmi: Drop unnecessary restoring of previous
chipselection
mtd: rawnand: gpmi: use runtime PM to manage clocks
dma: mxs: Drop unnecessary flag
mtd: rawnand: gpmi: drop unnecessary flag
dma: mxs: Add header file to be shared with gpmi nand driver
dma: mxs: rename custom flag
mtd: rawnand: gpmi: Implement exec_op
drivers/dma/mxs-dma.c | 25 +- drivers/mtd/nand/raw/fsmc_nand.c | 19 +- drivers/mtd/nand/raw/gpmi-nand/Makefile | 1 - drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c | 936 ----------- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 1687 ++++++++++++++------ drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h | 64 +- drivers/mtd/nand/raw/nand_base.c | 30 +- include/linux/dma/mxs-dma.h | 24 + include/linux/mtd/rawnand.h | 37 + 9 files changed, 1264 insertions(+), 1559 deletions(-) delete mode 100644 drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c create mode 100644 include/linux/dma/mxs-dma.h
Signature · 6 lines
2.20.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Sascha Hauer
maintainerPATCH v2 1/14 mtd: rawnand: export nand operation tracer
The nand core has a nand operation tracing function, but it can only be used by drivers using the generic option parser from the nand core. Export the tracing function as a static inline function in rawnand.h so that drivers implementing exec_op directly do not have to write their own operation tracing.
--- drivers/mtd/nand/raw/nand_base.c | 30 +------------------------- include/linux/mtd/rawnand.h | 37 ++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 29 deletions(-)
drivers/mtd/nand/raw/nand_base.c +1 -29
@@ -2090,35 +2090,7 @@ static void nand_op_parser_trace(const struct nand_op_parser_ctx *ctx)if (instr == &ctx->subop.instrs[0 ]) prefix =" ->" ; -switch (instr->type) { -case NAND_OP_CMD_INSTR : -pr_debug ("%sCMD [0x%02x]\n" , prefix, - instr->ctx.cmd.opcode); -break ; -case NAND_OP_ADDR_INSTR : -pr_debug ("%sADDR [%d cyc: %*ph]\n" , prefix, - instr->ctx.addr.naddrs, - instr->ctx.addr.naddrs <64 ? - instr->ctx.addr.naddrs :64 , - instr->ctx.addr.addrs); -break ; -case NAND_OP_DATA_IN_INSTR : -pr_debug ("%sDATA_IN [%d B%s]\n" , prefix, - instr->ctx.data.len, - instr->ctx.data.force_8bit ? -", force 8-bit" :"" ); -break ; -case NAND_OP_DATA_OUT_INSTR : -pr_debug ("%sDATA_OUT [%d B%s]\n" , prefix, - instr->ctx.data.len, - instr->ctx.data.force_8bit ? -", force 8-bit" :"" ); -break ; -case NAND_OP_WAITRDY_INSTR : -pr_debug ("%sWAITRDY [max %d ms]\n" , prefix, - instr->ctx.waitrdy.timeout_ms); -break ; - } +nand_op_trace (prefix, instr);if (instr == &ctx->subop.instrs[ctx->subop.ninstrs -1 ]) prefix =" " ;
include/linux/mtd/rawnand.h +37 -0
@@ -860,6 +860,43 @@ struct nand_operation {int nand_op_parser_exec_op (struct nand_chip *chip,const struct nand_op_parser *parser,const struct nand_operation *op,bool check_only); + +static inline void nand_op_trace (const char *prefix, +const struct nand_op_instr *instr) +{ +#if IS_ENABLED (CONFIG_DYNAMIC_DEBUG ) || defined(DEBUG ) +switch (instr->type) { +case NAND_OP_CMD_INSTR : +pr_debug ("%sCMD [0x%02x]\n" , prefix, + instr->ctx.cmd.opcode); +break ; +case NAND_OP_ADDR_INSTR : +pr_debug ("%sADDR [%d cyc: %*ph]\n" , prefix, + instr->ctx.addr.naddrs, + instr->ctx.addr.naddrs <64 ? + instr->ctx.addr.naddrs :64 , + instr->ctx.addr.addrs); +break ; +case NAND_OP_DATA_IN_INSTR : +pr_debug ("%sDATA_IN [%d B%s]\n" , prefix, + instr->ctx.data.len, + instr->ctx.data.force_8bit ? +", force 8-bit" :"" ); +break ; +case NAND_OP_DATA_OUT_INSTR : +pr_debug ("%sDATA_OUT [%d B%s]\n" , prefix, + instr->ctx.data.len, + instr->ctx.data.force_8bit ? +", force 8-bit" :"" ); +break ; +case NAND_OP_WAITRDY_INSTR : +pr_debug ("%sWAITRDY [max %d ms]\n" , prefix, + instr->ctx.waitrdy.timeout_ms); +break ; + } +#endif +} +/** * struct nand_controller_ops - Controller operations *
Signature · 6 lines
2.20.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 01/14] mtd: rawnand: export nand operation tracer
Hi Sascha,
Sascha Hauer <[email protected]> wrote on Tue, 9 Apr 2019 13:34:08 +0200:
Quoted 1 line
The nand core has a nand operation tracing function, but it can only
s/nand/NAND/ (please use uppercase in all your commit logs)
Quoted 7 lines
be used by drivers using the generic option parser from the nand core. Export the tracing function as a static inline function in
rawnand.hso that drivers implementingexec_opdirectly do not have to write their own operation tracing.Signed-off-by Sascha Hauer <[email protected]>---
Otherwise:
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Sascha Hauer
maintainerPATCH v2 2/14 mtd: rawnand: fsmc: Use nand_op_trace for operation tracing
In reply to Sascha HauerReplace the different operation tracing functions with a call to nand_op_trace.
--- drivers/mtd/nand/raw/fsmc_nand.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-)
drivers/mtd/nand/raw/fsmc_nand.c +2 -17
@@ -613,28 +613,20 @@ static int fsmc_exec_op(struct nand_chip *chip, const struct nand_operation *op,for (op_id =0 ; op_id < op->ninstrs; op_id++) { instr = &op->instrs[op_id]; +nand_op_trace (" " , instr); +switch (instr->type) {case NAND_OP_CMD_INSTR : -pr_debug (" ->CMD [0x%02x]\n" , - instr->ctx.cmd.opcode); -writeb_relaxed (instr->ctx.cmd.opcode, host->cmd_va);break ;case NAND_OP_ADDR_INSTR : -pr_debug (" ->ADDR [%d cyc]" , - instr->ctx.addr.naddrs); -for (i =0 ; i < instr->ctx.addr.naddrs; i++)writeb_relaxed (instr->ctx.addr.addrs[i], host->addr_va);break ;case NAND_OP_DATA_IN_INSTR : -pr_debug (" ->DATA_IN [%d B%s]\n" , instr->ctx.data.len, - instr->ctx.data.force_8bit ? -", force 8-bit" :"" ); -if (host->mode ==USE_DMA_ACCESS )fsmc_read_buf_dma (host, instr->ctx.data.buf.in, instr->ctx.data.len);
@@ -644,10 +636,6 @@ static int fsmc_exec_op(struct nand_chip *chip, const struct nand_operation *op,break ;case NAND_OP_DATA_OUT_INSTR : -pr_debug (" ->DATA_OUT [%d B%s]\n" , instr->ctx.data.len, - instr->ctx.data.force_8bit ? -", force 8-bit" :"" ); -if (host->mode ==USE_DMA_ACCESS ) fsmc_write_buf_dma(host, instr->ctx.data.buf.out,
@@ -658,9 +646,6 @@ static int fsmc_exec_op(struct nand_chip *chip, const struct nand_operation *op,break ;case NAND_OP_WAITRDY_INSTR : -pr_debug (" ->WAITRDY [max %d ms]\n" , - instr->ctx.waitrdy.timeout_ms); - ret =nand_soft_waitrdy (chip, instr->ctx.waitrdy.timeout_ms);break ;
Signature · 6 lines
2.20.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 02/14] mtd: rawnand: fsmc: Use nand_op_trace for operation tracing
Hi Sascha,
Sascha Hauer <[email protected]> wrote on Tue, 9 Apr 2019 13:34:09 +0200:
Quoted 8 lines
Replace the different operation tracing functions with a call to
nand_op_trace.Signed-off-by Sascha Hauer <[email protected]>--- drivers/mtd/nand/raw/fsmc_nand.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-)
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Sascha Hauer
maintainerPATCH v2 3/14 mtd: rawnand: gpmi: move all driver code into single file
In reply to Sascha HauerThis moves the whole driver into a single C file. The filename gpmi-lib implies that it implements library functions, but in fact there are several cases where functions in gpmi-lib.c call back into functions in gpmi-nand.c. With this one has to constantly jump between those two files, so moving it into a single file improves readability, even when the file gets quite large.
--- drivers/mtd/nand/raw/gpmi-nand/Makefile | 1 - drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c | 936 -------------- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 1272 +++++++++++++++++--- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h | 34 - 4 files changed, 1098 insertions(+), 1145 deletions(-) delete mode 100644 drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c
drivers/mtd/nand/raw/gpmi-nand/Makefile +0 -1
@@ -1,3 +1,2 @@ obj-$(CONFIG_MTD_NAND_GPMI_NAND) += gpmi_nand.o gpmi_nand-objs += gpmi-nand.o -gpmi_nand-objs += gpmi-lib.o
drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c deleted +0 -936
936 lines not on this page · raw message
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +1098 -174
1,362 lines not on this page · raw message
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h +0 -34
@@ -159,40 +159,6 @@ struct gpmi_nand_data {void *private; }; -/* Common Services */ -int common_nfc_set_geometry (struct gpmi_nand_data *); -struct dma_chan *get_dma_chan (struct gpmi_nand_data *); -bool prepare_data_dma (struct gpmi_nand_data *,const void *buf,int len, -enum dma_data_direction dr); -int start_dma_without_bch_irq (struct gpmi_nand_data *, -struct dma_async_tx_descriptor *); -int start_dma_with_bch_irq (struct gpmi_nand_data *, -struct dma_async_tx_descriptor *); - -/* GPMI-NAND helper function library */ -int gpmi_init (struct gpmi_nand_data *); -void gpmi_clear_bch (struct gpmi_nand_data *); -void gpmi_dump_info (struct gpmi_nand_data *); -int bch_set_geometry (struct gpmi_nand_data *); -int gpmi_is_ready (struct gpmi_nand_data *,unsigned chip); -int gpmi_send_command (struct gpmi_nand_data *); -int gpmi_enable_clk (struct gpmi_nand_data *this); -int gpmi_disable_clk (struct gpmi_nand_data *this); -int gpmi_setup_data_interface (struct nand_chip *chip,int chipnr, -const struct nand_data_interface *conf); -void gpmi_nfc_apply_timings (struct gpmi_nand_data *this); -int gpmi_read_data (struct gpmi_nand_data *,void *buf,int len); -int gpmi_send_data (struct gpmi_nand_data *,const void *buf,int len); - -int gpmi_send_page (struct gpmi_nand_data *, -dma_addr_t payload,dma_addr_t auxiliary); -int gpmi_read_page (struct gpmi_nand_data *, -dma_addr_t payload,dma_addr_t auxiliary); - -void gpmi_copy_bits (u8 *dst,size_t dst_bit_off, -const u8 *src,size_t src_bit_off, -size_t nbits); -/* BCH : Status Block Completion Codes */ #define STATUS_GOOD 0x00#define STATUS_ERASED 0xff
Signature · 6 lines
2.20.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 03/14] mtd: rawnand: gpmi: move all driver code into single file
Hi Sascha,
Sascha Hauer <[email protected]> wrote on Tue, 9 Apr 2019 13:34:10 +0200:
Quoted 9 lines
This moves the whole driver into a single C file. The filename gpmi-lib implies that it implements library functions, but in fact there are several cases where functions in
gpmi-lib.ccall back into functions ingpmi-nand.c. With this one has to constantly jump between those two files, so moving it into a single file improves readability, even when the file gets quite large.Signed-off-by Sascha Hauer <[email protected]>---
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Sascha Hauer
maintainerPATCH v2 4/14 mtd: rawnand: gpmi: remove unused variable
In reply to Sascha Hauer--- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h | 3 --- 1 file changed, 3 deletions(-)
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h +0 -3
@@ -154,9 +154,6 @@ struct gpmi_nand_data {#define DMA_CHANS 8struct dma_chan *dma_chans[DMA_CHANS ];struct completion dma_done; - -/* private */ -void *private; };/* BCH : Status Block Completion Codes */
Signature · 6 lines
2.20.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 04/14] mtd: rawnand: gpmi: remove unused variable
Hi Sascha,
Sascha Hauer <[email protected]> wrote on Tue, 9 Apr 2019 13:34:11 +0200:
Quoted 2 lines
Signed-off-by Sascha Hauer <[email protected]>---
Missing commit log (even if the patch is trivial...)
With the missing commit message:
Quoted 8 lines
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h | 3 --- 1 file changed, 3 deletions(-)drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h +0
-0
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h struct gpmi_nand_data { · line 159
Quoted 9 lines
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h +0
-3@@ -154,9 +154,6 @@ struct gpmi_nand_data {#define DMA_CHANS 8struct dma_chan *dma_chans[DMA_CHANS ];struct completion dma_done; - -/* private */ -void *private; };/* BCH : Status Block Completion Codes */
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Sascha Hauer
maintainerPATCH v2 5/14 mtd: rawnand: gpmi: Remove unnecessary variables
In reply to Sascha Hauerthis->page_buffer_virt and this->payload_virt are always set to the same value, so drop the former and just use the latter. Same for this->page_buffer_virt and this->payload_virt.
--- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 15 ++++++--------- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h | 2 -- 2 files changed, 6 insertions(+), 11 deletions(-)
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +6 -9
@@ -1637,10 +1637,10 @@ static void gpmi_free_dma_buffer(struct gpmi_nand_data *this) {struct device *dev = this->dev; -if (this->page_buffer_virt &&virt_addr_valid (this->page_buffer_virt)) +if (this->payload_virt &&virt_addr_valid (this->payload_virt))dma_free_coherent (dev, this->page_buffer_size, - this->page_buffer_virt, - this->page_buffer_phys); + this->payload_virt, + this->payload_phys);kfree (this->cmd_buffer);kfree (this->data_buffer_dma);kfree (this->raw_buffer);
@@ -1648,7 +1648,6 @@ static void gpmi_free_dma_buffer(struct gpmi_nand_data *this) this->cmd_buffer =NULL ; this->data_buffer_dma =NULL ; this->raw_buffer =NULL ; - this->page_buffer_virt =NULL ; this->page_buffer_size =0 ; }
@@ -1686,9 +1685,9 @@ static int gpmi_alloc_dma_buffer(struct gpmi_nand_data *this)* auxiliary buffer will appear on a 32-bit boundary. */ this->page_buffer_size = geo->payload_size + geo->auxiliary_size; - this->page_buffer_virt =dma_alloc_coherent (dev, this->page_buffer_size, - &this->page_buffer_phys,GFP_DMA ); -if (!this->page_buffer_virt) + this->payload_virt =dma_alloc_coherent (dev, this->page_buffer_size, + &this->payload_phys,GFP_DMA ); +if (!this->payload_virt) goto error_alloc; this->raw_buffer =kzalloc (mtd->writesize + mtd->oobsize,GFP_KERNEL );
@@ -1696,8 +1695,6 @@ static int gpmi_alloc_dma_buffer(struct gpmi_nand_data *this) goto error_alloc;/* Slice up the page buffer. */ - this->payload_virt = this->page_buffer_virt; - this->payload_phys = this->page_buffer_phys; this->auxiliary_virt = this->payload_virt + geo->payload_size; this->auxiliary_phys = this->payload_phys + geo->payload_size;return 0 ;
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h +0 -2
@@ -138,8 +138,6 @@ struct gpmi_nand_data {struct scatterlist data_sgl;char *data_buffer_dma; -void *page_buffer_virt; -dma_addr_t page_buffer_phys;unsigned int page_buffer_size;void *payload_virt;
Signature · 6 lines
2.20.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 05/14] mtd: rawnand: gpmi: Remove unnecessary variables
Hi Sascha,
Sascha Hauer <[email protected]> wrote on Tue, 9 Apr 2019 13:34:12 +0200:
Quoted 6 lines
this->page_buffer_virtandthis->payload_virtare always set to the same value, so drop the former and just use the latter. Same forthis->page_buffer_virtandthis->payload_virt.Signed-off-by Sascha Hauer <[email protected]>---
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Sascha Hauer
maintainerPATCH v2 6/14 mtd: rawnand: gpmi: read buf in nand_read_page_op
In reply to Sascha HauerThe driver calls nand_read_page_op without a buffer passed and then calls chip->legacy.read_buf to read the buffer afterwards which is the same as passing the buffer nand_read_page_op in the first place.
--- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +4 -8
@@ -2250,8 +2250,7 @@ static int gpmi_ecc_read_oob(struct nand_chip *chip, int page)memset (chip->oob_poi, ~0 , mtd->oobsize);/* Read out the conventional OOB. */ -nand_read_page_op (chip, page, mtd->writesize,NULL ,0 ); - chip->legacy.read_buf (chip, chip->oob_poi, mtd->oobsize); +nand_read_page_op (chip, page, mtd->writesize, chip->oob_poi, mtd->oobsize);/* * Now, we want to make sure the block mark is correct. In the
@@ -2260,8 +2259,7 @@ static int gpmi_ecc_read_oob(struct nand_chip *chip, int page)*/ if (GPMI_IS_MX23 (this)) {/* Read the block mark into the first byte of the OOB buffer. */ -nand_read_page_op (chip, page,0 ,NULL ,0 ); - chip->oob_poi[0 ] = chip->legacy.read_byte (chip); +nand_read_page_op (chip, page,0 , chip->oob_poi,1 ); }return 0 ;
@@ -2548,8 +2546,7 @@ static int mx23_check_transcription_stamp(struct gpmi_nand_data *this)* Read the NCB fingerprint. The fingerprint is four bytes long * and starts in the 12th byte of the page. */ -nand_read_page_op (chip, page,12 ,NULL ,0 ); - chip->legacy.read_buf (chip, buffer,strlen (fingerprint)); +nand_read_page_op (chip, page,12 , buffer,strlen (fingerprint));/* Look for the fingerprint. */ if (!memcmp (buffer, fingerprint,strlen (fingerprint))) {
@@ -2691,8 +2688,7 @@ static int mx23_boot_init(struct gpmi_nand_data *this)/* Send the command to read the conventional block mark. */ nand_select_target (chip, chipnr); -nand_read_page_op (chip, page, mtd->writesize,NULL ,0 ); - block_mark = chip->legacy.read_byte (chip); +nand_read_page_op (chip, page, mtd->writesize, &block_mark,1 );nand_deselect_target (chip);/*
Signature · 6 lines
2.20.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 06/14] mtd: rawnand: gpmi: read buf in nand_read_page_op
Hi Sascha,
Sascha Hauer <[email protected]> wrote on Tue, 9 Apr 2019 13:34:13 +0200:
Quoted 9 lines
The driver calls
nand_read_page_opwithout a buffer passed and then callschip->legacy.read_bufto read the buffer afterwards which is the same as passing the buffernand_read_page_opin the first place.Signed-off-by Sascha Hauer <[email protected]>--- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Sascha Hauer
maintainerPATCH v2 7/14 mtd: rawnand: gpmi: remove unused parameters
In reply to Sascha Hauergpmi_ecc_read_page_data uses the page parameter only for a debug printf, so we can drop the parameter and the debug printf. Moving the oob delivery from gpmi_ecc_read_page_data to gpmi_ecc_read_page makes the oob_required parameter unnecessary aswell.
--- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 34 ++++++++++++---------- 1 file changed, 19 insertions(+), 15 deletions(-)
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +19 -15
@@ -1852,9 +1852,7 @@ static void block_mark_swapping(struct gpmi_nand_data *this, p[1 ] = (p[1 ] & mask) | (from_oob >> (8 - bit)); } -static int gpmi_ecc_read_page_data (struct nand_chip *chip, -uint8_t *buf,int oob_required, -int page) +static int gpmi_ecc_read_page_data (struct nand_chip *chip,uint8_t *buf) {struct gpmi_nand_data *this =nand_get_controller_data (chip);struct bch_geometry *nfc_geo = &this->bch_geometry;
@@ -1866,8 +1864,6 @@ static int gpmi_ecc_read_page_data(struct nand_chip *chip,int ret;bool direct = false; -dev_dbg (this->dev,"page number is : %d\n" , page); - payload_phys = this->payload_phys;if (virt_addr_valid (buf)) {
@@ -1982,6 +1978,22 @@ static int gpmi_ecc_read_page_data(struct nand_chip *chip,/* handle the block mark swapping */ block_mark_swapping (this, buf, this->auxiliary_virt); +return max_bitflips; +} + +static int gpmi_ecc_read_page (struct nand_chip *chip,uint8_t *buf, +int oob_required,int page) +{ +struct gpmi_nand_data *this =nand_get_controller_data (chip); +struct mtd_info *mtd =nand_to_mtd (chip); +int ret; + +nand_read_page_op (chip, page,0 ,NULL ,0 ); + + ret =gpmi_ecc_read_page_data (chip, buf); +if (ret <0 ) +return ret; +if (oob_required) {/* * It's time to deliver the OOB bytes. See gpmi_ecc_read_oob()
@@ -1997,15 +2009,7 @@ static int gpmi_ecc_read_page_data(struct nand_chip *chip, chip->oob_poi[0 ] = ((uint8_t *)this->auxiliary_virt)[0 ]; } -return max_bitflips; -} - -static int gpmi_ecc_read_page (struct nand_chip *chip,uint8_t *buf, -int oob_required,int page) -{ -nand_read_page_op (chip, page,0 ,NULL ,0 ); - -return gpmi_ecc_read_page_data (chip, buf, oob_required, page); +return ret; }/* Fake a virtual small page for the subpage read */
@@ -2086,7 +2090,7 @@ static int gpmi_ecc_read_subpage(struct nand_chip *chip, uint32_t offs,/* Read the subpage now */ this->swap_block_mark = false; - max_bitflips =gpmi_ecc_read_page_data (chip, buf,0 , page); + max_bitflips =gpmi_ecc_read_page_data (chip, buf);/* Restore */ writel (r1_old, bch_regs +HW_BCH_FLASH0LAYOUT0 );
Signature · 6 lines
2.20.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 07/14] mtd: rawnand: gpmi: remove unused parameters
Hi Sascha,
Sascha Hauer <[email protected]> wrote on Tue, 9 Apr 2019 13:34:14 +0200:
Quoted 10 lines
gpmi_ecc_read_page_datauses the page parameter only for a debug printf, so we can drop the parameter and the debug printf. Moving the oob delivery fromgpmi_ecc_read_page_datatogpmi_ecc_read_pagemakes theoob_requiredparameter unnecessary aswell.Signed-off-by Sascha Hauer <[email protected]>--- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 34 ++++++++++++---------- 1 file changed, 19 insertions(+), 15 deletions(-)
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Sascha Hauer
maintainerPATCH v2 8/14 mtd: rawnand: gpmi: Drop unnecessary restoring of previous chipselection
In reply to Sascha HauerThe i.MX23 specific option read code is called right after nand_scan. We can rely on the nand core having disabled the chipselect, so there's no point in restoring the original chipselect after nand operations. Drop it.
--- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-)
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +2 -14
@@ -2526,13 +2526,11 @@ static int mx23_check_transcription_stamp(struct gpmi_nand_data *this)unsigned int stride;unsigned int page;uint8_t *buffer = chip->data_buf; -int saved_chip_number;int found_an_ncb_fingerprint = false;/* Compute the number of strides in a search area. */ search_area_size_in_strides =1 << rom_geo->search_area_stride_exponent; - saved_chip_number = this->current_chip;nand_select_target (chip,0 );/*
@@ -2560,10 +2558,7 @@ static int mx23_check_transcription_stamp(struct gpmi_nand_data *this) } -if (saved_chip_number >=0 ) -nand_select_target (chip, saved_chip_number); -else -nand_deselect_target (chip); +nand_deselect_target (chip);if (found_an_ncb_fingerprint)dev_dbg (dev,"\tFound a fingerprint\n" );
@@ -2587,7 +2582,6 @@ static int mx23_write_transcription_stamp(struct gpmi_nand_data *this)unsigned int stride;unsigned int page;uint8_t *buffer = chip->data_buf; -int saved_chip_number;int status;/* Compute the search area geometry. */
@@ -2604,8 +2598,6 @@ static int mx23_write_transcription_stamp(struct gpmi_nand_data *this)dev_dbg (dev,"\tin Strides: %u\n" , search_area_size_in_strides);dev_dbg (dev,"\tin Pages : %u\n" , search_area_size_in_pages); -/* Select chip 0. */ - saved_chip_number = this->current_chip;nand_select_target (chip,0 );/* Loop over blocks in the first search area, erasing them. */
@@ -2637,11 +2629,7 @@ static int mx23_write_transcription_stamp(struct gpmi_nand_data *this)dev_err (dev,"[%s] Write failed.\n" , __func__); } -/* Deselect chip 0. */ -if (saved_chip_number >=0 ) -nand_select_target (chip, saved_chip_number); -else -nand_deselect_target (chip); +nand_deselect_target (chip);return 0 ; }
Signature · 6 lines
2.20.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 08/14] mtd: rawnand: gpmi: Drop unnecessary restoring of previous chipselection
Hi Sascha,
Sascha Hauer <[email protected]> wrote on Tue, 9 Apr 2019 13:34:15 +0200:
Quoted 4 lines
The i.MX23 specific option read code is called right after
nand_scan. We can rely on the nand core having disabled the chipselect, so there's no point in restoring the original chipselect after nand operations. Drop it.
s/nand/NAND/
s/chipselect/chip select/?
Quoted 2 lines
Signed-off-by Sascha Hauer <[email protected]>---
With the above addressed:
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Sascha Hauer
maintainerPATCH v2 9/14 mtd: rawnand: gpmi: use runtime PM to manage clocks
In reply to Sascha HauerThe gpmi driver aggressively en/disables the clocks between operations which has significant performance cost. Use runtime PM to get rid of this bottleneck.
--- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 69 ++++++++++++++-------- 1 file changed, 44 insertions(+), 25 deletions(-)
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +44 -25
@@ -14,6 +14,7 @@#include <linux/mtd/partitions.h> #include <linux/of.h> #include <linux/of_device.h> +#include <linux/pm_runtime.h> #include "gpmi-nand.h" #include "gpmi-regs.h" #include "bch-regs.h"
@@ -141,24 +142,11 @@ static int __gpmi_enable_clk(struct gpmi_nand_data *this, bool v)return ret; } -static int gpmi_enable_clk (struct gpmi_nand_data *this) -{ -return __gpmi_enable_clk (this, true); -} - -static int gpmi_disable_clk (struct gpmi_nand_data *this) -{ -return __gpmi_enable_clk (this, false); -} -static int gpmi_init (struct gpmi_nand_data *this) {struct resources *r = &this->resources;int ret; - ret =gpmi_enable_clk (this); -if (ret) -return ret; ret =gpmi_reset_block (r->gpmi_regs, false);if (ret) goto err_out;
@@ -191,10 +179,8 @@ static int gpmi_init(struct gpmi_nand_data *this)*/ writel (BM_GPMI_CTRL1_DECOUPLE_CS , r->gpmi_regs +HW_GPMI_CTRL1_SET ); -gpmi_disable_clk (this);return 0 ; err_out: -gpmi_disable_clk (this);return ret; }
@@ -559,8 +545,8 @@ static int bch_set_geometry(struct gpmi_nand_data *this) page_size = bch_geo->page_size; gf_len = bch_geo->gf_len; - ret =gpmi_enable_clk (this); -if (ret) + ret =pm_runtime_get_sync (this->dev); +if (ret <0 )return ret;/*
@@ -594,10 +580,11 @@ static int bch_set_geometry(struct gpmi_nand_data *this)writel (BM_BCH_CTRL_COMPLETE_IRQ_EN , r->bch_regs +HW_BCH_CTRL_SET ); -gpmi_disable_clk (this); -return 0 ; + ret =0 ; err_out: -gpmi_disable_clk (this); +pm_runtime_mark_last_busy (this->dev); +pm_runtime_put_autosuspend (this->dev); +return ret; }
@@ -1754,13 +1741,12 @@ static void gpmi_select_chip(struct nand_chip *chip, int chipnr)* die is selected/unselected. */ if (this->current_chip <0 && chipnr >=0 ) { - ret =gpmi_enable_clk (this); -if (ret) + ret =pm_runtime_get_sync (this->dev); +if (ret <0 )dev_err (this->dev,"Failed to enable the clock\n" ); }else if (this->current_chip >=0 && chipnr <0 ) { - ret =gpmi_disable_clk (this); -if (ret) -dev_err (this->dev,"Failed to disable the clock\n" ); +pm_runtime_mark_last_busy (this->dev); +pm_runtime_put_autosuspend (this->dev); }/*
@@ -2910,6 +2896,16 @@ static int gpmi_nand_probe(struct platform_device *pdev)if (ret) goto exit_acquire_resources; + ret =__gpmi_enable_clk (this, true); +if (ret) + goto exit_nfc_init; + +pm_runtime_set_autosuspend_delay (&pdev->dev,500 ); +pm_runtime_use_autosuspend (&pdev->dev); +pm_runtime_set_active (&pdev->dev); +pm_runtime_enable (&pdev->dev); +pm_runtime_get_sync (&pdev->dev); + ret =gpmi_init (this);if (ret) goto exit_nfc_init;
@@ -2918,11 +2914,16 @@ static int gpmi_nand_probe(struct platform_device *pdev)if (ret) goto exit_nfc_init; +pm_runtime_mark_last_busy (&pdev->dev); +pm_runtime_put_autosuspend (&pdev->dev); +dev_info (this->dev,"driver registered.\n" );return 0 ; exit_nfc_init: +pm_runtime_put (&pdev->dev); +pm_runtime_disable (&pdev->dev);release_resources (this); exit_acquire_resources:
@@ -2933,6 +2934,9 @@ static int gpmi_nand_remove(struct platform_device *pdev) {struct gpmi_nand_data *this =platform_get_drvdata (pdev); +pm_runtime_put_sync (&pdev->dev); +pm_runtime_disable (&pdev->dev); +nand_release (&this->nand);gpmi_free_dma_buffer (this);release_resources (this);
@@ -2975,8 +2979,23 @@ static int gpmi_pm_resume(struct device *dev) }#endif /* CONFIG_PM_SLEEP */ +static int __maybe_unused gpmi_runtime_suspend (struct device *dev) +{ +struct gpmi_nand_data *this =dev_get_drvdata (dev); + +return __gpmi_enable_clk (this, false); +} + +static int __maybe_unused gpmi_runtime_resume (struct device *dev) +{ +struct gpmi_nand_data *this =dev_get_drvdata (dev); + +return __gpmi_enable_clk (this, true); +} +static const struct dev_pm_ops gpmi_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(gpmi_pm_suspend, gpmi_pm_resume) +SET_RUNTIME_PM_OPS (gpmi_runtime_suspend, gpmi_runtime_resume,NULL ) };static struct platform_driver gpmi_nand_driver = {
Signature · 6 lines
2.20.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 09/14] mtd: rawnand: gpmi: use runtime PM to manage clocks
Hi Sascha,
Sascha Hauer <[email protected]> wrote on Tue, 9 Apr 2019 13:34:16 +0200:
Quoted 6 lines
The gpmi driver aggressively en/disables the clocks between operations which has significant performance cost. Use runtime PM to get rid of this bottleneck.
Signed-off-by Sascha Hauer <[email protected]>---
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Sascha Hauer
maintainerPATCH v2 10/14 dma: mxs: Drop unnecessary flag
In reply to Sascha HauerThe mxs dma driver insists on having the DMA_PREP_INTERRUPT flag set on all but the first transfer. There's no need to let the user set this flag, the driver can do it internally whenever it needs it. Drop handling of this flag from the driver.
--- drivers/dma/mxs-dma.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/dma/mxs-dma.c +8 -9
@@ -477,16 +477,16 @@ static void mxs_dma_free_chan_resources(struct dma_chan *chan)* ...... * ->device_prep_slave_sg(0); * ...... -* ->device_prep_slave_sg(DMA_PREP_INTERRUPT | DMA_CTRL_ACK); +* ->device_prep_slave_sg(DMA_CTRL_ACK); * ...... * [3] If there are more than two DMA commands in the DMA chain, the code * should be: * ...... * ->device_prep_slave_sg(0); // First * ...... -* ->device_prep_slave_sg(DMA_PREP_INTERRUPT [| DMA_CTRL_ACK]); +* ->device_prep_slave_sg(DMA_CTRL_ACK]); * ...... -* ->device_prep_slave_sg(DMA_PREP_INTERRUPT | DMA_CTRL_ACK); // Last +* ->device_prep_slave_sg(DMA_CTRL_ACK); // Last * ...... */ static struct dma_async_tx_descriptor *mxs_dma_prep_slave_sg(
@@ -500,13 +500,12 @@ static struct dma_async_tx_descriptor *mxs_dma_prep_slave_sg(struct scatterlist *sg;u32 i, j;u32 *pio; -bool append = flags &DMA_PREP_INTERRUPT ; -int idx = append ? mxs_chan->desc_count :0 ; +int idx =0 ; -if (mxs_chan->status ==DMA_IN_PROGRESS && !append) -return NULL ; +if (mxs_chan->status ==DMA_IN_PROGRESS ) + idx = mxs_chan->desc_count; -if (sg_len + (append ? idx :0 ) >NUM_CCW ) { +if (sg_len + idx >NUM_CCW ) {dev_err (mxs_dma->dma_device.dev,"maximum number of sg exceeded: %d > %d\n" , sg_len,NUM_CCW );
@@ -520,7 +519,7 @@ static struct dma_async_tx_descriptor *mxs_dma_prep_slave_sg(* If the sg is prepared with append flag set, the sg * will be appended to the last prepared sg. */ -if (append) { +if (idx) {BUG_ON (idx <1 ); ccw = &mxs_chan->ccw[idx -1 ]; ccw->next = mxs_chan->ccw_phys +sizeof (*ccw) * idx;
Signature · 6 lines
2.20.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Miquel Raynal
maintainerRe: [PATCH 10/14] dma: mxs: Drop unnecessary flag
Hi Vinod,
Sascha Hauer <[email protected]> wrote on Tue, 9 Apr 2019 13:34:17 +0200:
Quoted 7 lines
The mxs dma driver insists on having the
DMA_PREP_INTERRUPTflag set on all but the first transfer. There's no need to let the user set this flag, the driver can do it internally whenever it needs it. Drop handling of this flag from the driver.Signed-off-by Sascha Hauer <[email protected]>---
Patches 10, 12, 13 of this series have repercussions on the other patches, I would like to apply the whole series through the MTD tree; is this okay for you?
Acked-by's welcome.
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Vinod Koul
maintainerRe: [PATCH 10/14] dma: mxs: Drop unnecessary flag
Quoted 10 lines · Miquel Raynal
Hi Vinod,
Sascha Hauer <[email protected]> wrote on Tue, 9 Apr 2019 13:34:17 +0200:
Quoted 5 lines
The mxs dma driver insists on having the
DMA_PREP_INTERRUPTflag set on all but the first transfer. There's no need to let the user set this flag, the driver can do it internally whenever it needs it. Drop handling of this flag from the driver.
Quoted 6 lines
Quoted 2 lines
Signed-off-by Sascha Hauer <[email protected]>---
Patches 10, 12, 13 of this series have repercussions on the other patches, I would like to apply the whole series through the MTD tree; is this okay for you?
Yeah I will check them. Sorry the tag was dma: so it got dropped by my filters :( and I was on conference/vacation and didnt check other email...
Quoted 5 lines
Acked-by's welcome.
Thanks,
Miquèl
Signature · 5 lines
~Vinod ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 10/14] dma: mxs: Drop unnecessary flag
In reply to Sascha HauerQuoted 4 lines · Sascha Hauer
The mxs dma driver insists on having the
DMA_PREP_INTERRUPTflag set on all but the first transfer. There's no need to let the user set this flag, the driver can do it internally whenever it needs it. Drop handling of this flag from the driver.
After changing patch title to dmaengine: mxs: ....
Quoted 58 lines
Signed-off-by Sascha Hauer <[email protected]>--- drivers/dma/mxs-dma.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)drivers/dma/mxs-dma.c +8
-9@@ -477,16 +477,16 @@ static void mxs_dma_free_chan_resources(struct dma_chan *chan)* ...... * ->device_prep_slave_sg(0); * ...... -* ->device_prep_slave_sg(DMA_PREP_INTERRUPT | DMA_CTRL_ACK); +* ->device_prep_slave_sg(DMA_CTRL_ACK); * ...... * [3] If there are more than two DMA commands in the DMA chain, the code * should be: * ...... * ->device_prep_slave_sg(0); // First * ...... -* ->device_prep_slave_sg(DMA_PREP_INTERRUPT [| DMA_CTRL_ACK]); +* ->device_prep_slave_sg(DMA_CTRL_ACK]); * ...... -* ->device_prep_slave_sg(DMA_PREP_INTERRUPT | DMA_CTRL_ACK); // Last +* ->device_prep_slave_sg(DMA_CTRL_ACK); // Last * ...... */ static struct dma_async_tx_descriptor *mxs_dma_prep_slave_sg(@@ -500,13 +500,12 @@ static struct dma_async_tx_descriptor *mxs_dma_prep_slave_sg(struct scatterlist *sg;u32 i, j;u32 *pio; -bool append = flags &DMA_PREP_INTERRUPT ; -int idx = append ? mxs_chan->desc_count :0 ; +int idx =0 ; -if (mxs_chan->status ==DMA_IN_PROGRESS && !append) -return NULL ; +if (mxs_chan->status ==DMA_IN_PROGRESS ) + idx = mxs_chan->desc_count; -if (sg_len + (append ? idx :0 ) >NUM_CCW ) { +if (sg_len + idx >NUM_CCW ) {dev_err (mxs_dma->dma_device.dev,"maximum number of sg exceeded: %d > %d\n" , sg_len,NUM_CCW );@@ -520,7 +519,7 @@ static struct dma_async_tx_descriptor *mxs_dma_prep_slave_sg(* If the sg is prepared with append flag set, the sg * will be appended to the last prepared sg. */ -if (append) { +if (idx) {BUG_ON (idx <1 ); ccw = &mxs_chan->ccw[idx -1 ]; ccw->next = mxs_chan->ccw_phys +sizeof (*ccw) * idx;Signature · 1 line
2.20.1
Signature · 5 lines
~Vinod ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Sascha Hauer
maintainerPATCH v2 11/14 mtd: rawnand: gpmi: drop unnecessary flag
In reply to Sascha HauerThe DMA_PREP_INTERRUPT flag is no longer needed by the mxs dma driver, drop it.
--- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +5 -9
@@ -925,8 +925,7 @@ static int gpmi_send_command(struct gpmi_nand_data *this)sg_init_one (sgl, this->cmd_buffer, this->command_length);dma_map_sg (this->dev, sgl,1 ,DMA_TO_DEVICE ); desc =dmaengine_prep_slave_sg (channel, - sgl,1 ,DMA_MEM_TO_DEV , -DMA_PREP_INTERRUPT |DMA_CTRL_ACK ); + sgl,1 ,DMA_MEM_TO_DEV ,DMA_CTRL_ACK );if (!desc)return -EINVAL ;
@@ -997,8 +996,7 @@ static int gpmi_send_data(struct gpmi_nand_data *this, const void *buf,/* [2] send DMA request */ prepare_data_dma (this, buf, len,DMA_TO_DEVICE ); desc =dmaengine_prep_slave_sg (channel, &this->data_sgl, -1 ,DMA_MEM_TO_DEV , -DMA_PREP_INTERRUPT |DMA_CTRL_ACK ); +1 ,DMA_MEM_TO_DEV ,DMA_CTRL_ACK );if (!desc)return -EINVAL ;
@@ -1036,8 +1034,7 @@ static int gpmi_read_data(struct gpmi_nand_data *this, void *buf, int len)/* [2] : send DMA request */ direct =prepare_data_dma (this, buf, len,DMA_FROM_DEVICE ); desc =dmaengine_prep_slave_sg (channel, &this->data_sgl, -1 ,DMA_DEV_TO_MEM , -DMA_PREP_INTERRUPT |DMA_CTRL_ACK ); +1 ,DMA_DEV_TO_MEM ,DMA_CTRL_ACK );if (!desc)return -EINVAL ;
@@ -1150,7 +1147,7 @@ static int gpmi_read_page(struct gpmi_nand_data *this, desc =dmaengine_prep_slave_sg (channel, (struct scatterlist *)pio,ARRAY_SIZE (pio),DMA_TRANS_NONE , -DMA_PREP_INTERRUPT |DMA_CTRL_ACK ); +DMA_CTRL_ACK );if (!desc)return -EINVAL ;
@@ -1168,8 +1165,7 @@ static int gpmi_read_page(struct gpmi_nand_data *this, pio[2 ] =0 ;/* clear GPMI_HW_GPMI_ECCCTRL, disable the BCH. */ desc =dmaengine_prep_slave_sg (channel, (struct scatterlist *)pio,3 , -DMA_TRANS_NONE , -DMA_PREP_INTERRUPT |DMA_CTRL_ACK ); +DMA_TRANS_NONE ,DMA_CTRL_ACK );if (!desc)return -EINVAL ;
Signature · 6 lines
2.20.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 11/14] mtd: rawnand: gpmi: drop unnecessary flag
Hi Sascha,
Sascha Hauer <[email protected]> wrote on Tue, 9 Apr 2019 13:34:18 +0200:
Quoted 3 lines
The
DMA_PREP_INTERRUPTflag is no longer needed by the mxs dma driver, drop it.
s/dma/DMA/?
Otherwise
Quoted 2 lines
Signed-off-by Sascha Hauer <[email protected]>---
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Sascha Hauer
maintainerPATCH v2 12/14 dma: mxs: Add header file to be shared with gpmi nand driver
In reply to Sascha HauerThe mxs dma driver can do PIO transfers. A pointer to the PIO words to transfer is passed in the struct scatterlist * argument of dmaengine_prep_slave_sg(). It's quite ugly and non obvious to cast u32 * to struct scatterlist * each time when calling dmaengine_prep_slave_sg(), so add a static inline wrapper function to be called by the user along with a description what is going on.
--- drivers/dma/mxs-dma.c | 1 + drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 36 +++++++++------------- include/linux/dma/mxs-dma.h | 21 +++++++++++++ 3 files changed, 36 insertions(+), 22 deletions(-) create mode 100644 include/linux/dma/mxs-dma.h
drivers/dma/mxs-dma.c +1 -0
@@ -24,6 +24,7 @@#include <linux/of_device.h> #include <linux/of_dma.h> #include <linux/list.h> +#include <linux/dma/mxs-dma.h> #include <asm/irq.h>
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +14 -22
@@ -15,6 +15,7 @@#include <linux/of.h> #include <linux/of_device.h> #include <linux/pm_runtime.h> +#include <linux/dma/mxs-dma.h> #include "gpmi-nand.h" #include "gpmi-regs.h" #include "bch-regs.h"
@@ -913,9 +914,8 @@ static int gpmi_send_command(struct gpmi_nand_data *this) | BM_GPMI_CTRL0_ADDRESS_INCREMENT |BF_GPMI_CTRL0_XFER_COUNT (this->command_length); pio[1 ] = pio[2 ] =0 ; - desc =dmaengine_prep_slave_sg (channel, - (struct scatterlist *)pio, -ARRAY_SIZE (pio),DMA_TRANS_NONE ,0 ); + desc =mxs_dmaengine_prep_pio (channel, pio,ARRAY_SIZE (pio), +DMA_TRANS_NONE ,0 );if (!desc)return -EINVAL ;
@@ -988,8 +988,8 @@ static int gpmi_send_data(struct gpmi_nand_data *this, const void *buf, | BF_GPMI_CTRL0_ADDRESS(address) |BF_GPMI_CTRL0_XFER_COUNT (len); pio[1 ] =0 ; - desc =dmaengine_prep_slave_sg (channel, (struct scatterlist *)pio, -ARRAY_SIZE (pio),DMA_TRANS_NONE ,0 ); + desc =mxs_dmaengine_prep_pio (channel, pio,ARRAY_SIZE (pio), +DMA_TRANS_NONE ,0 );if (!desc)return -EINVAL ;
@@ -1025,9 +1025,8 @@ static int gpmi_read_data(struct gpmi_nand_data *this, void *buf, int len) | BF_GPMI_CTRL0_ADDRESS(BV_GPMI_CTRL0_ADDRESS__NAND_DATA) |BF_GPMI_CTRL0_XFER_COUNT (len); pio[1 ] =0 ; - desc =dmaengine_prep_slave_sg (channel, - (struct scatterlist *)pio, -ARRAY_SIZE (pio),DMA_TRANS_NONE ,0 ); + desc =mxs_dmaengine_prep_pio (channel, pio,ARRAY_SIZE (pio), +DMA_TRANS_NONE ,0 );if (!desc)return -EINVAL ;
@@ -1083,10 +1082,8 @@ static int gpmi_send_page(struct gpmi_nand_data *this, dma_addr_t payload, pio[4 ] = payload; pio[5 ] = auxiliary; - desc =dmaengine_prep_slave_sg (channel, - (struct scatterlist *)pio, -ARRAY_SIZE (pio),DMA_TRANS_NONE , -DMA_CTRL_ACK ); + desc =mxs_dmaengine_prep_pio (channel, pio,ARRAY_SIZE (pio), +DMA_TRANS_NONE ,DMA_CTRL_ACK );if (!desc)return -EINVAL ;
@@ -1117,9 +1114,7 @@ static int gpmi_read_page(struct gpmi_nand_data *this, | BF_GPMI_CTRL0_ADDRESS(address) |BF_GPMI_CTRL0_XFER_COUNT (0 ); pio[1 ] =0 ; - desc =dmaengine_prep_slave_sg (channel, - (struct scatterlist *)pio,2 , -DMA_TRANS_NONE ,0 ); + desc =mxs_dmaengine_prep_pio (channel, pio,2 ,DMA_TRANS_NONE ,0 );if (!desc)return -EINVAL ;
@@ -1144,10 +1139,8 @@ static int gpmi_read_page(struct gpmi_nand_data *this, pio[3 ] = geo->page_size; pio[4 ] = payload; pio[5 ] = auxiliary; - desc =dmaengine_prep_slave_sg (channel, - (struct scatterlist *)pio, -ARRAY_SIZE (pio),DMA_TRANS_NONE , -DMA_CTRL_ACK ); + desc =mxs_dmaengine_prep_pio (channel, pio,ARRAY_SIZE (pio), +DMA_TRANS_NONE ,DMA_CTRL_ACK );if (!desc)return -EINVAL ;
@@ -1163,9 +1156,8 @@ static int gpmi_read_page(struct gpmi_nand_data *this, | BF_GPMI_CTRL0_XFER_COUNT(geo->page_size); pio[1 ] =0 ; pio[2 ] =0 ;/* clear GPMI_HW_GPMI_ECCCTRL, disable the BCH. */ - desc =dmaengine_prep_slave_sg (channel, - (struct scatterlist *)pio,3 , -DMA_TRANS_NONE ,DMA_CTRL_ACK ); + desc =mxs_dmaengine_prep_pio (channel, pio,3 ,DMA_TRANS_NONE , +DMA_CTRL_ACK );if (!desc)return -EINVAL ;
include/linux/dma/mxs-dma.h new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _MXS_DMA_H_ +#define _MXS_DMA_H_ + +#include <linux/dmaengine.h> + +/* +* The mxs dmaengine can do PIO transfers. We pass a pointer to the PIO words +* in the second argument to dmaengine_prep_slave_sg when the direction is +* set to DMA_TRANS_NONE. To make this clear and to prevent users from doing +* the error prone casting we have this wrapper function +*/ +static inline struct dma_async_tx_descriptor *mxs_dmaengine_prep_pio ( +struct dma_chan *chan,u32 *pio,unsigned int npio, +enum dma_transfer_direction dir,unsigned long flags) +{ +return dmaengine_prep_slave_sg (chan, (struct scatterlist *)pio, npio, + dir, flags); +} + +#endif /* _MXS_DMA_H_ */
Signature · 6 lines
2.20.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 12/14] dma: mxs: Add header file to be shared with gpmi nand driver
Quoted 6 lines · Sascha Hauer
The mxs dma driver can do PIO transfers. A pointer to the PIO words to transfer is passed in the struct scatterlist * argument of
dmaengine_prep_slave_sg(). It's quite ugly and non obvious to cast u32 * to struct scatterlist * each time when callingdmaengine_prep_slave_sg(), so add a static inline wrapper function to be called by the user along with a description what is going on.
Again after fixing subsystem tag to dmanegine:
Quoted 146 lines
Signed-off-by Sascha Hauer <[email protected]>--- drivers/dma/mxs-dma.c | 1 + drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 36 +++++++++------------- include/linux/dma/mxs-dma.h | 21 +++++++++++++ 3 files changed, 36 insertions(+), 22 deletions(-) create mode 100644 include/linux/dma/mxs-dma.hdrivers/dma/mxs-dma.c +1
-0@@ -24,6 +24,7 @@#include <linux/of_device.h> #include <linux/of_dma.h> #include <linux/list.h> +#include <linux/dma/mxs-dma.h> #include <asm/irq.h> drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +14
-22@@ -15,6 +15,7 @@#include <linux/of.h> #include <linux/of_device.h> #include <linux/pm_runtime.h> +#include <linux/dma/mxs-dma.h> #include "gpmi-nand.h" #include "gpmi-regs.h" #include "bch-regs.h" @@ -913,9 +914,8 @@ static int gpmi_send_command(struct gpmi_nand_data *this) | BM_GPMI_CTRL0_ADDRESS_INCREMENT |BF_GPMI_CTRL0_XFER_COUNT (this->command_length); pio[1 ] = pio[2 ] =0 ; - desc =dmaengine_prep_slave_sg (channel, - (struct scatterlist *)pio, -ARRAY_SIZE (pio),DMA_TRANS_NONE ,0 ); + desc =mxs_dmaengine_prep_pio (channel, pio,ARRAY_SIZE (pio), +DMA_TRANS_NONE ,0 );if (!desc)return -EINVAL ;@@ -988,8 +988,8 @@ static int gpmi_send_data(struct gpmi_nand_data *this, const void *buf, | BF_GPMI_CTRL0_ADDRESS(address) |BF_GPMI_CTRL0_XFER_COUNT (len); pio[1 ] =0 ; - desc =dmaengine_prep_slave_sg (channel, (struct scatterlist *)pio, -ARRAY_SIZE (pio),DMA_TRANS_NONE ,0 ); + desc =mxs_dmaengine_prep_pio (channel, pio,ARRAY_SIZE (pio), +DMA_TRANS_NONE ,0 );if (!desc)return -EINVAL ;@@ -1025,9 +1025,8 @@ static int gpmi_read_data(struct gpmi_nand_data *this, void *buf, int len) | BF_GPMI_CTRL0_ADDRESS(BV_GPMI_CTRL0_ADDRESS__NAND_DATA) |BF_GPMI_CTRL0_XFER_COUNT (len); pio[1 ] =0 ; - desc =dmaengine_prep_slave_sg (channel, - (struct scatterlist *)pio, -ARRAY_SIZE (pio),DMA_TRANS_NONE ,0 ); + desc =mxs_dmaengine_prep_pio (channel, pio,ARRAY_SIZE (pio), +DMA_TRANS_NONE ,0 );if (!desc)return -EINVAL ;@@ -1083,10 +1082,8 @@ static int gpmi_send_page(struct gpmi_nand_data *this, dma_addr_t payload, pio[4 ] = payload; pio[5 ] = auxiliary; - desc =dmaengine_prep_slave_sg (channel, - (struct scatterlist *)pio, -ARRAY_SIZE (pio),DMA_TRANS_NONE , -DMA_CTRL_ACK ); + desc =mxs_dmaengine_prep_pio (channel, pio,ARRAY_SIZE (pio), +DMA_TRANS_NONE ,DMA_CTRL_ACK );if (!desc)return -EINVAL ;@@ -1117,9 +1114,7 @@ static int gpmi_read_page(struct gpmi_nand_data *this, | BF_GPMI_CTRL0_ADDRESS(address) |BF_GPMI_CTRL0_XFER_COUNT (0 ); pio[1 ] =0 ; - desc =dmaengine_prep_slave_sg (channel, - (struct scatterlist *)pio,2 , -DMA_TRANS_NONE ,0 ); + desc =mxs_dmaengine_prep_pio (channel, pio,2 ,DMA_TRANS_NONE ,0 );if (!desc)return -EINVAL ;@@ -1144,10 +1139,8 @@ static int gpmi_read_page(struct gpmi_nand_data *this, pio[3 ] = geo->page_size; pio[4 ] = payload; pio[5 ] = auxiliary; - desc =dmaengine_prep_slave_sg (channel, - (struct scatterlist *)pio, -ARRAY_SIZE (pio),DMA_TRANS_NONE , -DMA_CTRL_ACK ); + desc =mxs_dmaengine_prep_pio (channel, pio,ARRAY_SIZE (pio), +DMA_TRANS_NONE ,DMA_CTRL_ACK );if (!desc)return -EINVAL ;@@ -1163,9 +1156,8 @@ static int gpmi_read_page(struct gpmi_nand_data *this, | BF_GPMI_CTRL0_XFER_COUNT(geo->page_size); pio[1 ] =0 ; pio[2 ] =0 ;/* clear GPMI_HW_GPMI_ECCCTRL, disable the BCH. */ - desc =dmaengine_prep_slave_sg (channel, - (struct scatterlist *)pio,3 , -DMA_TRANS_NONE ,DMA_CTRL_ACK ); + desc =mxs_dmaengine_prep_pio (channel, pio,3 ,DMA_TRANS_NONE , +DMA_CTRL_ACK );if (!desc)return -EINVAL ;include/linux/dma/mxs-dma.h new file +21
-0@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _MXS_DMA_H_ +#define _MXS_DMA_H_ + +#include <linux/dmaengine.h> + +/* +* The mxs dmaengine can do PIO transfers. We pass a pointer to the PIO words +* in the second argument to dmaengine_prep_slave_sg when the direction is +* set to DMA_TRANS_NONE. To make this clear and to prevent users from doing +* the error prone casting we have this wrapper function +*/ +static inline struct dma_async_tx_descriptor *mxs_dmaengine_prep_pio ( +struct dma_chan *chan,u32 *pio,unsigned int npio, +enum dma_transfer_direction dir,unsigned long flags) +{ +return dmaengine_prep_slave_sg (chan, (struct scatterlist *)pio, npio, + dir, flags); +} + +#endif /* _MXS_DMA_H_ */ Signature · 1 line
2.20.1
Signature · 5 lines
~Vinod ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Sascha Hauer
maintainerPATCH v2 13/14 dma: mxs: rename custom flag
In reply to Sascha HauerThe mxs dma driver uses the flags parameter in dmaengine_prep_slave_sg() for custom flags, but still uses the dmaengine specific names of the flags. Do a little bit better and at least give the flag a custom name.
--- drivers/dma/mxs-dma.c | 4 ++-- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 17 +++++++++++------ include/linux/dma/mxs-dma.h | 2 ++ 3 files changed, 15 insertions(+), 8 deletions(-)
drivers/dma/mxs-dma.c +2 -2
@@ -541,7 +541,7 @@ static struct dma_async_tx_descriptor *mxs_dma_prep_slave_sg( ccw->bits =0 ; ccw->bits |=CCW_IRQ ; ccw->bits |=CCW_DEC_SEM ; -if (flags &DMA_CTRL_ACK ) +if (flags &MXS_DMA_CTRL_WAIT4END ) ccw->bits |=CCW_WAIT4END ; ccw->bits |=CCW_HALT_ON_TERM ; ccw->bits |=CCW_TERM_FLUSH ;
@@ -573,7 +573,7 @@ static struct dma_async_tx_descriptor *mxs_dma_prep_slave_sg( ccw->bits &= ~CCW_CHAIN ; ccw->bits |=CCW_IRQ ; ccw->bits |=CCW_DEC_SEM ; -if (flags &DMA_CTRL_ACK ) +if (flags &MXS_DMA_CTRL_WAIT4END ) ccw->bits |=CCW_WAIT4END ; } }
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +11 -6
@@ -925,7 +925,8 @@ static int gpmi_send_command(struct gpmi_nand_data *this)sg_init_one (sgl, this->cmd_buffer, this->command_length);dma_map_sg (this->dev, sgl,1 ,DMA_TO_DEVICE ); desc =dmaengine_prep_slave_sg (channel, - sgl,1 ,DMA_MEM_TO_DEV ,DMA_CTRL_ACK ); + sgl,1 ,DMA_MEM_TO_DEV , +MXS_DMA_CTRL_WAIT4END );if (!desc)return -EINVAL ;
@@ -996,7 +997,8 @@ static int gpmi_send_data(struct gpmi_nand_data *this, const void *buf,/* [2] send DMA request */ prepare_data_dma (this, buf, len,DMA_TO_DEVICE ); desc =dmaengine_prep_slave_sg (channel, &this->data_sgl, -1 ,DMA_MEM_TO_DEV ,DMA_CTRL_ACK ); +1 ,DMA_MEM_TO_DEV , +MXS_DMA_CTRL_WAIT4END );if (!desc)return -EINVAL ;
@@ -1033,7 +1035,8 @@ static int gpmi_read_data(struct gpmi_nand_data *this, void *buf, int len)/* [2] : send DMA request */ direct =prepare_data_dma (this, buf, len,DMA_FROM_DEVICE ); desc =dmaengine_prep_slave_sg (channel, &this->data_sgl, -1 ,DMA_DEV_TO_MEM ,DMA_CTRL_ACK ); +1 ,DMA_DEV_TO_MEM , +MXS_DMA_CTRL_WAIT4END );if (!desc)return -EINVAL ;
@@ -1083,7 +1086,8 @@ static int gpmi_send_page(struct gpmi_nand_data *this, dma_addr_t payload, pio[5 ] = auxiliary; desc =mxs_dmaengine_prep_pio (channel, pio,ARRAY_SIZE (pio), -DMA_TRANS_NONE ,DMA_CTRL_ACK ); +DMA_TRANS_NONE , +MXS_DMA_CTRL_WAIT4END );if (!desc)return -EINVAL ;
@@ -1140,7 +1144,8 @@ static int gpmi_read_page(struct gpmi_nand_data *this, pio[4 ] = payload; pio[5 ] = auxiliary; desc =mxs_dmaengine_prep_pio (channel, pio,ARRAY_SIZE (pio), -DMA_TRANS_NONE ,DMA_CTRL_ACK ); +DMA_TRANS_NONE , +MXS_DMA_CTRL_WAIT4END );if (!desc)return -EINVAL ;
@@ -1157,7 +1162,7 @@ static int gpmi_read_page(struct gpmi_nand_data *this, pio[1 ] =0 ; pio[2 ] =0 ;/* clear GPMI_HW_GPMI_ECCCTRL, disable the BCH. */ desc =mxs_dmaengine_prep_pio (channel, pio,3 ,DMA_TRANS_NONE , -DMA_CTRL_ACK ); +MXS_DMA_CTRL_WAIT4END );if (!desc)return -EINVAL ;
include/linux/dma/mxs-dma.h +2 -0
@@ -4,6 +4,8 @@#include <linux/dmaengine.h> +#define MXS_DMA_CTRL_WAIT4END BIT(31) +/* * The mxs dmaengine can do PIO transfers. We pass a pointer to the PIO words * in the second argument to dmaengine_prep_slave_sg when the direction is
Signature · 6 lines
2.20.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 13/14] dma: mxs: rename custom flag
Quoted 3 lines · Sascha Hauer
The mxs dma driver uses the flags parameter in
dmaengine_prep_slave_sg()for custom flags, but still uses the dmaengine specific names of the flags. Do a little bit better and at least give the flag a custom name.
after subsystem tag to dmaengine:
Quoted 108 lines
Signed-off-by Sascha Hauer <[email protected]>--- drivers/dma/mxs-dma.c | 4 ++-- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 17 +++++++++++------ include/linux/dma/mxs-dma.h | 2 ++ 3 files changed, 15 insertions(+), 8 deletions(-)drivers/dma/mxs-dma.c +2
-2@@ -541,7 +541,7 @@ static struct dma_async_tx_descriptor *mxs_dma_prep_slave_sg( ccw->bits =0 ; ccw->bits |=CCW_IRQ ; ccw->bits |=CCW_DEC_SEM ; -if (flags &DMA_CTRL_ACK ) +if (flags &MXS_DMA_CTRL_WAIT4END ) ccw->bits |=CCW_WAIT4END ; ccw->bits |=CCW_HALT_ON_TERM ; ccw->bits |=CCW_TERM_FLUSH ;@@ -573,7 +573,7 @@ static struct dma_async_tx_descriptor *mxs_dma_prep_slave_sg( ccw->bits &= ~CCW_CHAIN ; ccw->bits |=CCW_IRQ ; ccw->bits |=CCW_DEC_SEM ; -if (flags &DMA_CTRL_ACK ) +if (flags &MXS_DMA_CTRL_WAIT4END ) ccw->bits |=CCW_WAIT4END ; } }drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +11
-6@@ -925,7 +925,8 @@ static int gpmi_send_command(struct gpmi_nand_data *this)sg_init_one (sgl, this->cmd_buffer, this->command_length);dma_map_sg (this->dev, sgl,1 ,DMA_TO_DEVICE ); desc =dmaengine_prep_slave_sg (channel, - sgl,1 ,DMA_MEM_TO_DEV ,DMA_CTRL_ACK ); + sgl,1 ,DMA_MEM_TO_DEV , +MXS_DMA_CTRL_WAIT4END );if (!desc)return -EINVAL ;@@ -996,7 +997,8 @@ static int gpmi_send_data(struct gpmi_nand_data *this, const void *buf,/* [2] send DMA request */ prepare_data_dma (this, buf, len,DMA_TO_DEVICE ); desc =dmaengine_prep_slave_sg (channel, &this->data_sgl, -1 ,DMA_MEM_TO_DEV ,DMA_CTRL_ACK ); +1 ,DMA_MEM_TO_DEV , +MXS_DMA_CTRL_WAIT4END );if (!desc)return -EINVAL ;@@ -1033,7 +1035,8 @@ static int gpmi_read_data(struct gpmi_nand_data *this, void *buf, int len)/* [2] : send DMA request */ direct =prepare_data_dma (this, buf, len,DMA_FROM_DEVICE ); desc =dmaengine_prep_slave_sg (channel, &this->data_sgl, -1 ,DMA_DEV_TO_MEM ,DMA_CTRL_ACK ); +1 ,DMA_DEV_TO_MEM , +MXS_DMA_CTRL_WAIT4END );if (!desc)return -EINVAL ;@@ -1083,7 +1086,8 @@ static int gpmi_send_page(struct gpmi_nand_data *this, dma_addr_t payload, pio[5 ] = auxiliary; desc =mxs_dmaengine_prep_pio (channel, pio,ARRAY_SIZE (pio), -DMA_TRANS_NONE ,DMA_CTRL_ACK ); +DMA_TRANS_NONE , +MXS_DMA_CTRL_WAIT4END );if (!desc)return -EINVAL ;@@ -1140,7 +1144,8 @@ static int gpmi_read_page(struct gpmi_nand_data *this, pio[4 ] = payload; pio[5 ] = auxiliary; desc =mxs_dmaengine_prep_pio (channel, pio,ARRAY_SIZE (pio), -DMA_TRANS_NONE ,DMA_CTRL_ACK ); +DMA_TRANS_NONE , +MXS_DMA_CTRL_WAIT4END );if (!desc)return -EINVAL ;@@ -1157,7 +1162,7 @@ static int gpmi_read_page(struct gpmi_nand_data *this, pio[1 ] =0 ; pio[2 ] =0 ;/* clear GPMI_HW_GPMI_ECCCTRL, disable the BCH. */ desc =mxs_dmaengine_prep_pio (channel, pio,3 ,DMA_TRANS_NONE , -DMA_CTRL_ACK ); +MXS_DMA_CTRL_WAIT4END );if (!desc)return -EINVAL ;include/linux/dma/mxs-dma.h +2
-0@@ -4,6 +4,8 @@#include <linux/dmaengine.h> +#define MXS_DMA_CTRL_WAIT4END BIT(31) +/* * The mxs dmaengine can do PIO transfers. We pass a pointer to the PIO words * in the second argument to dmaengine_prep_slave_sg when the direction is Signature · 1 line
2.20.1
Signature · 5 lines
~Vinod ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Sascha Hauer
maintainerPATCH v2 14/14 mtd: rawnand: gpmi: Implement exec_op
In reply to Sascha HauerThe gpmi driver performance suffers from nand operations being split in multiple small dma transfers. This has been forced by the nand layer in the former days, but now with exec_op we can use the controller as intended.
With this patch gpmi_nfc_exec_op becomes the main entry point to nand operations. Here all instructions are collected and chained as separate DMA transfers. In the end whole chain is fired and waited to be finished. gpmi_nfc_exec_op only does the hardware operations, bad block marker swapping and buffer scrambling is done by the callers. It's worth noting that the nand_*_op functions always take the buffer lengths for the data that the nand chip actually transfers. When doing BCH we have to calculate the net data size from the raw data size in some places.
This patch has been tested with 2048/64 and 2048/128 byte nand on i.MX6q. mtd_oobtest, mtd_subpagetest and mtd_speedtest run without errors. nandbiterrs, nandpagetest and nandsubpagetest userspace tests from mtdutils run without errors and UBIFS can successfully be mounted.
--- drivers/dma/mxs-dma.c | 3 + drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 1100 ++++++++------------ drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h | 25 +- include/linux/dma/mxs-dma.h | 1 + 4 files changed, 436 insertions(+), 693 deletions(-)
drivers/dma/mxs-dma.c +3 -0
@@ -78,6 +78,7 @@#define BM_CCW_COMMAND (3 << 0)#define CCW_CHAIN (1 << 2)#define CCW_IRQ (1 << 3) +#define CCW_WAIT4RDY (1 << 5)#define CCW_DEC_SEM (1 << 6)#define CCW_WAIT4END (1 << 7)#define CCW_HALT_ON_TERM (1 << 8)
@@ -547,6 +548,8 @@ static struct dma_async_tx_descriptor *mxs_dma_prep_slave_sg( ccw->bits |=CCW_TERM_FLUSH ; ccw->bits |=BF_CCW (sg_len,PIO_NUM ); ccw->bits |=BF_CCW (MXS_DMA_CMD_NO_XFER ,COMMAND ); +if (flags &MXS_DMA_CTRL_WAIT4RDY ) + ccw->bits |=CCW_WAIT4RDY ; }else {for_each_sg (sgl, sg, sg_len, i) {if (sg_dma_len (sg) >MAX_XFER_BYTES ) {
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +418 -682
1,317 lines not on this page · raw message
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h +14 -11
@@ -103,6 +103,14 @@ struct gpmi_nfc_hardware_timing {u32 ctrl1n; }; +#define GPMI_MAX_TRANSFERS 8 + +struct gpmi_transfer { +u8 cmdbuf[8 ]; +struct scatterlist sgl; +enum dma_data_direction direction; +}; +struct gpmi_nand_data {/* Devdata */ const struct gpmi_devdata *devdata;
@@ -126,23 +134,18 @@ struct gpmi_nand_data {struct boot_rom_geometry rom_geometry;/* MTD / NAND */ +struct nand_controller base;struct nand_chip nand; -/* General-use Variables */ -int current_chip; -unsigned int command_length; +struct gpmi_transfer transfers[GPMI_MAX_TRANSFERS ]; +int ntransfers; -struct scatterlist cmd_sgl; -char *cmd_buffer; +bool bch; +uint32_t bch_flashlayout0; +uint32_t bch_flashlayout1; -struct scatterlist data_sgl;char *data_buffer_dma; -unsigned int page_buffer_size; - -void *payload_virt; -dma_addr_t payload_phys; -void *auxiliary_virt;dma_addr_t auxiliary_phys;
include/linux/dma/mxs-dma.h +1 -0
@@ -5,6 +5,7 @@#include <linux/dmaengine.h> #define MXS_DMA_CTRL_WAIT4END BIT(31) +#define MXS_DMA_CTRL_WAIT4RDY BIT(30)/* * The mxs dmaengine can do PIO transfers. We pass a pointer to the PIO words
Signature · 6 lines
2.20.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Miquel Raynal
maintainerRe: [PATCH 14/14] mtd: rawnand: gpmi: Implement exec_op
Hi Sascha,
Sascha Hauer <[email protected]> wrote on Tue, 9 Apr 2019 13:34:21 +0200:
Quoted 22 lines
The gpmi driver performance suffers from nand operations being split in multiple small dma transfers. This has been forced by the nand layer in the former days, but now with
exec_opwe can use the controller as intended.With this patch
gpmi_nfc_exec_opbecomes the main entry point to nand operations. Here all instructions are collected and chained as separate DMA transfers. In the end whole chain is fired and waited to be finished.gpmi_nfc_exec_oponly does the hardware operations, bad block marker swapping and buffer scrambling is done by the callers. It's worth noting that the nand_*_op functions always take the buffer lengths for the data that the nand chip actually transfers. When doing BCH we have to calculate the net data size from the raw data size in some places.This patch has been tested with 2048/64 and 2048/128 byte nand on i.MX6q.
mtd_oobtest,mtd_subpagetestandmtd_speedtestrun without errors. nandbiterrs, nandpagetest and nandsubpagetest userspace tests from mtdutils run without errors and UBIFS can successfully be mounted.Signed-off-by Sascha Hauer <[email protected]>--- drivers/dma/mxs-dma.c | 3 +
[...]
Quoted 72 lines
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +72
-0+static int gpmi_nfc_exec_op (struct nand_chip *chip, +const struct nand_operation *op, +bool check_only) +{ +const struct nand_op_instr *instr; +struct gpmi_nand_data *this =nand_get_controller_data (chip); +struct dma_async_tx_descriptor *desc =NULL ; +int i, ret, buf_len =0 , nbufs =0 ; +u8 cmd =0 ; +void *buf_read =NULL ; +const void *buf_write =NULL ; +bool direct = false; +struct completion *completion; +unsigned long to; + + this->ntransfers =0 ; +for (i =0 ; i <GPMI_MAX_TRANSFERS ; i++) + this->transfers[i].direction =DMA_NONE ; + + ret =pm_runtime_get_sync (this->dev); +if (ret <0 ) +return ret; + +/* +* This driver currently supports only one NAND chip. Plus, dies share +* the same configuration. So once timings have been applied on the +* controller side, they will not change anymore. When the time will +* come, the check on must_apply_timings will have to be dropped. +*/ +if (this->hw.must_apply_timings) { + this->hw.must_apply_timings = false; +gpmi_nfc_apply_timings (this); + } + +dev_dbg (this->dev,"%s: %d instructions\n" , __func__, op->ninstrs); + +for (i =0 ; i < op->ninstrs; i++) { + instr = &op->instrs[i]; + +nand_op_trace (" " , instr); + +switch (instr->type) { +case NAND_OP_WAITRDY_INSTR : + desc =gpmi_chain_wait_ready (this); +break ; +case NAND_OP_CMD_INSTR : + cmd = instr->ctx.cmd.opcode; + +/* +* When this command has an address cycle chain it +* together with the address cycle +*/ +if (i +1 != op->ninstrs && + op->instrs[i +1 ].type ==NAND_OP_ADDR_INSTR ) +continue ; + + desc =gpmi_chain_command (this, cmd,NULL ,0 ); + +break ; +case NAND_OP_ADDR_INSTR : + desc =gpmi_chain_command (this, cmd, instr->ctx.addr.addrs, + instr->ctx.addr.naddrs); +break ; +case NAND_OP_DATA_OUT_INSTR : + buf_write = instr->ctx.data.buf.out; + buf_len = instr->ctx.data.len; + nbufs++; + + desc =gpmi_chain_data_write (this, buf_write, buf_len); + +break ; +case NAND_OP_DATA_IN_INSTR :
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c static int gpmi_nand_attach_chip(struct nand_chip *chip) · line 2446
Quoted 10 lines
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +10
-0+if (!instr->ctx.data.len) +break ; + buf_read = instr->ctx.data.buf.in; + buf_len = instr->ctx.data.len; + nbufs++; + + desc =gpmi_chain_data_read (this, buf_read, buf_len, + &direct); +break ; + }
So there is no limitation for the controller in terms of address/data cycles that can be asserted in one go?
Quoted 62 lines
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +62
-0+ +if (!desc) { + ret = -ENXIO ; + goto unmap; + } + } + +dev_dbg (this->dev,"%s setup done\n" , __func__); + +if (nbufs >1 ) { +dev_err (this->dev,"Multiple data instructions not supported\n" ); + ret = -EINVAL ; + goto unmap; + } + +if (this->bch) { +writel (this->bch_flashlayout0, + this->resources.bch_regs +HW_BCH_FLASH0LAYOUT0 ); +writel (this->bch_flashlayout1, + this->resources.bch_regs +HW_BCH_FLASH0LAYOUT1 ); + } + +if (this->bch && buf_read) { +writel (BM_BCH_CTRL_COMPLETE_IRQ_EN , + this->resources.bch_regs +HW_BCH_CTRL_SET ); + completion = &this->bch_done; + }else { + desc->callback = dma_irq_callback; + desc->callback_param = this; + completion = &this->dma_done; + } + +init_completion (completion); + +dmaengine_submit (desc); +dma_async_issue_pending (get_dma_chan (this)); + + to =wait_for_completion_timeout (completion,msecs_to_jiffies (1000 )); +if (!to) { +dev_err (this->dev,"DMA timeout, last DMA\n" ); +gpmi_dump_info (this); + ret = -ETIMEDOUT ; + goto unmap; + } + +writel (BM_BCH_CTRL_COMPLETE_IRQ_EN , + this->resources.bch_regs +HW_BCH_CTRL_CLR ); +gpmi_clear_bch (this); + + ret =0 ; + +unmap: +for (i =0 ; i < this->ntransfers; i++) { +struct gpmi_transfer *transfer = &this->transfers[i]; + +if (transfer->direction !=DMA_NONE ) +dma_unmap_sg (this->dev, &transfer->sgl,1 , + transfer->direction); + } + +if (!ret && buf_read && !direct) + memcpy(buf_read, this->data_buffer_dma,
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c static int gpmi_nand_attach_chip(struct nand_chip *chip) · line 2518
Quoted 10 lines
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +10
-0+ gpmi_raw_len_to_len(this, buf_len)); + + this->bch = false; + +pm_runtime_mark_last_busy (this->dev); +pm_runtime_put_autosuspend (this->dev); + +return ret; +} +
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Sascha Hauer
maintainerRe: [PATCH 14/14] mtd: rawnand: gpmi: Implement exec_op
Hi Miquel,
Thanks for the review. I fixed all of it.
Quoted 16 lines · Miquel Raynal
Hi Sascha,
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c static int gpmi_nand_attach_chip(struct nand_chip *chip) · line 2446
Quoted 11 lines
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +11
-0+case NAND_OP_DATA_IN_INSTR : +if (!instr->ctx.data.len) +break ; + buf_read = instr->ctx.data.buf.in; + buf_len = instr->ctx.data.len; + nbufs++; + + desc =gpmi_chain_data_read (this, buf_read, buf_len, + &direct); +break ; + }So there is no limitation for the controller in terms of address/data cycles that can be asserted in one go?
No I think not, at least not a practical one. I can't find anything about it in the reference manual.
Where is your question aiming at?
Sascha
Signature · 8 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Miquel Raynal
maintainerRe: [PATCH 14/14] mtd: rawnand: gpmi: Implement exec_op
Hi Sascha,
Sascha Hauer <[email protected]> wrote on Wed, 24 Apr 2019 09:09:40 +0200:
Quoted 22 lines
Hi Miquel,
Thanks for the review. I fixed all of it.
Quoted 16 lines · Miquel Raynal
Hi Sascha,
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c static int gpmi_nand_attach_chip(struct nand_chip *chip) · line 2446
Quoted 11 lines
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +11
-0+case NAND_OP_DATA_IN_INSTR : +if (!instr->ctx.data.len) +break ; + buf_read = instr->ctx.data.buf.in; + buf_len = instr->ctx.data.len; + nbufs++; + + desc =gpmi_chain_data_read (this, buf_read, buf_len, + &direct); +break ; + }So there is no limitation for the controller in terms of address/data cycles that can be asserted in one go?
Quoted 4 lines
No I think not, at least not a practical one. I can't find anything about it in the reference manual.
Where is your question aiming at?
I'm fine with your answer, it was just to be sure that the controller's limitations (if any) where described.
Thanks for your work,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/