From patchwork Tue Jun 6 22:31:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 13269813 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7539DC7EE2F for ; Tue, 6 Jun 2023 22:32:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0EC718E0005; Tue, 6 Jun 2023 18:32:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 075546B0078; Tue, 6 Jun 2023 18:32:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E7F048E0005; Tue, 6 Jun 2023 18:32:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id D8EB26B0075 for ; Tue, 6 Jun 2023 18:32:08 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9B07A1208D8 for ; Tue, 6 Jun 2023 22:32:08 +0000 (UTC) X-FDA: 80873772336.20.B4270E9 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf04.hostedemail.com (Postfix) with ESMTP id 72E0240003 for ; Tue, 6 Jun 2023 22:32:06 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=OXPnM5jo; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf04.hostedemail.com: domain of dakr@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dakr@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686090726; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=P88UvIrom7/7J04O1khPNHpiLRIr+035xquRG7LdscM=; b=hGRaTOyEnPFVYmd2NE4KvCOIzgCTdvpOWEqU0btlY3yeXzOPhEee+mGRY0YlPzRECC26u3 OfMjuwPoQjfmgYrYlCSSWzBouTGMMPdQaFpt7TJEdRHmxIiy/atoKOPJJ8CiAxl0627fmB 9GXbWRh5aWGQBDdD7nwVthf1zGlyR48= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=OXPnM5jo; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf04.hostedemail.com: domain of dakr@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dakr@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686090726; a=rsa-sha256; cv=none; b=JH8ESRaboS2nvz7xZbqaYydxxOet4GbaanQJ1xlR/34jCPNCprwzm5nOps7Keh50FvuiRv 2sdU3B7NlW/w1at1O5/18gFtV8rZZpdAjhhcQBcs/wAtOcsr5ZnQgrzgRbl5oGJqhgbCn4 DO7q2uh/I1MlH1cECpznEQm1UguDgrU= 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-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P88UvIrom7/7J04O1khPNHpiLRIr+035xquRG7LdscM=; b=OXPnM5joBiTACZRrnG6lsVPI67O37gSOZIu9oDmrSHsuwEMFFo7vGHK5PCWWLfPJXMaOqD qnwzmoSUJy5EhScDiftmUnaXL3zHypzI0XhoRnB81AFAjkOPEMrdeuqEKbxgP64C+hWy6w MiHIEMuly9VmBrlIDuWclvOafMiEuSY= 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-600-iKSt4wOoOb6JKqLwBHfM6g-1; Tue, 06 Jun 2023 18:32:04 -0400 X-MC-Unique: iKSt4wOoOb6JKqLwBHfM6g-1 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-50bf847b267so176301a12.3 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=jzJzLhKbTEGykTos0Cl/0Cot/iY5pDhhrCYIzW+V4qtV/FKjo6LVOoy99fqPxKMu6z z91fYD2XjL8vuIIcxIJwfqg4MIcIvrSLVpSyZKhFFqvQH8zHXHgfip/9gK+ddITOC+Y5 9l73Zlc1thu3EbqN1dn4Gs4vfkuVa1+EJ+mpW8NVHn+bipVZP41YkLntH3M0q+LHnZBp +ilIX39/1f+sF8doS/GdCXYNxRsQtr/s8xfL5f9/rVXGs2VXdfOw5wpfmm+59UrfS7G6 LcsslWZ1hISn7cDGoxPvktUNhe5jVOp1KtMkl9alYeK5HHajF7LWj6FM5SaK8MEDCkBZ 8Gsw== X-Gm-Message-State: AC+VfDzmqrC2qNhiFUMgHz8WYnGvDBA9CJrZ22bLFClVgOvtLwjIPSeA MnFjrmuOQAGPs9SEE74lrYYD3F4nRsEIgXLWF92kZeeQnj7vM7rkIkcvv+Oieg1EHtKJ0zeM9N/ MTzcraJzDc4Q= X-Received: by 2002:a17:907:628f:b0:96a:48ed:531d with SMTP id nd15-20020a170907628f00b0096a48ed531dmr4506625ejc.27.1686090723363; Tue, 06 Jun 2023 15:32:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4h21WZZBqQ9JVBgfj09OM8bmwxl6ZNZbuCk3aWebu9IoFFPYFZHVL412/Xn45PAHA69OvuJw== 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 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspamd-Queue-Id: 72E0240003 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: ybyncgn4zi8yzaegj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QAXJs+1Xy3z2MAlDHF7CigiRctlVo3thOSCdwwx+JYzL9lKECAJ17dQsU5E54L69BJ8sXiZQkDKmleqvWdLA4SGhLIL4hpOq6hAjMrcX30Phk0pOthBbxoUXRIv2lJOt6IP1veN+1oHmPDCBtmAdaprBFo/8iQ9BbgYTnkReANM4y83BAbzt/W7Ox2/Qe9tgCdAmGrB/hHuR78ichih5qWkHX9d++npzM6mbuACWTM1vXK1GWSb571mue/8CYuw6BmLyBQmy3RHHFw+dov4vORUFkowU+YeLjq1kAyoyMBEX7g0ssQWZHwB6mGMxOGW9diVYA1a04GRn9No547niO3KkB6R3tK80lY9DWz+qEUCnQz+Ha43i8AufKZPoKwn52T X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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))