dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Skeggs <skeggsb@gmail.com>
To: Thomas Hellstrom <thellstrom@vmware.com>
Cc: Jerome Glisse <jglisse@redhat.com>, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/ttm: pass buffer object for bind/unbind callback
Date: Sat, 19 Nov 2011 10:26:13 +1000	[thread overview]
Message-ID: <1321662373.18323.15.camel@nisroch> (raw)
In-Reply-To: <4EC6E0DA.4060907@vmware.com>

On Fri, 2011-11-18 at 23:48 +0100, Thomas Hellstrom wrote:
> On 11/18/2011 06:26 PM, Ben Skeggs wrote:
> > On Fri, 2011-11-18 at 15:30 +0100, Thomas Hellstrom wrote:
> >    
> >> On 11/18/2011 02:15 PM, Ben Skeggs wrote:
> >>      
> >>> On Fri, 2011-11-18 at 08:57 +0100, Thomas Hellstrom wrote:
> >>>
> >>>        
> >>>> Jerome,
> >>>>
> >>>> I don't like this change for the following reasons
> >>>>
> >>>>          
> >>> -snip-
> >>>
> >>>
> >>>        
> >>>>> One can take advantage of move notify callback but, there are
> >>>>> corner case where bind/unbind might be call without move notify
> >>>>> being call (in error path mostly). So to make sure that each
> >>>>> virtual address space have a consistent view of wether a buffer
> >>>>> object is backed or not by system page it's better to pass the
> >>>>> buffer object to bind/unbind.
> >>>>>
> >>>>>            
> >>> As I discussed previously with Jerome on IRC, I believe the move_notify
> >>> hook is sufficient.  I fixed a couple of issues back with it back when I
> >>> implemented support for this in nouveau.
> >>>
> >>> Jerome did point out two issues however, which I believe can be solved
> >>> easily enough.
> >>>
> >>> The first was that the error path after move_notify() has been called
> >>> doesn't reverse the move_notify() too, leaving incorrect page table
> >>> entries.  This, I think, could easily be solved by swapping bo->mem and
> >>> mem, and re-calling move_notify() to have the driver reverse whatever it
> >>> did.
> >>>
> >>> The second issue is that apparently move_notify() doesn't get called in
> >>> the destroy path.  Nouveau's GEM layer takes care of this for our
> >>> userspace bos, and we don't use any kernel bos that are mapped into a
> >>> channel's address space so we don't hit it.  This can probably be solved
> >>> easily enough too I expect.
> >>>
> >>> Ben.
> >>>
> >>>
> >>>        
> >> OK. I understand. Surely if a move_notify is missing somewhere, that can
> >> easily be fixed.
> >>
> >> It might be good if we can outline how the virtual tables are set up. In
> >> my world, the following would happen:
> >>
> >> 1) Pre command submission:
> >>
> >> a) reserve bo
> >> b) call ttm_bo_validate to set placement. move_notify will tear down any
> >> existing GPU page tables for the bo.
> >> c) Set up GPU page tables.
> >>      
> > Nouveau doesn't do this exactly.  I wanted to avoid having to check if a
> > bo was bound to a particular address space on every command submission.
> >    
> 
> It perhaps might be a good idea to revisit this?
> I think using move_notify to set up a new placement before the data has 
> actually been moved is very fragile and not the intended use. That would 
> also save you from having to handle error paths. Also how do you handle 
> swapouts?
I don't see how it's fragile, there's only the one error path after that
point that needs to undo it.  And, what *is* the expected use then?  I
see it as "tell the driver the buffer is moving so it can do whatever is
necessary as a result".

Swapouts are a missed case though, indeed.

> 
> A quick check in c) that the virtual map hasn't been torn down by a 
> move_notify and, in that case, rebuild it would probably be next to 
> free. The virtual GPU mapping would then be valid only after validation 
> and while the bo is fenced or pinned.
This alone doesn't solve the swapouts issue either unless you're also
wanting us to unmap once a buffer becomes unfenced, which would lead to
loads of completely unnecessary map/unmaps.

Ben.

> 
> Thanks,
> Thomas
> 
> > We allocate the virtual address when a client first gets a reference to
> > a bo (ie. creates new buffer, or opens an existing handle). If the
> > buffer happens to be in VRAM or TT memory at this point, it's also
> > mapped.
> >
> > And as buffers move around, we get called by TTM through move_notify()
> > of course, and do any mapping/unmapping that's necessary as a result.
> >
> > Ben.
> >
> >    
> >> d) Command submission
> >> e) unreserve_bo().
> >>
> >>
> >> 2) When eviction happens:
> >> a) reserve bo
> >> b) move_notify is called to tear down page tables
> >> c) change placement
> >> d) Unreserve bo.
> >>
> >> Let's say an error occurs in 1d) Why would you need to undo 1c?
> >>
> >> Similarly if an error occurs in 2c) Why would you  need to undo 2b)?
> >>
> >> Thanks,
> >> Thomas
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>      
> >
> >    
> 

  parent reply	other threads:[~2011-11-19  0:24 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-17 22:20 [PATCH] drm/ttm: pass buffer object for bind/unbind callback j.glisse
2011-11-18  7:57 ` Thomas Hellstrom
2011-11-18 13:15   ` Ben Skeggs
2011-11-18 14:30     ` Thomas Hellstrom
2011-11-18 14:56       ` Jerome Glisse
2011-11-18 15:06         ` Thomas Hellstrom
2011-11-18 15:27           ` Jerome Glisse
2011-11-18 17:26       ` Ben Skeggs
2011-11-18 22:48         ` Thomas Hellstrom
2011-11-18 23:14           ` Jerome Glisse
2011-11-18 23:25             ` Jerome Glisse
2011-11-18 23:30               ` Jerome Glisse
2011-11-19  0:26           ` Ben Skeggs [this message]
2011-11-19 10:07             ` Thomas Hellstrom
2011-11-19 14:53               ` Ben Skeggs
2011-11-19 17:00                 ` Thomas Hellstrom
2011-11-19 18:11                   ` Jerome Glisse
2011-11-19 19:46                     ` Thomas Hellstrom
2011-11-19 20:37                       ` Jerome Glisse
2011-11-19 21:01                         ` Thomas Hellstrom
2011-11-19 21:22                           ` Jerome Glisse
2011-11-19 22:37                             ` Thomas Hellstrom
2011-11-19 22:54                               ` Jerome Glisse
2011-11-20  9:30                                 ` Thomas Hellstrom
2011-11-20 15:13                                   ` Jerome Glisse
2011-11-21 10:37                                     ` Thomas Hellstrom

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=1321662373.18323.15.camel@nisroch \
    --to=skeggsb@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jglisse@redhat.com \
    --cc=thellstrom@vmware.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