Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1851412pxf; Fri, 26 Mar 2021 17:20:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBSD5eixk8yHETueHOsro0ktPk2HgRp6t4dHdP+nlVEHV9aIXAg93R48HrcgSyZrPJYiJz X-Received: by 2002:a05:6402:4405:: with SMTP id y5mr18268953eda.32.1616804448064; Fri, 26 Mar 2021 17:20:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616804448; cv=none; d=google.com; s=arc-20160816; b=ImYZiGeL4VUQ3LntNa53Inc7G7eELGn5wm3rMp8yBRR6O9r46jT5kyqVAMJZ2VL02V 7A68E/nM6TBUnRhX+5MUmaWYHJOu5bgL9U7PKnaD3a8yviV8NVzL1pKekBDcFkCGYcsY Wooc4z04o2hH1wWu6GKi0v6Mba6fvDad3KDd/gg8Zdru2s+zzdRLSI7xa4luTE4FohJI 6C3/UseJB+T73398+OfZl6ZnLjem9pAkUbb+oa+MCh2W/v1Wti0nKD0CFN6guy5aKM5f RMlcRt7wbz5os0BV9KNuyyybEpr6oN6AYBcuZLZ9Xt2CZLbBdpxJ+s8PvWmaLjS8mKXE SzvA== 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=p+le+7o7WICus9ZcLLEMXNUCCrtxxyozGQvSzYxP59s=; b=J09OZ5WRzcTsJq3m50Iu3jvl3cjV+5DGNqpldsWMfpxsreSwqDwcq8+0Uu809Ytu1Q LwXVJ29NvUpLvtGG1raOEpP2eJaALL2cn0D71J1sJR1L9c3G9k5lljYsZCtau8SnPZZa rwjRmevBmgVyQNaf9AydHx5BiDLO6vWxRi66/MOxg/0oPCZXGML99Ksh35wb81T45TuY DOZ2EEZzUupmLqfa54qRD9hi5oHOfAz161LQjHtg6FSsKjib8VgGEccaDnKlFFUFb7Zk 8lxOpl8ILtBKzMF0WpDk4OqYQqi3Ii914hodehxowf4K8vFFhPmfyfutozWbsqKwcT43 Sayw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gMHPNPfX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hq38si7705627ejc.350.2021.03.26.17.20.25; Fri, 26 Mar 2021 17:20:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gMHPNPfX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230487AbhC0AKu (ORCPT + 99 others); Fri, 26 Mar 2021 20:10:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:60807 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230076AbhC0AKk (ORCPT ); Fri, 26 Mar 2021 20:10:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616803839; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p+le+7o7WICus9ZcLLEMXNUCCrtxxyozGQvSzYxP59s=; b=gMHPNPfXIkII0LDjh8xiML8BIX90Rt3IxcKJQz1ADsPZxXJtXG9LVgs4F9VKgN5ckmMzXo nuUMRZOrMlL8kRTOrWmos9lDVVtXwTXBqxBetkZz6i26Nm8ZVAatK9l3yX3SWHO7kuggKC 9fh5arOq3pjbZQLQSPbx/ktFvqchKBw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-597-J9RQ6Dm5MIaokVwDed9NIw-1; Fri, 26 Mar 2021 20:10:35 -0400 X-MC-Unique: J9RQ6Dm5MIaokVwDed9NIw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7B425107ACCD; Sat, 27 Mar 2021 00:10:34 +0000 (UTC) Received: from Whitewolf.lyude.net (ovpn-114-133.rdu2.redhat.com [10.10.114.133]) by smtp.corp.redhat.com (Postfix) with ESMTP id A8AEA1972B; Sat, 27 Mar 2021 00:10:33 +0000 (UTC) From: Lyude Paul To: nouveau@lists.freedesktop.org Cc: Jeremy Cline , Ben Skeggs , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org (open list:DRM DRIVER FOR NVIDIA GEFORCE/QUADRO GPUS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 3/3] drm/nouveau: begin documenting core nouveau structures Date: Fri, 26 Mar 2021 20:10:01 -0400 Message-Id: <20210327001001.229093-4-lyude@redhat.com> In-Reply-To: <20210327001001.229093-1-lyude@redhat.com> References: <20210327001001.229093-1-lyude@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jeremy Cline Start on documentation for the Nouveau device structure and the NVIF client structure it uses. This documentation is not complete as the structures are non-trivial and I am not familiar with large portions of them. Signed-off-by: Jeremy Cline Signed-off-by: Lyude Paul --- drivers/gpu/drm/nouveau/nouveau_drv.h | 67 +++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h index 8eb133fd6df0..43d751d2445f 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drv.h +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h @@ -88,8 +88,20 @@ enum nouveau_drm_handle { NVDRM_NVSW = 0x55550000, }; +/** + * struct nouveau_cli - A DRM-specific NVIF client. + * + * This encapsulates a NVIF client and is intended to be the sole interface + * between the DRM APIs and NVKM. An instance of this structure is allocated + * for each userspace client when they open the device file. Additionally, + * there are several allocated strictly for the kernel's use. + */ struct nouveau_cli { struct nvif_client base; + + /** + * @drm: A reference to the device that the client is associated with. + */ struct nouveau_drm *drm; struct mutex mutex; @@ -99,6 +111,9 @@ struct nouveau_cli { struct nouveau_vmm svm; const struct nvif_mclass *mem; + /** + * @head: The list entry for this client in the @drm device's list of clients. + */ struct list_head head; void *abi16; struct list_head objects; @@ -106,13 +121,36 @@ struct nouveau_cli { char name[32]; struct work_struct work; + + /** + * @worker: List of pending &struct nouveau_cli_work associated with this client. + */ struct list_head worker; + + /** + * @lock: Protects the @worker list. Additionally, this lock on the + * @drm.master instance is used to serialize destruction of the @base + * member in this structure, as well as the destruction of the &struct + * nvif_mem embedded in &struct nouveau_mem instances. + */ struct mutex lock; }; +/** + * struct nouveau_cli_work - A pending work item for an NVIF client. + */ struct nouveau_cli_work { void (*func)(struct nouveau_cli_work *); + + /** + * @cli: Reference to the NVIF client this work belongs to. + */ struct nouveau_cli *cli; + + /** + * @head: The list entry for this work item in the &struct nouveau_cli + * worker list. + */ struct list_head head; struct dma_fence *fence; @@ -131,9 +169,32 @@ nouveau_cli(struct drm_file *fpriv) #include #include +/** + * struct nouveau_drm - The nouveau-specific device structure. + * + * This structure is allocated for a device when it is probed and keeps track + * of all the nouveau-specific device details. The lifetime of this structure + * is the same as the lifetime of a &struct drm_device and is managed by the + * DRM layer. + */ struct nouveau_drm { + /** + * @parent: Implementation of the interface required to use the NVIF_DEBUG + * and NVIF_ERROR macros + */ struct nvif_parent parent; + + /** + * @master: This NVIF client is used to initialize the NVIF driver and used + * for TTM memory allocations. It is the root of the NVIF object tree. + */ struct nouveau_cli master; + + /** + * @client: This NVIF client is used by the DRM layer to interact with + * the NVKM layer for everything except TTM memory allocations. It, and + * all other clients, are children of the primary (@master) client. + */ struct nouveau_cli client; /** @@ -141,6 +202,12 @@ struct nouveau_drm { */ struct drm_device drm_dev; + /** + * @clients: List of all &struct nouveau_cli allocated for userspace + * associated with this DRM device. Clients are allocated when the DRM + * file is opened and deallocated when the file is closed. This list is + * protected by the mutex in @client. + */ struct list_head clients; u8 old_pm_cap; -- 2.30.2