From patchwork Fri Nov 30 15:00:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 10706483 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8715113BF for ; Fri, 30 Nov 2018 15:01:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 773E6301AF for ; Fri, 30 Nov 2018 15:01:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B43D301D8; Fri, 30 Nov 2018 15:01:10 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 23C20301AF for ; Fri, 30 Nov 2018 15:01:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3455C6E619; Fri, 30 Nov 2018 15:01:09 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by gabe.freedesktop.org (Postfix) with ESMTPS id 947FD6E619; Fri, 30 Nov 2018 15:01:05 +0000 (UTC) Received: by mail-qk1-x741.google.com with SMTP id w204so3312196qka.2; Fri, 30 Nov 2018 07:01:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZIIynXA0FFPSVLn3lu7FimIsuF4uLklcho7eShOE9ec=; b=BDcbliiZgPiPh3liTz3FFLmaVq3egrbjFw7Ij3IQYCSMKWYXm34fv+YtU2OER2K1Yw d2ku8KADOLfFWmtccFq3AzO1/trGetpBmeH4iWKVvqFpJX+geWPZo4R4D4QWmDz4wYJE +cul4EFZslC8uuvSCCrVd8JPQLeLHcOY5bdgNYZH53Y/bTjCWPNatEwOLvipVgUH3M9S 8/nXf4QbWmk+8kkcychAQvYbzqNSlRExFjji1MrG+yGy+lSbagm9wz8JfaJ18lq6/T+K I/lC4NLVMEpSutwbueedXeoZCLmubwf+XRKmgBijCN0HhLuvzmjnS2K+HluDnG1u6lJj AJlQ== X-Gm-Message-State: AA+aEWY9wdYE4nMnNEAvX5xAoi8wqMSZ508AdZot2DU0Qg9ZKLomxS8m RS70uXqXmc5APw6AQTrp0oTDqSOl X-Google-Smtp-Source: AFSGD/VBclVMflf2PkhIstqjDgtpeWySWWZjjSUuJsaYqjszs6R9mPuxycA1WNmZR5V4Vo/iAaGdVw== X-Received: by 2002:a37:8d81:: with SMTP id p123mr5425667qkd.241.1543590064496; Fri, 30 Nov 2018 07:01:04 -0800 (PST) Received: from localhost ([144.121.20.162]) by smtp.gmail.com with ESMTPSA id k22sm2417808qtm.73.2018.11.30.07.01.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Nov 2018 07:01:03 -0800 (PST) From: Rob Clark To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/4] drm/msm: rework GEM_INFO ioctl Date: Fri, 30 Nov 2018 10:00:40 -0500 Message-Id: <20181130150050.13762-3-robdclark@gmail.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181130150050.13762-1-robdclark@gmail.com> References: <20181130150050.13762-1-robdclark@gmail.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, freedreno@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Prep work to add a way to get/set the GEM objects debug name. Signed-off-by: Rob Clark --- drivers/gpu/drm/msm/msm_drv.c | 25 ++++++++++++++++--------- include/uapi/drm/msm_drm.h | 17 ++++++++++++----- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 9f823bf8d312..913f5b3642b5 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -863,21 +863,28 @@ static int msm_ioctl_gem_info(struct drm_device *dev, void *data, struct drm_gem_object *obj; int ret = 0; - if (args->flags & ~MSM_INFO_FLAGS) + switch (args->info) { + case MSM_INFO_GET_OFFSET: + case MSM_INFO_GET_IOVA: + /* value returned as immediate, not pointer, so len==0: */ + if (args->len) + return -EINVAL; + break; + default: return -EINVAL; + } obj = drm_gem_object_lookup(file, args->handle); if (!obj) return -ENOENT; - if (args->flags & MSM_INFO_IOVA) { - 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); + switch (args->info) { + case MSM_INFO_GET_OFFSET: + args->value = msm_gem_mmap_offset(obj); + break; + case MSM_INFO_GET_IOVA: + ret = msm_ioctl_gem_info_iova(dev, obj, &args->value); + break; } drm_gem_object_put_unlocked(obj); diff --git a/include/uapi/drm/msm_drm.h b/include/uapi/drm/msm_drm.h index 3c3af92c4b3e..bc1757848c7c 100644 --- a/include/uapi/drm/msm_drm.h +++ b/include/uapi/drm/msm_drm.h @@ -105,14 +105,21 @@ struct drm_msm_gem_new { __u32 handle; /* out */ }; -#define MSM_INFO_IOVA 0x01 - -#define MSM_INFO_FLAGS (MSM_INFO_IOVA) +/* Get or set GEM buffer info. The requested value can be passed + * directly in 'value', or for data larger than 64b 'value' is a + * pointer to userspace buffer, with 'len' specifying the number of + * bytes copied into that buffer. For info returned by pointer, + * calling the GEM_INFO ioctl with null 'value' will return the + * required buffer size in 'len' + */ +#define MSM_INFO_GET_OFFSET 0x00 /* get mmap() offset, returned by value */ +#define MSM_INFO_GET_IOVA 0x01 /* get iova, returned by value */ struct drm_msm_gem_info { __u32 handle; /* in */ - __u32 flags; /* in - combination of MSM_INFO_* flags */ - __u64 offset; /* out, mmap() offset or iova */ + __u32 info; /* in - one of MSM_INFO_* */ + __u64 value; /* in or out */ + __u32 len; /* in or out */ }; #define MSM_PREP_READ 0x01