From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751023AbdEBJvF convert rfc822-to-8bit (ORCPT ); Tue, 2 May 2017 05:51:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52252 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750751AbdEBJvE (ORCPT ); Tue, 2 May 2017 05:51:04 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0CC6522CA47 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0CC6522CA47 Message-ID: <1493718658.8581.82.camel@redhat.com> Subject: Re: [RFC PATCH 6/6] drm/i915/gvt: support QEMU getting the dmabuf From: Gerd Hoffmann To: Xiaoguang Chen Cc: alex.williamson@redhat.com, intel-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, zhi.a.wang@intel.com, zhenyuw@linux.intel.com, linux-kernel@vger.kernel.org, zhiyuan.lv@intel.com, kevin.tian@intel.com Date: Tue, 02 May 2017 11:50:58 +0200 In-Reply-To: <1493372130-27727-7-git-send-email-xiaoguang.chen@intel.com> References: <1493372130-27727-1-git-send-email-xiaoguang.chen@intel.com> <1493372130-27727-7-git-send-email-xiaoguang.chen@intel.com> 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.39]); Tue, 02 May 2017 09:51:03 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fr, 2017-04-28 at 17:35 +0800, Xiaoguang Chen wrote: > +static size_t intel_vgpu_reg_rw_gvtg(struct intel_vgpu *vgpu, char > *buf, > + size_t count, loff_t *ppos, bool iswrite) > +{ > + unsigned int i = VFIO_PCI_OFFSET_TO_INDEX(*ppos) - > + VFIO_PCI_NUM_REGIONS; > + loff_t pos = *ppos & VFIO_PCI_OFFSET_MASK; > + int fd; > + > + if (pos >= vgpu->vdev.region[i].size || iswrite) { > + gvt_vgpu_err("invalid op or offset for Intel vgpu fd > region\n"); > + return -EINVAL; > + } > + > + fd = anon_inode_getfd("gvtg", &intel_vgpu_gvtg_ops, vgpu, > + O_RDWR | O_CLOEXEC); > + if (fd < 0) { > + gvt_vgpu_err("create intel vgpu fd failed:%d\n", fd); > + return -EINVAL; > + } > + > + count = min(count, (size_t)(vgpu->vdev.region[i].size - pos)); > + memcpy(buf, &fd, count); > + > + return count; > +} Hmm, that looks like a rather strange way to return a file descriptor. What is the reason to not use ioctls on the vfio file handle, like older version of these patches did? cheers, Gerd