diff mbox

intel: Mark bo's exported to prime as not reusable

Message ID 1347655073-15167-1-git-send-email-krh@bitplanet.net (mailing list archive)
State New, archived
Headers show

Commit Message

Kristian Hogsberg Sept. 14, 2012, 8:37 p.m. UTC
It's the same situation as flink and we need take the same pre-cautions.
---
 intel/intel_bufmgr_gem.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Kristian Hogsberg Sept. 14, 2012, 9:01 p.m. UTC | #1
On Fri, Sep 14, 2012 at 4:40 PM, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> On Fri, 14 Sep 2012 16:37:53 -0400, Kristian Høgsberg <krh@bitplanet.net> wrote:
>> It's the same situation as flink and we need take the same pre-cautions.
>> ---
>>  intel/intel_bufmgr_gem.c |    8 +++++++-
>>  1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
>> index 3bcc849..92c0444 100644
>> --- a/intel/intel_bufmgr_gem.c
>> +++ b/intel/intel_bufmgr_gem.c
>> @@ -2472,8 +2472,14 @@ drm_intel_bo_gem_export_to_prime(drm_intel_bo *bo, int *prime_fd)
>>  {
>>       drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *) bo->bufmgr;
>>       drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo;
>> +     int ret;
>>
>> -     return drmPrimeHandleToFD(bufmgr_gem->fd, bo_gem->gem_handle, DRM_CLOEXEC, prime_fd);
>> +     ret = drmPrimeHandleToFD(bufmgr_gem->fd, bo_gem->gem_handle,
>> +                              DRM_CLOEXEC, prime_fd);
>> +     if (ret == 0)
>> +             bo_gem->reusable = false;
>
> Now that you mention it...
> To be consistent with libdrm_intel, we should return -errno on error; so
> rephrasing this as
>   if (ret)
>     return -errno;
>
>   bo_gem->reusable = false;
>   return 0;
>
> would work better.

Argh, yes, I copy and pasted that from drm_intel_gem_bo_flink() but
edited it away later...  with that change, can I add your reviewed-by
and commit?

Kristian
Kristian Hogsberg Sept. 15, 2012, 2:12 a.m. UTC | #2
On Fri, Sep 14, 2012 at 5:03 PM, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> On Fri, 14 Sep 2012 17:01:18 -0400, Kristian Høgsberg <krh@bitplanet.net> wrote:
>> On Fri, Sep 14, 2012 at 4:40 PM, Chris Wilson <chris@chris-wilson.co.uk> wrote:
>> > On Fri, 14 Sep 2012 16:37:53 -0400, Kristian Høgsberg <krh@bitplanet.net> wrote:
>> >> It's the same situation as flink and we need take the same pre-cautions.
>> >> ---
>> >>  intel/intel_bufmgr_gem.c |    8 +++++++-
>> >>  1 file changed, 7 insertions(+), 1 deletion(-)
>> >>
>> >> diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
>> >> index 3bcc849..92c0444 100644
>> >> --- a/intel/intel_bufmgr_gem.c
>> >> +++ b/intel/intel_bufmgr_gem.c
>> >> @@ -2472,8 +2472,14 @@ drm_intel_bo_gem_export_to_prime(drm_intel_bo *bo, int *prime_fd)
>> >>  {
>> >>       drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *) bo->bufmgr;
>> >>       drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo;
>> >> +     int ret;
>> >>
>> >> -     return drmPrimeHandleToFD(bufmgr_gem->fd, bo_gem->gem_handle, DRM_CLOEXEC, prime_fd);
>> >> +     ret = drmPrimeHandleToFD(bufmgr_gem->fd, bo_gem->gem_handle,
>> >> +                              DRM_CLOEXEC, prime_fd);
>> >> +     if (ret == 0)
>> >> +             bo_gem->reusable = false;
>> >
>> > Now that you mention it...
>> > To be consistent with libdrm_intel, we should return -errno on error; so
>> > rephrasing this as
>> >   if (ret)
>> >     return -errno;
>> >
>> >   bo_gem->reusable = false;
>> >   return 0;
>> >
>> > would work better.
>>
>> Argh, yes, I copy and pasted that from drm_intel_gem_bo_flink() but
>> edited it away later...  with that change, can I add your reviewed-by
>> and commit?
>
> Yes,
>
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
> -Chris

Thanks, pushed.  Btw, before this patch,
drm_intel_bo_gem_export_to_prime() was actually just returning the
drmPrimeHandleToFD() return value directly, not -errno on error.

Kristian
diff mbox

Patch

diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
index 3bcc849..92c0444 100644
--- a/intel/intel_bufmgr_gem.c
+++ b/intel/intel_bufmgr_gem.c
@@ -2472,8 +2472,14 @@  drm_intel_bo_gem_export_to_prime(drm_intel_bo *bo, int *prime_fd)
 {
 	drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *) bo->bufmgr;
 	drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo;
+	int ret;
 
-	return drmPrimeHandleToFD(bufmgr_gem->fd, bo_gem->gem_handle, DRM_CLOEXEC, prime_fd);
+	ret = drmPrimeHandleToFD(bufmgr_gem->fd, bo_gem->gem_handle,
+				 DRM_CLOEXEC, prime_fd);
+	if (ret == 0)
+		bo_gem->reusable = false;
+
+	return ret;
 }
 
 static int