dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: Dave Airlie <airlied@gmail.com>, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] intel: add prime interface for getting/setting a prime bo. (v3)
Date: Mon, 16 Jul 2012 07:50:40 +0100	[thread overview]
Message-ID: <1342421457_3045@CP5-2952> (raw)
In-Reply-To: <1342403477-11709-1-git-send-email-airlied@gmail.com>

On Mon, 16 Jul 2012 02:51:17 +0100, Dave Airlie <airlied@gmail.com> wrote:
> This adds interfaces for the X driver to use to create a
> prime handle from a buffer, and create a bo from a handle.
> 
> v2: use Chris's suggested naming (well from at least for consistency)
> v3: git commit --amend fail
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
>  intel/intel_bufmgr.h     |    4 ++++
>  intel/intel_bufmgr_gem.c |   46 ++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 50 insertions(+)
> 
> diff --git a/intel/intel_bufmgr.h b/intel/intel_bufmgr.h
> index 9b3a483..2167e43 100644
> --- a/intel/intel_bufmgr.h
> +++ b/intel/intel_bufmgr.h
> @@ -192,6 +192,10 @@ void drm_intel_gem_context_destroy(drm_intel_context *ctx);
>  int drm_intel_gem_bo_context_exec(drm_intel_bo *bo, drm_intel_context *ctx,
>  				  int used, unsigned int flags);
>  
> +int drm_intel_bo_gem_export_to_prime(drm_intel_bo *bo, int *prime_fd);
> +drm_intel_bo *drm_intel_bo_gem_create_from_prime(drm_intel_bufmgr *bufmgr,
> +						int prime_fd, int size);
> +
>  /* drm_intel_bufmgr_fake.c */
>  drm_intel_bufmgr *drm_intel_bufmgr_fake_init(int fd,
>  					     unsigned long low_offset,
> diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
> index 12a3197..7966924 100644
> --- a/intel/intel_bufmgr_gem.c
> +++ b/intel/intel_bufmgr_gem.c
> @@ -2413,6 +2413,52 @@ drm_intel_gem_bo_get_tiling(drm_intel_bo *bo, uint32_t * tiling_mode,
>  	return 0;
>  }
>  
> +drm_intel_bo *
> +drm_intel_bo_gem_create_from_prime(drm_intel_bufmgr *bufmgr, int prime_fd, int size)
> +{
> +	drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *) bufmgr;
> +	int ret;
> +	uint32_t handle;
> +	drm_intel_bo_gem *bo_gem;
> +	ret = drmPrimeFDToHandle(bufmgr_gem->fd, prime_fd, &handle);
> +	if (ret) {
> +	  fprintf(stderr,"ret is %d %d\n", ret, errno);
> +		return NULL;
> +	}
> +
> +	bo_gem = calloc(1, sizeof(*bo_gem));
> +	if (!bo_gem)
> +		return NULL;
> +
> +	bo_gem->bo.size = size;
> +	bo_gem->name = "prime";
> +	atomic_set(&bo_gem->refcount, 1);
> +	bo_gem->validate_index = -1;
> +	bo_gem->reloc_tree_fences = 0;
> +	bo_gem->used_as_reloc_target = false;
> +	bo_gem->has_error = false;
> +	bo_gem->reusable = false;
> +
> +	bo_gem->bo.handle = handle;
> +	bo_gem->bo.bufmgr = bufmgr;

Can you group the 3 bo_gem->bo initialisation together, and move the
bo_gem->gem_handle initialisation closer. Perhaps:

  bo_gem->bo =

  bo_gem->gem_handle =
  bo_gem->* =

> +
> +	DRMINITLISTHEAD(&bo_gem->name_list);
> +	DRMINITLISTHEAD(&bo_gem->vma_list);
> +
> +	bo_gem->gem_handle = handle;

Comparing with create_from_name(), we should query the tiling at this
point - DRM_IOCTL_i915_GEM_GET_TILING.

That's the only thing missing that I could spot.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre

      reply	other threads:[~2012-07-16  6:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-16  1:51 [PATCH] intel: add prime interface for getting/setting a prime bo. (v3) Dave Airlie
2012-07-16  6:50 ` Chris Wilson [this message]

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=1342421457_3045@CP5-2952 \
    --to=chris@chris-wilson.co.uk \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    /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