public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Oscar Mateo <oscar.mateo@intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Deepak S <deepak.s@intel.com>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/i915/guc: Dynamically alloc GuC descriptor
Date: Tue, 7 Feb 2017 00:55:21 -0800	[thread overview]
Message-ID: <c5cdb8f3-4077-ae78-3a9b-edbd212072cd@intel.com> (raw)
In-Reply-To: <20170203073331.GA10177@nuc-i3427.alporthouse.com>



On 02/02/2017 11:33 PM, Chris Wilson wrote:
> On Thu, Feb 02, 2017 at 07:27:45AM -0800, Oscar Mateo wrote:
>> From: Michal Wajdeczko <michal.wajdeczko@intel.com>
>>
>> The GuC descriptor is big in size. If we use local definition of
>> guc_desc we have a chance to overflow stack. Use allocated one.
>>
>> v2: Rebased
>> v3: Split
>> v4: Handle ENOMEM, cover all uses of guc_context_desc, use kzalloc (Oscar)
>>
>> Signed-off-by: Deepak S <deepak.s@intel.com>
>> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
>> Signed-off-by: Oscar Mateo <oscar.mateo@intel.com>
>> ---
>>   drivers/gpu/drm/i915/i915_guc_submission.c | 94 ++++++++++++++++++------------
>>   1 file changed, 57 insertions(+), 37 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/i915_guc_submission.c b/drivers/gpu/drm/i915/i915_guc_submission.c
>> index 8ced9e2..b4f14f3 100644
>> --- a/drivers/gpu/drm/i915/i915_guc_submission.c
>> +++ b/drivers/gpu/drm/i915/i915_guc_submission.c
>> @@ -102,9 +102,13 @@ static int guc_update_doorbell_id(struct intel_guc *guc,
>>   	struct sg_table *sg = guc->ctx_pool_vma->pages;
>>   	void *doorbell_bitmap = guc->doorbell_bitmap;
>>   	struct guc_doorbell_info *doorbell;
>> -	struct guc_context_desc desc;
>> +	struct guc_context_desc *desc;
>>   	size_t len;
>>   
>> +	desc = kzalloc(sizeof(*desc), GFP_KERNEL);
>> +	if (!desc)
>> +		return -ENOMEM;
>> +
>>   	doorbell = client->vaddr + client->doorbell_offset;
>>   
>>   	if (client->doorbell_id != GUC_INVALID_DOORBELL_ID &&
>> @@ -116,15 +120,22 @@ static int guc_update_doorbell_id(struct intel_guc *guc,
>>   	}
>>   
>>   	/* Update the GuC's idea of the doorbell ID */
>> -	len = sg_pcopy_to_buffer(sg->sgl, sg->nents, &desc, sizeof(desc),
>> -			     sizeof(desc) * client->ctx_index);
>> -	if (len != sizeof(desc))
>> +	len = sg_pcopy_to_buffer(sg->sgl, sg->nents, desc, sizeof(*desc),
>> +				 sizeof(*desc) * client->ctx_index);
> This is silly. You are creating a pointer using kmalloc to copy into a
> pointer created using alloc_page. Just write directly into the backing
> store.
> -Chris
>

I guess I deserve this for not digging any deeper. From what I can see, 
the backing store is an array of 1024 context descriptors. If the whole 
context descriptor fell in one page, I could kmap_atomic only that. As 
it is, I would need to vmap a couple of pages to make sure I always get 
a complete pointer to guc_context_desc. Would you be happy with that?
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2017-02-07 16:55 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-02 15:27 [PATCH] drm/i915/guc: Dynamically alloc GuC descriptor Oscar Mateo
2017-02-02 23:52 ` ✓ Fi.CI.BAT: success for " Patchwork
2017-02-03  7:33 ` [PATCH] " Chris Wilson
2017-02-07  8:55   ` Oscar Mateo [this message]
2017-02-07 17:25     ` Chris Wilson
2017-02-07  9:37       ` Oscar Mateo
2017-02-07 20:49         ` Chris Wilson
2017-02-09 10:23           ` [PATCH] drm/i915/guc: Keep the ctx_pool_vaddr mapped, for easy access Oscar Mateo
2017-02-09 21:01             ` Chris Wilson
2017-02-13 16:05               ` Oscar Mateo
2017-02-15 12:37             ` Joonas Lahtinen
2017-02-16 14:15               ` [PATCH v2] " Oscar Mateo
2017-02-16 14:18                 ` Oscar Mateo
2017-02-16 22:50                 ` Chris Wilson
2017-02-09 18:52 ` ✓ Fi.CI.BAT: success for drm/i915/guc: Dynamically alloc GuC descriptor (rev2) Patchwork

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=c5cdb8f3-4077-ae78-3a9b-edbd212072cd@intel.com \
    --to=oscar.mateo@intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=deepak.s@intel.com \
    --cc=intel-gfx@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