From patchwork Thu Jan 29 18:46:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 5744651 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 170C3BF440 for ; Thu, 29 Jan 2015 18:46:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 46D452022D for ; Thu, 29 Jan 2015 18:46:41 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id EC37D20165 for ; Thu, 29 Jan 2015 18:46:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 29C466E781; Thu, 29 Jan 2015 10:46:39 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yk0-f179.google.com (mail-yk0-f179.google.com [209.85.160.179]) by gabe.freedesktop.org (Postfix) with ESMTP id 09EF26E782 for ; Thu, 29 Jan 2015 10:46:38 -0800 (PST) Received: by mail-yk0-f179.google.com with SMTP id 142so14752721ykq.10 for ; Thu, 29 Jan 2015 10:46:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=UpxlSeZ3KiAbv+H23Xu7FosD9WX4YlzO4WB3WoM14jc=; b=F+WyQwTwt6AJEgytcsV9ToEAAanIrZg08QmPqd+3S1jFPpAOCkADR9yhJq3RK59eg4 keeZmgCqKOyWGXYtJdq68J+jIW1HhXwU9peXpid1ZYmH3ZxXpiXx+3zxVTo8r3GB8BCW 4nCpTrDSzbJpT2o6qhlKXvtPbZ7kWBR+x7QFM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=UpxlSeZ3KiAbv+H23Xu7FosD9WX4YlzO4WB3WoM14jc=; b=Mex81Hdj78013rYNybIRltCiWZyRIW8hjHA5fZeXQikIT9PyPipBzfC9Oeis7RmdCq Jf2k+77bIW/2WzAiQ3QiRWRYRxli1om3M98iyTGEDT8ErGfE3cyk3yuY4/a33c2NpuM9 3DfWXc4v3vLRks5XjlekzBrTA7WWXPrZ+HCRQR2g2o/dxYBVOybLZqcx/rleWytFI9fo cvDU+WOb11RvCENA4ydpFzd/5qEpEEquy9K1brXCU6XbmdU9O6CdrZhdTWcnVvbIxpam rS0po7qKgQXsRROjc+DviDsEpRj2l15VoKLsffLl+QS7KFlcxAfI/kKM0GrQSWH0BoXa 2Tyw== X-Gm-Message-State: ALoCoQlDzsDx91awlvbcqNBq/XNCnm4rRqe1kC9UbGPdZYa+1f6IANqbATCC6uPvzvI6++XQuK/Y X-Received: by 10.236.228.163 with SMTP id f33mr1240617yhq.56.1422557197546; Thu, 29 Jan 2015 10:46:37 -0800 (PST) Received: from billyjoel.corp.google.com ([100.96.106.205]) by mx.google.com with ESMTPSA id l66sm5050651yha.2.2015.01.29.10.46.35 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Jan 2015 10:46:36 -0800 (PST) From: Sean Paul To: thierry.reding@gmail.com Subject: [PATCH] drm/tegra: Add tegra_gem_mmap2 to fix 64-bit offsets Date: Thu, 29 Jan 2015 13:46:29 -0500 Message-Id: <1422557189-31658-1-git-send-email-seanpaul@chromium.org> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c Cc: marcheu@chromium.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-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 64-bit targets, tegra_gem_mmap doesn't return the offset to userspace. As such, subsequent calls to mmap(2) fail. Add a new tegra_gem_mmap2 ioctl to fix this. Signed-off-by: Sean Paul --- drivers/gpu/drm/tegra/drm.c | 21 +++++++++++++++++++++ include/uapi/drm/tegra_drm.h | 8 ++++++++ 2 files changed, 29 insertions(+) diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c index d4f8275..be5dbe7 100644 --- a/drivers/gpu/drm/tegra/drm.c +++ b/drivers/gpu/drm/tegra/drm.c @@ -343,6 +343,26 @@ static int tegra_gem_create(struct drm_device *drm, void *data, return 0; } +static int tegra_gem_mmap2(struct drm_device *drm, void *data, + struct drm_file *file) +{ + struct drm_tegra_gem_mmap2 *args = data; + struct drm_gem_object *gem; + struct tegra_bo *bo; + + gem = drm_gem_object_lookup(drm, file, args->handle); + if (!gem) + return -EINVAL; + + bo = to_tegra_bo(gem); + + args->offset = drm_vma_node_offset_addr(&bo->gem.vma_node); + + drm_gem_object_unreference(gem); + + return 0; +} + static int tegra_gem_mmap(struct drm_device *drm, void *data, struct drm_file *file) { @@ -677,6 +697,7 @@ static const struct drm_ioctl_desc tegra_drm_ioctls[] = { DRM_IOCTL_DEF_DRV(TEGRA_GEM_GET_TILING, tegra_gem_get_tiling, DRM_UNLOCKED), DRM_IOCTL_DEF_DRV(TEGRA_GEM_SET_FLAGS, tegra_gem_set_flags, DRM_UNLOCKED), DRM_IOCTL_DEF_DRV(TEGRA_GEM_GET_FLAGS, tegra_gem_get_flags, DRM_UNLOCKED), + DRM_IOCTL_DEF_DRV(TEGRA_GEM_MMAP2, tegra_gem_mmap2, DRM_UNLOCKED), #endif }; diff --git a/include/uapi/drm/tegra_drm.h b/include/uapi/drm/tegra_drm.h index c15d781..9035257 100644 --- a/include/uapi/drm/tegra_drm.h +++ b/include/uapi/drm/tegra_drm.h @@ -167,6 +167,12 @@ struct drm_tegra_gem_get_flags { __u32 flags; }; +struct drm_tegra_gem_mmap2 { + __u32 handle; + __u64 offset; +}; + + #define DRM_TEGRA_GEM_CREATE 0x00 #define DRM_TEGRA_GEM_MMAP 0x01 #define DRM_TEGRA_SYNCPT_READ 0x02 @@ -181,6 +187,7 @@ struct drm_tegra_gem_get_flags { #define DRM_TEGRA_GEM_GET_TILING 0x0b #define DRM_TEGRA_GEM_SET_FLAGS 0x0c #define DRM_TEGRA_GEM_GET_FLAGS 0x0d +#define DRM_TEGRA_GEM_MMAP2 0x0e #define DRM_IOCTL_TEGRA_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_CREATE, struct drm_tegra_gem_create) #define DRM_IOCTL_TEGRA_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_MMAP, struct drm_tegra_gem_mmap) @@ -196,5 +203,6 @@ struct drm_tegra_gem_get_flags { #define DRM_IOCTL_TEGRA_GEM_GET_TILING DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_GET_TILING, struct drm_tegra_gem_get_tiling) #define DRM_IOCTL_TEGRA_GEM_SET_FLAGS DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_SET_FLAGS, struct drm_tegra_gem_set_flags) #define DRM_IOCTL_TEGRA_GEM_GET_FLAGS DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_GET_FLAGS, struct drm_tegra_gem_get_flags) +#define DRM_IOCTL_TEGRA_GEM_MMAP2 DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_MMAP2, struct drm_tegra_gem_mmap2) #endif