From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Anholt Subject: Re: [PATCH 3/4] drm/vc4: Export fence through syncobj Date: Mon, 23 Apr 2018 12:01:20 -0700 Message-ID: <877eox4uin.fsf@anholt.net> References: <20180421225022.7592-1-stschake@gmail.com> <20180421225022.7592-4-stschake@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0220213965==" Return-path: Received: from anholt.net (anholt.net [50.246.234.109]) by gabe.freedesktop.org (Postfix) with ESMTP id 704B86E2DE for ; Mon, 23 Apr 2018 19:01:23 +0000 (UTC) In-Reply-To: <20180421225022.7592-4-stschake@gmail.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Cc: airlied@linux.ie, linux-rpi-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, Stefan Schake List-Id: dri-devel@lists.freedesktop.org --===============0220213965== Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Stefan Schake writes: > Allow specifying a syncobj on render job submission where we store the > fence for the job. This gives userland flexible access to the fence. > > Signed-off-by: Stefan Schake > --- > drivers/gpu/drm/vc4/vc4_gem.c | 38 +++++++++++++++++++++++++++++++++++--- > include/uapi/drm/vc4_drm.h | 13 +++++++++++++ > 2 files changed, 48 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c > index 232363488125..b39515a4ddcb 100644 > --- a/drivers/gpu/drm/vc4/vc4_gem.c > +++ b/drivers/gpu/drm/vc4/vc4_gem.c > @@ -656,7 +656,8 @@ vc4_lock_bo_reservations(struct drm_device *dev, > */ > static int > vc4_queue_submit(struct drm_device *dev, struct vc4_exec_info *exec, > - struct ww_acquire_ctx *acquire_ctx) > + struct ww_acquire_ctx *acquire_ctx, > + struct drm_syncobj *out_sync) > { > struct vc4_dev *vc4 =3D to_vc4_dev(dev); > struct vc4_exec_info *renderjob; > @@ -679,6 +680,9 @@ vc4_queue_submit(struct drm_device *dev, struct vc4_e= xec_info *exec, > fence->seqno =3D exec->seqno; > exec->fence =3D &fence->base; >=20=20 > + if (out_sync) > + drm_syncobj_replace_fence(out_sync, exec->fence); > + > vc4_update_bo_seqnos(exec, seqno); >=20=20 > vc4_unlock_bo_reservations(dev, exec, acquire_ctx); > @@ -1114,6 +1118,7 @@ vc4_submit_cl_ioctl(struct drm_device *dev, void *d= ata, > struct vc4_dev *vc4 =3D to_vc4_dev(dev); > struct vc4_file *vc4file =3D file_priv->driver_priv; > struct drm_vc4_submit_cl *args =3D data; > + struct drm_syncobj *out_sync =3D NULL; > struct vc4_exec_info *exec; > struct ww_acquire_ctx acquire_ctx; > struct dma_fence *in_fence; > @@ -1123,11 +1128,17 @@ vc4_submit_cl_ioctl(struct drm_device *dev, void = *data, > VC4_SUBMIT_CL_FIXED_RCL_ORDER | > VC4_SUBMIT_CL_RCL_ORDER_INCREASING_X | > VC4_SUBMIT_CL_RCL_ORDER_INCREASING_Y | > - VC4_SUBMIT_CL_IMPORT_SYNCOBJ)) !=3D 0) { > + VC4_SUBMIT_CL_IMPORT_SYNCOBJ | > + VC4_SUBMIT_CL_EXPORT_SYNCOBJ)) !=3D 0) { > DRM_DEBUG("Unknown flags: 0x%02x\n", args->flags); > return -EINVAL; > } >=20=20 > + if (args->pad2 !=3D 0) { > + DRM_DEBUG("->pad2 must be set to zero\n"); > + return -EINVAL; > + } > + > exec =3D kcalloc(1, sizeof(*exec), GFP_KERNEL); > if (!exec) { > DRM_ERROR("malloc failure on exec struct\n"); > @@ -1202,12 +1213,33 @@ vc4_submit_cl_ioctl(struct drm_device *dev, void = *data, > if (ret) > goto fail; >=20=20 > + if (args->flags & VC4_SUBMIT_CL_EXPORT_SYNCOBJ) { > + out_sync =3D drm_syncobj_find(file_priv, args->out_sync); > + if (!out_sync) { > + ret =3D -EINVAL; > + goto fail; > + } > + > + /* We replace the fence in out_sync in vc4_queue_submit since > + * the render job could execute immediately after that call. > + * If it finishes before our ioctl processing resumes the > + * render job fence could already have been freed. > + */ > + } Same comment about not needing the exec flag. > + > /* Clear this out of the struct we'll be putting in the queue, > * since it's part of our stack. > */ > exec->args =3D NULL; >=20=20 > - ret =3D vc4_queue_submit(dev, exec, &acquire_ctx); > + ret =3D vc4_queue_submit(dev, exec, &acquire_ctx, out_sync); > + > + /* The syncobj isn't part of the exec data and we need to free our > + * reference even if job submission failed. > + */ > + if (out_sync) > + drm_syncobj_put(out_sync); > + > if (ret) > goto fail; >=20=20 > diff --git a/include/uapi/drm/vc4_drm.h b/include/uapi/drm/vc4_drm.h > index 389f21931c25..3a2ef9b5b60b 100644 > --- a/include/uapi/drm/vc4_drm.h > +++ b/include/uapi/drm/vc4_drm.h > @@ -174,6 +174,7 @@ struct drm_vc4_submit_cl { > #define VC4_SUBMIT_CL_RCL_ORDER_INCREASING_X (1 << 2) > #define VC4_SUBMIT_CL_RCL_ORDER_INCREASING_Y (1 << 3) > #define VC4_SUBMIT_CL_IMPORT_SYNCOBJ (1 << 4) > +#define VC4_SUBMIT_CL_EXPORT_SYNCOBJ (1 << 5) > __u32 flags; >=20=20 > /* Returned value of the seqno of this render job (for the > @@ -189,6 +190,18 @@ struct drm_vc4_submit_cl { > * syncobj is signalled. > */ > __u32 in_sync; > + > + /* Syncobj handle to export fence to. Set together with EXPORT_SYNCOBJ > + * flag. If set, the fence in the syncobj will be replaced with a fence > + * that signals upon completion of this render job. > + */ > + __u32 out_sync; > + > + /* Unused field to align this struct on 64 bits. Must be set to 0. > + * If one ever needs to add an u32 field to this struct, this field > + * can be used. > + */ > + __u32 pad2; As far as I know, there's no need to align the struct to 64 bits. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE/JuuFDWp9/ZkuCBXtdYpNtH8nugFAlreLYAACgkQtdYpNtH8 nuhiaRAAu12NWbLgRQ9IxrIsr/MZpJNVGVfm762LZ8avI3BwS7qZQDuYI7+ubtsK NX87w1hR6QiE1uMiKxH2SpjRNvJtaACkXTbDzKKXB3fvAd9H+o0H0ZXyvDK682Ug guCJ2tEX3Txw8NpwoVRqFs0RrB8WWs4Tli6B4a8LEPSpo2xUqG4Cd3pk8B1VFonp 3lmnv8wSIGP/6JgRHv5FqHdJ8pzcvEO2IyyaNCRnv2/OTnpxQkPounWbTOkJeNCX +SmkvDQ2XoqYFMKFwX8QHEUW/WXhgKyNUF4txBepowAHokViXKgWssr9MwwpCHZv dUhCnc7aJf5A2ulpueVmEJEddUgDGQYjAejydkdIL2CV+mpSvfaxvgNnNUOWcI3C BLmnnLp0OgPUtGTatJMlcegyx1UzzStndNcFad9TXVJj1tD19Yd0DufE8sj5eN2t BMSNiO5hTFfMPozOaXLN2irA37ZAinsE8NNWy1mu0GFSSEVf8H+rIG38Zl4JyJQ6 pL2om9HkcyImKdJLaryK+zdHDuCMa0/X2ALDaVCZ7k1nCCyVDvZbyYGGAdJPmnkQ Y1CGm5YXDeIzbAJ9v6sSVPxngQRS8v67XEfgAw0URpR2kRFMGTteXlbWIW8Ed8GD Xz/8haY78fz2woXIglwLH8dTiXhzIg7fsUiEBEB9hqs+9sX1GWQ= =P/Ly -----END PGP SIGNATURE----- --=-=-=-- --===============0220213965== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVsCg== --===============0220213965==--