dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Inki Dae <inki.dae@samsung.com>
To: Joonyoung Shim <jy0922.shim@samsung.com>,
	dri-devel@lists.freedesktop.org
Cc: sw0312.kim@samsung.com
Subject: Re: [PATCH 6/9] drm/exynos: switch to new buffer allocation
Date: Mon, 19 Oct 2015 21:20:10 +0900	[thread overview]
Message-ID: <5624DFFA.50602@samsung.com> (raw)
In-Reply-To: <1444719654-10639-7-git-send-email-jy0922.shim@samsung.com>

Hi,

How about combining patch 5 and 6?

Patch 5 just introduces new internal API but these API aren't used 
anywhere in patch 5.

Thanks,
Inki Dae

2015년 10월 13일 16:00에 Joonyoung Shim 이(가) 쓴 글:
> The buffer allocation using DMA mapping API can't support non-continuous
> buffer on non-iommu and cachable buffer, so switch to new buffer
> allocation using drm_gem_get/put_pages() and doesn't use DMA mapping API
> for mmap except allocation of physically continuous buffer on non-iommu.
>
> Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
> ---
>   drivers/gpu/drm/exynos/exynos_drm_gem.c | 90 +++++++++++----------------------
>   1 file changed, 29 insertions(+), 61 deletions(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c
> index d982d46b04da..163d113df1ab 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_gem.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c
> @@ -77,10 +77,7 @@ static int exynos_drm_alloc_dma(struct exynos_drm_gem *exynos_gem)
>
>   	init_dma_attrs(&exynos_gem->dma_attrs);
>
> -	if (exynos_gem->flags & EXYNOS_BO_WC ||
> -			!(exynos_gem->flags & EXYNOS_BO_CACHABLE))
> -		dma_set_attr(DMA_ATTR_WRITE_COMBINE, &exynos_gem->dma_attrs);
> -
> +	dma_set_attr(DMA_ATTR_WRITE_COMBINE, &exynos_gem->dma_attrs);
>   	dma_set_attr(DMA_ATTR_NO_KERNEL_MAPPING, &exynos_gem->dma_attrs);
>
>   	nr_pages = exynos_gem->size >> PAGE_SHIFT;
> @@ -128,51 +125,21 @@ static void exynos_drm_free_dma(struct exynos_drm_gem *exynos_gem)
>   static int exynos_drm_alloc_buf(struct exynos_drm_gem *exynos_gem)
>   {
>   	struct drm_device *dev = exynos_gem->base.dev;
> -	enum dma_attr attr;
> -	unsigned int nr_pages;
> +	int ret;
>
>   	if (exynos_gem->dma_addr) {
>   		DRM_DEBUG_KMS("already allocated.\n");
>   		return 0;
>   	}
>
> -	if (!is_drm_iommu_supported(dev))
> -		return exynos_drm_alloc_dma(exynos_gem);
> -
> -	init_dma_attrs(&exynos_gem->dma_attrs);
> -
> -	/*
> -	 * if EXYNOS_BO_CONTIG, fully physically contiguous memory
> -	 * region will be allocated else physically contiguous
> -	 * as possible.
> -	 */
> -	if (!(exynos_gem->flags & EXYNOS_BO_NONCONTIG))
> -		dma_set_attr(DMA_ATTR_FORCE_CONTIGUOUS, &exynos_gem->dma_attrs);
> -
> -	/* if EXYNOS_BO_WC or EXYNOS_BO_NONCACHABLE, writecombine mapping */
> -	if (exynos_gem->flags & EXYNOS_BO_WC ||
> -			!(exynos_gem->flags & EXYNOS_BO_CACHABLE))
> -		attr = DMA_ATTR_WRITE_COMBINE;
> -
> -	dma_set_attr(attr, &exynos_gem->dma_attrs);
> -	dma_set_attr(DMA_ATTR_NO_KERNEL_MAPPING, &exynos_gem->dma_attrs);
> -
> -	nr_pages = exynos_gem->size >> PAGE_SHIFT;
> -
> -	exynos_gem->cookie = dma_alloc_attrs(dev->dev, exynos_gem->size,
> -					     &exynos_gem->dma_addr, GFP_KERNEL,
> -					     &exynos_gem->dma_attrs);
> -	if (!exynos_gem->cookie) {
> -		DRM_ERROR("failed to allocate buffer.\n");
> -		if (exynos_gem->pages)
> -			drm_free_large(exynos_gem->pages);
> -		return -ENOMEM;
> +	if (!is_drm_iommu_supported(dev)) {
> +		if (!(exynos_gem->flags & EXYNOS_BO_NONCONTIG))
> +			return exynos_drm_alloc_dma(exynos_gem);
>   	}
>
> -	exynos_gem->pages = exynos_gem->cookie;
> -
> -	DRM_DEBUG_KMS("dma_addr(0x%lx), size(0x%lx)\n",
> -			(unsigned long)exynos_gem->dma_addr, exynos_gem->size);
> +	ret = exynos_drm_get_pages(exynos_gem);
> +	if (ret < 0)
> +		return ret;
>
>   	return 0;
>   }
> @@ -186,15 +153,12 @@ static void exynos_drm_free_buf(struct exynos_drm_gem *exynos_gem)
>   		return;
>   	}
>
> -	if (!is_drm_iommu_supported(dev))
> -		return exynos_drm_free_dma(exynos_gem);
> -
> -	DRM_DEBUG_KMS("dma_addr(0x%lx), size(0x%lx)\n",
> -			(unsigned long)exynos_gem->dma_addr, exynos_gem->size);
> +	if (!is_drm_iommu_supported(dev)) {
> +		if (!(exynos_gem->flags & EXYNOS_BO_NONCONTIG))
> +			return exynos_drm_free_dma(exynos_gem);
> +	}
>
> -	dma_free_attrs(dev->dev, exynos_gem->size, exynos_gem->cookie,
> -			(dma_addr_t)exynos_gem->dma_addr,
> -			&exynos_gem->dma_attrs);
> +	exynos_drm_put_pages(exynos_gem);
>   }
>
>   static int exynos_drm_gem_handle_create(struct drm_gem_object *obj,
> @@ -400,8 +364,8 @@ void exynos_drm_gem_put_dma_addr(struct drm_device *dev,
>   	drm_gem_object_unreference_unlocked(obj);
>   }
>
> -static int exynos_drm_gem_mmap_buffer(struct exynos_drm_gem *exynos_gem,
> -				      struct vm_area_struct *vma)
> +static int exynos_drm_gem_mmap_dma(struct exynos_drm_gem *exynos_gem,
> +				   struct vm_area_struct *vma)
>   {
>   	struct drm_device *drm_dev = exynos_gem->base.dev;
>   	unsigned long vm_size;
> @@ -579,6 +543,19 @@ int exynos_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
>
>   	DRM_DEBUG_KMS("flags = 0x%x\n", exynos_gem->flags);
>
> +	if (!is_drm_iommu_supported(obj->dev)) {
> +		if (!(exynos_gem->flags & EXYNOS_BO_NONCONTIG)) {
> +			ret = exynos_drm_gem_mmap_dma(exynos_gem, vma);
> +			if (ret < 0)
> +				drm_gem_vm_close(vma);
> +
> +			return ret;
> +		}
> +	}
> +
> +	vma->vm_flags &= ~VM_PFNMAP;
> +	vma->vm_flags |= VM_MIXEDMAP;
> +
>   	/* non-cachable as default. */
>   	if (exynos_gem->flags & EXYNOS_BO_CACHABLE)
>   		vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
> @@ -589,16 +566,7 @@ int exynos_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
>   		vma->vm_page_prot =
>   			pgprot_noncached(vm_get_page_prot(vma->vm_flags));
>
> -	ret = exynos_drm_gem_mmap_buffer(exynos_gem, vma);
> -	if (ret)
> -		goto err_close_vm;
> -
> -	return ret;
> -
> -err_close_vm:
> -	drm_gem_vm_close(vma);
> -
> -	return ret;
> +	return 0;
>   }
>
>   /* low-level interface prime helpers */
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2015-10-19 12:20 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-13  7:00 [PATCH 0/9] drm/exynos: update codes related with gem Joonyoung Shim
2015-10-13  7:00 ` [PATCH 1/9] drm/exynos: eliminate useless codes of exynos_drm_gem.h Joonyoung Shim
2015-10-13  7:00 ` [PATCH 2/9] drm/exynos: use directly DMA mapping APIs on g2d Joonyoung Shim
2015-10-13  7:00 ` [PATCH 3/9] drm/exynos: remove using non-consistent DMA attribute Joonyoung Shim
2015-10-13  7:00 ` [PATCH 4/9] drm/exynos: split buffer allocation using DMA mapping API on non-iommu Joonyoung Shim
2015-10-13  7:00 ` [PATCH 5/9] drm/exynos: introduce buffer allocation using drm_gem_get/put_pages() Joonyoung Shim
2015-10-13  7:00 ` [PATCH 6/9] drm/exynos: switch to new buffer allocation Joonyoung Shim
2015-10-19 12:20   ` Inki Dae [this message]
2015-10-20  6:03     ` Joonyoung Shim
2015-10-13  7:00 ` [PATCH 7/9] drm/exynos: always use EXYNOS_BO_CONTIG flag on iommu Joonyoung Shim
2015-10-13  7:00 ` [PATCH 8/9] drm/exynos: use DMA_ERROR_CODE Joonyoung Shim
2015-10-13  7:00 ` [PATCH 9/9] drm/exynos: add ioctls for cpu access of gem object from user Joonyoung Shim
2015-10-13  8:27 ` [PATCH 0/9] drm/exynos: update codes related with gem Daniel Vetter
2015-10-13  8:37   ` Joonyoung Shim
2015-10-13  9:32     ` Joonyoung Shim
2015-10-13 12:29       ` Daniel Vetter
2015-10-14  0:33         ` Joonyoung Shim
2015-10-14  7:43           ` Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5624DFFA.50602@samsung.com \
    --to=inki.dae@samsung.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jy0922.shim@samsung.com \
    --cc=sw0312.kim@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox