Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp529418ybk; Fri, 15 May 2020 07:05:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRtfJatIwdm/GS0aWZaix0sSzM7/vBtM9JmAQ3zNWYFJQQNEZOet9WJl636or9K9Ispg2V X-Received: by 2002:a17:906:3d69:: with SMTP id r9mr2973894ejf.20.1589551515136; Fri, 15 May 2020 07:05:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589551515; cv=none; d=google.com; s=arc-20160816; b=tt4CChcx7P+nDLzMYc45FtzaOtMdY0TfKEgGc5A4PgximRobg6tO+DG7ZUoUE3/W2t TVigqshFlRWxHJIdOReQX3XcWQ2tbli4bFWeXu9fdl20eIy8fRubZa+ya1zutXONHzXf Yo2jecri/LP6cjjZ+YkYwt8cr83/E/OdWcdp59QaA9YPey4BGFIyFUpECdv+FNtC4dTM KrNMA1cES+u5XJnHfIVs95oNqavbMkCS+mruhJFx+eFU0h/Dra+ucLl7BzT1VNrVXVra dTPjH3PriL44isHhqt4IJPyj8B1+iwxYfiMPs2ak68snJf6iCuxW1iwdJCYa4GBD9Gm4 STsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:mail-followup-to:message-id:subject:cc:to :from:date:dkim-signature; bh=hfKkBsIEgs0vkAeFdo392aLMF7GnommANe2U1KeK9uI=; b=OUEgbiMjRSJLdTfrhqv8uCc1fAP2PEjLhRyLSZkPEehcDJFW2PeWl+9xUvp8F3JuS6 COXsByEuDTyOLqWLfOOYoBa9q21VuSf+SejR93O51/dyLDJ4RgN8jvzDOrp08Bq0bKrF uut5hvrRuBqW7FY7sBC8WvjOtLwe76ZNQFZhcdqWDizNkaYo2QTLp4IzkrB+zhsWor0O EoxLwK6PnMkFrF/9y1MHeqzYy/Pzq5Sd6ODgM+wG1pcdqvZbEh3roa0x9VckZJ6nziWT C04i4OIFJqg/xgiXZ6eUwO/YAAkjAomw5xK+ApfI/Du82oRUfxACRwmonUkutz5uvocg GRRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=b5d+I2Ch; 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 bi20si1469822edb.233.2020.05.15.07.04.43; Fri, 15 May 2020 07:05:15 -0700 (PDT) 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=b5d+I2Ch; 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 S1726204AbgEOODN (ORCPT + 99 others); Fri, 15 May 2020 10:03:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726168AbgEOODM (ORCPT ); Fri, 15 May 2020 10:03:12 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3760C05BD09 for ; Fri, 15 May 2020 07:03:11 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id n5so2822278wmd.0 for ; Fri, 15 May 2020 07:03:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=hfKkBsIEgs0vkAeFdo392aLMF7GnommANe2U1KeK9uI=; b=b5d+I2ChU9zk48jsjVya/j0veq8tA45Z1eTGEqW25PFGpflpOB0ANQJMsC27YLELuK XicoRGOzRMF/LBcAPpJOO34Vk5ZNPtNo0SYXz1CceDLR+75jgKMSr5Gq2Y4tegRs0IP+ Ups2PzNHV/VnPwJpVSpa0NFTYgmvPlT+Oi4U0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=hfKkBsIEgs0vkAeFdo392aLMF7GnommANe2U1KeK9uI=; b=pst+gEYq9lXRRELEuu+Ijb3IDthOnum1OVOk2RitlP1nW7iWa9wXt0MOMXlyWinlYC MKehW2QhDyNYoJx1WRq2pTzSkBCvJAv/GUNSpIXbZZXD0Zfuw/EIltlJVAM5v+aOxOTJ +Ta3Zuxf2dx4W6nx1l4izDzzhSvtuBh5Q1u1P0DRq7hZ6GsdDTLY5agSzpSQltqck5mU 0TvV1Pc+C58piUBXDT+p1HyMF5laS7Epq3ZpwfUn2IDz74N8coDOQDBSmF2X2iZubDFU 4phizONpe27UFVErPoXS6g4wLN3c8gBdaluwWTPQNfVsCq/WjbypCg/jITC3QM+U34O5 48Vg== X-Gm-Message-State: AOAM5335nyll7nbBpicQZpGquTa/W36kv7PeRhi1KZq1NlmsTEbFsRrK /JmBgcmBt39I8MC2N90FdR5QIg== X-Received: by 2002:a1c:dc05:: with SMTP id t5mr4402679wmg.112.1589551389616; Fri, 15 May 2020 07:03:09 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id x16sm3814048wrq.23.2020.05.15.07.03.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 07:03:08 -0700 (PDT) Date: Fri, 15 May 2020 16:03:06 +0200 From: Daniel Vetter To: David Stevens Cc: Tomasz Figa , Gerd Hoffmann , David Airlie , "Michael S . Tsirkin" , Jason Wang , Sumit Semwal , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Linux Kernel Mailing List , dri-devel , "open list:VIRTIO CORE, NET..." , "open list:DMA BUFFER SHARING FRAMEWORK" , "moderated list:DMA BUFFER SHARING FRAMEWORK" , virtio-dev@lists.oasis-open.org, Daniel Vetter Subject: Re: [PATCH v3 1/4] dma-buf: add support for virtio exported objects Message-ID: <20200515140306.GF206103@phenom.ffwll.local> Mail-Followup-To: David Stevens , Tomasz Figa , Gerd Hoffmann , David Airlie , "Michael S . Tsirkin" , Jason Wang , Sumit Semwal , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Linux Kernel Mailing List , dri-devel , "open list:VIRTIO CORE, NET..." , "open list:DMA BUFFER SHARING FRAMEWORK" , "moderated list:DMA BUFFER SHARING FRAMEWORK" , virtio-dev@lists.oasis-open.org References: <20200311112004.47138-1-stevensd@chromium.org> <20200311112004.47138-2-stevensd@chromium.org> <20200514123007.GP206103@phenom.ffwll.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: Linux phenom 5.6.0-1-amd64 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 15, 2020 at 02:07:06PM +0900, David Stevens wrote: > On Thu, May 14, 2020 at 9:30 PM Daniel Vetter wrote: > > On Thu, May 14, 2020 at 05:19:40PM +0900, David Stevens wrote: > > > Sorry for the duplicate reply, didn't notice this until now. > > > > > > > Just storing > > > > the uuid should be doable (assuming this doesn't change during the > > > > lifetime of the buffer), so no need for a callback. > > > > > > Directly storing the uuid doesn't work that well because of > > > synchronization issues. The uuid needs to be shared between multiple > > > virtio devices with independent command streams, so to prevent races > > > between importing and exporting, the exporting driver can't share the > > > uuid with other drivers until it knows that the device has finished > > > registering the uuid. That requires a round trip to and then back from > > > the device. Using a callback allows the latency from that round trip > > > registration to be hidden. > > > > Uh, that means you actually do something and there's locking involved. > > Makes stuff more complicated, invariant attributes are a lot easier > > generally. Registering that uuid just always doesn't work, and blocking > > when you're exporting? > > Registering the id at creation and blocking in gem export is feasible, > but it doesn't work well for systems with a centralized buffer > allocator that doesn't support batch allocations (e.g. gralloc). In > such a system, the round trip latency would almost certainly be > included in the buffer allocation time. At least on the system I'm > working on, I suspect that would add 10s of milliseconds of startup > latency to video pipelines (although I haven't benchmarked the > difference). Doing the blocking as late as possible means most or all > of the latency can be hidden behind other pipeline setup work. > > In terms of complexity, I think the synchronization would be basically > the same in either approach, just in different locations. All it would > do is alleviate the need for a callback to fetch the UUID. Hm ok. I guess if we go with the older patch, where this all is a lot more just code in virtio, doing an extra function to allocate the uuid sounds fine. Then synchronization is entirely up to the virtio subsystem and not a dma-buf problem (and hence not mine). You can use dma_resv_lock or so, but no need to. But with callbacks potentially going both ways things always get a bit interesting wrt locking - this is what makes peer2peer dma-buf so painful right now. Hence I'd like to avoid that if needed, at least at the dma-buf level. virtio code I don't mind what you do there :-) Cheers, Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch