Skip to contentSkip to conversation

usb: serial: option: Fix the lackage for Quectel EG95 LTE modem support

PATCH Superseded William Sung 3 participants 4 messages Sep 1, 2020 – Sep 18, 2020

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#1 lore raw

PATCH 2/2 usb: serial: usb_wwan: Fix lackage for Quectel EG95 LTE modem support

In reply to William Sung

As required by the USB protocol, add zero packet support for Quectel EG95 LTE modem module.

Fixes f815dd5cf48b ("net: usb: qmi_wwan: add support for Quectel EG95

LTE modem"

---
 drivers/usb/serial/usb_wwan.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/usb/serial/usb_wwan.c +10 -2
index 4b9845807bee..75495c939ac6 100644
@@ -467,6 +467,7 @@ static struct urb *usb_wwan_setup_urb(struct usb_serial_port *port,
 	struct usb_serial *serial = port->serial;
 	struct usb_wwan_intf_private *intfdata = usb_get_serial_data(serial);
 	struct urb *urb;
+	struct usb_device_descriptor *desc = &serial->dev->descriptor;
 
 	urb = usb_alloc_urb(0, GFP_KERNEL);	/* No ISO */
 	if (!urb)
@@ -476,8 +477,15 @@ static struct urb *usb_wwan_setup_urb(struct usb_serial_port *port,
 			  usb_sndbulkpipe(serial->dev, endpoint) | dir,
 			  buf, len, callback, ctx);
 
-	if (intfdata->use_zlp && dir == USB_DIR_OUT)
-		urb->transfer_flags |= URB_ZERO_PACKET;
+	if (dir == USB_DIR_OUT) {
+		if (intfdata->use_zlp)
+			urb->transfer_flags |= URB_ZERO_PACKET;
+
+		/* Add zero packet support for Quectel EG95 */
+		if (desc->idVendor == cpu_to_le16(0x2C7C) &&
+			desc->idProduct == cpu_to_le16(0x0195))
+			urb->transfer_flags |= URB_ZERO_PACKET;
+	}
 
 	return urb;
 }
Signature · 1 line
2.17.1
#0 lore raw

PATCH 1/2 usb: serial: option: Fix the lackage for Quectel EG95 LTE modem support

* Add reset-resume callback for resetting USB devices after MCU exits from suspend/sleep mode.

* Because Quectel EG95 uses USB interface 4 as a USB network device, so return from option_startup() to prevent being used as a USB serial device.

Fixes da6902e5b6db ("USB: serial: option: add Quectel EG95 LTE modem"
---
 drivers/usb/serial/option.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/usb/serial/option.c +6 -0
index 89b3192af326..9de8aec47e5e 100644
@@ -2069,6 +2069,7 @@ static struct usb_serial_driver option_1port_device = {
 #ifdef CONFIG_PM
 	.suspend           = usb_wwan_suspend,
 	.resume            = usb_wwan_resume,
+	.reset_resume      = usb_wwan_resume,
 #endif
 };
 
@@ -2104,6 +2105,11 @@ static int option_probe(struct usb_serial *serial,
 	if (device_flags & NUMEP2 && iface_desc->bNumEndpoints != 2)
 		return -ENODEV;
 
+	/* Quectel EC25 & EC21 & EG91 & EG95 ... interface 4 can be used as USB network device */
+	if (serial->dev->descriptor.idVendor == cpu_to_le16(0x2c7c) &&
+		serial->interface->cur_altsetting->desc.bInterfaceNumber >= 4)
+		return -ENODEV;
+
 	/* Store the device flags so we can use them during attach. */
 	usb_set_serial_data(serial, (void *)device_flags);
 
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH 2/2] usb: serial: usb_wwan: Fix lackage for Quectel EG95 LTE modem support

In reply to William Sung

Hi William,

Il giorno mar 1 set 2020 alle ore 07:14 William Sung <[email protected]> ha scritto:

Quoted 6 lines

As required by the USB protocol, add zero packet support for Quectel EG95 LTE modem module.

Fixes f815dd5cf48b ("net: usb: qmi_wwan: add support for Quectel EG95

LTE modem"

If I'm not wrong, that commit is just related to qmi_wwan.

Quoted 23 lines
---
 drivers/usb/serial/usb_wwan.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/usb/serial/usb_wwan.c +1 -1
index 4b9845807bee..75495c939ac6 100644
@@ -467,6 +467,7 @@ static struct urb *usb_wwan_setup_urb(struct usb_serial_port *port,
        struct usb_serial *serial = port->serial;
        struct usb_wwan_intf_private *intfdata = usb_get_serial_data(serial);
        struct urb *urb;
+       struct usb_device_descriptor *desc = &serial->dev->descriptor;
 
        urb = usb_alloc_urb(0, GFP_KERNEL);     /* No ISO */
        if (!urb)
@@ -476,8 +477,15 @@ static struct urb *usb_wwan_setup_urb(struct usb_serial_port *port,
                          usb_sndbulkpipe(serial->dev, endpoint) | dir,
                          buf, len, callback, ctx);
 
-       if (intfdata->use_zlp && dir == USB_DIR_OUT)

drivers/usb/serial/usb_wwan.c static struct urb *usb_wwan_setup_urb(struct usb_serial_port *port, · line 488

Quoted 10 lines
drivers/usb/serial/usb_wwan.c +9 -1
-               urb->transfer_flags |= URB_ZERO_PACKET;
+       if (dir == USB_DIR_OUT) {
+               if (intfdata->use_zlp)
+                       urb->transfer_flags |= URB_ZERO_PACKET;
+
+               /* Add zero packet support for Quectel EG95 */
+               if (desc->idVendor == cpu_to_le16(0x2C7C) &&
+                       desc->idProduct == cpu_to_le16(0x0195))
+                       urb->transfer_flags |= URB_ZERO_PACKET;
+       }

Why not simply add the ZLP flag in option for that device?

Regards,
Daniele

Quoted 6 lines
drivers/usb/serial/usb_wwan.c +0 -1
        return urb;
 }
--

2.17.1

maintainer
#3 lore raw
In reply to William Sung
Quoted 2 lines · William Sung

* Add reset-resume callback for resetting USB devices after MCU exits from suspend/sleep mode.

Please split this in it's own patch and argue for why it's needed.

Quoted 24 lines

* Because Quectel EG95 uses USB interface 4 as a USB network device, so return from option_startup() to prevent being used as a USB serial device.

Fixes da6902e5b6db ("USB: serial: option: add Quectel EG95 LTE modem"
---
 drivers/usb/serial/option.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/usb/serial/option.c +1 -0
index 89b3192af326..9de8aec47e5e 100644
@@ -2069,6 +2069,7 @@ static struct usb_serial_driver option_1port_device = {
 #ifdef CONFIG_PM
 	.suspend           = usb_wwan_suspend,
 	.resume            = usb_wwan_resume,
+	.reset_resume      = usb_wwan_resume,
 #endif
 };
 

drivers/usb/serial/option.c static int option_probe(struct usb_serial *serial, · line 2111

Quoted 7 lines
drivers/usb/serial/option.c +4 -0
@@ -2104,6 +2105,11 @@ static int option_probe(struct usb_serial *serial,
 	if (device_flags & NUMEP2 && iface_desc->bNumEndpoints != 2)
 		return -ENODEV;
 
+	/* Quectel EC25 & EC21 & EG91 & EG95 ... interface 4 can be used as USB network device */
+	if (serial->dev->descriptor.idVendor == cpu_to_le16(0x2c7c) &&
+		serial->interface->cur_altsetting->desc.bInterfaceNumber >= 4)
+		return -ENODEV;

And please use the normal mechanisms for blacklisting interfaces (e.g. the RSVD() macro).

drivers/usb/serial/option.c static int option_probe(struct usb_serial *serial, · line 2114

Quoted 3 lines
drivers/usb/serial/option.c +1 -0
+
 	/* Store the device flags so we can use them during attach. */
 	usb_set_serial_data(serial, (void *)device_flags);

Also make sure your patches have distinct and descriptive summaries (Subject lines).

Johan