Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp1415818rwp; Thu, 13 Jul 2023 10:28:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlHKK5/4axbh173iL1UqV6KSB31Xyw+3EIHZo1deMJsGHCr76mDWU4rbjhksOYOsvWaBfIKl X-Received: by 2002:a05:6358:e81f:b0:134:cf15:92e1 with SMTP id gi31-20020a056358e81f00b00134cf1592e1mr1188684rwb.2.1689269304334; Thu, 13 Jul 2023 10:28:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689269304; cv=none; d=google.com; s=arc-20160816; b=OsJDZdGw1JA0jaP5HTm2t3GC60xZq//3D6VVLDy9t+EPJl8D0hIJiS0SMk+VFbAxZX Sir8JPub0GaXbCZw56l7IveMbX2Ds31JYnU4fZDcZOISh3hNbz80AZhc24oG5ObvIF02 wnopB0ZzsowevLX7A4cCo8Ie73p+4GfcAI4Vi9Ce9KlB1LYx1K4feUC258MZ9MBvXg/+ DUSteoYN5ct1FxQdBiOft9CYNc2Mur2P2kT50WOwofyzlJju51Jw4dYRh0mIx0CVnH7p tcxCXUo0/x83NJHpJGnzAIjl9pFNw3z2p55bstA9G3GSEsSQERZaCuhnNgg9lTOnpYds U7Aw== 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=DNvPFmPephzOlef4HOM2AR90BUKB3CUNAq245FGhm7Y=; fh=grh6qrjW0oxu0S8zfHJMhxWLgUXiZ/TU2uoVe6KOi4w=; b=BMYC2o9m7VKvIPCE3kPTh+hI37s6P4wo00A0CSMTMIObbUv4Mhv4bOwRXOHJUJ+0wB JFKn117dsRPwqVY9RRpR9hVCbJhPBJGWdvYSQfi6jMkwUdnurZMpcr0vGLiebeF+nUAF IjJX1HmB2ajpjyiX6jyNMWIkWvjYqK6qLO1LIkCOFbaPulqpA/ZQ3PFJ7ZqPVqHK4LHD gtd4wAaFtyXQIuqF3ClUQ3J5oBJGtcMUwaHNNHgbzu65L9tA4+PcDrEXBfJl/AHlqNHD iaH59GHJHNOLLj1puGPqLO8pZs+wMUlyiCt0tXFSehRqw8f+sPfBhsFflWhu9mjMmdlv xeMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bsH8lJul; 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 q184-20020a632ac1000000b0055c090df2f8si5297769pgq.478.2023.07.13.10.28.12; Thu, 13 Jul 2023 10:28:24 -0700 (PDT) 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=bsH8lJul; 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 S231709AbjGMRGM (ORCPT + 99 others); Thu, 13 Jul 2023 13:06:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231660AbjGMRGH (ORCPT ); Thu, 13 Jul 2023 13:06:07 -0400 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 D8DD82D46 for ; Thu, 13 Jul 2023 10:04:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689267898; 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=DNvPFmPephzOlef4HOM2AR90BUKB3CUNAq245FGhm7Y=; b=bsH8lJul4vojRI9z3ibGES92JJTYyQvalRbwczHBZxHKKlnaRixeRnWkUKj8yqs2lKG/Ls rKAIVXcHL4XmMsCB8oXFWwjxflT06U3VLA4BSgVTXltl1dcPnKS16wXz2+g+fUp8b2QEuL kvkNeABl0vvL1a2vI9HrNCvZZvX9d4k= 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-311-UbaI15hMM22OeamC3MV-Bg-1; Thu, 13 Jul 2023 13:04:56 -0400 X-MC-Unique: UbaI15hMM22OeamC3MV-Bg-1 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-51e5a6bae66so587953a12.0 for ; Thu, 13 Jul 2023 10:04:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689267895; x=1691859895; 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=DNvPFmPephzOlef4HOM2AR90BUKB3CUNAq245FGhm7Y=; b=PK9yyCNTwVT4dBPnmtlH6Ky5IMqh6JlKnOhM69vZz3uePVYLyl9KXE9tsycOkeowqp G7EzMl3AaE1vcKIybh5bwAfLIFy4hWEMazfsUEHK7FdmyWG0w0Yn4Z/smQc+KZqTzyTf I4GLSRDav9kkWHQFFg4Z8S874kwGaiGV6rgFBZAlgOc6scIYi8Sln/NjZIK6ZGpyLJGm WYgdNh4vIB0Eft5aXFLwQ2C4e9pQXMJO6ZEqgwqZQwJ1ZzBEbhuar3vbOlyUfXcJRGEf MSX09heJ0h6ztT3RolhNqNHOHt+qKT2pRjEjTljqL+CAVN9Ni7wyFAHKbpBynqe7MahG CQpw== X-Gm-Message-State: ABy/qLbRQHVTcjcASK+I9LJVNaiJ9M8pG2aqSg2DQx1xMVsCnMbInkAd 4AA/50Li9N8UrvO0DTFgILdaotDP8m2XFPVMMP/yRgDb1dUrp1FSFPJG4zMfiykX85PMz0rEQkv lyHY8Zab3UfArEaW8jjznetQs X-Received: by 2002:aa7:c6cf:0:b0:51e:1a3c:e729 with SMTP id b15-20020aa7c6cf000000b0051e1a3ce729mr2086211eds.15.1689267895628; Thu, 13 Jul 2023 10:04:55 -0700 (PDT) X-Received: by 2002:aa7:c6cf:0:b0:51e:1a3c:e729 with SMTP id b15-20020aa7c6cf000000b0051e1a3ce729mr2086181eds.15.1689267895346; Thu, 13 Jul 2023 10:04:55 -0700 (PDT) Received: from cassiopeiae.. ([2a02:810d:4b3f:de9c:642:1aff:fe31:a19f]) by smtp.gmail.com with ESMTPSA id r14-20020aa7da0e000000b0051dd16f7e50sm4528065eds.44.2023.07.13.10.04.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jul 2023 10:04:55 -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, donald.robson@imgtec.com 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 v7 05/13] drm/nouveau: get vmm via nouveau_cli_vmm() Date: Thu, 13 Jul 2023 19:04:00 +0200 Message-ID: <20230713170429.2964-6-dakr@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230713170429.2964-1-dakr@redhat.com> References: <20230713170429.2964-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_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham 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 c2ec91cc845d..7724fe63067d 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 ab9062e50977..45ca4eb98f54 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.41.0