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

Commit 19498ab3 authored by Hemant Kumar's avatar Hemant Kumar Committed by Gerrit - the friendly Code Review server
Browse files

mhi: core: Add support to allocate contiguous phys mem for bhie table



Contiguous phys memory is required per segment of the bhie table for
collecting rddm and fbc ram dumps.

Change-Id: Id21a34d4b22ed85cfa3fd559904c5a4602e5f8e7
Signed-off-by: default avatarHemant Kumar <hemantk@codeaurora.org>
parent 02974df6
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -306,7 +306,7 @@ void mhi_free_bhie_table(struct mhi_controller *mhi_cntrl,
	struct mhi_buf *mhi_buf = image_info->mhi_buf;

	for (i = 0; i < image_info->entries; i++, mhi_buf++)
		mhi_free_coherent(mhi_cntrl, mhi_buf->len, mhi_buf->buf,
		mhi_free_contig_coherent(mhi_cntrl, mhi_buf->len, mhi_buf->buf,
				  mhi_buf->dma_addr);

	kfree(image_info->mhi_buf);
@@ -347,7 +347,7 @@ int mhi_alloc_bhie_table(struct mhi_controller *mhi_cntrl,
			vec_size = sizeof(struct bhi_vec_entry) * i;

		mhi_buf->len = vec_size;
		mhi_buf->buf = mhi_alloc_coherent(mhi_cntrl, vec_size,
		mhi_buf->buf = mhi_alloc_contig_coherent(mhi_cntrl, vec_size,
					&mhi_buf->dma_addr, GFP_KERNEL);
		if (!mhi_buf->buf)
			goto error_alloc_segment;
@@ -366,7 +366,7 @@ int mhi_alloc_bhie_table(struct mhi_controller *mhi_cntrl,

error_alloc_segment:
	for (--i, --mhi_buf; i >= 0; i--, mhi_buf--)
		mhi_free_coherent(mhi_cntrl, mhi_buf->len, mhi_buf->buf,
		mhi_free_contig_coherent(mhi_cntrl, mhi_buf->len, mhi_buf->buf,
				  mhi_buf->dma_addr);

error_alloc_mhi_buf:
+24 −0
Original line number Diff line number Diff line
@@ -847,6 +847,30 @@ static inline void mhi_free_coherent(struct mhi_controller *mhi_cntrl,
	atomic_sub(size, &mhi_cntrl->alloc_size);
	dma_free_coherent(mhi_cntrl->dev, size, vaddr, dma_handle);
}

static inline void *mhi_alloc_contig_coherent(
					struct mhi_controller *mhi_cntrl,
					size_t size, dma_addr_t *dma_handle,
					gfp_t gfp)
{
	void *buf = dma_alloc_attrs(mhi_cntrl->dev, size, dma_handle, gfp,
					DMA_ATTR_FORCE_CONTIGUOUS);

	if (buf)
		atomic_add(size, &mhi_cntrl->alloc_size);

	return buf;
}
static inline void mhi_free_contig_coherent(
					struct mhi_controller *mhi_cntrl,
					size_t size, void *vaddr,
					dma_addr_t dma_handle)
{
	atomic_sub(size, &mhi_cntrl->alloc_size);
	dma_free_attrs(mhi_cntrl->dev, size, vaddr, dma_handle,
					DMA_ATTR_FORCE_CONTIGUOUS);
}

struct mhi_device *mhi_alloc_device(struct mhi_controller *mhi_cntrl);
static inline void mhi_dealloc_device(struct mhi_controller *mhi_cntrl,
				      struct mhi_device *mhi_dev)