media: mtk-vpu: Ensure alignment of 8 for DTCM buffer
Subsystems (2)
PATCH v4 1/1 media: mtk-vpu: Ensure alignment of 8 for DTCM buffer
From: Alexandre Courbot <[email protected]>
When running memcpy_toio:memcpy_toio(send_obj->share_buf, buf, len);
it was found that errors appear if len is not a multiple of 8:
[58.350841] mtk-mdp 14001000.rdma: processing failed: -22
This patch ensures the copy of a multiple of 8 size by calling round_up(len, 8) when copying
---
changes since v3:
1. multile -> multiple
2. add inline doc
changes since v2:
1. do the extra copy only if len is not multiple of 8
changes since v1:
1. change sign-off-by tags
2. change values to memset
drivers/media/platform/mtk-vpu/mtk_vpu.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/media/platform/mtk-vpu/mtk_vpu.c +14 -1
@@ -349,7 +349,20 @@ int vpu_ipi_send(struct platform_device *pdev, } }while (vpu_cfg_readl (vpu,HOST_TO_VPU )); -memcpy_toio (send_obj->share_buf, buf, len); +/* +* when copying data to the vpu hardware, the memcpy_toio operation must copy +* a multiple of 8. Otherwise the processing fails +*/ +if (len %8 !=0 ) { +unsigned char data[SHARE_BUF_SIZE ]; + +memset (data + len,0 ,sizeof (data) - len); +memcpy (data, buf, len); +memcpy_toio (send_obj->share_buf, data,round_up (len,8 )); + }else { +memcpy_toio (send_obj->share_buf, buf, len); + } +writel (len, &send_obj->len);writel (id, &send_obj->id);
Signature · 7 lines
2.17.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Quoted 7 lines · Dafna Hirschfeld
From: Alexandre Courbot <[email protected]>
When running
memcpy_toio:memcpy_toio(send_obj->share_buf, buf, len);
it was found that errors appear if len is not a multiple of 8:[58.350841] mtk-mdp 14001000.rdma: processing failed: -22
Why do errors appear? Is that due to a HW bug? Some other reason?
Quoted 29 lines
This patch ensures the copy of a multiple of 8 size by calling
round_up(len, 8)when copyingFixes e6599adfad30 ("media: mtk-vpu: avoid unaligned access to DTCM buffer.")Signed-off-by Alexandre Courbot <[email protected]>Signed-off-by Enric Balletbo i Serra <[email protected]>Signed-off-by Dafna Hirschfeld <[email protected]>Reviewed-by Houlong Wei <[email protected]>---
changes since v3:
1. multile -> multiple
2. add inline docchanges since v2:
1. do the extra copy only if len is not multiple of 8changes since v1:
1. change sign-off-by tags
2. change values to memsetdrivers/media/platform/mtk-vpu/mtk_vpu.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)drivers/media/platform/mtk-vpu/mtk_vpu.c +0
-0
drivers/media/platform/mtk-vpu/mtk_vpu.c int vpu_ipi_send(struct platform_device *pdev, · line 354
Quoted 7 lines
drivers/media/platform/mtk-vpu/mtk_vpu.c +3
-1@@ -349,7 +349,20 @@ int vpu_ipi_send(struct platform_device *pdev, } }while (vpu_cfg_readl (vpu,HOST_TO_VPU )); -memcpy_toio (send_obj->share_buf, buf, len); +/* +* when copying data to the vpu hardware, the memcpy_toio operation must copy +* a multiple of 8. Otherwise the processing fails
Same here: it needs to explain why the processing fails.
drivers/media/platform/mtk-vpu/mtk_vpu.c int vpu_ipi_send(struct platform_device *pdev, · line 357
Quoted 3 lines
drivers/media/platform/mtk-vpu/mtk_vpu.c +3
-0+*/ +if (len %8 !=0 ) { +unsigned char data[SHARE_BUF_SIZE ];
Wouldn't it be more robust if you say:
unsigned char data[sizeof(send_obj->share_buf)];
I also think that the SHARE_BUF_SIZE define needs a comment stating that it must be a multiple of 8, otherwise unexpected things can happen.
You also noticed that the current SHARE_BUF_SIZE define is too low, but I saw no patch correcting this. Shouldn't that be fixed as well?
Regards,
Hans
Quoted 12 lines
drivers/media/platform/mtk-vpu/mtk_vpu.c +8
-0+ +memset (data + len,0 ,sizeof (data) - len); +memcpy (data, buf, len); +memcpy_toio (send_obj->share_buf, data,round_up (len,8 )); + }else { +memcpy_toio (send_obj->share_buf, buf, len); + } +writel (len, &send_obj->len);writel (id, &send_obj->id);
Hi Hans!
Quoted 11 lines · Hans Verkuil
Quoted 7 lines · Dafna Hirschfeld
From: Alexandre Courbot <[email protected]>
When running
memcpy_toio:memcpy_toio(send_obj->share_buf, buf, len);
it was found that errors appear if len is not a multiple of 8:[58.350841] mtk-mdp 14001000.rdma: processing failed: -22Why do errors appear? Is that due to a HW bug? Some other reason?
MTK folks would be the best placed to answer this, but since the failure is reported by the firmware I'd suspect either a firmware or hardware limitation.
Quoted 40 lines
Quoted 30 lines
This patch ensures the copy of a multiple of 8 size by calling
round_up(len, 8)when copyingFixes e6599adfad30 ("media: mtk-vpu: avoid unaligned access to DTCM buffer.")Signed-off-by Alexandre Courbot <[email protected]>Signed-off-by Enric Balletbo i Serra <[email protected]>Signed-off-by Dafna Hirschfeld <[email protected]>Reviewed-by Houlong Wei <[email protected]>---
changes since v3:
1. multile -> multiple
2. add inline docchanges since v2:
1. do the extra copy only if len is not multiple of 8changes since v1:
1. change sign-off-by tags
2. change values to memsetdrivers/media/platform/mtk-vpu/mtk_vpu.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)drivers/media/platform/mtk-vpu/mtk_vpu.c +0
-0drivers/media/platform/mtk-vpu/mtk_vpu.c int vpu_ipi_send(struct platform_device *pdev, · line 354
Quoted 7 lines
drivers/media/platform/mtk-vpu/mtk_vpu.c +3
-1@@ -349,7 +349,20 @@ int vpu_ipi_send(struct platform_device *pdev, } }while (vpu_cfg_readl (vpu,HOST_TO_VPU )); -memcpy_toio (send_obj->share_buf, buf, len); +/* +* when copying data to the vpu hardware, the memcpy_toio operation must copy +* a multiple of 8. Otherwise the processing fails Same here: it needs to explain why the processing fails.
Quoted 7 lines
drivers/media/platform/mtk-vpu/mtk_vpu.c int vpu_ipi_send(struct platform_device *pdev, · line 357
Quoted 3 lines
drivers/media/platform/mtk-vpu/mtk_vpu.c +3
-0+*/ +if (len %8 !=0 ) { +unsigned char data[SHARE_BUF_SIZE ];Wouldn't it be more robust if you say:
unsigned char data[sizeof(send_obj->share_buf)];
Definitely yes.
Quoted 6 lines
I also think that the
SHARE_BUF_SIZEdefine needs a comment stating that it must be a multiple of 8, otherwise unexpected things can happen.You also noticed that the current
SHARE_BUF_SIZEdefine is too low, but I saw no patch correcting this. Shouldn't that be fixed as well?
AFAICT the firmware expects this exact size on its end, so I don't believe it can be changed that easily. But maybe someone from MTK can prove me wrong.
Cheers,
Alex.
Quoted 11 lines · Alexandre Courbot
Hi Hans!
Quoted 8 lines · Hans Verkuil
Quoted 6 lines · Dafna Hirschfeld
From: Alexandre Courbot <[email protected]>
When running
memcpy_toio:memcpy_toio(send_obj->share_buf, buf, len);
it was found that errors appear if len is not a multiple of 8:
Quoted 47 lines
Quoted 3 lines
Quoted 1 line
[58.350841] mtk-mdp 14001000.rdma: processing failed: -22Why do errors appear? Is that due to a HW bug? Some other reason?
MTK folks would be the best placed to answer this, but since the failure is reported by the firmware I'd suspect either a firmware or hardware limitation.
Quoted 39 lines
Quoted 30 lines
This patch ensures the copy of a multiple of 8 size by calling
round_up(len, 8)when copyingFixes e6599adfad30 ("media: mtk-vpu: avoid unaligned access to DTCM buffer.")Signed-off-by Alexandre Courbot <[email protected]>Signed-off-by Enric Balletbo i Serra <[email protected]>Signed-off-by Dafna Hirschfeld <[email protected]>Reviewed-by Houlong Wei <[email protected]>---
changes since v3:
1. multile -> multiple
2. add inline docchanges since v2:
1. do the extra copy only if len is not multiple of 8changes since v1:
1. change sign-off-by tags
2. change values to memsetdrivers/media/platform/mtk-vpu/mtk_vpu.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)drivers/media/platform/mtk-vpu/mtk_vpu.c +0
-0drivers/media/platform/mtk-vpu/mtk_vpu.c int vpu_ipi_send(struct platform_device *pdev, · line 354
Quoted 7 lines
drivers/media/platform/mtk-vpu/mtk_vpu.c +3
-1@@ -349,7 +349,20 @@ int vpu_ipi_send(struct platform_device *pdev, } }while (vpu_cfg_readl (vpu,HOST_TO_VPU )); -memcpy_toio (send_obj->share_buf, buf, len); +/* +* when copying data to the vpu hardware, the memcpy_toio operation must copy +* a multiple of 8. Otherwise the processing fails Same here: it needs to explain why the processing fails.
Is writing 'due to hardware or firmware limitation' enough?
If not, then we should wait for mediatek people's response to explain if they know more
Quoted 10 lines
Quoted 8 lines
drivers/media/platform/mtk-vpu/mtk_vpu.c int vpu_ipi_send(struct platform_device *pdev, · line 357
Quoted 4 lines
drivers/media/platform/mtk-vpu/mtk_vpu.c +3
-0+*/ +if (len %8 !=0 ) { +unsigned char data[SHARE_BUF_SIZE ];Wouldn't it be more robust if you say:
unsigned char data[sizeof(send_obj->share_buf)];Definitely yes.
I'll send v5 fixing this
Quoted 5 lines
Quoted 5 lines
I also think that the
SHARE_BUF_SIZEdefine needs a comment stating that it must be a multiple of 8, otherwise unexpected things can happen.
Quoted 7 lines
Quoted 2 lines
You also noticed that the current
SHARE_BUF_SIZEdefine is too low, but I saw no patch correcting this. Shouldn't that be fixed as well?AFAICT the firmware expects this exact size on its end, so I don't believe it can be changed that easily. But maybe someone from MTK can prove me wrong.
I looked further and noted that the structs that are larger than 'SHARE_BUF_SIZE' (venc_ap_ipi_msg_enc_ext venc_ap_ipi_msg_set_param_ext)
are used by drivers that don't use this vpu api, so actually SHARE_BUF_SIZE is not too low and as Corurbot worte probably not changeable.
Thanks,
Dafna
Quoted 3 lines
Cheers,
Alex.
Add mtk-vpu driver expert irui.wang in the loop.
Quoted 116 lines · Dafna Hirschfeld
Quoted 12 lines · Alexandre Courbot
Hi Hans!
Quoted 8 lines · Hans Verkuil
Quoted 6 lines · Dafna Hirschfeld
From: Alexandre Courbot <[email protected]>
When running
memcpy_toio:memcpy_toio(send_obj->share_buf, buf, len);
it was found that errors appear if len is not a multiple of 8:Quoted 54 lines
Quoted 3 lines
Quoted 1 line
[58.350841] mtk-mdp 14001000.rdma: processing failed: -22Why do errors appear? Is that due to a HW bug? Some other reason?
MTK folks would be the best placed to answer this, but since the failure is reported by the firmware I'd suspect either a firmware or
hardware limitation.Quoted 45 lines
Quoted 41 lines
This patch ensures the copy of a multiple of 8 size by calling
round_up(len, 8)when copyingFixes e6599adfad30 ("media: mtk-vpu: avoid unaligned access toDTCM buffer.")
Signed-off-by Alexandre Courbot <[email protected]>Signed-off-by Enric Balletbo i Serra <Signed-off-by Dafna Hirschfeld <[email protected]Quoted 1 line
Reviewed-by Houlong Wei <[email protected]>---
changes since v3:
1. multile -> multiple
2. add inline docchanges since v2:
1. do the extra copy only if len is not multiple of 8changes since v1:
1. change sign-off-by tags
2. change values to memsetdrivers/media/platform/mtk-vpu/mtk_vpu.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)drivers/media/platform/mtk-vpu/mtk_vpu.c +2
-1@@ -349,7 +349,20 @@ int vpu_ipi_send(struct platform_device *pdev, } }while (vpu_cfg_readl (vpu,HOST_TO_VPU )); -memcpy_toio (send_obj->share_buf, buf, len); +/* +* when copying data to the vpu hardware, the memcpy_toio Quoted 2 lines
operation must copy
+ * a multiple of 8. Otherwise the processing failsSame here: it needs to explain why the processing fails.
Is writing 'due to hardware or firmware limitation' enough? If not, then we should wait for mediatek people's response to explain if they know more
Quoted 10 lines
Quoted 8 lines
drivers/media/platform/mtk-vpu/mtk_vpu.c int vpu_ipi_send(struct platform_device *pdev, · line 357
Quoted 4 lines
drivers/media/platform/mtk-vpu/mtk_vpu.c +3
-0+*/ +if (len %8 !=0 ) { +unsigned char data[SHARE_BUF_SIZE ];Wouldn't it be more robust if you say:
unsigned char data[sizeof(send_obj->share_buf)];Definitely yes.
I'll send v5 fixing this
Quoted 6 lines
Quoted 6 lines
I also think that the
SHARE_BUF_SIZEdefine needs a comment stating that it must be a
multiple of 8, otherwise unexpected things can happen.Quoted 9 lines
Quoted 3 lines
You also noticed that the current
SHARE_BUF_SIZEdefine is too low, but I saw
no patch correcting this. Shouldn't that be fixed as well?AFAICT the firmware expects this exact size on its end, so I don't believe it can be changed that easily. But maybe someone from MTK can
prove me wrong.I looked further and noted that the structs that are larger than '
SHARE_BUF_SIZE'
(venc_ap_ipi_msg_enc_extvenc_ap_ipi_msg_set_param_ext) are used by drivers that don't use this vpu api, so actuallySHARE_BUF_SIZEis
not too low and as Corurbot worte probably not changeable.Thanks,
DafnaQuoted 3 lines
Cheers,
Alex.
Hi,
The "len" of share_buf copied should be always 8 alignment; do you have other logs to prove the len is not 8 alignment when errors appear?
Quoted 1 line
Quoted 1 line
[58.350841] mtk-mdp 14001000.rdma: processing failed: -22
Quoted 132 lines · houlong wei
Add mtk-vpu driver expert irui.wang in the loop.
Quoted 127 lines · Dafna Hirschfeld
Quoted 15 lines · Alexandre Courbot
Hi Hans!
Quoted 11 lines · Hans Verkuil
Quoted 8 lines · Dafna Hirschfeld
From: Alexandre Courbot <[email protected]>
When running
memcpy_toio:memcpy_toio(send_obj->share_buf, buf, len);
it was found that errors appear if len is not a multiple of 8:[58.350841] mtk-mdp 14001000.rdma: processing failed: -22Quoted 59 lines
Quoted 2 lines
Why do errors appear? Is that due to a HW bug? Some other reason?
MTK folks would be the best placed to answer this, but since the failure is reported by the firmware I'd suspect either a firmware or
hardware limitation.Quoted 51 lines
Quoted 46 lines
This patch ensures the copy of a multiple of 8 size by calling
round_up(len, 8)when copyingFixes e6599adfad30 ("media: mtk-vpu: avoid unaligned accessto
DTCM buffer.")Signed-off-by Alexandre Courbot <[email protected]>Signed-off-by Enric Balletbo i Serra <[email protected]>
Signed-off-by: Dafna Hirschfeld <
[email protected]Quoted 1 line
Reviewed-by Houlong Wei <[email protected]>---
changes since v3:
1. multile -> multiple
2. add inline docchanges since v2:
1. do the extra copy only if len is not multiple of 8changes since v1:
1. change sign-off-by tags
2. change values to memsetdrivers/media/platform/mtk-vpu/mtk_vpu.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)drivers/media/platform/mtk-vpu/mtk_vpu.c +2
-1@@ -349,7 +349,20 @@ int vpu_ipi_send(struct platform_device *pdev, } }while (vpu_cfg_readl (vpu,HOST_TO_VPU )); -memcpy_toio (send_obj->share_buf, buf, len); +/* +* when copying data to the vpu hardware, the Quoted 3 lines
memcpy_toio
operation must copy
+ * a multiple of 8. Otherwise the processing failsSame here: it needs to explain why the processing fails.
Is writing 'due to hardware or firmware limitation' enough? If not, then we should wait for mediatek people's response to explain
if they know moreQuoted 11 lines
Quoted 9 lines
drivers/media/platform/mtk-vpu/mtk_vpu.c int vpu_ipi_send(struct platform_device *pdev, · line 357
Quoted 4 lines
drivers/media/platform/mtk-vpu/mtk_vpu.c +3
-0+*/ +if (len %8 !=0 ) { +unsigned char data[SHARE_BUF_SIZE ];Wouldn't it be more robust if you say:
unsigned char data[sizeof(send_obj-
Quoted 1 line
share_buf)];Definitely yes.
I'll send v5 fixing this
Quoted 10 lines
Quoted 9 lines
I also think that the
SHARE_BUF_SIZEdefine needs a comment stating that it must be a
multiple of 8, otherwise unexpected things can happen.You also noticed that the current
SHARE_BUF_SIZEdefine is too low, but I saw
no patch correcting this. Shouldn't that be fixed as well?Quoted 6 lines
AFAICT the firmware expects this exact size on its end, so I don't
believe it can be changed that easily. But maybe someone from MTK can
prove me wrong.I looked further and noted that the structs that are larger than '
SHARE_BUF_SIZE'
(venc_ap_ipi_msg_enc_extvenc_ap_ipi_msg_set_param_ext) are used by drivers that don't use this vpu api, so actuallySHARE_BUF_SIZEis
not too low and as Corurbot worte probably not changeable.Thanks,
DafnaQuoted 3 lines
Cheers,
Alex.
Quoted 5 lines · Irui Wang
Hi,
The "len" of
share_bufcopied should be always 8 alignment; do you have other logs to prove the len is not 8 alignment when errors appear?
Hi, I found out that "sizeof(mdp_ipi_comm) = 20"
this is due to the macro #pragma pack(push, 4) in mtk_mdp_ipi.h
see [1]
[1] http://lkml.iu.edu/hypermail/linux/kernel/2109.2/04978.html
Thanks,
Dafna
Quoted 135 lines
Quoted 1 line
Quoted 1 line
[58.350841] mtk-mdp 14001000.rdma: processing failed: -22Quoted 132 lines · houlong wei
Add mtk-vpu driver expert irui.wang in the loop.
Quoted 127 lines · Dafna Hirschfeld
Quoted 15 lines · Alexandre Courbot
Hi Hans!
Quoted 11 lines · Hans Verkuil
Quoted 8 lines · Dafna Hirschfeld
From: Alexandre Courbot <[email protected]>
When running
memcpy_toio:memcpy_toio(send_obj->share_buf, buf, len);
it was found that errors appear if len is not a multiple of 8:[58.350841] mtk-mdp 14001000.rdma: processing failed: -22Quoted 59 lines
Quoted 2 lines
Why do errors appear? Is that due to a HW bug? Some other reason?
MTK folks would be the best placed to answer this, but since the failure is reported by the firmware I'd suspect either a firmware or
hardware limitation.Quoted 51 lines
Quoted 46 lines
This patch ensures the copy of a multiple of 8 size by calling
round_up(len, 8)when copyingFixes e6599adfad30 ("media: mtk-vpu: avoid unaligned accessto
DTCM buffer.")Signed-off-by Alexandre Courbot <[email protected]>Signed-off-by Enric Balletbo i Serra <[email protected]>
Signed-off-by: Dafna Hirschfeld <
[email protected]Quoted 1 line
Reviewed-by Houlong Wei <[email protected]>---
changes since v3:
1. multile -> multiple
2. add inline docchanges since v2:
1. do the extra copy only if len is not multiple of 8changes since v1:
1. change sign-off-by tags
2. change values to memsetdrivers/media/platform/mtk-vpu/mtk_vpu.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)drivers/media/platform/mtk-vpu/mtk_vpu.c +2
-1@@ -349,7 +349,20 @@ int vpu_ipi_send(struct platform_device *pdev, } }while (vpu_cfg_readl (vpu,HOST_TO_VPU )); -memcpy_toio (send_obj->share_buf, buf, len); +/* +* when copying data to the vpu hardware, the Quoted 3 lines
memcpy_toio
operation must copy
+ * a multiple of 8. Otherwise the processing failsSame here: it needs to explain why the processing fails.
Is writing 'due to hardware or firmware limitation' enough? If not, then we should wait for mediatek people's response to explain
if they know moreQuoted 11 lines
Quoted 9 lines
drivers/media/platform/mtk-vpu/mtk_vpu.c int vpu_ipi_send(struct platform_device *pdev, · line 357
Quoted 4 lines
drivers/media/platform/mtk-vpu/mtk_vpu.c +3
-0+*/ +if (len %8 !=0 ) { +unsigned char data[SHARE_BUF_SIZE ];Wouldn't it be more robust if you say:
unsigned char data[sizeof(send_obj-
Quoted 1 line
share_buf)];Definitely yes.
I'll send v5 fixing this
Quoted 10 lines
Quoted 9 lines
I also think that the
SHARE_BUF_SIZEdefine needs a comment stating that it must be a
multiple of 8, otherwise unexpected things can happen.You also noticed that the current
SHARE_BUF_SIZEdefine is too low, but I saw
no patch correcting this. Shouldn't that be fixed as well?Quoted 6 lines
AFAICT the firmware expects this exact size on its end, so I don't
believe it can be changed that easily. But maybe someone from MTK can
prove me wrong.I looked further and noted that the structs that are larger than '
SHARE_BUF_SIZE'
(venc_ap_ipi_msg_enc_extvenc_ap_ipi_msg_set_param_ext) are used by drivers that don't use this vpu api, so actuallySHARE_BUF_SIZEis
not too low and as Corurbot worte probably not changeable.Thanks,
DafnaQuoted 3 lines
Cheers,
Alex.
Quoted 9 lines · Dafna Hirschfeld
Quoted 5 lines · Irui Wang
Hi,
The "len" of
share_bufcopied should be always 8 alignment; do you have other logs to prove the len is not 8 alignment when errors appear?
Quoted 7 lines
Hi, I found out that "
sizeof(mdp_ipi_comm)= 20"
this is due to the macro #pragmapack(push, 4)inmtk_mdp_ipi.hsee [1]
[1] http://lkml.iu.edu/hypermail/linux/kernel/2109.2/04978.html
Hi Irui Wang,
Any update regarding that patch?
Can you give more explanation for that errors that we see when the buffer size is not a multiple of 8?
Thanks,
Dafna
Quoted 138 lines
Thanks,
DafnaQuoted 135 lines
Quoted 1 line
Quoted 1 line
[58.350841] mtk-mdp 14001000.rdma: processing failed: -22Quoted 132 lines · houlong wei
Add mtk-vpu driver expert irui.wang in the loop.
Quoted 127 lines · Dafna Hirschfeld
Quoted 15 lines · Alexandre Courbot
Hi Hans!
Quoted 11 lines · Hans Verkuil
Quoted 8 lines · Dafna Hirschfeld
From: Alexandre Courbot <[email protected]>
When running
memcpy_toio:memcpy_toio(send_obj->share_buf, buf, len);
it was found that errors appear if len is not a multiple of 8:[58.350841] mtk-mdp 14001000.rdma: processing failed: -22Quoted 59 lines
Quoted 2 lines
Why do errors appear? Is that due to a HW bug? Some other reason?
MTK folks would be the best placed to answer this, but since the failure is reported by the firmware I'd suspect either a firmware or
hardware limitation.Quoted 51 lines
Quoted 46 lines
This patch ensures the copy of a multiple of 8 size by calling
round_up(len, 8)when copyingFixes e6599adfad30 ("media: mtk-vpu: avoid unaligned accessto
DTCM buffer.")Signed-off-by Alexandre Courbot <[email protected]>Signed-off-by Enric Balletbo i Serra <[email protected]>
Signed-off-by: Dafna Hirschfeld <
[email protected]Quoted 1 line
Reviewed-by Houlong Wei <[email protected]>---
changes since v3:
1. multile -> multiple
2. add inline docchanges since v2:
1. do the extra copy only if len is not multiple of 8changes since v1:
1. change sign-off-by tags
2. change values to memset
drivers/media/platform/mtk-vpu/mtk_vpu.c| 15
++++++++++++++-1 file changed, 14 insertions(+), 1 deletion(-)drivers/media/platform/mtk-vpu/mtk_vpu.c +2
-1@@ -349,7 +349,20 @@ int vpu_ipi_send(struct platform_device *pdev, } } while (vpu_cfg_readl(vpu, HOST_TO_VPU)); - memcpy_toio(send_obj->share_buf, buf, len); + /* +* when copying data to the vpu hardware, the Quoted 3 lines
memcpy_toio
operation must copy
+ * a multiple of 8. Otherwise the processing failsSame here: it needs to explain why the processing fails.
Is writing 'due to hardware or firmware limitation' enough? If not, then we should wait for mediatek people's response to explain
if they know moreQuoted 11 lines
Quoted 9 lines
Quoted 4 lines
+ */
+ if (len % 8 != 0) {
+ unsigned char data[SHARE_BUF_SIZE];Wouldn't it be more robust if you say:
unsigned char data[sizeof(send_obj-
Quoted 1 line
share_buf)];Definitely yes.
I'll send v5 fixing this
Quoted 10 lines
Quoted 9 lines
I also think that the
SHARE_BUF_SIZEdefine needs a comment stating that it must be a
multiple of 8, otherwise unexpected things can happen.You also noticed that the current
SHARE_BUF_SIZEdefine is too low, but I saw
no patch correcting this. Shouldn't that be fixed as well?Quoted 6 lines
AFAICT the firmware expects this exact size on its end, so I don't
believe it can be changed that easily. But maybe someone from MTK can
prove me wrong.I looked further and noted that the structs that are larger than '
SHARE_BUF_SIZE'
(venc_ap_ipi_msg_enc_extvenc_ap_ipi_msg_set_param_ext) are used by drivers that don't use this vpu api, so actuallySHARE_BUF_SIZEis
not too low and as Corurbot worte probably not changeable.Thanks,
DafnaQuoted 3 lines
Cheers,
Alex.
Hi, Dafna,
Thanks for the patch.
Quoted 20 lines · Dafna Hirschfeld
Quoted 10 lines · Dafna Hirschfeld
Quoted 6 lines · Irui Wang
Hi,
The "len" of
share_bufcopied should be always 8 alignment; do you have other logs to prove the len is not 8 alignment when errors
appear?Quoted 7 lines
Hi, I found out that "
sizeof(mdp_ipi_comm)= 20"
this is due to the macro #pragmapack(push, 4)inmtk_mdp_ipi.hsee [1]
[1] http://lkml.iu.edu/hypermail/linux/kernel/2109.2/04978.html
Quoted 7 lines
Hi Irui Wang,
Any update regarding that patch?
Can you give more explanation for that errors that we see when the buffer size is not a multiple of 8?Thanks,
Dafna
share_buf is a mapped memory by ioremap, it should be better use memcpy_to/fromio instead of memcpy because of alignment.
As for memcpy_toio, it may also have requirements for alignment, we can also get such information from:
https://elixir.bootlin.com/linux/v5.15/source/drivers/mtd/spi-nor/controllers/aspeed-smc.c#L207
.
So, it's not VPU HW bug or limitation, it's memcpy_toio requirements, maybe we can modify IPI message to do alignment, but it need modify both kernel and vpu firmware, which will break upstream backward compatible, we think it's unacceptale.
If this patch can solve the issue, we think it's OK.
Thanks
Quoted 154 lines
Quoted 154 lines
Thanks,
DafnaQuoted 150 lines
Quoted 1 line
Quoted 1 line
[58.350841] mtk-mdp 14001000.rdma: processing failed: -22Quoted 147 lines · houlong wei
Add mtk-vpu driver expert irui.wang in the loop.
Quoted 142 lines · Dafna Hirschfeld
Quoted 21 lines · Alexandre Courbot
Hi Hans!
Quoted 10 lines · Hans Verkuil
Quoted 8 lines · Dafna Hirschfeld
From: Alexandre Courbot <[email protected]>
When running
memcpy_toio:memcpy_toio(send_obj->share_buf, buf, len);
it was found that errors appear if len is not a
multiple of
8:Quoted 5 lines
Quoted 2 lines
[58.350841] mtk-mdp 14001000.rdma: processing failed:-22
Why do errors appear? Is that due to a HW bug? Some other reason?
Quoted 62 lines
MTK folks would be the best placed to answer this, but since the
failure is reported by the firmware I'd suspect either a firmware
or
hardware limitation.Quoted 55 lines
Quoted 49 lines
This patch ensures the copy of a multiple of 8 size by calling
round_up(len, 8)when copyingFixes e6599adfad30 ("media: mtk-vpu: avoid unalignedaccess
to
DTCM buffer.")Signed-off-by Alexandre Courbot <[email protected]Quoted 1 line
Signed-off-by: Enric Balletbo i Serra <
[email protected]>
Signed-off-by: Dafna Hirschfeld <
[email protected]Quoted 1 line
Reviewed-by Houlong Wei <[email protected]>---
changes since v3:
1. multile -> multiple
2. add inline docchanges since v2:
1. do the extra copy only if len is not multiple of 8changes since v1:
1. change sign-off-by tags
2. change values to memsetdrivers/media/platform/mtk-vpu/mtk_vpu.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)drivers/media/platform/mtk-vpu/mtk_vpu.c +0
-0@@ -349,7 +349,20 @@ int vpu_ipi_send(struct
platform_device
*pdev,} } while (vpu_cfg_readl(vpu, HOST_TO_VPU));drivers/media/platform/mtk-vpu/mtk_vpu.c +2
-1-memcpy_toio (send_obj->share_buf, buf, len); +/* +* when copying data to the vpu hardware, the Quoted 4 lines
memcpy_toio
operation must copy
+ * a multiple of 8. Otherwise the processing
failsSame here: it needs to explain why the processing fails.
Is writing 'due to hardware or firmware limitation' enough? If not, then we should wait for mediatek people's response to explain
if they know moreQuoted 11 lines
Quoted 9 lines
drivers/media/platform/mtk-vpu/mtk_vpu.c
Quoted 4 lines
drivers/media/platform/mtk-vpu/mtk_vpu.c +3
-0+*/ +if (len %8 !=0 ) { +unsigned char data[SHARE_BUF_SIZE ];Wouldn't it be more robust if you say:
unsigned char data[sizeof(send_obj-
Quoted 1 line
share_buf)];Definitely yes.
I'll send v5 fixing this
Quoted 13 lines
Quoted 7 lines
I also think that the
SHARE_BUF_SIZEdefine needs a comment
stating that it must be a
multiple of 8, otherwise unexpected things can happen.Quoted 5 lines
You also noticed that the current
SHARE_BUF_SIZEdefine is too
low, but I saw
no patch correcting this. Shouldn't that be fixed as well?Quoted 8 lines
AFAICT the firmware expects this exact size on its end, so I
don't
believe it can be changed that easily. But maybe someone from MTK
can
prove me wrong.I looked further and noted that the structs that are larger than
'SHARE_BUF_SIZE'
(venc_ap_ipi_msg_enc_extvenc_ap_ipi_msg_set_param_ext) are used by drivers that don't use this vpu api, so actuallySHARE_BUF_SIZEis
not too low and as Corurbot worte probably not changeable.Thanks,
DafnaQuoted 3 lines
Cheers,
Alex.
Quoted 41 lines · Irui Wang
Hi, Dafna,
Thanks for the patch.
Quoted 20 lines · Dafna Hirschfeld
Quoted 10 lines · Dafna Hirschfeld
Quoted 6 lines · Irui Wang
Hi,
The "len" of
share_bufcopied should be always 8 alignment; do you have other logs to prove the len is not 8 alignment when errors
appear?Quoted 7 lines
Hi, I found out that "
sizeof(mdp_ipi_comm)= 20"
this is due to the macro #pragmapack(push, 4)inmtk_mdp_ipi.hsee [1]
[1] http://lkml.iu.edu/hypermail/linux/kernel/2109.2/04978.html
Quoted 7 lines
Hi Irui Wang,
Any update regarding that patch?
Can you give more explanation for that errors that we see when the buffer size is not a multiple of 8?Thanks,
Dafna
share_bufis a mapped memory by ioremap, it should be better use memcpy_to/fromio instead of memcpy because of alignment.As for
memcpy_toio, it may also have requirements for alignment, we can also get such information from:https://elixir.bootlin.com/linux/v5.15/source/drivers/mtd/spi-nor/controllers/aspeed-smc.c#L207
.
Quoted 6 lines
So, it's not VPU HW bug or limitation, it's
memcpy_toiorequirements, maybe we can modify IPI message to do alignment, but it need modify both kernel and vpu firmware, which will break upstream backward compatible, we think it's unacceptale.If this patch can solve the issue, we think it's OK.
In such case shouldn't we also make sure that the address of send_obj->share_buf is 8 aligend before calling memcpy_toio, and also shouldn't we make the same checks for the memcpy_fromio ?
Thanks,
Dafna
Quoted 156 lines
Thanks
Quoted 154 lines
Quoted 154 lines
Thanks,
DafnaQuoted 150 lines
Quoted 1 line
Quoted 1 line
[58.350841] mtk-mdp 14001000.rdma: processing failed: -22Quoted 147 lines · houlong wei
Add mtk-vpu driver expert irui.wang in the loop.
Quoted 142 lines · Dafna Hirschfeld
Quoted 21 lines · Alexandre Courbot
Hi Hans!
Quoted 10 lines · Hans Verkuil
Quoted 8 lines · Dafna Hirschfeld
From: Alexandre Courbot <[email protected]>
When running
memcpy_toio:memcpy_toio(send_obj->share_buf, buf, len);
it was found that errors appear if len is not a
multiple of
8:Quoted 5 lines
Quoted 2 lines
[58.350841] mtk-mdp 14001000.rdma: processing failed:-22
Why do errors appear? Is that due to a HW bug? Some other reason?
Quoted 62 lines
MTK folks would be the best placed to answer this, but since the
failure is reported by the firmware I'd suspect either a firmware
or
hardware limitation.Quoted 55 lines
Quoted 49 lines
This patch ensures the copy of a multiple of 8 size by calling
round_up(len, 8)when copyingFixes e6599adfad30 ("media: mtk-vpu: avoid unalignedaccess
to
DTCM buffer.")Signed-off-by Alexandre Courbot <[email protected]Quoted 1 line
Signed-off-by: Enric Balletbo i Serra <
[email protected]>
Signed-off-by: Dafna Hirschfeld <
[email protected]Quoted 1 line
Reviewed-by Houlong Wei <[email protected]>---
changes since v3:
1. multile -> multiple
2. add inline docchanges since v2:
1. do the extra copy only if len is not multiple of 8changes since v1:
1. change sign-off-by tags
2. change values to memsetdrivers/media/platform/mtk-vpu/mtk_vpu.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)drivers/media/platform/mtk-vpu/mtk_vpu.c +0
-0@@ -349,7 +349,20 @@ int vpu_ipi_send(struct
platform_device
*pdev,} } while (vpu_cfg_readl(vpu, HOST_TO_VPU));drivers/media/platform/mtk-vpu/mtk_vpu.c +2
-1-memcpy_toio (send_obj->share_buf, buf, len); +/* +* when copying data to the vpu hardware, the Quoted 4 lines
memcpy_toio
operation must copy
+ * a multiple of 8. Otherwise the processing
failsSame here: it needs to explain why the processing fails.
Is writing 'due to hardware or firmware limitation' enough? If not, then we should wait for mediatek people's response to explain
if they know moreQuoted 11 lines
Quoted 9 lines
drivers/media/platform/mtk-vpu/mtk_vpu.c
Quoted 4 lines
drivers/media/platform/mtk-vpu/mtk_vpu.c +3
-0+*/ +if (len %8 !=0 ) { +unsigned char data[SHARE_BUF_SIZE ];Wouldn't it be more robust if you say:
unsigned char data[sizeof(send_obj-
Quoted 1 line
share_buf)];Definitely yes.
I'll send v5 fixing this
Quoted 13 lines
Quoted 7 lines
I also think that the
SHARE_BUF_SIZEdefine needs a comment
stating that it must be a
multiple of 8, otherwise unexpected things can happen.Quoted 5 lines
You also noticed that the current
SHARE_BUF_SIZEdefine is too
low, but I saw
no patch correcting this. Shouldn't that be fixed as well?Quoted 8 lines
AFAICT the firmware expects this exact size on its end, so I
don't
believe it can be changed that easily. But maybe someone from MTK
can
prove me wrong.I looked further and noted that the structs that are larger than
'SHARE_BUF_SIZE'
(venc_ap_ipi_msg_enc_extvenc_ap_ipi_msg_set_param_ext) are used by drivers that don't use this vpu api, so actuallySHARE_BUF_SIZEis
not too low and as Corurbot worte probably not changeable.Thanks,
DafnaQuoted 3 lines
Cheers,
Alex.
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Quoted 63 lines · Alexandre Courbot
Hi Hans!
Quoted 11 lines · Hans Verkuil
Quoted 7 lines · Dafna Hirschfeld
From: Alexandre Courbot <[email protected]>
When running
memcpy_toio:memcpy_toio(send_obj->share_buf, buf, len);
it was found that errors appear if len is not a multiple of 8:[58.350841] mtk-mdp 14001000.rdma: processing failed: -22Why do errors appear? Is that due to a HW bug? Some other reason?
MTK folks would be the best placed to answer this, but since the failure is reported by the firmware I'd suspect either a firmware or hardware limitation.
Quoted 44 lines
Quoted 30 lines
This patch ensures the copy of a multiple of 8 size by calling
round_up(len, 8)when copyingFixes e6599adfad30 ("media: mtk-vpu: avoid unaligned access to DTCM buffer.")Signed-off-by Alexandre Courbot <[email protected]>Signed-off-by Enric Balletbo i Serra <[email protected]>Signed-off-by Dafna Hirschfeld <[email protected]>Reviewed-by Houlong Wei <[email protected]>---
changes since v3:
1. multile -> multiple
2. add inline docchanges since v2:
1. do the extra copy only if len is not multiple of 8changes since v1:
1. change sign-off-by tags
2. change values to memsetdrivers/media/platform/mtk-vpu/mtk_vpu.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)drivers/media/platform/mtk-vpu/mtk_vpu.c +0
-0drivers/media/platform/mtk-vpu/mtk_vpu.c int vpu_ipi_send(struct platform_device *pdev, · line 354
Quoted 7 lines
drivers/media/platform/mtk-vpu/mtk_vpu.c +3
-1@@ -349,7 +349,20 @@ int vpu_ipi_send(struct platform_device *pdev, } }while (vpu_cfg_readl (vpu,HOST_TO_VPU )); -memcpy_toio (send_obj->share_buf, buf, len); +/* +* when copying data to the vpu hardware, the memcpy_toio operation must copy +* a multiple of 8. Otherwise the processing fails Same here: it needs to explain why the processing fails.
Quoted 3 lines
drivers/media/platform/mtk-vpu/mtk_vpu.c +3
-0+*/ +if (len %8 !=0 ) { +unsigned char data[SHARE_BUF_SIZE ];
Quoted 5 lines
Quoted 3 lines
Wouldn't it be more robust if you say:
unsigned char data[sizeof(send_obj->share_buf)];Definitely yes.
won't it actually be better to implement it like this:
(assuming len is always multiply of 4 - which I think it must be since access must be 4 aligned)
void __iomem *to = obj->share_buf;
if (len % 8 != 0) {
memcpy_toio(to, buf, len - 4);
to += len - 4;
buf += len - 4;
writel_relaxed(*(u32 *)buf, to);
} else {
memcpy_toio(obj->share_buf, buf, len);
}Thanks,
Dafna
Quoted 8 lines
Quoted 7 lines
I also think that the
SHARE_BUF_SIZEdefine needs a comment stating that it must be a multiple of 8, otherwise unexpected things can happen.You also noticed that the current
SHARE_BUF_SIZEdefine is too low, but I saw no patch correcting this. Shouldn't that be fixed as well?
Quoted 7 lines
AFAICT the firmware expects this exact size on its end, so I don't believe it can be changed that easily. But maybe someone from MTK can prove me wrong.
Cheers,
Alex.
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Quoted 76 lines · Dafna Hirschfeld
Quoted 63 lines · Alexandre Courbot
Hi Hans!
Quoted 11 lines · Hans Verkuil
Quoted 7 lines · Dafna Hirschfeld
From: Alexandre Courbot <[email protected]>
When running
memcpy_toio:memcpy_toio(send_obj->share_buf, buf, len);
it was found that errors appear if len is not a multiple of 8:[58.350841] mtk-mdp 14001000.rdma: processing failed: -22Why do errors appear? Is that due to a HW bug? Some other reason?
MTK folks would be the best placed to answer this, but since the failure is reported by the firmware I'd suspect either a firmware or hardware limitation.
Quoted 44 lines
Quoted 30 lines
This patch ensures the copy of a multiple of 8 size by calling
round_up(len, 8)when copyingFixes e6599adfad30 ("media: mtk-vpu: avoid unaligned access to DTCM buffer.")Signed-off-by Alexandre Courbot <[email protected]>Signed-off-by Enric Balletbo i Serra <[email protected]>Signed-off-by Dafna Hirschfeld <[email protected]>Reviewed-by Houlong Wei <[email protected]>---
changes since v3:
1. multile -> multiple
2. add inline docchanges since v2:
1. do the extra copy only if len is not multiple of 8changes since v1:
1. change sign-off-by tags
2. change values to memsetdrivers/media/platform/mtk-vpu/mtk_vpu.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)drivers/media/platform/mtk-vpu/mtk_vpu.c +0
-0drivers/media/platform/mtk-vpu/mtk_vpu.c int vpu_ipi_send(struct platform_device *pdev, · line 354
Quoted 7 lines
drivers/media/platform/mtk-vpu/mtk_vpu.c +3
-1@@ -349,7 +349,20 @@ int vpu_ipi_send(struct platform_device *pdev, } }while (vpu_cfg_readl (vpu,HOST_TO_VPU )); -memcpy_toio (send_obj->share_buf, buf, len); +/* +* when copying data to the vpu hardware, the memcpy_toio operation must copy +* a multiple of 8. Otherwise the processing fails Same here: it needs to explain why the processing fails.
Quoted 3 lines
drivers/media/platform/mtk-vpu/mtk_vpu.c +3
-0+*/ +if (len %8 !=0 ) { +unsigned char data[SHARE_BUF_SIZE ];Quoted 5 lines
Quoted 3 lines
Wouldn't it be more robust if you say:
unsigned char data[sizeof(send_obj->share_buf)];Definitely yes.
won't it actually be better to implement it like this:
(assuming len is always multiply of 4 - which I think it must be since access must be 4 aligned)
Quoted 10 lines
void __iomem *to = obj->share_buf;
if (len % 8 != 0) {
memcpy_toio(to, buf, len - 4);
to += len - 4;
buf += len - 4;
writel_relaxed(*(u32 *)buf, to);
} else {
memcpy_toio(obj->share_buf, buf, len);
}Not sure if avoiding that stack allocation is worth the extra complexity and requirement for len being a multiple of 4. Also I'd like to test it on real hardware to confirm it is indeed ok.
Il 20/09/21 19:04, Dafna Hirschfeld ha scritto:
Quoted 8 lines
From: Alexandre Courbot <[email protected]>
When running
memcpy_toio:memcpy_toio(send_obj->share_buf, buf, len);
it was found that errors appear if len is not a multiple of 8:[58.350841] mtk-mdp 14001000.rdma: processing failed: -22
Quoted 8 lines
This patch ensures the copy of a multiple of 8 size by calling
round_up(len, 8)when copyingFixes e6599adfad30 ("media: mtk-vpu: avoid unaligned access to DTCM buffer.")Signed-off-by Alexandre Courbot <[email protected]>Signed-off-by Enric Balletbo i Serra <[email protected]>Signed-off-by Dafna Hirschfeld <[email protected]>Reviewed-by Houlong Wei <[email protected]>
I acknowledge that this patch is getting very old and stale, but after some testing on MT8173, we were able to verify that it is essential for MediaTek MDP functionality, along with some other patches.
Without this one, it won't work.
Keeping this in mind, I would propose to get this one picked before it gets completely stale and requiring a rewrite.
Cheers,
Angelo