Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5314391rwl; Mon, 3 Apr 2023 18:29:49 -0700 (PDT) X-Google-Smtp-Source: AKy350awZRTNRg97Mi6Jrmdv10BBxtMvY4ujLC6/+w51RB6+NHYUNZb7B8liNpb4Qe0kCHfq9dGY X-Received: by 2002:aa7:9709:0:b0:626:2cc8:311e with SMTP id a9-20020aa79709000000b006262cc8311emr484287pfg.12.1680571789038; Mon, 03 Apr 2023 18:29:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680571789; cv=none; d=google.com; s=arc-20160816; b=Mz+YBOPwk9kkmaa9wGHklYq5Vb8ion5Jbd0yuDYbPVJeMJfF6rCYP7YknNn8F48t+4 3IslsauQ40iOgMzp5CLNko/BNsnoHXu0Bgk2j2V/a+//uiOVVG+DFp5WN9yEZDg/9iVP Wggkp4ERY9I0JU2VFGuTlfUBB9aUUvAObH1svYtMLPkiDSjpTJXDPRE32eIkDjQ+GJg/ gMvuR9zCVvPfQKsEKU/PcyFsjUx0L3fE3uAu10Ka+7AlTgRHaYZCb1xoako3WsJnwkdZ HZIPlGlR5e6J5bvQkBCCWV1SZgRDtcKognJ9VFfvu6hVlF2MQMc+pNUgKk5r0gbaEsB5 rg3Q== 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=C41um5yLWIzQt7F7rKhcCeybPcAXgIiNcRs8QRFgiIk=; b=HuMhouthWEVxXs1Ih4MMfZOA0yLXlPGSZTkOrKatMKhribvu0kEN3kKJvvKaDFRUwF BamKY7I1XUHLw/SINIBcvBKTnVMA+9TDe4xWyxRWKhvCBhB6qJO9iF1xaav3vtoWHVLG PGjt/1wQHmrs3gJ8b/zek6YCrvdIlQOAs1VOx9B2QaoD4oeDAuS/308Q6D2lEbOOcoE4 kqEPa18lR2680iFDJG4Ygnpo5xnjnCUuCEeqRtqkx8G1Bwf7rQRn1igsmgXeB8Qp7+4G yBNST31GcwT5Uu6q+LOzRG/Wuh+T/hmTKT7Q7fvQJQ8X7m8Ct9vFcDVmHo4LOtDuHfeD 85kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=i1KRwvgp; 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 a23-20020aa79717000000b006233c7e8887si9520853pfg.90.2023.04.03.18.29.37; Mon, 03 Apr 2023 18:29:49 -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=i1KRwvgp; 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 S232839AbjDDB30 (ORCPT + 99 others); Mon, 3 Apr 2023 21:29:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232656AbjDDB3W (ORCPT ); Mon, 3 Apr 2023 21:29:22 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC5792108 for ; Mon, 3 Apr 2023 18:28:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680571696; 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=C41um5yLWIzQt7F7rKhcCeybPcAXgIiNcRs8QRFgiIk=; b=i1KRwvgpDKNo3CogI/H5QvnOEoKuwqCwUzLjPHAo63NRBfoCssGU1q0lFTHnZ6hWvLI6uM NLz2zKk9yb5K44muPtldoSjZu/3CEJIbpHOk7Y6RWenTSki5X7bhJ7Y/xow1mHLimazKA6 kQaUZHlNFRxO/KfnEP5iLSRfVDurRwk= 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-64-miohBxddOSyawI4l0oRDPA-1; Mon, 03 Apr 2023 21:28:15 -0400 X-MC-Unique: miohBxddOSyawI4l0oRDPA-1 Received: by mail-ed1-f71.google.com with SMTP id b18-20020a50b412000000b0050234a3ad75so38956802edh.23 for ; Mon, 03 Apr 2023 18:28:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680571693; 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=C41um5yLWIzQt7F7rKhcCeybPcAXgIiNcRs8QRFgiIk=; b=4DeNzJkdydfy6OKglRqNs/h2HA9ma1z/NyZL929imObUTUaCl+gGlNGcMFjWco/N/F g8K9P2TZUyoicypvjER/iym/ralg+6UfQP68Mtomvcg8bBPbYMhUbMwPmC0HFiZFhxkF Q2DomJHp1d2/bUm0QpTAOz30zPqqSEAVx2/o+8GRwYeYxmPyO2mUmBWXWawaZRa/RQsr UmKcNtPiqk8oTwufMjlMSo9TVaDDnbMhTs4YLSe3WtBPcLLGnsk8irJ6NSvY/EtRUC9v czWUI3Obm1wwhjmi5CEV/PlkaTX1CY9TfYoo5Gm7h3Cvcn1JQCbKLSk398YwhkZeBxEB GNbQ== X-Gm-Message-State: AAQBX9dPsNMI42HJNQSzvp/nL902iyKtZIV8vN/X3O81e9Cbkz7cywye AHXWA5Xg/aHi3Lf9xdObGbBBVLS2qSB59igr2/EzaF/aHlsHx9Np5AczJu+ZyHPrJRqlZ3XsAjH hFdUqpcv9BWgy9QuRo4KhyazTv2F/DRGq X-Received: by 2002:aa7:c90e:0:b0:4fa:aee8:235f with SMTP id b14-20020aa7c90e000000b004faaee8235fmr943446edt.9.1680571693571; Mon, 03 Apr 2023 18:28:13 -0700 (PDT) X-Received: by 2002:aa7:c90e:0:b0:4fa:aee8:235f with SMTP id b14-20020aa7c90e000000b004faaee8235fmr943422edt.9.1680571693408; Mon, 03 Apr 2023 18:28:13 -0700 (PDT) Received: from cassiopeiae.. ([2a02:810d:4b3f:de78:642:1aff:fe31:a19f]) by smtp.gmail.com with ESMTPSA id cq5-20020a056402220500b005023ddb37eesm5156889edb.8.2023.04.03.18.28.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Apr 2023 18:28:13 -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 v3 07/15] drm/nouveau: get vmm via nouveau_cli_vmm() Date: Tue, 4 Apr 2023 03:27:33 +0200 Message-Id: <20230404012741.116502-8-dakr@redhat.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230404012741.116502-1-dakr@redhat.com> References: <20230404012741.116502-1-dakr@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=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 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 f77e44958037..08689ced4f6a 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.2