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

Commit 5e3cf80f authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: mhi_dev: Fail start command if fails to allocate reqs"

parents 991ca50f 0ec60229
Loading
Loading
Loading
Loading
+33 −16
Original line number Diff line number Diff line
@@ -1940,12 +1940,7 @@ static int mhi_dev_process_cmd_ring(struct mhi_dev *mhi,
				mhi_log(MHI_MSG_VERBOSE,
					"Failed to enable chdb for ch %d\n",
						ch_id);
				rc = mhi_dev_send_cmd_comp_event(mhi,
					MHI_CMD_COMPL_CODE_UNDEFINED);
				if (rc)
					mhi_log(MHI_MSG_VERBOSE,
						"Error with compl event\n");
				return rc;
				goto send_undef_completion_event;
			}
		}

@@ -1959,12 +1954,7 @@ static int mhi_dev_process_cmd_ring(struct mhi_dev *mhi,
		if (rc) {
			mhi_log(MHI_MSG_ERROR,
				"start ring failed for ch %d\n", ch_id);
			rc = mhi_dev_send_cmd_comp_event(mhi,
						MHI_CMD_COMPL_CODE_UNDEFINED);
			if (rc)
				mhi_log(MHI_MSG_ERROR,
					"Error with compl event\n");
			return rc;
			goto send_undef_completion_event;
		}

		mhi->ring[mhi->ch_ring_start + ch_id].state =
@@ -1990,13 +1980,19 @@ static int mhi_dev_process_cmd_ring(struct mhi_dev *mhi,
					mhi_log(MHI_MSG_ERROR,
					"error starting event ring %d\n",
					mhi->ch_ctx_cache[ch_id].err_indx);
					return rc;
					goto send_undef_completion_event;
				}
			}
			mutex_lock(&mhi->ch[ch_id].ch_lock);
			mhi_dev_alloc_evt_buf_evt_req(mhi, &mhi->ch[ch_id],
			rc = mhi_dev_alloc_evt_buf_evt_req(mhi, &mhi->ch[ch_id],
					evt_ring);
			mutex_unlock(&mhi->ch[ch_id].ch_lock);
			if (rc) {
				mhi_log(MHI_MSG_ERROR,
					"Failed to alloc ereqs for er %d\n",
					mhi->ch_ctx_cache[ch_id].err_indx);
				goto send_undef_completion_event;
			}
		}

		if (MHI_USE_DMA(mhi))
@@ -2022,6 +2018,20 @@ static int mhi_dev_process_cmd_ring(struct mhi_dev *mhi,
		mhi_dev_trigger_cb(ch_id);
		mhi_uci_chan_state_notify(mhi, ch_id, MHI_STATE_CONNECTED);
		break;

send_undef_completion_event:
		mhi->ch_ctx_cache[ch_id].ch_state = MHI_DEV_CH_STATE_DISABLED;
		mhi->ch[ch_id].state = MHI_DEV_CH_UNINT;

		rc = mhi_dev_send_cmd_comp_event(mhi,
				MHI_CMD_COMPL_CODE_UNDEFINED);
		if (rc)
			mhi_log(MHI_MSG_VERBOSE, "Error with compl event\n");

		mhi_dev_mmio_disable_chdb_a7(mhi, ch_id);

		return rc;

	case MHI_DEV_RING_EL_STOP:
		if (ch_id >= HW_CHANNEL_BASE) {
			rc = mhi_hwc_chcmd(mhi, ch_id, el->generic.type);
@@ -3098,13 +3108,20 @@ static int mhi_dev_alloc_evt_buf_evt_req(struct mhi_dev *mhi,

	/* Allocate event requests */
	ch->ereqs = kcalloc(ch->evt_req_size, sizeof(*ch->ereqs), GFP_KERNEL);
	if (!ch->ereqs)
		return -ENOMEM;
	if (!ch->ereqs) {
		mhi_log(MHI_MSG_ERROR,
			"Failed to alloc ereqs for Channel %d\n", ch->ch_id);
		rc = -ENOMEM;
		goto free_ereqs;
	}

	/* Allocate buffers to queue transfer completion events */
	ch->tr_events = kcalloc(ch->evt_buf_size, sizeof(*ch->tr_events),
			GFP_KERNEL);
	if (!ch->tr_events) {
		mhi_log(MHI_MSG_ERROR,
			"Failed to alloc tr_events buffer for Channel %d\n",
			ch->ch_id);
		rc = -ENOMEM;
		goto free_ereqs;
	}
+3 −3
Original line number Diff line number Diff line
@@ -651,7 +651,7 @@ static int mhi_uci_send_async(struct uci_client *uci_handle,
	int bytes_to_write;
	struct mhi_req *ureq;

	uci_log(UCI_DBG_VERBOSE,
	uci_log(UCI_DBG_DBG,
		"Async write for ch %d size %d\n",
		uci_handle->out_chan, size);

@@ -865,7 +865,7 @@ static int mhi_uci_read_async(struct uci_client *uci_handle, int *bytes_avail)
	struct mhi_req *ureq;
	struct mhi_dev_client *client_handle;

	uci_log(UCI_DBG_ERROR,
	uci_log(UCI_DBG_DBG,
		"Async read for ch %d\n", uci_handle->in_chan);

	ureq = mhi_uci_get_req(uci_handle);
@@ -1031,7 +1031,7 @@ static int open_client_mhi_channels(struct uci_client *uci_client)
			uci_ctxt.event_notifier);
	if (rc < 0) {
		uci_log(UCI_DBG_ERROR,
			"Failed to open chan %d, ret 0x%x\n",
			"Failed to open chan %d, ret %d\n",
			uci_client->out_chan, rc);
		goto handle_in_err;
	}