From: Jerome Glisse Subject: Re: [PATCH] drm/radeon: Add support for userspace fence waits Date: Tue, 31 Jan 2012 14:36:58 -0500 Message-ID: <20120131193657.GC8135@homer.localdomain> References: <1328029169-12729-1-git-send-email-simon.farnsworth@onelan.co.uk> <20120131190717.GB8135@homer.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail-gy0-f177.google.com (mail-gy0-f177.google.com [209.85.160.177]) by gabe.freedesktop.org (Postfix) with ESMTP id 59BE89E79E for ; Tue, 31 Jan 2012 11:37:03 -0800 (PST) Received: by ghbg20 with SMTP id g20so265080ghb.36 for ; Tue, 31 Jan 2012 11:37:02 -0800 (PST) Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: Alex Deucher Cc: David Airlie , dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org On Tue, Jan 31, 2012 at 02:13:00PM -0500, Alex Deucher wrote: > On Tue, Jan 31, 2012 at 2:07 PM, Jerome Glisse wrote: > > On Tue, Jan 31, 2012 at 01:55:43PM -0500, David Airlie wrote: > >> > >> > >> Some comments below. > >> > >> > + =A0 struct radeon_device *rdev =3D dev->dev_private; > >> > + =A0 struct drm_gem_object *gobj; > >> > + =A0 struct radeon_bo *robj; > >> > + =A0 void *buffer_data; > >> > + =A0 uint32_t *fence_data; > >> > + =A0 int r =3D 0; > >> > + =A0 long timeout; > >> > + =A0 int ring =3D RADEON_RING_TYPE_GFX_INDEX; > >> > + > >> > + =A0 /* If you're implementing this for other rings, you'll want to > >> > share > >> > + =A0 =A0 =A0code with radeon_cs_get_ring in radeon_cs.c */ > >> > + =A0 if (args->ring !=3D RADEON_CS_RING_GFX) { > >> > + =A0 =A0 =A0 =A0 =A0 return -EINVAL; > >> > + =A0 } > >> > + > >> > + =A0 gobj =3D drm_gem_object_lookup(dev, filp, args->handle); > >> > + =A0 if (gobj =3D=3D NULL) { > >> > + =A0 =A0 =A0 =A0 =A0 return -ENOENT; > >> > + =A0 } > >> > + =A0 robj =3D gem_to_radeon_bo(gobj); > >> > + > >> > + =A0 if (gobj->size < args->offset) { > >> > + =A0 =A0 =A0 =A0 =A0 r =3D -EINVAL; > >> > + =A0 =A0 =A0 =A0 =A0 goto unreference; > >> > + =A0 } > >> > + > >> > + =A0 r =3D radeon_bo_reserve(robj, true); > >> > + =A0 if (r) { > >> > + =A0 =A0 =A0 =A0 =A0 goto unreference; > >> > + =A0 } > >> > + > >> > + =A0 r =3D radeon_bo_pin(robj, RADEON_GEM_DOMAIN_GTT, NULL); > >> > + =A0 if (r) { > >> > + =A0 =A0 =A0 =A0 =A0 goto unreserve; > >> > + =A0 } > >> > + > >> > + =A0 r =3D radeon_bo_kmap(robj, &buffer_data); > >> > + =A0 if (r) { > >> > + =A0 =A0 =A0 =A0 =A0 goto unpin; > >> > + =A0 } > >> > + > >> > >> > >> Do you need to pin it? I think if you have it reserved and you are in = here you shouldn't need to. (unless kmapping requires a pin)/ > > > > No you don't need to pin, actually it's bad to pin the buffer you might > > want to wait on might be in vram. > > > > Also you never assume that things could go wrong and that your value > > might never be written to the buffer. So it will wait forever in the > > kernel. > > > > As i said in the other mail i would rather as a wait on submited cs > > ioctl and add some return value from cs ioctl. I can't remember the > > outcome of this discusion we had when we were doing virtual memory > > support. Alex ? Michel ? better memory than i do ? :) > > > = > I vaguely recall the discussion, but I don't remember the details, > I'll have to look through my old mail. Maybe a new CS ioctl flag > requesting EOP irqs for the CS would be a better approach than a > separate ioctl. > = > Alex I think the idea was to return u64 value of specific ring and only enable irq if new wait cs ioctl was call, a little bit like bo wait. Will try to dig through my mail too. Cheers, Jerome > > > >> > >> > >> > + =A0 radeon_irq_kms_sw_irq_get(rdev, ring); > >> > + > >> > + =A0 fence_data =3D (uint32_t*)buffer_data; > >> > + =A0 timeout =3D > >> > an > >> > + * interrupt and the value in the buffer might have changed. > >> > + */ > >> > +struct drm_radeon_gem_wait_user_fence { > >> > + =A0 uint32_t =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0handle; > >> > + =A0 uint32_t =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ring; > >> > + =A0 uint64_t =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0offset; > >> > + =A0 uint32_t =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0value; > >> > + =A0 uint64_t =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0timeout_usec; > >> > >> Align things here, 64 then 64 then 32 32 32 and a 32 pad. > >> > >> _______________________________________________ > >> dri-devel mailing list > >> dri-devel@lists.freedesktop.org > >> http://lists.freedesktop.org/mailman/listinfo/dri-devel > > _______________________________________________ > > dri-devel mailing list > > dri-devel@lists.freedesktop.org > > http://lists.freedesktop.org/mailman/listinfo/dri-devel