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

Commit 55317ea0 authored by Nirmal Abraham's avatar Nirmal Abraham
Browse files

msm: mdss: use vmalloc for sglist allocation



In scenarios where system is running low on memory, the
sglist allocation during sg_table cloning was failing as
there was no order 4 pages available. The cloned list
is only used for iommu map/unmap SW ops and not used by HW.
So it's safe to use physically noncontinuous sglist.
Thus replacing kmalloc with vmalloc for sglist allocation.

Change-Id: I80a10377398f90756df9533a78a63f4da3fe9a43
Signed-off-by: default avatarNirmal Abraham <nabrah@codeaurora.org>
parent 035363ab
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@
#include <linux/msm-bus-board.h>
#include <linux/qcom_iommu.h>
#include <linux/msm_iommu_domains.h>
#include <linux/vmalloc.h>

#include <linux/msm_dma_iommu_mapping.h>

@@ -1869,7 +1870,7 @@ int mdp3_put_img(struct mdp3_img_data *data, int client)
		return -EINVAL;
	}
	if (client == MDP3_CLIENT_PPP || client == MDP3_CLIENT_DMA_P) {
		kfree(data->tab_clone->sgl);
		vfree(data->tab_clone->sgl);
		kfree(data->tab_clone);
	}
	return 0;
@@ -2026,7 +2027,7 @@ err_unmap:
	dma_buf_put(data->srcp_dma_buf);

	if (client ==  MDP3_CLIENT_PPP || client == MDP3_CLIENT_DMA_P) {
		kfree(data->tab_clone->sgl);
		vfree(data->tab_clone->sgl);
		kfree(data->tab_clone);
	}
	return ret;
+4 −3
Original line number Diff line number Diff line
/* Copyright (c) 2007-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2007-2018, 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
@@ -26,6 +26,7 @@
#include <linux/dma-buf.h>
#include <linux/of_platform.h>
#include <linux/msm_dma_iommu_mapping.h>
#include <linux/vmalloc.h>

#include <linux/qcom_iommu.h>
#include <asm/dma-iommu.h>
@@ -495,7 +496,7 @@ static void mdss_smmu_deinit_v2(struct mdss_data_type *mdata)
 *   either sides of sgl.
 *
 * Returns:
 *   Pointer to new kmalloced sg list, ERR_PTR() on error
 *   Pointer to new vmalloced sg list, ERR_PTR() on error
 *
 */
static struct scatterlist *sg_clone(struct scatterlist *orig_sgl, u64 len,
@@ -511,7 +512,7 @@ static struct scatterlist *sg_clone(struct scatterlist *orig_sgl, u64 len,
	if (padding)
		nents += 2;

	head = kmalloc_array(nents, sizeof(struct scatterlist), gfp_mask);
	head = vmalloc(nents * sizeof(struct scatterlist));
	if (!head)
		return ERR_PTR(-ENOMEM);