From: Johan Hovold <johan@kernel.org>
To: Daniele Palmas <dnlplm@gmail.com>
Cc: Johan Hovold <johan@kernel.org>, linux-usb@vger.kernel.org
Subject: Re: [PATCH RESEND 1/1] usb: serial: option: add ZLP support for 0x1bc7/0x9010
Date: Thu, 5 Dec 2019 15:57:31 +0100 [thread overview]
Message-ID: <20191205145731.GM10631@localhost> (raw)
In-Reply-To: <20191118133251.21401-1-dnlplm@gmail.com>
On Mon, Nov 18, 2019 at 02:32:51PM +0100, Daniele Palmas wrote:
> Telit FN980 flashing device 0x1bc7/0x9010 requires zero packet
> to be sent if out data size is equal to the endpoint max size.
>
> Signed-off-by: Daniele Palmas <dnlplm@gmail.com>
> ---
> drivers/usb/serial/option.c | 8 ++++++++
> drivers/usb/serial/usb-wwan.h | 1 +
> drivers/usb/serial/usb_wwan.c | 9 +++++++++
> 3 files changed, 18 insertions(+)
>
> diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
> index e9491d400a24..c13e063cb399 100644
> --- a/drivers/usb/serial/option.c
> +++ b/drivers/usb/serial/option.c
> @@ -567,6 +567,9 @@ static void option_instat_callback(struct urb *urb);
> /* Interface must have two endpoints */
> #define NUMEP2 BIT(16)
>
> +/* Device needs ZLP */
> +#define ZLP BIT(17)
> +
>
> static const struct usb_device_id option_ids[] = {
> { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
> @@ -1196,6 +1199,8 @@ static const struct usb_device_id option_ids[] = {
> .driver_info = NCTRL(0) | RSVD(1) },
> { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1901, 0xff), /* Telit LN940 (MBIM) */
> .driver_info = NCTRL(0) },
> + { USB_DEVICE(TELIT_VENDOR_ID, 0x9010), /* Telit SBL FN980 flashing device */
> + .driver_info = NCTRL(0) | ZLP },
Hmm. Could you post the lsusb -v output for this device?
I wonder whether using option is the right thing to do here. We're just
currently throwing everything modem related in here it seems. :)
> { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF622, 0xff, 0xff, 0xff) }, /* ZTE WCDMA products */
> { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0002, 0xff, 0xff, 0xff),
> .driver_info = RSVD(1) },
> @@ -2097,6 +2102,9 @@ static int option_attach(struct usb_serial *serial)
> if (!(device_flags & NCTRL(iface_desc->bInterfaceNumber)))
> data->use_send_setup = 1;
>
> + if (device_flags & ZLP)
> + data->use_zlp = 1;
> +
> spin_lock_init(&data->susp_lock);
>
> usb_set_serial_data(serial, data);
> diff --git a/drivers/usb/serial/usb-wwan.h b/drivers/usb/serial/usb-wwan.h
> index 1c120eaf4091..934e9361cf6b 100644
> --- a/drivers/usb/serial/usb-wwan.h
> +++ b/drivers/usb/serial/usb-wwan.h
> @@ -38,6 +38,7 @@ struct usb_wwan_intf_private {
> spinlock_t susp_lock;
> unsigned int suspended:1;
> unsigned int use_send_setup:1;
> + unsigned int use_zlp:1;
> int in_flight;
> unsigned int open_ports;
> void *private;
> diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c
> index 7e855c87e4f7..8066b5e2d305 100644
> --- a/drivers/usb/serial/usb_wwan.c
> +++ b/drivers/usb/serial/usb_wwan.c
> @@ -228,6 +228,15 @@ int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port,
> } else {
> intfdata->in_flight++;
> spin_unlock_irqrestore(&intfdata->susp_lock, flags);
> + if (intfdata->use_zlp) {
> + unsigned int ep_maxp;
> +
> + ep_maxp = usb_maxpacket(port->serial->dev,
> + this_urb->pipe, 1);
> +
> + if (ep_maxp && (todo % ep_maxp == 0))
> + this_urb->transfer_flags |= URB_ZERO_PACKET;
No need to do the transfer_length calculations here, the host-controller
driver will take care of that. Just set URB_ZERO_PACKET unconditionally
if the device requires it.
> + }
> err = usb_submit_urb(this_urb, GFP_ATOMIC);
> if (err) {
> dev_err(&port->dev,
Johan
next prev parent reply other threads:[~2019-12-05 14:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-18 13:32 [PATCH RESEND 1/1] usb: serial: option: add ZLP support for 0x1bc7/0x9010 Daniele Palmas
2019-11-28 18:12 ` Daniele Palmas
2019-11-28 18:18 ` Johan Hovold
2019-12-05 14:57 ` Johan Hovold [this message]
2019-12-05 16:06 ` Daniele Palmas
2019-12-06 15:43 ` Johan Hovold
2019-12-06 15:56 ` Daniele Palmas
2019-12-16 12:01 ` Johan Hovold
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=20191205145731.GM10631@localhost \
--to=johan@kernel.org \
--cc=dnlplm@gmail.com \
--cc=linux-usb@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).