Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2962546pxb; Mon, 17 Jan 2022 09:04:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJxCDGWuyFzw39qOLjv2cERR4rVDIjEuGrbj4Wbcv4n4vu3FI/ZcdMBU2Z7YauGZHaG1WfK3 X-Received: by 2002:a62:8855:0:b0:4bd:e21c:1f14 with SMTP id l82-20020a628855000000b004bde21c1f14mr21992890pfd.76.1642439083977; Mon, 17 Jan 2022 09:04:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642439083; cv=none; d=google.com; s=arc-20160816; b=HCxxgAwHTd+rnbwSnEg9CnU8o3Z2/Rpgrh8PqrZK0UkU6UP0zJYR8ws2P65j3Vp429 dOFzw2ScQplIWFiKVG8BE7Is+xjthwpTlL3545FoCfuAI0+PRUToQLKJyKfaS7/90yr2 SjKVtRxK+A54NPy+n4HwVzGm/p4htBKaMgekMmIT5zo/H7sq+MlZkDYyRVB73JzxLOvq /Ep5i3GIJn5rmmyHnWrIU/JX2jsf9q5QShirrWwG9jFM7CpasmkgRKpAJDnGQ9SEcblm kFm1YfbuUtiACVUrs2HtrBZ6Y5P7HdY+ItoK54TUeDk4kK4Fq0csuwwOVPkAz9FWIIku 6VIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=/TWot+GBT255Kn595XxLRRlEGzkpc6u0aEZt1sgu9nQ=; b=koMQXTemXsxh5WjVjqa5Q8rrBwvzC3+Nnk6aMbWF5zCr+JfnMz+nfJdnOuTPL63LbZ io3u43S/16GkxC1yn/fbriDBlRAWnLe/OYS9M+4xdTMQbGsGDGRa4j90HcwylZkbGQ7h GmRQwuMJxeGieJ1l5GWYlEaoQ8V68UpPTFdH+dgI5VhXDfdsPqtdGC638RhKzi7QD1aI t1+uMge73Nwbxoj3pG/5oQ/FmNYXkO8eyli0pfi488KwgE/dQWN4ntOOZO6Zj6Mdn2fg JPwWmjCX3U8A/9+YyYVomyKa0HxR3wWUb7DYlDPGZgy3403k1vDw48XaUtNfuUpb0RvX buTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=brYMghhN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t186si3863194pgd.764.2022.01.17.09.04.30; Mon, 17 Jan 2022 09:04:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=brYMghhN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235748AbiAQJfp (ORCPT + 99 others); Mon, 17 Jan 2022 04:35:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235710AbiAQJfi (ORCPT ); Mon, 17 Jan 2022 04:35:38 -0500 Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A53FC061574 for ; Mon, 17 Jan 2022 01:35:38 -0800 (PST) Received: by mail-oi1-x22e.google.com with SMTP id y14so22597713oia.9 for ; Mon, 17 Jan 2022 01:35:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/TWot+GBT255Kn595XxLRRlEGzkpc6u0aEZt1sgu9nQ=; b=brYMghhNpV3UtW8Pry19jIqkr5UG+1u8w9vx0wfpPtB+68SvTVhWt23hZ5fvWzMuMB +Z91zQpxcQt0ofra67Y98j4cXwUJJQ5TTn+6MvOkrK+75hiuxdXjddoZf8Wr684vAOpE 8UnIwlhCxGWTDfkszaoL7H5a/hLEqSd4JWVfI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/TWot+GBT255Kn595XxLRRlEGzkpc6u0aEZt1sgu9nQ=; b=C+bBKQ0JBWI8QQV8dwmhalu0kskSpyOfvBcSTWDgzZWq1bCNlmIYwHKX60A9GHqki9 pKrbsyTdAXx39tIy2Oe+1cDG23z1J3ZRdx4Bm6ul1TXqoNyH7mItN0qIVCpW2HeUknuC sH3i2zeRmcTqzjSRk0zhmiGSrTHq+juWF4qm1wPkW+OJkNcGRflI+XMudtNPHyKugVxZ sgdD6lLkjr0TX+XddRP17kUTUlWUDxjAHxRXEmTl4eAJl0wr8oTJfCWICmQU4pOCsN/2 gX0N36H0RMJvTbx3Cor7uDlZEprdZa4BJQSMXZDhVSkN02B5davdyTgkmV8N9wUJ2XGd AmMA== X-Gm-Message-State: AOAM5300YXSrgUe7CmcG4bNlOf/DgVZbEMRLNOOWMhmuHsGXNsG7aSI5 PUHFSP+Svm751l5k/Ml7XlLu+4Q2vRA9A25jrfsPxg== X-Received: by 2002:a05:6808:1188:: with SMTP id j8mr21930539oil.101.1642412137479; Mon, 17 Jan 2022 01:35:37 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Daniel Vetter Date: Mon, 17 Jan 2022 10:35:26 +0100 Message-ID: Subject: Re: [PATCH v1 9/9] drivers: hv: dxgkrnl: Implement DXGSYNCFILE To: Iouri Tarassov Cc: kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, wei.liu@kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, spronovo@microsoft.com, gregkh@linuxfoundation.org, DRI Development , jenatali@microsoft.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 17, 2022 at 9:34 AM Iouri Tarassov wrote: > > > On 1/14/2022 10:03 AM, Daniel Vetter wrote: > > Hi all, > > > > On Wed, Jan 12, 2022 at 11:55:14AM -0800, Iouri Tarassov wrote: > > > Implement the LX_DXCREATESYNCFILE IOCTL (D3DKMTCreateSyncFile). > > > > > > dxgsyncfile is built on top of the Linux sync_file object and > > > provides a way for the user mode to synchronize with the execution > > > of the device DMA packets. > > > > > > The IOCTL creates a dxgsyncfile object for the given GPU synchronization > > > object and a fence value. A sync_object file descriptor is returned to > > > the caller. The caller could wait for the object by using poll(). > > > When the GPU synchronization object is signaled on the host, the host > > > sends a message to the virtual machine and the sync_file object is > > > signaled. > > > > > > Signed-off-by: Iouri Tarassov > > > > Adding dri-devel, which get_maintainers.pl should have done automatically > > with the dma_fence wildcard match. Not sure why that didn't happen. > > > > > +struct dxgsyncpoint { > > > + struct dxghostevent hdr; > > > + struct dma_fence base; > > > > This doesn't work unfortuntately. For better or worse memory fences like > > monitored fences from wddm have completely different semantics from > > dma_fence. You could probably hack this to be self-consistent for hyper-v, > > but the problem is that then hv would have incompatible locking/nesting > > rules compared to everything else, and dma_fence matter for memory > > management so this includes whether you're allowed to kmalloc(GFP_KERNEL) > > or not, and that's just a bit too much. > > > > I discussed this quickly with Jesse on irc and it sounds like the reason > > you want the dma_fence is just to emulate the sync_file interface for > > android. I think the correct solution here is to create a hv_dxg_sync_file > > fd, which emulates the exact ioctls that Android needs, but with a wddm > > monitored fence underneath instead of a dma_fence underneath. > > > > This way we guarantee that no one ever accidentally mixes these > > incompatible concepts up in the kernel, and Android should still be able > > to happily run under hyperv. > > > > Thoughts? > > > > Also pls cc me on this sync work since even if you drop dma_fence use > > completely I'd like to follow this a bit. > > Hi Daniel, > > Thank you for the review and feedback. > I will get this addressed. btw another idea I had over the w/e: Another option might be to allow different backends for sync_file, and then making sure that you cannot ever mix dma_fence and hv_dxg_fence type sync_file up (in e.g. the merge ioctl). The issue is that fundamentally dma_fence and memory fences (or umf for userspace memory fences as we tend to call them) aren't compatible, but some of the interop plans we have is to allow stuffing either of them into fence container objects like sync_file. So going that route for wddm monitored fence support too could be a really future-proof approach, plus it'd allow you to still share the sync_file interface code. Not that it's going to be much code sharing, since all the implementation code needs to be distinct. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch