From patchwork Tue Apr 11 22:56:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 13208320 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57B64C7619A for ; Tue, 11 Apr 2023 22:57:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229674AbjDKW5w (ORCPT ); Tue, 11 Apr 2023 18:57:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229647AbjDKW5p (ORCPT ); Tue, 11 Apr 2023 18:57:45 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B5C140D7; Tue, 11 Apr 2023 15:57:43 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id y6so8321128plp.2; Tue, 11 Apr 2023 15:57:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681253863; 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=ndo7/lTZcfHCD79DpWpY2qpFEQ7Xd6kuppJxXwpF0ms=; b=MelNz4UYP8A57Tyb6z4hyxuO2j+c1WaLKmnMvc26DemjfOxamU6zD12VnHZGDqc3sF 4JknlyvWJJOyzN5YxBtAvezxx7qilD7GR1KNApjm5w6EZsbjOgJGjZ/4Ba0Fzji691EF 1Y3u1YQgRH+e7cr4XvUp3YKWJZVhGVuUBQQXdoeyZeo5IpFjDBJ5UpUSYju5WqonLxiY l5gtPurRXeR9im6uK0YSjH3U2DkCFTYfk6z0UQOGDdyqhHcVHMoD8oycqXJuSKE4EU6v lwhf+f/43tdjxsEik3bx8Ya98FAq/i5VpC6UxsGWxOykAX6edRGBz6615HG4mMwyKsoa 4QoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681253863; 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=ndo7/lTZcfHCD79DpWpY2qpFEQ7Xd6kuppJxXwpF0ms=; b=nUGSYxn70D8qcscFbtgUMoJfcDKvWc7kR/UR48D/+7PQBTdRrcFryLE/RUemWH5wmk m6a3PgJEjgjk5PsDRiAQloUTeQ8P8iuzojFKmx8roZU80j0z0taDWo/RRum8Ab5xvKmV 0/U6jWlT+qpyBsA/MtdXo404L9w1ejT/Fk5J4A303HPt1ATEH4lwZ6qaXY8O+CGFjb1m GEeqs/H8USwukjBLsQdNg56BFiYAwHbOPsHM6EJPymfaH9GgpsNh2CTskKc3dblFlGTs Oj9omCalXdkuXqKN16UMoK7zPe2csTG8lj5jRDyJyNQv2F2sZyOJmBVxKkvbsWsAhSfM dzFQ== X-Gm-Message-State: AAQBX9dBobRpAC7Bo+MEcrfQblJa/jDsLf/BfX/un9YZL5FysZVSJV+K 1ukGGlFVQB7tYnGSAP/RK2Y= X-Google-Smtp-Source: AKy350YX8burQawQVvj0e8kKDtvhq+EucOeKpgDFXUOzjPZ8nmdMytz6DHh0nGTKQtDt5xjLGlyawA== X-Received: by 2002:a17:902:ce89:b0:1a1:f70c:c81a with SMTP id f9-20020a170902ce8900b001a1f70cc81amr23063606plg.9.1681253862885; Tue, 11 Apr 2023 15:57:42 -0700 (PDT) Received: from localhost ([2a00:79e1:abd:4a00:61b:48ed:72ab:435b]) by smtp.gmail.com with ESMTPSA id w1-20020a1709027b8100b001a664e49ebasm436209pll.304.2023.04.11.15.57.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Apr 2023 15:57:42 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Boris Brezillon , Tvrtko Ursulin , Christopher Healy , Emil Velikov , Rob Clark , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 1/7] drm: Add common fdinfo helper Date: Tue, 11 Apr 2023 15:56:06 -0700 Message-Id: <20230411225725.2032862-2-robdclark@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230411225725.2032862-1-robdclark@gmail.com> References: <20230411225725.2032862-1-robdclark@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Rob Clark Handle a bit of the boiler-plate in a single case, and make it easier to add some core tracked stats. Signed-off-by: Rob Clark Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_file.c | 39 ++++++++++++++++++++++++++++++++++++++ include/drm/drm_drv.h | 7 +++++++ include/drm/drm_file.h | 4 ++++ 3 files changed, 50 insertions(+) diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c index a51ff8cee049..37dfaa6be560 100644 --- a/drivers/gpu/drm/drm_file.c +++ b/drivers/gpu/drm/drm_file.c @@ -148,6 +148,7 @@ bool drm_dev_needs_global_mutex(struct drm_device *dev) */ struct drm_file *drm_file_alloc(struct drm_minor *minor) { + static atomic_t ident = ATOMIC_INIT(0); struct drm_device *dev = minor->dev; struct drm_file *file; int ret; @@ -156,6 +157,8 @@ struct drm_file *drm_file_alloc(struct drm_minor *minor) if (!file) return ERR_PTR(-ENOMEM); + /* Get a unique identifier for fdinfo: */ + file->client_id = atomic_inc_return(&ident) - 1; file->pid = get_pid(task_pid(current)); file->minor = minor; @@ -868,6 +871,42 @@ void drm_send_event(struct drm_device *dev, struct drm_pending_event *e) } EXPORT_SYMBOL(drm_send_event); +/** + * drm_fop_show_fdinfo - helper for drm file fops + * @seq_file: output stream + * @f: the device file instance + * + * Helper to implement fdinfo, for userspace to query usage stats, etc, of a + * process using the GPU. + */ +void drm_fop_show_fdinfo(struct seq_file *m, struct file *f) +{ + struct drm_file *file = f->private_data; + struct drm_device *dev = file->minor->dev; + struct drm_printer p = drm_seq_file_printer(m); + + /* + * ****************************************************************** + * For text output format description please see drm-usage-stats.rst! + * ****************************************************************** + */ + + drm_printf(&p, "drm-driver:\t%s\n", dev->driver->name); + drm_printf(&p, "drm-client-id:\t%u\n", file->client_id); + + if (dev_is_pci(dev->dev)) { + struct pci_dev *pdev = to_pci_dev(dev->dev); + + drm_printf(&p, "drm-pdev:\t%04x:%02x:%02x.%d\n", + pci_domain_nr(pdev->bus), pdev->bus->number, + PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn)); + } + + if (dev->driver->show_fdinfo) + dev->driver->show_fdinfo(&p, file); +} +EXPORT_SYMBOL(drm_fop_show_fdinfo); + /** * mock_drm_getfile - Create a new struct file for the drm device * @minor: drm minor to wrap (e.g. #drm_device.primary) diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h index 5b86bb7603e7..a883c6d3bcdf 100644 --- a/include/drm/drm_drv.h +++ b/include/drm/drm_drv.h @@ -401,6 +401,13 @@ struct drm_driver { struct drm_device *dev, uint32_t handle, uint64_t *offset); + /** + * @fdinfo: + * + * Print device specific fdinfo. See drm-usage-stats.rst. + */ + void (*show_fdinfo)(struct drm_printer *p, struct drm_file *f); + /** @major: driver major number */ int major; /** @minor: driver minor number */ diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h index 0d1f853092ab..dfa995b787e1 100644 --- a/include/drm/drm_file.h +++ b/include/drm/drm_file.h @@ -258,6 +258,9 @@ struct drm_file { /** @pid: Process that opened this file. */ struct pid *pid; + /** @client_id: A unique id for fdinfo */ + u32 client_id; + /** @magic: Authentication magic, see @authenticated. */ drm_magic_t magic; @@ -437,6 +440,7 @@ void drm_send_event(struct drm_device *dev, struct drm_pending_event *e); void drm_send_event_timestamp_locked(struct drm_device *dev, struct drm_pending_event *e, ktime_t timestamp); +void drm_fop_show_fdinfo(struct seq_file *m, struct file *f); struct file *mock_drm_getfile(struct drm_minor *minor, unsigned int flags); From patchwork Tue Apr 11 22:56:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 13208321 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB39CC76196 for ; Tue, 11 Apr 2023 22:57:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229583AbjDKW5x (ORCPT ); Tue, 11 Apr 2023 18:57:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229655AbjDKW5q (ORCPT ); Tue, 11 Apr 2023 18:57:46 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E91146BE; Tue, 11 Apr 2023 15:57:45 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id ik20so9280896plb.3; Tue, 11 Apr 2023 15:57:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681253864; 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=0wlvnl6FahWn1EEVl5XEqTBS0ldcLDlAbSv9n0bbBLA=; b=sSxYCJhTMTGU4c9Pr4qhDhsZfPVfOfKUG4uV1ydWafAmd0E+M5cWAblMYfH4KzE23t jKT3tVVNVyzQM6LeWIZGZhukwqNX21TvB7MC+Q1+WJvKoqSHuY2u8Ektt+FuXQgSNSw4 Qv9v4YAA8Fhpf8drpjvsGwME/RWJx0dQ1oGlztFbkZ39DsDLjz9Ewo4Z9KdGHI6m5wsT iuiscFq4uDiVT26V7kpj4jUmbmVrBvevzvprvNog39h8+7bSmYSPApFrLrnW7yvu/54x 7nEIVcFRP0U45V22III7fp7v7nlXx2a9nEQXgc1Qyyu5I36EDUCCZzMtAOV9eQGfj8fN Px1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681253864; 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=0wlvnl6FahWn1EEVl5XEqTBS0ldcLDlAbSv9n0bbBLA=; b=0PT3DVBIWh0F1EM8aeOX/OnGFTeb0svs9OIvj0EFaxYlUZvHEy8aG9GTF3XpOQ7Ctu 0k7mMn6ZyKCrkN5GkUHK+eGZyZKsajttFLVBMpH1GcW1oXwk6Sx03I5pSJeXF4GfJ/yn D6EsFPckeMKK1wN21efWm/AxOZztgiaQmFYLbjviKZZmBrCQ1WyblGc12H8ywefZTkiM Hy5gxwvQ/jFvMUwOB0hla4DGZ/h5irU7Do3WVQjQo8+B1qGye4X1XDvMP8ihv/zl2tfz hKi1RjDpcg6DGXVWlzEyAJSx5bVbGDxhZjAKoOqkWF3NmFICQBy8zEZQmxqF2L4SSfex lm9w== X-Gm-Message-State: AAQBX9chxa89rsjsRrJMvq0WzM1bmleihkj0rQStFemjX3xCs7rdZsZ2 hmzg4tjFTeLHL0WIt18wLb4= X-Google-Smtp-Source: AKy350aqH2UsVc7wl7kw/6JAvQjJ+lsRZo3f39HCLfgoMvhVUL96lEwXMeh+l46oB5pYB21Mvicm7w== X-Received: by 2002:a17:902:d4d1:b0:19b:dbf7:f9ca with SMTP id o17-20020a170902d4d100b0019bdbf7f9camr23621397plg.0.1681253864547; Tue, 11 Apr 2023 15:57:44 -0700 (PDT) Received: from localhost ([2a00:79e1:abd:4a00:61b:48ed:72ab:435b]) by smtp.gmail.com with ESMTPSA id p1-20020a1709028a8100b001a06eb43880sm10213699plo.153.2023.04.11.15.57.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Apr 2023 15:57:44 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Boris Brezillon , Tvrtko Ursulin , Christopher Healy , Emil Velikov , Rob Clark , Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , David Airlie , Daniel Vetter , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 2/7] drm/msm: Switch to fdinfo helper Date: Tue, 11 Apr 2023 15:56:07 -0700 Message-Id: <20230411225725.2032862-3-robdclark@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230411225725.2032862-1-robdclark@gmail.com> References: <20230411225725.2032862-1-robdclark@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Rob Clark Signed-off-by: Rob Clark --- drivers/gpu/drm/msm/msm_drv.c | 11 +++++------ drivers/gpu/drm/msm/msm_gpu.c | 2 -- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 5a10d28de9dd..e516a3544505 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -1043,23 +1043,21 @@ static const struct drm_ioctl_desc msm_ioctls[] = { DRM_IOCTL_DEF_DRV(MSM_SUBMITQUEUE_QUERY, msm_ioctl_submitqueue_query, DRM_RENDER_ALLOW), }; -static void msm_fop_show_fdinfo(struct seq_file *m, struct file *f) +static void msm_show_fdinfo(struct drm_printer *p, struct drm_file *file) { - struct drm_file *file = f->private_data; struct drm_device *dev = file->minor->dev; struct msm_drm_private *priv = dev->dev_private; - struct drm_printer p = drm_seq_file_printer(m); if (!priv->gpu) return; - msm_gpu_show_fdinfo(priv->gpu, file->driver_priv, &p); + msm_gpu_show_fdinfo(priv->gpu, file->driver_priv, p); } static const struct file_operations fops = { .owner = THIS_MODULE, DRM_GEM_FOPS, - .show_fdinfo = msm_fop_show_fdinfo, + .show_fdinfo = drm_fop_show_fdinfo, }; static const struct drm_driver msm_driver = { @@ -1070,7 +1068,7 @@ static const struct drm_driver msm_driver = { DRIVER_SYNCOBJ_TIMELINE | DRIVER_SYNCOBJ, .open = msm_open, - .postclose = msm_postclose, + .postclose = msm_postclose, .lastclose = drm_fb_helper_lastclose, .dumb_create = msm_gem_dumb_create, .dumb_map_offset = msm_gem_dumb_map_offset, @@ -1081,6 +1079,7 @@ static const struct drm_driver msm_driver = { #ifdef CONFIG_DEBUG_FS .debugfs_init = msm_debugfs_init, #endif + .show_fdinfo = msm_show_fdinfo, .ioctls = msm_ioctls, .num_ioctls = ARRAY_SIZE(msm_ioctls), .fops = &fops, diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c index 26ebda40be4f..c403912d13ab 100644 --- a/drivers/gpu/drm/msm/msm_gpu.c +++ b/drivers/gpu/drm/msm/msm_gpu.c @@ -151,8 +151,6 @@ int msm_gpu_pm_suspend(struct msm_gpu *gpu) void msm_gpu_show_fdinfo(struct msm_gpu *gpu, struct msm_file_private *ctx, struct drm_printer *p) { - drm_printf(p, "drm-driver:\t%s\n", gpu->dev->driver->name); - drm_printf(p, "drm-client-id:\t%u\n", ctx->seqno); drm_printf(p, "drm-engine-gpu:\t%llu ns\n", ctx->elapsed_ns); drm_printf(p, "drm-cycles-gpu:\t%llu\n", ctx->cycles); drm_printf(p, "drm-maxfreq-gpu:\t%u Hz\n", gpu->fast_rate); From patchwork Tue Apr 11 22:56:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 13208322 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50904C77B6F for ; Tue, 11 Apr 2023 22:57:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229477AbjDKW5y (ORCPT ); Tue, 11 Apr 2023 18:57:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229648AbjDKW5w (ORCPT ); Tue, 11 Apr 2023 18:57:52 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DE36449C; Tue, 11 Apr 2023 15:57:50 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id e18-20020a17090ac21200b00246952d917fso8089888pjt.4; Tue, 11 Apr 2023 15:57:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681253869; 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=IA16a8P3ifQnuFE2cU6SZqzeMpec7rd2aaRk7CHbWjo=; b=N1wV9W1CkfJg8ZW8nbO/XbncdQcQ5WGUtAM39mq0MG54NQ569pUJsbxo8xSPP82eit Aw1VXkHGLydvIe2j7Xskuta625jMiaCqT3wkVDU9Nklhk1E50eh93rQ4W+epDDOw1hCC TDYs1dg+HW2pUlvEQSCcjOSegMnOP82/h46z/2i5x8r+Ia8Gv2Obf5QLbH/v8KXbW3xM btyYK0XK+zdVkAi+aleiIramImekj7X87ikeburFiU/L2qvhqMWTQU+KqydDKsnJ3vlv kGG+jOK8ZET2J3IVZPTATZNhsfpgnWv0E4G9FBmaV3Gx7ZtDKixAi7Acr5hArBjCpqRQ QzcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681253869; 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=IA16a8P3ifQnuFE2cU6SZqzeMpec7rd2aaRk7CHbWjo=; b=vdJ9DDoNHagJF+Wxjw2uZPYomDhrhISMoEAnxaYUBbJskk7JtZ3Oz8iGrwF69yDa/i O/OqUDpcm6+PFsahiPtDIp5MlI6Rhi5gQib74/FB5KY2Kz1m9fUmTcRJbkSPkw0wmkM1 Q0SdkOampMrMjOgMyIOPMcOJi6srbiQFfeAavqqlt71Fqt8nJ8K4NwtpSXk+R8hH46AI oe2FQMoc8fQVADuu0ByqxIDgKVDr9pXpJOaBi1v7u4wYIucwag+Tw4Q5NoGQvvPCBuLa 12edYC8ZEUvyMNz5T/f5lHPSiSAmcLA2JtaTMPTnXHmxwgegVyIxsYZHUswGlsdutA6p QB0Q== X-Gm-Message-State: AAQBX9cJAopuL0w7uF/XoQ17UcuHC7AjkXDy2h2QJKqIMfjSmwVAxWMM Ajh8Nme8xXfGkU/oBjWiF4E= X-Google-Smtp-Source: AKy350bEeqU5DiwN669zYMn8njQUVxYmCFUZdbZaRVA3pKtDRjjEcnb2lSJmj4IgzOT1GoTtagoJXQ== X-Received: by 2002:a17:90b:3892:b0:246:c223:14ba with SMTP id mu18-20020a17090b389200b00246c22314bamr8589895pjb.28.1681253869342; Tue, 11 Apr 2023 15:57:49 -0700 (PDT) Received: from localhost ([2a00:79e1:abd:4a00:61b:48ed:72ab:435b]) by smtp.gmail.com with ESMTPSA id jw8-20020a170903278800b001a649347f59sm3626131plb.12.2023.04.11.15.57.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Apr 2023 15:57:49 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Boris Brezillon , Tvrtko Ursulin , Christopher Healy , Emil Velikov , Rob Clark , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , Hawking Zhang , Evan Quan , Mario Limonciello , Guchun Chen , YiPeng Chai , =?utf-8?q?Michel_D=C3=A4nzer?= , Shashank Sharma , Tvrtko Ursulin , Arunpravin Paneer Selvam , amd-gfx@lists.freedesktop.org (open list:RADEON and AMDGPU DRM DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 3/7] drm/amdgpu: Switch to fdinfo helper Date: Tue, 11 Apr 2023 15:56:08 -0700 Message-Id: <20230411225725.2032862-4-robdclark@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230411225725.2032862-1-robdclark@gmail.com> References: <20230411225725.2032862-1-robdclark@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Rob Clark Signed-off-by: Rob Clark --- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c | 16 ++++++---------- drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.h | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index f5ffca24def4..3611cfd5f076 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -2752,7 +2752,7 @@ static const struct file_operations amdgpu_driver_kms_fops = { .compat_ioctl = amdgpu_kms_compat_ioctl, #endif #ifdef CONFIG_PROC_FS - .show_fdinfo = amdgpu_show_fdinfo + .show_fdinfo = drm_fop_show_fdinfo, #endif }; @@ -2807,6 +2807,7 @@ static const struct drm_driver amdgpu_kms_driver = { .dumb_map_offset = amdgpu_mode_dumb_mmap, .fops = &amdgpu_driver_kms_fops, .release = &amdgpu_driver_release_kms, + .show_fdinfo = amdgpu_show_fdinfo, .prime_handle_to_fd = drm_gem_prime_handle_to_fd, .prime_fd_to_handle = drm_gem_prime_fd_to_handle, diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c index 99a7855ab1bc..c2fdd5e448d1 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c @@ -53,9 +53,8 @@ static const char *amdgpu_ip_name[AMDGPU_HW_IP_NUM] = { [AMDGPU_HW_IP_VCN_JPEG] = "jpeg", }; -void amdgpu_show_fdinfo(struct seq_file *m, struct file *f) +void amdgpu_show_fdinfo(struct drm_printer *p, struct drm_file *file) { - struct drm_file *file = f->private_data; struct amdgpu_device *adev = drm_to_adev(file->minor->dev); struct amdgpu_fpriv *fpriv = file->driver_priv; struct amdgpu_vm *vm = &fpriv->vm; @@ -86,18 +85,15 @@ void amdgpu_show_fdinfo(struct seq_file *m, struct file *f) * ****************************************************************** */ - seq_printf(m, "pasid:\t%u\n", fpriv->vm.pasid); - seq_printf(m, "drm-driver:\t%s\n", file->minor->dev->driver->name); - seq_printf(m, "drm-pdev:\t%04x:%02x:%02x.%d\n", domain, bus, dev, fn); - seq_printf(m, "drm-client-id:\t%Lu\n", vm->immediate.fence_context); - seq_printf(m, "drm-memory-vram:\t%llu KiB\n", vram_mem/1024UL); - seq_printf(m, "drm-memory-gtt: \t%llu KiB\n", gtt_mem/1024UL); - seq_printf(m, "drm-memory-cpu: \t%llu KiB\n", cpu_mem/1024UL); + drm_printf(p, "pasid:\t%u\n", fpriv->vm.pasid); + drm_printf(p, "drm-memory-vram:\t%llu KiB\n", vram_mem/1024UL); + drm_printf(p, "drm-memory-gtt: \t%llu KiB\n", gtt_mem/1024UL); + drm_printf(p, "drm-memory-cpu: \t%llu KiB\n", cpu_mem/1024UL); for (hw_ip = 0; hw_ip < AMDGPU_HW_IP_NUM; ++hw_ip) { if (!usage[hw_ip]) continue; - seq_printf(m, "drm-engine-%s:\t%Ld ns\n", amdgpu_ip_name[hw_ip], + drm_printf(p, "drm-engine-%s:\t%Ld ns\n", amdgpu_ip_name[hw_ip], ktime_to_ns(usage[hw_ip])); } } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.h index e86834bfea1d..0398f5a159ef 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.h @@ -37,6 +37,6 @@ #include "amdgpu_ids.h" uint32_t amdgpu_get_ip_count(struct amdgpu_device *adev, int id); -void amdgpu_show_fdinfo(struct seq_file *m, struct file *f); +void amdgpu_show_fdinfo(struct drm_printer *p, struct drm_file *file); #endif From patchwork Tue Apr 11 22:56:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 13208323 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 709BCC7619A for ; Tue, 11 Apr 2023 22:58:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229546AbjDKW6J (ORCPT ); Tue, 11 Apr 2023 18:58:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbjDKW57 (ORCPT ); Tue, 11 Apr 2023 18:57:59 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECA494C2D; Tue, 11 Apr 2023 15:57:56 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id d22-20020a17090a111600b0023d1b009f52so12614377pja.2; Tue, 11 Apr 2023 15:57:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681253876; 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=ibZGCHCGgDbXF+wN6k9ulDgB+4n/u9g3t3I8e8YECX8=; b=SOoWEeih3vbn6+Nih46qhJtfcGTn0gX3CVj2lu3IxrRDEb9JISqVrewL9cxTj9oAWD XwE7QeceHOgop81oBrMIy7NNoTu1fPvKVXuHsKCibJyfP8B9yzipusPCOg7SB+W5NO5W XobaMsolMU175cDGGveMQnAPNacdrNt0L0AoVVryCvUPiZEcqgzh948ejKp6tqZecQb3 JrX/Icj0sz078GEwUkzouk73+cL/kZscuAvgZB71HQ2pcmfvBQadkNIabMiRJ+mU2zwZ qM0IJPbacmQ3IfxclNAn6MWQZzp2HG60LpTV6JgoXshy8qVB1eU19ufJUNYH2eIDRoeF QS9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681253876; 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=ibZGCHCGgDbXF+wN6k9ulDgB+4n/u9g3t3I8e8YECX8=; b=E8gyk3LHTZFwpaxms6xL2thmcnvs6lMdFNBULgZScRtjuLSOf2plqmjzvUpBLdAHbc wdOCeMGo66Bv7RXvjPiOxNdW7IuWGhMjgMGyE87QljmRop26zPSGU2Ri8DD5damcAG1b iyAu+2jr2zLxZTISXm53eXR2lRbx7EAfoNSnCS5umRXpW9ZWsbBlDie9f+MibjTNRe5e TQ9Oiil9Nl9UeoVfjgtKcqRqEFYQ0HewXPBmHAHlxYXQoQMOVublfVFP2B4ZfwhaLtBV XmtvuHr49MUg1wXwQkMXxJBD60n10+wEdviYJdr0T1FghoF3dhI4hidi5FQlws+9U2jC mTYw== X-Gm-Message-State: AAQBX9dEi/Y13dR7TMah8/cgwqtpYqFV4EFgrfZtuA5b0MsJd9eIpTti dgbS2dU6rfq2LHA0y8W2b7E= X-Google-Smtp-Source: AKy350b0zKnyM6u0Mr5B0MMULX87J0zKuKdgmuj+ocn/jghbUy7A4qoIP9IUAkNdhEi+ZZsgZ34Z9w== X-Received: by 2002:a17:902:d08c:b0:1a6:5493:a3e8 with SMTP id v12-20020a170902d08c00b001a65493a3e8mr4197694plv.41.1681253876147; Tue, 11 Apr 2023 15:57:56 -0700 (PDT) Received: from localhost ([2a00:79e1:abd:4a00:61b:48ed:72ab:435b]) by smtp.gmail.com with ESMTPSA id e12-20020a65478c000000b00517b7e3ef43sm6087613pgs.41.2023.04.11.15.57.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Apr 2023 15:57:55 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Boris Brezillon , Tvrtko Ursulin , Christopher Healy , Emil Velikov , Rob Clark , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , David Airlie , Daniel Vetter , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 4/7] drm/i915: Switch to fdinfo helper Date: Tue, 11 Apr 2023 15:56:09 -0700 Message-Id: <20230411225725.2032862-5-robdclark@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230411225725.2032862-1-robdclark@gmail.com> References: <20230411225725.2032862-1-robdclark@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Rob Clark Signed-off-by: Rob Clark --- drivers/gpu/drm/i915/i915_driver.c | 3 ++- drivers/gpu/drm/i915/i915_drm_client.c | 18 +++++------------- drivers/gpu/drm/i915/i915_drm_client.h | 2 +- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c index db7a86def7e2..37eacaa3064b 100644 --- a/drivers/gpu/drm/i915/i915_driver.c +++ b/drivers/gpu/drm/i915/i915_driver.c @@ -1696,7 +1696,7 @@ static const struct file_operations i915_driver_fops = { .compat_ioctl = i915_ioc32_compat_ioctl, .llseek = noop_llseek, #ifdef CONFIG_PROC_FS - .show_fdinfo = i915_drm_client_fdinfo, + .show_fdinfo = drm_fop_show_fdinfo, #endif }; @@ -1796,6 +1796,7 @@ static const struct drm_driver i915_drm_driver = { .open = i915_driver_open, .lastclose = i915_driver_lastclose, .postclose = i915_driver_postclose, + .show_fdinfo = i915_drm_client_fdinfo, .prime_handle_to_fd = drm_gem_prime_handle_to_fd, .prime_fd_to_handle = drm_gem_prime_fd_to_handle, diff --git a/drivers/gpu/drm/i915/i915_drm_client.c b/drivers/gpu/drm/i915/i915_drm_client.c index b09d1d386574..4a77e5e47f79 100644 --- a/drivers/gpu/drm/i915/i915_drm_client.c +++ b/drivers/gpu/drm/i915/i915_drm_client.c @@ -101,7 +101,7 @@ static u64 busy_add(struct i915_gem_context *ctx, unsigned int class) } static void -show_client_class(struct seq_file *m, +show_client_class(struct drm_printer *p, struct i915_drm_client *client, unsigned int class) { @@ -117,22 +117,20 @@ show_client_class(struct seq_file *m, rcu_read_unlock(); if (capacity) - seq_printf(m, "drm-engine-%s:\t%llu ns\n", + drm_printf(p, "drm-engine-%s:\t%llu ns\n", uabi_class_names[class], total); if (capacity > 1) - seq_printf(m, "drm-engine-capacity-%s:\t%u\n", + drm_printf(p, "drm-engine-capacity-%s:\t%u\n", uabi_class_names[class], capacity); } -void i915_drm_client_fdinfo(struct seq_file *m, struct file *f) +void i915_drm_client_fdinfo(struct drm_printer *p, struct drm_file *file) { - struct drm_file *file = f->private_data; struct drm_i915_file_private *file_priv = file->driver_priv; struct drm_i915_private *i915 = file_priv->dev_priv; struct i915_drm_client *client = file_priv->client; - struct pci_dev *pdev = to_pci_dev(i915->drm.dev); unsigned int i; /* @@ -141,12 +139,6 @@ void i915_drm_client_fdinfo(struct seq_file *m, struct file *f) * ****************************************************************** */ - seq_printf(m, "drm-driver:\t%s\n", i915->drm.driver->name); - seq_printf(m, "drm-pdev:\t%04x:%02x:%02x.%d\n", - pci_domain_nr(pdev->bus), pdev->bus->number, - PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn)); - seq_printf(m, "drm-client-id:\t%u\n", client->id); - /* * Temporarily skip showing client engine information with GuC submission till * fetching engine busyness is implemented in the GuC submission backend @@ -155,6 +147,6 @@ void i915_drm_client_fdinfo(struct seq_file *m, struct file *f) return; for (i = 0; i < ARRAY_SIZE(uabi_class_names); i++) - show_client_class(m, client, i); + show_client_class(p, client, i); } #endif diff --git a/drivers/gpu/drm/i915/i915_drm_client.h b/drivers/gpu/drm/i915/i915_drm_client.h index 69496af996d9..ef85fef45de5 100644 --- a/drivers/gpu/drm/i915/i915_drm_client.h +++ b/drivers/gpu/drm/i915/i915_drm_client.h @@ -60,7 +60,7 @@ static inline void i915_drm_client_put(struct i915_drm_client *client) struct i915_drm_client *i915_drm_client_add(struct i915_drm_clients *clients); #ifdef CONFIG_PROC_FS -void i915_drm_client_fdinfo(struct seq_file *m, struct file *f); +void i915_drm_client_fdinfo(struct drm_printer *p, struct drm_file *file); #endif void i915_drm_clients_fini(struct i915_drm_clients *clients); From patchwork Tue Apr 11 22:56:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 13208324 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 528CEC7619A for ; Tue, 11 Apr 2023 22:58:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229638AbjDKW6M (ORCPT ); Tue, 11 Apr 2023 18:58:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229648AbjDKW6J (ORCPT ); Tue, 11 Apr 2023 18:58:09 -0400 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 614A15275; Tue, 11 Apr 2023 15:57:58 -0700 (PDT) Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-634b28df952so849561b3a.2; Tue, 11 Apr 2023 15:57:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681253878; 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=61YxJCuswj9xA83srgCQq+LpDU/NdlnFqvUJ2L68W28=; b=fzBJIokAts+RXDDaUaHyBMUmEWyCEpqt/q5M5m29gvFIePVvslMTBmgeaXIIOR2Ac0 IKD4FDATQxWMrcXusMnMszqhH+ZFJUzNugl40qN33DRbhpmqVksqUaVRyb3TKcBlO3ob vrFgnK/cyair5Bpw1M73oVX/HdIR7gu5m1gkXUM+LiCHGrgYoRPJtmhIVyBoEJFdH50m D/b1pQ5vvmQELw83iKDaFVd4MtyXH2KRsKoLKutQ+Sjsq7U2J3b1JT7ekBAiDG927SoX y9LdBEnPpvAfHEYj+KBiACoG7fYWcLUqxCYeqUa/lu67QCaTVBR+SBy2ukeZ7NGv9x9f pwEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681253878; 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=61YxJCuswj9xA83srgCQq+LpDU/NdlnFqvUJ2L68W28=; b=XkBIpOat5+Vi3fXUgBs1RrHgTPWwhhyz5xAmJDB08E0dH+9srYj7JJKySnufNxouRw w/yDyABj36QqedGu1+CzHfboOB8OKQFfd/gX7uFzQXfzbaRPjZIHyidtuhHgZPAQrCFy DuoFe5nXInQpOm3rS+fX6vFmik7yKxykEEBz1yFqWNFYf0BttqnHgJbonPwIQdFfI0ko HmuDVRMjMxzi9xLAhwmyZ/HzsTWjnUuUjUYQuvw4DsiqsLo04tQHF9KhwnFzzjrwdtnQ 3hvosmAEXQ1hJJxZxtiM8oUTwNbdBQSOw8A7+of3Oyaj3R0U6I4OBZb8h/T+fjsxFH9P 3iYA== X-Gm-Message-State: AAQBX9fcY36fdAjeIoeMlgOmQ21wVJ9ZzJ6AeU0BEUwIDdF41CGwdAsi TipYSpnx1OpYZMY8YJkPrCM= X-Google-Smtp-Source: AKy350arI+CyPmWu3SVA1SipRhUdpjuMh/HgAyHw47YA/h5KMXGlVoWtJo9Ttap9MbvO0vk1YV7H6g== X-Received: by 2002:a62:3815:0:b0:63a:b1ab:79a5 with SMTP id f21-20020a623815000000b0063ab1ab79a5mr5543199pfa.18.1681253877854; Tue, 11 Apr 2023 15:57:57 -0700 (PDT) Received: from localhost ([2a00:79e1:abd:4a00:61b:48ed:72ab:435b]) by smtp.gmail.com with ESMTPSA id o12-20020a056a001bcc00b005d866d184b5sm10225457pfw.46.2023.04.11.15.57.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Apr 2023 15:57:57 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Boris Brezillon , Tvrtko Ursulin , Christopher Healy , Emil Velikov , Rob Clark , Lucas Stach , Russell King , Christian Gmeiner , David Airlie , Daniel Vetter , etnaviv@lists.freedesktop.org (moderated list:DRM DRIVERS FOR VIVANTE GPU IP), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 5/7] drm/etnaviv: Switch to fdinfo helper Date: Tue, 11 Apr 2023 15:56:10 -0700 Message-Id: <20230411225725.2032862-6-robdclark@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230411225725.2032862-1-robdclark@gmail.com> References: <20230411225725.2032862-1-robdclark@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Rob Clark Signed-off-by: Rob Clark --- drivers/gpu/drm/etnaviv/etnaviv_drv.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c index 44ca803237a5..170000d6af94 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c @@ -476,9 +476,8 @@ static const struct drm_ioctl_desc etnaviv_ioctls[] = { ETNA_IOCTL(PM_QUERY_SIG, pm_query_sig, DRM_RENDER_ALLOW), }; -static void etnaviv_fop_show_fdinfo(struct seq_file *m, struct file *f) +static void etnaviv_fop_show_fdinfo(struct drm_printer *p, struct drm_file *file) { - struct drm_file *file = f->private_data; struct drm_device *dev = file->minor->dev; struct etnaviv_drm_private *priv = dev->dev_private; struct etnaviv_file_private *ctx = file->driver_priv; @@ -487,8 +486,6 @@ static void etnaviv_fop_show_fdinfo(struct seq_file *m, struct file *f) * For a description of the text output format used here, see * Documentation/gpu/drm-usage-stats.rst. */ - seq_printf(m, "drm-driver:\t%s\n", dev->driver->name); - seq_printf(m, "drm-client-id:\t%u\n", ctx->id); for (int i = 0; i < ETNA_MAX_PIPES; i++) { struct etnaviv_gpu *gpu = priv->gpu[i]; @@ -507,7 +504,7 @@ static void etnaviv_fop_show_fdinfo(struct seq_file *m, struct file *f) cur = snprintf(engine + cur, sizeof(engine) - cur, "%sNN", cur ? "/" : ""); - seq_printf(m, "drm-engine-%s:\t%llu ns\n", engine, + drm_printf(p, "drm-engine-%s:\t%llu ns\n", engine, ctx->sched_entity[i].elapsed_ns); } } @@ -515,7 +512,7 @@ static void etnaviv_fop_show_fdinfo(struct seq_file *m, struct file *f) static const struct file_operations fops = { .owner = THIS_MODULE, DRM_GEM_FOPS, - .show_fdinfo = etnaviv_fop_show_fdinfo, + .show_fdinfo = drm_fop_show_fdinfo, }; static const struct drm_driver etnaviv_drm_driver = { @@ -529,6 +526,7 @@ static const struct drm_driver etnaviv_drm_driver = { #ifdef CONFIG_DEBUG_FS .debugfs_init = etnaviv_debugfs_init, #endif + .show_fdinfo = etnaviv_fop_show_fdinfo, .ioctls = etnaviv_ioctls, .num_ioctls = DRM_ETNAVIV_NUM_IOCTLS, .fops = &fops, From patchwork Tue Apr 11 22:56:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 13208325 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9400EC76196 for ; Tue, 11 Apr 2023 22:58:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229710AbjDKW6Z (ORCPT ); Tue, 11 Apr 2023 18:58:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229742AbjDKW6O (ORCPT ); Tue, 11 Apr 2023 18:58:14 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 217AE4231; Tue, 11 Apr 2023 15:58:07 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id i8so424985plt.10; Tue, 11 Apr 2023 15:58:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681253880; 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=x+Y9rFqb6JFNxJRIVkTus3EfCZpjMTDt8LZNCNaQpSk=; b=Gnjl7xlKzgOD/FJhGOxJSatQoxNL92VZh1T010f+KMpLHbiNZMjI7OWmHq276109UH 4K8CKrZ4DPT8+9EnkvzjFKLuqWTJR53DQkzE3hdWTh1SlyJmD7d38SELk6BIrnX1brXA T9czLy89UglFKjNxrn0eVWxN1wjrlCFqELBa0XskKNZzlgC+ogr2fv0eq4XVr12hhuUi B9HQrOatX0K1+5FJRTnv3bQbV/yZfGXLpzAUGKOv60Aye+TC0bNkXJiC7H3U6A/2bS0q XQ4IL8tKObllfWhuXE5QlVCU0yd0nMtqs5ZpgdS4dtO6yKpHQvx90a/rzYX85bTvam7Q QJKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681253880; 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=x+Y9rFqb6JFNxJRIVkTus3EfCZpjMTDt8LZNCNaQpSk=; b=QSH5laOz8AE1m39zgeUSY+yoqzKJNtv/U4SgYIxvY6S4+oC0kx++VavoOZ8rjYCGuJ 4BzhqvIsjxSpiFF9kacgsepQm86fGtwcSE4kB6wIIpavFNSjOjfQAReQDbxoUXzzqcyG IJ0VHHxPtukZO91a/cYfJ2IIGcWn0zg+hY4FZGfWyZrdmroWxgo30tSyQ9ptw0DLf6Tl c8Q3LRzBEbyFJqFq9I3MVDHhq+owSmiiw9Egpkmll+vVTAFaV25Q7tIEwD/IsJr15iBD 9U4rNOmPdhwOT+T0oUgEP7aPkpJ0wpXL889f2wJhcvxTehNuL8zKga722gZSbhhiOP61 CD8Q== X-Gm-Message-State: AAQBX9fHUT4HdpRALJ6z+tawjDXTRgu1rjZDr/YFbqBqXFZ87WtQzTA8 aQvTjvQrLAj65GONmnpDH5c= X-Google-Smtp-Source: AKy350ZV8ggQN6BVMgCuSSsJXeTi9lsYz/FHoIFgXYmD7SwhxOmNXUaQ+6yjVlQd6SYy9rt71Gz2yQ== X-Received: by 2002:a17:902:e38b:b0:1a6:4689:fc79 with SMTP id g11-20020a170902e38b00b001a64689fc79mr5681467ple.20.1681253879710; Tue, 11 Apr 2023 15:57:59 -0700 (PDT) Received: from localhost ([2a00:79e1:abd:4a00:61b:48ed:72ab:435b]) by smtp.gmail.com with ESMTPSA id l2-20020a170902d34200b001a1abc93eabsm10220811plk.226.2023.04.11.15.57.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Apr 2023 15:57:59 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Boris Brezillon , Tvrtko Ursulin , Christopher Healy , Emil Velikov , Rob Clark , David Airlie , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Jonathan Corbet , linux-doc@vger.kernel.org (open list:DOCUMENTATION), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 6/7] drm: Add fdinfo memory stats Date: Tue, 11 Apr 2023 15:56:11 -0700 Message-Id: <20230411225725.2032862-7-robdclark@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230411225725.2032862-1-robdclark@gmail.com> References: <20230411225725.2032862-1-robdclark@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Rob Clark Add support to dump GEM stats to fdinfo. v2: Fix typos, change size units to match docs, use div_u64 v3: Do it in core Signed-off-by: Rob Clark Reviewed-by: Emil Velikov Reviewed-by: Daniel Vetter --- Documentation/gpu/drm-usage-stats.rst | 21 ++++++++ drivers/gpu/drm/drm_file.c | 76 +++++++++++++++++++++++++++ include/drm/drm_file.h | 1 + include/drm/drm_gem.h | 19 +++++++ 4 files changed, 117 insertions(+) diff --git a/Documentation/gpu/drm-usage-stats.rst b/Documentation/gpu/drm-usage-stats.rst index b46327356e80..b5e7802532ed 100644 --- a/Documentation/gpu/drm-usage-stats.rst +++ b/Documentation/gpu/drm-usage-stats.rst @@ -105,6 +105,27 @@ object belong to this client, in the respective memory region. Default unit shall be bytes with optional unit specifiers of 'KiB' or 'MiB' indicating kibi- or mebi-bytes. +- drm-shared-memory: [KiB|MiB] + +The total size of buffers that are shared with another file (ie. have more +than a single handle). + +- drm-private-memory: [KiB|MiB] + +The total size of buffers that are not shared with another file. + +- drm-resident-memory: [KiB|MiB] + +The total size of buffers that are resident in system memory. + +- drm-purgeable-memory: [KiB|MiB] + +The total size of buffers that are purgeable. + +- drm-active-memory: [KiB|MiB] + +The total size of buffers that are active on one or more rings. + - drm-cycles- Engine identifier string must be the same as the one specified in the diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c index 37dfaa6be560..46fdd843bb3a 100644 --- a/drivers/gpu/drm/drm_file.c +++ b/drivers/gpu/drm/drm_file.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include "drm_crtc_internal.h" @@ -871,6 +872,79 @@ void drm_send_event(struct drm_device *dev, struct drm_pending_event *e) } EXPORT_SYMBOL(drm_send_event); +static void print_size(struct drm_printer *p, const char *stat, size_t sz) +{ + const char *units[] = {"", " KiB", " MiB"}; + unsigned u; + + for (u = 0; u < ARRAY_SIZE(units) - 1; u++) { + if (sz < SZ_1K) + break; + sz = div_u64(sz, SZ_1K); + } + + drm_printf(p, "%s:\t%zu%s\n", stat, sz, units[u]); +} + +static void print_memory_stats(struct drm_printer *p, struct drm_file *file) +{ + struct drm_gem_object *obj; + struct { + size_t shared; + size_t private; + size_t resident; + size_t purgeable; + size_t active; + } size = {0}; + bool has_status = false; + int id; + + spin_lock(&file->table_lock); + idr_for_each_entry (&file->object_idr, obj, id) { + enum drm_gem_object_status s = 0; + + if (obj->funcs && obj->funcs->status) { + s = obj->funcs->status(obj); + has_status = true; + } + + if (obj->handle_count > 1) { + size.shared += obj->size; + } else { + size.private += obj->size; + } + + if (s & DRM_GEM_OBJECT_RESIDENT) { + size.resident += obj->size; + } else { + /* If already purged or not yet backed by pages, don't + * count it as purgeable: + */ + s &= ~DRM_GEM_OBJECT_PURGEABLE; + } + + if (!dma_resv_test_signaled(obj->resv, dma_resv_usage_rw(true))) { + size.active += obj->size; + + /* If still active, don't count as purgeable: */ + s &= ~DRM_GEM_OBJECT_PURGEABLE; + } + + if (s & DRM_GEM_OBJECT_PURGEABLE) + size.purgeable += obj->size; + } + spin_unlock(&file->table_lock); + + print_size(p, "drm-shared-memory", size.shared); + print_size(p, "drm-private-memory", size.private); + print_size(p, "drm-active-memory", size.active); + + if (has_status) { + print_size(p, "drm-resident-memory", size.resident); + print_size(p, "drm-purgeable-memory", size.purgeable); + } +} + /** * drm_fop_show_fdinfo - helper for drm file fops * @seq_file: output stream @@ -904,6 +978,8 @@ void drm_fop_show_fdinfo(struct seq_file *m, struct file *f) if (dev->driver->show_fdinfo) dev->driver->show_fdinfo(&p, file); + + print_memory_stats(&p, file); } EXPORT_SYMBOL(drm_fop_show_fdinfo); diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h index dfa995b787e1..e5b40084538f 100644 --- a/include/drm/drm_file.h +++ b/include/drm/drm_file.h @@ -41,6 +41,7 @@ struct dma_fence; struct drm_file; struct drm_device; +struct drm_printer; struct device; struct file; diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h index 189fd618ca65..213917bb6b11 100644 --- a/include/drm/drm_gem.h +++ b/include/drm/drm_gem.h @@ -42,6 +42,14 @@ struct iosys_map; struct drm_gem_object; +/** + * enum drm_gem_object_status - bitmask of object state for fdinfo reporting + */ +enum drm_gem_object_status { + DRM_GEM_OBJECT_RESIDENT = BIT(0), + DRM_GEM_OBJECT_PURGEABLE = BIT(1), +}; + /** * struct drm_gem_object_funcs - GEM object functions */ @@ -174,6 +182,17 @@ struct drm_gem_object_funcs { */ int (*evict)(struct drm_gem_object *obj); + /** + * @status: + * + * The optional status callback can return additional object state + * which determines which stats the object is counted against. The + * callback is called under table_lock. Racing against object status + * change is "harmless", and the callback can expect to not race + * against object destruction. + */ + enum drm_gem_object_status (*status)(struct drm_gem_object *obj); + /** * @vm_ops: * From patchwork Tue Apr 11 22:56:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 13208326 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 996AFC77B6F for ; Tue, 11 Apr 2023 22:58:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229486AbjDKW60 (ORCPT ); Tue, 11 Apr 2023 18:58:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229745AbjDKW6O (ORCPT ); Tue, 11 Apr 2023 18:58:14 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B1322D63; Tue, 11 Apr 2023 15:58:08 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id q2so14282340pll.7; Tue, 11 Apr 2023 15:58:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681253881; 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=ayU9yxyS63GOBM6CjiiY8bjBwmD9ZnU8dUfgj0+el7c=; b=VHMVks6NvFNA2/mOKdow01yeN+D6kqEpVibmOQv1tGWfHDT2poOsnsKr7eTZ7pHDvD DJY9EFVJaynf/OAjF0rD5h8BRBfY/Nw/R0RnOGYwnDSaz/5zPj5ZEl+RUp8zC7F/fEhs x0H7SQF0GF6TFrorb4/00O1gYYJ8B4QdsyIE86JVC6N4ywG1DB2S9J1uP22usScfEJWf 1dNBvgS2a9bRLfmrPzRWj1BWlbBEs13UEMUl1WBPeS69+JumPmo5V6CEg2Qnaj4jlk+n Y0Phzi7RUHipcV/fBRkNwMFXd7mbOCJBMgHT1G4kHzuXt4KaVnrvFYoi7YV7MCNfwHc8 hZDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681253881; 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=ayU9yxyS63GOBM6CjiiY8bjBwmD9ZnU8dUfgj0+el7c=; b=rq2cTS6GT3X9uGNSzoxUTbQYx9RmQ1apTlo1JEXNNKTwjMqX8fP17ZM0OwmetoYt12 h9Gx1z3n4R9xLTkLeQ5nMUqdpYTee6gjS04DAaCNKHRr6tOH1wb7S5Rd7B6tvSMJYSpS 2Z8i6zMbQq8KYeABgfNJjfu75F+sncPV7efZyIsgSoGAawsAcA5X7g7zf3z7u0HTrJIS rIISNhpMRtput+p8Id0/Ine41KYxkBGn39ubHfjz6FG/L1JZuMjODFpz1G+MFtiF/o1g Vl7MDIioqIDfdlRtMWOpkEWXEGRKcwZNiSb5+/vOtPR7Ksv+5CuDGPMvSvh3ZugL6HfY moHQ== X-Gm-Message-State: AAQBX9c0oBWDZCtPAntrid9eZP//KyFR0ju8utc4Pmxnqnk59Lo5jceH NtuFtDNOPFopSxJteDXXedo= X-Google-Smtp-Source: AKy350afowYNd7r6IlQY5UFSM5Gy2/2tZFNE2WZ/1NW240MZr8PnH0GSNz7NIR7TH3mphaC5yTZvWQ== X-Received: by 2002:a17:903:11c9:b0:1a5:a1e:6f9e with SMTP id q9-20020a17090311c900b001a50a1e6f9emr142303plh.15.1681253881277; Tue, 11 Apr 2023 15:58:01 -0700 (PDT) Received: from localhost ([2a00:79e1:abd:4a00:61b:48ed:72ab:435b]) by smtp.gmail.com with ESMTPSA id a11-20020a170902900b00b00196807b5189sm10087161plp.292.2023.04.11.15.58.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Apr 2023 15:58:00 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Boris Brezillon , Tvrtko Ursulin , Christopher Healy , Emil Velikov , Rob Clark , Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , David Airlie , Daniel Vetter , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 7/7] drm/msm: Add memory stats to fdinfo Date: Tue, 11 Apr 2023 15:56:12 -0700 Message-Id: <20230411225725.2032862-8-robdclark@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230411225725.2032862-1-robdclark@gmail.com> References: <20230411225725.2032862-1-robdclark@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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_gem.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c index db6c4e281d75..c32264234ea1 100644 --- a/drivers/gpu/drm/msm/msm_gem.c +++ b/drivers/gpu/drm/msm/msm_gem.c @@ -1096,6 +1096,20 @@ int msm_gem_new_handle(struct drm_device *dev, struct drm_file *file, 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, @@ -1110,6 +1124,7 @@ static const struct drm_gem_object_funcs msm_gem_object_funcs = { .vmap = msm_gem_prime_vmap, .vunmap = msm_gem_prime_vunmap, .mmap = msm_gem_object_mmap, + .status = msm_gem_status, .vm_ops = &vm_ops, };