All of lore.kernel.org
 help / color / mirror / Atom feed
* This patch fixes endian issue in xHCI for scratchpad buffer.
@ 2019-04-29 14:01 ` Aleksey Kuleshov
  0 siblings, 0 replies; 2+ messages in thread
From: Aleksey Kuleshov @ 2019-04-29 14:01 UTC (permalink / raw)
  To: linux-usb; +Cc: Mathias Nyman, Aleksey Kuleshov

Scratchpad buffer is an array of pointers every of which must be
in little endian format.

Signed-off-by: Aleksey Kuleshov <rndfax@yandex.ru>
---
 drivers/usb/host/xhci-mem.c | 6 +++---
 drivers/usb/host/xhci.h     | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index cf5e179..ffc3236 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1677,7 +1677,7 @@ static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags)
 		if (!buf)
 			goto fail_sp4;
 
-		xhci->scratchpad->sp_array[i] = dma;
+		xhci->scratchpad->sp_array[i] = cpu_to_le64(dma);
 		xhci->scratchpad->sp_buffers[i] = buf;
 	}
 
@@ -1687,7 +1687,7 @@ static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags)
 	for (i = i - 1; i >= 0; i--) {
 		dma_free_coherent(dev, xhci->page_size,
 				    xhci->scratchpad->sp_buffers[i],
-				    xhci->scratchpad->sp_array[i]);
+				    le64_to_cpu(xhci->scratchpad->sp_array[i]));
 	}
 
 	kfree(xhci->scratchpad->sp_buffers);
@@ -1719,7 +1719,7 @@ static void scratchpad_free(struct xhci_hcd *xhci)
 	for (i = 0; i < num_sp; i++) {
 		dma_free_coherent(dev, xhci->page_size,
 				    xhci->scratchpad->sp_buffers[i],
-				    xhci->scratchpad->sp_array[i]);
+				    le64_to_cpu(xhci->scratchpad->sp_array[i]));
 	}
 	kfree(xhci->scratchpad->sp_buffers);
 	dma_free_coherent(dev, num_sp * sizeof(u64),
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 9334cde..385fa70 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1621,7 +1621,7 @@ struct xhci_erst {
 };
 
 struct xhci_scratchpad {
-	u64 *sp_array;
+	__le64 *sp_array;
 	dma_addr_t sp_dma;
 	void **sp_buffers;
 };

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] This patch fixes endian issue in xHCI for scratchpad buffer.
@ 2019-04-29 14:01 ` Aleksey Kuleshov
  0 siblings, 0 replies; 2+ messages in thread
From: Aleksey Kuleshov @ 2019-04-29 14:01 UTC (permalink / raw)
  To: linux-usb; +Cc: Mathias Nyman, Aleksey Kuleshov

Scratchpad buffer is an array of pointers every of which must be
in little endian format.

Signed-off-by: Aleksey Kuleshov <rndfax@yandex.ru>
---
 drivers/usb/host/xhci-mem.c | 6 +++---
 drivers/usb/host/xhci.h     | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index cf5e179..ffc3236 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1677,7 +1677,7 @@ static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags)
 		if (!buf)
 			goto fail_sp4;
 
-		xhci->scratchpad->sp_array[i] = dma;
+		xhci->scratchpad->sp_array[i] = cpu_to_le64(dma);
 		xhci->scratchpad->sp_buffers[i] = buf;
 	}
 
@@ -1687,7 +1687,7 @@ static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags)
 	for (i = i - 1; i >= 0; i--) {
 		dma_free_coherent(dev, xhci->page_size,
 				    xhci->scratchpad->sp_buffers[i],
-				    xhci->scratchpad->sp_array[i]);
+				    le64_to_cpu(xhci->scratchpad->sp_array[i]));
 	}
 
 	kfree(xhci->scratchpad->sp_buffers);
@@ -1719,7 +1719,7 @@ static void scratchpad_free(struct xhci_hcd *xhci)
 	for (i = 0; i < num_sp; i++) {
 		dma_free_coherent(dev, xhci->page_size,
 				    xhci->scratchpad->sp_buffers[i],
-				    xhci->scratchpad->sp_array[i]);
+				    le64_to_cpu(xhci->scratchpad->sp_array[i]));
 	}
 	kfree(xhci->scratchpad->sp_buffers);
 	dma_free_coherent(dev, num_sp * sizeof(u64),
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 9334cde..385fa70 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1621,7 +1621,7 @@ struct xhci_erst {
 };
 
 struct xhci_scratchpad {
-	u64 *sp_array;
+	__le64 *sp_array;
 	dma_addr_t sp_dma;
 	void **sp_buffers;
 };
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-04-29 14:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-29 14:01 This patch fixes endian issue in xHCI for scratchpad buffer Aleksey Kuleshov
2019-04-29 14:01 ` [PATCH] " Aleksey Kuleshov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.