usb: chipidea: udc: enforce write to the memory.
Subsystems (2)
PATCH 1/1 usb: chipidea: udc: enforce write to the memory.
In the prime endpoint function, we need to read from qh.ptr->td.token to ensure that the previous write to it has indeed been committed to memory.
--- drivers/usb/chipidea/udc.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/usb/chipidea/udc.c +12 -3
@@ -190,12 +190,21 @@ static int hw_ep_get_halt(struct ci_hdrc *ci, int num, int dir)* * This function returns an error code */ -static int hw_ep_prime (struct ci_hdrc *ci,int num,int dir,int is_ctrl) +static int hw_ep_prime (struct ci_hdrc *ci,struct ci_hw_ep *hwep,int num, +int dir,int is_ctrl) {int n =hw_ep_bit (num, dir);/* Synchronize before ep prime */ wmb (); + +/* +* We add the read from qh.ptr->td.token to make sure the previous +* write to it indeed got into the mamory so when we prime the DMA +* will read the updated data +*/ +if (hwep->qh.ptr->td.token &0x80000000 ) +pr_info ("%s(): hwep->qh.ptr->td.token=%08x\n" , __func__, hwep->qh.ptr->td.token);if (is_ctrl && dir ==RX &&hw_read (ci,OP_ENDPTSETUPSTAT ,BIT (num)))return -EAGAIN ;
@@ -632,7 +641,7 @@ static int _hardware_enqueue(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq) hwep->qh.ptr->cap |=cpu_to_le32 (mul <<__ffs (QH_MULT )); } - ret =hw_ep_prime (ci, hwep->num, hwep->dir, + ret =hw_ep_prime (ci, hwep, hwep->num, hwep->dir, hwep->type ==USB_ENDPOINT_XFER_CONTROL ); done:return ret;
@@ -658,7 +667,7 @@ static int reprime_dtd(struct ci_hdrc *ci, struct ci_hw_ep *hwep, hwep->qh.ptr->td.token &=cpu_to_le32 (~(TD_STATUS_HALTED |TD_STATUS_ACTIVE )); -return hw_ep_prime (ci, hwep->num, hwep->dir, +return hw_ep_prime (ci, hwep, hwep->num, hwep->dir, hwep->type ==USB_ENDPOINT_XFER_CONTROL ); }
Signature · 1 line
2.34.1
Dear Tomer,
Thank you for your patch.
Am 10.07.24 um 14:41 schrieb Tomer Maimon:
Quoted 3 lines
In the prime endpoint function, we need to read from
qh.ptr->td.tokento ensure that the previous write to it has indeed been committed to memory.
Please document the datasheet name, revision and section. If this actually caused user visible problems, please also document the test case.
Quoted 15 lines
Signed-off-by Tomer Maimon <[email protected]>--- drivers/usb/chipidea/udc.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)drivers/usb/chipidea/udc.c +1
-1@@ -190,12 +190,21 @@ static int hw_ep_get_halt(struct ci_hdrc *ci, int num, int dir)* * This function returns an error code */ -static int hw_ep_prime (struct ci_hdrc *ci,int num,int dir,int is_ctrl) +static int hw_ep_prime(struct ci_hdrc *ci, struct ci_hw_ep *hwep, int num,
drivers/usb/chipidea/udc.c static int hw_ep_get_halt(struct ci_hdrc *ci, int num, int dir) · line 203
Quoted 10 lines
drivers/usb/chipidea/udc.c +5
-0+ int dir, int is_ctrl) { int n = hw_ep_bit(num, dir);/* Synchronize before ep prime */ wmb (); + +/* +* We add the read from qh.ptr->td.token to make sure the previous +* write to it indeed got into the mamory so when we prime the DMA
m*e*mory
Quoted 17 lines
drivers/usb/chipidea/udc.c +5
-1+* will read the updated data +*/ +if (hwep->qh.ptr->td.token &0x80000000 ) +pr_info ("%s(): hwep->qh.ptr->td.token=%08x\n" , __func__, hwep->qh.ptr->td.token);if (is_ctrl && dir ==RX &&hw_read (ci,OP_ENDPTSETUPSTAT ,BIT (num)))return -EAGAIN ;@@ -632,7 +641,7 @@ static int _hardware_enqueue(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq) hwep->qh.ptr->cap |=cpu_to_le32 (mul <<__ffs (QH_MULT )); } - ret =hw_ep_prime (ci, hwep->num, hwep->dir, + ret =hw_ep_prime (ci, hwep, hwep->num, hwep->dir, hwep->type ==USB_ENDPOINT_XFER_CONTROL ); done:return ret;
drivers/usb/chipidea/udc.c static int reprime_dtd(struct ci_hdrc *ci, struct ci_hw_ep *hwep, · line 673
Quoted 8 lines
drivers/usb/chipidea/udc.c +1
-1@@ -658,7 +667,7 @@ static int reprime_dtd(struct ci_hdrc *ci, struct ci_hw_ep *hwep, hwep->qh.ptr->td.token &=cpu_to_le32 (~(TD_STATUS_HALTED |TD_STATUS_ACTIVE )); -return hw_ep_prime (ci, hwep->num, hwep->dir, +return hw_ep_prime (ci, hwep, hwep->num, hwep->dir, hwep->type ==USB_ENDPOINT_XFER_CONTROL ); }
Kind regards,
Paul
Hi Paul,
Thanks a lot for your comments, it will be addressed in the next version.
Tomer
Quoted 72 lines · Paul Menzel
Dear Tomer,
Thank you for your patch.
Am 10.07.24 um 14:41 schrieb Tomer Maimon:
Quoted 3 lines
In the prime endpoint function, we need to read from
qh.ptr->td.tokento ensure that the previous write to it has indeed been committed to memory.Please document the datasheet name, revision and section. If this actually caused user visible problems, please also document the test case.
Quoted 15 lines
Signed-off-by Tomer Maimon <[email protected]>--- drivers/usb/chipidea/udc.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)drivers/usb/chipidea/udc.c +1
-1@@ -190,12 +190,21 @@ static int hw_ep_get_halt(struct ci_hdrc *ci, int num, int dir)* * This function returns an error code */ -static int hw_ep_prime (struct ci_hdrc *ci,int num,int dir,int is_ctrl) +static int hw_ep_prime(struct ci_hdrc *ci, struct ci_hw_ep *hwep, int num,drivers/usb/chipidea/udc.c static int hw_ep_get_halt(struct ci_hdrc *ci, int num, int dir) · line 203
Quoted 10 lines
drivers/usb/chipidea/udc.c +5
-0+ int dir, int is_ctrl) { int n = hw_ep_bit(num, dir);/* Synchronize before ep prime */ wmb (); + +/* +* We add the read from qh.ptr->td.token to make sure the previous +* write to it indeed got into the mamory so when we prime the DMA m*e*mory
Quoted 17 lines
drivers/usb/chipidea/udc.c +5
-1+* will read the updated data +*/ +if (hwep->qh.ptr->td.token &0x80000000 ) +pr_info ("%s(): hwep->qh.ptr->td.token=%08x\n" , __func__, hwep->qh.ptr->td.token);if (is_ctrl && dir ==RX &&hw_read (ci,OP_ENDPTSETUPSTAT ,BIT (num)))return -EAGAIN ;@@ -632,7 +641,7 @@ static int _hardware_enqueue(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq) hwep->qh.ptr->cap |=cpu_to_le32 (mul <<__ffs (QH_MULT )); } - ret =hw_ep_prime (ci, hwep->num, hwep->dir, + ret =hw_ep_prime (ci, hwep, hwep->num, hwep->dir, hwep->type ==USB_ENDPOINT_XFER_CONTROL ); done:return ret;drivers/usb/chipidea/udc.c static int reprime_dtd(struct ci_hdrc *ci, struct ci_hw_ep *hwep, · line 673
Quoted 8 lines
drivers/usb/chipidea/udc.c +1
-1@@ -658,7 +667,7 @@ static int reprime_dtd(struct ci_hdrc *ci, struct ci_hw_ep *hwep, hwep->qh.ptr->td.token &=cpu_to_le32 (~(TD_STATUS_HALTED |TD_STATUS_ACTIVE )); -return hw_ep_prime (ci, hwep->num, hwep->dir, +return hw_ep_prime (ci, hwep, hwep->num, hwep->dir, hwep->type ==USB_ENDPOINT_XFER_CONTROL ); }Kind regards,
Paul
Quoted 8 lines · Tomer Maimon
In the prime endpoint function, we need to read from
qh.ptr->td.tokento ensure that the previous write to it has indeed been committed to memory.Signed-off-by Tomer Maimon <[email protected]>--- drivers/usb/chipidea/udc.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
What's the state of this patch with respect to upstream? Is this something specific to the openbmc/linux dev-6.6 tree, or is there an upstream equivalent? If the latter, can you please link to the relevant patch?
Andrew
Hi Andrew,
Quoted 11 lines · Andrew Jeffery
Quoted 8 lines · Tomer Maimon
In the prime endpoint function, we need to read from
qh.ptr->td.tokento ensure that the previous write to it has indeed been committed to memory.Signed-off-by Tomer Maimon <[email protected]>--- drivers/usb/chipidea/udc.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
Quoted 4 lines
What's the state of this patch with respect to upstream? Is this something specific to the openbmc/linux dev-6.6 tree, or is there an upstream equivalent? If the latter, can you please link to the relevant patch?
This patch didn't upstream yet to OpenBMC vanilla.
Its not specific to openbmc/linux dev-6.6 tree, but it is something that related to NPCM UDC module and I am not sure that Chipidea will approve to upstream it to the main chipidea driver
I am planning to start the upstream in the next Linux version 6.11.
Quoted 2 lines
Andrew
Thanks,
Tomer
Quoted 15 lines · Tomer Maimon
Hi Andrew,
Quoted 11 lines · Andrew Jeffery
Quoted 8 lines · Tomer Maimon
In the prime endpoint function, we need to read from
qh.ptr->td.tokento ensure that the previous write to it has indeed been committed to memory.Signed-off-by Tomer Maimon <[email protected]>--- drivers/usb/chipidea/udc.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
Quoted 8 lines
Quoted 4 lines
What's the state of this patch with respect to upstream? Is this something specific to the openbmc/linux dev-6.6 tree, or is there an upstream equivalent? If the latter, can you please link to the relevant patch?
This patch didn't upstream yet to OpenBMC vanilla.
Its not specific to openbmc/linux dev-6.6 tree, but it is something that related to NPCM UDC module and I am not sure that Chipidea will approve to upstream it to the main chipidea driver
Given it's a driver for shared IP I prefer you get some feedback on the upstream lists before we apply this to the openbmc tree.
Andrew