* [PATCH V3] Set NTB format again after altsetting switch for Huawei devices
@ 2017-07-11 15:21 Enrico Mioso
2017-07-11 21:04 ` Oliver Neukum
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Enrico Mioso @ 2017-07-11 15:21 UTC (permalink / raw)
Cc: Enrico Mioso, Bjørn Mork, Christian Panton,
linux-usb-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
Oliver Neukum
Some firmwares in Huawei E3372H devices have been observed to switch back
to NTB 32-bit format after altsetting switch.
This patch implements a driver flag to check for the device settings and
set NTB format to 16-bit again if needed.
The flag has been activated for devices controlled by the huawei_cdc_ncm.c
driver.
V1->V2:
- fixed broken error checks
- some corrections to the commit message
V2->V3:
- variable name changes, to clarify what's happening
- check (and possibly set) the NTB format later in the common bind code path
Signed-off-by: Enrico Mioso <mrkiko.rs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Reported-and-tested-by: Christian Panton <christian-urZh+a7hbKEdnm+yROfE0A@public.gmane.org>
Reviewed-by: Bjørn Mork <bjorn-yOkvZcmFvRU@public.gmane.org>
CC: Bjørn Mork <bjorn-yOkvZcmFvRU@public.gmane.org>
CC: Christian Panton <christian-urZh+a7hbKEdnm+yROfE0A@public.gmane.org>
CC: linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
CC: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
CC: Oliver Neukum <oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
---
drivers/net/usb/cdc_ncm.c | 28 ++++++++++++++++++++++++++++
drivers/net/usb/huawei_cdc_ncm.c | 6 ++++++
include/linux/usb/cdc_ncm.h | 1 +
3 files changed, 35 insertions(+)
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index d103a1d4fb36..8f572b9f3625 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -768,8 +768,10 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
u8 *buf;
int len;
int temp;
+ int err;
u8 iface_no;
struct usb_cdc_parsed_header hdr;
+ u16 curr_ntb_format;
ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
if (!ctx)
@@ -874,6 +876,32 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
goto error2;
}
+ /*
+ * Some Huawei devices have been observed to come out of reset in NDP32 mode.
+ * Let's check if this is the case, and set the device to NDP16 mode again if
+ * needed.
+ */
+ if (ctx->drvflags & CDC_NCM_FLAG_RESET_NTB16) {
+ err = usbnet_read_cmd(dev, USB_CDC_GET_NTB_FORMAT,
+ USB_TYPE_CLASS | USB_DIR_IN | USB_RECIP_INTERFACE,
+ 0, iface_no, &curr_ntb_format, 2);
+ if (err < 0) {
+ goto error2;
+ }
+
+ if (curr_ntb_format == USB_CDC_NCM_NTB32_FORMAT) {
+ dev_info(&intf->dev, "resetting NTB format to 16-bit");
+ err = usbnet_write_cmd(dev, USB_CDC_SET_NTB_FORMAT,
+ USB_TYPE_CLASS | USB_DIR_OUT
+ | USB_RECIP_INTERFACE,
+ USB_CDC_NCM_NTB16_FORMAT,
+ iface_no, NULL, 0);
+
+ if (err < 0)
+ goto error2;
+ }
+ }
+
cdc_ncm_find_endpoints(dev, ctx->data);
cdc_ncm_find_endpoints(dev, ctx->control);
if (!dev->in || !dev->out || !dev->status) {
diff --git a/drivers/net/usb/huawei_cdc_ncm.c b/drivers/net/usb/huawei_cdc_ncm.c
index 2680a65cd5e4..63f28908afda 100644
--- a/drivers/net/usb/huawei_cdc_ncm.c
+++ b/drivers/net/usb/huawei_cdc_ncm.c
@@ -80,6 +80,12 @@ static int huawei_cdc_ncm_bind(struct usbnet *usbnet_dev,
* be at the end of the frame.
*/
drvflags |= CDC_NCM_FLAG_NDP_TO_END;
+
+ /* Additionally, it has been reported that some Huawei E3372H devices, with
+ * firmware version 21.318.01.00.541, come out of reset in NTB32 format mode, hence
+ * needing to be set to the NTB16 one again.
+ */
+ drvflags |= CDC_NCM_FLAG_RESET_NTB16;
ret = cdc_ncm_bind_common(usbnet_dev, intf, 1, drvflags);
if (ret)
goto err;
diff --git a/include/linux/usb/cdc_ncm.h b/include/linux/usb/cdc_ncm.h
index 021f7a88f52c..1a59699cf82a 100644
--- a/include/linux/usb/cdc_ncm.h
+++ b/include/linux/usb/cdc_ncm.h
@@ -83,6 +83,7 @@
/* Driver flags */
#define CDC_NCM_FLAG_NDP_TO_END 0x02 /* NDP is placed at end of frame */
#define CDC_MBIM_FLAG_AVOID_ALTSETTING_TOGGLE 0x04 /* Avoid altsetting toggle during init */
+#define CDC_NCM_FLAG_RESET_NTB16 0x08 /* set NDP16 one more time after altsetting switch */
#define cdc_ncm_comm_intf_is_mbim(x) ((x)->desc.bInterfaceSubClass == USB_CDC_SUBCLASS_MBIM && \
(x)->desc.bInterfaceProtocol == USB_CDC_PROTO_NONE)
--
2.13.2
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH V3] Set NTB format again after altsetting switch for Huawei devices
2017-07-11 15:21 [PATCH V3] Set NTB format again after altsetting switch for Huawei devices Enrico Mioso
@ 2017-07-11 21:04 ` Oliver Neukum
[not found] ` <1499806256.29772.1.camel@neukum.org>
2017-07-14 15:15 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Oliver Neukum @ 2017-07-11 21:04 UTC (permalink / raw)
To: Enrico Mioso; +Cc: Bjørn Mork, Christian Panton, linux-usb, netdev
Am Dienstag, den 11.07.2017, 17:21 +0200 schrieb Enrico Mioso:
>
> Some firmwares in Huawei E3372H devices have been observed to switch back
> to NTB 32-bit format after altsetting switch.
> This patch implements a driver flag to check for the device settings and
> set NTB format to 16-bit again if needed.
> The flag has been activated for devices controlled by the huawei_cdc_ncm.c
> driver.
Hi,
does this cover reset_resume()?
Regards
Oliver
^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <1499806256.29772.1.camel@neukum.org>]
* Re: [PATCH V3] Set NTB format again after altsetting switch for Huawei devices
[not found] ` <1499806256.29772.1.camel@neukum.org>
@ 2017-07-11 21:14 ` Bjørn Mork
0 siblings, 0 replies; 4+ messages in thread
From: Bjørn Mork @ 2017-07-11 21:14 UTC (permalink / raw)
To: Oliver Neukum; +Cc: Enrico Mioso, Christian Panton, linux-usb, netdev
Oliver Neukum <oliver@neukum.org> writes:
> Am Dienstag, den 11.07.2017, 17:21 +0200 schrieb Enrico Mioso:
>> Some firmwares in Huawei E3372H devices have been observed to switch back
>> to NTB 32-bit format after altsetting switch.
>> This patch implements a driver flag to check for the device settings and
>> set NTB format to 16-bit again if needed.
>> The flag has been activated for devices controlled by the huawei_cdc_ncm.c
>> driver.
>
> Hi,
>
> does this cover reset_resume()?
AFAIK reset_resume doesn't really work for 3G/LTE modems. Too much
state to restore both in firmware and network, with no well defined
protocol to restore it.
The only reason for having reset_resume in the modem drivers is that
quite a few modems have an SD reader. We need to support persist for the
usb-storage function, even if the modem functions fail. There is no
reason to mess up the file system too.
Bjørn
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH V3] Set NTB format again after altsetting switch for Huawei devices
2017-07-11 15:21 [PATCH V3] Set NTB format again after altsetting switch for Huawei devices Enrico Mioso
2017-07-11 21:04 ` Oliver Neukum
[not found] ` <1499806256.29772.1.camel@neukum.org>
@ 2017-07-14 15:15 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2017-07-14 15:15 UTC (permalink / raw)
To: mrkiko.rs; +Cc: bjorn, christian, linux-usb, netdev, oliver
From: Enrico Mioso <mrkiko.rs@gmail.com>
Date: Tue, 11 Jul 2017 17:21:52 +0200
> Some firmwares in Huawei E3372H devices have been observed to switch back
> to NTB 32-bit format after altsetting switch.
> This patch implements a driver flag to check for the device settings and
> set NTB format to 16-bit again if needed.
> The flag has been activated for devices controlled by the huawei_cdc_ncm.c
> driver.
>
> V1->V2:
> - fixed broken error checks
> - some corrections to the commit message
> V2->V3:
> - variable name changes, to clarify what's happening
> - check (and possibly set) the NTB format later in the common bind code path
>
> Signed-off-by: Enrico Mioso <mrkiko.rs@gmail.com>
> Reported-and-tested-by: Christian Panton <christian@panton.org>
> Reviewed-by: Bjørn Mork <bjorn@mork.no>
Applied, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-07-14 15:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-11 15:21 [PATCH V3] Set NTB format again after altsetting switch for Huawei devices Enrico Mioso
2017-07-11 21:04 ` Oliver Neukum
[not found] ` <1499806256.29772.1.camel@neukum.org>
2017-07-11 21:14 ` Bjørn Mork
2017-07-14 15:15 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).