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

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

Merge "msm: ipa: misc cleanup"

parents 8fcf414c a8b0f759
Loading
Loading
Loading
Loading
+3 −15
Original line number Diff line number Diff line
@@ -1902,15 +1902,6 @@ static int ipa_init(const struct ipa_plat_drv_res *resource_p,
		result = -ENOMEM;
		goto fail_rx_pkt_wrapper_cache;
	}
	ipa_ctx->tree_node_cache =
	   kmem_cache_create("IPA TREE", sizeof(struct ipa_tree_node), 0, 0,
			   NULL);
	if (!ipa_ctx->tree_node_cache) {
		IPAERR(":ipa tree node cache create failed\n");
		result = -ENOMEM;
		goto fail_tree_node_cache;
	}

	/*
	 * setup DMA pool 4 byte aligned, don't cross 1k boundaries, nominal
	 * size 512 bytes
@@ -1969,10 +1960,8 @@ static int ipa_init(const struct ipa_plat_drv_res *resource_p,
	mutex_init(&ipa_ctx->lock);
	mutex_init(&ipa_ctx->nat_mem.lock);

	ipa_ctx->hdr_hdl_tree = RB_ROOT;
	ipa_ctx->rt_rule_hdl_tree = RB_ROOT;
	ipa_ctx->rt_tbl_hdl_tree = RB_ROOT;
	ipa_ctx->flt_rule_hdl_tree = RB_ROOT;
	idr_init(&ipa_ctx->ipa_idr);
	spin_lock_init(&ipa_ctx->idr_lock);

	mutex_init(&ipa_ctx->ipa_active_clients_lock);
	ipa_ctx->ipa_active_clients = 0;
@@ -2134,14 +2123,13 @@ fail_empty_rt_tbl:
			  ipa_ctx->empty_rt_tbl_mem.base,
			  ipa_ctx->empty_rt_tbl_mem.phys_base);
fail_apps_pipes:
	idr_destroy(&ipa_ctx->ipa_idr);
	/*
	 * DMA pool need to be released only for IPA HW v1.0 only.
	 */
	if (ipa_ctx->ipa_hw_type == IPA_HW_v1_0)
		dma_pool_destroy(ipa_ctx->dma_pool);
fail_dma_pool:
	kmem_cache_destroy(ipa_ctx->tree_node_cache);
fail_tree_node_cache:
	kmem_cache_destroy(ipa_ctx->rx_pkt_wrapper_cache);
fail_rx_pkt_wrapper_cache:
	kmem_cache_destroy(ipa_ctx->tx_pkt_wrapper_cache);
+2 −2
Original line number Diff line number Diff line
@@ -282,7 +282,7 @@ int ipa_connect(const struct ipa_connect_params *in, struct ipa_sps_params *sps,
		ep->connect.desc = in->desc;
		ep->desc_fifo_client_allocated = 1;
	}
	IPADBG("Descriptor FIFO pa=0x%x, size=%d\n", ep->connect.desc.phys_base,
	IPADBG("Descriptor FIFO pa=%pa, size=%d\n", &ep->connect.desc.phys_base,
	       ep->connect.desc.size);

	if (in->data.base == NULL) {
@@ -299,7 +299,7 @@ int ipa_connect(const struct ipa_connect_params *in, struct ipa_sps_params *sps,
		ep->connect.data = in->data;
		ep->data_fifo_client_allocated = 1;
	}
	IPADBG("Data FIFO pa=0x%x, size=%d\n", ep->connect.data.phys_base,
	IPADBG("Data FIFO pa=%pa, size=%d\n", &ep->connect.data.phys_base,
	       ep->connect.data.size);

	if (ipa_ctx->ipa_hw_type == IPA_HW_v2_0 &&
+2 −2
Original line number Diff line number Diff line
@@ -730,7 +730,7 @@ static ssize_t ipa_read_flt(struct file *file, char __user *ubuf, size_t count,
			bitmap = entry->rule.eq_attrib.rule_eq_bitmap;
			eq = true;
		} else {
			rt_tbl = (struct ipa_rt_tbl *)entry->rule.rt_tbl_hdl;
			rt_tbl = ipa_id_find(entry->rule.rt_tbl_hdl);
			if (rt_tbl)
				rt_tbl_idx = rt_tbl->idx;
			else
@@ -759,12 +759,12 @@ static ssize_t ipa_read_flt(struct file *file, char __user *ubuf, size_t count,
		tbl = &ipa_ctx->flt_tbl[j][ip];
		i = 0;
		list_for_each_entry(entry, &tbl->head_flt_rule_list, link) {
			rt_tbl = (struct ipa_rt_tbl *)entry->rule.rt_tbl_hdl;
			if (entry->rule.eq_attrib_type) {
				rt_tbl_idx = entry->rule.rt_tbl_idx;
				bitmap = entry->rule.eq_attrib.rule_eq_bitmap;
				eq = true;
			} else {
				rt_tbl = ipa_id_find(entry->rule.rt_tbl_hdl);
				if (rt_tbl)
					rt_tbl_idx = rt_tbl->idx;
				else
+16 −18
Original line number Diff line number Diff line
@@ -545,7 +545,7 @@ failure_coherent:
 * Complete the immediate commands completion object, this will release the
 * thread which waits on this completion object (ipa_send_cmd())
 */
static void ipa_sps_irq_cmd_ack(void *user1, void *user2)
static void ipa_sps_irq_cmd_ack(void *user1, int user2)
{
	struct ipa_desc *desc = (struct ipa_desc *)user1;

@@ -1132,10 +1132,10 @@ EXPORT_SYMBOL(ipa_teardown_sys_pipe);
 * This notified callback is for the destination client.
 * This function is supplied in ipa_connect.
 */
static void ipa_tx_comp_usr_notify_release(void *user1, void *user2)
static void ipa_tx_comp_usr_notify_release(void *user1, int user2)
{
	struct sk_buff *skb = (struct sk_buff *)user1;
	u32 ep_idx = (u32)user2;
	int ep_idx = user2;

	IPADBG("skb=%p ep=%d\n", skb, ep_idx);

@@ -1148,7 +1148,7 @@ static void ipa_tx_comp_usr_notify_release(void *user1, void *user2)
		dev_kfree_skb_any(skb);
}

static void ipa_tx_cmd_comp(void *user1, void *user2)
static void ipa_tx_cmd_comp(void *user1, int user2)
{
	kfree(user1);
}
@@ -1235,8 +1235,8 @@ int ipa_tx_dp(enum ipa_client_type dst, struct sk_buff *skb,
		desc[1].user1 = skb;
		desc[1].user2 = (meta && meta->pkt_init_dst_ep_valid &&
				meta->pkt_init_dst_ep_remote) ?
				(void *)src_ep_idx :
				(void *)dst_ep_idx;
				src_ep_idx :
				dst_ep_idx;

		if (ipa_send(sys, 2, desc, true)) {
			IPAERR("fail to send immediate command\n");
@@ -1250,7 +1250,7 @@ int ipa_tx_dp(enum ipa_client_type dst, struct sk_buff *skb,
		desc[0].type = IPA_DATA_DESC_SKB;
		desc[0].callback = ipa_tx_comp_usr_notify_release;
		desc[0].user1 = skb;
		desc[0].user2 = (void *)src_ep_idx;
		desc[0].user2 = src_ep_idx;

		if (ipa_send_one(sys, &desc[0], true)) {
			IPAERR("fail to send skb\n");
@@ -1977,11 +1977,10 @@ static void ipa_wq_rx_common(struct ipa_sys_context *sys, u32 size)
	rx_skb = rx_pkt_expected->data.skb;
	dma_unmap_single(ipa_ctx->pdev, rx_pkt_expected->data.dma_addr,
			sys->rx_buff_sz, DMA_FROM_DEVICE);
	rx_skb->tail = rx_skb->data + rx_pkt_expected->len;
	skb_set_tail_pointer(rx_skb, rx_pkt_expected->len);
	rx_skb->len = rx_pkt_expected->len;
	rx_skb->truesize = rx_pkt_expected->len + sizeof(struct sk_buff);
	sys->pyld_hdlr(rx_skb, sys);

	ipa_replenish_rx_cache(sys);
	kmem_cache_free(ipa_ctx->rx_pkt_wrapper_cache, rx_pkt_expected);

@@ -2006,7 +2005,7 @@ static void ipa_wlan_wq_rx_common(struct ipa_sys_context *sys, u32 size)
		rx_pkt_expected->len = size;

	rx_skb = rx_pkt_expected->data.skb;
	rx_skb->tail = rx_skb->data + rx_pkt_expected->len;
	skb_set_tail_pointer(rx_skb, rx_pkt_expected->len);
	rx_skb->len = rx_pkt_expected->len;
	rx_skb->truesize = rx_pkt_expected->len + sizeof(struct sk_buff);
	ipa_ctx->wstats.tx_pkts_rcvd++;
@@ -2016,7 +2015,6 @@ static void ipa_wlan_wq_rx_common(struct ipa_sys_context *sys, u32 size)
	ipa_replenish_wlan_rx_cache(sys);
}


static void ipa_wq_rx_avail(struct work_struct *work)
{
	struct ipa_rx_pkt_wrapper *rx_pkt;
@@ -2194,10 +2192,10 @@ static int ipa_assign_policy(struct ipa_sys_connect_params *in,
 * This notified callback is for the destination client
 * This function is supplied in ipa_tx_dp_mul
 */
static void ipa_tx_client_rx_notify_release(void *user1, void *user2)
static void ipa_tx_client_rx_notify_release(void *user1, int user2)
{
	struct ipa_tx_data_desc *dd = (struct ipa_tx_data_desc *)user1;
	u32 ep_idx = (u32)user2;
	int ep_idx = user2;

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

@@ -2227,9 +2225,9 @@ static void ipa_tx_client_rx_notify_release(void *user1, void *user2)
 * This notified callback is for the destination client
 * This function is supplied in ipa_tx_dp_mul
 */
static void ipa_tx_client_rx_pkt_status(void *user1, void *user2)
static void ipa_tx_client_rx_pkt_status(void *user1, int user2)
{
	u32 ep_idx = (u32)user2;
	int ep_idx = user2;


	ipa_ctx->ep[ep_idx].avail_fifo_desc++;
@@ -2308,7 +2306,7 @@ int ipa_tx_dp_mul(enum ipa_client_type src,
		desc.len = entry->pyld_len;
		desc.type = IPA_DATA_DESC_SKB;
		desc.user1 = data_desc;
		desc.user2 = (void *)ep_idx;
		desc.user2 = ep_idx;
		IPADBG("priv:%p pyld_buf:0x%p pyld_len:%d\n",
			entry->priv, desc.pyld, desc.len);

+31 −45
Original line number Diff line number Diff line
@@ -366,10 +366,10 @@ static int ipa_generate_flt_hw_tbl_common(enum ipa_ip_type ip, u8 *base,

			/* write the rule-set terminator */
			body = ipa_write_32(0, body);
			if ((u32)body & IPA_FLT_ENTRY_MEMORY_ALLIGNMENT)
			if ((long)body & IPA_FLT_ENTRY_MEMORY_ALLIGNMENT)
				/* advance body to next word boundary */
				body = body + (IPA_FLT_TABLE_WORD_SIZE -
					((u32)body &
					((long)body &
					IPA_FLT_ENTRY_MEMORY_ALLIGNMENT));
		} else {
			WARN_ON(tbl->sz == 0);
@@ -452,10 +452,11 @@ static int ipa_generate_flt_hw_tbl_common(enum ipa_ip_type ip, u8 *base,

				/* write the rule-set terminator */
				body = ipa_write_32(0, body);
				if ((u32)body & IPA_FLT_ENTRY_MEMORY_ALLIGNMENT)
				if ((long)body &
					IPA_FLT_ENTRY_MEMORY_ALLIGNMENT)
					/* advance body to next word boundary */
					body = body + (IPA_FLT_TABLE_WORD_SIZE -
						((u32)body &
						((long)body &
					IPA_FLT_ENTRY_MEMORY_ALLIGNMENT));
			} else {
				WARN_ON(tbl->sz == 0);
@@ -910,7 +911,8 @@ static int __ipa_add_flt_rule(struct ipa_flt_tbl *tbl, enum ipa_ip_type ip,
			      u32 *rule_hdl)
{
	struct ipa_flt_entry *entry;
	struct ipa_tree_node *node;
	struct ipa_rt_tbl *rt_tbl = NULL;
	int id;

	if (rule->action != IPA_PASS_TO_EXCEPTION) {
		if (!rule->eq_attrib_type) {
@@ -919,14 +921,13 @@ static int __ipa_add_flt_rule(struct ipa_flt_tbl *tbl, enum ipa_ip_type ip,
				goto error;
			}

			if (ipa_search(&ipa_ctx->rt_tbl_hdl_tree,
						rule->rt_tbl_hdl) == NULL) {
			rt_tbl = ipa_id_find(rule->rt_tbl_hdl);
			if (rt_tbl == NULL) {
				IPAERR("RT tbl not found\n");
				goto error;
			}

			if (((struct ipa_rt_tbl *)rule->rt_tbl_hdl)->cookie !=
					IPA_COOKIE) {
			if (rt_tbl->cookie != IPA_COOKIE) {
				IPAERR("RT table cookie is invalid\n");
				goto error;
			}
@@ -940,22 +941,15 @@ static int __ipa_add_flt_rule(struct ipa_flt_tbl *tbl, enum ipa_ip_type ip,
		}
	}

	node = kmem_cache_zalloc(ipa_ctx->tree_node_cache, GFP_KERNEL);
	if (!node) {
		IPAERR("failed to alloc tree node object\n");
		goto error;
	}

	entry = kmem_cache_zalloc(ipa_ctx->flt_rule_cache, GFP_KERNEL);
	if (!entry) {
		IPAERR("failed to alloc FLT rule object\n");
		goto mem_alloc_fail;
		goto error;
	}
	INIT_LIST_HEAD(&entry->link);
	entry->rule = *rule;
	entry->cookie = IPA_COOKIE;
	if (!rule->eq_attrib_type)
		entry->rt_tbl = (struct ipa_rt_tbl *)rule->rt_tbl_hdl;
	entry->rt_tbl = rt_tbl;
	entry->tbl = tbl;
	if (add_rear) {
		if (tbl->sticky_rear)
@@ -969,41 +963,37 @@ static int __ipa_add_flt_rule(struct ipa_flt_tbl *tbl, enum ipa_ip_type ip,
	tbl->rule_cnt++;
	if (entry->rt_tbl)
		entry->rt_tbl->ref_cnt++;
	*rule_hdl = (u32)entry;
	IPADBG("add flt rule rule_cnt=%d\n", tbl->rule_cnt);

	node->hdl = *rule_hdl;
	if (ipa_insert(&ipa_ctx->flt_rule_hdl_tree, node)) {
	id = ipa_id_alloc(entry);
	if (id < 0) {
		IPAERR("failed to add to tree\n");
		WARN_ON(1);
	}
	*rule_hdl = id;
	entry->id = id;
	IPADBG("add flt rule rule_cnt=%d\n", tbl->rule_cnt);

	return 0;

mem_alloc_fail:
	kmem_cache_free(ipa_ctx->tree_node_cache, node);
error:

	return -EPERM;
}

static int __ipa_del_flt_rule(u32 rule_hdl)
{
	struct ipa_flt_entry *entry = (struct ipa_flt_entry *)rule_hdl;
	struct ipa_tree_node *node;
	struct ipa_flt_entry *entry;
	int id;

	node = ipa_search(&ipa_ctx->flt_rule_hdl_tree, rule_hdl);
	if (node == NULL) {
	entry = ipa_id_find(rule_hdl);
	if (entry == NULL) {
		IPAERR("lookup failed\n");

		return -EINVAL;
	}

	if (entry == NULL || (entry->cookie != IPA_COOKIE)) {
	if (entry->cookie != IPA_COOKIE) {
		IPAERR("bad params\n");

		return -EINVAL;
	}
	id = entry->id;

	list_del(&entry->link);
	entry->tbl->rule_cnt--;
@@ -1014,8 +1004,7 @@ static int __ipa_del_flt_rule(u32 rule_hdl)
	kmem_cache_free(ipa_ctx->flt_rule_cache, entry);

	/* remove the handle from the database */
	rb_erase(&node->node, &ipa_ctx->flt_rule_hdl_tree);
	kmem_cache_free(ipa_ctx->tree_node_cache, node);
	ipa_id_remove(id);

	return 0;
}
@@ -1206,8 +1195,8 @@ int ipa_reset_flt(enum ipa_ip_type ip)
	struct ipa_flt_tbl *tbl;
	struct ipa_flt_entry *entry;
	struct ipa_flt_entry *next;
	struct ipa_tree_node *node;
	int i;
	int id;

	if (ip >= IPA_IP_MAX) {
		IPAERR("bad parm\n");
@@ -1218,8 +1207,7 @@ int ipa_reset_flt(enum ipa_ip_type ip)
	mutex_lock(&ipa_ctx->lock);
	IPADBG("reset flt ip=%d\n", ip);
	list_for_each_entry_safe(entry, next, &tbl->head_flt_rule_list, link) {
		node = ipa_search(&ipa_ctx->flt_rule_hdl_tree, (u32)entry);
		if (node == NULL) {
		if (ipa_id_find(entry->id) == NULL) {
			WARN_ON(1);
			mutex_unlock(&ipa_ctx->lock);
			return -EFAULT;
@@ -1240,20 +1228,18 @@ int ipa_reset_flt(enum ipa_ip_type ip)
		if (entry->rt_tbl)
			entry->rt_tbl->ref_cnt--;
		entry->cookie = 0;
		id = entry->id;
		kmem_cache_free(ipa_ctx->flt_rule_cache, entry);

		/* remove the handle from the database */
		rb_erase(&node->node, &ipa_ctx->flt_rule_hdl_tree);
		kmem_cache_free(ipa_ctx->tree_node_cache, node);
		ipa_id_remove(id);
	}

	for (i = 0; i < IPA_NUM_PIPES; i++) {
		tbl = &ipa_ctx->flt_tbl[i][ip];
		list_for_each_entry_safe(entry, next, &tbl->head_flt_rule_list,
				link) {
			node = ipa_search(&ipa_ctx->flt_rule_hdl_tree,
					(u32)entry);
			if (node == NULL) {
			if (ipa_id_find(entry->id) == NULL) {
				WARN_ON(1);
				mutex_unlock(&ipa_ctx->lock);
				return -EFAULT;
@@ -1263,11 +1249,11 @@ int ipa_reset_flt(enum ipa_ip_type ip)
			if (entry->rt_tbl)
				entry->rt_tbl->ref_cnt--;
			entry->cookie = 0;
			id = entry->id;
			kmem_cache_free(ipa_ctx->flt_rule_cache, entry);

			/* remove the handle from the database */
			rb_erase(&node->node, &ipa_ctx->flt_rule_hdl_tree);
			kmem_cache_free(ipa_ctx->tree_node_cache, node);
			ipa_id_remove(id);
		}
	}
	mutex_unlock(&ipa_ctx->lock);
Loading