Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3837996ybi; Tue, 18 Jun 2019 07:18:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqzBMv7O9PYfc5/B423ExkS1Cq78hQU46Ia4zymWGc7uWiI6L1YgJkIxfooEC/yvsEaSPr3x X-Received: by 2002:a63:ee0c:: with SMTP id e12mr2946592pgi.184.1560867487245; Tue, 18 Jun 2019 07:18:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560867487; cv=none; d=google.com; s=arc-20160816; b=JXnbuO15DB1mOPKXYQ1Bx71nDSgqX/OJH8ykqQ5hSzTD7g62D35yKJwD5dcDHMxuYX BhSf6vFJKNYHrT2H1v3a3VqnOKt5r/Zsu0lyhh3NkHbuNHHtExO6KTRgZC8+yg6bjCW4 MYFX6wm5GMn03p4sTteprOdGMYiFVMJs/6ixymDnku2WZJHkZntbdIX7rY/njgkJhikS JbkdVQSSbcryb0XoESL85QI0Ps0eW8MtGC0yb+bkI8RVlnURjm7thZlYnuuqQqF9C2E3 050n/uzrGRCIOt5xFI63dHVtk+2FA9h+WcMKWhFvf/THvTNOgoAyYa1RPTHUD9Z392X7 k1dQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=wDyr/Hayw2IId/qNGbRLKP0mrDW1etMQA1PqQ01Gh10=; b=onrxX4c+KkOK4YyMu7vfgTHixuX9t5x880j0BMk8oe5DTbSsqoS4XeiCG0u0/yCynF dfrELlO5ElmHpiTvWRG4wQI6oRi1DPgfyTqGZnnj6YbgppP5Xhue1Eia1TVb10jLdM4O Huim/x9gHLSCOgpw6nqbYfTBYoiCHhXC5XhH2ErPQKwcGalgj26otQfP5VRhjDFE//tI /NMilLJeYgdQxuZgVzb88V8JzcrtwiyZBDaN1HHJQA1WxLDQtyGc6N5peGEWLqMcEaUb qO7sYJJ3hHMDjVQC6QlACON6SDLJ3cJxf9EVkrv5oa7/D55QkgZEjGqiDQ34OshvsMAA 79TA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b="Mn/9T9RB"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s15si2367847pjp.38.2019.06.18.07.17.50; Tue, 18 Jun 2019 07:18:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b="Mn/9T9RB"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729325AbfFROQJ (ORCPT + 99 others); Tue, 18 Jun 2019 10:16:09 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:36883 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726248AbfFROQJ (ORCPT ); Tue, 18 Jun 2019 10:16:09 -0400 Received: by mail-ed1-f67.google.com with SMTP id w13so22008378eds.4 for ; Tue, 18 Jun 2019 07:16:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=wDyr/Hayw2IId/qNGbRLKP0mrDW1etMQA1PqQ01Gh10=; b=Mn/9T9RBbKXfNDMa8owY91k+MzyKmTXct/gRR9pkGC5sb28PLS5L9iEMP+FZmAFPw/ nwcYkVIuVZ/ruRkYJiy/qr0IKuLKzkvmTQKUFFN64wRCq46JvEjab28ekRfZWFHW99BU s+ZJXt5+tn/X0ihJrtkCJrp54eaXZ/EFkx3GU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=wDyr/Hayw2IId/qNGbRLKP0mrDW1etMQA1PqQ01Gh10=; b=iaSKbEmF51N/xU3XM50M4oIy7CNhD+O3JbVuUZ8u/IpsFGTbe30E2RdfbYUwU+r6Hk 0n44rnK8ONAI+QiXbbG0m2emEcvtch6BUljVJBt1G/XYjjOp7KLKLcy9L2P/Cy8ckqp7 A1hedO66VzUfcefm0tFmEIxblYBH9UayaVIX8MUlSQS1iso+KsPyNn9RhyvJhG90uRzJ 0fT+ULfK95V43wBp/01SfOR+t+g9LX9DiZGKPIFbMU9bw84PFTjSClcZR/ltBRHiKVAH BCQBLi63y314h8ND8dpPB38aPhLvbazPTjrWm8OmMojB3E4lQfV7Km1BJA2yIozuMo1L xUaA== X-Gm-Message-State: APjAAAWkotfsvRAoqKC4PplOSYoHp1eo5lZXc0wqC2pCc4Kl2eJM04s0 he0i9EckCT4xxwyj7A4S2Y76Gw== X-Received: by 2002:a17:906:670c:: with SMTP id a12mr54979446ejp.290.1560867366769; Tue, 18 Jun 2019 07:16:06 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:569e:0:3106:d637:d723:e855]) by smtp.gmail.com with ESMTPSA id i16sm2842945ejc.16.2019.06.18.07.16.05 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 18 Jun 2019 07:16:06 -0700 (PDT) Date: Tue, 18 Jun 2019 16:16:04 +0200 From: Daniel Vetter To: Gerd Hoffmann Cc: dri-devel@lists.freedesktop.org, David Airlie , Daniel Vetter , "open list:VIRTIO GPU DRIVER" , open list Subject: Re: [PATCH v2 07/12] drm/virtio: rework virtio_gpu_execbuffer_ioctl fencing Message-ID: <20190618141604.GC12905@phenom.ffwll.local> Mail-Followup-To: Gerd Hoffmann , dri-devel@lists.freedesktop.org, David Airlie , "open list:VIRTIO GPU DRIVER" , open list References: <20190618135821.8644-1-kraxel@redhat.com> <20190618135821.8644-8-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190618135821.8644-8-kraxel@redhat.com> X-Operating-System: Linux phenom 4.19.0-5-amd64 User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 18, 2019 at 03:58:15PM +0200, Gerd Hoffmann wrote: > Use gem reservation helpers and direct reservation_object_* calls > instead of ttm. > > Signed-off-by: Gerd Hoffmann > --- > drivers/gpu/drm/virtio/virtgpu_ioctl.c | 36 ++++++++++++-------------- > 1 file changed, 17 insertions(+), 19 deletions(-) > > diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c > index 5cffd2e54c04..6db6a6e92dde 100644 > --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c > +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c > @@ -107,12 +107,11 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data, > struct virtio_gpu_fpriv *vfpriv = drm_file->driver_priv; > struct drm_gem_object *gobj; > struct virtio_gpu_fence *out_fence; > - struct virtio_gpu_object *qobj; > int ret; > uint32_t *bo_handles = NULL; > void __user *user_bo_handles = NULL; > struct list_head validate_list; > - struct ttm_validate_buffer *buflist = NULL; > + struct drm_gem_object **buflist = NULL; > int i; > struct ww_acquire_ctx ticket; > struct sync_file *sync_file; > @@ -157,12 +156,11 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data, > > INIT_LIST_HEAD(&validate_list); > if (exbuf->num_bo_handles) { > - > bo_handles = kvmalloc_array(exbuf->num_bo_handles, > - sizeof(uint32_t), GFP_KERNEL); > + sizeof(uint32_t), GFP_KERNEL); > buflist = kvmalloc_array(exbuf->num_bo_handles, > - sizeof(struct ttm_validate_buffer), > - GFP_KERNEL | __GFP_ZERO); > + sizeof(struct drm_gem_object*), > + GFP_KERNEL | __GFP_ZERO); > if (!bo_handles || !buflist) { > ret = -ENOMEM; > goto out_unused_fd; > @@ -181,19 +179,15 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data, > ret = -ENOENT; > goto out_unused_fd; > } > - > - qobj = gem_to_virtio_gpu_obj(gobj); > - buflist[i].bo = &qobj->tbo; > - > - list_add(&buflist[i].head, &validate_list); > + buflist[i] = gobj; I didn't bother looking, but I guess there's some room for a array-of-gem-id to gem_bo-pointers helper function? Would only make sense if we can share it with panfrost/v3d maybe. > } > kvfree(bo_handles); > bo_handles = NULL; > } > > - ret = virtio_gpu_object_list_validate(&ticket, &validate_list); > + ret = drm_gem_lock_reservations(buflist, exbuf->num_bo_handles, &ticket); > if (ret) > - goto out_free; > + goto out_unused_fd; > > buf = memdup_user(u64_to_user_ptr(exbuf->command), exbuf->size); > if (IS_ERR(buf)) { > @@ -222,21 +216,25 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data, > virtio_gpu_cmd_submit(vgdev, buf, exbuf->size, > vfpriv->ctx_id, out_fence); > > - ttm_eu_fence_buffer_objects(&ticket, &validate_list, &out_fence->f); > + for (i = 0; i < exbuf->num_bo_handles; i++) > + reservation_object_add_excl_fence(buflist[i]->resv, &out_fence->f); Helper to unref an array of gem bo? Probably also needed by other drivers. > + drm_gem_unlock_reservations(buflist, exbuf->num_bo_handles, &ticket); > > - /* fence the command bo */ > - virtio_gpu_unref_list(&validate_list); > + for (i = 0; i < exbuf->num_bo_handles; i++) > + if (buflist[i]) > + drm_gem_object_put_unlocked(buflist[i]); I am left wondering who's holding references onto these buffers now? How do you make sure they don't disappear untimely? I think atm it's ttm making sure of that, but if you drop that completely there needs to be something else. > kvfree(buflist); > return 0; > > out_memdup: > kfree(buf); > out_unresv: > - ttm_eu_backoff_reservation(&ticket, &validate_list); > -out_free: > - virtio_gpu_unref_list(&validate_list); > + drm_gem_unlock_reservations(buflist, exbuf->num_bo_handles, &ticket); > out_unused_fd: > kvfree(bo_handles); > + for (i = 0; i < exbuf->num_bo_handles; i++) > + if (buflist && buflist[i]) > + drm_gem_object_put_unlocked(buflist[i]); > kvfree(buflist); > > if (out_fence_fd >= 0) Patch itself looks correct, just put down my thoughts while reviewing it. Reviewed-by: Daniel Vetter > -- > 2.18.1 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch