Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751258AbdFBPYE convert rfc822-to-8bit (ORCPT ); Fri, 2 Jun 2017 11:24:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59012 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750813AbdFBPYD (ORCPT ); Fri, 2 Jun 2017 11:24:03 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7AE3E80F95 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7AE3E80F95 Message-ID: <1496417038.16895.7.camel@redhat.com> Subject: Re: [PATCH v6 6/6] drm/i915/gvt: Adding interface so user space can get the dma-buf From: Gerd Hoffmann To: Alex Williamson , "Chen, Xiaoguang" Cc: "chris@chris-wilson.co.uk" , "intel-gfx@lists.freedesktop.org" , "linux-kernel@vger.kernel.org" , "zhenyuw@linux.intel.com" , "Lv, Zhiyuan" , "intel-gvt-dev@lists.freedesktop.org" , "Wang, Zhi A" , "Tian, Kevin" Date: Fri, 02 Jun 2017 17:23:58 +0200 In-Reply-To: <20170602085831.41454a1f@t450s.home> References: <1495874332-2851-1-git-send-email-xiaoguang.chen@intel.com> <1495874332-2851-7-git-send-email-xiaoguang.chen@intel.com> <20170601120820.3358f7dd@w520.home> <20170601213459.461ecf36@w520.home> <20170602085831.41454a1f@t450s.home> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Mime-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 02 Jun 2017 15:24:03 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 847 Lines: 22 Hi, > > When i915's dma-buf's release() callback is called it will try to > > free the gem object associated with the dma-buf if its ref count is > > 0. But in our case the ref count is 1 so no free callback is called > > so we can not release allocations there. Why the ref count is one? Who holds a reference and why? Maybe it should be the other way around, i.e. the dmabuf holds a reference on the vgpu instance backing it, i.e. you can't delete the vgpu while dma-bufs exist? > We cannot simply say that the user isn't allowed to release them in > that order. Yep, not going to fly. Can happen even unintentionally because we can pass around dmabufs to other processes. Example: qemu passes dmabuf to spice-client, then qemu crashes. mgmt fd is closed before dmabuf fd then. The kernel must be able to handle that. cheers, Gerd