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

Commit 8fd5e6cf authored by Siva Kumar Akkireddi's avatar Siva Kumar Akkireddi
Browse files

msm: mhi_dev: Fix client callback call sequence to update channel state



Client callback for state change notification is called after updating
state in MHI driver to avoid updating stale state to the client. Also,
the client callback list and MHI mutex initialization are moved to
mhi_dev_probe since mhi_register_state_cb, where they are used,
may be called early.

Change-Id: I53b3ac7c22aadd0613d84ee533a4a3d84ee309bb
Signed-off-by: default avatarSiva Kumar Akkireddi <sivaa@codeaurora.org>
parent d5546ff2
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -1021,10 +1021,9 @@ static void mhi_dev_process_cmd_ring(struct mhi_dev *mhi,
		if (rc)
			pr_err("Error sending command completion event\n");

		mhi_update_state_info(ch_id, MHI_STATE_CONNECTED);
		/* Trigger callback to clients */
		mhi_dev_trigger_cb();

		mhi_update_state_info(ch_id, MHI_STATE_CONNECTED);
		if (ch_id == MHI_CLIENT_MBIM_OUT)
			kobject_uevent_env(&mhi_ctx->dev->kobj,
						KOBJ_CHANGE, connected);
@@ -2452,8 +2451,10 @@ int mhi_register_state_cb(void (*mhi_state_cb)
	 * If channel is open during registration, no callback is issued.
	 * Instead return -EEXIST to notify the client. Clients request
	 * is added to the list to notify future state change notification.
	 * Channel struct may not be allocated yet if this function is called
	 * early during boot - add an explicit check for non-null "ch".
	 */
	if (mhi_ctx->ch[channel].state == MHI_DEV_CH_STARTED) {
	if (mhi_ctx->ch && (mhi_ctx->ch[channel].state == MHI_DEV_CH_STARTED)) {
		mutex_unlock(&mhi_ctx->mhi_lock);
		return -EEXIST;
	}
@@ -2832,8 +2833,6 @@ static int mhi_dev_resume_mmio_mhi_init(struct mhi_dev *mhi_ctx)

	INIT_LIST_HEAD(&mhi_ctx->event_ring_list);
	INIT_LIST_HEAD(&mhi_ctx->process_ring_list);
	INIT_LIST_HEAD(&mhi_ctx->client_cb_list);
	mutex_init(&mhi_ctx->mhi_lock);
	mutex_init(&mhi_ctx->mhi_event_lock);
	mutex_init(&mhi_ctx->mhi_write_test);

@@ -2983,6 +2982,14 @@ static int mhi_dev_probe(struct platform_device *pdev)
			dev_err(&pdev->dev,
				"Failed to create IPC logging context\n");
		}
		/*
		 * The below list and mutex should be initialized
		 * before calling mhi_uci_init to avoid crash in
		 * mhi_register_state_cb when accessing these.
		 */
		INIT_LIST_HEAD(&mhi_ctx->client_cb_list);
		mutex_init(&mhi_ctx->mhi_lock);

		mhi_uci_init();
		mhi_update_state_info(MHI_DEV_UEVENT_CTRL,
						MHI_STATE_CONFIGURED);