All of lore.kernel.org
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] xhci: Fix immediate data transfer if buffer is already DMA" failed to apply to 5.2-stable tree
@ 2019-07-24 15:43 gregkh
  2019-07-24 15:53 ` Nicolas Saenz Julienne
  2019-07-24 15:53 ` Greg KH
  0 siblings, 2 replies; 4+ messages in thread
From: gregkh @ 2019-07-24 15:43 UTC (permalink / raw)
  To: mathias.nyman, gregkh, m.szyprowski, nsaenzjulienne; +Cc: stable


The patch below does not apply to the 5.2-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 13b82b746310b51b064bc855993a1c84bf862726 Mon Sep 17 00:00:00 2001
From: Mathias Nyman <mathias.nyman@linux.intel.com>
Date: Wed, 22 May 2019 14:34:00 +0300
Subject: [PATCH] xhci: Fix immediate data transfer if buffer is already DMA
 mapped

xhci immediate data transfer (IDT) support in 5.2-rc1 caused regression
on various Samsung Exynos boards with ASIX USB 2.0 ethernet dongle.

If the transfer buffer in the URB is already DMA mapped then IDT should
not be used. urb->transfer_dma will already contain a valid dma address,
and there is no guarantee the data in urb->transfer_buffer is valid.

The IDT support patch used urb->transfer_dma as a temporary storage,
copying data from urb->transfer_buffer into it.

Issue was solved by preventing IDT if transfer buffer is already dma
mapped, and by not using urb->transfer_dma as temporary storage.

