Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp6018106rwb; Tue, 17 Jan 2023 23:25:04 -0800 (PST) X-Google-Smtp-Source: AMrXdXuDRaK2ibOuHThiZzXbC4LBL6j0Sno7zyhGGL7/RrMHANbNOJ+wbxE4rFaJNbzE+Zk/QwCr X-Received: by 2002:a17:907:6746:b0:871:2051:637a with SMTP id qm6-20020a170907674600b008712051637amr6293732ejc.60.1674026704623; Tue, 17 Jan 2023 23:25:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674026704; cv=none; d=google.com; s=arc-20160816; b=SmGqbt9+VGZzweEFz8NL+vuKK8JCFAdPqGTI3xUXyFPbqTD2Der43221yVVfcdiB8H uFJOEoK+TN2Z5teJlgxoHHxBbK2gTtrCM/iFfm1DjnLD1dE3eodiHlmXenqBnHhBL+wM P/r2b+Bjm0IER6vBNrXN2t/nJ7bYY5cCaIHUVMMU+1R/Q1t4MpGU5+yJG123lCzd93LG egN0ZvMvsWbnamKULISOf4Y/TOwpN7WZ9vkqcmQzCCMp9Czlvwk4kBYf3AtHowkqRJx2 5YtoHbEq8gdLOYXKuesL0GEjnGmTlR4xQGRFBazXUOBIlKAtPgzRew5Fi5wcg+XOxd9l 2grQ== 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=THkjWbjdTDoalDkhZzXhw8wgGXeOdJbZJd1kVOay+qU=; b=qLMR3VZxU9gCl5P/7e9F/IsC1wOk+VBFYUWdixlv5H8Yk9C6Z5hyjAYCSUbfxZva83 rwJkehGszHu+DGOPOJH5ttO7E2aPFq7oetZftL04ssAr/gIFpzI37bJ6kvGMcoCzi4ja AI34klEOGfBkD+ZRD202sED0L1MeyGwzEDVZ3kM4UosDR5NN5s1j2dhjpFQXON85eCUK LiGDFNNQpRcWSIwklq0RR700U+JtQRpUv92S656j8xQYzOMLYcGzee+0GDlZxfdZLSIr M/BarNy6JfA5Rag6YwsXq+ub7g5MUEtBxYRW3kem/zGx2eGEGlMgy7MfNEPiEj8CYu0l Rk2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TcjSoSt8; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r19-20020a05640251d300b00485220caa05si43345253edd.597.2023.01.17.23.24.53; Tue, 17 Jan 2023 23:25:04 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=TcjSoSt8; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230140AbjARGtz (ORCPT + 46 others); Wed, 18 Jan 2023 01:49:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229778AbjARGZN (ORCPT ); Wed, 18 Jan 2023 01:25:13 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C489530CA for ; Tue, 17 Jan 2023 22:13:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674022431; 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=THkjWbjdTDoalDkhZzXhw8wgGXeOdJbZJd1kVOay+qU=; b=TcjSoSt86NPPC1XSTrAcTussVnVMjYKbqnt9lxwbo0f91PobeuiIRJ3vudZUglzC/iumx8 AVXzwvoImf+6nbsrjHuMdDPQfp9bRV/6sLyidn8XhD6+fgOWgNGgxlxgExp29wDE+RVhNH /O0gQG5rXxRRGqHOMciL5Xjs5Be/kLk= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-203-A40zqezQOHGFeVB4WLOFOw-1; Wed, 18 Jan 2023 01:13:50 -0500 X-MC-Unique: A40zqezQOHGFeVB4WLOFOw-1 Received: by mail-ej1-f70.google.com with SMTP id qb2-20020a1709077e8200b00842b790008fso23513348ejc.21 for ; Tue, 17 Jan 2023 22:13:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=THkjWbjdTDoalDkhZzXhw8wgGXeOdJbZJd1kVOay+qU=; b=L7evX7OUaruiZc9S89p7u2+dMBeiLd2K+KiaFWpxBvLPCLWnZRLcw+mDggx9NCUviY nCM0HOcVyLIXVcXqw1smGvKhkhDGGlrt/NCf7LMYJTqiQy1WCpOu61Z1kzA9qOW5X4sj bQO3iYW7eXSp+1yUarV68Ah7Nxz+ln2O4mlxra+L9lzyMYe1W9w+y1JPPbadZubuYDqz dGKs6sEOo/W2wB1MepQZUu+Xet48b/Y0/nd+9e2rb9H7FMpuWK8voPEZDGDQrBCXv+kY kYjpmbW4x6Z6P3vBabvyIxCviRLP5XgQZXzUVcqHweE15M7RSnYolbijALP8iaVQAZlI RlZA== X-Gm-Message-State: AFqh2kpgdYOV8SP+ntr0XAQsSyuzxEYAkKLwvZ3smWK8SSWXyf6kv6gH qiOnUIokxKwtidhP8R99c1XGHoQDmkZpAicjS48OaNzRsMmptlYPCdaAeoVeKkptCdsKN47Y0+N tGuHQGcdbuzOLDBXZIC07tstp X-Received: by 2002:a17:907:62a8:b0:86a:d385:81df with SMTP id nd40-20020a17090762a800b0086ad38581dfmr8955220ejc.3.1674022428969; Tue, 17 Jan 2023 22:13:48 -0800 (PST) X-Received: by 2002:a17:907:62a8:b0:86a:d385:81df with SMTP id nd40-20020a17090762a800b0086ad38581dfmr8955202ejc.3.1674022428774; Tue, 17 Jan 2023 22:13:48 -0800 (PST) Received: from cassiopeiae.. ([2a02:810d:4b3f:de78:642:1aff:fe31:a19f]) by smtp.gmail.com with ESMTPSA id k2-20020a170906970200b0073dbaeb50f6sm13961020ejx.169.2023.01.17.22.13.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 22:13:48 -0800 (PST) From: Danilo Krummrich To: daniel@ffwll.ch, airlied@redhat.com, christian.koenig@amd.com, bskeggs@redhat.com, jason@jlekstrand.net, tzimmermann@suse.de, mripard@kernel.org, corbet@lwn.net Cc: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Danilo Krummrich Subject: [PATCH drm-next 06/14] drm/nouveau: get vmm via nouveau_cli_vmm() Date: Wed, 18 Jan 2023 07:12:48 +0100 Message-Id: <20230118061256.2689-7-dakr@redhat.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230118061256.2689-1-dakr@redhat.com> References: <20230118061256.2689-1-dakr@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 Provide a getter function for the client's current vmm context. Since we'll add a new (u)vmm context for UMD bindings in subsequent commits, this will keep the code clean. Signed-off-by: Danilo Krummrich --- drivers/gpu/drm/nouveau/nouveau_bo.c | 2 +- drivers/gpu/drm/nouveau/nouveau_chan.c | 2 +- drivers/gpu/drm/nouveau/nouveau_drv.h | 9 +++++++++ drivers/gpu/drm/nouveau/nouveau_gem.c | 6 +++--- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c index 335fa91ca4ad..d2b32a47e480 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c @@ -204,7 +204,7 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain, struct nouveau_drm *drm = cli->drm; struct nouveau_bo *nvbo; struct nvif_mmu *mmu = &cli->mmu; - struct nvif_vmm *vmm = cli->svm.cli ? &cli->svm.vmm : &cli->vmm.vmm; + struct nvif_vmm *vmm = &nouveau_cli_vmm(cli)->vmm; int i, pi = -1; if (!*size) { diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c index e648ecd0c1a0..1068abe41024 100644 --- a/drivers/gpu/drm/nouveau/nouveau_chan.c +++ b/drivers/gpu/drm/nouveau/nouveau_chan.c @@ -148,7 +148,7 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device, chan->device = device; chan->drm = drm; - chan->vmm = cli->svm.cli ? &cli->svm : &cli->vmm; + chan->vmm = nouveau_cli_vmm(cli); atomic_set(&chan->killed, 0); /* allocate memory for dma push buffer */ diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h index b5de312a523f..81350e685b50 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drv.h +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h @@ -112,6 +112,15 @@ struct nouveau_cli_work { struct dma_fence_cb cb; }; +static inline struct nouveau_vmm * +nouveau_cli_vmm(struct nouveau_cli *cli) +{ + if (cli->svm.cli) + return &cli->svm; + + return &cli->vmm; +} + void nouveau_cli_work_queue(struct nouveau_cli *, struct dma_fence *, struct nouveau_cli_work *); diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c index ac5793c96957..48e6ba00ec27 100644 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c @@ -103,7 +103,7 @@ nouveau_gem_object_open(struct drm_gem_object *gem, struct drm_file *file_priv) struct nouveau_bo *nvbo = nouveau_gem_object(gem); struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev); struct device *dev = drm->dev->dev; - struct nouveau_vmm *vmm = cli->svm.cli ? &cli->svm : &cli->vmm; + struct nouveau_vmm *vmm = nouveau_cli_vmm(cli); struct nouveau_vma *vma; int ret; @@ -180,7 +180,7 @@ nouveau_gem_object_close(struct drm_gem_object *gem, struct drm_file *file_priv) struct nouveau_bo *nvbo = nouveau_gem_object(gem); struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev); struct device *dev = drm->dev->dev; - struct nouveau_vmm *vmm = cli->svm.cli ? &cli->svm : & cli->vmm; + struct nouveau_vmm *vmm = nouveau_cli_vmm(cli); struct nouveau_vma *vma; int ret; @@ -269,7 +269,7 @@ nouveau_gem_info(struct drm_file *file_priv, struct drm_gem_object *gem, { struct nouveau_cli *cli = nouveau_cli(file_priv); struct nouveau_bo *nvbo = nouveau_gem_object(gem); - struct nouveau_vmm *vmm = cli->svm.cli ? &cli->svm : &cli->vmm; + struct nouveau_vmm *vmm = nouveau_cli_vmm(cli); struct nouveau_vma *vma; if (is_power_of_2(nvbo->valid_domains)) -- 2.39.0