[v1,1/9] usb: gadget: f_ecm/f_eem/f_rndis: Setup quirk_avoids_skb_reserve

Message ID a2f60b1ee32dba0adb7dfaaab7b1ee4d67699107.1499273075.git.digetx@gmail.com
State Superseded
Headers show

Commit Message

Dmitry Osipenko July 5, 2017, 5:19 p.m.
This quirk is required to make USB Ethernet gadget working with HW that
can't cope with unaligned DMA. For some reason only f_ncm handles that
quirk, let's handle it in the rest of the network models. All models have
been tested with a ChipIdea UDC driver on NVIDIA Tegra20 SoC that require
DMA to be aligned.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/usb/gadget/function/f_ecm.c   | 2 ++
 drivers/usb/gadget/function/f_eem.c   | 2 ++
 drivers/usb/gadget/function/f_rndis.c | 4 ++++
 3 files changed, 8 insertions(+)

Comments

Peter Chen July 6, 2017, 1:12 a.m. | #1
On Wed, Jul 05, 2017 at 08:19:50PM +0300, Dmitry Osipenko wrote:
> This quirk is required to make USB Ethernet gadget working with HW that
> can't cope with unaligned DMA. For some reason only f_ncm handles that
> quirk, let's handle it in the rest of the network models. All models have
> been tested with a ChipIdea UDC driver on NVIDIA Tegra20 SoC that require
> DMA to be aligned.
> 
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
>  drivers/usb/gadget/function/f_ecm.c   | 2 ++
>  drivers/usb/gadget/function/f_eem.c   | 2 ++
>  drivers/usb/gadget/function/f_rndis.c | 4 ++++
>  3 files changed, 8 insertions(+)
> 
> diff --git a/drivers/usb/gadget/function/f_ecm.c b/drivers/usb/gadget/function/f_ecm.c
> index 4c488d15b6f6..01150f7864c7 100644
> --- a/drivers/usb/gadget/function/f_ecm.c
> +++ b/drivers/usb/gadget/function/f_ecm.c
> @@ -584,6 +584,8 @@ static int ecm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
>  			 */
>  			ecm->port.is_zlp_ok =
>  				gadget_is_zlp_supported(cdev->gadget);
> +			ecm->port.no_skb_reserve =
> +				gadget_avoids_skb_reserve(cdev->gadget);
>  			ecm->port.cdc_filter = DEFAULT_FILTER;
>  			DBG(cdev, "activate ecm\n");
>  			net = gether_connect(&ecm->port);
> diff --git a/drivers/usb/gadget/function/f_eem.c b/drivers/usb/gadget/function/f_eem.c
> index 007ec6e4a5d4..3b70b9ccfd2d 100644
> --- a/drivers/usb/gadget/function/f_eem.c
> +++ b/drivers/usb/gadget/function/f_eem.c
> @@ -215,6 +215,8 @@ static int eem_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
>  		 */
>  		eem->port.is_zlp_ok = 1;
>  		eem->port.cdc_filter = DEFAULT_FILTER;
> +		eem->port.no_skb_reserve =
> +				gadget_avoids_skb_reserve(cdev->gadget);
>  		DBG(cdev, "activate eem\n");
>  		net = gether_connect(&eem->port);
>  		if (IS_ERR(net))
> diff --git a/drivers/usb/gadget/function/f_rndis.c b/drivers/usb/gadget/function/f_rndis.c
> index 16562e461121..1b379c051a84 100644
> --- a/drivers/usb/gadget/function/f_rndis.c
> +++ b/drivers/usb/gadget/function/f_rndis.c
> @@ -593,6 +593,10 @@ static int rndis_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
>  		 */
>  		rndis->port.cdc_filter = 0;
>  
> +		/* Setup DMA alignment workaround for UDC's that need it */
> +		rndis->port.no_skb_reserve =
> +				gadget_avoids_skb_reserve(cdev->gadget);
> +

You may add above comments for other two changes.

