All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] USB: serial: option: support dynamic Quectel USB compositions
@ 2020-08-29 13:42 Bjørn Mork
  2020-08-29 21:59 ` Sasha Levin
  2020-08-31  6:44 ` Johan Hovold
  0 siblings, 2 replies; 3+ messages in thread
From: Bjørn Mork @ 2020-08-29 13:42 UTC (permalink / raw)
  To: Johan Hovold
  Cc: linux-usb, Bjørn Mork, AceLan Kao, Sebastian Sjoholm,
	Dan Williams, stable

The USB composition, defining the set of exported functions, is dynamic
in newer Quectel modems.  Default functions can be disabled and
alternative functions can be enabled instead.  The alternatives
includes class functions using interface pairs, which should be
handled by the respective class drivers.

Active interfaces are numbered consecutively, so static
blacklisting based on interface numbers will fail when the
composition changes.  An example of such an error, where the
option driver has bound to the CDC ECM data interface,
preventing cdc_ether from handling this function:

 T: Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=480 MxCh= 0
 D: Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs= 1
 P: Vendor=2c7c ProdID=0125 Rev= 3.18
 S: Manufacturer=Quectel
 S: Product=EC25-AF
 C:* #Ifs= 6 Cfg#= 1 Atr=a0 MxPwr=500mA
 A: FirstIf#= 4 IfCount= 2 Cls=02(comm.) Sub=06 Prot=00
 I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
 E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 I:* If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
 E: Ad=83(I) Atr=03(Int.) MxPS= 10 Ivl=32ms
 E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
 E: Ad=85(I) Atr=03(Int.) MxPS= 10 Ivl=32ms
 E: Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
 E: Ad=87(I) Atr=03(Int.) MxPS= 10 Ivl=32ms
 E: Ad=86(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 I:* If#= 4 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=06 Prot=00 Driver=(none)
 E: Ad=89(I) Atr=03(Int.) MxPS= 16 Ivl=32ms
 I:* If#= 5 Alt= 0 #EPs= 0 Cls=0a(data ) Sub=00 Prot=00 Driver=option
 I: If#= 5 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=option
 E: Ad=88(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 E: Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms

Another device with the same id gets correct drivers, since the
interface of the network function happens to be blacklisted by option:

 T: Bus=01 Lev=02 Prnt=02 Port=01 Cnt=01 Dev#= 3 Spd=480 MxCh= 0
 D: Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs= 1
 P: Vendor=2c7c ProdID=0125 Rev= 3.18
 S: Manufacturer=Android
 S: Product=Android
 C:* #Ifs= 5 Cfg#= 1 Atr=a0 MxPwr=500mA
 I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
 E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 I:* If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
 E: Ad=83(I) Atr=03(Int.) MxPS= 10 Ivl=32ms
 E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
 E: Ad=85(I) Atr=03(Int.) MxPS= 10 Ivl=32ms
 E: Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
 E: Ad=87(I) Atr=03(Int.) MxPS= 10 Ivl=32ms
 E: Ad=86(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 I:* If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=qmi_wwan
 E: Ad=89(I) Atr=03(Int.) MxPS= 8 Ivl=32ms
 E: Ad=88(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
 E: Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms

Change rules for EC21, EC25, BG96 and EG95 to match vendor specific
serial functions only, to prevent binding to class functions. Require
2 endpoints on ff/ff/ff functions, avoiding the 3 endpoint QMI/RMNET
network functions.

Cc: AceLan Kao <acelan.kao@canonical.com>
Cc: Sebastian Sjoholm <ssjoholm@mac.com>
Cc: Dan Williams <dcbw@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Bjørn Mork <bjorn@mork.no>
---
 drivers/usb/serial/option.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 89b3192af326..6c3ece5dd9c9 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -1094,14 +1094,18 @@ static const struct usb_device_id option_ids[] = {
 	{ USB_DEVICE(QUALCOMM_VENDOR_ID, UBLOX_PRODUCT_R410M),
 	  .driver_info = RSVD(1) | RSVD(3) },
 	/* Quectel products using Quectel vendor ID */
-	{ USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC21),
-	  .driver_info = RSVD(4) },
-	{ USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC25),
-	  .driver_info = RSVD(4) },
-	{ USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EG95),
-	  .driver_info = RSVD(4) },
-	{ USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96),
-	  .driver_info = RSVD(4) },
+	{ USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC21, 0xff, 0xff, 0xff),
+	  .driver_info = NUMEP2 },
+	{ USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC21, 0xff, 0, 0) },
+	{ USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC25, 0xff, 0xff, 0xff),
+	  .driver_info = NUMEP2 },
+	{ USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC25, 0xff, 0, 0) },
+	{ USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EG95, 0xff, 0xff, 0xff),
+	  .driver_info = NUMEP2 },
+	{ USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EG95, 0xff, 0, 0) },
+	{ USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96, 0xff, 0xff, 0xff),
+	  .driver_info = NUMEP2 },
+	{ USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96, 0xff, 0, 0) },
 	{ USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06, 0xff, 0xff, 0xff),
 	  .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) },
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] USB: serial: option: support dynamic Quectel USB compositions
  2020-08-29 13:42 [PATCH] USB: serial: option: support dynamic Quectel USB compositions Bjørn Mork
@ 2020-08-29 21:59 ` Sasha Levin
  2020-08-31  6:44 ` Johan Hovold
  1 sibling, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2020-08-29 21:59 UTC (permalink / raw)
  To: Sasha Levin, Bjørn Mork, Johan Hovold
  Cc: linux-usb, AceLan Kao, Sebastian Sjoholm, Dan Williams, stable, stable

