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

Commit 0c0ed824 authored by Sivan Reinstein's avatar Sivan Reinstein
Browse files

msm: ipa: add IPA driver initialization checks to public IPA APIs



When IPA HW is not enabled/used, IPA driver is not loaded.
In these cases, there's a need to make sure that the public
IPA API calls will fail accordingly.
The change was made in all API calls which are used outside
of IPA driver and IPA WAN driver context.

Change-Id: If46c65ef428ee114c4850ca2f459846a3280fe3c
Acked-by: default avatarDavid Arinzon <darinzon@qti.qualcomm.com>
Signed-off-by: default avatarSivan Reinstein <sivanr@codeaurora.org>
parent f47b4920
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -213,6 +213,11 @@ int ipa_connect(const struct ipa_connect_params *in, struct ipa_sps_params *sps,
	unsigned long base;
	struct iommu_domain *smmu_domain;

	if (unlikely(!ipa_ctx)) {
		IPAERR("IPA driver was not initialized\n");
		return -EINVAL;
	}

	IPADBG("connecting client\n");

	if (in == NULL || sps == NULL || clnt_hdl == NULL ||
@@ -451,6 +456,11 @@ int ipa_disconnect(u32 clnt_hdl)
	unsigned long base;
	struct iommu_domain *smmu_domain;

	if (unlikely(!ipa_ctx)) {
		IPAERR("IPA driver was not initialized\n");
		return -EINVAL;
	}

	if (clnt_hdl >= ipa_ctx->ipa_num_pipes ||
		ipa_ctx->ep[clnt_hdl].valid == 0) {
		IPAERR("bad parm.\n");
@@ -564,6 +574,11 @@ int ipa_reset_endpoint(u32 clnt_hdl)
	int res;
	struct ipa_ep_context *ep;

	if (unlikely(!ipa_ctx)) {
		IPAERR("IPA driver was not initialized\n");
		return -EINVAL;
	}

	if (clnt_hdl >= ipa_ctx->ipa_num_pipes) {
		IPAERR("Bad parameters.\n");
		return -EFAULT;
+25 −0
Original line number Diff line number Diff line
@@ -891,6 +891,11 @@ int ipa_setup_sys_pipe(struct ipa_sys_connect_params *sys_in, u32 *clnt_hdl)
	char buff[IPA_RESOURCE_NAME_MAX];
	struct iommu_domain *smmu_domain;

	if (unlikely(!ipa_ctx)) {
		IPAERR("IPA driver was not initialized\n");
		return -EINVAL;
	}

	if (sys_in == NULL || clnt_hdl == NULL) {
		IPAERR("NULL args\n");
		goto fail_gen;
@@ -1167,6 +1172,11 @@ int ipa_teardown_sys_pipe(u32 clnt_hdl)
	struct ipa_ep_context *ep;
	int empty;

	if (unlikely(!ipa_ctx)) {
		IPAERR("IPA driver was not initialized\n");
		return -EINVAL;
	}

	if (clnt_hdl >= ipa_ctx->ipa_num_pipes ||
	    ipa_ctx->ep[clnt_hdl].valid == 0) {
		IPAERR("bad parm.\n");
@@ -1293,6 +1303,11 @@ int ipa_tx_dp(enum ipa_client_type dst, struct sk_buff *skb,
	struct ipa_sys_context *sys;
	int src_ep_idx;

	if (unlikely(!ipa_ctx)) {
		IPAERR("IPA driver was not initialized\n");
		return -EINVAL;
	}

	memset(desc, 0, 2 * sizeof(struct ipa_desc));

	if (skb->len == 0) {
@@ -2760,6 +2775,11 @@ int ipa_tx_dp_mul(enum ipa_client_type src,
	u32 num_desc, cnt;
	int ep_idx;

	if (unlikely(!ipa_ctx)) {
		IPAERR("IPA driver was not initialized\n");
		return -EINVAL;
	}

	IPADBG("Received data desc anchor:%p\n", data_desc);

	spin_lock_bh(&ipa_ctx->wc_memb.ipa_tx_mul_spinlock);
@@ -2844,6 +2864,11 @@ void ipa_free_skb(struct ipa_rx_data *data)
{
	struct ipa_rx_pkt_wrapper *rx_pkt;

	if (unlikely(!ipa_ctx)) {
		IPAERR("IPA driver was not initialized\n");
		return;
	}

	spin_lock_bh(&ipa_ctx->wc_memb.wlan_spinlock);

	ipa_ctx->wc_memb.total_tx_pkts_freed++;
+15 −0
Original line number Diff line number Diff line
@@ -829,6 +829,11 @@ int ipa_add_hdr(struct ipa_ioc_add_hdr *hdrs)
	int i;
	int result = -EFAULT;

	if (unlikely(!ipa_ctx)) {
		IPAERR("IPA driver was not initialized\n");
		return -EINVAL;
	}

	if (hdrs == NULL || hdrs->num_hdrs == 0) {
		IPAERR("bad parm\n");
		return -EINVAL;
@@ -874,6 +879,11 @@ int ipa_del_hdr(struct ipa_ioc_del_hdr *hdls)
	int i;
	int result = -EFAULT;

	if (unlikely(!ipa_ctx)) {
		IPAERR("IPA driver was not initialized\n");
		return -EINVAL;
	}

	if (hdls == NULL || hdls->num_hdls == 0) {
		IPAERR("bad parm\n");
		return -EINVAL;
@@ -1196,6 +1206,11 @@ int ipa_get_hdr(struct ipa_ioc_get_hdr *lookup)
	struct ipa_hdr_entry *entry;
	int result = -1;

	if (unlikely(!ipa_ctx)) {
		IPAERR("IPA driver was not initialized\n");
		return -EINVAL;
	}

	if (lookup == NULL) {
		IPAERR("bad parm\n");
		return -EINVAL;
+16 −1
Original line number Diff line number Diff line
/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -55,6 +55,11 @@ struct ipa_pull_msg {
int ipa_register_intf(const char *name, const struct ipa_tx_intf *tx,
		       const struct ipa_rx_intf *rx)
{
	if (unlikely(!ipa_ctx)) {
		IPAERR("IPA driver was not initialized\n");
		return -EINVAL;
	}

	return ipa_register_intf_ext(name, tx, rx, NULL);
}
EXPORT_SYMBOL(ipa_register_intf);
@@ -182,6 +187,11 @@ int ipa_deregister_intf(const char *name)
	struct ipa_intf *next;
	int result = -EINVAL;

	if (unlikely(!ipa_ctx)) {
		IPAERR("IPA driver was not initialized\n");
		return -EINVAL;
	}

	if (name == NULL) {
		IPAERR("invalid param name=%p\n", name);
		return result;
@@ -361,6 +371,11 @@ int ipa_send_msg(struct ipa_msg_meta *meta, void *buff,
{
	struct ipa_push_msg *msg;

	if (unlikely(!ipa_ctx)) {
		IPAERR("IPA driver was not initialized\n");
		return -EINVAL;
	}

	if (meta == NULL || (buff == NULL && callback != NULL) ||
	    (buff != NULL && callback == NULL)) {
		IPAERR("invalid param meta=%p buff=%p, callback=%p\n",
+24 −4
Original line number Diff line number Diff line
@@ -1099,9 +1099,9 @@ int ipa_mhi_start(struct ipa_mhi_start_params *params)
		return -EINVAL;
	}

	if (!ipa_mhi_ctx) {
		IPA_MHI_ERR("not initialized\n");
		return -EPERM;
	if (unlikely(!ipa_mhi_ctx)) {
		IPA_MHI_ERR("IPA MHI was not initialized\n");
		return -EINVAL;
	}

	if (ipa_uc_state_check()) {
@@ -1207,6 +1207,11 @@ int ipa_mhi_connect_pipe(struct ipa_mhi_connect_params *in, u32 *clnt_hdl)
		return -EINVAL;
	}

	if (unlikely(!ipa_mhi_ctx)) {
		IPA_MHI_ERR("IPA MHI was not initialized\n");
		return -EINVAL;
	}

	spin_lock_irqsave(&ipa_mhi_ctx->state_lock, flags);
	if (!ipa_mhi_ctx || ipa_mhi_ctx->state != IPA_MHI_STATE_STARTED) {
		IPA_MHI_ERR("IPA MHI was not started\n");
@@ -1359,7 +1364,7 @@ int ipa_mhi_disconnect_pipe(u32 clnt_hdl)
		return -EINVAL;
	}

	if (!ipa_mhi_ctx) {
	if (unlikely(!ipa_mhi_ctx)) {
		IPA_MHI_ERR("IPA MHI was not initialized\n");
		return -EINVAL;
	}
@@ -1594,6 +1599,11 @@ int ipa_mhi_suspend(bool force)

	IPA_MHI_FUNC_ENTRY();

	if (unlikely(!ipa_mhi_ctx)) {
		IPA_MHI_ERR("IPA MHI was not initialized\n");
		return -EINVAL;
	}

	res = ipa_mhi_set_state(IPA_MHI_STATE_SUSPEND_IN_PROGRESS);
	if (res) {
		IPA_MHI_ERR("ipa_mhi_set_state failed %d\n", res);
@@ -1732,6 +1742,11 @@ int ipa_mhi_resume(void)

	IPA_MHI_FUNC_ENTRY();

	if (unlikely(!ipa_mhi_ctx)) {
		IPA_MHI_ERR("IPA MHI was not initialized\n");
		return -EINVAL;
	}

	res = ipa_mhi_set_state(IPA_MHI_STATE_RESUME_IN_PROGRESS);
	if (res) {
		IPA_MHI_ERR("ipa_mhi_set_state failed %d\n", res);
@@ -1811,6 +1826,11 @@ int ipa_mhi_destroy(void)
{
	IPA_MHI_FUNC_ENTRY();

	if (unlikely(!ipa_mhi_ctx)) {
		IPA_MHI_ERR("IPA MHI was not initialized\n");
		return -EINVAL;
	}

	IPAERR("Not implemented Yet!\n");
	ipa_mhi_debugfs_destroy();

Loading