From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: "Bjørn Mork" <bjorn@mork.no>,
"Kristian Evensen" <kristian.evensen@gmail.com>,
"Aleksander Morgado" <aleksander@aleksander.es>,
"David S . Miller" <davem@davemloft.net>,
"Sasha Levin" <sashal@kernel.org>,
netdev@vger.kernel.org, linux-usb@vger.kernel.org
Subject: [PATCH AUTOSEL 5.4 11/50] qmi_wwan: unconditionally reject 2 ep interfaces
Date: Sat, 22 Feb 2020 21:21:56 -0500 [thread overview]
Message-ID: <20200223022235.1404-11-sashal@kernel.org> (raw)
In-Reply-To: <20200223022235.1404-1-sashal@kernel.org>
From: Bjørn Mork <bjorn@mork.no>
[ Upstream commit 00516d13d4cfa56ce39da144db2dbf08b09b9357 ]
We have been using the fact that the QMI and DIAG functions
usually are the only ones with class/subclass/protocol being
ff/ff/ff on Quectel modems. This has allowed us to match the
QMI function without knowing the exact interface number,
which can vary depending on firmware configuration.
The ability to silently reject the DIAG function, which is
usually handled by the option driver, is important for this
method to work. This is done based on the knowledge that it
has exactly 2 bulk endpoints. QMI function control interfaces
will have either 3 or 1 endpoint. This rule is universal so
the quirk condition can be removed.
The fixed layouts known from the Gobi1k and Gobi2k modems
have been gradually replaced by more dynamic layouts, and
many vendors now use configurable layouts without changing
device IDs. Renaming the class/subclass/protocol matching
macro makes it more obvious that this is now not Quectel
specific anymore.
Cc: Kristian Evensen <kristian.evensen@gmail.com>
Cc: Aleksander Morgado <aleksander@aleksander.es>
Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/usb/qmi_wwan.c | 42 ++++++++++++++------------------------
1 file changed, 15 insertions(+), 27 deletions(-)
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index 839cef720cf64..3b7a3b8a5e067 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -61,7 +61,6 @@ enum qmi_wwan_flags {
enum qmi_wwan_quirks {
QMI_WWAN_QUIRK_DTR = 1 << 0, /* needs "set DTR" request */
- QMI_WWAN_QUIRK_QUECTEL_DYNCFG = 1 << 1, /* check num. endpoints */
};
struct qmimux_hdr {
@@ -916,16 +915,6 @@ static const struct driver_info qmi_wwan_info_quirk_dtr = {
.data = QMI_WWAN_QUIRK_DTR,
};
-static const struct driver_info qmi_wwan_info_quirk_quectel_dyncfg = {
- .description = "WWAN/QMI device",
- .flags = FLAG_WWAN | FLAG_SEND_ZLP,
- .bind = qmi_wwan_bind,
- .unbind = qmi_wwan_unbind,
- .manage_power = qmi_wwan_manage_power,
- .rx_fixup = qmi_wwan_rx_fixup,
- .data = QMI_WWAN_QUIRK_DTR | QMI_WWAN_QUIRK_QUECTEL_DYNCFG,
-};
-
#define HUAWEI_VENDOR_ID 0x12D1
/* map QMI/wwan function by a fixed interface number */
@@ -946,14 +935,18 @@ static const struct driver_info qmi_wwan_info_quirk_quectel_dyncfg = {
#define QMI_GOBI_DEVICE(vend, prod) \
QMI_FIXED_INTF(vend, prod, 0)
-/* Quectel does not use fixed interface numbers on at least some of their
- * devices. We need to check the number of endpoints to ensure that we bind to
- * the correct interface.
+/* Many devices have QMI and DIAG functions which are distinguishable
+ * from other vendor specific functions by class, subclass and
+ * protocol all being 0xff. The DIAG function has exactly 2 endpoints
+ * and is silently rejected when probed.
+ *
+ * This makes it possible to match dynamically numbered QMI functions
+ * as seen on e.g. many Quectel modems.
*/
-#define QMI_QUIRK_QUECTEL_DYNCFG(vend, prod) \
+#define QMI_MATCH_FF_FF_FF(vend, prod) \
USB_DEVICE_AND_INTERFACE_INFO(vend, prod, USB_CLASS_VENDOR_SPEC, \
USB_SUBCLASS_VENDOR_SPEC, 0xff), \
- .driver_info = (unsigned long)&qmi_wwan_info_quirk_quectel_dyncfg
+ .driver_info = (unsigned long)&qmi_wwan_info_quirk_dtr
static const struct usb_device_id products[] = {
/* 1. CDC ECM like devices match on the control interface */
@@ -1059,10 +1052,10 @@ static const struct usb_device_id products[] = {
USB_DEVICE_AND_INTERFACE_INFO(0x03f0, 0x581d, USB_CLASS_VENDOR_SPEC, 1, 7),
.driver_info = (unsigned long)&qmi_wwan_info,
},
- {QMI_QUIRK_QUECTEL_DYNCFG(0x2c7c, 0x0125)}, /* Quectel EC25, EC20 R2.0 Mini PCIe */
- {QMI_QUIRK_QUECTEL_DYNCFG(0x2c7c, 0x0306)}, /* Quectel EP06/EG06/EM06 */
- {QMI_QUIRK_QUECTEL_DYNCFG(0x2c7c, 0x0512)}, /* Quectel EG12/EM12 */
- {QMI_QUIRK_QUECTEL_DYNCFG(0x2c7c, 0x0800)}, /* Quectel RM500Q-GL */
+ {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0125)}, /* Quectel EC25, EC20 R2.0 Mini PCIe */
+ {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0306)}, /* Quectel EP06/EG06/EM06 */
+ {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0512)}, /* Quectel EG12/EM12 */
+ {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0800)}, /* Quectel RM500Q-GL */
/* 3. Combined interface devices matching on interface number */
{QMI_FIXED_INTF(0x0408, 0xea42, 4)}, /* Yota / Megafon M100-1 */
@@ -1455,7 +1448,6 @@ static int qmi_wwan_probe(struct usb_interface *intf,
{
struct usb_device_id *id = (struct usb_device_id *)prod;
struct usb_interface_descriptor *desc = &intf->cur_altsetting->desc;
- const struct driver_info *info;
/* Workaround to enable dynamic IDs. This disables usbnet
* blacklisting functionality. Which, if required, can be
@@ -1491,12 +1483,8 @@ static int qmi_wwan_probe(struct usb_interface *intf,
* different. Ignore the current interface if the number of endpoints
* equals the number for the diag interface (two).
*/
- info = (void *)id->driver_info;
-
- if (info->data & QMI_WWAN_QUIRK_QUECTEL_DYNCFG) {
- if (desc->bNumEndpoints == 2)
- return -ENODEV;
- }
+ if (desc->bNumEndpoints == 2)
+ return -ENODEV;
return usbnet_probe(intf, id);
}
--
2.20.1
next prev parent reply other threads:[~2020-02-23 2:33 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-23 2:21 [PATCH AUTOSEL 5.4 01/50] ipmi:ssif: Handle a possible NULL pointer reference Sasha Levin
2020-02-23 2:21 ` [PATCH AUTOSEL 5.4 02/50] drm/msm: Set dma maximum segment size for mdss Sasha Levin
2020-02-23 2:21 ` [PATCH AUTOSEL 5.4 03/50] sched/core: Don't skip remote tick for idle CPUs Sasha Levin
2020-02-23 2:21 ` [PATCH AUTOSEL 5.4 04/50] timers/nohz: Update NOHZ load in remote tick Sasha Levin
2020-02-23 2:21 ` [PATCH AUTOSEL 5.4 05/50] sched/fair: Prevent unlimited runtime on throttled group Sasha Levin
2020-02-23 2:21 ` [PATCH AUTOSEL 5.4 06/50] dax: pass NOWAIT flag to iomap_apply Sasha Levin
2020-02-23 2:21 ` [PATCH AUTOSEL 5.4 07/50] mac80211: consider more elements in parsing CRC Sasha Levin
2020-02-23 2:21 ` [PATCH AUTOSEL 5.4 08/50] cfg80211: check wiphy driver existence for drvinfo report Sasha Levin
2020-02-23 2:21 ` [PATCH AUTOSEL 5.4 09/50] s390/zcrypt: fix card and queue total counter wrap Sasha Levin
2020-02-23 2:21 ` [PATCH AUTOSEL 5.4 10/50] qmi_wwan: re-add DW5821e pre-production variant Sasha Levin
2020-02-23 2:21 ` Sasha Levin [this message]
2020-02-23 2:21 ` [PATCH AUTOSEL 5.4 12/50] NFSv4: Fix races between open and dentry revalidation Sasha Levin
2020-02-23 2:21 ` [PATCH AUTOSEL 5.4 13/50] perf/smmuv3: Use platform_get_irq_optional() for wired interrupt Sasha Levin
2020-02-23 2:21 ` [PATCH AUTOSEL 5.4 14/50] arm/ftrace: Fix BE text poking Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 15/50] sched/psi: Fix OOB write when writing 0 bytes to PSI files Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 16/50] perf/x86/intel: Add Elkhart Lake support Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 17/50] perf/x86/cstate: Add Tremont support Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 18/50] perf/x86/msr: " Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 19/50] ceph: do not execute direct write in parallel if O_APPEND is specified Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 20/50] ARM: dts: sti: fixup sound frame-inversion for stihxxx-b2120.dtsi Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 21/50] drm/amd/display: Do not set optimized_require to false after plane disable Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 22/50] RDMA/siw: Remove unwanted WARN_ON in siw_cm_llp_data_ready() Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 23/50] drm/amd/display: Check engine is not NULL before acquiring Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 24/50] drm/amd/display: Limit minimum DPPCLK to 100MHz Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 25/50] drm/amd/display: Add initialitions for PLL2 clock source Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 26/50] amdgpu: Prevent build errors regarding soft/hard-float FP ABI tags Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 27/50] soc/tegra: fuse: Fix build with Tegra194 configuration Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 28/50] i40e: Fix the conditional for i40e_vc_validate_vqs_bitmaps Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 29/50] net: ena: fix potential crash when rxfh key is NULL Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 30/50] net: ena: fix uses of round_jiffies() Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 31/50] net: ena: add missing ethtool TX timestamping indication Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 32/50] net: ena: fix incorrect default RSS key Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 33/50] net: ena: rss: do not allocate key when not supported Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 34/50] net: ena: rss: fix failure to get indirection table Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 35/50] net: ena: rss: store hash function as values and not bits Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 36/50] net: ena: fix incorrectly saving queue numbers when setting RSS indirection table Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 37/50] net: ena: fix corruption of dev_idx_to_host_tbl Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 38/50] net: ena: ethtool: use correct value for crc32 hash Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 39/50] net: ena: ena-com.c: prevent NULL pointer dereference Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 40/50] enic: prevent waking up stopped tx queues over watchdog reset Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 41/50] ice: update Unit Load Status bitmask to check after reset Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 42/50] cifs: Fix mode output in debugging statements Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 43/50] bcache: ignore pending signals when creating gc and allocator thread Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 44/50] cfg80211: add missing policy for NL80211_ATTR_STATUS_CODE Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 45/50] mac80211: fix wrong 160/80+80 MHz setting Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 46/50] net: hns3: add management table after IMP reset Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 47/50] net: hns3: fix a copying IPv6 address error in hclge_fd_get_flow_tuples() Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 48/50] nvme/tcp: fix bug on double requeue when send fails Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 49/50] nvme: prevent warning triggered by nvme_stop_keep_alive Sasha Levin
2020-02-23 2:22 ` [PATCH AUTOSEL 5.4 50/50] nvme/pci: move cqe check after device shutdown Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200223022235.1404-11-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=aleksander@aleksander.es \
--cc=bjorn@mork.no \
--cc=davem@davemloft.net \
--cc=kristian.evensen@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).