diff mbox series

[U-Boot,v2] usb: xhci-mem: Fix scratchpad array issue

Message ID 1546829104-8904-1-git-send-email-ye.li@nxp.com
State Accepted
Commit 8c6cc71b40357dad4e3f21e9f1bd84db76a3d994
Delegated to: Marek Vasut
Headers show
Series [U-Boot,v2] usb: xhci-mem: Fix scratchpad array issue | expand

Commit Message

Ye Li Jan. 7, 2019, 2:45 a.m. UTC
After updating the value of dev_context_ptrs[0], we should flush this
from cache to memory. Otherwise the xhci controller won't use it.

Signed-off-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Marek Vasut <marex@denx.de>
---
Changes for v2:
   - Change to use sizeof(ctrl->dcbaa->dev_context_ptrs[0])

 drivers/usb/host/xhci-mem.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Marek Vasut Jan. 7, 2019, 6:22 a.m. UTC | #1
On 1/7/19 3:45 AM, Ye Li wrote:
> After updating the value of dev_context_ptrs[0], we should flush this
> from cache to memory. Otherwise the xhci controller won't use it.
> 
> Signed-off-by: Ye Li <ye.li@nxp.com>
> Reviewed-by: Marek Vasut <marex@denx.de>

Looks good to me, waiting for A-B/R-B from Bin.

