Skip to contentSkip to conversation

usb: xhci-mem: Fix scratchpad array issue

PATCH Superseded Ye Li 3 participants 8 messages Jan 7, 2019 – Jan 9, 2019

Subsystems (2)
lore
Share & tools
lore

Ye Li

author
#0 lore raw

PATCH v2 1/1 usb: xhci-mem: Fix scratchpad array issue

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.

---
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(+)
drivers/usb/host/xhci-mem.c +3 -0
index 04ab540..84c2c33 100644
@@ -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)
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 1/1 usb: xhci-mem: Fix scratchpad array issue

Quoted 5 lines · Ye Li

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.

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

Quoted 22 lines

---
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(+)
drivers/usb/host/xhci-mem.c +3 -0
index 04ab540..84c2c33 100644
@@ -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)
Signature · 2 lines
Best regards,
Marek Vasut
#2 lore raw

PATCH v2 1/1 usb: xhci-mem: Fix scratchpad array issue

In reply to Ye Li
Quoted 4 lines · Ye Li

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.

Quoted 9 lines

---
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(+)

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

Regards,
Bin

author
#3 lore raw

PATCH v2 1/1 usb: xhci-mem: Fix scratchpad array issue

Quoted 15 lines · Bin Meng
Quoted 4 lines · Ye Li

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.

Quoted 9 lines

---
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(+)
Quoted 7 lines

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

#4 lore raw

PATCH v2 1/1 usb: xhci-mem: Fix scratchpad array issue

Quoted 17 lines · Ye Li
Quoted 15 lines · Bin Meng
Quoted 13 lines · Ye Li

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.

---
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(+)
Quoted 7 lines
Quoted 4 lines

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

#5 lore raw

PATCH v2 1/1 usb: xhci-mem: Fix scratchpad array issue

Quoted 20 lines · Bin Meng
Quoted 19 lines · Ye Li
Quoted 17 lines · Bin Meng
Quoted 4 lines · Ye Li

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.

Quoted 9 lines

---
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(+)
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

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 ?

Signature · 2 lines
Best regards,
Marek Vasut
#6 lore raw

PATCH v2 1/1 usb: xhci-mem: Fix scratchpad array issue

Quoted 24 lines · Marek Vasut
Quoted 22 lines · Bin Meng
Quoted 21 lines · Ye Li
Quoted 19 lines · Bin Meng
Quoted 4 lines · Ye Li

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.

Quoted 9 lines

---
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(+)

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

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

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

Applied
#7 lore raw

PATCH v2 1/1 usb: xhci-mem: Fix scratchpad array issue

Quoted 29 lines · Bin Meng
Quoted 28 lines · Marek Vasut
Quoted 26 lines · Bin Meng
Quoted 24 lines · Ye Li
Quoted 11 lines · Bin Meng
Quoted 10 lines · Ye Li

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.

---
Changes for v2:
- Change to use sizeof(ctrl->dcbaa->dev_context_ptrs[0])

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

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.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

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.

Signature · 2 lines
Best regards,
Marek Vasut