Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp789507imd; Thu, 1 Nov 2018 05:45:01 -0700 (PDT) X-Google-Smtp-Source: AJdET5ckm2PpPJjF1LGnRchqc5a3pDBnkwpqZ0pKMcz222c7zrP8XcFPYDHv+kbOts28kQpiIRHJ X-Received: by 2002:a62:2606:: with SMTP id m6-v6mr7588265pfm.104.1541076301742; Thu, 01 Nov 2018 05:45:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541076301; cv=none; d=google.com; s=arc-20160816; b=VBw6tg0HQBXLCFkWe5OZaprY/RL5Ik+aNbnynyo6RofiSTCg+U1zVqmh5SXoi1Ykd2 ZDhqmJibfUEmUimWU0nhfe9h7OOjdm2ELWL5vxTFyOEiwo7rCzlzGjX+znqlG1TMsD2j 0cnNjxGrr8OinWiBmMG+SM8uw9ddll/kQPO0Ff86pt+JruRrEGA5L/u7j8xWXolkRGyv gDYQyhUJwqmtfkv9uRO4n/V4dOrxaticJavt9tuVuoCH/o6Pzw/WOsQ0h3YS6pdiV0D4 /+fs5bMy5bGmpTlHvzsyvrf5bOVpD1AmDkP/qTBjM8q6ll1mDu/7/pKtZeyYMpmLDfco Z2fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=DmzqnosRaNFwZ3dhiUvvs68Rxlkhn0GgUdhkS5hQjsU=; b=joRXFGJdUXKRBjOmZGmV+6Nwiu4l42VXYQybQlG1vAuZ1MgWbhj30gYisdU8VH1xEq Be2zpchWmnxx0z6A807xt7IZRUPY1bf2kK0I+WXZA8uAhdgwd3BC3l5LSlaVe+hzV9FX dFFwSsYlCcPAOYBIMZH/rlVla5wn70xpX3izjfAA13Hz86OQ7fUX+55ITQedNmbRHJjs WEuzo4GeH/ty3rdQlY3TlqG7iTszyT3PoZjj7lDxd2WQyVcl/rpqt15Ve+qLaTx+MB7+ tNEyXSRdqYiF6AAxx15YzZcHee4cJdcxGAue7whsnkCsyvgyakkVEY0dSQ4s2/HTgXdF m+WQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e93-v6si31379881plk.208.2018.11.01.05.44.44; Thu, 01 Nov 2018 05:45:01 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728315AbeKAVqt (ORCPT + 99 others); Thu, 1 Nov 2018 17:46:49 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:56620 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728211AbeKAVqt (ORCPT ); Thu, 1 Nov 2018 17:46:49 -0400 Received: from [IPv6:2a02:8109:92c0:207d:3d24:60ad:a75d:194d] (unknown [IPv6:2a02:8109:92c0:207d:3d24:60ad:a75d:194d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: robertfoss) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id E322C260560; Thu, 1 Nov 2018 12:43:53 +0000 (GMT) Subject: Re: [PATCH 1/5] drm/virtio: add virtio_gpu_alloc_fence() To: Emil Velikov Cc: David Airlie , "Linux-Kernel@Vger. Kernel. Org" , ML dri-devel , "open list:VIRTIO GPU DRIVER" , Gustavo Padovan , Gerd Hoffmann , Emil Velikov References: <20181025183739.9375-1-robert.foss@collabora.com> <20181025183739.9375-2-robert.foss@collabora.com> From: Robert Foss Message-ID: <1c92b6dc-4152-c81b-5180-2f48799b959f@collabora.com> Date: Thu, 1 Nov 2018 13:43:51 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hey Emil, On 2018-10-31 10:38, Emil Velikov wrote: > 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. Agreed, I'll hold off with this change until then. > > 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. Ack > >> + >> + 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? That case should never be hit, and if it is that's a bug. Fixed in v4. > >> +} >> + >> 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 ... > Fixed during drm-misc-next rebase for v4. > > >> @@ -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. Agreed. Fixed in v4. > >> +ttm_eu_backoff_reservation(&ticket, &validate_list); > Indentation seems off (or my client ate it)? No, the indentation is bad here. Fixed in v4. Thanks for the feedback Emil.