From patchwork Tue Jun 20 00:42:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 13285100 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 39B61C001DF for ; Tue, 20 Jun 2023 00:43:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6DD9010E251; Tue, 20 Jun 2023 00:43:46 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5791410E257 for ; Tue, 20 Jun 2023 00:43:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687221819; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a7jCgjA/GeF+vfePBjhGpS1KJtr0QbtMbF11c3DSw0c=; b=GdgzvotwJ9no5dxVYGceLB/USY/0nZnPozc6XHwDHc7FglgtJrEAwj1fScSMhRUSNTBima 9xVvsi9H8u9AVKBuazntdnGwXpaiap9GnxfMQBBMZcPcLZBd9JMTIiD0Tk75sMAh6zm+4E VcGdp4JevKorw64NrmeVnQ1rrdZkwf8= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-498-ns9KLR3VNXa9_SW2fEFZ8w-1; Mon, 19 Jun 2023 20:43:36 -0400 X-MC-Unique: ns9KLR3VNXa9_SW2fEFZ8w-1 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-51bca893729so76999a12.1 for ; Mon, 19 Jun 2023 17:43:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687221815; x=1689813815; 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=a7jCgjA/GeF+vfePBjhGpS1KJtr0QbtMbF11c3DSw0c=; b=C+hIKn7yH2zk1NPw8JwVIyWOxz82s7B3vc3NEBdLOfa+Gm8CWOJ2ACOujqRQkxlvWj pdsZrbwLrF4gZ+BezZfV1kofKLT1LDrP52nhF3x7KteBdqE9xSJ3Ysv/l8VMAVGV1iOb u+GREVCUKRl9FBVJz4G4abaUIa2es4NXvWvDnYntY8FnVLIuF0tiHuF9iV0VBCtGozGa U73LwgbRDXOWjthCJyZb5HUtMqyzkhvpzvHTVlzhnIOsvcWzg1XJmW6R2Vv9dstOMUsk nz1OwXVkSb1qiLth26ydfaD3kpWX6cEB78KOmOX+3hgsjglMK3s2VMcL6PDG4d1KyRrL 1MAA== X-Gm-Message-State: AC+VfDwuSCNNQMovJ20av0V+IrHCMgvXjtK1MRsGjRke0RY60oJ4MQLe 3CUfd2EhhrK6V0ksbGmu11aEFr3JZ+YxWMBUzT3gece9OiRDfZK8+FkD687fhZCrcEs4V7W57n2 v/6PfGYIZHFB5PQPKGEFZRzuw3ToG X-Received: by 2002:a17:907:16a2:b0:977:4b68:bf2 with SMTP id hc34-20020a17090716a200b009774b680bf2mr9258861ejc.54.1687221815358; Mon, 19 Jun 2023 17:43:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5q+6yQrxXHN5sb4rpMGvKSpAc2GEIwMGMC//JzmRysYg1+0tvGxqivxz5K0CNgMJjmvWb+Bw== X-Received: by 2002:a17:907:16a2:b0:977:4b68:bf2 with SMTP id hc34-20020a17090716a200b009774b680bf2mr9258842ejc.54.1687221815070; Mon, 19 Jun 2023 17:43:35 -0700 (PDT) Received: from cassiopeiae.. ([2a02:810d:4b3f:de9c:642:1aff:fe31:a19f]) by smtp.gmail.com with ESMTPSA id bk6-20020a170906b0c600b0098748422178sm393480ejb.56.2023.06.19.17.43.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 17:43:34 -0700 (PDT) From: Danilo Krummrich To: airlied@gmail.com, daniel@ffwll.ch, tzimmermann@suse.de, mripard@kernel.org, corbet@lwn.net, christian.koenig@amd.com, bskeggs@redhat.com, Liam.Howlett@oracle.com, matthew.brost@intel.com, boris.brezillon@collabora.com, alexdeucher@gmail.com, ogabbay@kernel.org, bagasdotme@gmail.com, willy@infradead.org, jason@jlekstrand.net Subject: [PATCH drm-next v5 14/14] drm/nouveau: debugfs: implement DRM GPU VA debugfs Date: Tue, 20 Jun 2023 02:42:17 +0200 Message-Id: <20230620004217.4700-15-dakr@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230620004217.4700-1-dakr@redhat.com> References: <20230620004217.4700-1-dakr@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-doc@vger.kernel.org, nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mm@kvack.org, Danilo Krummrich Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Provide the driver indirection iterating over all DRM GPU VA spaces to enable the common 'gpuvas' debugfs file for dumping DRM GPU VA spaces. Signed-off-by: Danilo Krummrich --- drivers/gpu/drm/nouveau/nouveau_debugfs.c | 39 +++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/gpu/drm/nouveau/nouveau_debugfs.c b/drivers/gpu/drm/nouveau/nouveau_debugfs.c index 99d022a91afc..053f703f2f68 100644 --- a/drivers/gpu/drm/nouveau/nouveau_debugfs.c +++ b/drivers/gpu/drm/nouveau/nouveau_debugfs.c @@ -203,6 +203,44 @@ nouveau_debugfs_pstate_open(struct inode *inode, struct file *file) return single_open(file, nouveau_debugfs_pstate_get, inode->i_private); } +static void +nouveau_debugfs_gpuva_regions(struct seq_file *m, struct nouveau_uvmm *uvmm) +{ + MA_STATE(mas, &uvmm->region_mt, 0, 0); + struct nouveau_uvma_region *reg; + + seq_puts (m, " VA regions | start | range | end \n"); + seq_puts (m, "----------------------------------------------------------------------------\n"); + mas_for_each(&mas, reg, ULONG_MAX) + seq_printf(m, " | 0x%016llx | 0x%016llx | 0x%016llx\n", + reg->va.addr, reg->va.range, reg->va.addr + reg->va.range); +} + +static int +nouveau_debugfs_gpuva(struct seq_file *m, void *data) +{ + struct drm_info_node *node = (struct drm_info_node *) m->private; + struct nouveau_drm *drm = nouveau_drm(node->minor->dev); + struct nouveau_cli *cli; + + mutex_lock(&drm->clients_lock); + list_for_each_entry(cli, &drm->clients, head) { + struct nouveau_uvmm *uvmm = nouveau_cli_uvmm(cli); + + if (!uvmm) + continue; + + nouveau_uvmm_lock(uvmm); + drm_debugfs_gpuva_info(m, &uvmm->umgr); + seq_puts(m, "\n"); + nouveau_debugfs_gpuva_regions(m, uvmm); + nouveau_uvmm_unlock(uvmm); + } + mutex_unlock(&drm->clients_lock); + + return 0; +} + static const struct file_operations nouveau_pstate_fops = { .owner = THIS_MODULE, .open = nouveau_debugfs_pstate_open, @@ -214,6 +252,7 @@ static const struct file_operations nouveau_pstate_fops = { static struct drm_info_list nouveau_debugfs_list[] = { { "vbios.rom", nouveau_debugfs_vbios_image, 0, NULL }, { "strap_peek", nouveau_debugfs_strap_peek, 0, NULL }, + DRM_DEBUGFS_GPUVA_INFO(nouveau_debugfs_gpuva, NULL), }; #define NOUVEAU_DEBUGFS_ENTRIES ARRAY_SIZE(nouveau_debugfs_list)