Message ID | 20231027165859.395638-1-robdclark@gmail.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp748752vqb; Fri, 27 Oct 2023 09:59:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHUOv3UuqlooJthJvDhG4ssR2Z4tVyeKar9QgWMXQNG9jfhOAGi54aXJbzHY4tpCwCZu3+O X-Received: by 2002:a81:ae13:0:b0:5ad:47ba:fa3a with SMTP id m19-20020a81ae13000000b005ad47bafa3amr3449180ywh.43.1698425996961; Fri, 27 Oct 2023 09:59:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698425996; cv=none; d=google.com; s=arc-20160816; b=k+H1mM5EQZ5zU2ol/PaSOCDlvR+aUs7GqW2Dn0GGo1QXI3y/s1cOooGgpM+tv+vRV7 a8wR05SxIX+5p7lAN9wYFNTqd74naRVXi5s2J1YK3afpS+jgE2ErtuqUC7J0N8n3eKaP u8ApN+uJ7mv3MATjhHniu2eyM+0atSwG8SZaSvxDlhTMRxKseYbI74Q1q/eNLQPHfEsM JSJKsylCPrYEbQX2VOwcv+53rNGGaWoMQLp3nE4w0d0/JsjlB7kCAJJbshoJdLF8utTA 9oyhTbxdt9knD/xxiS63Lm+nMcugt8tNu1XatsRIHpqXdMiSDaZ7OZGR9pI3IXMzm3bX ki0Q== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=l2XOiyO7ELntzgtLuOwOBKhVQExybEKPgHk4URVDgho=; fh=/1poAG9xO1zTxc0mX0e8ONbJTvEOl6U9SEq14wCyaE0=; b=OzaJ922kqsZ8XVZtxCklCBZP/vc8XL5kFstfUQJmQGIsyiThgCnksKwbmEotImRrbD WSB1MMEev/XWWa2RuTtIjXK6UJewf1XaDir/Rqj+KGsVUXUv9viVfDjwkBLgvCW4EjMy DZhf2lX2rFMcZ3ZByX6UAAfaHhgL2R6PDnZlyu9c+r2LjKhhNRFH8zvKlFrQXaEzMYLT qMpOKlH8La7rs2DT55bUTZv+irsrYFWCeJ8YYwFRmQXl3xgpOXCrK7KiWjVEPoRZu+o8 0cFXcxVD76NrcGE9EzR8/AfPIbmuGUSgzQjqI4vi+dfdKHtV2ca6u2YtXQTNRvfwI5Ep k56w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=TaXdggCf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id o128-20020a817386000000b0056557e9a372si3066321ywc.161.2023.10.27.09.59.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 09:59:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=TaXdggCf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 2A44F85BEA7E; Fri, 27 Oct 2023 09:59:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232101AbjJ0Q7S (ORCPT <rfc822;a1648639935@gmail.com> + 25 others); Fri, 27 Oct 2023 12:59:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229454AbjJ0Q7Q (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 27 Oct 2023 12:59:16 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF01411B; Fri, 27 Oct 2023 09:59:14 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-2800ab6fa66so881705a91.3; Fri, 27 Oct 2023 09:59:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698425954; x=1699030754; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=l2XOiyO7ELntzgtLuOwOBKhVQExybEKPgHk4URVDgho=; b=TaXdggCfuxcnoE3f7wujFBb8G5rfCzEQXCsOLdMruV4SRYxEXcbMj2mXFEfSUMKS94 ES82gfraay+Ip729LlK8pgOjUOSmJTTlLMhI0XOJYo6m3kXjGeTQ4Fya+po6VKM+8lHA Lhv42BDhXWMOQaXeK3wtgdSW2Mk2hCntYfMi6oTdR52TsLfep3BNky17LU8tWBrrOBim 6j1H9yhv7jCDq8IpzbFa7oorOQYUN2WN1pmXDsmi+pxe3lxegRE47LkLVCFphGhamhMU wRwmM80i1n7/sNtJUQ8dkPB7Cuy1UUydS2Cm9Ja21l04cQ4tU9+9IpE02Zt2UsQohU7f oGcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698425954; x=1699030754; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=l2XOiyO7ELntzgtLuOwOBKhVQExybEKPgHk4URVDgho=; b=sfyj5tpvP/Tk+pndESDBUiDtTx4oXu3nBDODEPpF7V54MbKUaxtktueyvfqi/Uf6qU tdsyVqw/Q3qWI+i1331B3rRN3/L94c2R/QLKWTVVjGbd+WYAbP4EyeoHiBtVgZe+SiTo wWsDajLzwg0vuJp+J63HnXpKlwXFEPcsmry05hS69rZh+KUXM1F71row3XYvLHyFSCTW dBFN6V/277qdy4axvo3dq5KB666IxdPByCVnyPtOgey/LZge3qaAlsQP4vmbrt/sMM57 ANbo7L3pYtktJ+sVJ8xuy4M3ZrMEgPIw7DCo/wMxXKfnvDnuDZcXPSznIYGXceuDj2ek MO+Q== X-Gm-Message-State: AOJu0YxqKPNwGlZSjyPWA8mJKV+rwho6vHkl1KnCLPYOJJjoEjC2/RIX SbkcRjIjOk6Xg/oMc9EUCJc= X-Received: by 2002:a17:90a:1a0b:b0:280:1022:f00e with SMTP id 11-20020a17090a1a0b00b002801022f00emr1807988pjk.29.1698425954002; Fri, 27 Oct 2023 09:59:14 -0700 (PDT) Received: from localhost ([2a00:79e1:abd:4a00:6c80:7c10:75a0:44f4]) by smtp.gmail.com with ESMTPSA id s31-20020a17090a2f2200b0028017a2a8fasm733629pjd.3.2023.10.27.09.59.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 09:59:13 -0700 (PDT) From: Rob Clark <robdclark@gmail.com> To: dri-devel@lists.freedesktop.org Cc: freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, Rob Clark <robdclark@chromium.org>, Alex Deucher <alexander.deucher@amd.com>, amd-gfx@lists.freedesktop.org (open list:RADEON and AMDGPU DRM DRIVERS), Andrew Morton <akpm@linux-foundation.org>, Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com>, =?utf-8?q?Chris?= =?utf-8?q?tian_K=C3=B6nig?= <christian.koenig@amd.com>, Dong Chenchen <dongchenchen2@huawei.com>, Felix Kuehling <Felix.Kuehling@amd.com>, Guchun Chen <guchun.chen@amd.com>, Jack Xiao <Jack.Xiao@amd.com>, James Zhu <James.Zhu@amd.com>, Jonathan Kim <jonathan.kim@amd.com>, Lang Yu <Lang.Yu@amd.com>, linux-kernel@vger.kernel.org (open list), linux-pm@vger.kernel.org (open list:SUSPEND TO RAM), Luben Tuikov <luben.tuikov@amd.com>, Marijn Suijten <marijn.suijten@somainline.org>, Mario Limonciello <mario.limonciello@amd.com>, nouveau@lists.freedesktop.org (open list:DRM DRIVER FOR NVIDIA GEFORCE/QUADRO GPUS), Philip Yang <Philip.Yang@amd.com>, "Rafael J. Wysocki" <rafael@kernel.org>, Sean Paul <sean@poorly.run>, Shashank Sharma <shashank.sharma@amd.com>, Srinivasan Shanmugam <srinivasan.shanmugam@amd.com> Subject: [PATCH 0/7] drm/msm/gem: drm_exec conversion Date: Fri, 27 Oct 2023 09:58:34 -0700 Message-ID: <20231027165859.395638-1-robdclark@gmail.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 27 Oct 2023 09:59:47 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780928738430481204 X-GMAIL-MSGID: 1780928738430481204 |
Series |
drm/msm/gem: drm_exec conversion
|
|
Message
Rob Clark
Oct. 27, 2023, 4:58 p.m. UTC
From: Rob Clark <robdclark@chromium.org>
Simplify the exec path (removing a legacy optimization) and convert to
drm_exec. One drm_exec patch to allow passing in the expected # of GEM
objects to avoid re-allocation.
I'd be a bit happier if I could avoid the extra objects table allocation
in drm_exec in the first place, but wasn't really happy with any of the
things I tried to get rid of that.
Rob Clark (7):
drm/msm/gem: Remove "valid" tracking
drm/msm/gem: Remove submit_unlock_unpin_bo()
drm/msm/gem: Don't queue job to sched in error cases
drm/msm/gem: Split out submit_unpin_objects() helper
drm/msm/gem: Cleanup submit_cleanup_bo()
drm/exec: Pass in initial # of objects
drm/msm/gem: Convert to drm_exec
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 +-
drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c | 4 +-
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 4 +-
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 4 +-
drivers/gpu/drm/drm_exec.c | 15 +-
drivers/gpu/drm/msm/Kconfig | 1 +
drivers/gpu/drm/msm/msm_gem.h | 13 +-
drivers/gpu/drm/msm/msm_gem_submit.c | 197 ++++++------------------
drivers/gpu/drm/msm/msm_ringbuffer.c | 3 +-
drivers/gpu/drm/nouveau/nouveau_exec.c | 2 +-
drivers/gpu/drm/nouveau/nouveau_uvmm.c | 2 +-
include/drm/drm_exec.h | 2 +-
12 files changed, 79 insertions(+), 170 deletions(-)
Comments
Am 27.10.23 um 18:58 schrieb Rob Clark: > From: Rob Clark <robdclark@chromium.org> > > In cases where the # is known ahead of time, it is silly to do the table > resize dance. Ah, yes that was my initial implementation as well, but I ditched that because nobody actually used it. One comment below. > > Signed-off-by: Rob Clark <robdclark@chromium.org> > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 +- > drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c | 4 ++-- > drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 4 ++-- > drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 4 ++-- > drivers/gpu/drm/drm_exec.c | 15 ++++++++++++--- > drivers/gpu/drm/nouveau/nouveau_exec.c | 2 +- > drivers/gpu/drm/nouveau/nouveau_uvmm.c | 2 +- > include/drm/drm_exec.h | 2 +- > 8 files changed, 22 insertions(+), 13 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c > index efdb1c48f431..d27ca8f61929 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c > @@ -65,7 +65,7 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, > } > > amdgpu_sync_create(&p->sync); > - drm_exec_init(&p->exec, DRM_EXEC_INTERRUPTIBLE_WAIT); > + drm_exec_init(&p->exec, DRM_EXEC_INTERRUPTIBLE_WAIT, 0); > return 0; > } > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c > index 720011019741..796fa6f1420b 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c > @@ -70,7 +70,7 @@ int amdgpu_map_static_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm, > struct drm_exec exec; > int r; > > - drm_exec_init(&exec, DRM_EXEC_INTERRUPTIBLE_WAIT); > + drm_exec_init(&exec, DRM_EXEC_INTERRUPTIBLE_WAIT, 0); > drm_exec_until_all_locked(&exec) { > r = amdgpu_vm_lock_pd(vm, &exec, 0); > if (likely(!r)) > @@ -110,7 +110,7 @@ int amdgpu_unmap_static_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm, > struct drm_exec exec; > int r; > > - drm_exec_init(&exec, DRM_EXEC_INTERRUPTIBLE_WAIT); > + drm_exec_init(&exec, DRM_EXEC_INTERRUPTIBLE_WAIT, 0); > drm_exec_until_all_locked(&exec) { > r = amdgpu_vm_lock_pd(vm, &exec, 0); > if (likely(!r)) > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c > index ca4d2d430e28..16f1715148ad 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c > @@ -203,7 +203,7 @@ static void amdgpu_gem_object_close(struct drm_gem_object *obj, > struct drm_exec exec; > long r; > > - drm_exec_init(&exec, DRM_EXEC_IGNORE_DUPLICATES); > + drm_exec_init(&exec, DRM_EXEC_IGNORE_DUPLICATES, 0); > drm_exec_until_all_locked(&exec) { > r = drm_exec_prepare_obj(&exec, &bo->tbo.base, 1); > drm_exec_retry_on_contention(&exec); > @@ -739,7 +739,7 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data, > } > > drm_exec_init(&exec, DRM_EXEC_INTERRUPTIBLE_WAIT | > - DRM_EXEC_IGNORE_DUPLICATES); > + DRM_EXEC_IGNORE_DUPLICATES, 0); > drm_exec_until_all_locked(&exec) { > if (gobj) { > r = drm_exec_lock_obj(&exec, gobj); > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c > index b6015157763a..3c351941701e 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c > @@ -1105,7 +1105,7 @@ int amdgpu_mes_ctx_map_meta_data(struct amdgpu_device *adev, > > amdgpu_sync_create(&sync); > > - drm_exec_init(&exec, 0); > + drm_exec_init(&exec, 0, 0); > drm_exec_until_all_locked(&exec) { > r = drm_exec_lock_obj(&exec, > &ctx_data->meta_data_obj->tbo.base); > @@ -1176,7 +1176,7 @@ int amdgpu_mes_ctx_unmap_meta_data(struct amdgpu_device *adev, > struct drm_exec exec; > long r; > > - drm_exec_init(&exec, 0); > + drm_exec_init(&exec, 0, 0); > drm_exec_until_all_locked(&exec) { > r = drm_exec_lock_obj(&exec, > &ctx_data->meta_data_obj->tbo.base); > diff --git a/drivers/gpu/drm/drm_exec.c b/drivers/gpu/drm/drm_exec.c > index 5d2809de4517..27d11c20d148 100644 > --- a/drivers/gpu/drm/drm_exec.c > +++ b/drivers/gpu/drm/drm_exec.c > @@ -69,16 +69,25 @@ static void drm_exec_unlock_all(struct drm_exec *exec) > * drm_exec_init - initialize a drm_exec object > * @exec: the drm_exec object to initialize > * @flags: controls locking behavior, see DRM_EXEC_* defines > + * @nr: the initial # of objects > * > * Initialize the object and make sure that we can track locked objects. > + * > + * If nr is non-zero then it is used as the initial objects table size. > + * In either case, the table will grow (be re-allocated) on demand. > */ > -void drm_exec_init(struct drm_exec *exec, uint32_t flags) > +void drm_exec_init(struct drm_exec *exec, uint32_t flags, unsigned nr) > { > + size_t sz = PAGE_SIZE; > + > + if (nr) > + sz = (size_t)nr * sizeof(void *); > + > exec->flags = flags; > - exec->objects = kmalloc(PAGE_SIZE, GFP_KERNEL); > + exec->objects = kmalloc(sz, GFP_KERNEL); Please use k*v*malloc() here since we can't predict how large that will be. With that fixed the patch is Reviewed-by: Christian König <christian.koenig@amd.com>. Regards, Christian. > > /* If allocation here fails, just delay that till the first use */ > - exec->max_objects = exec->objects ? PAGE_SIZE / sizeof(void *) : 0; > + exec->max_objects = exec->objects ? sz / sizeof(void *) : 0; > exec->num_objects = 0; > exec->contended = DRM_EXEC_DUMMY; > exec->prelocked = NULL; > diff --git a/drivers/gpu/drm/nouveau/nouveau_exec.c b/drivers/gpu/drm/nouveau/nouveau_exec.c > index 19024ce21fbb..f5930cc0b3fb 100644 > --- a/drivers/gpu/drm/nouveau/nouveau_exec.c > +++ b/drivers/gpu/drm/nouveau/nouveau_exec.c > @@ -103,7 +103,7 @@ nouveau_exec_job_submit(struct nouveau_job *job) > > nouveau_uvmm_lock(uvmm); > drm_exec_init(exec, DRM_EXEC_INTERRUPTIBLE_WAIT | > - DRM_EXEC_IGNORE_DUPLICATES); > + DRM_EXEC_IGNORE_DUPLICATES, 0); > drm_exec_until_all_locked(exec) { > struct drm_gpuva *va; > > diff --git a/drivers/gpu/drm/nouveau/nouveau_uvmm.c b/drivers/gpu/drm/nouveau/nouveau_uvmm.c > index aae780e4a4aa..3a9331a1c830 100644 > --- a/drivers/gpu/drm/nouveau/nouveau_uvmm.c > +++ b/drivers/gpu/drm/nouveau/nouveau_uvmm.c > @@ -1288,7 +1288,7 @@ nouveau_uvmm_bind_job_submit(struct nouveau_job *job) > } > > drm_exec_init(exec, DRM_EXEC_INTERRUPTIBLE_WAIT | > - DRM_EXEC_IGNORE_DUPLICATES); > + DRM_EXEC_IGNORE_DUPLICATES, 0); > drm_exec_until_all_locked(exec) { > list_for_each_op(op, &bind_job->ops) { > struct drm_gpuva_op *va_op; > diff --git a/include/drm/drm_exec.h b/include/drm/drm_exec.h > index b5bf0b6da791..f1a66c048721 100644 > --- a/include/drm/drm_exec.h > +++ b/include/drm/drm_exec.h > @@ -135,7 +135,7 @@ static inline bool drm_exec_is_contended(struct drm_exec *exec) > return !!exec->contended; > } > > -void drm_exec_init(struct drm_exec *exec, uint32_t flags); > +void drm_exec_init(struct drm_exec *exec, uint32_t flags, unsigned nr); > void drm_exec_fini(struct drm_exec *exec); > bool drm_exec_cleanup(struct drm_exec *exec); > int drm_exec_lock_obj(struct drm_exec *exec, struct drm_gem_object *obj);