nand: fix buffer alignment in new verification feature
Subsystems (2)
PATCH RESEND v2 1/1 nand: fix buffer alignment in new verification feature
From: Stephen Warren <[email protected]>
On systems with caches enabled, NAND I/O may need to flush/invalidate the cache during read/write operations. For this to work correctly, all buffers must be cache-aligned. Fix nand_verify*() to allocate aligned buffers.
This prevents cache alignment warnings from being spewed when using U-Boot to write an updated version of itself to flash on NVIDIA Tegra Seaboard (after perturbation of stack/data layout in current u-boot-dm/next branch).
I have validatd (executed) nand_verify(), but I don't think I've executed nand_verify_page_oob(); testing of that would be useful.
---
Resending to Tom for direct application, including reviewed-/acked-by tags from others.
As an aside, I think this patch demonstrates why new features shouldn't be merged just a couple weeks before the release; there's not enough time to detect regressions and patch them. The merge window is for new features.
v2: Use memalign() rather than ALLOC_CACHE_ALIGN_BUFFER() so that the buffer is allocated from the heap not on the stack, to reduce stack usage.
drivers/mtd/nand/nand_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/nand/nand_util.c +2 -2
@@ -483,7 +483,7 @@ int nand_verify_page_oob(nand_info_t *nand, struct mtd_oob_ops *ops, loff_t ofs)memcpy (&vops, ops,sizeof (vops)); - vops.datbuf =malloc (verlen); + vops.datbuf =memalign (ARCH_DMA_MINALIGN , verlen);if (!vops.datbuf)return -ENOMEM ;
@@ -520,7 +520,7 @@ int nand_verify(nand_info_t *nand, loff_t ofs, size_t len, u_char *buf)int rval =0 ;size_t verofs;size_t verlen = nand->writesize; -uint8_t *verbuf =malloc (verlen); +uint8_t *verbuf =memalign (ARCH_DMA_MINALIGN , verlen);if (!verbuf)return -ENOMEM ;
Signature · 1 line
1.9.1
PATCH RESEND v2 1/1 nand: fix buffer alignment in new verification feature
Hello Stephen,
Am 06.05.2015 18:01, schrieb Stephen Warren:
Quoted 22 lines
From: Stephen Warren <[email protected]>
On systems with caches enabled, NAND I/O may need to flush/invalidate the cache during read/write operations. For this to work correctly, all buffers must be cache-aligned. Fix nand_verify*() to allocate aligned buffers.
This prevents cache alignment warnings from being spewed when using U-Boot to write an updated version of itself to flash on NVIDIA Tegra Seaboard (after perturbation of stack/data layout in current u-boot-dm/next branch).
I have validatd (executed)
nand_verify(), but I don't think I've executednand_verify_page_oob(); testing of that would be useful.Cc Peter Tyser <[email protected]>Cc Heiko Schocher <[email protected]>Cc Scott Wood <[email protected]>Fixes 59b5a2ad83df ("nand: Add verification functions")Signed-off-by Stephen Warren <[email protected]>Reviewed-by Simon Glass <[email protected]>Acked-by Scott Wood <[email protected]>
Quoted 7 lines
---
Resending to Tom for direct application, including reviewed-/acked-by tags from others.As an aside, I think this patch demonstrates why new features shouldn't be merged just a couple weeks before the release; there's not enough time to detect regressions and patch them. The merge window is for new features.
Yes, with new features we should be more conservative.
Quoted 6 lines
v2: Use
memalign()rather thanALLOC_CACHE_ALIGN_BUFFER()so that the buffer is allocated from the heap not on the stack, to reduce stack usage.drivers/mtd/nand/nand_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Thanks for detecting this.
bye,
Heiko
Quoted 24 lines
drivers/mtd/nand/nand_util.c +2
-2@@ -483,7 +483,7 @@ int nand_verify_page_oob(nand_info_t *nand, struct mtd_oob_ops *ops, loff_t ofs)memcpy (&vops, ops,sizeof (vops)); - vops.datbuf =malloc (verlen); + vops.datbuf =memalign (ARCH_DMA_MINALIGN , verlen);if (!vops.datbuf)return -ENOMEM ;@@ -520,7 +520,7 @@ int nand_verify(nand_info_t *nand, loff_t ofs, size_t len, u_char *buf)int rval =0 ;size_t verofs;size_t verlen = nand->writesize; -uint8_t *verbuf =malloc (verlen); +uint8_t *verbuf =memalign (ARCH_DMA_MINALIGN , verlen);if (!verbuf)return -ENOMEM ;
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH RESEND v2 1/1 nand: fix buffer alignment in new verification feature
Quoted 17 lines · Heiko Schocher
Hello Stephen,
Am 06.05.2015 18:01, schrieb Stephen Warren:
Quoted 14 lines
From: Stephen Warren <[email protected]>
On systems with caches enabled, NAND I/O may need to flush/invalidate the cache during read/write operations. For this to work correctly, all buffers must be cache-aligned. Fix nand_verify*() to allocate aligned buffers.
This prevents cache alignment warnings from being spewed when using U-Boot to write an updated version of itself to flash on NVIDIA Tegra Seaboard (after perturbation of stack/data layout in current u-boot-dm/next branch).
I have validatd (executed)
nand_verify(), but I don't think I've executednand_verify_page_oob(); testing of that would be useful.
Is there any chance of this being applied? It's been 5 weeks since it was first sent.
Quoted 59 lines
Quoted 12 lines
Cc Peter Tyser <[email protected]>Cc Heiko Schocher <[email protected]>Cc Scott Wood <[email protected]>Fixes 59b5a2ad83df ("nand: Add verification functions")Signed-off-by Stephen Warren <[email protected]>Reviewed-by Simon Glass <[email protected]>Acked-by Scott Wood <[email protected]>---
Resending to Tom for direct application, including reviewed-/acked-by tags
from others.Quoted 4 lines
As an aside, I think this patch demonstrates why new features shouldn't be
merged just a couple weeks before the release; there's not enough time to detect regressions and patch them. The merge window is for new features.Yes, with new features we should be more conservative.
Quoted 6 lines
v2: Use
memalign()rather thanALLOC_CACHE_ALIGN_BUFFER()so that the buffer is allocated from the heap not on the stack, to reduce stack usage.drivers/mtd/nand/nand_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Thanks for detecting this.
Acked-by Heiko Schocher <[email protected]>bye,
HeikoQuoted 26 lines
drivers/mtd/nand/nand_util.c +1
-1@@ -483,7 +483,7 @@ int nand_verify_page_oob(nand_info_t *nand, struct mtd_oob_ops *ops, loff_t ofs) memcpy(&vops, ops, sizeof(vops)); - vops.datbuf =malloc (verlen); + vops.datbuf =memalign (ARCH_DMA_MINALIGN , verlen);if (!vops.datbuf)return -ENOMEM;drivers/mtd/nand/nand_util.c +1
-1@@ -520,7 +520,7 @@ int nand_verify(nand_info_t *nand, loff_t ofs, size_t len, u_char *buf) int rval = 0;size_t verofs;size_t verlen = nand->writesize; -uint8_t *verbuf =malloc (verlen); +uint8_t *verbuf =memalign (ARCH_DMA_MINALIGN , verlen);if (!verbuf)return -ENOMEM;
PATCH RESEND v2 1/1 nand: fix buffer alignment in new verification feature
Quoted 16 lines · Stephen Warren
Quoted 15 lines · Heiko Schocher
Hello Stephen,
Am 06.05.2015 18:01, schrieb Stephen Warren:
Quoted 12 lines
From: Stephen Warren <[email protected]>
On systems with caches enabled, NAND I/O may need to flush/invalidate the cache during read/write operations. For this to work correctly, all buffers must be cache-aligned. Fix nand_verify*() to allocate aligned buffers.
This prevents cache alignment warnings from being spewed when using U-Boot to write an updated version of itself to flash on NVIDIA Tegra Seaboard (after perturbation of stack/data layout in current u-boot-dm/next branch).
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
I have validatd (executed)
nand_verify(), but I don't think I've executednand_verify_page_oob(); testing of that would be useful.Is there any chance of this being applied? It's been 5 weeks since it was first sent.
Sorry about the delay. I'll send a pull request soon.
-Scott