Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2124162rwd; Mon, 15 May 2023 07:34:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6wNNPzRpI+pIOhJHCALEfP5huO2zkwT0hNUaoJP5CkcAdRBX754h4pnP6pOgzIXiCGNJCh X-Received: by 2002:a05:6a20:7f98:b0:106:11fa:b802 with SMTP id d24-20020a056a207f9800b0010611fab802mr4649802pzj.15.1684161281175; Mon, 15 May 2023 07:34:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684161281; cv=none; d=google.com; s=arc-20160816; b=rwIgGQKCOV8uJH3uNhoZfVIqQ9jqsEdbzH6Szg3geTPmqkYXB0XjQNdraIHHtEmjnK z0mxwnjUUFP6Dj+M2r5a21+hBki4Q3zTRc1s6KqYoaRuPY8WcV6sl/DM9QR5eyd2dU+q YQ0GWFklFW3nrKdNp5fc7+xXHXfStWFK6uyeSqr+ATG9QA/e6gzpTvinezIqyQLIBk4Y UaL0+wC1wGGt9h+KlnYlCx0HqbgEz4WUuB+RzgyQfDTfwNEjliNXfTSzC2hAldagbazy JFi0YI6Zi2kDgezQpw0yXeM03HmUIIiVH16E3BxJMgJpMzWo2/jHYjfwF2hJMIEbywXD b6ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3L1H5A/AgNdZq2KMqprQZztlGdFsDSiLstadTyfsWps=; b=D0v6/FRpDsoTuWwjQmyVYIYZ3hJ7ReidO4I2HiTGt6cDeVU49bwjzjVd4wLjTfQIGp bU6r4OF1J+n9KhQLEkFQ/SB7VydsM6PNagbgiKt3lrfq3UC5eOxHV5xZt+X290i6EaTd uuSVGr7D4UADiAa59R4ki3t5jGGzX1nidJAR1ub4XRveMidouCS4N7j6vouuN/ZCB2AC CHW20ADGH9MNKQNffIcrG+0ePR6Iy5HOfuHRuipd5yAbmgQinFybM94c+9q1vvizWzio Q5O6LItrUxyMwuc+axtwVNfWPSuKMREF/YMeGXDHnQp/wXJtgigxwHjB2OAKoSzkx76C eD9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=eCRMUe9G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k68-20020a633d47000000b005304ceae2e9si14950916pga.78.2023.05.15.07.34.26; Mon, 15 May 2023 07:34:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=eCRMUe9G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238294AbjEOObY (ORCPT + 99 others); Mon, 15 May 2023 10:31:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241639AbjEOObL (ORCPT ); Mon, 15 May 2023 10:31:11 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2932F2D4F; Mon, 15 May 2023 07:31:01 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1ab13da70a3so124326415ad.1; Mon, 15 May 2023 07:31:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684161060; x=1686753060; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3L1H5A/AgNdZq2KMqprQZztlGdFsDSiLstadTyfsWps=; b=eCRMUe9GcCej4DZn0o5scm14epytTxlq5SKShRg5NCvxZfpyg0sZ9Sl/rB+3TLrnjW s7+4/FXsCbKSOTfS9q8e0PGpu6T2VfNwGBkf8dJhzC8RwZZhKAhzywnit04Doft9V0qp opsWuRAf6zsqCll2HTwlXoHpthYiZEN7bGnCg2aGMl1kmxVskL+1GnGHsgmbYCHhic0s VmNa7CFqFEVuHk0AkesRR1+kmS2hHB04LP1Ky3hw3GlkkgZWFjZvG4syg12T3qZzWNP+ tBrXZmeupszD9NIkMbZwaRJe7ItV5YqzI/u1qG2P21uLKQ81ZM4OkRwO2qssdCLgl5Jg bm7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684161060; x=1686753060; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3L1H5A/AgNdZq2KMqprQZztlGdFsDSiLstadTyfsWps=; b=l7Os79rfxgFiaIR3Hld2f7YpqD1l8ZrFBFCRaPIkmdqlfU0+nRx2754XeJQRzVzKgz LMqPkScAXpY81TbmChNgZUeA5C64tCxRlEgvM2SUdpvesmXJmIGfkMSMbnL1zWAKgcns zBR+yaM9/gxJsJbt54dEEJQNG5hoKfDp5Qpv0M47/8bG3syfrjWmA+bUkmvEK9rgsfx2 HRrixRyiST+Ej4Qo1xy/dq++Ij74h2Crd991hV7TDVS2ASFQLUBZfoO7Tw6/mPpew9fa Ms+wT1xAgl3O1NO6hWPRjj47ee0aldMhGcLb0vhWMO2iw5mYDWzWSmQ9OYmyLWUFEl/E TUTA== X-Gm-Message-State: AC+VfDy74Cp6Um5Eo4HCDr+eUr6VNbMW2ip4FOmR83W5veYWPOylk2QR QmHOigkOATzWyIpuq5P55P0= X-Received: by 2002:a17:903:185:b0:1a1:e237:5f0 with SMTP id z5-20020a170903018500b001a1e23705f0mr46730970plg.58.1684161060586; Mon, 15 May 2023 07:31:00 -0700 (PDT) Received: from localhost ([2a00:79e1:abd:4a00:61b:48ed:72ab:435b]) by smtp.gmail.com with ESMTPSA id j12-20020a170902c3cc00b0019f3cc463absm13665435plj.0.2023.05.15.07.30.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 07:31:00 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: freedreno@lists.freedesktop.org, Daniel Vetter , Tvrtko Ursulin , Boris Brezillon , Christopher Healy , Emil Velikov , =?UTF-8?q?Christian=20K=C3=B6nig?= , Rob Clark , Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , David Airlie , linux-arm-msm@vger.kernel.org (open list:DRM DRIVER FOR MSM ADRENO GPU), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v4 6/9] drm/msm: Add memory stats to fdinfo Date: Mon, 15 May 2023 07:30:13 -0700 Message-Id: <20230515143023.801167-7-robdclark@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230515143023.801167-1-robdclark@gmail.com> References: <20230515143023.801167-1-robdclark@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rob Clark Use the new helper to export stats about memory usage. v2: Drop unintended hunk v3: Rebase Signed-off-by: Rob Clark Reviewed-by: Emil Velikov --- drivers/gpu/drm/msm/msm_drv.c | 2 ++ drivers/gpu/drm/msm/msm_gem.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 467c689a95f2..a403aebe7f5a 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -1045,20 +1045,22 @@ static const struct drm_ioctl_desc msm_ioctls[] = { static void msm_show_fdinfo(struct drm_printer *p, struct drm_file *file) { struct drm_device *dev = file->minor->dev; struct msm_drm_private *priv = dev->dev_private; if (!priv->gpu) return; msm_gpu_show_fdinfo(priv->gpu, file->driver_priv, p); + + drm_show_memory_stats(p, file); } static const struct file_operations fops = { .owner = THIS_MODULE, DRM_GEM_FOPS, .show_fdinfo = drm_show_fdinfo, }; static const struct drm_driver msm_driver = { .driver_features = DRIVER_GEM | diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c index cd39b9d8abdb..20cfd86d2b32 100644 --- a/drivers/gpu/drm/msm/msm_gem.c +++ b/drivers/gpu/drm/msm/msm_gem.c @@ -1083,34 +1083,49 @@ int msm_gem_new_handle(struct drm_device *dev, struct drm_file *file, msm_gem_object_set_name(obj, "%s", name); ret = drm_gem_handle_create(file, obj, handle); /* drop reference from allocate - handle holds it now */ drm_gem_object_put(obj); return ret; } +static enum drm_gem_object_status msm_gem_status(struct drm_gem_object *obj) +{ + struct msm_gem_object *msm_obj = to_msm_bo(obj); + enum drm_gem_object_status status = 0; + + if (msm_obj->pages) + status |= DRM_GEM_OBJECT_RESIDENT; + + if (msm_obj->madv == MSM_MADV_DONTNEED) + status |= DRM_GEM_OBJECT_PURGEABLE; + + return status; +} + static const struct vm_operations_struct vm_ops = { .fault = msm_gem_fault, .open = drm_gem_vm_open, .close = drm_gem_vm_close, }; static const struct drm_gem_object_funcs msm_gem_object_funcs = { .free = msm_gem_free_object, .pin = msm_gem_prime_pin, .unpin = msm_gem_prime_unpin, .get_sg_table = msm_gem_prime_get_sg_table, .vmap = msm_gem_prime_vmap, .vunmap = msm_gem_prime_vunmap, .mmap = msm_gem_object_mmap, + .status = msm_gem_status, .vm_ops = &vm_ops, }; static int msm_gem_new_impl(struct drm_device *dev, uint32_t size, uint32_t flags, struct drm_gem_object **obj) { struct msm_drm_private *priv = dev->dev_private; struct msm_gem_object *msm_obj; -- 2.40.1