Fixes: 33e39350ebd2 ("usb: xhci: add Immediate Data Transfer support")
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
CC: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index ef7c8698772e..88392aa65722 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -3432,11 +3432,14 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
 
 	if (urb->transfer_buffer_length > 0) {
 		u32 length_field, remainder;
+		u64 addr;
 
 		if (xhci_urb_suitable_for_idt(urb)) {
-			memcpy(&urb->transfer_dma, urb->transfer_buffer,
+			memcpy(&addr, urb->transfer_buffer,
 			       urb->transfer_buffer_length);
 			field |= TRB_IDT;
+		} else {
+			addr = (u64) urb->transfer_dma;
 		}
 
 		remainder = xhci_td_remainder(xhci, 0,
@@ -3449,8 +3452,8 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
 		if (setup->bRequestType & USB_DIR_IN)
 			field |= TRB_DIR_IN;
 		queue_trb(xhci, ep_ring, true,
-				lower_32_bits(urb->transfer_dma),
-				upper_32_bits(urb->transfer_dma),
+				lower_32_bits(addr),
+				upper_32_bits(addr),
 				length_field,
 				field | ep_ring->cycle_state);
 	}
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index a450a99e90eb..7f8b950d1a73 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -2160,7 +2160,8 @@ static inline bool xhci_urb_suitable_for_idt(struct urb *urb)
 {
 	if (!usb_endpoint_xfer_isoc(&urb->ep->desc) && usb_urb_dir_out(urb) &&
 	    usb_endpoint_maxp(&urb->ep->desc) >= TRB_IDT_MAX_SIZE &&
-	    urb->transfer_buffer_length <= TRB_IDT_MAX_SIZE)
+	    urb->transfer_buffer_length <= TRB_IDT_MAX_SIZE &&
+	    !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP))
 		return true;
 
 	return false;


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

* Re: FAILED: patch "[PATCH] xhci: Fix immediate data transfer if buffer is already DMA" failed to apply to 5.2-stable tree
  2019-07-24 15:43 FAILED: patch "[PATCH] xhci: Fix immediate data transfer if buffer is already DMA" failed to apply to 5.2-stable tree gregkh
@ 2019-07-24 15:53 ` Nicolas Saenz Julienne
  2019-07-24 15:53 ` Greg KH
  1 sibling, 0 replies; 4+ messages in thread
From: Nicolas Saenz Julienne @ 2019-07-24 15:53 UTC (permalink / raw)
  To: gregkh, mathias.nyman, m.szyprowski; +Cc: stable

[-- Attachment #1: Type: text/plain, Size: 3628 bytes --]

On Wed, 2019-07-24 at 17:43 +0200, gregkh@linuxfoundation.org wrote:
> The patch below does not apply to the 5.2-stable tree.
> If someone wants it applied there, or to any other stable or longterm
> tree, then please email the backport, including the original git commit
> id to <stable@vger.kernel.org>.
> 
> thanks,
> 
> greg k-h
>

For the record, just so it doesn't get lost, it is indeed needed. 
I'll take care of it as long as Matthias doesn't prefer to do it himself.

> ------------------ original commit in Linus's tree ------------------
> 
> From 13b82b746310b51b064bc855993a1c84bf862726 Mon Sep 17 00:00:00 2001
> From: Mathias Nyman <mathias.nyman@linux.intel.com>
> Date: Wed, 22 May 2019 14:34:00 +0300
> Subject: [PATCH] xhci: Fix immediate data transfer if buffer is already DMA
>  mapped
> 
> xhci immediate data transfer (IDT) support in 5.2-rc1 caused regression
> on various Samsung Exynos boards with ASIX USB 2.0 ethernet dongle.
> 
> If the transfer buffer in the URB is already DMA mapped then IDT should
> not be used. urb->transfer_dma will already contain a valid dma address,
> and there is no guarantee the data in urb->transfer_buffer is valid.
> 
> The IDT support patch used urb->transfer_dma as a temporary storage,
> copying data from urb->transfer_buffer into it.
> 
> Issue was solved by preventing IDT if transfer buffer is already dma
> mapped, and by not using urb->transfer_dma as temporary storage.
> 
> Fixes: 33e39350ebd2 ("usb: xhci: add Immediate Data Transfer support")
> Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
> Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
> CC: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> 
> diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
> index ef7c8698772e..88392aa65722 100644
> --- a/drivers/usb/host/xhci-ring.c
> +++ b/drivers/usb/host/xhci-ring.c
> @@ -3432,11 +3432,14 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t
> mem_flags,
>  
>  	if (urb->transfer_buffer_length > 0) {
>  		u32 length_field, remainder;
> +		u64 addr;
>  
>  		if (xhci_urb_suitable_for_idt(urb)) {
> -			memcpy(&urb->transfer_dma, urb->transfer_buffer,
> +			memcpy(&addr, urb->transfer_buffer,
>  			       urb->transfer_buffer_length);
>  			field |= TRB_IDT;
> +		} else {
> +			addr = (u64) urb->transfer_dma;
>  		}
>  
>  		remainder = xhci_td_remainder(xhci, 0,
> @@ -3449,8 +3452,8 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t
> mem_flags,
>  		if (setup->bRequestType & USB_DIR_IN)
>  			field |= TRB_DIR_IN;
>  		queue_trb(xhci, ep_ring, true,
> -				lower_32_bits(urb->transfer_dma),
> -				upper_32_bits(urb->transfer_dma),
> +				lower_32_bits(addr),
> +				upper_32_bits(addr),
>  				length_field,
>  				field | ep_ring->cycle_state);
>  	}
> diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
> index a450a99e90eb..7f8b950d1a73 100644
> --- a/drivers/usb/host/xhci.h
> +++ b/drivers/usb/host/xhci.h
> @@ -2160,7 +2160,8 @@ static inline bool xhci_urb_suitable_for_idt(struct urb
> *urb)
>  {
>  	if (!usb_endpoint_xfer_isoc(&urb->ep->desc) && usb_urb_dir_out(urb) &&
>  	    usb_endpoint_maxp(&urb->ep->desc) >= TRB_IDT_MAX_SIZE &&
> -	    urb->transfer_buffer_length <= TRB_IDT_MAX_SIZE)
> +	    urb->transfer_buffer_length <= TRB_IDT_MAX_SIZE &&
> +	    !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP))
>  		return true;
>  
>  	return false;
> 


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: FAILED: patch "[PATCH] xhci: Fix immediate data transfer if buffer is already DMA" failed to apply to 5.2-stable tree
  2019-07-24 15:43 FAILED: patch "[PATCH] xhci: Fix immediate data transfer if buffer is already DMA" failed to apply to 5.2-stable tree gregkh
  2019-07-24 15:53 ` Nicolas Saenz Julienne
@ 2019-07-24 15:53 ` Greg KH
  2019-07-24 15:56   ` Nicolas Saenz Julienne
  1 sibling, 1 reply; 4+ messages in thread
From: Greg KH @ 2019-07-24 15:53 UTC (permalink / raw)
  To: mathias.nyman, m.szyprowski, nsaenzjulienne; +Cc: stable

On Wed, Jul 24, 2019 at 05:43:47PM +0200, gregkh@linuxfoundation.org wrote:
> 
> The patch below does not apply to the 5.2-stable tree.
> If someone wants it applied there, or to any other stable or longterm
> tree, then please email the backport, including the original git commit
> id to <stable@vger.kernel.org>.
> 
> thanks,
> 
> greg k-h
> 
> ------------------ original commit in Linus's tree ------------------
> 
> >From 13b82b746310b51b064bc855993a1c84bf862726 Mon Sep 17 00:00:00 2001
> From: Mathias Nyman <mathias.nyman@linux.intel.com>
> Date: Wed, 22 May 2019 14:34:00 +0300
> Subject: [PATCH] xhci: Fix immediate data transfer if buffer is already DMA
>  mapped
> 
> xhci immediate data transfer (IDT) support in 5.2-rc1 caused regression
> on various Samsung Exynos boards with ASIX USB 2.0 ethernet dongle.
> 
> If the transfer buffer in the URB is already DMA mapped then IDT should
> not be used. urb->transfer_dma will already contain a valid dma address,
> and there is no guarantee the data in urb->transfer_buffer is valid.
> 
> The IDT support patch used urb->transfer_dma as a temporary storage,
> copying data from urb->transfer_buffer into it.
> 
> Issue was solved by preventing IDT if transfer buffer is already dma
> mapped, and by not using urb->transfer_dma as temporary storage.
> 
> Fixes: 33e39350ebd2 ("usb: xhci: add Immediate Data Transfer support")
> Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
> Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
> CC: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Oh nevermind, this should be a 5.2-only thing.

it shouldn't affect anyone, sorry for the noise.

greg k-h

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

* Re: FAILED: patch "[PATCH] xhci: Fix immediate data transfer if buffer is already DMA" failed to apply to 5.2-stable tree
  2019-07-24 15:53 ` Greg KH
@ 2019-07-24 15:56   ` Nicolas Saenz Julienne
  0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Saenz Julienne @ 2019-07-24 15:56 UTC (permalink / raw)
  To: Greg KH, mathias.nyman, m.szyprowski; +Cc: stable

[-- Attachment #1: Type: text/plain, Size: 1960 bytes --]

On Wed, 2019-07-24 at 17:53 +0200, Greg KH wrote:
> On Wed, Jul 24, 2019 at 05:43:47PM +0200, gregkh@linuxfoundation.org wrote:
> > The patch below does not apply to the 5.2-stable tree.
> > If someone wants it applied there, or to any other stable or longterm
> > tree, then please email the backport, including the original git commit
> > id to <stable@vger.kernel.org>.
> > 
> > thanks,
> > 
> > greg k-h
> > 
> > ------------------ original commit in Linus's tree ------------------
> > 
> > > From 13b82b746310b51b064bc855993a1c84bf862726 Mon Sep 17 00:00:00 2001
> > From: Mathias Nyman <mathias.nyman@linux.intel.com>
> > Date: Wed, 22 May 2019 14:34:00 +0300
> > Subject: [PATCH] xhci: Fix immediate data transfer if buffer is already DMA
> >  mapped
> > 
> > xhci immediate data transfer (IDT) support in 5.2-rc1 caused regression
> > on various Samsung Exynos boards with ASIX USB 2.0 ethernet dongle.
> > 
> > If the transfer buffer in the URB is already DMA mapped then IDT should
> > not be used. urb->transfer_dma will already contain a valid dma address,
> > and there is no guarantee the data in urb->transfer_buffer is valid.
> > 
> > The IDT support patch used urb->transfer_dma as a temporary storage,
> > copying data from urb->transfer_buffer into it.
> > 
> > Issue was solved by preventing IDT if transfer buffer is already dma
> > mapped, and by not using urb->transfer_dma as temporary storage.
> > 
> > Fixes: 33e39350ebd2 ("usb: xhci: add Immediate Data Transfer support")
> > Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
> > Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
> > CC: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> > Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> 
> Oh nevermind, this should be a 5.2-only thing.

You're right, I reacted too fast.

Regards,
Nicolas


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2019-07-24 15:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-24 15:43 FAILED: patch "[PATCH] xhci: Fix immediate data transfer if buffer is already DMA" failed to apply to 5.2-stable tree gregkh
2019-07-24 15:53 ` Nicolas Saenz Julienne
2019-07-24 15:53 ` Greg KH
2019-07-24 15:56   ` Nicolas Saenz Julienne

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.