soc: qcom: qmi_interface: Add send timeout helper

Add an api for clients to set the send timeout of the underlying qrtr
socket. QMI sets this timeout to 10 seconds by default but this is too
long for some clients in critical paths.

Change-Id: I4c892a2f034c87b6bf2f71664369140910e72383
Signed-off-by: Chris Lew <clew@codeaurora.org>
This commit is contained in:
Chris Lew 2019-03-07 14:11:43 -08:00
commit e62317caca
2 changed files with 18 additions and 0 deletions

View file

@ -448,6 +448,7 @@ static void qmi_handle_net_reset(struct qmi_handle *qmi)
struct sockaddr_qrtr sq;
struct qmi_service *svc;
struct socket *sock;
long timeo = qmi->sock->sk->sk_sndtimeo;
sock = qmi_sock_create(qmi, &sq);
if (IS_ERR(sock))
@ -467,6 +468,7 @@ static void qmi_handle_net_reset(struct qmi_handle *qmi)
sock_release(qmi->sock);
qmi->sock = sock;
qmi->sq = sq;
qmi->sock->sk->sk_sndtimeo = timeo;
mutex_unlock(&qmi->sock_lock);
list_for_each_entry(svc, &qmi->lookups, list_node)
@ -620,6 +622,21 @@ static struct socket *qmi_sock_create(struct qmi_handle *qmi,
return sock;
}
/**
* qmi_set_sndtimeo() - set the sk_sndtimeo of the qmi handle
* @qmi: QMI client handle
* @timeo: timeout in jiffies.
*
* This sets the timeout for the blocking socket send in qmi send.
*/
void qmi_set_sndtimeo(struct qmi_handle *qmi, long timeo)
{
mutex_lock(&qmi->sock_lock);
qmi->sock->sk->sk_sndtimeo = timeo;
mutex_unlock(&qmi->sock_lock);
}
EXPORT_SYMBOL(qmi_set_sndtimeo);
/**
* qmi_handle_init() - initialize a QMI client handle
* @qmi: QMI handle to initialize

View file

@ -268,5 +268,6 @@ int qmi_txn_init(struct qmi_handle *qmi, struct qmi_txn *txn,
struct qmi_elem_info *ei, void *c_struct);
int qmi_txn_wait(struct qmi_txn *txn, unsigned long timeout);
void qmi_txn_cancel(struct qmi_txn *txn);
void qmi_set_sndtimeo(struct qmi_handle *qmi, long timeo);
#endif