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

Commit c2afa45a authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "soc: qcom: rpm-smd: Add API to send message without waiting on ACK"

parents 0fa3bac6 dabf885f
Loading
Loading
Loading
Loading
+49 −5
Original line number Diff line number Diff line
@@ -1153,7 +1153,7 @@ static int msm_rpm_glink_send_buffer(char *buf, uint32_t size, bool noirq)
}

static int msm_rpm_send_data(struct msm_rpm_request *cdata,
		int msg_type, bool noirq)
		int msg_type, bool noirq, bool noack)
{
	uint8_t *tmpbuff;
	int ret;
@@ -1237,6 +1237,7 @@ static int msm_rpm_send_data(struct msm_rpm_request *cdata,
		return ret;
	}

	if (!noack)
		msm_rpm_add_wait_list(cdata->msg_hdr.msg_id);

	ret = msm_rpm_send_buffer(&cdata->buf[0], msg_size, noirq);
@@ -1262,25 +1263,40 @@ static int msm_rpm_send_data(struct msm_rpm_request *cdata,
	return ret;
}

int msm_rpm_send_request(struct msm_rpm_request *handle)
static int _msm_rpm_send_request(struct msm_rpm_request *handle, bool noack)
{
	int ret;
	static DEFINE_MUTEX(send_mtx);

	mutex_lock(&send_mtx);
	ret = msm_rpm_send_data(handle, MSM_RPM_MSG_REQUEST_TYPE, false);
	ret = msm_rpm_send_data(handle, MSM_RPM_MSG_REQUEST_TYPE, false, noack);
	mutex_unlock(&send_mtx);

	return ret;
}

int msm_rpm_send_request(struct msm_rpm_request *handle)
{
	return _msm_rpm_send_request(handle, false);
}
EXPORT_SYMBOL(msm_rpm_send_request);

int msm_rpm_send_request_noirq(struct msm_rpm_request *handle)
{
	return msm_rpm_send_data(handle, MSM_RPM_MSG_REQUEST_TYPE, true);
	return msm_rpm_send_data(handle, MSM_RPM_MSG_REQUEST_TYPE, true, false);
}
EXPORT_SYMBOL(msm_rpm_send_request_noirq);

void *msm_rpm_send_request_noack(struct msm_rpm_request *handle)
{
	int ret;

	ret = _msm_rpm_send_request(handle, true);

	return ret < 0 ? ERR_PTR(ret) : NULL;
}
EXPORT_SYMBOL(msm_rpm_send_request_noack);

int msm_rpm_wait_for_ack(uint32_t msg_id)
{
	struct msm_rpm_wait_data *elem;
@@ -1402,6 +1418,34 @@ wait_ack_cleanup:
}
EXPORT_SYMBOL(msm_rpm_wait_for_ack_noirq);

void *msm_rpm_send_message_noack(enum msm_rpm_set set, uint32_t rsc_type,
		uint32_t rsc_id, struct msm_rpm_kvp *kvp, int nelems)
{
	int i, rc;
	struct msm_rpm_request *req =
		msm_rpm_create_request_common(set, rsc_type, rsc_id, nelems,
			       false);

	if (IS_ERR(req))
		return req;

	if (!req)
		return ERR_PTR(ENOMEM);

	for (i = 0; i < nelems; i++) {
		rc = msm_rpm_add_kvp_data(req, kvp[i].key,
				kvp[i].data, kvp[i].length);
		if (rc)
			goto bail;
	}

	rc = PTR_ERR(msm_rpm_send_request_noack(req));
bail:
	msm_rpm_free_request(req);
	return rc < 0 ? ERR_PTR(rc) : NULL;
}
EXPORT_SYMBOL(msm_rpm_send_message_noack);

int msm_rpm_send_message(enum msm_rpm_set set, uint32_t rsc_type,
		uint32_t rsc_id, struct msm_rpm_kvp *kvp, int nelems)
{
+41 −0
Original line number Diff line number Diff line
@@ -115,6 +115,19 @@ void msm_rpm_free_request(struct msm_rpm_request *handle);
 */
int msm_rpm_send_request(struct msm_rpm_request *handle);

/**
 * msm_rpm_send_request_noack() - Send the RPM messages using SMD. The function
 * assigns a message id before sending the data out to the RPM. RPM hardware
 * uses the message id to acknowledge the messages, but this API does not wait
 * on the ACK for this message id and it does not add the message id to the wait
 * list.
 *
 * @handle: pointer to the msm_rpm_request for the resource being modified.
 *
 * returns NULL on success and PTR_ERR on a failed transaction.
 */
void *msm_rpm_send_request_noack(struct msm_rpm_request *handle);

/**
 * msm_rpm_send_request_noirq() - Send the RPM messages using SMD. The
 * function assigns a message id before sending the data out to the RPM.
@@ -166,6 +179,22 @@ int msm_rpm_wait_for_ack_noirq(uint32_t msg_id);
int msm_rpm_send_message(enum msm_rpm_set set, uint32_t rsc_type,
		uint32_t rsc_id, struct msm_rpm_kvp *kvp, int nelems);

/**
 * msm_rpm_send_message_noack() -Wrapper function for clients to send data
 * given an array of key value pairs without waiting for ack.
 *
 * @set: if the device is setting the active/sleep set parameter
 * for the resource
 * @rsc_type: unsigned 32 bit integer that identifies the type of the resource
 * @rsc_id: unsigned 32 bit that uniquely identifies a resource within a type
 * @kvp: array of KVP data.
 * @nelem: number of KVPs pairs associated with the message.
 *
 * returns  NULL on success and PTR_ERR(errno) on failure.
 */
void *msm_rpm_send_message_noack(enum msm_rpm_set set, uint32_t rsc_type,
		uint32_t rsc_id, struct msm_rpm_kvp *kvp, int nelems);

/**
 * msm_rpm_send_message_noirq() -Wrapper function for clients to send data
 * given an array of key value pairs. This function is similar to the
@@ -237,6 +266,11 @@ static inline int msm_rpm_send_request_noirq(struct msm_rpm_request *handle)

}

static inline void *msm_rpm_send_request_noack(struct msm_rpm_request *handle)
{
	return NULL;
}

static inline int msm_rpm_send_message(enum msm_rpm_set set, uint32_t rsc_type,
		uint32_t rsc_id, struct msm_rpm_kvp *kvp, int nelems)
{
@@ -250,6 +284,13 @@ static inline int msm_rpm_send_message_noirq(enum msm_rpm_set set,
	return 0;
}

static inline void *msm_rpm_send_message_noack(enum msm_rpm_set set,
		uint32_t rsc_type, uint32_t rsc_id, struct msm_rpm_kvp *kvp,
		int nelems)
{
	return NULL;
}

static inline int msm_rpm_wait_for_ack(uint32_t msg_id)
{
	return 0;