mtd: nand: brcmnand: Add support for flash-dma v0
PATCH 1/2 mtd: nand: brcmnand: Add support for flash-dma v0
This change adds support for flash dma v0.0.
--- drivers/mtd/nand/raw/brcmnand/brcmnand.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)
drivers/mtd/nand/raw/brcmnand/brcmnand.c +19 -2
@@ -117,6 +117,18 @@ enum flash_dma_reg { FLASH_DMA_CURRENT_DESC_EXT, }; +/* flash_dma registers v0*/ +static const u16 flash_dma_regs_v0[] = { + [FLASH_DMA_REVISION ] =0x00 , + [FLASH_DMA_FIRST_DESC ] =0x04 , + [FLASH_DMA_CTRL ] =0x08 , + [FLASH_DMA_MODE ] =0x0c , + [FLASH_DMA_STATUS ] =0x10 , + [FLASH_DMA_INTERRUPT_DESC ] =0x14 , + [FLASH_DMA_ERROR_STATUS ] =0x18 , + [FLASH_DMA_CURRENT_DESC ] =0x1c , +}; +/* flash_dma registers v1*/ static const u16 flash_dma_regs_v1[] = { [FLASH_DMA_REVISION ] =0x00 ,
@@ -597,6 +609,8 @@ static void brcmnand_flash_dma_revision_init(struct brcmnand_controller *ctrl)/* flash_dma register offsets */ if (ctrl->nand_version >=0x0703 ) ctrl->flash_dma_offsets = flash_dma_regs_v4; +else if (ctrl->nand_version ==0x0602 ) + ctrl->flash_dma_offsets = flash_dma_regs_v0;else ctrl->flash_dma_offsets = flash_dma_regs_v1; }
@@ -1673,8 +1687,11 @@ static void brcmnand_dma_run(struct brcmnand_host *host, dma_addr_t desc)flash_dma_writel (ctrl,FLASH_DMA_FIRST_DESC ,lower_32_bits (desc)); (void )flash_dma_readl (ctrl,FLASH_DMA_FIRST_DESC ); -flash_dma_writel (ctrl,FLASH_DMA_FIRST_DESC_EXT ,upper_32_bits (desc)); - (void )flash_dma_readl (ctrl,FLASH_DMA_FIRST_DESC_EXT ); +if (ctrl->nand_version >0x0602 ) { +flash_dma_writel (ctrl,FLASH_DMA_FIRST_DESC_EXT , +upper_32_bits (desc)); + (void )flash_dma_readl (ctrl,FLASH_DMA_FIRST_DESC_EXT ); + }/* Start FLASH_DMA engine */ ctrl->dma_pending = true;
Signature · 1 line
2.17.1
PATCH 2/2 mtd: rawnand: use bounce buffer when vmalloced data buf detected
For controller drivers that use DMA and set NAND_USE_BOUNCE_BUFFER option use data buffers that are not vmalloced, aligned and have valid virtual address to be able to do DMA transfers. This change adds additional check and makes use of data buffer allocated in nand_base driver when it is passed a vmalloced data buffer for DMA transfers.
--- drivers/mtd/nand/raw/nand_base.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/mtd/nand/raw/nand_base.c +8 -6
@@ -45,6 +45,12 @@#include "internals.h" +static int nand_need_bounce_buf (const void *buf,struct nand_chip *chip) +{ +return !virt_addr_valid (buf) ||is_vmalloc_addr (buf) || + !IS_ALIGNED ((unsigned long )buf, chip->buf_align); +} +/* Define default oob placement schemes for large and small page devices */ static int nand_ooblayout_ecc_sp (struct mtd_info *mtd,int section,struct mtd_oob_region *oobregion)
@@ -3183,9 +3189,7 @@ static int nand_do_read_ops(struct nand_chip *chip, loff_t from,if (!aligned) use_bufpoi =1 ;else if (chip->options &NAND_USE_BOUNCE_BUFFER ) - use_bufpoi = !virt_addr_valid (buf) || - !IS_ALIGNED ((unsigned long )buf, - chip->buf_align); + use_bufpoi =nand_need_bounce_buf (buf, chip);else use_bufpoi =0 ;
@@ -4009,9 +4013,7 @@ static int nand_do_write_ops(struct nand_chip *chip, loff_t to,if (part_pagewr) use_bufpoi =1 ;else if (chip->options &NAND_USE_BOUNCE_BUFFER ) - use_bufpoi = !virt_addr_valid (buf) || - !IS_ALIGNED ((unsigned long )buf, - chip->buf_align); + use_bufpoi =nand_need_bounce_buf (buf, chip);else use_bufpoi =0 ;
Signature · 1 line
2.17.1
Re: [PATCH 2/2] mtd: rawnand: use bounce buffer when vmalloced data buf detected
Does anyone have any comments on this patch ?.
Kamal
Quoted 55 lines · Kamal Dasu
For controller drivers that use DMA and set
NAND_USE_BOUNCE_BUFFERoption use data buffers that are not vmalloced, aligned and have valid virtual address to be able to do DMA transfers. This change adds additional check and makes use of data buffer allocated innand_basedriver when it is passed a vmalloced data buffer for DMA transfers.Signed-off-by Kamal Dasu <[email protected]>--- drivers/mtd/nand/raw/nand_base.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)drivers/mtd/nand/raw/nand_base.c +8
-7@@ -45,6 +45,12 @@#include "internals.h" +static int nand_need_bounce_buf (const void *buf,struct nand_chip *chip) +{ +return !virt_addr_valid (buf) ||is_vmalloc_addr (buf) || + !IS_ALIGNED ((unsigned long )buf, chip->buf_align); +} +/* Define default oob placement schemes for large and small page devices */ static int nand_ooblayout_ecc_sp (struct mtd_info *mtd,int section,struct mtd_oob_region *oobregion)@@ -3183,9 +3189,7 @@ static int nand_do_read_ops(struct nand_chip *chip, loff_t from,if (!aligned) use_bufpoi =1 ;else if (chip->options &NAND_USE_BOUNCE_BUFFER ) - use_bufpoi = !virt_addr_valid (buf) || - !IS_ALIGNED ((unsigned long )buf, - chip->buf_align); + use_bufpoi =nand_need_bounce_buf (buf, chip);else use_bufpoi =0 ;@@ -4009,9 +4013,7 @@ static int nand_do_write_ops(struct nand_chip *chip, loff_t to,if (part_pagewr) use_bufpoi =1 ;else if (chip->options &NAND_USE_BOUNCE_BUFFER ) - use_bufpoi = !virt_addr_valid (buf) || - !IS_ALIGNED ((unsigned long )buf, - chip->buf_align); + use_bufpoi =nand_need_bounce_buf (buf, chip);else use_bufpoi =0 ; --2.17.1
Re: [PATCH 2/2] mtd: rawnand: use bounce buffer when vmalloced data buf detected
Quoted 24 lines · On Mon, 30 Sep 2019 12:01:28 -0400 Kamal Dasu <[email protected]> wrote:
Does anyone have any comments on this patch ?.
Kamal
Quoted 19 lines · Kamal Dasu
For controller drivers that use DMA and set
NAND_USE_BOUNCE_BUFFERoption use data buffers that are not vmalloced, aligned and have valid virtual address to be able to do DMA transfers. This change adds additional check and makes use of data buffer allocated innand_basedriver when it is passed a vmalloced data buffer for DMA transfers.Signed-off-by Kamal Dasu <[email protected]>--- drivers/mtd/nand/raw/nand_base.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)drivers/mtd/nand/raw/nand_base.c +0
-0@@ -45,6 +45,12 @@
Quoted 5 lines
drivers/mtd/nand/raw/nand_base.c line 50
Quoted 5 lines
drivers/mtd/nand/raw/nand_base.c +3
-0#include "internals.h" +static int nand_need_bounce_buf (const void *buf,struct nand_chip *chip) +{ + return !virt_addr_valid(buf) || is_vmalloc_addr(buf) ||
I thought virt_addr_valid() was implying !is_vmalloc_addr(), are you sure you need that test, and can you tell me on which arch(es) this is needed.
Quoted 31 lines
Quoted 31 lines
drivers/mtd/nand/raw/nand_base.c +5
-7+ !IS_ALIGNED ((unsigned long )buf, chip->buf_align); +} +/* Define default oob placement schemes for large and small page devices */ static int nand_ooblayout_ecc_sp (struct mtd_info *mtd,int section,struct mtd_oob_region *oobregion)@@ -3183,9 +3189,7 @@ static int nand_do_read_ops(struct nand_chip *chip, loff_t from,if (!aligned) use_bufpoi =1 ;else if (chip->options &NAND_USE_BOUNCE_BUFFER ) - use_bufpoi = !virt_addr_valid (buf) || - !IS_ALIGNED ((unsigned long )buf, - chip->buf_align); + use_bufpoi =nand_need_bounce_buf (buf, chip);else use_bufpoi =0 ;@@ -4009,9 +4013,7 @@ static int nand_do_write_ops(struct nand_chip *chip, loff_t to,if (part_pagewr) use_bufpoi =1 ;else if (chip->options &NAND_USE_BOUNCE_BUFFER ) - use_bufpoi = !virt_addr_valid (buf) || - !IS_ALIGNED ((unsigned long )buf, - chip->buf_align); + use_bufpoi =nand_need_bounce_buf (buf, chip);else use_bufpoi =0 ; --2.17.1
Kamal Dasu
maintainerRe: [PATCH 2/2] mtd: rawnand: use bounce buffer when vmalloced data buf detected
Quoted 30 lines · Boris Brezillon
Quoted 26 lines · On Mon, 30 Sep 2019 12:01:28 -0400 Kamal Dasu <[email protected]> wrote:
Does anyone have any comments on this patch ?.
Kamal
Quoted 21 lines · Kamal Dasu
For controller drivers that use DMA and set
NAND_USE_BOUNCE_BUFFERoption use data buffers that are not vmalloced, aligned and have valid virtual address to be able to do DMA transfers. This change adds additional check and makes use of data buffer allocated innand_basedriver when it is passed a vmalloced data buffer for DMA transfers.Signed-off-by Kamal Dasu <[email protected]>--- drivers/mtd/nand/raw/nand_base.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)drivers/mtd/nand/raw/nand_base.c +0
-0@@ -45,6 +45,12 @@#include "internals.h"
Quoted 8 lines
Quoted 3 lines
drivers/mtd/nand/raw/nand_base.c line 50
Quoted 3 lines
drivers/mtd/nand/raw/nand_base.c +3
-0+static int nand_need_bounce_buf (const void *buf,struct nand_chip *chip) +{ + return !virt_addr_valid(buf) || is_vmalloc_addr(buf) ||I thought
virt_addr_valid()was implying !is_vmalloc_addr(), are you sure you need that test, and can you tell me on which arch(es) this is needed.
This has been observed on MIPS4K and MIPS5K architectures. There is a check on the controller driver to use pio in such cases.
Quoted 32 lines
Quoted 31 lines
Quoted 31 lines
drivers/mtd/nand/raw/nand_base.c +5
-7+ !IS_ALIGNED ((unsigned long )buf, chip->buf_align); +} +/* Define default oob placement schemes for large and small page devices */ static int nand_ooblayout_ecc_sp (struct mtd_info *mtd,int section,struct mtd_oob_region *oobregion)@@ -3183,9 +3189,7 @@ static int nand_do_read_ops(struct nand_chip *chip, loff_t from,if (!aligned) use_bufpoi =1 ;else if (chip->options &NAND_USE_BOUNCE_BUFFER ) - use_bufpoi = !virt_addr_valid (buf) || - !IS_ALIGNED ((unsigned long )buf, - chip->buf_align); + use_bufpoi =nand_need_bounce_buf (buf, chip);else use_bufpoi =0 ;@@ -4009,9 +4013,7 @@ static int nand_do_write_ops(struct nand_chip *chip, loff_t to,if (part_pagewr) use_bufpoi =1 ;else if (chip->options &NAND_USE_BOUNCE_BUFFER ) - use_bufpoi = !virt_addr_valid (buf) || - !IS_ALIGNED ((unsigned long )buf, - chip->buf_align); + use_bufpoi =nand_need_bounce_buf (buf, chip);else use_bufpoi =0 ; --2.17.1
Richard Weinberger
maintainerRe: [PATCH 2/2] mtd: rawnand: use bounce buffer when vmalloced data buf detected
----- Ursprüngliche Mail -----
Quoted 3 lines
Von: "Kamal Dasu" <[email protected]>
This has been observed on MIPS4K and MIPS5K architectures. There is a check on the controller driver to use pio in such cases.
I fear your kernel misses commit:074a1e1167af ("MIPS: Bounds check virt_addr_valid")
Thanks,
//richard
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 2/2] mtd: rawnand: use bounce buffer when vmalloced data buf detected
I was testing with UBI/UBIFS where vmalloced data buffers can be passed to the nand_base and then o the controller driver. Probably applies to older kernel 4.1.
Can the Patch1/2 be accepted or you want me to send it separately by removing the nand_base changes ?.
Kamal
Kamal
Quoted 11 lines · Richard Weinberger
----- Ursprüngliche Mail -----
Quoted 3 lines
Von: "Kamal Dasu" <[email protected]>
This has been observed on MIPS4K and MIPS5K architectures. There is a check on the controller driver to use pio in such cases.I fear your kernel misses commit:
074a1e1167af("MIPS: Bounds checkvirt_addr_valid")Thanks,
//richard
Quoted 3 lines · Kamal Dasu
This change adds support for flash dma v0.0.
Signed-off-by Kamal Dasu <[email protected]>
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.
Miquel