This patch series contains backports for 4.14 of two patches that were submitted to stable, but failed to apply. One patch adds support for dynamic interface configuration on the Quectel EP06, while the other contains an upstream change triggered by the EP06-change.
The reason the patches failed to apply, is that option_probe() in option.c has been changed upstream. A slight reshuffling of the changes in "USB: serial: option: improve Quectel EP06 detection" was required. "USB: serial: option: add two-endpoints device-id flag" applied cleanly after the change, but a small change was still needed. The upstream commit removes a variable that is still in use in 4.14, so this change is removed.
Signed-off-by: Kristian Evensen kristian.evensen@gmail.com
Johan Hovold (1): USB: serial: option: add two-endpoints device-id flag
Kristian Evensen (1): USB: serial: option: improve Quectel EP06 detection
drivers/usb/serial/option.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
commit 36cae568404a298a19a6e8a3f18641075d4cab04 upstream
The Quectel EP06 (and EM06/EG06) LTE modem supports updating the USB configuration, without the VID/PID or configuration number changing. When the configuration is updated and interfaces are added/removed, the interface numbers are updated. This causes our current code for matching EP06 not to work as intended, as the assumption about reserved interfaces no longer holds. If for example the diagnostic (first) interface is removed, option will (try to) bind to the QMI interface.
This patch improves EP06 detection by replacing the current match with two matches, and those matches check class, subclass and protocol as well as VID and PID. The diag interface exports class, subclass and protocol as 0xff. For the other serial interfaces, class is 0xff and subclass and protocol are both 0x0.
The modem can export the following devices and always in this order: diag, nmea, at, ppp. qmi and adb. This means that diag can only ever be interface 0, and interface numbers 1-5 should be marked as reserved. The three other serial devices can have interface numbers 0-3, but I have not marked any interfaces as reserved. The reason is that the serial devices are the only interfaces exported by the device where subclass and protocol is 0x0.
QMI exports the same class, subclass and protocol values as the diag interface. However, the two interfaces have different number of endpoints, QMI has three and diag two. I have added a check for number of interfaces if VID/PID matches the EP06, and we ignore the device if number of interfaces equals three (and subclass is set).
The upstream commit does not apply cleanly to the 4.14-tree because of differences in option_probe(). In order to make the commit apply, a slight reshuffeling of the code was needed.
Signed-off-by: Kristian Evensen kristian.evensen@gmail.com Acked-by: Dan Williams dcbw@redhat.com [ johan: drop uneeded RSVD(5) for ADB ] Cc: stable stable@vger.kernel.org Signed-off-by: Johan Hovold johan@kernel.org Signed-off-by: Kristian Evensen kristian.evensen@gmail.com --- drivers/usb/serial/option.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index 0600dadd6..d8d3cb18e 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c @@ -1084,8 +1084,9 @@ static const struct usb_device_id option_ids[] = { .driver_info = RSVD(4) }, { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96), .driver_info = RSVD(4) }, - { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06), - .driver_info = RSVD(4) | RSVD(5) }, + { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06, 0xff, 0xff, 0xff), + .driver_info = RSVD(1) | RSVD(2) | RSVD(3) | RSVD(4) }, + { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06, 0xff, 0, 0) }, { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) }, { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) }, { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6003), @@ -2010,6 +2011,18 @@ static int option_probe(struct usb_serial *serial, iface_desc->bInterfaceClass != USB_CLASS_CDC_DATA) return -ENODEV;
+ /* + * Don't bind to the QMI device of the Quectel EP06/EG06/EM06. Class, + * subclass and protocol is 0xff for both the diagnostic port and the + * QMI interface, but the diagnostic port only has two endpoints (QMI + * has three). + */ + if (dev_desc->idVendor == cpu_to_le16(QUECTEL_VENDOR_ID) && + dev_desc->idProduct == cpu_to_le16(QUECTEL_PRODUCT_EP06) && + iface_desc->bInterfaceSubClass && iface_desc->bNumEndpoints == 3) { + return -ENODEV; + } + /* Store the device flags so we can use them during attach. */ usb_set_serial_data(serial, (void *)device_flags);
From: Johan Hovold johan@kernel.org
commit 35aecc02b5b621782111f64cbb032c7f6a90bb32 upstream
Allow matching on interfaces having two endpoints by adding a new device-id flag.
This allows for the handling of devices whose interface numbers can change (e.g. Quectel EP06) to be contained in the device-id table.
The upstream commit removes a variable that is still in use in the 4.14 version of the option-driver, so the removal is undone.
Tested-by: Kristian Evensen kristian.evensen@gmail.com Cc: stable stable@vger.kernel.org Signed-off-by: Johan Hovold johan@kernel.org Signed-off-by: Kristian Evensen kristian.evensen@gmail.com --- drivers/usb/serial/option.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index d8d3cb18e..392fddc80 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c @@ -564,6 +564,9 @@ static void option_instat_callback(struct urb *urb); /* Interface is reserved */ #define RSVD(ifnum) ((BIT(ifnum) & 0xff) << 0)
+/* Interface must have two endpoints */ +#define NUMEP2 BIT(16) +
static const struct usb_device_id option_ids[] = { { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, @@ -1085,7 +1088,7 @@ static const struct usb_device_id option_ids[] = { { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96), .driver_info = RSVD(4) }, { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06, 0xff, 0xff, 0xff), - .driver_info = RSVD(1) | RSVD(2) | RSVD(3) | RSVD(4) }, + .driver_info = RSVD(1) | RSVD(2) | RSVD(3) | RSVD(4) | NUMEP2 }, { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06, 0xff, 0, 0) }, { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) }, { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) }, @@ -2012,16 +2015,11 @@ static int option_probe(struct usb_serial *serial, return -ENODEV;
/* - * Don't bind to the QMI device of the Quectel EP06/EG06/EM06. Class, - * subclass and protocol is 0xff for both the diagnostic port and the - * QMI interface, but the diagnostic port only has two endpoints (QMI - * has three). + * Allow matching on bNumEndpoints for devices whose interface numbers + * can change (e.g. Quectel EP06). */ - if (dev_desc->idVendor == cpu_to_le16(QUECTEL_VENDOR_ID) && - dev_desc->idProduct == cpu_to_le16(QUECTEL_PRODUCT_EP06) && - iface_desc->bInterfaceSubClass && iface_desc->bNumEndpoints == 3) { + if (device_flags & NUMEP2 && iface_desc->bNumEndpoints != 2) return -ENODEV; - }
/* Store the device flags so we can use them during attach. */ usb_set_serial_data(serial, (void *)device_flags);
On Thu, Nov 01, 2018 at 08:52:45PM +0100, Kristian Evensen wrote:
This patch series contains backports for 4.14 of two patches that were submitted to stable, but failed to apply. One patch adds support for dynamic interface configuration on the Quectel EP06, while the other contains an upstream change triggered by the EP06-change.
The reason the patches failed to apply, is that option_probe() in option.c has been changed upstream. A slight reshuffling of the changes in "USB: serial: option: improve Quectel EP06 detection" was required. "USB: serial: option: add two-endpoints device-id flag" applied cleanly after the change, but a small change was still needed. The upstream commit removes a variable that is still in use in 4.14, so this change is removed.
Signed-off-by: Kristian Evensen kristian.evensen@gmail.com
Johan Hovold (1): USB: serial: option: add two-endpoints device-id flag
Kristian Evensen (1): USB: serial: option: improve Quectel EP06 detection
drivers/usb/serial/option.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
Queued both for 4.14, thank you.
-- Thanks, Sasha
linux-stable-mirror@lists.linaro.org