From patchwork Fri Nov 30 15:00:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 10706491 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 5BB1F13AD for ; Fri, 30 Nov 2018 15:01:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C27630199 for ; Fri, 30 Nov 2018 15:01:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40902301E4; Fri, 30 Nov 2018 15:01:17 +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 E80DC301E3 for ; Fri, 30 Nov 2018 15:01:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 35CD26E61D; Fri, 30 Nov 2018 15:01:14 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by gabe.freedesktop.org (Postfix) with ESMTPS id D12CC6E619; Fri, 30 Nov 2018 15:01:08 +0000 (UTC) Received: by mail-qk1-x743.google.com with SMTP id w204so3312328qka.2; Fri, 30 Nov 2018 07:01:08 -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=luJtdTOq5YyKAq6WN9mVXmmzV+2w+uytn39snmmCeq4=; b=UM5wse/k1OEifsjh1jWpiCn1MR6O3r1NkDQ3MVzbfOTgor17kmyqw37CC8fg/ULaHh pTTdtwjyMWriBVSj3TeoFdM97zcONndiTcBv24rrW0hnIZmjktoF6CGAoTtVd7/DI4Mb WK/HSU6214PmWY0zA+FB0GCQRJNmCESrF/M7P54p/RvtmFkerPNhmxh/3xUPrEE2/lq3 u4fIBD6IARIJoRzP1NAM/++K9Y/hFgJtiwpxBS48EKB1wzHF3Mcs1Jen79WHrCLhzkSW YgmysAmjMbG6oocSTLo5GWAWdC0FvPhp6LTIz5IuYsMeNYm9QzP9o5xPwnw3/sYEZ+o2 ONxg== X-Gm-Message-State: AA+aEWZ5Yx2HdOxbgux5BPWHu04iBEjmLWrvdIuB1JoshKKTnWbXCOu6 mSFXkh4RigtbIVxgOzdLINfLpBvK X-Google-Smtp-Source: AFSGD/WSve9AcaU/LS2rxVkDSOPUuMmvKLpx1KtVOvrrSnPOlz1ZN/SSVjGB/+BVVe8ifvvAqnRLUg== X-Received: by 2002:a37:2808:: with SMTP id o8mr5430825qkh.14.1543590067701; Fri, 30 Nov 2018 07:01:07 -0800 (PST) Received: from localhost ([144.121.20.162]) by smtp.gmail.com with ESMTPSA id 46sm3629818qtv.22.2018.11.30.07.01.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Nov 2018 07:01:06 -0800 (PST) From: Rob Clark To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/4] drm/msm: add uapi to get/set debug name Date: Fri, 30 Nov 2018 10:00:41 -0500 Message-Id: <20181130150050.13762-4-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 Add UAPI to get/set GEM objects' debug name. Signed-off-by: Rob Clark --- drivers/gpu/drm/msm/msm_drv.c | 36 ++++++++++++++++++++++++++++++++++- include/uapi/drm/msm_drm.h | 2 ++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 913f5b3642b5..6ebbd5010722 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -23,6 +23,7 @@ #include "msm_drv.h" #include "msm_debugfs.h" #include "msm_fence.h" +#include "msm_gem.h" #include "msm_gpu.h" #include "msm_kms.h" @@ -861,7 +862,8 @@ static int msm_ioctl_gem_info(struct drm_device *dev, void *data, { struct drm_msm_gem_info *args = data; struct drm_gem_object *obj; - int ret = 0; + struct msm_gem_object *msm_obj; + int i, ret = 0; switch (args->info) { case MSM_INFO_GET_OFFSET: @@ -870,6 +872,9 @@ static int msm_ioctl_gem_info(struct drm_device *dev, void *data, if (args->len) return -EINVAL; break; + case MSM_INFO_SET_NAME: + case MSM_INFO_GET_NAME: + break; default: return -EINVAL; } @@ -878,6 +883,8 @@ static int msm_ioctl_gem_info(struct drm_device *dev, void *data, if (!obj) return -ENOENT; + msm_obj = to_msm_bo(obj); + switch (args->info) { case MSM_INFO_GET_OFFSET: args->value = msm_gem_mmap_offset(obj); @@ -885,6 +892,33 @@ static int msm_ioctl_gem_info(struct drm_device *dev, void *data, case MSM_INFO_GET_IOVA: ret = msm_ioctl_gem_info_iova(dev, obj, &args->value); break; + case MSM_INFO_SET_NAME: + /* length check should leave room for terminating null: */ + if (args->len >= sizeof(msm_obj->name)) { + ret = -EINVAL; + break; + } + ret = copy_from_user(msm_obj->name, + u64_to_user_ptr(args->value), args->len); + msm_obj->name[args->len] = '\0'; + for (i = 0; i < args->len; i++) { + if (!isprint(msm_obj->name[i])) { + msm_obj->name[i] = '\0'; + break; + } + } + break; + case MSM_INFO_GET_NAME: + if (args->value && (args->len < strlen(msm_obj->name))) { + ret = -EINVAL; + break; + } + args->len = strlen(msm_obj->name); + if (args->value) { + ret = copy_to_user(u64_to_user_ptr(args->value), + msm_obj->name, args->len); + } + break; } drm_gem_object_put_unlocked(obj); diff --git a/include/uapi/drm/msm_drm.h b/include/uapi/drm/msm_drm.h index bc1757848c7c..09f16fd7beda 100644 --- a/include/uapi/drm/msm_drm.h +++ b/include/uapi/drm/msm_drm.h @@ -114,6 +114,8 @@ struct drm_msm_gem_new { */ #define MSM_INFO_GET_OFFSET 0x00 /* get mmap() offset, returned by value */ #define MSM_INFO_GET_IOVA 0x01 /* get iova, returned by value */ +#define MSM_INFO_SET_NAME 0x02 /* set the debug name (by pointer) */ +#define MSM_INFO_GET_NAME 0x03 /* get debug name, returned by pointer */ struct drm_msm_gem_info { __u32 handle; /* in */