>  		DBG(cdev, "RNDIS RX/TX early activation ... \n");
>  		net = gether_connect(&rndis->port);
>  		if (IS_ERR(net))
> -- 
> 2.13.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Dmitry Osipenko July 6, 2017, 10:13 a.m. | #2
On 06.07.2017 04:12, Peter Chen wrote:
> On Wed, Jul 05, 2017 at 08:19:50PM +0300, Dmitry Osipenko wrote:
>> This quirk is required to make USB Ethernet gadget working with HW that
>> can't cope with unaligned DMA. For some reason only f_ncm handles that
>> quirk, let's handle it in the rest of the network models. All models have
>> been tested with a ChipIdea UDC driver on NVIDIA Tegra20 SoC that require
>> DMA to be aligned.
>>
>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
>> ---
>>  drivers/usb/gadget/function/f_ecm.c   | 2 ++
>>  drivers/usb/gadget/function/f_eem.c   | 2 ++
>>  drivers/usb/gadget/function/f_rndis.c | 4 ++++
>>  3 files changed, 8 insertions(+)
>>
>> diff --git a/drivers/usb/gadget/function/f_ecm.c b/drivers/usb/gadget/function/f_ecm.c
>> index 4c488d15b6f6..01150f7864c7 100644
>> --- a/drivers/usb/gadget/function/f_ecm.c
>> +++ b/drivers/usb/gadget/function/f_ecm.c
>> @@ -584,6 +584,8 @@ static int ecm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
>>  			 */
>>  			ecm->port.is_zlp_ok =
>>  				gadget_is_zlp_supported(cdev->gadget);
>> +			ecm->port.no_skb_reserve =
>> +				gadget_avoids_skb_reserve(cdev->gadget);
>>  			ecm->port.cdc_filter = DEFAULT_FILTER;
>>  			DBG(cdev, "activate ecm\n");
>>  			net = gether_connect(&ecm->port);
>> diff --git a/drivers/usb/gadget/function/f_eem.c b/drivers/usb/gadget/function/f_eem.c
>> index 007ec6e4a5d4..3b70b9ccfd2d 100644
>> --- a/drivers/usb/gadget/function/f_eem.c
>> +++ b/drivers/usb/gadget/function/f_eem.c
>> @@ -215,6 +215,8 @@ static int eem_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
>>  		 */
>>  		eem->port.is_zlp_ok = 1;
>>  		eem->port.cdc_filter = DEFAULT_FILTER;
>> +		eem->port.no_skb_reserve =
>> +				gadget_avoids_skb_reserve(cdev->gadget);
>>  		DBG(cdev, "activate eem\n");
>>  		net = gether_connect(&eem->port);
>>  		if (IS_ERR(net))
>> diff --git a/drivers/usb/gadget/function/f_rndis.c b/drivers/usb/gadget/function/f_rndis.c
>> index 16562e461121..1b379c051a84 100644
>> --- a/drivers/usb/gadget/function/f_rndis.c
>> +++ b/drivers/usb/gadget/function/f_rndis.c
>> @@ -593,6 +593,10 @@ static int rndis_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
>>  		 */
>>  		rndis->port.cdc_filter = 0;
>>  
>> +		/* Setup DMA alignment workaround for UDC's that need it */
>> +		rndis->port.no_skb_reserve =
>> +				gadget_avoids_skb_reserve(cdev->gadget);
>> +
> 
> You may add above comments for other two changes.
> 

Yeah, but I haven't added a comment there for consistency.

Patch

diff --git a/drivers/usb/gadget/function/f_ecm.c b/drivers/usb/gadget/function/f_ecm.c
index 4c488d15b6f6..01150f7864c7 100644
--- a/drivers/usb/gadget/function/f_ecm.c
+++ b/drivers/usb/gadget/function/f_ecm.c
@@ -584,6 +584,8 @@  static int ecm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
 			 */
 			ecm->port.is_zlp_ok =
 				gadget_is_zlp_supported(cdev->gadget);
+			ecm->port.no_skb_reserve =
+				gadget_avoids_skb_reserve(cdev->gadget);
 			ecm->port.cdc_filter = DEFAULT_FILTER;
 			DBG(cdev, "activate ecm\n");
 			net = gether_connect(&ecm->port);
diff --git a/drivers/usb/gadget/function/f_eem.c b/drivers/usb/gadget/function/f_eem.c
index 007ec6e4a5d4..3b70b9ccfd2d 100644
--- a/drivers/usb/gadget/function/f_eem.c
+++ b/drivers/usb/gadget/function/f_eem.c
@@ -215,6 +215,8 @@  static int eem_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
 		 */
 		eem->port.is_zlp_ok = 1;
 		eem->port.cdc_filter = DEFAULT_FILTER;
+		eem->port.no_skb_reserve =
+				gadget_avoids_skb_reserve(cdev->gadget);
 		DBG(cdev, "activate eem\n");
 		net = gether_connect(&eem->port);
 		if (IS_ERR(net))
diff --git a/drivers/usb/gadget/function/f_rndis.c b/drivers/usb/gadget/function/f_rndis.c
index 16562e461121..1b379c051a84 100644
--- a/drivers/usb/gadget/function/f_rndis.c
+++ b/drivers/usb/gadget/function/f_rndis.c
@@ -593,6 +593,10 @@  static int rndis_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
 		 */
 		rndis->port.cdc_filter = 0;
 
+		/* Setup DMA alignment workaround for UDC's that need it */
+		rndis->port.no_skb_reserve =
+				gadget_avoids_skb_reserve(cdev->gadget);
+
 		DBG(cdev, "RNDIS RX/TX early activation ... \n");
 		net = gether_connect(&rndis->port);
 		if (IS_ERR(net))