From patchwork Mon Feb 6 17:39:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jordan Crouse X-Patchwork-Id: 9558543 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E4E6F60547 for ; Mon, 6 Feb 2017 17:41:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5C8B26224 for ; Mon, 6 Feb 2017 17:41:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CAC6827F82; Mon, 6 Feb 2017 17:41:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7CE5026224 for ; Mon, 6 Feb 2017 17:41:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D926B6E53F; Mon, 6 Feb 2017 17:39:50 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from smtp.codeaurora.org (smtp.codeaurora.org [198.145.29.96]) by gabe.freedesktop.org (Postfix) with ESMTPS id B1FC66E50E; Mon, 6 Feb 2017 17:39:46 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 9D7BC609C3; Mon, 6 Feb 2017 17:39:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1486402786; bh=SH8wtR8iqC5qpfiXF/Ku2alTYdvIGVkW3vXOnzwmze4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lJIIYwwsBotrVSulOftNARSh+jD9U3RoHxkaSvAd6mdFET9DLC2Y7uVTCs8P69j+F s4xr/unmMHlLxIxCDPcMfnCxj+bWOCSbITLdEjKwUD8+8O+HrL/iudEkZ1qGNpvfzQ eSveKuIQOTuJSs3rPT1yrwwtlnFtngw5mvDHSB54= Received: from jcrouse-lnx.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: jcrouse@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id DEEE5609C3; Mon, 6 Feb 2017 17:39:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1486402786; bh=SH8wtR8iqC5qpfiXF/Ku2alTYdvIGVkW3vXOnzwmze4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lJIIYwwsBotrVSulOftNARSh+jD9U3RoHxkaSvAd6mdFET9DLC2Y7uVTCs8P69j+F s4xr/unmMHlLxIxCDPcMfnCxj+bWOCSbITLdEjKwUD8+8O+HrL/iudEkZ1qGNpvfzQ eSveKuIQOTuJSs3rPT1yrwwtlnFtngw5mvDHSB54= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org DEEE5609C3 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=jcrouse@codeaurora.org From: Jordan Crouse To: freedreno@lists.freedesktop.org Subject: [PATCH 03/11] drm/msm: Add hint to DRM_IOCTL_MSM_GEM_INFO to return an object IOVA Date: Mon, 6 Feb 2017 10:39:31 -0700 Message-Id: <1486402779-9024-4-git-send-email-jcrouse@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1486402779-9024-1-git-send-email-jcrouse@codeaurora.org> References: <1486402779-9024-1-git-send-email-jcrouse@codeaurora.org> Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Modify the 'pad' member of struct drm_msm_gem_info to 'hint'. If the user sets 'hint' to non-zero it means that they want a IOVA for the GEM object instead of a mmap() offset. Return the iova in the 'offset' member. Signed-off-by: Jordan Crouse --- drivers/gpu/drm/msm/msm_drv.c | 29 +++++++++++++++++++++++++---- include/uapi/drm/msm_drm.h | 4 ++-- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index e29bb66..1e4e022 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -677,6 +677,17 @@ static int msm_ioctl_gem_cpu_fini(struct drm_device *dev, void *data, return ret; } +static int msm_ioctl_gem_info_iova(struct drm_device *dev, + struct drm_gem_object *obj, uint64_t *iova) +{ + struct msm_drm_private *priv = dev->dev_private; + + if (!priv->gpu) + return -EINVAL; + + return msm_gem_get_iova(obj, priv->gpu->aspace, iova); +} + static int msm_ioctl_gem_info(struct drm_device *dev, void *data, struct drm_file *file) { @@ -684,14 +695,24 @@ static int msm_ioctl_gem_info(struct drm_device *dev, void *data, struct drm_gem_object *obj; int ret = 0; - if (args->pad) - return -EINVAL; - obj = drm_gem_object_lookup(file, args->handle); if (!obj) return -ENOENT; - args->offset = msm_gem_mmap_offset(obj); + /* + * If the hint variable is set, it means that the user wants a IOVA for + * this buffer. Return the address from the GPU because that is + * probably what it is looking for + */ + if (args->hint) { + uint64_t iova; + + ret = msm_ioctl_gem_info_iova(dev, obj, &iova); + if (!ret) + args->offset = iova; + } else { + args->offset = msm_gem_mmap_offset(obj); + } drm_gem_object_unreference_unlocked(obj); diff --git a/include/uapi/drm/msm_drm.h b/include/uapi/drm/msm_drm.h index 4d5d6a2..045ad20 100644 --- a/include/uapi/drm/msm_drm.h +++ b/include/uapi/drm/msm_drm.h @@ -105,8 +105,8 @@ struct drm_msm_gem_new { struct drm_msm_gem_info { __u32 handle; /* in */ - __u32 pad; - __u64 offset; /* out, offset to pass to mmap() */ + __u32 hint; /* in */ + __u64 offset; /* out, mmap() offset if hint is 0, iova if 1 */ }; #define MSM_PREP_READ 0x01