public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Dave Gordon <david.s.gordon@intel.com>
To: yu.dai@intel.com, intel-gfx@lists.freedesktop.org
Cc: "Michael H. Nguyen" <michael.h.nguyen@intel.com>
Subject: Re: [PATCH v3 02/15] drm/i915: Add i915_gem_object_write() to i915_gem.c
Date: Tue, 21 Apr 2015 19:46:36 +0100	[thread overview]
Message-ID: <55369B0C.4090209@intel.com> (raw)
In-Reply-To: <553699BE.1070003@intel.com>

On 21/04/15 19:41, Dave Gordon wrote:
> On 17/04/15 22:21, yu.dai@intel.com wrote:
>> From: "Michael H. Nguyen" <michael.h.nguyen@intel.com>
>>
>> i915_gem_object_write() is a generic function to copy data from
>> user memory to gem object.
>>
>> Issue: VIZ-4884
>> Signed-off-by: Alex Dai <yu.dai@intel.com>
>> ---
>>  drivers/gpu/drm/i915/i915_drv.h |  3 +++
>>  drivers/gpu/drm/i915/i915_gem.c | 30 ++++++++++++++++++++++++++++++
>>  2 files changed, 33 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
>> index 40ef672..6e8d106 100644
>> --- a/drivers/gpu/drm/i915/i915_drv.h
>> +++ b/drivers/gpu/drm/i915/i915_drv.h
>> @@ -2645,6 +2645,9 @@ void i915_init_vm(struct drm_i915_private *dev_priv,
>>  void i915_gem_free_object(struct drm_gem_object *obj);
>>  void i915_gem_vma_destroy(struct i915_vma *vma);
>>  
>> +int i915_gem_object_write(struct drm_i915_gem_object *obj,
>> +			const void *data, const size_t size);
>> +
>>  #define PIN_MAPPABLE 0x1
>>  #define PIN_NONBLOCK 0x2
>>  #define PIN_GLOBAL 0x4
>> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
>> index f7b8766..44154fe 100644
>> --- a/drivers/gpu/drm/i915/i915_gem.c
>> +++ b/drivers/gpu/drm/i915/i915_gem.c
>> @@ -5260,3 +5260,33 @@ bool i915_gem_obj_is_pinned(struct drm_i915_gem_object *obj)
>>  	return false;
>>  }
>>  
>> +/* Fill the @obj with the @size amount of @data */
>> +int i915_gem_object_write(struct drm_i915_gem_object *obj,
>> +			const void *data, const size_t size)
>> +{
>> +	struct sg_table *sg;
>> +	size_t bytes;
>> +	int ret;
>> +
>> +	ret = i915_gem_object_get_pages(obj);
>> +	if (ret)
>> +		return ret;
>> +
>> +	i915_gem_object_pin_pages(obj);
>> +
>> +	sg = obj->pages;
>> +
>> +	bytes = sg_copy_from_buffer(sg->sgl, sg->nents,
>> +				    (void *)data, (size_t)size);
> 
> The second cast (size_t) is not required; better still, without
> that cast the code fits on one line :)
> 
>> +	i915_gem_object_unpin_pages(obj);
>> +
>> +	if (WARN(bytes != size,
>> +		 "Failed to upload all data (completed %zu bytes out of %zu total",
> 
> There's a mismatched parenthesis in the warning message above.
> Also the line is just a bit too long, according to checkpatch :(
> Perhaps just "Incomplete transfer, wrote %zu of %zu bytes" ?

Also a WARNing should have a trailing newline, so that would be
"Incomplete transfer, wrote %zu of %zu bytes\n" !

> The caller is going to issue a message too, if we ever reach
> this case, so this code doesn't have to explain too much.
> 
> With these fixed,
> 
> Reviewed-by: Dave Gordon <david.s.gordon@intel.com>
> 
>> +		 bytes, size)) {
>> +		i915_gem_object_put_pages(obj);
>> +		return -EIO;
>> +	}
>> +
>> +	return 0;
>> +}
>>
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx


_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2015-04-21 18:46 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-17 21:21 [PATCH v3 00/15] *** Command submission via GuC for SKL *** yu.dai
2015-04-17 21:21 ` [PATCH v3 01/15] drm/i915: Add guc firmware interface headers yu.dai
2015-04-17 21:21 ` [PATCH v3 02/15] drm/i915: Add i915_gem_object_write() to i915_gem.c yu.dai
2015-04-21 18:41   ` Dave Gordon
2015-04-21 18:46     ` Dave Gordon [this message]
2015-04-17 21:21 ` [PATCH v3 03/15] drm/i915: Unified firmware loading mechanism yu.dai
2015-04-23 17:12   ` Dave Gordon
2015-04-17 21:21 ` [PATCH v3 04/15] drm/i915: GuC firmware loader yu.dai
2015-04-23 17:48   ` Dave Gordon
2015-04-28 15:12     ` Dave Gordon
2015-04-28 15:18       ` Yu Dai
2015-04-17 21:21 ` [PATCH v3 05/15] drm/i915: Defer default hardware context initialisation until first open yu.dai
2015-04-23 12:25   ` Dave Gordon
2015-04-17 21:21 ` [PATCH v3 06/15] drm/i915: Move execlists defines from .c to .h yu.dai
2015-04-22 14:02   ` Dave Gordon
2015-04-17 21:21 ` [PATCH v3 07/15] drm/i915: Add functions to allocate / release gem obj for GuC yu.dai
2015-04-18 13:47   ` Chris Wilson
2015-04-20 16:02     ` Yu Dai
2015-04-20 19:52       ` Chris Wilson
2015-04-20 20:09         ` Yu Dai
2015-04-20 20:33           ` Chris Wilson
2015-04-21 17:23             ` Dave Gordon
2015-04-21 20:41               ` Chris Wilson
2015-04-17 21:21 ` [PATCH v3 08/15] drm/i915: Functions to support command submission via GuC yu.dai
2015-04-18 13:48   ` Chris Wilson
2015-04-20 16:07     ` Yu Dai
2015-04-20 19:43       ` Chris Wilson
2015-04-20 20:01         ` Yu Dai
2015-04-17 21:21 ` [PATCH v3 09/15] drm/i915: Integration of GuC client yu.dai
2015-04-17 21:21 ` [PATCH v3 10/15] drm/i915: Interrupt routing for GuC scheduler yu.dai
2015-04-17 21:21 ` [PATCH v3 11/15] drm/i915: Enable commands submission via GuC yu.dai
2015-04-17 21:21 ` [PATCH v3 12/15] drm/i915: debugfs of GuC status yu.dai
2015-04-17 21:21 ` [PATCH v3 13/15] drm/i915: Enable GuC firmware log yu.dai
2015-04-17 21:21 ` [PATCH v3 14/15] drm/i915: Taking forcewake during GuC load yu.dai
2015-04-28 15:22   ` Dave Gordon
2015-04-17 21:21 ` [PATCH v3 15/15] Documentation/drm: kerneldoc for GuC yu.dai
2015-04-18  1:13   ` shuang.he

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=55369B0C.4090209@intel.com \
    --to=david.s.gordon@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=michael.h.nguyen@intel.com \
    --cc=yu.dai@intel.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