Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp134373imm; Tue, 12 Jun 2018 20:15:59 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJS1RDEwP/ZT+OSjyMZRBObJBNLshGuhbAopVPOvSjs40ySMExqZIaXdi75umopqGZczdKy X-Received: by 2002:a17:902:bb8d:: with SMTP id m13-v6mr3203620pls.46.1528859759529; Tue, 12 Jun 2018 20:15:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528859759; cv=none; d=google.com; s=arc-20160816; b=sKYrZFTNkKzGmb3NC1kyUmkfFyn7tVCcocGEI7tmKiKeHCRqaHTHQc/IXs47WIOt3K Gvsr1/JYePujLRukmyVtS1bEn5rSmbRneqhSW70EJrSpNLGSZ7rD/GukWRM/AgqMWz8F SNi71oCIuvJ9mdTpmPgKyxEfXXWju7tGhwYdM7nqOn7LPzKQ1L9IyjieRcKCNsNJ6YAC GI1rEcFx3dK47JswOrshVM5EhnfCbYrXfL8aYuKtChWN0VEKz4MEbNfBGMtgU96ez+5x PecrMDdNN0OpvobjOCjLEouKsyI97fxZu0y+jhoPo+dX4OqiTowVPBYWE7v5az8msAgE nitQ== 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:dkim-signature :arc-authentication-results; bh=rk9H8ECkUHTZTHA16nbIj1YbQ2GtX4F/saF9QVPbo9M=; b=ImBiRO/Kk6KVkRsE8PqafNcDMsRyEVpMO47SbdoluX2sHIc1g9Xb9ndp2Tm5xtQMEx 52nAiZveS4fZ8lv+cAib5iubM9Wf6Ef4unu85yqcutksEiXen9vu/jP5U8v0NX7nKs0X fu8mj7HSeKqBVIaclxT5Q+kD0RcwD2SB9cng/WZeK9jKW9Q07eEa756sjb94iEfk0kWO 4Zmu9PBe5tGf5WH4aL3ioMj1wd7vC7CDWjyqtelOJdD+eYp4qA8GNwGbgnHS1vTUXxLf t57CDIaDmP2UdVoKaTsTbUZ4rN+sqaOYKHhlUQBL/cG3j1wrK+NfZGf+DajB7CK6dkVB 4vzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=HLa3VHQJ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v72-v6si1614137pfa.103.2018.06.12.20.15.32; Tue, 12 Jun 2018 20:15:59 -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; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=HLa3VHQJ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754398AbeFMDO6 (ORCPT + 99 others); Tue, 12 Jun 2018 23:14:58 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:44430 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754202AbeFMDO5 (ORCPT ); Tue, 12 Jun 2018 23:14:57 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w5D3ArXs168522; Wed, 13 Jun 2018 03:14:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=rk9H8ECkUHTZTHA16nbIj1YbQ2GtX4F/saF9QVPbo9M=; b=HLa3VHQJj/QjiMKyAG4gR+NM+jZNEn3cqso/K8no3R7LpQw0K03/kqD70fSxa8P0QvGw elS92sKdfSMJsfRaLiJuqFMcLqKkdYWGrVzTdZ1zi08nkBELM9u0kv/cXqvIxWpHXJmi /c0bZCmCrky3mSRnmftqi3J2BsLmKdIOYfYc8SMow826gfcsYIfMt2sufM19PK8qRMUm ze5bzJ3HUiwoajtPwl2QbZ+AzoYrldyDfq2hISexmc6SGcoUiK3nFYp/gbdYOict6rN1 6jF4guf7AQisVFx2sEfNwF9/JUGgu6okzVwDPP4C9m/LInYx4MJmEhRL0TxuM4nSEOP6 yQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2130.oracle.com with ESMTP id 2jjp6c8hqf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Jun 2018 03:14:46 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w5D3Ej03023123 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Jun 2018 03:14:46 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w5D3Eifa023035; Wed, 13 Jun 2018 03:14:44 GMT Received: from [10.154.144.7] (/10.154.144.7) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 12 Jun 2018 20:14:44 -0700 Subject: Re: [PATCH v3 9/9] xen/gntdev: Implement dma-buf import functionality To: Oleksandr Andrushchenko , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, jgross@suse.com, konrad.wilk@oracle.com Cc: daniel.vetter@intel.com, dongwon.kim@intel.com, matthew.d.roper@intel.com, Oleksandr Andrushchenko References: <20180612134200.17456-1-andr2000@gmail.com> <20180612134200.17456-10-andr2000@gmail.com> From: Boris Ostrovsky Message-ID: Date: Tue, 12 Jun 2018 23:14:42 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180612134200.17456-10-andr2000@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8922 signatures=668702 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=749 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1805220000 definitions=main-1806130036 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/12/2018 09:42 AM, Oleksandr Andrushchenko wrote: > int gntdev_dmabuf_imp_release(struct gntdev_dmabuf_priv *priv, u32 fd) > { > - return -EINVAL; > + struct gntdev_dmabuf *gntdev_dmabuf; > + struct dma_buf_attachment *attach; > + struct dma_buf *dma_buf; > + > + gntdev_dmabuf = dmabuf_imp_find_unlink(priv, fd); > + if (IS_ERR(gntdev_dmabuf)) > + return PTR_ERR(gntdev_dmabuf); > + > + pr_debug("Releasing DMA buffer with fd %d\n", fd); > + > + attach = gntdev_dmabuf->u.imp.attach; > + > + if (gntdev_dmabuf->u.imp.sgt) > + dma_buf_unmap_attachment(attach, gntdev_dmabuf->u.imp.sgt, > + DMA_BIDIRECTIONAL); > + dma_buf = attach->dmabuf; > + dma_buf_detach(attach->dmabuf, attach); > + dma_buf_put(dma_buf); > + > + dmabuf_imp_end_foreign_access(gntdev_dmabuf->u.imp.refs, > + gntdev_dmabuf->nr_pages); Should you first end foreign access, before doing anything? -boris > + dmabuf_imp_free_storage(gntdev_dmabuf); > + return 0; > } >