diff mbox series

usb: cdns3: ep0: Invalidate cache before reading Setup Packet

Message ID 20200127122554.24615-1-vigneshr@ti.com
State Accepted
Commit bf16a7be90d5732279c454c10be1686ed79610be
Delegated to: Marek Vasut
Headers show
Series usb: cdns3: ep0: Invalidate cache before reading Setup Packet | expand

Commit Message

Raghavendra, Vignesh Jan. 27, 2020, 12:25 p.m. UTC
Invalidate dcache line before accessing Setup Packet contents. Otherwise
driver will see stale content on non coherent architecture.

Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
---
 drivers/usb/cdns3/ep0.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Marek Vasut Jan. 27, 2020, 12:57 p.m. UTC | #1
On 1/27/20 1:25 PM, Vignesh Raghavendra wrote:
> Invalidate dcache line before accessing Setup Packet contents. Otherwise
> driver will see stale content on non coherent architecture.
> 
> Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
> ---
>  drivers/usb/cdns3/ep0.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/usb/cdns3/ep0.c b/drivers/usb/cdns3/ep0.c
> index 0b6d9cf7274e..f35a92483948 100644
> --- a/drivers/usb/cdns3/ep0.c
> +++ b/drivers/usb/cdns3/ep0.c
> @@ -562,6 +562,10 @@ static void cdns3_ep0_setup_phase(struct cdns3_device *priv_dev)
>  	struct cdns3_endpoint *priv_ep = priv_dev->eps[0];
>  	int result;
>  
> +	/* Invalidate Setup Packet received */
> +	invalidate_dcache_range(priv_dev->setup_dma,
> +				priv_dev->setup_dma + ARCH_DMA_MINALIGN);
> +
>  	priv_dev->ep0_data_dir = ctrl->bRequestType & USB_DIR_IN;
>  
>  	trace_cdns3_ctrl_req(ctrl);
> 

Applied, thanks.
diff mbox series

Patch

diff --git a/drivers/usb/cdns3/ep0.c b/drivers/usb/cdns3/ep0.c
index 0b6d9cf7274e..f35a92483948 100644
--- a/drivers/usb/cdns3/ep0.c
+++ b/drivers/usb/cdns3/ep0.c
@@ -562,6 +562,10 @@  static void cdns3_ep0_setup_phase(struct cdns3_device *priv_dev)
 	struct cdns3_endpoint *priv_ep = priv_dev->eps[0];
 	int result;
 
+	/* Invalidate Setup Packet received */
+	invalidate_dcache_range(priv_dev->setup_dma,
+				priv_dev->setup_dma + ARCH_DMA_MINALIGN);
+
 	priv_dev->ep0_data_dir = ctrl->bRequestType & USB_DIR_IN;
 
 	trace_cdns3_ctrl_req(ctrl);