Hi

[This is an automated email]

This commit has been processed because it contains a -stable tag.
The stable tag indicates that it's relevant for the following trees: all

The bot has tested the following trees: v5.8.5, v5.4.61, v4.19.142, v4.14.195, v4.9.234, v4.4.234.

v5.8.5: Build OK!
v5.4.61: Build OK!
v4.19.142: Build OK!
v4.14.195: Build OK!
v4.9.234: Failed to apply! Possible dependencies:
    35aecc02b5b6 ("USB: serial: option: add two-endpoints device-id flag")
    36cae568404a ("USB: serial: option: improve Quectel EP06 detection")

v4.4.234: Failed to apply! Possible dependencies:
    35aecc02b5b6 ("USB: serial: option: add two-endpoints device-id flag")
    36cae568404a ("USB: serial: option: improve Quectel EP06 detection")


NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

-- 
Thanks
Sasha

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] USB: serial: option: support dynamic Quectel USB compositions
  2020-08-29 13:42 [PATCH] USB: serial: option: support dynamic Quectel USB compositions Bjørn Mork
  2020-08-29 21:59 ` Sasha Levin
@ 2020-08-31  6:44 ` Johan Hovold
  1 sibling, 0 replies; 3+ messages in thread
From: Johan Hovold @ 2020-08-31  6:44 UTC (permalink / raw)
  To: Bjørn Mork
  Cc: Johan Hovold, linux-usb, AceLan Kao, Sebastian Sjoholm,
	Dan Williams, stable

On Sat, Aug 29, 2020 at 03:42:50PM +0200, Bjørn Mork wrote:
> The USB composition, defining the set of exported functions, is dynamic
> in newer Quectel modems.  Default functions can be disabled and
> alternative functions can be enabled instead.  The alternatives
> includes class functions using interface pairs, which should be
> handled by the respective class drivers.
> 
> Active interfaces are numbered consecutively, so static
> blacklisting based on interface numbers will fail when the
> composition changes.  An example of such an error, where the
> option driver has bound to the CDC ECM data interface,
> preventing cdc_ether from handling this function:
> 
>  T: Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=480 MxCh= 0
>  D: Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs= 1
>  P: Vendor=2c7c ProdID=0125 Rev= 3.18
>  S: Manufacturer=Quectel
>  S: Product=EC25-AF
>  C:* #Ifs= 6 Cfg#= 1 Atr=a0 MxPwr=500mA
>  A: FirstIf#= 4 IfCount= 2 Cls=02(comm.) Sub=06 Prot=00
>  I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
>  E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
>  E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
>  I:* If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
>  E: Ad=83(I) Atr=03(Int.) MxPS= 10 Ivl=32ms
>  E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
>  E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
>  I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
>  E: Ad=85(I) Atr=03(Int.) MxPS= 10 Ivl=32ms
>  E: Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
>  E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
>  I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
>  E: Ad=87(I) Atr=03(Int.) MxPS= 10 Ivl=32ms
>  E: Ad=86(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
>  E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
>  I:* If#= 4 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=06 Prot=00 Driver=(none)
>  E: Ad=89(I) Atr=03(Int.) MxPS= 16 Ivl=32ms
>  I:* If#= 5 Alt= 0 #EPs= 0 Cls=0a(data ) Sub=00 Prot=00 Driver=option
>  I: If#= 5 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=option
>  E: Ad=88(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
>  E: Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
> 
> Another device with the same id gets correct drivers, since the
> interface of the network function happens to be blacklisted by option:
> 
>  T: Bus=01 Lev=02 Prnt=02 Port=01 Cnt=01 Dev#= 3 Spd=480 MxCh= 0
>  D: Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs= 1
>  P: Vendor=2c7c ProdID=0125 Rev= 3.18
>  S: Manufacturer=Android
>  S: Product=Android
>  C:* #Ifs= 5 Cfg#= 1 Atr=a0 MxPwr=500mA
>  I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
>  E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
>  E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
>  I:* If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
>  E: Ad=83(I) Atr=03(Int.) MxPS= 10 Ivl=32ms
>  E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
>  E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
>  I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
>  E: Ad=85(I) Atr=03(Int.) MxPS= 10 Ivl=32ms
>  E: Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
>  E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
>  I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
>  E: Ad=87(I) Atr=03(Int.) MxPS= 10 Ivl=32ms
>  E: Ad=86(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
>  E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
>  I:* If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=qmi_wwan
>  E: Ad=89(I) Atr=03(Int.) MxPS= 8 Ivl=32ms
>  E: Ad=88(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
>  E: Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
> 
> Change rules for EC21, EC25, BG96 and EG95 to match vendor specific
> serial functions only, to prevent binding to class functions. Require
> 2 endpoints on ff/ff/ff functions, avoiding the 3 endpoint QMI/RMNET
> network functions.
> 
> Cc: AceLan Kao <acelan.kao@canonical.com>
> Cc: Sebastian Sjoholm <ssjoholm@mac.com>
> Cc: Dan Williams <dcbw@redhat.com>
> Cc: stable@vger.kernel.org
> Signed-off-by: Bjørn Mork <bjorn@mork.no>

Thanks, Bjørn. Now applied.

Johan

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-31  6:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-29 13:42 [PATCH] USB: serial: option: support dynamic Quectel USB compositions Bjørn Mork
2020-08-29 21:59 ` Sasha Levin
2020-08-31  6:44 ` Johan Hovold

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.