remoteproc: drop memset when loading elf segments
PATCH 1/2 remoteproc: drop memset when loading elf segments
To arm64, "dc zva, dst" is used in memset.
Per ARM DDI 0487A.j, chapter C5.3.8 DC ZVA, Data Cache Zero by VA,
"If the memory region being zeroed is any type of Device memory, this instruction can give an alignment fault which is prioritized in the same way as other alignment faults that are determined by the memory type."
On i.MX platforms, when elf is loaded to onchip TCM area, the region is ioremapped, so "dc zva, dst" will trigger abort.
Since memset is not strictly required, let's drop it.
--- drivers/remoteproc/remoteproc_elf_loader.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/remoteproc/remoteproc_elf_loader.c +2 -5
@@ -238,14 +238,11 @@ int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw)memcpy (ptr, elf_data + offset, filesz);/* -* Zero out remaining memory for this segment. +* No need zero out remaining memory for this segment. * * This isn't strictly required since dma_alloc_coherent already -* did this for us. albeit harmless, we may consider removing -* this. +* did this for us. */ -if (memsz > filesz) -memset (ptr + filesz,0 , memsz - filesz); }if (ret ==0 )
Signature · 1 line
2.16.4
PATCH 2/2 remoteproc: use filesz as backup when translate memsz fail
Since we no need memset if memsz is larger than filesz, we could use filesz for the da to va translation when memsz translation fail.
--- drivers/remoteproc/remoteproc_elf_loader.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/remoteproc/remoteproc_elf_loader.c +10 -2
@@ -229,8 +229,16 @@ int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw)if (!ptr) {dev_err (dev,"bad phdr da 0x%llx mem 0x%llx\n" , da, memsz); - ret = -EINVAL ; -break ; + + ptr =rproc_da_to_va (rproc, da, filesz); +if (!ptr) { +dev_err (dev, +"bad phdr da 0x%llx mem 0x%llx\n" , + da, filesz); + ret = -EINVAL ; +break ; + } + }/* put the segment where the remote processor expects it */
Signature · 1 line
2.16.4
Re: [PATCH 2/2] remoteproc: use filesz as backup when translate memsz fail
Quoted 3 lines · Peng Fan
Since we no need memset if memsz is larger than filesz, we could use filesz for the da to va translation when memsz translation fail.
To me this implies that the firmware has a segment that's larger than the memory that it's going to run in. I think even if we're not writing to the entire memsz, asking da_to_va for the entire memsz provides a valuable sanity check.
Regards,
Bjorn
Quoted 31 lines
Signed-off-by Peng Fan <[email protected]>--- drivers/remoteproc/remoteproc_elf_loader.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)drivers/remoteproc/remoteproc_elf_loader.c +10
-2@@ -229,8 +229,16 @@ int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw)if (!ptr) {dev_err (dev,"bad phdr da 0x%llx mem 0x%llx\n" , da, memsz); - ret = -EINVAL ; -break ; + + ptr =rproc_da_to_va (rproc, da, filesz); +if (!ptr) { +dev_err (dev, +"bad phdr da 0x%llx mem 0x%llx\n" , + da, filesz); + ret = -EINVAL ; +break ; + } + }/* put the segment where the remote processor expects it */ Signature · 1 line
2.16.4
RE: [PATCH 2/2] remoteproc: use filesz as backup when translate memsz fail
Hi Bjorn,
Quoted 5 lines
Subject: Re: [PATCH 2/2] remoteproc: use filesz as backup when translate memsz fail
On Thu 09 Apr 01:22 PDT 2020, Peng Fan wrote:
Quoted 8 lines
Quoted 3 lines
Since we no need memset if memsz is larger than filesz, we could use filesz for the da to va translation when memsz translation fail.
To me this implies that the firmware has a segment that's larger than the memory that it's going to run in. I think even if we're not writing to the entire memsz, asking
da_to_vafor the entire memsz provides a valuable sanity check.
da_to_va implies that Linux should have the va map to da. However that will be case that Linux is not able to touch all da, it only able touch half. Then Linux should also map all da?
Thanks,
Peng.
Quoted 37 lines
Regards,
Bjorndrivers/remoteproc/remoteproc_elf_loader.c int rproc_elf_load_segments(struct rproc *rproc,
Quoted 11 lines
Signed-off-by Peng Fan <[email protected]>--- drivers/remoteproc/remoteproc_elf_loader.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)drivers/remoteproc/remoteproc_elf_loader.c +0
-0@@ -229,8 +229,16 @@ int rproc_elf_load_segments(struct rproc *rproc,const struct firmware *fw)
Quoted 21 lines
drivers/remoteproc/remoteproc_elf_loader.c +10
-3if (!ptr) {dev_err (dev,"bad phdr da 0x%llx mem 0x%llx\n" , da, memsz); - ret = -EINVAL ; -break ; + + ptr =rproc_da_to_va (rproc, da, filesz); +if (!ptr) { +dev_err (dev, +"bad phdr da 0x%llx mem 0x%llx\n" , + da, filesz); + ret = -EINVAL ; +break ; + } + }/* put the segment where the remote processor expects it */ --2.16.4
Re: [PATCH 2/2] remoteproc: use filesz as backup when translate memsz fail
Quoted 11 lines · Peng Fan
Hi Bjorn,
Quoted 9 lines
Subject: Re: [PATCH 2/2] remoteproc: use filesz as backup when translate memsz fail
Quoted 3 lines · Peng Fan
Since we no need memset if memsz is larger than filesz, we could use filesz for the da to va translation when memsz translation fail.
Quoted 9 lines
Quoted 4 lines
To me this implies that the firmware has a segment that's larger than the memory that it's going to run in. I think even if we're not writing to the entire memsz, asking
da_to_vafor the entire memsz provides a valuable sanity check.
da_to_vaimplies that Linux should have the va map to da. However that will be case that Linux is not able to touch all da, it only able touch half. Then Linux should also map all da?
So you have memory described in your ELF that can only be accessed by the remoteproc? And this memory is covered by segments of type PT_LOAD?
What's your strategy for making sure that filesz stays within the boundaries that the ELF loader is allowed to touch?
Regards,
Bjorn
Quoted 40 lines
Thanks,
Peng.Quoted 37 lines
Regards,
Bjorndrivers/remoteproc/remoteproc_elf_loader.c int rproc_elf_load_segments(struct rproc *rproc,
Quoted 11 lines
Signed-off-by Peng Fan <[email protected]>--- drivers/remoteproc/remoteproc_elf_loader.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)drivers/remoteproc/remoteproc_elf_loader.c +0
-0@@ -229,8 +229,16 @@ int rproc_elf_load_segments(struct rproc *rproc,const struct firmware *fw)
Quoted 21 lines
drivers/remoteproc/remoteproc_elf_loader.c +10
-3if (!ptr) {dev_err (dev,"bad phdr da 0x%llx mem 0x%llx\n" , da, memsz); - ret = -EINVAL ; -break ; + + ptr =rproc_da_to_va (rproc, da, filesz); +if (!ptr) { +dev_err (dev, +"bad phdr da 0x%llx mem 0x%llx\n" , + da, filesz); + ret = -EINVAL ; +break ; + } + }/* put the segment where the remote processor expects it */ --2.16.4
Mathieu Poirier
maintainerRe: [PATCH 2/2] remoteproc: use filesz as backup when translate memsz fail
In reply to Bjorn AnderssonQuoted 31 lines · Bjorn Andersson
Quoted 3 lines · Peng Fan
Since we no need memset if memsz is larger than filesz, we could use filesz for the da to va translation when memsz translation fail.
To me this implies that the firmware has a segment that's larger than the memory that it's going to run in. I think even if we're not writing to the entire memsz, asking
da_to_vafor the entire memsz provides a valuable sanity check.Regards,
BjornQuoted 17 lines
Signed-off-by Peng Fan <[email protected]>--- drivers/remoteproc/remoteproc_elf_loader.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)drivers/remoteproc/remoteproc_elf_loader.c +2
-2@@ -229,8 +229,16 @@ int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw)if (!ptr) {dev_err (dev,"bad phdr da 0x%llx mem 0x%llx\n" , da, memsz); - ret = -EINVAL ; -break ; + + ptr =rproc_da_to_va (rproc, da, filesz);
Quoted 8 lines
drivers/remoteproc/remoteproc_elf_loader.c int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw) · line 241
Quoted 8 lines
drivers/remoteproc/remoteproc_elf_loader.c +8
-0+if (!ptr) { +dev_err (dev, +"bad phdr da 0x%llx mem 0x%llx\n" , + da, filesz); + ret = -EINVAL ; +break ; + } +
Adding to Bjorn's comment, I think if rproc_da_to_va() fails with memsz but succeeds with filesz something went wrong with how memory was laid out in the DT or the ELF resources. To me this patch offers the wrong solution - the focus should be on why rproc_da_to_va() fails.
Thanks,
Mathieu
Quoted 6 lines
Quoted 6 lines
drivers/remoteproc/remoteproc_elf_loader.c +0
-0}/* put the segment where the remote processor expects it */ Signature · 1 line
2.16.4
RE: [PATCH 2/2] remoteproc: use filesz as backup when translate memsz fail
Quoted 42 lines
Subject: Re: [PATCH 2/2] remoteproc: use filesz as backup when translate memsz fail
Quoted 19 lines · Bjorn Andersson
Quoted 3 lines · Peng Fan
Since we no need memset if memsz is larger than filesz, we could use filesz for the da to va translation when memsz translation fail.
To me this implies that the firmware has a segment that's larger than the memory that it's going to run in. I think even if we're not writing to the entire memsz, asking
da_to_vafor the entire memsz provides a valuable sanity check.Regards,
BjornQuoted 5 lines
Signed-off-by Peng Fan <[email protected]>--- drivers/remoteproc/remoteproc_elf_loader.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)Quoted 6 lines
drivers/remoteproc/remoteproc_elf_loader.c int rproc_elf_load_segments(struct rproc *rproc,
Quoted 6 lines
drivers/remoteproc/remoteproc_elf_loader.c +0
-0@@ -229,8 +229,16 @@ int rproc_elf_load_segments(struct rproc *rproc,const struct firmware *fw)
Quoted 12 lines
Quoted 12 lines
drivers/remoteproc/remoteproc_elf_loader.c +7
-2if (!ptr) {dev_err (dev,"bad phdr da 0x%llx mem 0x%llx\n" , da, memsz); - ret = -EINVAL ; -break ; + + ptr =rproc_da_to_va (rproc, da, filesz); +if (!ptr) { +dev_err (dev, +"bad phdr da 0x%llx mem 0x%llx\n" , + da, filesz); + ret = -EINVAL ;
Quoted 8 lines
Quoted 3 lines
drivers/remoteproc/remoteproc_elf_loader.c int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw) · line 241
Quoted 3 lines
drivers/remoteproc/remoteproc_elf_loader.c +3
-0+break ; + } +Adding to Bjorn's comment, I think if
rproc_da_to_va()fails with memsz but succeeds with filesz something went wrong with how memory was laid out in the DT or the ELF resources. To me this patch offers the wrong solution - the focus should be on whyrproc_da_to_va()fails.
ok, I'll send out patch to fix imx_rproc. It is TCML and TCMU are not mapped continusly.
Thanks,
Peng.
Quoted 10 lines
Thanks,
MathieuQuoted 6 lines
Quoted 6 lines
drivers/remoteproc/remoteproc_elf_loader.c +0
-1}/* put the segment where the remote processor expects it */ --2.16.4
Quoted 8 lines · Peng Fan
To arm64, "dc zva, dst" is used in memset.
Per ARM DDI 0487A.j, chapter C5.3.8 DC ZVA, Data Cache Zero by VA,"If the memory region being zeroed is any type of Device memory, this instruction can give an alignment fault which is prioritized in the same way as other alignment faults that are determined by the memory type."
Quoted 5 lines
On i.MX platforms, when elf is loaded to onchip TCM area, the region is ioremapped, so "dc zva, dst" will trigger abort.
Since memset is not strictly required, let's drop it.
This would imply that we trust that the firmware doesn't expect remoteproc to zero out the memory, which we've always done. So I don't think we can say that it's not required.
Quoted 10 lines
Signed-off-by Peng Fan <[email protected]>--- drivers/remoteproc/remoteproc_elf_loader.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/remoteproc/remoteproc_elf_loader.c +0
-0
drivers/remoteproc/remoteproc_elf_loader.c int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw) · line 244
Quoted 10 lines
drivers/remoteproc/remoteproc_elf_loader.c +2
-3@@ -238,14 +238,11 @@ int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw)memcpy (ptr, elf_data + offset, filesz);/* -* Zero out remaining memory for this segment. +* No need zero out remaining memory for this segment. * * This isn't strictly required since dma_alloc_coherent already -* did this for us. albeit harmless, we may consider removing -* this. +* did this for us.
In the case of recovery this comment is wrong, we do not dma_alloc_coherent() the carveout during a recovery.
And in your case you ioremapped existing TCM, so it's never true.
drivers/remoteproc/remoteproc_elf_loader.c int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw) · line 248
Quoted 3 lines
drivers/remoteproc/remoteproc_elf_loader.c +0
-2*/ -if (memsz > filesz) -memset (ptr + filesz,0 , memsz - filesz);
So I think you do want to zero out this region. Question is how we do it...
Regards,
Bjorn
Quoted 6 lines
drivers/remoteproc/remoteproc_elf_loader.c +0
-0}if (ret ==0 )Signature · 1 line
2.16.4
Hi Bjorn,
Quoted 16 lines
Subject: Re: [PATCH 1/2] remoteproc: drop memset when loading elf segments
Quoted 11 lines · Peng Fan
To arm64, "dc zva, dst" is used in memset.
Per ARM DDI 0487A.j, chapter C5.3.8 DC ZVA, Data Cache Zero by VA,"If the memory region being zeroed is any type of Device memory, this instruction can give an alignment fault which is prioritized in the same way as other alignment faults that are determined by the memory type."
On i.MX platforms, when elf is loaded to onchip TCM area, the region is ioremapped, so "dc zva, dst" will trigger abort.
Quoted 6 lines
Quoted 2 lines
Since memset is not strictly required, let's drop it.
This would imply that we trust that the firmware doesn't expect remoteproc to zero out the memory, which we've always done. So I don't think we can say that it's not required.
Saying an image runs on a remote core needs Linux to help zero out BSS section, this not make sense to me. My case is as following, I need to load section 7 data. I no need to let remoteproc to memset section 8/9/10/11/12, the firmware itself could handle that. Just because the memsz is larger than filesz, remoreproc must memset?
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al [ 0] NULL 00000000 000000 000000 00 0 0 0 [ 1] .interrupts PROGBITS 1ffe0000 010000 000240 00 A 0 0 4 [ 2] .resource_table PROGBITS 1ffe0240 010240 000058 00 A 0 0 1 [ 3] .text PROGBITS 1ffe02a0 0102a0 009ccc 00 AX 0 0 16 [ 4] .ARM ARM_EXIDX 1ffe9f6c 019f6c 000008 00 AL 3 0 4 [ 5] .init_array INIT_ARRAY 1ffe9f74 019f74 000004 04 WA 0 0 4 [ 6] .fini_array FINI_ARRAY 1ffe9f78 019f78 000004 04 WA 0 0 4 [ 7] .data PROGBITS 1fff9240 029240 000084 00 WA 0 0 4 [ 8] .ncache.init PROGBITS 1fff92c4 0292c4 000000 00 W 0 0 1 [ 9] .ncache NOBITS 1fff92c4 0292c4 000a80 00 WA 0 0 4 [10] .bss NOBITS 1fff9d44 0292c4 01f5c0 00 WA 0 0 4 [11] .heap NOBITS 20019304 0292c4 000404 00 WA 0 0 1 [12] .stack NOBITS 20019708 0292c4 000400 00 WA 0 0 1
Quoted 15 lines
drivers/remoteproc/remoteproc_elf_loader.c int rproc_elf_load_segments(struct rproc *rproc,
Quoted 12 lines
Signed-off-by Peng Fan <[email protected]>--- drivers/remoteproc/remoteproc_elf_loader.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/remoteproc/remoteproc_elf_loader.c +0
-0@@ -238,14 +238,11 @@ int rproc_elf_load_segments(struct rproc *rproc,const struct firmware *fw)
Quoted 2 lines
drivers/remoteproc/remoteproc_elf_loader.c +0
-0memcpy (ptr, elf_data + offset, filesz);
Quoted 11 lines
drivers/remoteproc/remoteproc_elf_loader.c int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw) · line 244
Quoted 8 lines
drivers/remoteproc/remoteproc_elf_loader.c +2
-3/* -* Zero out remaining memory for this segment. +* No need zero out remaining memory for this segment. * * This isn't strictly required since dma_alloc_coherent already -* did this for us. albeit harmless, we may consider removing -* this. +* did this for us. In the case of recovery this comment is wrong, we do not
dma_alloc_coherent()the carveout during a recovery.
Isn't the it the firmware's job to memset the region?
Quoted 8 lines
And in your case you ioremapped existing TCM, so it's never true.
drivers/remoteproc/remoteproc_elf_loader.c int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw) · line 248
Quoted 3 lines
drivers/remoteproc/remoteproc_elf_loader.c +0
-2*/ -if (memsz > filesz) -memset (ptr + filesz,0 , memsz - filesz);So I think you do want to zero out this region. Question is how we do it...
I have contacted our M4 owners, we no need clear it from Linux side. We also support booting m4 before booting Linux, at that case, Linux has noting to do with memset. It is just I try loading m4 image with Linux, and met the issue that memset trigger abort.
Thanks,
Peng.
Quoted 10 lines
Regards,
BjornQuoted 6 lines
drivers/remoteproc/remoteproc_elf_loader.c +0
-1}if (ret ==0 ) --2.16.4
Quoted 21 lines · Peng Fan
Hi Bjorn,
Quoted 19 lines
Subject: Re: [PATCH 1/2] remoteproc: drop memset when loading elf segments
Quoted 13 lines · Peng Fan
To arm64, "dc zva, dst" is used in memset.
Per ARM DDI 0487A.j, chapter C5.3.8 DC ZVA, Data Cache Zero by VA,"If the memory region being zeroed is any type of Device memory, this instruction can give an alignment fault which is prioritized in the same way as other alignment faults that are determined by the memory type."
On i.MX platforms, when elf is loaded to onchip TCM area, the region is ioremapped, so "dc zva, dst" will trigger abort.
Since memset is not strictly required, let's drop it.
Quoted 6 lines
Quoted 3 lines
This would imply that we trust that the firmware doesn't expect remoteproc to zero out the memory, which we've always done. So I don't think we can say that it's not required.
Saying an image runs on a remote core needs Linux to help zero out BSS section, this not make sense to me.
Maybe not, but it has always done it, so if there's firmware out there that depends on it such change would break them..
Quoted 4 lines
My case is as following, I need to load section 7 data.
I no need to let remoteproc to memset section 8/9/10/11/12, the firmware itself could handle that. Just because the memsz is larger than filesz, remoreproc must memset?
By having a PT_LOAD segment covering these I think it's reasonable to assume that the ELF loader should be able to touch the associated memory.
Quoted 43 lines
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al [ 0] NULL 00000000 000000 000000 00 0 0 0 [ 1] .interrupts PROGBITS 1ffe0000 010000 000240 00 A 0 0 4 [ 2] .resource_table PROGBITS 1ffe0240 010240 000058 00 A 0 0 1 [ 3] .text PROGBITS 1ffe02a0 0102a0 009ccc 00 AX 0 0 16 [ 4] .ARM ARM_EXIDX 1ffe9f6c 019f6c 000008 00 AL 3 0 4 [ 5] .init_array INIT_ARRAY 1ffe9f74 019f74 000004 04 WA 0 0 4 [ 6] .fini_array FINI_ARRAY 1ffe9f78 019f78 000004 04 WA 0 0 4 [ 7] .data PROGBITS 1fff9240 029240 000084 00 WA 0 0 4 [ 8] .ncache.init PROGBITS 1fff92c4 0292c4 000000 00 W 0 0 1 [ 9] .ncache NOBITS 1fff92c4 0292c4 000a80 00 WA 0 0 4 [10] .bss NOBITS 1fff9d44 0292c4 01f5c0 00 WA 0 0 4 [11] .heap NOBITS 20019304 0292c4 000404 00 WA 0 0 1 [12] .stack NOBITS 20019708 0292c4 000400 00 WA 0 0 1Quoted 15 lines
drivers/remoteproc/remoteproc_elf_loader.c int rproc_elf_load_segments(struct rproc *rproc,
Quoted 12 lines
Signed-off-by Peng Fan <[email protected]>--- drivers/remoteproc/remoteproc_elf_loader.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/remoteproc/remoteproc_elf_loader.c +0
-0@@ -238,14 +238,11 @@ int rproc_elf_load_segments(struct rproc *rproc,const struct firmware *fw)
Quoted 2 lines
drivers/remoteproc/remoteproc_elf_loader.c +0
-0memcpy (ptr, elf_data + offset, filesz);Quoted 11 lines
drivers/remoteproc/remoteproc_elf_loader.c int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw) · line 244
Quoted 8 lines
drivers/remoteproc/remoteproc_elf_loader.c +2
-3/* -* Zero out remaining memory for this segment. +* No need zero out remaining memory for this segment. * * This isn't strictly required since dma_alloc_coherent already -* did this for us. albeit harmless, we may consider removing -* this. +* did this for us. In the case of recovery this comment is wrong, we do not
dma_alloc_coherent()the carveout during a recovery.
Quoted 2 lines
Isn't the it the firmware's job to memset the region?
I'm not aware of this being a documented requirement, we've always done it here for them, so removing this call would be a change in behavior.
Quoted 10 lines
Quoted 8 lines
And in your case you ioremapped existing TCM, so it's never true.
drivers/remoteproc/remoteproc_elf_loader.c int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw) · line 248
Quoted 3 lines
drivers/remoteproc/remoteproc_elf_loader.c +0
-2*/ -if (memsz > filesz) -memset (ptr + filesz,0 , memsz - filesz);So I think you do want to zero out this region. Question is how we do it...
I have contacted our M4 owners, we no need clear it from Linux side.
And I think _most_ firmware out there, like yours, does clear BSS etc during initialization.
Quoted 4 lines
We also support booting m4 before booting Linux, at that case, Linux has noting to do with memset. It is just I try loading m4 image with Linux, and met the issue that memset trigger abort.
Please see the proposal for attaching to already running remoteproc's from Mathieu. I don't expect that you want to load your PROGBITS either in this case?
Regards,
Bjorn
Quoted 31 lines
Subject: Re: [PATCH 1/2] remoteproc: drop memset when loading elf segments
Quoted 25 lines · Peng Fan
Hi Bjorn,
Quoted 22 lines
Subject: Re: [PATCH 1/2] remoteproc: drop memset when loading elf segments
Quoted 8 lines · Peng Fan
To arm64, "dc zva, dst" is used in memset.
Per ARM DDI 0487A.j, chapter C5.3.8 DC ZVA, Data Cache Zero by VA,"If the memory region being zeroed is any type of Device memory, this instruction can give an alignment fault which is prioritized in the same way as other alignment faults that are determined by the memory type."
Quoted 5 lines
On i.MX platforms, when elf is loaded to onchip TCM area, the region is ioremapped, so "dc zva, dst" will trigger abort.
Since memset is not strictly required, let's drop it.
This would imply that we trust that the firmware doesn't expect remoteproc to zero out the memory, which we've always done. So I don't think we can say that it's not required.
Quoted 5 lines
Quoted 2 lines
Saying an image runs on a remote core needs Linux to help zero out BSS section, this not make sense to me.
Maybe not, but it has always done it, so if there's firmware out there that depends on it such change would break them..
Got it.
Quoted 87 lines
Quoted 5 lines
My case is as following, I need to load section 7 data. I no need to let remoteproc to memset section 8/9/10/11/12, the firmware itself could handle that. Just because the memsz is larger than filesz, remoreproc must memset?
By having a
PT_LOADsegment covering these I think it's reasonable to assume that the ELF loader should be able to touch the associated memory.Quoted 2 lines
Section Headers:
[Nr] Name Type Addr Off SizeES Flg Lk Inf Al
Quoted 1 line
[ 0] NULL 00000000 000000
000000 00 0 0 0
Quoted 1 line
[ 1] .interrupts PROGBITS
1ffe0000010000 000240 00A 0 0 4
Quoted 1 line
[ 2] .resource_table PROGBITS
1ffe0240010240 000058 00A 0 0 1
Quoted 1 line
[ 3] .text PROGBITS
1ffe02a00102a0 009ccc 00AX 0 0 16 > [ 4] .ARM ARM_EXIDX 1ffe9f6c 019f6c 000008 00 AL 3 0 4 > [ 5] .init_array INIT_ARRAY 1ffe9f74 019f74 000004 04 WA 0 0 4 > [ 6] .fini_array FINI_ARRAY 1ffe9f78 019f78 000004 04 WA 0 0 4 > [ 7] .data PROGBITS 1fff9240 029240 000084 00 WA 0 0 4 > [ 8] .ncache.init PROGBITS 1fff92c4 0292c4 000000 00W 0 0 1
Quoted 1 line
[ 9] .ncache NOBITS
1fff92c40292c4 000a8000 WA 0 0 4 > [10] .bss NOBITS 1fff9d44 0292c4 01f5c0 00 WA 0 0 4 > [11] .heap NOBITS 20019304 0292c4 000404 00 WA 0 0 1 > [12] .stack NOBITS 20019708 0292c4 000400 00 WA 0 0 1Quoted 29 lines
Quoted 17 lines
Quoted 13 lines
Signed-off-by Peng Fan <[email protected]>--- drivers/remoteproc/remoteproc_elf_loader.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/remoteproc/remoteproc_elf_loader.c +0
-0drivers/remoteproc/remoteproc_elf_loader.c int rproc_elf_load_segments(struct rproc · line 238
Quoted 1 line
drivers/remoteproc/remoteproc_elf_loader.c +0
-0@@ -238,14 +238,11 @@ int rproc_elf_load_segments(struct rproc *rproc,const struct firmware *fw)
Quoted 2 lines
drivers/remoteproc/remoteproc_elf_loader.c +0
-0memcpy (ptr, elf_data + offset, filesz);Quoted 11 lines
drivers/remoteproc/remoteproc_elf_loader.c int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw) · line 244
Quoted 8 lines
drivers/remoteproc/remoteproc_elf_loader.c +2
-3/* -* Zero out remaining memory for this segment. +* No need zero out remaining memory for this segment. * * This isn't strictly required since dma_alloc_coherent already -* did this for us. albeit harmless, we may consider removing -* this. +* did this for us. In the case of recovery this comment is wrong, we do not
dma_alloc_coherent()the carveout during a recovery.Quoted 2 lines
Isn't the it the firmware's job to memset the region?
I'm not aware of this being a documented requirement, we've always done it here for them, so removing this call would be a change in behavior.
Quoted 10 lines
Quoted 8 lines
And in your case you ioremapped existing TCM, so it's never true.
drivers/remoteproc/remoteproc_elf_loader.c int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw) · line 248
Quoted 3 lines
drivers/remoteproc/remoteproc_elf_loader.c +0
-2*/ -if (memsz > filesz) -memset (ptr + filesz,0 , memsz - filesz);So I think you do want to zero out this region. Question is how we do it...
I have contacted our M4 owners, we no need clear it from Linux side.
And I think _most_ firmware out there, like yours, does clear BSS etc during initialization.
Quoted 8 lines
Quoted 4 lines
We also support booting m4 before booting Linux, at that case, Linux has noting to do with memset. It is just I try loading m4 image with Linux, and met the issue that memset trigger abort.
Please see the proposal for attaching to already running remoteproc's from Mathieu. I don't expect that you want to load your PROGBITS either in this case?
No need to load for early boot case. It is just userspace load trigger kernel panic, because memset arm64 could not work for ioremapped memory.
How about adding ops hooks for memset and memcpy to let driver have their own implementation?
Thanks,
Peng.
Quoted 3 lines
Regards,
Bjorn
Quoted 135 lines · Peng Fan
Quoted 31 lines
Subject: Re: [PATCH 1/2] remoteproc: drop memset when loading elf segments
Quoted 25 lines · Peng Fan
Hi Bjorn,
Quoted 22 lines
Subject: Re: [PATCH 1/2] remoteproc: drop memset when loading elf segments
Quoted 8 lines · Peng Fan
To arm64, "dc zva, dst" is used in memset.
Per ARM DDI 0487A.j, chapter C5.3.8 DC ZVA, Data Cache Zero by VA,"If the memory region being zeroed is any type of Device memory, this instruction can give an alignment fault which is prioritized in the same way as other alignment faults that are determined by the memory type."
Quoted 5 lines
On i.MX platforms, when elf is loaded to onchip TCM area, the region is ioremapped, so "dc zva, dst" will trigger abort.
Since memset is not strictly required, let's drop it.
This would imply that we trust that the firmware doesn't expect remoteproc to zero out the memory, which we've always done. So I don't think we can say that it's not required.
Quoted 5 lines
Quoted 2 lines
Saying an image runs on a remote core needs Linux to help zero out BSS section, this not make sense to me.
Maybe not, but it has always done it, so if there's firmware out there that depends on it such change would break them..
Got it.
Quoted 87 lines
Quoted 5 lines
My case is as following, I need to load section 7 data. I no need to let remoteproc to memset section 8/9/10/11/12, the firmware itself could handle that. Just because the memsz is larger than filesz, remoreproc must memset?
By having a
PT_LOADsegment covering these I think it's reasonable to assume that the ELF loader should be able to touch the associated memory.Quoted 2 lines
Section Headers:
[Nr] Name Type Addr Off SizeES Flg Lk Inf Al
Quoted 1 line
[ 0] NULL 00000000 000000000000 00 0 0 0
Quoted 1 line
[ 1] .interrupts PROGBITS 1ffe0000 010000 000240 00A 0 0 4
Quoted 1 line
[ 2] .resource_table PROGBITS 1ffe0240 010240 000058 00A 0 0 1
Quoted 1 line
[ 3] .text PROGBITS 1ffe02a0 0102a0 009ccc 00AX 0 0 16
Quoted 1 line
[ 4] .ARM ARM_EXIDX 1ffe9f6c 019f6c 00000800 AL 3 0 4
Quoted 1 line
[ 5] .init_array INIT_ARRAY 1ffe9f74 019f74 000004 04WA 0 0 4
Quoted 1 line
[ 6] .fini_array FINI_ARRAY 1ffe9f78 019f78 000004 04WA 0 0 4
Quoted 1 line
[ 7] .data PROGBITS 1fff9240 029240 00008400 WA 0 0 4
Quoted 1 line
[ 8] .ncache.init PROGBITS 1fff92c4 0292c4 000000 00W 0 0 1
Quoted 1 line
[ 9] .ncache NOBITS 1fff92c4 0292c4 000a8000 WA 0 0 4
Quoted 1 line
[10] .bss NOBITS 1fff9d44 0292c4 01f5c000 WA 0 0 4
Quoted 1 line
[11] .heap NOBITS 20019304 0292c4 00040400 WA 0 0 1
Quoted 1 line
[12] .stack NOBITS 20019708 0292c4 00040000 WA 0 0 1
Quoted 29 lines
Quoted 17 lines
Quoted 13 lines
Signed-off-by Peng Fan <[email protected]>--- drivers/remoteproc/remoteproc_elf_loader.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/remoteproc/remoteproc_elf_loader.c +0
-0drivers/remoteproc/remoteproc_elf_loader.c int rproc_elf_load_segments(struct rproc · line 238
Quoted 1 line
drivers/remoteproc/remoteproc_elf_loader.c +0
-0@@ -238,14 +238,11 @@ int rproc_elf_load_segments(struct rproc *rproc,const struct firmware *fw)
Quoted 2 lines
drivers/remoteproc/remoteproc_elf_loader.c +0
-0memcpy (ptr, elf_data + offset, filesz);Quoted 11 lines
drivers/remoteproc/remoteproc_elf_loader.c int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw) · line 244
Quoted 8 lines
drivers/remoteproc/remoteproc_elf_loader.c +2
-3/* -* Zero out remaining memory for this segment. +* No need zero out remaining memory for this segment. * * This isn't strictly required since dma_alloc_coherent already -* did this for us. albeit harmless, we may consider removing -* this. +* did this for us. In the case of recovery this comment is wrong, we do not
dma_alloc_coherent()the carveout during a recovery.Quoted 2 lines
Isn't the it the firmware's job to memset the region?
I'm not aware of this being a documented requirement, we've always done it here for them, so removing this call would be a change in behavior.
Quoted 10 lines
Quoted 8 lines
And in your case you ioremapped existing TCM, so it's never true.
drivers/remoteproc/remoteproc_elf_loader.c int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw) · line 248
Quoted 3 lines
drivers/remoteproc/remoteproc_elf_loader.c +0
-2*/ -if (memsz > filesz) -memset (ptr + filesz,0 , memsz - filesz);So I think you do want to zero out this region. Question is how we do it...
I have contacted our M4 owners, we no need clear it from Linux side.
And I think _most_ firmware out there, like yours, does clear BSS etc during initialization.
Quoted 8 lines
Quoted 4 lines
We also support booting m4 before booting Linux, at that case, Linux has noting to do with memset. It is just I try loading m4 image with Linux, and met the issue that memset trigger abort.
Please see the proposal for attaching to already running remoteproc's from Mathieu. I don't expect that you want to load your PROGBITS either in this case?
Quoted 5 lines
No need to load for early boot case. It is just userspace load trigger kernel panic, because memset arm64 could not work for ioremapped memory.
How about adding ops hooks for memset and memcpy to let driver have their own implementation?
Hi Peng,
The trick is to use the ioremap_wc() variant instead of ioremap() in your platform driver while mapping the TCMs. I know multiple folks have run into this issue. This is what most of the remoteproc drivers use, and mmio-sram driver also uses the same.
regards
Suman
Quoted 161 lines
Subject: Re: [PATCH 1/2] remoteproc: drop memset when loading elf segments
Quoted 31 lines · Peng Fan
Quoted 31 lines
Subject: Re: [PATCH 1/2] remoteproc: drop memset when loading elf segments
Quoted 25 lines · Peng Fan
Hi Bjorn,
Quoted 22 lines
Subject: Re: [PATCH 1/2] remoteproc: drop memset when loading elf segments
Quoted 8 lines · Peng Fan
To arm64, "dc zva, dst" is used in memset.
Per ARM DDI 0487A.j, chapter C5.3.8 DC ZVA, Data Cache Zero by VA,"If the memory region being zeroed is any type of Device memory, this instruction can give an alignment fault which is prioritized in the same way as other alignment faults that are determined by the memory type."
Quoted 5 lines
On i.MX platforms, when elf is loaded to onchip TCM area, the region is ioremapped, so "dc zva, dst" will trigger abort.
Since memset is not strictly required, let's drop it.
This would imply that we trust that the firmware doesn't expect remoteproc to zero out the memory, which we've always done. So I don't think we can say that it's not required.
Quoted 16 lines
Quoted 5 lines
Quoted 2 lines
Saying an image runs on a remote core needs Linux to help zero out BSS section, this not make sense to me.
Maybe not, but it has always done it, so if there's firmware out there that depends on it such change would break them..
Got it.
Quoted 8 lines
Quoted 5 lines
My case is as following, I need to load section 7 data. I no need to let remoteproc to memset section 8/9/10/11/12, the firmware itself could handle that. Just because the memsz is larger than filesz, remoreproc must memset?
By having a
PT_LOADsegment covering these I think it's reasonable to assume that the ELF loader should be able to touch the associatedmemory.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Section Headers:
[Nr] Name Type Addr OffSize
Quoted 4 lines
Quoted 4 lines
ES Flg Lk Inf Al
Quoted 1 line
[ 0] NULL 00000000 000000000000 00 0 0 0
Quoted 1 line
[ 1] .interrupts PROGBITS 1ffe0000 010000 00024000
Quoted 2 lines
Quoted 2 lines
A 0 0 4
Quoted 1 line
[ 2] .resource_table PROGBITS 1ffe0240 010240 00005800
Quoted 2 lines
Quoted 2 lines
A 0 0 1
Quoted 1 line
[ 3] .text PROGBITS
1ffe02a00102a0009ccc 00
Quoted 2 lines
Quoted 2 lines
AX 0 0 16
Quoted 1 line
[ 4] .ARM
ARM_EXIDX1ffe9f6c019f6c000008
Quoted 2 lines
Quoted 2 lines
00 AL 3 0 4
Quoted 1 line
[ 5] .init_array INIT_ARRAY 1ffe9f74 019f74 00000404
Quoted 2 lines
Quoted 2 lines
WA 0 0 4
Quoted 1 line
[ 6] .fini_array FINI_ARRAY 1ffe9f78 019f78 00000404
Quoted 2 lines
Quoted 2 lines
WA 0 0 4
Quoted 1 line
[ 7] .data PROGBITS 1fff9240 029240000084
Quoted 2 lines
Quoted 2 lines
00 WA 0 0 4
Quoted 1 line
[ 8] .ncache.init PROGBITS 1fff92c4 0292c4 00000000
Quoted 2 lines
Quoted 2 lines
W 0 0 1
Quoted 1 line
[ 9] .ncache NOBITS
1fff92c40292c4000a80
Quoted 2 lines
Quoted 2 lines
00 WA 0 0 4
Quoted 1 line
[10] .bss NOBITS 1fff9d44 0292c401f5c0
Quoted 2 lines
Quoted 2 lines
00 WA 0 0 4
Quoted 1 line
[11] .heap NOBITS 20019304 0292c4000404
Quoted 2 lines
Quoted 2 lines
00 WA 0 0 1
Quoted 1 line
[12] .stack NOBITS 20019708 0292c4000400
Quoted 16 lines
Quoted 16 lines
00 WA 0 0 1
Quoted 15 lines
Quoted 15 lines
Quoted 13 lines
Signed-off-by Peng Fan <[email protected]>--- drivers/remoteproc/remoteproc_elf_loader.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/remoteproc/remoteproc_elf_loader.c +0
-0drivers/remoteproc/remoteproc_elf_loader.c int rproc_elf_load_segments(struct rproc · line 238
Quoted 1 line
drivers/remoteproc/remoteproc_elf_loader.c +0
-0@@ -238,14 +238,11 @@ int rproc_elf_load_segments(struct rproc *rproc,const struct firmware *fw)
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/remoteproc/remoteproc_elf_loader.c int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw)
Quoted 7 lines
drivers/remoteproc/remoteproc_elf_loader.c +1
-1memcpy (ptr, elf_data + offset, filesz);/* -* Zero out remaining memory for this segment. +* No need zero out remaining memory for this segment. * * This isn't strictly required since dma_alloc_coherent already
Quoted 32 lines
Quoted 32 lines
Quoted 9 lines
Quoted 6 lines
drivers/remoteproc/remoteproc_elf_loader.c int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw) · line 244
Quoted 3 lines
drivers/remoteproc/remoteproc_elf_loader.c +1
-2-* did this for us. albeit harmless, we may consider removing -* this. +* did this for us. In the case of recovery this comment is wrong, we do not
dma_alloc_coherent()the carveout during a recovery.Isn't the it the firmware's job to memset the region?
I'm not aware of this being a documented requirement, we've always done it here for them, so removing this call would be a change in behavior.
Quoted 10 lines
Quoted 8 lines
And in your case you ioremapped existing TCM, so it's never true.
drivers/remoteproc/remoteproc_elf_loader.c int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw) · line 248
Quoted 3 lines
drivers/remoteproc/remoteproc_elf_loader.c +0
-2*/ -if (memsz > filesz) -memset (ptr + filesz,0 , memsz - filesz);So I think you do want to zero out this region. Question is how we do it...
I have contacted our M4 owners, we no need clear it from Linux side.
And I think _most_ firmware out there, like yours, does clear BSS etc during initialization.
Quoted 4 lines
We also support booting m4 before booting Linux, at that case, Linux has noting to do with memset. It is just I try loading m4 image with Linux, and met the issue that memset trigger abort.
Quoted 6 lines
Quoted 3 lines
Please see the proposal for attaching to already running remoteproc's from Mathieu. I don't expect that you want to load your PROGBITS either in this case?
No need to load for early boot case. It is just userspace load trigger kernel panic, because memset arm64 could not work for ioremapped
memory.
Quoted 3 lines
How about adding ops hooks for memset and memcpy to let driver have their own implementation?
Quoted 6 lines
Hi Peng,
The trick is to use the
ioremap_wc()variant instead ofioremap()in your platform driver while mapping the TCMs. I know multiple folks have run into this issue. This is what most of the remoteproc drivers use, and mmio-sram driver also uses the same.
TCM is different from OCRAM in i.MX chips. ioremap_wc not work for TCM memory, I just tried that.
I am thinking we change memset/memcpy to use memset_io/memcpy_fromio/memcpy_toio for remoteproc common code,
Thanks,
Peng.
Quoted 3 lines
regards
Suman
Quoted 163 lines · Peng Fan
Quoted 163 lines
Subject: Re: [PATCH 1/2] remoteproc: drop memset when loading elf segments
Quoted 31 lines · Peng Fan
Quoted 31 lines
Subject: Re: [PATCH 1/2] remoteproc: drop memset when loading elf segments
Quoted 25 lines · Peng Fan
Hi Bjorn,
Quoted 22 lines
Subject: Re: [PATCH 1/2] remoteproc: drop memset when loading elf segments
Quoted 8 lines · Peng Fan
To arm64, "dc zva, dst" is used in memset.
Per ARM DDI 0487A.j, chapter C5.3.8 DC ZVA, Data Cache Zero by VA,"If the memory region being zeroed is any type of Device memory, this instruction can give an alignment fault which is prioritized in the same way as other alignment faults that are determined by the memory type."
Quoted 5 lines
On i.MX platforms, when elf is loaded to onchip TCM area, the region is ioremapped, so "dc zva, dst" will trigger abort.
Since memset is not strictly required, let's drop it.
This would imply that we trust that the firmware doesn't expect remoteproc to zero out the memory, which we've always done. So I don't think we can say that it's not required.
Quoted 16 lines
Quoted 5 lines
Quoted 2 lines
Saying an image runs on a remote core needs Linux to help zero out BSS section, this not make sense to me.
Maybe not, but it has always done it, so if there's firmware out there that depends on it such change would break them..
Got it.
Quoted 8 lines
Quoted 5 lines
My case is as following, I need to load section 7 data. I no need to let remoteproc to memset section 8/9/10/11/12, the firmware itself could handle that. Just because the memsz is larger than filesz, remoreproc must memset?
By having a
PT_LOADsegment covering these I think it's reasonable to assume that the ELF loader should be able to touch the associatedmemory.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Section Headers:
[Nr] Name Type Addr OffSize
Quoted 4 lines
Quoted 4 lines
ES Flg Lk Inf Al
Quoted 1 line
[ 0] NULL 00000000 000000000000 00 0 0 0
Quoted 1 line
[ 1] .interrupts PROGBITS 1ffe0000 010000 00024000
Quoted 2 lines
Quoted 2 lines
A 0 0 4
Quoted 1 line
[ 2] .resource_table PROGBITS 1ffe0240 010240 00005800
Quoted 2 lines
Quoted 2 lines
A 0 0 1
Quoted 1 line
[ 3] .text PROGBITS
1ffe02a00102a0009ccc 00
Quoted 2 lines
Quoted 2 lines
AX 0 0 16
Quoted 1 line
[ 4] .ARM
ARM_EXIDX1ffe9f6c019f6c000008
Quoted 2 lines
Quoted 2 lines
00 AL 3 0 4
Quoted 1 line
[ 5] .init_array INIT_ARRAY 1ffe9f74 019f74 00000404
Quoted 2 lines
Quoted 2 lines
WA 0 0 4
Quoted 1 line
[ 6] .fini_array FINI_ARRAY 1ffe9f78 019f78 00000404
Quoted 2 lines
Quoted 2 lines
WA 0 0 4
Quoted 1 line
[ 7] .data PROGBITS 1fff9240 029240000084
Quoted 2 lines
Quoted 2 lines
00 WA 0 0 4
Quoted 1 line
[ 8] .ncache.init PROGBITS 1fff92c4 0292c4 00000000
Quoted 2 lines
Quoted 2 lines
W 0 0 1
Quoted 1 line
[ 9] .ncache NOBITS
1fff92c40292c4000a80
Quoted 2 lines
Quoted 2 lines
00 WA 0 0 4
Quoted 1 line
[10] .bss NOBITS 1fff9d44 0292c401f5c0
Quoted 2 lines
Quoted 2 lines
00 WA 0 0 4
Quoted 1 line
[11] .heap NOBITS 20019304 0292c4000404
Quoted 2 lines
Quoted 2 lines
00 WA 0 0 1
Quoted 1 line
[12] .stack NOBITS 20019708 0292c4000400
Quoted 16 lines
Quoted 16 lines
00 WA 0 0 1
Quoted 15 lines
Quoted 15 lines
Quoted 13 lines
Signed-off-by Peng Fan <[email protected]>--- drivers/remoteproc/remoteproc_elf_loader.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/remoteproc/remoteproc_elf_loader.c +0
-0drivers/remoteproc/remoteproc_elf_loader.c int rproc_elf_load_segments(struct rproc · line 238
Quoted 1 line
drivers/remoteproc/remoteproc_elf_loader.c +0
-0@@ -238,14 +238,11 @@ int rproc_elf_load_segments(struct rproc *rproc,const struct firmware *fw)
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/remoteproc/remoteproc_elf_loader.c int rproc_elf_load_segments(struct rproc · line 244
Quoted 7 lines
drivers/remoteproc/remoteproc_elf_loader.c +1
-1memcpy (ptr, elf_data + offset, filesz);/* -* Zero out remaining memory for this segment. +* No need zero out remaining memory for this segment. * * This isn't strictly required since dma_alloc_coherent already
Quoted 32 lines
Quoted 32 lines
Quoted 9 lines
Quoted 6 lines
drivers/remoteproc/remoteproc_elf_loader.c int rproc_elf_load_segments(struct rproc · line 245
Quoted 3 lines
drivers/remoteproc/remoteproc_elf_loader.c +1
-2-* did this for us. albeit harmless, we may consider removing -* this. +* did this for us. In the case of recovery this comment is wrong, we do not
dma_alloc_coherent()the carveout during a recovery.Isn't the it the firmware's job to memset the region?
I'm not aware of this being a documented requirement, we've always done it here for them, so removing this call would be a change in behavior.
Quoted 10 lines
Quoted 8 lines
And in your case you ioremapped existing TCM, so it's never true.
drivers/remoteproc/remoteproc_elf_loader.c int rproc_elf_load_segments(struct rproc · line 249
Quoted 3 lines
drivers/remoteproc/remoteproc_elf_loader.c +0
-2*/ -if (memsz > filesz) -memset (ptr + filesz,0 , memsz - filesz);So I think you do want to zero out this region. Question is how we do it...
I have contacted our M4 owners, we no need clear it from Linux side.
And I think _most_ firmware out there, like yours, does clear BSS etc during initialization.
Quoted 4 lines
We also support booting m4 before booting Linux, at that case, Linux has noting to do with memset. It is just I try loading m4 image with Linux, and met the issue that memset trigger abort.
Quoted 6 lines
Quoted 3 lines
Please see the proposal for attaching to already running remoteproc's from Mathieu. I don't expect that you want to load your PROGBITS either in this case?
No need to load for early boot case. It is just userspace load trigger kernel panic, because memset arm64 could not work for ioremapped
memory.
Quoted 3 lines
How about adding ops hooks for memset and memcpy to let driver have their own implementation?
Hi Peng,
Quoted 7 lines
Quoted 4 lines
The trick is to use the
ioremap_wc()variant instead ofioremap()in your platform driver while mapping the TCMs. I know multiple folks have run into this issue. This is what most of the remoteproc drivers use, and mmio-sram driver also uses the same.TCM is different from OCRAM in i.MX chips.
ioremap_wcnot work for TCM memory, I just tried that.
What ARM core is this? Is it a standard ARM TCM memory? The TCM interfaces from standard ARM cores in general are treated as normal memory, so write combine should be ok on them. When you say it doesn't work, whats not working - the memcpy/memset or the remoteproc doesn't boot?
Quoted 2 lines
I am thinking we change memset/memcpy to use memset_io/memcpy_fromio/memcpy_toio for remoteproc common code,
This has other implications. Not everything is IO memory to make this change in the common core.
If this is a custom memory interface requiring specific handling, then one option is to provide and use your own ops->load function within the driver. This is what I do for one of our remoteprocs that requires a specific memcpy handling semantics.
regards
Suman
Quoted 16 lines · ----- On 21 Apr, 2020, at 20:25, s-anna [email protected] wrote:
Quoted 10 lines
Quoted 7 lines
Hi Peng,
The trick is to use the
ioremap_wc()variant instead ofioremap()in your platform driver while mapping the TCMs. I know multiple folks have run into this issue. This is what most of the remoteproc drivers use, and mmio-sram driver also uses the same.TCM is different from OCRAM in i.MX chips.
ioremap_wcnot work for TCM memory, I just tried that.What ARM core is this? Is it a standard ARM TCM memory? The TCM interfaces from standard ARM cores in general are treated as normal memory, so write combine should be ok on them. When you say it doesn't work, whats not working - the memcpy/memset or the remoteproc doesn't boot?
Quoted 5 lines
Quoted 2 lines
I am thinking we change memset/memcpy to use memset_io/memcpy_fromio/memcpy_toio for remoteproc common code,
This has other implications. Not everything is IO memory to make this change in the common core.
Hi Suman,
AFAIK, most (if not all) the drivers are using ioremap to expose the remoteproc memories. Since these are IO memories, then care should be taken when writing/reading from them and memset_io/memcpy_fromio /memcpy_toio should be used (or ioread/write). Currently, this is not the case in the remoteproc driver and it works because everything is aligned and there is no misaligned access. IMHO, as suggested by Peng, remoteproc core should use such accessors.
We (at Kalray) have some modifications to do that since there were some misalignment after modifying the resource table (64 bits fields).
The only drawback that I can see using io memcpy is potentially a loss of performance for processors not requiring any alignement check. But other than that, it seems safer for everyon and performance in init does not seems really critical.
Quoted 5 lines
If this is a custom memory interface requiring specific handling, then one option is to provide and use your own
ops->loadfunction within the driver. This is what I do for one of our remoteprocs that requires a specific memcpy handling semantics.
This does not only apply to firmware loading. This applies to all the resource table accesses which are currently done using direct accesses to members. They should also used io memcpy.
Regards,
Clément
Quoted 3 lines
regards
Suman