> ---
> Changes for v2:
>    - Change to use sizeof(ctrl->dcbaa->dev_context_ptrs[0])
> 
>  drivers/usb/host/xhci-mem.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
> index 04ab540..84c2c33 100644
> --- a/drivers/usb/host/xhci-mem.c
> +++ b/drivers/usb/host/xhci-mem.c
> @@ -369,6 +369,9 @@ static int xhci_scratchpad_alloc(struct xhci_ctrl *ctrl)
>  	ctrl->dcbaa->dev_context_ptrs[0] =
>  		cpu_to_le64((uintptr_t)scratchpad->sp_array);
>  
> +	xhci_flush_cache((uintptr_t)&ctrl->dcbaa->dev_context_ptrs[0],
> +		sizeof(ctrl->dcbaa->dev_context_ptrs[0]));
> +
>  	page_size = xhci_readl(&hcor->or_pagesize) & 0xffff;
>  	for (i = 0; i < 16; i++) {
>  		if ((0x1 & page_size) != 0)
>
Bin Meng Jan. 7, 2019, 9:54 a.m. UTC | #2
On Mon, Jan 7, 2019 at 10:45 AM Ye Li <ye.li@nxp.com> wrote:
>
> After updating the value of dev_context_ptrs[0], we should flush this
> from cache to memory. Otherwise the xhci controller won't use it.
>
> Signed-off-by: Ye Li <ye.li@nxp.com>
> Reviewed-by: Marek Vasut <marex@denx.de>
> ---
> Changes for v2:
>    - Change to use sizeof(ctrl->dcbaa->dev_context_ptrs[0])
>
>  drivers/usb/host/xhci-mem.c | 3 +++
>  1 file changed, 3 insertions(+)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

But you need do the same in xhci_scratchpad_free() too. Please fix it in v3.

Regards,
Bin
Ye Li Jan. 8, 2019, 4 a.m. UTC | #3
On 1/7/2019 5:54 PM, Bin Meng wrote:
> On Mon, Jan 7, 2019 at 10:45 AM Ye Li <ye.li@nxp.com> wrote:
>>
>> After updating the value of dev_context_ptrs[0], we should flush this
>> from cache to memory. Otherwise the xhci controller won't use it.
>>
>> Signed-off-by: Ye Li <ye.li@nxp.com>
>> Reviewed-by: Marek Vasut <marex@denx.de>
>> ---
>> Changes for v2:
>>    - Change to use sizeof(ctrl->dcbaa->dev_context_ptrs[0])
>>
>>  drivers/usb/host/xhci-mem.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
> 
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> 
> But you need do the same in xhci_scratchpad_free() too. Please fix it in v3.
> 
> Regards,
> Bin
> 
The xhci controller has been stopped before calling xhci_scratchpad_free, is it necessary to 
add flush in this function? And I don't see other buffers are flushed when freeing. 

Best regards,
Ye Li
Bin Meng Jan. 8, 2019, 6:34 a.m. UTC | #4
On Tue, Jan 8, 2019 at 12:00 PM Ye Li <ye.li@nxp.com> wrote:
>
> On 1/7/2019 5:54 PM, Bin Meng wrote:
> > On Mon, Jan 7, 2019 at 10:45 AM Ye Li <ye.li@nxp.com> wrote:
> >>
> >> After updating the value of dev_context_ptrs[0], we should flush this
> >> from cache to memory. Otherwise the xhci controller won't use it.
> >>
> >> Signed-off-by: Ye Li <ye.li@nxp.com>
> >> Reviewed-by: Marek Vasut <marex@denx.de>
> >> ---
> >> Changes for v2:
> >>    - Change to use sizeof(ctrl->dcbaa->dev_context_ptrs[0])
> >>
> >>  drivers/usb/host/xhci-mem.c | 3 +++
> >>  1 file changed, 3 insertions(+)
> >>
> >
> > Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> >
> > But you need do the same in xhci_scratchpad_free() too. Please fix it in v3.
> >
> The xhci controller has been stopped before calling xhci_scratchpad_free, is it necessary to
> add flush in this function? And I don't see other buffers are flushed when freeing.
>

Ah, yes. It's called after HCD reset, so that's not needed.

Regards,
Bin
Marek Vasut Jan. 8, 2019, 11:11 a.m. UTC | #5
On 1/8/19 7:34 AM, Bin Meng wrote:
> On Tue, Jan 8, 2019 at 12:00 PM Ye Li <ye.li@nxp.com> wrote:
>>
>> On 1/7/2019 5:54 PM, Bin Meng wrote:
>>> On Mon, Jan 7, 2019 at 10:45 AM Ye Li <ye.li@nxp.com> wrote:
>>>>
>>>> After updating the value of dev_context_ptrs[0], we should flush this
>>>> from cache to memory. Otherwise the xhci controller won't use it.
>>>>
>>>> Signed-off-by: Ye Li <ye.li@nxp.com>
>>>> Reviewed-by: Marek Vasut <marex@denx.de>
>>>> ---
>>>> Changes for v2:
>>>>    - Change to use sizeof(ctrl->dcbaa->dev_context_ptrs[0])
>>>>
>>>>  drivers/usb/host/xhci-mem.c | 3 +++
>>>>  1 file changed, 3 insertions(+)
>>>>
>>>
>>> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
>>>
>>> But you need do the same in xhci_scratchpad_free() too. Please fix it in v3.
>>>
>> The xhci controller has been stopped before calling xhci_scratchpad_free, is it necessary to
>> add flush in this function? And I don't see other buffers are flushed when freeing.
>>
> 
> Ah, yes. It's called after HCD reset, so that's not needed.

Shall I pick this for this release then, Bin ?
Bin Meng Jan. 9, 2019, 7:05 a.m. UTC | #6
On Tue, Jan 8, 2019 at 7:19 PM Marek Vasut <marex@denx.de> wrote:
>
> On 1/8/19 7:34 AM, Bin Meng wrote:
> > On Tue, Jan 8, 2019 at 12:00 PM Ye Li <ye.li@nxp.com> wrote:
> >>
> >> On 1/7/2019 5:54 PM, Bin Meng wrote:
> >>> On Mon, Jan 7, 2019 at 10:45 AM Ye Li <ye.li@nxp.com> wrote:
> >>>>
> >>>> After updating the value of dev_context_ptrs[0], we should flush this
> >>>> from cache to memory. Otherwise the xhci controller won't use it.
> >>>>
> >>>> Signed-off-by: Ye Li <ye.li@nxp.com>
> >>>> Reviewed-by: Marek Vasut <marex@denx.de>
> >>>> ---
> >>>> Changes for v2:
> >>>>    - Change to use sizeof(ctrl->dcbaa->dev_context_ptrs[0])
> >>>>
> >>>>  drivers/usb/host/xhci-mem.c | 3 +++
> >>>>  1 file changed, 3 insertions(+)
> >>>>
> >>>
> >>> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> >>>
> >>> But you need do the same in xhci_scratchpad_free() too. Please fix it in v3.
> >>>
> >> The xhci controller has been stopped before calling xhci_scratchpad_free, is it necessary to
> >> add flush in this function? And I don't see other buffers are flushed when freeing.
> >>
> >
> > Ah, yes. It's called after HCD reset, so that's not needed.
>
> Shall I pick this for this release then, Bin ?
>

Yes, I think so.

Regards,
Bin
Marek Vasut Jan. 9, 2019, 3:04 p.m. UTC | #7
On 1/9/19 8:05 AM, Bin Meng wrote:
> On Tue, Jan 8, 2019 at 7:19 PM Marek Vasut <marex@denx.de> wrote:
>>
>> On 1/8/19 7:34 AM, Bin Meng wrote:
>>> On Tue, Jan 8, 2019 at 12:00 PM Ye Li <ye.li@nxp.com> wrote:
>>>>
>>>> On 1/7/2019 5:54 PM, Bin Meng wrote:
>>>>> On Mon, Jan 7, 2019 at 10:45 AM Ye Li <ye.li@nxp.com> wrote:
>>>>>>
>>>>>> After updating the value of dev_context_ptrs[0], we should flush this
>>>>>> from cache to memory. Otherwise the xhci controller won't use it.
>>>>>>
>>>>>> Signed-off-by: Ye Li <ye.li@nxp.com>
>>>>>> Reviewed-by: Marek Vasut <marex@denx.de>
>>>>>> ---
>>>>>> Changes for v2:
>>>>>>    - Change to use sizeof(ctrl->dcbaa->dev_context_ptrs[0])
>>>>>>
>>>>>>  drivers/usb/host/xhci-mem.c | 3 +++
>>>>>>  1 file changed, 3 insertions(+)
>>>>>>
>>>>>
>>>>> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
>>>>>
>>>>> But you need do the same in xhci_scratchpad_free() too. Please fix it in v3.
>>>>>
>>>> The xhci controller has been stopped before calling xhci_scratchpad_free, is it necessary to
>>>> add flush in this function? And I don't see other buffers are flushed when freeing.
>>>>
>>>
>>> Ah, yes. It's called after HCD reset, so that's not needed.
>>
>> Shall I pick this for this release then, Bin ?
>>
> 
> Yes, I think so.

Applied, thanks.
diff mbox series

Patch

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 04ab540..84c2c33 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -369,6 +369,9 @@  static int xhci_scratchpad_alloc(struct xhci_ctrl *ctrl)
 	ctrl->dcbaa->dev_context_ptrs[0] =
 		cpu_to_le64((uintptr_t)scratchpad->sp_array);
 
+	xhci_flush_cache((uintptr_t)&ctrl->dcbaa->dev_context_ptrs[0],
+		sizeof(ctrl->dcbaa->dev_context_ptrs[0]));
+
 	page_size = xhci_readl(&hcor->or_pagesize) & 0xffff;
 	for (i = 0; i < 16; i++) {
 		if ((0x1 & page_size) != 0)