Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7736911rwd; Tue, 6 Jun 2023 15:46:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5sBdJqWfFltnyunXggnRFJDfGKe2kAh/n0vTsdMIyrktPtG6H1DJhJt2ldO0F9FH0jTmXn X-Received: by 2002:ac8:7d96:0:b0:3f5:a0a:b30c with SMTP id c22-20020ac87d96000000b003f50a0ab30cmr1592445qtd.42.1686091602527; Tue, 06 Jun 2023 15:46:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686091602; cv=none; d=google.com; s=arc-20160816; b=hMYGzUwDFMcasDB9T4YMYCGuiapbROpLv1n7PGFgFCEjfEuIjdmzF+56KL0r4cf51q HL0/Z1muj5bye8GpuiXCoE/qVPJeZetZkpUYm+l+/8d4TinG27VYYSkHdbxZlWOoyCuS dwG8k7GSn9z6Mo0uxeA/PaiaVxGUZh0DGnkT3ft/7Olq61WR2HrmmBeCe8Fk4lpPSfWX n7zRlz8aXWCuYV9FviWw/J0kgTk29JI5UMx/TrtDlESwZxYNGTFXEFCGm3pIPPIVYFZg aOliYArzP+tpfk0UiSS74qU71IQtT7UQj51oq5g4n/LrQtA2OvKHcRYpbF9TREa8aacp XbjQ== 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=P88UvIrom7/7J04O1khPNHpiLRIr+035xquRG7LdscM=; b=rWa7TNWBduUV9lqlBkXwxKfgOAksYVPyjEYbHtA8paOR36eHpL529ZU0t8CV4P1TbL OI/ud7r0QiInEc0pRwkRmDl6sBqzryS8NQNoKk6rD54WuWmcohPMXKsJY8npKNL2NKJY geFNqCWzd0AcGdi7B88jhBvIhf7F/Uy8pu/2+G5gaYGRbiKvSr6uo9f85oVlvLnAlW4X o6/N3PwPizgt0zi5+X5Y5+ZQHBuh8M4VhobQCmAZkpD1xa0hHOlRD0M8gTybEZA+U9pN MyrP1kwlgo6E+Jq6u0o8kQROlkYbuAENW564Ev8Bjkma7iM7z20iq2xVw3SCms5JX9bR cZ+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jMwwfFWG; 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 c12-20020ac85a8c000000b003f7eef648dasi7038185qtc.458.2023.06.06.15.46.26; Tue, 06 Jun 2023 15:46:42 -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=jMwwfFWG; 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 S239944AbjFFWc7 (ORCPT + 99 others); Tue, 6 Jun 2023 18:32:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239903AbjFFWcs (ORCPT ); Tue, 6 Jun 2023 18:32:48 -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 689001736 for ; Tue, 6 Jun 2023 15:32:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686090725; 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=P88UvIrom7/7J04O1khPNHpiLRIr+035xquRG7LdscM=; b=jMwwfFWGIM7WSbu9jIT+PgoN8LlX8nkpiKWizlTGKjbR8ZlStaxX8jeLxqkY27/YJRHUci 8/5ym48nEJ0eUgUEYG+lWEK9apKFmyqddzMYd+SIGaw4YgJ/0JsPbdCbLSsSTN91nF3GhK f7Nxhu6CPh0gh2hYI96aFCc9sQtpisQ= 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-609--R3YYR0jNCenluyT5elU0A-1; Tue, 06 Jun 2023 18:32:04 -0400 X-MC-Unique: -R3YYR0jNCenluyT5elU0A-1 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-514b8d2b21fso183384a12.1 for ; Tue, 06 Jun 2023 15:32:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686090723; x=1688682723; 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=P88UvIrom7/7J04O1khPNHpiLRIr+035xquRG7LdscM=; b=jNRXyXd+hMnXT0OIdEBbbR5mzt5cuhSEYekLfXg3rUATUBYoTOc0J0cjOucMfSOPyz cbaqOa/Xkz7yvue5YulnmH4wZ3xciSGt1NJeAoZPA6da/bNsi/Wr5YRx4Qi0tXldR7cr y0DHwLuPJ5k3UbXbhaIjyzrj7YRMSwA+F60QbnadZBKVxzscU54dB7Ufag2sdOzPqTE6 Vi8DWtx60Cfa+bwbYoyTDAI5dzqLYP5Pov+QR4kEoIt7ILuoMmm9ll2rqXg8/0zBWne1 QVyDoAPwtcdIOt/k3CtSWf1/JSvK/+PMk5cCQQHr+XOkuHyy7yOD/f5IgR8s0//ASf81 ydKg== X-Gm-Message-State: AC+VfDwso6aYCgmZk1FbjHBzS9kMfOgR1Xh0WvYawMLhRfPh15EoZ/xn OXv0uGHgLfg6Yf8tZlbfooEd4Pk0OgP90m63Vzkc4/SX8zpsakY7FQtdrNpg7cYYyhN5NmWzQhm ohKNx10EvAJTFsOppD4n3W1Yb X-Received: by 2002:a17:907:628f:b0:96a:48ed:531d with SMTP id nd15-20020a170907628f00b0096a48ed531dmr4506637ejc.27.1686090723370; Tue, 06 Jun 2023 15:32:03 -0700 (PDT) X-Received: by 2002:a17:907:628f:b0:96a:48ed:531d with SMTP id nd15-20020a170907628f00b0096a48ed531dmr4506609ejc.27.1686090723041; Tue, 06 Jun 2023 15:32:03 -0700 (PDT) Received: from cassiopeiae.. ([2a02:810d:4b3f:de9c:642:1aff:fe31:a19f]) by smtp.gmail.com with ESMTPSA id l10-20020a1709066b8a00b00974556e50a6sm6087779ejr.114.2023.06.06.15.32.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jun 2023 15:32:02 -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 v4 06/14] drm/nouveau: get vmm via nouveau_cli_vmm() Date: Wed, 7 Jun 2023 00:31:22 +0200 Message-Id: <20230606223130.6132-7-dakr@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230606223130.6132-1-dakr@redhat.com> References: <20230606223130.6132-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, 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.40.1