From 4e92819480908ae197ea85e1112511a1f2288593 Mon Sep 17 00:00:00 2001 From: Ajay Agarwal Date: Thu, 26 Mar 2020 19:06:07 +0530 Subject: [PATCH] usb: gadget: f_gsi: Send 0 byte packet when both ctrl and data paths setup Currently the driver notifies line state change to QTI for RmNet interface on set_alt. As soon as QTI receives this 0 byte packet, it queries USB driver for RmNet line state. This might still be 0 since gsi_setup for DTR state as 1 might not have been invoked by this time. Also, the xdci_connect with IPA for RmNet/RmNet_v2x might not have happened by this time, because of which IPA cannot send proper ep_info to QTI. These can lead to data call failure. Fix this by sending 0 byte packet to QTI for RmNet interfaces only when both ctrl and data paths have been setup. Change-Id: Ic569dc731885166f260857e4d194ac34ae0e62f4 Signed-off-by: Ajay Agarwal --- drivers/usb/gadget/function/f_gsi.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/usb/gadget/function/f_gsi.c b/drivers/usb/gadget/function/f_gsi.c index f252d323d8c1..2524146037f0 100644 --- a/drivers/usb/gadget/function/f_gsi.c +++ b/drivers/usb/gadget/function/f_gsi.c @@ -73,6 +73,7 @@ static int gsi_alloc_trb_buffer(struct f_gsi *gsi); static void gsi_free_trb_buffer(struct f_gsi *gsi); static struct gsi_ctrl_pkt *gsi_ctrl_pkt_alloc(unsigned int len, gfp_t flags); static void gsi_ctrl_pkt_free(struct gsi_ctrl_pkt *pkt); +static int gsi_ctrl_send_cpkt_tomodem(struct f_gsi *gsi, void *buf, size_t len); static inline bool is_ext_prot_ether(int prot_id) { @@ -740,6 +741,12 @@ static int ipa_connect_channels(struct gsi_data_port *d_port) ipa_out_channel_out_params.db_reg_phs_addr_msb; } + /* Send 0 byte packet to QTI only if DTR linetstate is HIGH already */ + if (gsi->rmnet_dtr_status && + (gsi->prot_id == USB_PROT_RMNET_IPA || + gsi->prot_id == USB_PROT_RMNET_V2X_IPA)) + gsi_ctrl_send_cpkt_tomodem(gsi, NULL, 0); + return ret; end_xfer_ep_out: @@ -2220,6 +2227,14 @@ gsi_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl) queue_work(gsi->c_port.uevent_wq, &gsi->c_port.uevent_work); + /* Send 0 byte packet to QTI only if IPA connect is done */ + if (gsi->rmnet_dtr_status) { + if (gsi->prot_id == USB_PROT_RMNET_ETHER) + gsi_ctrl_send_cpkt_tomodem(gsi, NULL, 0); + else if (gsi->d_port.in_channel_handle != -EINVAL) + gsi_ctrl_send_cpkt_tomodem(gsi, NULL, 0); + } + value = 0; break; case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8) @@ -2624,10 +2639,7 @@ static int gsi_set_alt(struct usb_function *f, unsigned int intf, if (gsi->prot_id == USB_PROT_DIAG_IPA || gsi->prot_id == USB_PROT_DPL_ETHER || gsi->prot_id == USB_PROT_GPS_CTRL || - gsi->prot_id == USB_PROT_MBIM_IPA || - gsi->prot_id == USB_PROT_RMNET_IPA || - gsi->prot_id == USB_PROT_RMNET_V2X_IPA || - gsi->prot_id == USB_PROT_RMNET_ETHER) + gsi->prot_id == USB_PROT_MBIM_IPA) gsi_ctrl_send_cpkt_tomodem(gsi, NULL, 0); if (gsi->c_port.uevent_wq)