Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp5828831imd; Wed, 31 Oct 2018 02:41:54 -0700 (PDT) X-Google-Smtp-Source: AJdET5fHFd2fJzmHnDivMbVf4XZ16+Wo63FCWkGlW4ucByVwpvnmNwfTiNGqk6PSEdqxQzW/CHim X-Received: by 2002:a62:7a92:: with SMTP id v140-v6mr2626137pfc.46.1540978914156; Wed, 31 Oct 2018 02:41:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540978914; cv=none; d=google.com; s=arc-20160816; b=drSXCtUQcPUzrSspfbMV4SuuY0RvWAkj3RFgKPljOCSew/VWQkmeKmUl5gcJ/rNcyu rGeh4CkUULSeNb9tVIYS8n85+xwkvvzB7c8DYA6oZ6HJltL/fwcUEn7VSA4D23SNZleM e2ax4Ji9JwE5N39XvvcLh1tQd20A3JtD/GW38B7+Rqg0+YC+mHnBONEWztd77KyN6Ao0 y+vD5dUUFLNvuW3Crkzne2ol/dFQHsuFwMHNDJSfjBfwhra7c0HdERPKL7Ckra28rcxK 3pEE2TI7cmE/wuCvc6CO5KcOsSUVCyULR/6lxDW+Ybf3BQWTAnsgkeyaAiELZ7L9M3uq oeLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=SkM4fZTJWWCAtvbfzHbA7JEsdH/DSkvV6DP0rjdlLxU=; b=tZy6SYOSifdEeykLfGBR2Q2by2GKMCwOZ+0UB23MTBsMhQdsLA2kvzUKECZRZ/w0N6 9eYjUiSHOjR+V56rPOmvceTitcfNg2EnM6UztQF9jl9apNmQRtgQ8gymuPFaTUwhZJKG WQFB1LXOJZhAT4L9Q7gIBvBmWTHr773KZdh5ZvN+nDBvj6cSTzm8fUuVhhdt6SmMbGuz hK+h+bOkeXdzCS5aVkrRhn3SSuzRTaoGaJ4cACfTaayXg1X3ecibO96TYy5J/ICaEAoM 306AyjdlG1aR/xJQAJp32qnq8iFV5WTdmYk+VY6zS3O1Gy67UxTrhIzo3iNWtbggNK8R n0nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="XHlq3Wu/"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d23-v6si26736644pgj.533.2018.10.31.02.41.39; Wed, 31 Oct 2018 02:41:54 -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=pass header.i=@gmail.com header.s=20161025 header.b="XHlq3Wu/"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727963AbeJaShM (ORCPT + 99 others); Wed, 31 Oct 2018 14:37:12 -0400 Received: from mail-vk1-f196.google.com ([209.85.221.196]:32830 "EHLO mail-vk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727436AbeJaShM (ORCPT ); Wed, 31 Oct 2018 14:37:12 -0400 Received: by mail-vk1-f196.google.com with SMTP id l186so3749407vke.0 for ; Wed, 31 Oct 2018 02:39:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SkM4fZTJWWCAtvbfzHbA7JEsdH/DSkvV6DP0rjdlLxU=; b=XHlq3Wu/D2NC4fCDlcsCfz/PKITtT1yfuCdwsufUVYos2a/mJZG1+zRtimaHmLIC5d Ek6fUUmKge393kgPKFP5lgVgE0fDSiTyQPl0gqiBvIsiLoc4cfXqtGjrHPUQveD4KjwE bq0Ol5fgsD5DuoP0C0LcTFtfPMGKdh/W0fM6vafkK77bQ3leGrOik9Hx+FsOeNv9UfwF 8q+98rehaymu7gNrLG6xDFBNsm9YX96xQP12WjLAbRshLOH0++EYXPgJhCnz7sEObxb2 dqnFaNMyKMIs+1656UM7ccMV2rBPDjBqP2UOLeE035+Q8iuAsp9G9V+fQAeSf5TGsD+m cehg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SkM4fZTJWWCAtvbfzHbA7JEsdH/DSkvV6DP0rjdlLxU=; b=tkmv5ftX13TLpd1gk5HxLceUGKVV9aF0lFhPRw+O1SSW1BC02rEx39yxn1+nvz55LB w5RSNUXs6OlqAFmxswkq2B+ZySK5h7WK7oWbP2B37KvKat7VQTnHtfWYw8nMQJJ4A/F+ IOlo2zziHS3vJLl2/C4HTWPpXD4/1ene2bE2Fsz5QPw8gi+Uix9Dl8Wkhk6AeMMExovj hcAc5m6RTFTomoxKDIMsx4iLUSRI6sKxOOsRuJFUcKf8O/UwSCLzNs91GfAf5jEJmnbj g5lmbx1OsG4M1m7cB0sbB5SpWRCtt9WaS7qb5zeUMGm/jSh2BxajrWSJO4a5FUaeXhz8 eOLw== X-Gm-Message-State: AGRZ1gJxddz25wQJR7i7lIedK7qwvB8ee9Nrwof7PRjWu0Vna9zgTfDM w96FukXcZHbaBX6VPbE4VyPI0LLNUh8/pCv4bXs= X-Received: by 2002:a1f:e9c7:: with SMTP id g190mr925186vkh.69.1540978789557; Wed, 31 Oct 2018 02:39:49 -0700 (PDT) MIME-Version: 1.0 References: <20181025183739.9375-1-robert.foss@collabora.com> <20181025183739.9375-2-robert.foss@collabora.com> In-Reply-To: <20181025183739.9375-2-robert.foss@collabora.com> From: Emil Velikov Date: Wed, 31 Oct 2018 09:38:31 +0000 Message-ID: Subject: Re: [PATCH 1/5] drm/virtio: add virtio_gpu_alloc_fence() To: Robert Foss Cc: David Airlie , Gerd Hoffmann , ML dri-devel , "open list:VIRTIO GPU DRIVER" , "Linux-Kernel@Vger. Kernel. Org" , Rob Herring , Gustavo Padovan , Emil Velikov Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Rob, On Thu, 25 Oct 2018 at 19:38, Robert Foss wrote: > > From: Gustavo Padovan > > Refactor fence creation to remove the potential allocation failure from > the cmd_submit and atomic_commit paths. Now the fence should be allocated > first and just after we should proceed with the rest of the execution. > Commit does a bit more that what the above says: - dummy, factor out fence creation/destruction - use per virtio_gpu_framebuffer fence Personally I'd keep the two separate patches and elaborate on the latter. Obviously in that case, one will need to add 3 lines worth of virtio_gpu_fence_alloc() in virtio_gpu_cursor_plane_update which will be nuked with the next patch. Not a big deal, but it's up-to the maintainer to make the final call if it's worth splitting or not. Couple of minor nitpicks below. > struct virtio_gpu_device *vgdev = dev->dev_private; > struct virtio_gpu_output *output = NULL; > struct virtio_gpu_framebuffer *vgfb; > - struct virtio_gpu_fence *fence = NULL; > struct virtio_gpu_object *bo = NULL; > uint32_t handle; > int ret = 0; Add the virtio_gpu_fence_alloc()? And yes it will be nuked with patch 2/... > +struct virtio_gpu_fence *virtio_gpu_fence_alloc(struct virtio_gpu_device *vgdev) > +{ > + struct virtio_gpu_fence_driver *drv = &vgdev->fence_drv; > + struct virtio_gpu_fence *fence = kzalloc(sizeof(struct virtio_gpu_fence), GFP_ATOMIC); > + if (!fence) > + return fence; > + > + fence->drv = drv; > + dma_fence_init(&fence->f, &virtio_fence_ops, &drv->lock, drv->context, 0); Oh no, lines over 80 col... while the original code is pretty and neat. > + > + return fence; > +} > + > +void virtio_gpu_fence_cleanup(struct virtio_gpu_fence *fence) > +{ > + if (!fence) > + return; > + > + if (fence->drv) > + dma_fence_put(&fence->f); > + else > + kfree(fence); I'm not sure if/how we reach the else case here? > +} > + > int virtio_gpu_fence_emit(struct virtio_gpu_device *vgdev, > struct virtio_gpu_ctrl_hdr *cmd_hdr, > - struct virtio_gpu_fence **fence) > + struct virtio_gpu_fence *fence) > { With a follow-up commit, we can drop the no longer needed return type. Which it turns out was never checked ... > @@ -319,6 +332,8 @@ static int virtio_gpu_resource_create_ioctl(struct drm_device *dev, void *data, > dma_fence_put(&fence->f); > } > return 0; > +fail_fence: The error labels seems to be called after what they do, not what fails. fail_backoff seems better IMHO. > +ttm_eu_backoff_reservation(&ticket, &validate_list); Indentation seems off (or my client ate it)? HTH Emil