Re: [PATCH v1 04/29] usb: dwc2: gadget: don't embed ep0 buffers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On 12/21/2014 05:14 PM, Mian Yousaf Kaukab wrote:
> When using DMA, data of the previous setup packet can be read back
> from cache because ep0 and ctrl buffers are embedded in struct s3c_hsotg.
> Allocate buffers instead of embedding them.
> 
> Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@xxxxxxxxx>
> ---
>  drivers/usb/dwc2/core.h   |  7 +++++--
>  drivers/usb/dwc2/gadget.c | 20 ++++++++++++++++++--
>  2 files changed, 23 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
> index 7a70a13..e841a56 100644
> --- a/drivers/usb/dwc2/core.h
> +++ b/drivers/usb/dwc2/core.h
> @@ -434,6 +434,9 @@ struct dwc2_hw_params {
>  	u32 snpsid;
>  };
>  
> +/* Size of control and EP0 buffers */
> +#define DWC2_CTRL_BUFF_SIZE 8
> +
>  /**
>   * struct dwc2_hsotg - Holds the state of the driver, including the non-periodic
>   * and periodic schedules
> @@ -684,8 +687,8 @@ struct dwc2_hsotg {
>  
>  	struct usb_request *ep0_reply;
>  	struct usb_request *ctrl_req;
> -	u8 ep0_buff[8];
> -	u8 ctrl_buff[8];
> +	void *ep0_buff;
> +	void *ctrl_buff;
>  
>  	struct usb_gadget gadget;
>  	unsigned int enabled:1;
> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
> index d89c341..5de3a3a 100644
> --- a/drivers/usb/dwc2/gadget.c
> +++ b/drivers/usb/dwc2/gadget.c
> @@ -3485,7 +3485,7 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
>  
>  	if (ret) {
>  		dev_err(dev, "failed to enable supplies: %d\n", ret);
> -		goto err_supplies;
> +		goto err_clk;
>  	}
>  
>  	/* usb phy enable */
> @@ -3495,6 +3495,22 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
>  	s3c_hsotg_hw_cfg(hsotg);
>  	s3c_hsotg_init(hsotg);
>  
> +	hsotg->ctrl_buff = devm_kzalloc(hsotg->dev,
> +			DWC2_CTRL_BUFF_SIZE, GFP_KERNEL);
> +	if (!hsotg->ctrl_buff) {
> +		dev_err(dev, "failed to allocate ctrl request buff\n");
> +		ret = -ENOMEM;
> +		goto err_supplies;
> +	}
> +
> +	hsotg->ep0_buff = devm_kzalloc(hsotg->dev,
> +			DWC2_CTRL_BUFF_SIZE, GFP_KERNEL);
> +	if (!hsotg->ep0_buff) {
> +		dev_err(dev, "failed to allocate ctrl reply buff\n");
> +		ret = -ENOMEM;
> +		goto err_supplies;
> +	}
> +
>  	ret = devm_request_irq(hsotg->dev, irq, s3c_hsotg_irq, IRQF_SHARED,
>  				dev_name(hsotg->dev), hsotg);
>  	if (ret < 0) {
> @@ -3503,7 +3519,7 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
>  		regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies),
>  				       hsotg->supplies);
>  		dev_err(dev, "cannot claim IRQ for gadget\n");
> -		goto err_clk;
> +		goto err_supplies;

This is unrelated change. Should be in separate patch.

>  	}
>  
>  	/* hsotg->num_of_eps holds number of EPs other than ep0 */
> 

Reviewed-by: Robert Baldyga <r.baldyga@xxxxxxxxxxx>

Best regards,
Robert Baldyga
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux