Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a20b8823 authored by Devdutt Patnaik's avatar Devdutt Patnaik Committed by Mayank Rana
Browse files

usb: f_gsi: Ignore supsend/resume events if data interface is not selected



Usually the GSI disconnect handler is invoked on disconnect
and bus suspend (with remote wakeup disabled) conditions.
However, for functions such as MBIM that support alternate
data interface, suspend/resume handling becomes a no-op
if the data interface is not selected.

One such example is disabling/enabling network device from device manager
or host sending set_alt 0 before suspend. This operation explicitly
disables data interface, remains the state in STATE_CONNECT_IN_PROGRESS.
After that when set_alt 1 comes from the host ipa_work_handler does
enable the data interface in this state.

Hence post the disconnect event in set_alt 0 handling and
subsequent suspend/resume operations become no-ops.

Change-Id: Idaf240ed5253f61880c05a1b11d87d4979d474c9
Signed-off-by: default avatarDevdutt Patnaik <dpatnaik@codeaurora.org>
Signed-off-by: default avatarChandana Kishori Chiluveru <cchiluve@codeaurora.org>
parent e594cb26
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -2468,8 +2468,13 @@ static int gsi_set_alt(struct usb_function *f, unsigned int intf,
		if (alt == 0 && ((gsi->d_port.in_ep &&
				!gsi->d_port.in_ep->driver_data) ||
				(gsi->d_port.out_ep &&
				!gsi->d_port.out_ep->driver_data)))
				!gsi->d_port.out_ep->driver_data))) {
			ipa_disconnect_handler(&gsi->d_port);
			post_event(&gsi->d_port, EVT_DISCONNECTED);
			queue_work(gsi->d_port.ipa_usb_wq,
				&gsi->d_port.usb_ipa_w);
			log_event_dbg("%s: Disconnecting\n", __func__);
		}

		gsi->data_interface_up = alt;
		log_event_dbg("DATA_INTERFACE id = %d, status = %d",
@@ -2556,11 +2561,11 @@ static void gsi_suspend(struct usb_function *f)
		return;
	}

	/*
	 * GPS doesn't use any data interface, hence bail out as there is no
	 * GSI specific handling needed.
	/* For functions such as MBIM that support alternate data
	 * interface, suspend/resume handling becomes a no-op if the
	 * data interface is not selected.
	 */
	if (gsi->prot_id == USB_PROT_GPS_CTRL) {
	if (!gsi->data_interface_up) {
		log_event_dbg("%s: suspend done\n", __func__);
		return;
	}
@@ -2608,7 +2613,7 @@ static void gsi_resume(struct usb_function *f)
	/* Check any pending cpkt, and queue immediately on resume */
	gsi_ctrl_send_notification(gsi);

	if (gsi->prot_id == USB_PROT_GPS_CTRL) {
	if (!gsi->data_interface_up) {
		log_event_dbg("%s: resume done\n", __func__);
		return;
	}