From 640176fca2fcc846a72b4475fac0896fb2d13f8d Mon Sep 17 00:00:00 2001 From: Mayank Rana Date: Thu, 31 Jan 2019 10:53:23 -0800 Subject: [PATCH] usb: f_gsi: Send zero length packet for MBIM/GPS on cable connect Qmuxd bridge daemon is opening /dev/gps before USB enumerated with USB composition having GPS interface as part of it. This daemon performs EP_LOOKUP ioctl and encounters failure. It keeps retrying for some iterations, and later goes into sleep and doesn't perform any IOs. This results into no GPS related IOs between daemon and host side QMUXD driver. Hence this change sends zero length packet for MBIM (as QBI also faces same issue) and GPS interface when USB cable is connected and those interfaces are part of USB composition. Both QBI and Qmuxd bridge daemon are now wait for zero length packet as indication for change in USB cable status, and queries using GSI_MBIM_GPS_USB_STATUS IOCTL (newly added). Based on this IOCTL related response, both daemons performs read/write with created control devices. Change-Id: Ib47443fe0e473ab4e27facb3f2927b8c13966158 Signed-off-by: Mayank Rana --- drivers/usb/gadget/function/f_gsi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/function/f_gsi.c b/drivers/usb/gadget/function/f_gsi.c index 52f5835e60f6..ed45212fc218 100644 --- a/drivers/usb/gadget/function/f_gsi.c +++ b/drivers/usb/gadget/function/f_gsi.c @@ -1533,6 +1533,7 @@ static long gsi_ctrl_dev_ioctl(struct file *fp, unsigned int cmd, atomic_set(&c_port->ctrl_online, 1); break; case QTI_CTRL_GET_LINE_STATE: + case GSI_MBIM_GPS_USB_STATUS: val = atomic_read(&gsi->connected); if (gsi->prot_id == IPA_USB_RMNET) val = gsi->rmnet_dtr_status; @@ -2499,7 +2500,9 @@ static int gsi_set_alt(struct usb_function *f, unsigned int intf, atomic_set(&gsi->connected, 1); /* send 0 len pkt to qti to notify state change */ - if (gsi->prot_id == IPA_USB_DIAG) + if (gsi->prot_id == IPA_USB_DIAG || + gsi->prot_id == IPA_USB_GPS || + gsi->prot_id == IPA_USB_MBIM) gsi_ctrl_send_cpkt_tomodem(gsi, NULL, 0); return ret; @@ -2531,7 +2534,7 @@ static void gsi_disable(struct usb_function *f) } gsi_ctrl_clear_cpkt_queues(gsi, false); - /* send 0 len pkt to qti/qbi to notify state change */ + /* send 0 len pkt to qti/qbi/gps to notify state change */ gsi_ctrl_send_cpkt_tomodem(gsi, NULL, 0); gsi->c_port.notify_req_queued = false; /* Disable Data Path - only if it was initialized already (alt=1) */