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

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

Merge "msm: ipa3: Fix to add check for dma_map_single return values"

parents a6e2c496 4064fd83
Loading
Loading
Loading
Loading
+28 −35
Original line number Diff line number Diff line
@@ -400,7 +400,6 @@ int ipa3_send(struct ipa3_sys_context *sys,
	int i = 0;
	int j;
	int result;
	int fail_dma_wrap = 0;
	u32 mem_flag = GFP_ATOMIC;
	const struct ipa_gsi_ep_config *gsi_ep_cfg;

@@ -431,7 +430,6 @@ int ipa3_send(struct ipa3_sys_context *sys,
	spin_lock_bh(&sys->spinlock);

	for (i = 0; i < num_desc; i++) {
		fail_dma_wrap = 0;
		tx_pkt = kmem_cache_zalloc(ipa3_ctx->tx_pkt_wrapper_cache,
					   mem_flag);
		if (!tx_pkt) {
@@ -454,7 +452,7 @@ int ipa3_send(struct ipa3_sys_context *sys,
			if (ipa_populate_tag_field(&desc[i], tx_pkt,
				&tag_pyld_ret)) {
				IPAERR("Failed to populate tag field\n");
				goto failure;
				goto failure_dma_map;
			}
		}

@@ -470,11 +468,6 @@ int ipa3_send(struct ipa3_sys_context *sys,
					tx_pkt->mem.base,
					tx_pkt->mem.size,
					DMA_TO_DEVICE);
				if (!tx_pkt->mem.phys_base) {
					IPAERR("failed to do dma map.\n");
					fail_dma_wrap = 1;
					goto failure;
				}
			} else {
					tx_pkt->mem.phys_base =
						desc[i].dma_address;
@@ -490,17 +483,17 @@ int ipa3_send(struct ipa3_sys_context *sys,
					desc[i].frag,
					0, tx_pkt->mem.size,
					DMA_TO_DEVICE);
				if (!tx_pkt->mem.phys_base) {
					IPAERR("dma map failed\n");
					fail_dma_wrap = 1;
					goto failure;
				}
			} else {
				tx_pkt->mem.phys_base =
					desc[i].dma_address;
				tx_pkt->no_unmap_dma = true;
			}
		}
		if (dma_mapping_error(ipa3_ctx->pdev, tx_pkt->mem.phys_base)) {
			IPAERR("failed to do dma map.\n");
			goto failure_dma_map;
		}

		tx_pkt->sys = sys;
		tx_pkt->callback = desc[i].callback;
		tx_pkt->user1 = desc[i].user1;
@@ -561,28 +554,31 @@ int ipa3_send(struct ipa3_sys_context *sys,

	return 0;

failure_dma_map:
		kmem_cache_free(ipa3_ctx->tx_pkt_wrapper_cache, tx_pkt);

failure:
	ipahal_destroy_imm_cmd(tag_pyld_ret);
	tx_pkt = tx_pkt_first;
	for (j = 0; j < i; j++) {
		next_pkt = list_next_entry(tx_pkt, link);
		list_del(&tx_pkt->link);

		if (!tx_pkt->no_unmap_dma) {
			if (desc[j].type != IPA_DATA_DESC_SKB_PAGED) {
			dma_unmap_single(ipa3_ctx->pdev, tx_pkt->mem.phys_base,
				tx_pkt->mem.size,
				DMA_TO_DEVICE);
				dma_unmap_single(ipa3_ctx->pdev,
					tx_pkt->mem.phys_base,
					tx_pkt->mem.size, DMA_TO_DEVICE);
		    } else {
			dma_unmap_page(ipa3_ctx->pdev, tx_pkt->mem.phys_base,
				dma_unmap_page(ipa3_ctx->pdev,
					tx_pkt->mem.phys_base,
					tx_pkt->mem.size,
					DMA_TO_DEVICE);
			}
		}
		kmem_cache_free(ipa3_ctx->tx_pkt_wrapper_cache, tx_pkt);
		tx_pkt = next_pkt;
	}
	if (j < num_desc)
		/* last desc failed */
		if (fail_dma_wrap)
			kmem_cache_free(ipa3_ctx->tx_pkt_wrapper_cache, tx_pkt);

	kfree(gsi_xfer_elem_array);
	spin_unlock_bh(&sys->spinlock);
@@ -1825,8 +1821,7 @@ begin:
		rx_pkt->data.dma_addr = dma_map_single(ipa3_ctx->pdev, ptr,
						     sys->rx_buff_sz,
						     DMA_FROM_DEVICE);
		if (rx_pkt->data.dma_addr == 0 ||
				rx_pkt->data.dma_addr == ~0) {
		if (dma_mapping_error(ipa3_ctx->pdev, rx_pkt->data.dma_addr)) {
			pr_err_ratelimited("%s dma map fail %p for %p sys=%p\n",
			       __func__, (void *)rx_pkt->data.dma_addr,
			       ptr, sys);
@@ -1993,8 +1988,7 @@ static void ipa3_alloc_wlan_rx_common_cache(u32 size)
		ptr = skb_put(rx_pkt->data.skb, IPA_WLAN_RX_BUFF_SZ);
		rx_pkt->data.dma_addr = dma_map_single(ipa3_ctx->pdev, ptr,
				IPA_WLAN_RX_BUFF_SZ, DMA_FROM_DEVICE);
		if (rx_pkt->data.dma_addr == 0 ||
				rx_pkt->data.dma_addr == ~0) {
		if (dma_mapping_error(ipa3_ctx->pdev, rx_pkt->data.dma_addr)) {
			IPAERR("dma_map_single failure %p for %p\n",
			       (void *)rx_pkt->data.dma_addr, ptr);
			goto fail_dma_mapping;
@@ -2065,8 +2059,7 @@ static void ipa3_replenish_rx_cache(struct ipa3_sys_context *sys)
		rx_pkt->data.dma_addr = dma_map_single(ipa3_ctx->pdev, ptr,
						     sys->rx_buff_sz,
						     DMA_FROM_DEVICE);
		if (rx_pkt->data.dma_addr == 0 ||
				rx_pkt->data.dma_addr == ~0) {
		if (dma_mapping_error(ipa3_ctx->pdev, rx_pkt->data.dma_addr)) {
			IPAERR("dma_map_single failure %p for %p\n",
			       (void *)rx_pkt->data.dma_addr, ptr);
			goto fail_dma_mapping;
@@ -2165,8 +2158,8 @@ static void ipa3_replenish_rx_cache_recycle(struct ipa3_sys_context *sys)
			ptr = skb_put(rx_pkt->data.skb, sys->rx_buff_sz);
			rx_pkt->data.dma_addr = dma_map_single(ipa3_ctx->pdev,
				ptr, sys->rx_buff_sz, DMA_FROM_DEVICE);
			if (rx_pkt->data.dma_addr == 0 ||
				rx_pkt->data.dma_addr == ~0) {
			if (dma_mapping_error(ipa3_ctx->pdev,
				rx_pkt->data.dma_addr)) {
				IPAERR("dma_map_single failure %p for %p\n",
					(void *)rx_pkt->data.dma_addr, ptr);
				goto fail_dma_mapping;
@@ -2181,8 +2174,8 @@ static void ipa3_replenish_rx_cache_recycle(struct ipa3_sys_context *sys)
			ptr = skb_put(rx_pkt->data.skb, sys->rx_buff_sz);
			rx_pkt->data.dma_addr = dma_map_single(ipa3_ctx->pdev,
				ptr, sys->rx_buff_sz, DMA_FROM_DEVICE);
			if (rx_pkt->data.dma_addr == 0 ||
				rx_pkt->data.dma_addr == ~0) {
			if (dma_mapping_error(ipa3_ctx->pdev,
				rx_pkt->data.dma_addr)) {
				IPAERR("dma_map_single failure %p for %p\n",
					(void *)rx_pkt->data.dma_addr, ptr);
				goto fail_dma_mapping;
+7 −0
Original line number Diff line number Diff line
@@ -491,6 +491,10 @@ static int __ipa_add_hdr(struct ipa_hdr_add *hdr)
			entry->hdr,
			entry->hdr_len,
			DMA_TO_DEVICE);
		if (dma_mapping_error(ipa3_ctx->pdev, entry->phys_base)) {
			IPAERR("dma_map_single failure for entry\n");
			goto fail_dma_mapping;
		}
	} else {
		entry->is_hdr_proc_ctx = false;
		if (list_empty(&htbl->head_free_offset_list[bin])) {
@@ -566,6 +570,9 @@ fail_add_proc_ctx:
	list_del(&entry->link);
	dma_unmap_single(ipa3_ctx->pdev, entry->phys_base,
			entry->hdr_len, DMA_TO_DEVICE);
fail_dma_mapping:
	entry->is_hdr_proc_ctx = false;

bad_hdr_len:
	entry->cookie = 0;
	kmem_cache_free(ipa3_ctx->hdr_cache, entry);