From patchwork Wed Jul 12 12:46:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 13310326 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 37B4FEB64DD for ; Wed, 12 Jul 2023 12:47:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EFC0310E513; Wed, 12 Jul 2023 12:47:22 +0000 (UTC) Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by gabe.freedesktop.org (Postfix) with ESMTPS id DF65910E082; Wed, 12 Jul 2023 12:47:09 +0000 (UTC) Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-307d20548adso6970703f8f.0; Wed, 12 Jul 2023 05:47:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689166028; x=1691758028; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tdCxVQY6zUD0NCu5CO0Sn71XJFnwoJPf6cyzKz5R28s=; b=IvEQ4+8vz0AgSJGoItrIZIu5+p7CghVfK6454DuKK+na4ysuLbtbvORDgAjn1gUotJ WH3R06GpkuxO9c59yZw5RZ4vKILg64plzT4FdDrI4zzaz/ZhMTQBJWPB5GCF38gd0KR+ Y4vFrvZLceQBUGLkDGFydq6bUEY1hnY2FFaWX/L5jQzVYGBYPHDkdtfeqwGbXwiBotet NEJvBBoEY5au+bw1cOiPm4jZvXrVEXE25sbU5RaxiTG8XsS36hJvi6v+expfTBCTkiE7 nZiKbnyQ6lVoM/JWgPBKsMiBOyDTNQvL0bOZ8Irm1cp2xnZkde1DD9gzLB0EwYruOHuH 3TAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689166028; x=1691758028; 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=tdCxVQY6zUD0NCu5CO0Sn71XJFnwoJPf6cyzKz5R28s=; b=aWkb8s6oSYJc84+p+d6mq/3zFoOLtK+wmQMbJsFXD5axlEycoPv4l1t0D2f65Wk7dM 02+FHXw7FYu81siwXw8f8UVA10dCvatM2w5FYQt60f+V90mY8/Ls/OZyM8ndamjA3MhM I3A/ZmcbH0kZl1A0/815ytKAMs5ilsFN7DpkAwJFn+LsHY3CMdRqf8UbrGL9BLt/Adhl q8TxPUMjx1ALpBRZU35JYrqnFPV1l9XGvmNyUPPNqQdyf37KIqaRsLwh9ir2F9C6DjI4 SwQ4Qztt70Kkcgxg3OLrN5Z5iQatfFZJUHzAg15FqqAAVgQYkky0dr17C+Nvpls98g4V S0TQ== X-Gm-Message-State: ABy/qLaMs0xwu/ZlZWBcVc5ZQwFnP9waMauzCQoSuuUhetWYgVY9iuL6 4jNIpZlAUICMG2ouOEosrbrNIazcnvY= X-Google-Smtp-Source: APBJJlGR80N/UcbSuewCFc/CgH5nSwFNyLqKuJvb63uLTILtLrC0BY6DmdVGbPYTuL5axL5dbuQCBg== X-Received: by 2002:a5d:43ca:0:b0:2d1:3eb9:c3c2 with SMTP id v10-20020a5d43ca000000b002d13eb9c3c2mr15217334wrr.54.1689166027596; Wed, 12 Jul 2023 05:47:07 -0700 (PDT) Received: from EliteBook.fritz.box ([2a00:e180:1557:4100:d4c4:2bb7:77d6:6d86]) by smtp.gmail.com with ESMTPSA id j8-20020adfe508000000b0031424950a99sm4989225wrm.81.2023.07.12.05.47.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 05:47:07 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/7] drm/radeon: switch over to drm_exec Date: Wed, 12 Jul 2023 14:46:58 +0200 Message-Id: <20230712124704.333004-2-christian.koenig@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230712124704.333004-1-christian.koenig@amd.com> References: <20230712124704.333004-1-christian.koenig@amd.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Christian_K=C3=B6nig?= , amd-gfx@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Just a straightforward conversion without any optimization. Signed-off-by: Christian König Cc: amd-gfx@lists.freedesktop.org --- drivers/gpu/drm/radeon/Kconfig | 1 + drivers/gpu/drm/radeon/radeon.h | 7 ++-- drivers/gpu/drm/radeon/radeon_cs.c | 45 +++++++++++++------------- drivers/gpu/drm/radeon/radeon_gem.c | 39 ++++++++++++---------- drivers/gpu/drm/radeon/radeon_object.c | 25 +++++++------- drivers/gpu/drm/radeon/radeon_object.h | 2 +- drivers/gpu/drm/radeon/radeon_vm.c | 10 +++--- 7 files changed, 66 insertions(+), 63 deletions(-) diff --git a/drivers/gpu/drm/radeon/Kconfig b/drivers/gpu/drm/radeon/Kconfig index fe498c8af1bb..fdfede471a6d 100644 --- a/drivers/gpu/drm/radeon/Kconfig +++ b/drivers/gpu/drm/radeon/Kconfig @@ -12,6 +12,7 @@ config DRM_RADEON select DRM_TTM select DRM_TTM_HELPER select FB_IO_HELPERS if DRM_FBDEV_EMULATION + select DRM_EXEC select SND_HDA_COMPONENT if SND_HDA_CORE select POWER_SUPPLY select HWMON diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index 8afb03bbce29..37a932a5195f 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h @@ -75,8 +75,8 @@ #include #include -#include +#include #include #include #include @@ -458,7 +458,8 @@ struct radeon_mman { struct radeon_bo_list { struct radeon_bo *robj; - struct ttm_validate_buffer tv; + struct list_head list; + bool shared; uint64_t gpu_offset; unsigned preferred_domains; unsigned allowed_domains; @@ -1031,6 +1032,7 @@ struct radeon_cs_parser { struct radeon_bo_list *vm_bos; struct list_head validated; unsigned dma_reloc_idx; + struct drm_exec exec; /* indices of various chunks */ struct radeon_cs_chunk *chunk_ib; struct radeon_cs_chunk *chunk_relocs; @@ -1044,7 +1046,6 @@ struct radeon_cs_parser { u32 cs_flags; u32 ring; s32 priority; - struct ww_acquire_ctx ticket; }; static inline u32 radeon_get_ib_value(struct radeon_cs_parser *p, int idx) diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c index a6700d7278bf..ea0a1ed56bd8 100644 --- a/drivers/gpu/drm/radeon/radeon_cs.c +++ b/drivers/gpu/drm/radeon/radeon_cs.c @@ -182,11 +182,8 @@ static int radeon_cs_parser_relocs(struct radeon_cs_parser *p) } } - p->relocs[i].tv.bo = &p->relocs[i].robj->tbo; - p->relocs[i].tv.num_shared = !r->write_domain; - - radeon_cs_buckets_add(&buckets, &p->relocs[i].tv.head, - priority); + p->relocs[i].shared = !r->write_domain; + radeon_cs_buckets_add(&buckets, &p->relocs[i].list, priority); } radeon_cs_buckets_get_list(&buckets, &p->validated); @@ -197,7 +194,7 @@ static int radeon_cs_parser_relocs(struct radeon_cs_parser *p) if (need_mmap_lock) mmap_read_lock(current->mm); - r = radeon_bo_list_validate(p->rdev, &p->ticket, &p->validated, p->ring); + r = radeon_bo_list_validate(p->rdev, &p->exec, &p->validated, p->ring); if (need_mmap_lock) mmap_read_unlock(current->mm); @@ -253,12 +250,11 @@ static int radeon_cs_sync_rings(struct radeon_cs_parser *p) struct radeon_bo_list *reloc; int r; - list_for_each_entry(reloc, &p->validated, tv.head) { + list_for_each_entry(reloc, &p->validated, list) { struct dma_resv *resv; resv = reloc->robj->tbo.base.resv; - r = radeon_sync_resv(p->rdev, &p->ib.sync, resv, - reloc->tv.num_shared); + r = radeon_sync_resv(p->rdev, &p->ib.sync, resv, reloc->shared); if (r) return r; } @@ -276,6 +272,7 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data) s32 priority = 0; INIT_LIST_HEAD(&p->validated); + drm_exec_init(&p->exec, DRM_EXEC_INTERRUPTIBLE_WAIT); if (!cs->num_chunks) { return 0; @@ -397,8 +394,8 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data) static int cmp_size_smaller_first(void *priv, const struct list_head *a, const struct list_head *b) { - struct radeon_bo_list *la = list_entry(a, struct radeon_bo_list, tv.head); - struct radeon_bo_list *lb = list_entry(b, struct radeon_bo_list, tv.head); + struct radeon_bo_list *la = list_entry(a, struct radeon_bo_list, list); + struct radeon_bo_list *lb = list_entry(b, struct radeon_bo_list, list); /* Sort A before B if A is smaller. */ if (la->robj->tbo.base.size > lb->robj->tbo.base.size) @@ -417,11 +414,13 @@ static int cmp_size_smaller_first(void *priv, const struct list_head *a, * If error is set than unvalidate buffer, otherwise just free memory * used by parsing context. **/ -static void radeon_cs_parser_fini(struct radeon_cs_parser *parser, int error, bool backoff) +static void radeon_cs_parser_fini(struct radeon_cs_parser *parser, int error) { unsigned i; if (!error) { + struct radeon_bo_list *reloc; + /* Sort the buffer list from the smallest to largest buffer, * which affects the order of buffers in the LRU list. * This assures that the smallest buffers are added first @@ -433,15 +432,17 @@ static void radeon_cs_parser_fini(struct radeon_cs_parser *parser, int error, bo * per frame under memory pressure. */ list_sort(NULL, &parser->validated, cmp_size_smaller_first); - - ttm_eu_fence_buffer_objects(&parser->ticket, - &parser->validated, - &parser->ib.fence->base); - } else if (backoff) { - ttm_eu_backoff_reservation(&parser->ticket, - &parser->validated); + list_for_each_entry(reloc, &parser->validated, list) { + dma_resv_add_fence(reloc->robj->tbo.base.resv, + &parser->ib.fence->base, + reloc->shared ? + DMA_RESV_USAGE_READ : + DMA_RESV_USAGE_WRITE); + } } + drm_exec_fini(&parser->exec); + if (parser->relocs != NULL) { for (i = 0; i < parser->nrelocs; i++) { struct radeon_bo *bo = parser->relocs[i].robj; @@ -693,7 +694,7 @@ int radeon_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) r = radeon_cs_parser_init(&parser, data); if (r) { DRM_ERROR("Failed to initialize parser !\n"); - radeon_cs_parser_fini(&parser, r, false); + radeon_cs_parser_fini(&parser, r); up_read(&rdev->exclusive_lock); r = radeon_cs_handle_lockup(rdev, r); return r; @@ -707,7 +708,7 @@ int radeon_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) } if (r) { - radeon_cs_parser_fini(&parser, r, false); + radeon_cs_parser_fini(&parser, r); up_read(&rdev->exclusive_lock); r = radeon_cs_handle_lockup(rdev, r); return r; @@ -724,7 +725,7 @@ int radeon_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) goto out; } out: - radeon_cs_parser_fini(&parser, r, true); + radeon_cs_parser_fini(&parser, r); up_read(&rdev->exclusive_lock); r = radeon_cs_handle_lockup(rdev, r); return r; diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c index d0119c5f7eb3..3af518895603 100644 --- a/drivers/gpu/drm/radeon/radeon_gem.c +++ b/drivers/gpu/drm/radeon/radeon_gem.c @@ -623,33 +623,40 @@ int radeon_gem_get_tiling_ioctl(struct drm_device *dev, void *data, static void radeon_gem_va_update_vm(struct radeon_device *rdev, struct radeon_bo_va *bo_va) { - struct ttm_validate_buffer tv, *entry; - struct radeon_bo_list *vm_bos; - struct ww_acquire_ctx ticket; + struct radeon_bo_list *vm_bos, *entry; struct list_head list; + struct drm_exec exec; unsigned domain; int r; INIT_LIST_HEAD(&list); - tv.bo = &bo_va->bo->tbo; - tv.num_shared = 1; - list_add(&tv.head, &list); - vm_bos = radeon_vm_get_bos(rdev, bo_va->vm, &list); if (!vm_bos) return; - r = ttm_eu_reserve_buffers(&ticket, &list, true, NULL); - if (r) - goto error_free; + drm_exec_init(&exec, DRM_EXEC_INTERRUPTIBLE_WAIT); + drm_exec_until_all_locked(&exec) { + list_for_each_entry(entry, &list, list) { + r = drm_exec_prepare_obj(&exec, &entry->robj->tbo.base, + 1); + drm_exec_retry_on_contention(&exec); + if (unlikely(r)) + goto error_cleanup; + } - list_for_each_entry(entry, &list, head) { - domain = radeon_mem_type_to_domain(entry->bo->resource->mem_type); + r = drm_exec_prepare_obj(&exec, &bo_va->bo->tbo.base, 1); + drm_exec_retry_on_contention(&exec); + if (unlikely(r)) + goto error_cleanup; + } + + list_for_each_entry(entry, &list, list) { + domain = radeon_mem_type_to_domain(entry->robj->tbo.resource->mem_type); /* if anything is swapped out don't swap it in here, just abort and wait for the next CS */ if (domain == RADEON_GEM_DOMAIN_CPU) - goto error_unreserve; + goto error_cleanup; } mutex_lock(&bo_va->vm->mutex); @@ -663,10 +670,8 @@ static void radeon_gem_va_update_vm(struct radeon_device *rdev, error_unlock: mutex_unlock(&bo_va->vm->mutex); -error_unreserve: - ttm_eu_backoff_reservation(&ticket, &list); - -error_free: +error_cleanup: + drm_exec_fini(&exec); kvfree(vm_bos); if (r && r != -ERESTARTSYS) diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c index 10c0fbd9d2b4..e47f04c001b8 100644 --- a/drivers/gpu/drm/radeon/radeon_object.c +++ b/drivers/gpu/drm/radeon/radeon_object.c @@ -468,23 +468,26 @@ static u64 radeon_bo_get_threshold_for_moves(struct radeon_device *rdev) } int radeon_bo_list_validate(struct radeon_device *rdev, - struct ww_acquire_ctx *ticket, + struct drm_exec *exec, struct list_head *head, int ring) { struct ttm_operation_ctx ctx = { true, false }; struct radeon_bo_list *lobj; - struct list_head duplicates; - int r; u64 bytes_moved = 0, initial_bytes_moved; u64 bytes_moved_threshold = radeon_bo_get_threshold_for_moves(rdev); + int r; - INIT_LIST_HEAD(&duplicates); - r = ttm_eu_reserve_buffers(ticket, head, true, &duplicates); - if (unlikely(r != 0)) { - return r; + drm_exec_until_all_locked(exec) { + list_for_each_entry(lobj, head, list) { + r = drm_exec_prepare_obj(exec, &lobj->robj->tbo.base, + 1); + drm_exec_retry_on_contention(exec); + if (unlikely(r && r != -EALREADY)) + return r; + } } - list_for_each_entry(lobj, head, tv.head) { + list_for_each_entry(lobj, head, list) { struct radeon_bo *bo = lobj->robj; if (!bo->tbo.pin_count) { u32 domain = lobj->preferred_domains; @@ -523,7 +526,6 @@ int radeon_bo_list_validate(struct radeon_device *rdev, domain = lobj->allowed_domains; goto retry; } - ttm_eu_backoff_reservation(ticket, head); return r; } } @@ -531,11 +533,6 @@ int radeon_bo_list_validate(struct radeon_device *rdev, lobj->tiling_flags = bo->tiling_flags; } - list_for_each_entry(lobj, &duplicates, tv.head) { - lobj->gpu_offset = radeon_bo_gpu_offset(lobj->robj); - lobj->tiling_flags = lobj->robj->tiling_flags; - } - return 0; } diff --git a/drivers/gpu/drm/radeon/radeon_object.h b/drivers/gpu/drm/radeon/radeon_object.h index 39cc87a59a9a..d7bbb52db546 100644 --- a/drivers/gpu/drm/radeon/radeon_object.h +++ b/drivers/gpu/drm/radeon/radeon_object.h @@ -152,7 +152,7 @@ extern void radeon_bo_force_delete(struct radeon_device *rdev); extern int radeon_bo_init(struct radeon_device *rdev); extern void radeon_bo_fini(struct radeon_device *rdev); extern int radeon_bo_list_validate(struct radeon_device *rdev, - struct ww_acquire_ctx *ticket, + struct drm_exec *exec, struct list_head *head, int ring); extern int radeon_bo_set_tiling_flags(struct radeon_bo *bo, u32 tiling_flags, u32 pitch); diff --git a/drivers/gpu/drm/radeon/radeon_vm.c b/drivers/gpu/drm/radeon/radeon_vm.c index 987cabbf1318..647c4a07d92a 100644 --- a/drivers/gpu/drm/radeon/radeon_vm.c +++ b/drivers/gpu/drm/radeon/radeon_vm.c @@ -142,10 +142,9 @@ struct radeon_bo_list *radeon_vm_get_bos(struct radeon_device *rdev, list[0].robj = vm->page_directory; list[0].preferred_domains = RADEON_GEM_DOMAIN_VRAM; list[0].allowed_domains = RADEON_GEM_DOMAIN_VRAM; - list[0].tv.bo = &vm->page_directory->tbo; - list[0].tv.num_shared = 1; + list[0].shared = true; list[0].tiling_flags = 0; - list_add(&list[0].tv.head, head); + list_add(&list[0].list, head); for (i = 0, idx = 1; i <= vm->max_pde_used; i++) { if (!vm->page_tables[i].bo) @@ -154,10 +153,9 @@ struct radeon_bo_list *radeon_vm_get_bos(struct radeon_device *rdev, list[idx].robj = vm->page_tables[i].bo; list[idx].preferred_domains = RADEON_GEM_DOMAIN_VRAM; list[idx].allowed_domains = RADEON_GEM_DOMAIN_VRAM; - list[idx].tv.bo = &list[idx].robj->tbo; - list[idx].tv.num_shared = 1; + list[idx].shared = true; list[idx].tiling_flags = 0; - list_add(&list[idx++].tv.head, head); + list_add(&list[idx++].list, head); } return list; From patchwork Wed Jul 12 12:46:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 13310327 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 04B8BEB64DA for ; Wed, 12 Jul 2023 12:47:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F179D10E51E; Wed, 12 Jul 2023 12:47:23 +0000 (UTC) Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by gabe.freedesktop.org (Postfix) with ESMTPS id CFD9910E501; Wed, 12 Jul 2023 12:47:10 +0000 (UTC) Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-3110ab7110aso7511442f8f.3; Wed, 12 Jul 2023 05:47:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689166029; x=1691758029; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MyjcGW684jqraSNBZ8B7xVADXgFfF/OvzrpaGLGUOqc=; b=L0uYEDkUPkUDMI3OPLD9CxQwdAnA3ZPcshnf3sYSx/oONyUzYTpol94z6/pY6zsvZK oGxwKsqiQoRaZIKjwaMg2QOlTDOdtDl8yBCfaBEmK86Y34WxdaOwPvvASHCxmpuf5I+n U9cMw3vO3QiQ3eDcqT89yOrLtWlXO8YJsM606NSAbfhkHybQZRiIt9iecCa7+JlFfGfx 2i8HQmbc4INvJlMjGAIxca31pNTOnJr8vfs/bXgcvnhds/ENY9BJ52cxIb2cpvKk5Ctu tzxykmEinkadJt2k2W56pbGxYG42qgsjeamwPV5mGHB0lMp+au0dkkEPZUECGUpYqmJB 3vbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689166029; x=1691758029; 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=MyjcGW684jqraSNBZ8B7xVADXgFfF/OvzrpaGLGUOqc=; b=FikfXfm9m4s3XVkgqpXpULKfaKMKqIt2XdA8DWKqdDfkr6Yne1BwLTyzH6pUqz8I74 sAlcRkhLhVKhELsXn7hSUASuUl8Bp3RH7MxeJwva0n7+wmPJH6v7vFvYIJL+tG5csEgS qL43eVJUptmO96TCW6JoXypMz1C0j2P7jpFUgX5/GU5vMMljbLFDmOdg3sIsVHQRefwj Z1s2mkcZY15kl+Eo9+OJaQM7aEjwW05x3ZwfMLPV0O9ABETkr+wsK412zVxoJfgQqbJq 1jzGwSUOnqbUsKFzgfNRGqnpV408JJXb4Kt1WaD2IZxabgpMhnzMGvD+mqbK5AB7XTPV IDKg== X-Gm-Message-State: ABy/qLaIrOXIBy0v1Dt0W9dF+lYqv1FvPV+ZOpCqF1duG95Z47lXRbdC BU8WCHB89YORPuoZh8WGv+hFDJLQxZI= X-Google-Smtp-Source: APBJJlH53nWP6tXBO9qvMZ5Itj/kes9j4QMcFPGjT3TnBVVMQLp0fABfiiW6hCZrDpY446sVVZtT2w== X-Received: by 2002:a5d:4608:0:b0:314:3c84:4da2 with SMTP id t8-20020a5d4608000000b003143c844da2mr18941166wrq.13.1689166028574; Wed, 12 Jul 2023 05:47:08 -0700 (PDT) Received: from EliteBook.fritz.box ([2a00:e180:1557:4100:d4c4:2bb7:77d6:6d86]) by smtp.gmail.com with ESMTPSA id j8-20020adfe508000000b0031424950a99sm4989225wrm.81.2023.07.12.05.47.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 05:47:08 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/7] drm/qxl: switch to using drm_exec Date: Wed, 12 Jul 2023 14:46:59 +0200 Message-Id: <20230712124704.333004-3-christian.koenig@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230712124704.333004-1-christian.koenig@amd.com> References: <20230712124704.333004-1-christian.koenig@amd.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: spice-devel@lists.freedesktop.org, Dave Airlie , virtualization@lists.linux-foundation.org, =?utf-8?q?Christian_K=C3=B6nig?= , Gerd Hoffmann Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Just a straightforward conversion without any optimization. Only compile tested for now. Signed-off-by: Christian König Cc: Dave Airlie Cc: Gerd Hoffmann Cc: virtualization@lists.linux-foundation.org Cc: spice-devel@lists.freedesktop.org --- drivers/gpu/drm/qxl/Kconfig | 1 + drivers/gpu/drm/qxl/qxl_drv.h | 7 ++-- drivers/gpu/drm/qxl/qxl_release.c | 68 ++++++++++++++++--------------- 3 files changed, 40 insertions(+), 36 deletions(-) diff --git a/drivers/gpu/drm/qxl/Kconfig b/drivers/gpu/drm/qxl/Kconfig index ca3f51c2a8fe..9c8e433be33e 100644 --- a/drivers/gpu/drm/qxl/Kconfig +++ b/drivers/gpu/drm/qxl/Kconfig @@ -5,6 +5,7 @@ config DRM_QXL select DRM_KMS_HELPER select DRM_TTM select DRM_TTM_HELPER + select DRM_EXEC select CRC32 help QXL virtual GPU for Spice virtualization desktop integration. diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h index ea993d7162e8..3e732648b332 100644 --- a/drivers/gpu/drm/qxl/qxl_drv.h +++ b/drivers/gpu/drm/qxl/qxl_drv.h @@ -38,12 +38,12 @@ #include #include +#include #include #include #include #include #include -#include #include #include "qxl_dev.h" @@ -101,7 +101,8 @@ struct qxl_gem { }; struct qxl_bo_list { - struct ttm_validate_buffer tv; + struct qxl_bo *bo; + struct list_head list; }; struct qxl_crtc { @@ -151,7 +152,7 @@ struct qxl_release { struct qxl_bo *release_bo; uint32_t release_offset; uint32_t surface_release_id; - struct ww_acquire_ctx ticket; + struct drm_exec exec; struct list_head bos; }; diff --git a/drivers/gpu/drm/qxl/qxl_release.c b/drivers/gpu/drm/qxl/qxl_release.c index 368d26da0d6a..5953e8ed5f47 100644 --- a/drivers/gpu/drm/qxl/qxl_release.c +++ b/drivers/gpu/drm/qxl/qxl_release.c @@ -121,13 +121,11 @@ qxl_release_free_list(struct qxl_release *release) { while (!list_empty(&release->bos)) { struct qxl_bo_list *entry; - struct qxl_bo *bo; entry = container_of(release->bos.next, - struct qxl_bo_list, tv.head); - bo = to_qxl_bo(entry->tv.bo); - qxl_bo_unref(&bo); - list_del(&entry->tv.head); + struct qxl_bo_list, list); + qxl_bo_unref(&entry->bo); + list_del(&entry->list); kfree(entry); } release->release_bo = NULL; @@ -172,8 +170,8 @@ int qxl_release_list_add(struct qxl_release *release, struct qxl_bo *bo) { struct qxl_bo_list *entry; - list_for_each_entry(entry, &release->bos, tv.head) { - if (entry->tv.bo == &bo->tbo) + list_for_each_entry(entry, &release->bos, list) { + if (entry->bo == bo) return 0; } @@ -182,9 +180,8 @@ int qxl_release_list_add(struct qxl_release *release, struct qxl_bo *bo) return -ENOMEM; qxl_bo_ref(bo); - entry->tv.bo = &bo->tbo; - entry->tv.num_shared = 0; - list_add_tail(&entry->tv.head, &release->bos); + entry->bo = bo; + list_add_tail(&entry->list, &release->bos); return 0; } @@ -221,21 +218,28 @@ int qxl_release_reserve_list(struct qxl_release *release, bool no_intr) if (list_is_singular(&release->bos)) return 0; - ret = ttm_eu_reserve_buffers(&release->ticket, &release->bos, - !no_intr, NULL); - if (ret) - return ret; - - list_for_each_entry(entry, &release->bos, tv.head) { - struct qxl_bo *bo = to_qxl_bo(entry->tv.bo); - - ret = qxl_release_validate_bo(bo); - if (ret) { - ttm_eu_backoff_reservation(&release->ticket, &release->bos); - return ret; + drm_exec_init(&release->exec, no_intr ? 0 : + DRM_EXEC_INTERRUPTIBLE_WAIT); + drm_exec_until_all_locked(&release->exec) { + list_for_each_entry(entry, &release->bos, list) { + ret = drm_exec_prepare_obj(&release->exec, + &entry->bo->tbo.base, + 1); + drm_exec_retry_on_contention(&release->exec); + if (ret) + goto error; } } + + list_for_each_entry(entry, &release->bos, list) { + ret = qxl_release_validate_bo(entry->bo); + if (ret) + goto error; + } return 0; +error: + drm_exec_fini(&release->exec); + return ret; } void qxl_release_backoff_reserve_list(struct qxl_release *release) @@ -245,7 +249,7 @@ void qxl_release_backoff_reserve_list(struct qxl_release *release) if (list_is_singular(&release->bos)) return; - ttm_eu_backoff_reservation(&release->ticket, &release->bos); + drm_exec_fini(&release->exec); } int qxl_alloc_surface_release_reserved(struct qxl_device *qdev, @@ -404,18 +408,18 @@ void qxl_release_unmap(struct qxl_device *qdev, void qxl_release_fence_buffer_objects(struct qxl_release *release) { - struct ttm_buffer_object *bo; struct ttm_device *bdev; - struct ttm_validate_buffer *entry; + struct qxl_bo_list *entry; struct qxl_device *qdev; + struct qxl_bo *bo; /* if only one object on the release its the release itself since these objects are pinned no need to reserve */ if (list_is_singular(&release->bos) || list_empty(&release->bos)) return; - bo = list_first_entry(&release->bos, struct ttm_validate_buffer, head)->bo; - bdev = bo->bdev; + bo = list_first_entry(&release->bos, struct qxl_bo_list, list)->bo; + bdev = bo->tbo.bdev; qdev = container_of(bdev, struct qxl_device, mman.bdev); /* @@ -426,14 +430,12 @@ void qxl_release_fence_buffer_objects(struct qxl_release *release) release->id | 0xf0000000, release->base.seqno); trace_dma_fence_emit(&release->base); - list_for_each_entry(entry, &release->bos, head) { + list_for_each_entry(entry, &release->bos, list) { bo = entry->bo; - dma_resv_add_fence(bo->base.resv, &release->base, + dma_resv_add_fence(bo->tbo.base.resv, &release->base, DMA_RESV_USAGE_READ); - ttm_bo_move_to_lru_tail_unlocked(bo); - dma_resv_unlock(bo->base.resv); + ttm_bo_move_to_lru_tail_unlocked(&bo->tbo); } - ww_acquire_fini(&release->ticket); + drm_exec_fini(&release->exec); } - From patchwork Wed Jul 12 12:47:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 13310322 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 64C21EB64D9 for ; Wed, 12 Jul 2023 12:47:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 727C210E512; Wed, 12 Jul 2023 12:47:13 +0000 (UTC) Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8E03410E512; Wed, 12 Jul 2023 12:47:11 +0000 (UTC) Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-31441bc0092so6833961f8f.1; Wed, 12 Jul 2023 05:47:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689166029; x=1691758029; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jHB85lYYuoXRXeEQBJlN9+erRgQ0YNtnpeexgtMqiNU=; b=qUFXD++gJJEq867Q8tMMLt3APs9rY8R1KsFUZX9ygraxxQsPbTiK6NaW9YkUnHz1bB HBh9RSF59Eu+/Ryh5xOM3tm956ZXSroQYehKCbC9QlvpWmvKX+GttKQhHaVwtBblgnmd c+RjkNEpnJ1+Z+PvSgPK0hL0/3yZa701f1397CZS64Jvg7ijcmi90aAZZLhoJi37oJqF Hinm18l2aF1eIpPquee+eCSgUAXK3VH2IKCkKrl2Uwsq+BkPULyCGjvCHuXPJWizlh4D TieHa9JU1AO796vPd/NLb6eJUjy6QGl/u/58UkSKPq3cUnQa85Oh8B+XDY2gYMbgNPFU H9+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689166029; x=1691758029; 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=jHB85lYYuoXRXeEQBJlN9+erRgQ0YNtnpeexgtMqiNU=; b=ZEIsJYa8kzhtUtrAVgWp1nyKWx3VHPuufidG7MTJT22RbEa/sPm1rGJ2IeCeGHqVlZ cATrwbgV7rIz58unNyY6An22ybyO2qaVVzyT87/B+cLmcOc2OSc2IO1b6nglTRPoUZZa zL5MLrnKwSi6D6RPCThZjpvhFy6KtUI7ztS8Ev0Htrdm8eDu/x1YJD5Nmoodo4MJy+bo jqFHIvRiVFdddeC+4k0lJC/O5wQdVeI+xaFYoag1ZAy2g3mbx21Lgrm8EOTfY0Tb9ZZ1 4jPHTmcDJLdekZTIUYUXLe8xScFc+njXpPUNRpbiMoBjEd3qWaNGeSdigRlonFHz8/zd icxg== X-Gm-Message-State: ABy/qLaDxatIyGSPOqKoBa3XyPAwZEnYJE2DUTwOoa2ZcLLYVjUADUSp +cZVesCDlquYAREYEwMurhLL6IJkhl4= X-Google-Smtp-Source: APBJJlEKdL6p/77/wJzXlf2kuJI3Orjh4OaDmmiDniORcukOog90eGUkqhaPlmWeilfB1QkgkSBhcQ== X-Received: by 2002:adf:f108:0:b0:313:eaf5:515 with SMTP id r8-20020adff108000000b00313eaf50515mr15167312wro.6.1689166029358; Wed, 12 Jul 2023 05:47:09 -0700 (PDT) Received: from EliteBook.fritz.box ([2a00:e180:1557:4100:d4c4:2bb7:77d6:6d86]) by smtp.gmail.com with ESMTPSA id j8-20020adfe508000000b0031424950a99sm4989225wrm.81.2023.07.12.05.47.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 05:47:08 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/7] drm/lima: switch to using drm_exec Date: Wed, 12 Jul 2023 14:47:00 +0200 Message-Id: <20230712124704.333004-4-christian.koenig@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230712124704.333004-1-christian.koenig@amd.com> References: <20230712124704.333004-1-christian.koenig@amd.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Christian_K=C3=B6nig?= , lima@lists.freedesktop.org, Qiang Yu Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Just a straightforward conversion without any optimization. Only compile tested for now. Signed-off-by: Christian König Cc: Qiang Yu Cc: lima@lists.freedesktop.org --- drivers/gpu/drm/lima/Kconfig | 1 + drivers/gpu/drm/lima/lima_gem.c | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/lima/Kconfig b/drivers/gpu/drm/lima/Kconfig index fa1d4f5df31e..1d2871d9ddd2 100644 --- a/drivers/gpu/drm/lima/Kconfig +++ b/drivers/gpu/drm/lima/Kconfig @@ -9,6 +9,7 @@ config DRM_LIMA depends on COMMON_CLK depends on OF select DRM_SCHED + select DRM_EXEC select DRM_GEM_SHMEM_HELPER select PM_DEVFREQ select DEVFREQ_GOV_SIMPLE_ONDEMAND diff --git a/drivers/gpu/drm/lima/lima_gem.c b/drivers/gpu/drm/lima/lima_gem.c index 4f9736e5f929..d4688d19465b 100644 --- a/drivers/gpu/drm/lima/lima_gem.c +++ b/drivers/gpu/drm/lima/lima_gem.c @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -292,7 +293,7 @@ static int lima_gem_add_deps(struct drm_file *file, struct lima_submit *submit) int lima_gem_submit(struct drm_file *file, struct lima_submit *submit) { int i, err = 0; - struct ww_acquire_ctx ctx; + struct drm_exec exec; struct lima_drm_priv *priv = to_lima_drm_priv(file); struct lima_vm *vm = priv->vm; struct drm_syncobj *out_sync = NULL; @@ -329,8 +330,11 @@ int lima_gem_submit(struct drm_file *file, struct lima_submit *submit) bos[i] = bo; } - err = drm_gem_lock_reservations((struct drm_gem_object **)bos, - submit->nr_bos, &ctx); + drm_exec_init(&exec, DRM_EXEC_INTERRUPTIBLE_WAIT); + drm_exec_until_all_locked(&exec) + err = drm_exec_prepare_array(&exec, + (struct drm_gem_object **)bos, + submit->nr_bos, 0); if (err) goto err_out0; @@ -360,9 +364,7 @@ int lima_gem_submit(struct drm_file *file, struct lima_submit *submit) submit->bos[i].flags & LIMA_SUBMIT_BO_WRITE ? DMA_RESV_USAGE_WRITE : DMA_RESV_USAGE_READ); } - - drm_gem_unlock_reservations((struct drm_gem_object **)bos, - submit->nr_bos, &ctx); + drm_exec_fini(&exec); for (i = 0; i < submit->nr_bos; i++) drm_gem_object_put(&bos[i]->base.base); @@ -379,8 +381,7 @@ int lima_gem_submit(struct drm_file *file, struct lima_submit *submit) err_out2: lima_sched_task_fini(submit->task); err_out1: - drm_gem_unlock_reservations((struct drm_gem_object **)bos, - submit->nr_bos, &ctx); + drm_exec_fini(&exec); err_out0: for (i = 0; i < submit->nr_bos; i++) { if (!bos[i]) From patchwork Wed Jul 12 12:47:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 13310328 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ABC44EB64D9 for ; Wed, 12 Jul 2023 12:47:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 42A7610E51F; Wed, 12 Jul 2023 12:47:24 +0000 (UTC) Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2675310E512 for ; Wed, 12 Jul 2023 12:47:12 +0000 (UTC) Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-314417861b9so6999090f8f.0 for ; Wed, 12 Jul 2023 05:47:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689166030; x=1691758030; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3Xh5RMuLzB6AZnd1vsrppGQ5UNHATRX9hF95pP3+kNg=; b=k4x8P5cQn4pvpM6erMvBQpUTVTNi+yCigoFuT064t5a8Hgw67L/Etwvh9FrfKUYGtn Pi0qGA+/t4CID0SuoPV41x32dlC+j5rNnfW46fWZQPjLDoxDlQnVQTSozUG5pRK77k96 4voJqBe3Ol69T0bc7YAqCdB1HEQTuzazEb9dm4BBypSTQx3bmTeMzyW5tRhGc/nA3cYo Qri7L0mCKtr7ktZu722tvkuVUG3tvIqYtJaSt02eMTJkRCkAnsDO/MPk6SIn59Moor3J ah0agXhL2OWLzq03MRtdBwkYJEnutH78oZICLz1frHIZYy3EWY5fyzXXO5vQ1YaOqA14 GKpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689166030; x=1691758030; 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=3Xh5RMuLzB6AZnd1vsrppGQ5UNHATRX9hF95pP3+kNg=; b=XvPG5flLLBmFIwtjFeyoJH+OK3JPr+aEJTBhCG5yZVAEKqFRpcIeXsbi6pRnyhY4jq Hi6+an62I64ywRUp4p7d2JNQ6inCdYOjUxMviTU/1PtgAHDeWPfSTR+poLKbLiJd9715 H6qLvrw4rXknftbWil2bgyx4RL3FeTXYwHsdxyHJK6r6vKbRj8KQap4leiBaM81SuWZm 9rjGNww1CRPNGV2uvCVRPcOrI/aYZoZjFMMOSx7k3bJbQJDOhwYOBrn/sK4T+/sfPygV cTjaORcDEXUx96E0LI6s/gRQk+/SZXgs7GjrfESWhV6uz6cehkHlR4HJn4FIbOnhxraO Yr1A== X-Gm-Message-State: ABy/qLZ79OddSke7Uu/WJTZSZI3Mm6MW5DSohsYbniAUTeZVCWmh2gNH BwD1qE9UaUMlf8neXGIrhVKlW4IV7ac= X-Google-Smtp-Source: APBJJlGPxZP3AapSCcqrBo9XpTcLvDyjY/PBnCBR0Cv72nSZgVUCz5VzggU0jEc/10Vksn0+sILn4A== X-Received: by 2002:a05:6000:1cc9:b0:314:2735:dc13 with SMTP id bf9-20020a0560001cc900b003142735dc13mr18659974wrb.47.1689166030228; Wed, 12 Jul 2023 05:47:10 -0700 (PDT) Received: from EliteBook.fritz.box ([2a00:e180:1557:4100:d4c4:2bb7:77d6:6d86]) by smtp.gmail.com with ESMTPSA id j8-20020adfe508000000b0031424950a99sm4989225wrm.81.2023.07.12.05.47.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 05:47:09 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: dri-devel@lists.freedesktop.org Subject: [PATCH 4/7] drm/virtgpu: switch to using drm_exec Date: Wed, 12 Jul 2023 14:47:01 +0200 Message-Id: <20230712124704.333004-5-christian.koenig@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230712124704.333004-1-christian.koenig@amd.com> References: <20230712124704.333004-1-christian.koenig@amd.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Christian_K=C3=B6nig?= , Gurchetan Singh , Gerd Hoffmann , David Airlie , virtualization@lists.linux-foundation.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Just a straightforward conversion without any optimization. Only compile tested for now. Signed-off-by: Christian König Cc: David Airlie Cc: Gerd Hoffmann Cc: Gurchetan Singh Cc: Chia-I Wu Cc: virtualization@lists.linux-foundation.org --- drivers/gpu/drm/virtio/Kconfig | 1 + drivers/gpu/drm/virtio/virtgpu_drv.h | 3 ++- drivers/gpu/drm/virtio/virtgpu_gem.c | 28 +++++----------------------- 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/virtio/Kconfig b/drivers/gpu/drm/virtio/Kconfig index ea06ff2aa4b4..a24a1ce5e666 100644 --- a/drivers/gpu/drm/virtio/Kconfig +++ b/drivers/gpu/drm/virtio/Kconfig @@ -5,6 +5,7 @@ config DRM_VIRTIO_GPU select VIRTIO select DRM_KMS_HELPER select DRM_GEM_SHMEM_HELPER + select DRM_EXEC select VIRTIO_DMA_SHARED_BUFFER help This is the virtual GPU driver for virtio. It can be used with diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h index 4126c384286b..cb5d9218a3ab 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.h +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -116,7 +117,7 @@ struct virtio_gpu_object_vram { container_of((virtio_gpu_object), struct virtio_gpu_object_vram, base) struct virtio_gpu_object_array { - struct ww_acquire_ctx ticket; + struct drm_exec exec; struct list_head next; u32 nents, total; struct drm_gem_object *objs[]; diff --git a/drivers/gpu/drm/virtio/virtgpu_gem.c b/drivers/gpu/drm/virtio/virtgpu_gem.c index 7db48d17ee3a..bb7928e7b3b6 100644 --- a/drivers/gpu/drm/virtio/virtgpu_gem.c +++ b/drivers/gpu/drm/virtio/virtgpu_gem.c @@ -171,6 +171,7 @@ struct virtio_gpu_object_array *virtio_gpu_array_alloc(u32 nents) objs->nents = 0; objs->total = nents; + drm_exec_init(&objs->exec, DRM_EXEC_INTERRUPTIBLE_WAIT); return objs; } @@ -214,36 +215,17 @@ void virtio_gpu_array_add_obj(struct virtio_gpu_object_array *objs, int virtio_gpu_array_lock_resv(struct virtio_gpu_object_array *objs) { - unsigned int i; int ret; - if (objs->nents == 1) { - ret = dma_resv_lock_interruptible(objs->objs[0]->resv, NULL); - } else { - ret = drm_gem_lock_reservations(objs->objs, objs->nents, - &objs->ticket); - } - if (ret) - return ret; - - for (i = 0; i < objs->nents; ++i) { - ret = dma_resv_reserve_fences(objs->objs[i]->resv, 1); - if (ret) { - virtio_gpu_array_unlock_resv(objs); - return ret; - } - } + drm_exec_until_all_locked(&objs->exec) + ret = drm_exec_prepare_array(&objs->exec, objs->objs, + objs->nents, 1); return ret; } void virtio_gpu_array_unlock_resv(struct virtio_gpu_object_array *objs) { - if (objs->nents == 1) { - dma_resv_unlock(objs->objs[0]->resv); - } else { - drm_gem_unlock_reservations(objs->objs, objs->nents, - &objs->ticket); - } + drm_exec_fini(&objs->exec); } void virtio_gpu_array_add_fence(struct virtio_gpu_object_array *objs, From patchwork Wed Jul 12 12:47:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 13310324 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EF20CEB64DD for ; Wed, 12 Jul 2023 12:47:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9786910E517; Wed, 12 Jul 2023 12:47:15 +0000 (UTC) Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2A07410E512 for ; Wed, 12 Jul 2023 12:47:13 +0000 (UTC) Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-31441dfbf97so7752234f8f.1 for ; Wed, 12 Jul 2023 05:47:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689166031; x=1691758031; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kJUoBT3tqtyuccM+TuY1/4SIsygQhaE2x0NqcVtNoxw=; b=qOVRvaXQPHcSyoKjm/p/MU8olIQ5eS9XrxvxBIC/EQMBYWIPlSCcRHnF1wOes5OqnD 6nmsXo3Gsq8K3a+nixe/wCuw7sxAYPfLEv11+s4rU5JszgAFSzIX8jTtdUtsFtM74pA/ NsQwXMWDKZV0IqIKwVs1n5CC9mMPHBFbcQoWaD+pXKsEEElbhkAC/de7Msv6wCb8+omg uqJKoxaP4I/Lij/tud508x7L7R9r7XMaiY6OHegJ7UxSDXgxNC1yaX4IiylC6tzf8Zbj QNrQN9xoxIsLY+SYy9wBxY88/zKgZciRMbFtE4UrTKw55ULUCZpwKSybfm5d2BW01Sij Y1gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689166031; x=1691758031; 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=kJUoBT3tqtyuccM+TuY1/4SIsygQhaE2x0NqcVtNoxw=; b=P8m2W2e7KB6hvfsqyahF4YAn8R8koSUc6gKK4/UmOTHJH+SYfIg+lgBOwpDCmlzkcz Ca9Mts3MAdYE3M+8ttI4nU8IqGtc/xh90HrPGAEeC6ErGTruhxqNLsYvA/OjR7uKB3c0 jweLzA8GzCbRmz3epRKI0HKkPSkEE58Nlz/kj0Yq9OGcBHPBp64CMcDz1KPDKBTPAGT2 ihthZwNK8WGVOusRMnyiithPOlhWgWY34/lvHHrhqKmsK9uqwCwHAQR/kOFZAy9CYA+U qsWtUOgr+wwMzBLNKsS2xAmJKcrX+l739ombz/QEtl5TIn0XLn4YA09Qbc2wtxq8QufF w5Fg== X-Gm-Message-State: ABy/qLYIDd/DyzrdabVamTVm5XoXQ96KRbVMx8UE/dkg5tHi7x3hH74W Q4gUC6VuMb7vXuUlPAMEJbC3+1RrO9c= X-Google-Smtp-Source: APBJJlHJXkseDiPtG4kEyMUSdeWGA/1wvEjUc5pbesGOyxUOKeiW8SSoFRcRR3ocLL131y6Lsoaasw== X-Received: by 2002:adf:ea08:0:b0:315:ad16:c1b7 with SMTP id q8-20020adfea08000000b00315ad16c1b7mr2151391wrm.17.1689166031132; Wed, 12 Jul 2023 05:47:11 -0700 (PDT) Received: from EliteBook.fritz.box ([2a00:e180:1557:4100:d4c4:2bb7:77d6:6d86]) by smtp.gmail.com with ESMTPSA id j8-20020adfe508000000b0031424950a99sm4989225wrm.81.2023.07.12.05.47.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 05:47:10 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: dri-devel@lists.freedesktop.org Subject: [PATCH 5/7] drm/panfrost: switch to using drm_exec Date: Wed, 12 Jul 2023 14:47:02 +0200 Message-Id: <20230712124704.333004-6-christian.koenig@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230712124704.333004-1-christian.koenig@amd.com> References: <20230712124704.333004-1-christian.koenig@amd.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alyssa Rosenzweig , =?utf-8?q?Christian?= =?utf-8?q?_K=C3=B6nig?= , Tomeu Vizoso , Steven Price Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Just a straightforward conversion without any optimization. Only compile tested for now. Signed-off-by: Christian König Cc: Rob Herring Cc: Tomeu Vizoso Cc: Steven Price Cc: Alyssa Rosenzweig --- drivers/gpu/drm/panfrost/Kconfig | 1 + drivers/gpu/drm/panfrost/panfrost_job.c | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/panfrost/Kconfig b/drivers/gpu/drm/panfrost/Kconfig index e6403a9d66ad..e86a1a2fd8e1 100644 --- a/drivers/gpu/drm/panfrost/Kconfig +++ b/drivers/gpu/drm/panfrost/Kconfig @@ -7,6 +7,7 @@ config DRM_PANFROST depends on !GENERIC_ATOMIC64 # for IOMMU_IO_PGTABLE_LPAE depends on MMU select DRM_SCHED + select DRM_EXEC select IOMMU_SUPPORT select IOMMU_IO_PGTABLE_LPAE select DRM_GEM_SHMEM_HELPER diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c b/drivers/gpu/drm/panfrost/panfrost_job.c index dbc597ab46fb..8b9206e910b5 100644 --- a/drivers/gpu/drm/panfrost/panfrost_job.c +++ b/drivers/gpu/drm/panfrost/panfrost_job.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -275,13 +276,14 @@ static void panfrost_attach_object_fences(struct drm_gem_object **bos, int panfrost_job_push(struct panfrost_job *job) { struct panfrost_device *pfdev = job->pfdev; - struct ww_acquire_ctx acquire_ctx; + struct drm_exec exec; int ret = 0; - ret = drm_gem_lock_reservations(job->bos, job->bo_count, - &acquire_ctx); + drm_exec_init(&exec, DRM_EXEC_INTERRUPTIBLE_WAIT); + drm_exec_until_all_locked(&exec) + ret = drm_exec_prepare_array(&exec, job->bos, job->bo_count, 1); if (ret) - return ret; + goto unlock; mutex_lock(&pfdev->sched_lock); drm_sched_job_arm(&job->base); @@ -305,7 +307,7 @@ int panfrost_job_push(struct panfrost_job *job) job->render_done_fence); unlock: - drm_gem_unlock_reservations(job->bos, job->bo_count, &acquire_ctx); + drm_exec_fini(&exec); return ret; } From patchwork Wed Jul 12 12:47:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 13310323 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 84F95EB64D9 for ; Wed, 12 Jul 2023 12:47:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 68FC810E515; Wed, 12 Jul 2023 12:47:15 +0000 (UTC) Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8659A10E515 for ; Wed, 12 Jul 2023 12:47:13 +0000 (UTC) Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-3142ee41fd2so6968867f8f.3 for ; Wed, 12 Jul 2023 05:47:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689166032; x=1691758032; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ePLEbc/ip+tHkl2r/nCDyk54NfZldvlti6WJpwpMVEQ=; b=Dh4H23dLQ6v1YH3/pcmhuKB2+1/xqdSxBgP11YhaBEfTOa6ALMT+CJsdzxWBw6MWpK cn4kFuvTHNfOYZaaY/BvAeV3OGhCCVDjRO/ihRn7zbl4MQwduI2Y+w+ONKCn0VSUNKv1 D7fIIMAXjwHJf2iAbYsziSoW6cECIYJN5eyFw/5OVOKfslRKxv9B+Cp3iJla7uTSVI0L tfjfjSkqHw6XpDq6pohlmf8UJRLmPB1hod5n8/OHLCspoUREiBE0rUrESsIKZfmt+CpH YGiV9gQSITncV+17BODfG8puF1nxl5lS0/9WMYlBEj2k2U/EaaQ9VdmSC7n8nfnV6ItI Y+6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689166032; x=1691758032; 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=ePLEbc/ip+tHkl2r/nCDyk54NfZldvlti6WJpwpMVEQ=; b=YsFpRJOEhk32drcvrKm+wVu/+Z6tibivHHhVyuS5PIJncKVvBwepdPt/JekwJ+CbDI XQKu+hBB1KiqrrxJZoy4xeUDfrXSqK10etJmGQhYv+IaiUUS0mdocSZqfnm1446NdnSv 95Jvw77mUB/9CasVkn+9M56SYr6wwQLlgtKTwfTkf1zmp9JlvAmK2ezF0CfjcWmIAMXS Z2mf1dObOvGKQ89bUEAORJbq6vXSGaIxR+KlFM1MD0uXgiGtlc17g5lYx/bKuXq/1X6/ WUmgHynRDySuIPoshnrSFJ7tkm5at5o2G2Cn3d12udGtOQB2e8uDPTlMBH0R5uOWoYoK Bemg== X-Gm-Message-State: ABy/qLYxhGbMx6ukX3QQwCFmiX2fPrBZBGSqO18PxhdbJuhz/7P/E7To dx1MvmDD3UmhirVBTuRoWhR7xxmWBtQ= X-Google-Smtp-Source: APBJJlG6yA8cFjNOOPSisTLCh2181pgZ6/RyhhxTF+uCD9d4uyz0ZszfxsXI6vh7iMY5suH3uMzvyA== X-Received: by 2002:adf:cc83:0:b0:313:e12d:b245 with SMTP id p3-20020adfcc83000000b00313e12db245mr17873659wrj.29.1689166031961; Wed, 12 Jul 2023 05:47:11 -0700 (PDT) Received: from EliteBook.fritz.box ([2a00:e180:1557:4100:d4c4:2bb7:77d6:6d86]) by smtp.gmail.com with ESMTPSA id j8-20020adfe508000000b0031424950a99sm4989225wrm.81.2023.07.12.05.47.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 05:47:11 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: dri-devel@lists.freedesktop.org Subject: [PATCH 6/7] drm/v3d: switch to using drm_exec Date: Wed, 12 Jul 2023 14:47:03 +0200 Message-Id: <20230712124704.333004-7-christian.koenig@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230712124704.333004-1-christian.koenig@amd.com> References: <20230712124704.333004-1-christian.koenig@amd.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Melissa Wen , =?utf-8?q?Christian_K=C3=B6nig?= , Emma Anholt Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Just a straightforward conversion without any optimization. Only compile tested for now. Signed-off-by: Christian König Cc: Emma Anholt Cc: Melissa Wen --- drivers/gpu/drm/v3d/v3d_gem.c | 44 ++++++++++++++++------------------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/v3d/v3d_gem.c b/drivers/gpu/drm/v3d/v3d_gem.c index 2e94ce788c71..190e2a9f64a4 100644 --- a/drivers/gpu/drm/v3d/v3d_gem.c +++ b/drivers/gpu/drm/v3d/v3d_gem.c @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -249,20 +250,17 @@ v3d_invalidate_caches(struct v3d_dev *v3d) * to v3d, so we don't attach dma-buf fences to them. */ static int -v3d_lock_bo_reservations(struct v3d_job *job, - struct ww_acquire_ctx *acquire_ctx) +v3d_lock_bo_reservations(struct v3d_job *job, struct drm_exec *exec) { int i, ret; - ret = drm_gem_lock_reservations(job->bo, job->bo_count, acquire_ctx); + drm_exec_init(exec, DRM_EXEC_INTERRUPTIBLE_WAIT); + drm_exec_until_all_locked(exec) + ret = drm_exec_prepare_array(exec, job->bo, job->bo_count, 1); if (ret) - return ret; + goto fail; for (i = 0; i < job->bo_count; i++) { - ret = dma_resv_reserve_fences(job->bo[i]->resv, 1); - if (ret) - goto fail; - ret = drm_sched_job_add_implicit_dependencies(&job->base, job->bo[i], true); if (ret) @@ -272,7 +270,7 @@ v3d_lock_bo_reservations(struct v3d_job *job, return 0; fail: - drm_gem_unlock_reservations(job->bo, job->bo_count, acquire_ctx); + drm_exec_fini(exec); return ret; } @@ -477,7 +475,7 @@ v3d_push_job(struct v3d_job *job) static void v3d_attach_fences_and_unlock_reservation(struct drm_file *file_priv, struct v3d_job *job, - struct ww_acquire_ctx *acquire_ctx, + struct drm_exec *exec, u32 out_sync, struct v3d_submit_ext *se, struct dma_fence *done_fence) @@ -492,7 +490,7 @@ v3d_attach_fences_and_unlock_reservation(struct drm_file *file_priv, DMA_RESV_USAGE_WRITE); } - drm_gem_unlock_reservations(job->bo, job->bo_count, acquire_ctx); + drm_exec_fini(exec); /* Update the return sync object for the job */ /* If it only supports a single signal semaphore*/ @@ -669,7 +667,7 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data, struct v3d_render_job *render = NULL; struct v3d_job *clean_job = NULL; struct v3d_job *last_job; - struct ww_acquire_ctx acquire_ctx; + struct drm_exec exec; int ret = 0; trace_v3d_submit_cl_ioctl(&v3d->drm, args->rcl_start, args->rcl_end); @@ -731,7 +729,7 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data, if (ret) goto fail; - ret = v3d_lock_bo_reservations(last_job, &acquire_ctx); + ret = v3d_lock_bo_reservations(last_job, &exec); if (ret) goto fail; @@ -775,7 +773,7 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data, v3d_attach_fences_and_unlock_reservation(file_priv, last_job, - &acquire_ctx, + &exec, args->out_sync, &se, last_job->done_fence); @@ -791,8 +789,7 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data, fail_unreserve: mutex_unlock(&v3d->sched_lock); fail_perfmon: - drm_gem_unlock_reservations(last_job->bo, - last_job->bo_count, &acquire_ctx); + drm_exec_fini(&exec); fail: v3d_job_cleanup((void *)bin); v3d_job_cleanup((void *)render); @@ -819,7 +816,7 @@ v3d_submit_tfu_ioctl(struct drm_device *dev, void *data, struct drm_v3d_submit_tfu *args = data; struct v3d_submit_ext se = {0}; struct v3d_tfu_job *job = NULL; - struct ww_acquire_ctx acquire_ctx; + struct drm_exec exec; int ret = 0; trace_v3d_submit_tfu_ioctl(&v3d->drm, args->iia); @@ -870,7 +867,7 @@ v3d_submit_tfu_ioctl(struct drm_device *dev, void *data, job->base.bo[job->base.bo_count] = bo; } - ret = v3d_lock_bo_reservations(&job->base, &acquire_ctx); + ret = v3d_lock_bo_reservations(&job->base, &exec); if (ret) goto fail; @@ -879,7 +876,7 @@ v3d_submit_tfu_ioctl(struct drm_device *dev, void *data, mutex_unlock(&v3d->sched_lock); v3d_attach_fences_and_unlock_reservation(file_priv, - &job->base, &acquire_ctx, + &job->base, &exec, args->out_sync, &se, job->base.done_fence); @@ -914,7 +911,7 @@ v3d_submit_csd_ioctl(struct drm_device *dev, void *data, struct v3d_submit_ext se = {0}; struct v3d_csd_job *job = NULL; struct v3d_job *clean_job = NULL; - struct ww_acquire_ctx acquire_ctx; + struct drm_exec exec; int ret; trace_v3d_submit_csd_ioctl(&v3d->drm, args->cfg[5], args->cfg[6]); @@ -957,7 +954,7 @@ v3d_submit_csd_ioctl(struct drm_device *dev, void *data, if (ret) goto fail; - ret = v3d_lock_bo_reservations(clean_job, &acquire_ctx); + ret = v3d_lock_bo_reservations(clean_job, &exec); if (ret) goto fail; @@ -983,7 +980,7 @@ v3d_submit_csd_ioctl(struct drm_device *dev, void *data, v3d_attach_fences_and_unlock_reservation(file_priv, clean_job, - &acquire_ctx, + &exec, args->out_sync, &se, clean_job->done_fence); @@ -996,8 +993,7 @@ v3d_submit_csd_ioctl(struct drm_device *dev, void *data, fail_unreserve: mutex_unlock(&v3d->sched_lock); fail_perfmon: - drm_gem_unlock_reservations(clean_job->bo, clean_job->bo_count, - &acquire_ctx); + drm_exec_fini(&exec); fail: v3d_job_cleanup((void *)job); v3d_job_cleanup(clean_job); From patchwork Wed Jul 12 12:47:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 13310325 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 24D7EEB64DA for ; Wed, 12 Jul 2023 12:47:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 639D810E51C; Wed, 12 Jul 2023 12:47:16 +0000 (UTC) Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by gabe.freedesktop.org (Postfix) with ESMTPS id 53DFF10E517 for ; Wed, 12 Jul 2023 12:47:14 +0000 (UTC) Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-31297125334so461414f8f.0 for ; Wed, 12 Jul 2023 05:47:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689166033; x=1691758033; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yD3KxKBEcA4joV+km9J8x0kE8plOrThcT8QkdqJYGow=; b=GPVJPH0Z1Wa5KDMmIbRUkZJ1Yp2ZN4dRjvwuy1Kn1omKGAn7y6Gv11UIYpsY59tfIl oposggtZcf9C9B3UmZqR79aPON1t5OBW+grsLIniXo2YhhjjHCgTcpl+wuLxUMXZIvdy XwlGhgCiEvJ16dtGrBo8adcdIOTaBA18VCLjxPdLb9lywUdPowZbx4JQv139ds9l+ZLF H/nJq/Ievdk/S+2V/a2drJZn/BiD3iX22GRkqjHXC2kGmenSr3I6fF9bb+LTEImC5wsG tZUpQ3xwkkW6dyKVpKOJqvMrYM8h5HUAb3PWRQDh52rmqDQHmtO/ceCr6R+QGtgc0Csy 7nxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689166033; x=1691758033; 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=yD3KxKBEcA4joV+km9J8x0kE8plOrThcT8QkdqJYGow=; b=AHllZ7OHLnFf+9vVhBooKej44HnTY4LY/pNrUUMvLC+4JUwU7HWf1j1/GmjNAKKcP1 kuWqhvljWkaVJIChkJcFD2vWrrqh6WeGgLNtAN4JiJKnMwTtrzU/WobuqImQKp7xkh3a FCGh9BEl22tjYz2Rj5fRN+JZ8QUR075+BB2jkXcZylukDsyAPykKosXQSAy5wcMi4FdT kctbuXDpkZbhmW+0hsUgEKYOcgxqZ6C4QyLYwQkL1d8rLXexFN4UCKpol98PshOYzBdk LkxKPPIeTBsmz5hjoDn4uge3ToVkiiJsIgJ017Ixsrks8EZ3QSmwp6j0hg3vp2JGofp1 LC5w== X-Gm-Message-State: ABy/qLbWnTw+S8nR2kML6cQArTtvnsLHCqGhNXXBWWAt2f229x24rCU+ APCySyTg8rB8Z922+h2DmP1i7ca87vg= X-Google-Smtp-Source: APBJJlGjpwQEpt6vpgDnJuO0ZRkdj8bOWKnNgAnButWgsiqY3NXqgStxbCTihUI4tLMK62wwFsO58Q== X-Received: by 2002:a5d:6b45:0:b0:314:385d:3f32 with SMTP id x5-20020a5d6b45000000b00314385d3f32mr1676498wrw.29.1689166032789; Wed, 12 Jul 2023 05:47:12 -0700 (PDT) Received: from EliteBook.fritz.box ([2a00:e180:1557:4100:d4c4:2bb7:77d6:6d86]) by smtp.gmail.com with ESMTPSA id j8-20020adfe508000000b0031424950a99sm4989225wrm.81.2023.07.12.05.47.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 05:47:12 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: dri-devel@lists.freedesktop.org Subject: [PATCH 7/7] drm: remove drm_gem_(un)lock_reservations Date: Wed, 12 Jul 2023 14:47:04 +0200 Message-Id: <20230712124704.333004-8-christian.koenig@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230712124704.333004-1-christian.koenig@amd.com> References: <20230712124704.333004-1-christian.koenig@amd.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Zimmermann , =?utf-8?q?Christian_K=C3=B6nig?= , Maxime Ripard Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Not used any more. Signed-off-by: Christian König Cc: Maxime Ripard Cc: Thomas Zimmermann --- drivers/gpu/drm/drm_gem.c | 78 -------------------------- drivers/gpu/drm/scheduler/sched_main.c | 5 +- include/drm/drm_gem.h | 4 -- 3 files changed, 2 insertions(+), 85 deletions(-) diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index c18686f434d4..2753926c74db 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -1214,84 +1214,6 @@ void drm_gem_vunmap_unlocked(struct drm_gem_object *obj, struct iosys_map *map) } EXPORT_SYMBOL(drm_gem_vunmap_unlocked); -/** - * drm_gem_lock_reservations - Sets up the ww context and acquires - * the lock on an array of GEM objects. - * - * Once you've locked your reservations, you'll want to set up space - * for your shared fences (if applicable), submit your job, then - * drm_gem_unlock_reservations(). - * - * @objs: drm_gem_objects to lock - * @count: Number of objects in @objs - * @acquire_ctx: struct ww_acquire_ctx that will be initialized as - * part of tracking this set of locked reservations. - */ -int -drm_gem_lock_reservations(struct drm_gem_object **objs, int count, - struct ww_acquire_ctx *acquire_ctx) -{ - int contended = -1; - int i, ret; - - ww_acquire_init(acquire_ctx, &reservation_ww_class); - -retry: - if (contended != -1) { - struct drm_gem_object *obj = objs[contended]; - - ret = dma_resv_lock_slow_interruptible(obj->resv, - acquire_ctx); - if (ret) { - ww_acquire_fini(acquire_ctx); - return ret; - } - } - - for (i = 0; i < count; i++) { - if (i == contended) - continue; - - ret = dma_resv_lock_interruptible(objs[i]->resv, - acquire_ctx); - if (ret) { - int j; - - for (j = 0; j < i; j++) - dma_resv_unlock(objs[j]->resv); - - if (contended != -1 && contended >= i) - dma_resv_unlock(objs[contended]->resv); - - if (ret == -EDEADLK) { - contended = i; - goto retry; - } - - ww_acquire_fini(acquire_ctx); - return ret; - } - } - - ww_acquire_done(acquire_ctx); - - return 0; -} -EXPORT_SYMBOL(drm_gem_lock_reservations); - -void -drm_gem_unlock_reservations(struct drm_gem_object **objs, int count, - struct ww_acquire_ctx *acquire_ctx) -{ - int i; - - for (i = 0; i < count; i++) - dma_resv_unlock(objs[i]->resv); - - ww_acquire_fini(acquire_ctx); -} -EXPORT_SYMBOL(drm_gem_unlock_reservations); - /** * drm_gem_lru_init - initialize a LRU * diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c index 7b2bfc10c1a5..335640369a0f 100644 --- a/drivers/gpu/drm/scheduler/sched_main.c +++ b/drivers/gpu/drm/scheduler/sched_main.c @@ -795,9 +795,8 @@ EXPORT_SYMBOL(drm_sched_job_add_resv_dependencies); * @write: whether the job might write the object (so we need to depend on * shared fences in the reservation object). * - * This should be called after drm_gem_lock_reservations() on your array of - * GEM objects used in the job but before updating the reservations with your - * own fences. + * This should be called after locking your GEM objects used in the job but + * before updating the reservations with your own fences. * * Returns: * 0 on success, or an error on failing to expand the array. diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h index bbc721870c13..35ffa5aa7b96 100644 --- a/include/drm/drm_gem.h +++ b/include/drm/drm_gem.h @@ -508,10 +508,6 @@ int drm_gem_objects_lookup(struct drm_file *filp, void __user *bo_handles, struct drm_gem_object *drm_gem_object_lookup(struct drm_file *filp, u32 handle); long drm_gem_dma_resv_wait(struct drm_file *filep, u32 handle, bool wait_all, unsigned long timeout); -int drm_gem_lock_reservations(struct drm_gem_object **objs, int count, - struct ww_acquire_ctx *acquire_ctx); -void drm_gem_unlock_reservations(struct drm_gem_object **objs, int count, - struct ww_acquire_ctx *acquire_ctx); int drm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev, u32 handle, u64 *offset);