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: 13285084 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F11B9EB64DA for ; Tue, 20 Jun 2023 00:43:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7CA208D0008; Mon, 19 Jun 2023 20:43:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 77A5F8D0001; Mon, 19 Jun 2023 20:43:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 61AE08D0008; Mon, 19 Jun 2023 20:43:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 5500D8D0001 for ; Mon, 19 Jun 2023 20:43:42 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 304081204A8 for ; Tue, 20 Jun 2023 00:43:42 +0000 (UTC) X-FDA: 80921278284.13.8621B04 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf16.hostedemail.com (Postfix) with ESMTP id 1BAF0180009 for ; Tue, 20 Jun 2023 00:43:39 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Gdgzvotw; spf=pass (imf16.hostedemail.com: domain of dakr@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dakr@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687221820; a=rsa-sha256; cv=none; b=ewwk2fO8IyvNBcdcIK7UCp6PmkXvzbdG+UmCv71dhBvuq79S/w9mQi8vwnEYPn9vbZwGeN B6tAQ60Cti7gf1z+CPyklMsUsR4Lm/bNQs/jQu/oDgIizlbzX0Xo37a5zwOQoZTB40snWC RDBS3aBw+E9AyJbduP0g7KDr93ZzCKg= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Gdgzvotw; spf=pass (imf16.hostedemail.com: domain of dakr@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dakr@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687221820; h=from:from:sender: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:dkim-signature; bh=a7jCgjA/GeF+vfePBjhGpS1KJtr0QbtMbF11c3DSw0c=; b=wFWQXq79s5QaNd7ZkSZDgDR/sLG9PhbwuH1uhyjWhInnQWKlrffsfAqor/AH2RuRYb+Rsq S7CLF9CLkOOu6ON3TgVvF64lzTnj/xB/OHr8y7MQEpiGRzu+mT48Nwt+rRMW9a6B0Rsdfo b1pHwE0EvzHdICUpt2Zq/B59jHor4O0= 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-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-490-jBW1iVGbNbKL3vxjx1XNAQ-1; Mon, 19 Jun 2023 20:43:36 -0400 X-MC-Unique: jBW1iVGbNbKL3vxjx1XNAQ-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-987accb96dbso184585566b.2 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=lC3UnrEnkVa0fIW3RGrFTgzozW8lCBbtAzGLI1qQpjx4ED1Y83lXHrR1p1s0fQ7QRG Kuiqgxypsdcf/Gzft6hlIV+hwo6CYZ3ELSNj+lrFqJBIhgT8UUKeCFp7MnUOr8qxd/re /8djiagrYJAaHfPAPrtMx6uZsv88spz0bLy2IZddCsf5XgAKfzaXjI3pcbXfnRzBiUAo jBWOXEk/HJzpUz4HexRlN+II34V7AIy/3l/NKNlQE2TRHV7krvFW2KFkFhWN4GHoalJ7 kcnUtHccJMCAzqO6FhvIZLGdvENU4fyg/sydToL+5rswzzwjynRxHUSIgNRu4Ethtu5G GBtA== X-Gm-Message-State: AC+VfDwswIHbfD5WuDQDh5y1HyGNRXtfRKXhXuD960kM8shEqLnQ9oxp akEQctj+9/QVITzs2dNqPH7llhu7oIrwnxnRJNLHfiy9YpexdG1beQq1wq5AjqpJAAH8Rv835iD ehYcSaZ+RkP4= X-Received: by 2002:a17:907:16a2:b0:977:4b68:bf2 with SMTP id hc34-20020a17090716a200b009774b680bf2mr9258852ejc.54.1687221815353; 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 Cc: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Danilo Krummrich 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-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 1BAF0180009 X-Stat-Signature: m7xhif4xe5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YWH6Vg2KMJRN0fxHKoMdpQQ5Xr/8kvSLALIWALOeDFwLO6BR8FiisrT87CLgXHCn5XQhsdbdpCkvobPpIAXwh5ZRNVxRL/kVZ+iWS9iVGK65qA2uuC2aMNluQhogxfA4EB+0t9+Xci8OebukDmxeLYSXDvURD8NB6nSGAzNhodIrQDrRW/kHAnCUcVkrPP9PguYvW6tLjNkqZlOnpGzJXzgS1q6LgjoPX/2fO3vqW59RHxBLpqeYFCq7UbLmWqzkeLEiaLzWFcECV/V+4tai/nOUpZ7BLv5WCgRjabJmDXleZP6lk4BrbnPCWJSmNKA3IIlePqcUj+3hDoCM3xAjT8XHJmpe4oqg= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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)