From: Mika Kuoppala <mika.kuoppala@linux.intel.com>
To: Ben Widawsky <ben@bwidawsk.net>
Cc: intel-gfx@lists.freedesktop.org, miku@iki.fi
Subject: Re: [PATCH 2/2] drm/i915: unreference default context on module unload
Date: Thu, 02 May 2013 11:37:02 +0300 [thread overview]
Message-ID: <87a9od6amp.fsf@gaia.fi.intel.com> (raw)
In-Reply-To: <20130430154941.GA7621@bwidawsk.net>
Ben Widawsky <ben@bwidawsk.net> writes:
> On Tue, Apr 30, 2013 at 01:30:34PM +0300, Mika Kuoppala wrote:
>> Before module unload is called, gpu_idle() will switch
>> to default context. This will increment ref count of base
>> object as the default context is 'running' on module unload
>> time. Unreference the drm object so that when context
>> is freed, base object is freed as well.
>>
>> Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
>
>
> I would have liked the patch to be distinct from the context refcounting
> since it really is a fix unrelated to the context refcounting. I don't
> think you need to resend though.
>
> I also think the commit message is false. The unload code will call
> gpu_idle, yes, but it also will also idle the ring, wait for it to
> complete and then immediately call i915_gem_retire_requests. Unless I'm
> missing something that will handle the missing unref, and the only ref
> possibly at that point is the one we have from when we created the
> object.
>
> The reset case can leave a ref over - but that's okay AFAICT.
>
> I know we discussed this on IRC a few days ago, and then you convinced
> me that we need this, but my brain reset. Can you explain where I've
> gotten lost?
This is how I see it:
When default context is created and switched to, base object refcount is
2. +1 from object creation, +1 from do_switch.
It is 2 also when _fini is called, as we are running in default context.
So if the i915_gem_context_unreference at the end of _fini
will decrement the object creation part, we still need to offset the
do_switch part, to free the base object.
-Mika
> I still want to play around with patch 1 a bit more.
>
>> ---
>> drivers/gpu/drm/i915/i915_gem_context.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
>> index 9e8c685..30f7f4c 100644
>> --- a/drivers/gpu/drm/i915/i915_gem_context.c
>> +++ b/drivers/gpu/drm/i915/i915_gem_context.c
>> @@ -274,6 +274,7 @@ void i915_gem_context_fini(struct drm_device *dev)
>> intel_gpu_reset(dev);
>>
>> i915_gem_object_unpin(dctx->obj);
>> + drm_gem_object_unreference(&dctx->obj->base);
>> i915_gem_context_unreference(dctx);
>> }
>>
>> --
>> 1.7.9.5
>>
>> _______________________________________________
>> Intel-gfx mailing list
>> Intel-gfx@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
>
> --
> Ben Widawsky, Intel Open Source Technology Center
next prev parent reply other threads:[~2013-05-02 8:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-30 10:30 [PATCH 1/2] drm/i915: reference count for i915_hw_contexts Mika Kuoppala
2013-04-30 10:30 ` [PATCH 2/2] drm/i915: unreference default context on module unload Mika Kuoppala
2013-04-30 15:49 ` Ben Widawsky
2013-05-02 8:37 ` Mika Kuoppala [this message]
2013-05-02 16:10 ` Ben Widawsky
2013-05-03 13:29 ` [PATCH v2] " Mika Kuoppala
2013-05-03 15:53 ` Ben Widawsky
2013-05-03 16:22 ` Daniel Vetter
2013-04-30 18:40 ` [PATCH 1/2] drm/i915: reference count for i915_hw_contexts Ben Widawsky
2013-04-30 21:39 ` 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=87a9od6amp.fsf@gaia.fi.intel.com \
--to=mika.kuoppala@linux.intel.com \
--cc=ben@bwidawsk.net \
--cc=intel-gfx@lists.freedesktop.org \
--cc=miku@iki.fi \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.