diff options
author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2017-03-30 04:15:05 -0400 |
---|---|---|
committer | Boris Brezillon <boris.brezillon@free-electrons.com> | 2017-04-25 08:18:38 -0400 |
commit | 477544c62a84d3bacd9f90ba75ffc16c04d78071 (patch) | |
tree | e9a1cdeaaa0862bd8d64483b14c0883357766a48 | |
parent | 3deb9979c7319bc7846d1aac528a9db85162960a (diff) |
mtd: nand: allow drivers to request minimum alignment for passed buffer
In some cases, nand_do_{read,write}_ops is passed with unaligned
ops->datbuf. Drivers using DMA will be unhappy about unaligned
buffer.
The new struct member, buf_align, represents the minimum alignment
the driver require for the buffer. If the buffer passed from the
upper MTD layer does not have enough alignment, nand_do_*_ops will
use bufpoi.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
-rw-r--r-- | drivers/mtd/nand/nand_base.c | 10 | ||||
-rw-r--r-- | include/linux/mtd/nand.h | 2 |
2 files changed, 10 insertions, 2 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index c796d0e4039a..ed49a1d634b0 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
@@ -1954,7 +1954,9 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from, | |||
1954 | if (!aligned) | 1954 | if (!aligned) |
1955 | use_bufpoi = 1; | 1955 | use_bufpoi = 1; |
1956 | else if (chip->options & NAND_USE_BOUNCE_BUFFER) | 1956 | else if (chip->options & NAND_USE_BOUNCE_BUFFER) |
1957 | use_bufpoi = !virt_addr_valid(buf); | 1957 | use_bufpoi = !virt_addr_valid(buf) || |
1958 | !IS_ALIGNED((unsigned long)buf, | ||
1959 | chip->buf_align); | ||
1958 | else | 1960 | else |
1959 | use_bufpoi = 0; | 1961 | use_bufpoi = 0; |
1960 | 1962 | ||
@@ -2810,7 +2812,9 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to, | |||
2810 | if (part_pagewr) | 2812 | if (part_pagewr) |
2811 | use_bufpoi = 1; | 2813 | use_bufpoi = 1; |
2812 | else if (chip->options & NAND_USE_BOUNCE_BUFFER) | 2814 | else if (chip->options & NAND_USE_BOUNCE_BUFFER) |
2813 | use_bufpoi = !virt_addr_valid(buf); | 2815 | use_bufpoi = !virt_addr_valid(buf) || |
2816 | !IS_ALIGNED((unsigned long)buf, | ||
2817 | chip->buf_align); | ||
2814 | else | 2818 | else |
2815 | use_bufpoi = 0; | 2819 | use_bufpoi = 0; |
2816 | 2820 | ||
@@ -3429,6 +3433,8 @@ static void nand_set_defaults(struct nand_chip *chip) | |||
3429 | nand_hw_control_init(chip->controller); | 3433 | nand_hw_control_init(chip->controller); |
3430 | } | 3434 | } |
3431 | 3435 | ||
3436 | if (!chip->buf_align) | ||
3437 | chip->buf_align = 1; | ||
3432 | } | 3438 | } |
3433 | 3439 | ||
3434 | /* Sanitize ONFI strings so we can safely print them */ | 3440 | /* Sanitize ONFI strings so we can safely print them */ |
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 9e0c93c44bef..8f67b1581683 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h | |||
@@ -755,6 +755,7 @@ struct nand_manufacturer_ops { | |||
755 | * setting the read-retry mode. Mostly needed for MLC NAND. | 755 | * setting the read-retry mode. Mostly needed for MLC NAND. |
756 | * @ecc: [BOARDSPECIFIC] ECC control structure | 756 | * @ecc: [BOARDSPECIFIC] ECC control structure |
757 | * @buffers: buffer structure for read/write | 757 | * @buffers: buffer structure for read/write |
758 | * @buf_align: minimum buffer alignment required by a platform | ||
758 | * @hwcontrol: platform-specific hardware control structure | 759 | * @hwcontrol: platform-specific hardware control structure |
759 | * @erase: [REPLACEABLE] erase function | 760 | * @erase: [REPLACEABLE] erase function |
760 | * @scan_bbt: [REPLACEABLE] function to scan bad block table | 761 | * @scan_bbt: [REPLACEABLE] function to scan bad block table |
@@ -905,6 +906,7 @@ struct nand_chip { | |||
905 | 906 | ||
906 | struct nand_ecc_ctrl ecc; | 907 | struct nand_ecc_ctrl ecc; |
907 | struct nand_buffers *buffers; | 908 | struct nand_buffers *buffers; |
909 | unsigned long buf_align; | ||
908 | struct nand_hw_control hwcontrol; | 910 | struct nand_hw_control hwcontrol; |
909 | 911 | ||
910 | uint8_t *bbt; | 912 | uint8_t *bbt; |