public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Ivan Shapovalov <intelfx@intelfx.name>
To: linux-kernel@vger.kernel.org
Cc: "Ivan Shapovalov" <intelfx@intelfx.name>,
	"Bjørn Mork" <bjorn@mork.no>,
	"Andrew Lunn" <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Johan Hovold" <johan@kernel.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	netdev@vger.kernel.org, linux-usb@vger.kernel.org
Subject: [PATCH 5/5] USB: serial: qcserial: enable ZLP for non-QDL interfaces
Date: Sun, 17 Nov 2024 12:31:15 +0400	[thread overview]
Message-ID: <20241117083204.57738-5-intelfx@intelfx.name> (raw)
In-Reply-To: <20241117083204.57738-1-intelfx@intelfx.name>

This is a port of the corresponding change from the qcserial.c driver
distributed as part of the 9X50 SDK, tested using author's own EM7565
device.

The SDK qcserial.c driver enables ZLP unconditionally, however this was
found to break QDL mode (as exercised by the qmi-firmware-update tool
from libqmi[1], as well as the SDK-provided firmware update utility).
Thus, ZLP is limited to non-QDL interfaces.

[1]: https://www.freedesktop.org/wiki/Software/libqmi/

Signed-off-by: Ivan Shapovalov <intelfx@intelfx.name>
---
 drivers/usb/serial/qcserial.c | 36 ++++++++++++++++++++++-------------
 1 file changed, 23 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c
index b2ae0b16bc2b..d51d022d76b1 100644
--- a/drivers/usb/serial/qcserial.c
+++ b/drivers/usb/serial/qcserial.c
@@ -32,6 +32,11 @@ enum qcserial_layouts {
 	QCSERIAL_SWI_SDX55_RMNET = 7, /* Sierra Wireless SDX55 */
 };
 
+enum qcserial_flags {
+	QC_SENDSETUP = (1 << 0),
+	QC_ZLP = (1 << 1),
+};
+
 #define DEVICE_G1K(v, p) \
 	USB_DEVICE(v, p), .driver_info = QCSERIAL_G1K
 #define DEVICE_SWI(v, p) \
@@ -262,7 +267,7 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
 	__u8 nintf;
 	__u8 ifnum;
 	int altsetting = -1;
-	bool sendsetup = false;
+	unsigned long flags = 0;
 
 	/* we only support vendor specific functions */
 	if (intf->desc.bInterfaceClass != USB_CLASS_VENDOR_SPEC)
@@ -301,6 +306,9 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
 	/* default to enabling interface */
 	altsetting = 0;
 
+	/* default to enabling ZLP */
+	flags |= QC_ZLP;
+
 	/*
 	 * Composite mode; don't bind to the QMI/net interface as that
 	 * gets handled by other drivers.
@@ -386,11 +394,11 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
 			break;
 		case 2:
 			dev_dbg(dev, "NMEA GPS interface found\n");
-			sendsetup = true;
+			flags |= QC_SENDSETUP;
 			break;
 		case 3:
 			dev_dbg(dev, "Modem port found\n");
-			sendsetup = true;
+			flags |= QC_SENDSETUP;
 			break;
 		default:
 			/* don't claim any unsupported interface */
@@ -446,11 +454,11 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
 		switch (ifnum) {
 		case 2:
 			dev_dbg(dev, "Modem port found\n");
-			sendsetup = true;
+			flags |= QC_SENDSETUP;
 			break;
 		case 3:
 			dev_dbg(dev, "NMEA GPS interface found\n");
-			sendsetup = true;
+			flags |= QC_SENDSETUP;
 			break;
 		case 4:
 			dev_dbg(dev, "DM/DIAG interface found\n");
@@ -475,11 +483,11 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
 		switch (ifnum) {
 		case 0:
 			dev_dbg(dev, "Modem port found\n");
-			sendsetup = true;
+			flags |= QC_SENDSETUP;
 			break;
 		case 1:
 			dev_dbg(dev, "NMEA GPS interface found\n");
-			sendsetup = true;
+			flags |= QC_SENDSETUP;
 			break;
 		case 2:
 			dev_dbg(dev, "DM/DIAG interface found\n");
@@ -502,7 +510,7 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
 		switch (ifnum) {
 		case 3:
 			dev_dbg(dev, "Modem port found\n");
-			sendsetup = true;
+			flags |= QC_SENDSETUP;
 			break;
 		case 4:
 			dev_dbg(dev, "DM/DIAG interface found\n");
@@ -522,7 +530,7 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
 		switch (ifnum) {
 		case 1:
 			dev_dbg(dev, "Modem port found\n");
-			sendsetup = true;
+			flags |= QC_SENDSETUP;
 			break;
 		case 2:
 			dev_dbg(dev, "DM/DIAG interface found\n");
@@ -551,7 +559,7 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
 	}
 
 	if (!retval)
-		usb_set_serial_data(serial, (void *)(unsigned long)sendsetup);
+		usb_set_serial_data(serial, (void *)flags);
 
 	return retval;
 }
@@ -559,15 +567,17 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
 static int qc_attach(struct usb_serial *serial)
 {
 	struct usb_wwan_intf_private *data;
-	bool sendsetup;
+	unsigned long flags = 0;
 
 	data = kzalloc(sizeof(*data), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
 
-	sendsetup = !!(unsigned long)(usb_get_serial_data(serial));
-	if (sendsetup)
+	flags = (unsigned long)(usb_get_serial_data(serial));
+	if (flags & QC_SENDSETUP)
 		data->use_send_setup = 1;
+	if (flags & QC_ZLP)
+		data->use_zlp = 1;
 
 	spin_lock_init(&data->susp_lock);
 
-- 
2.47.0.5.gd823fa0eac


  parent reply	other threads:[~2024-11-17  8:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-17  8:31 [PATCH 1/5] net: usb: qmi_wwan: add IDs for EM7565 (9X50) in "MBIM USBIF" config Ivan Shapovalov
2024-11-17  8:31 ` [PATCH 2/5] USB: serial: qcserial: add EM7565 (9X50) IDs and configurations Ivan Shapovalov
2024-11-17  8:31 ` [PATCH 3/5] USB: serial: qcserial: add EM9xxx (SDX55) " Ivan Shapovalov
2024-11-17  8:31 ` [PATCH 4/5] USB: serial: qcserial: disable autosuspend for QDL configurations Ivan Shapovalov
2024-11-17  8:31 ` Ivan Shapovalov [this message]
2024-11-19  4:55 ` [PATCH 1/5] net: usb: qmi_wwan: add IDs for EM7565 (9X50) in "MBIM USBIF" config Lars Melin

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=20241117083204.57738-5-intelfx@intelfx.name \
    --to=intelfx@intelfx.name \
    --cc=andrew+netdev@lunn.ch \
    --cc=bjorn@mork.no \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=johan@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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