From patchwork Fri Oct 27 16:58:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 13438657 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 EB5E8C25B47 for ; Fri, 27 Oct 2023 16:59:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 28F5910EA16; Fri, 27 Oct 2023 16:59:20 +0000 (UTC) Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by gabe.freedesktop.org (Postfix) with ESMTPS id 409E510EA15; Fri, 27 Oct 2023 16:59:17 +0000 (UTC) Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-5aa7fdd1420so1812304a12.3; Fri, 27 Oct 2023 09:59:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698425956; x=1699030756; darn=lists.freedesktop.org; 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=5R6dnp6JYl9GTg3p8/cfLvJpZVQTPFVKn1Jc3rRbi2Y=; b=g8aKGrPBX9MLuavGoqS4sEY8t3BHNYYmEViVQl1VBp/+eUfCgJx2aLopzOSdL+j7A2 462FalJS/VtE2MVFLujJzRXzZbdPdlCGrLXZvFgQS8TiQvjghwOP7neGgEUnBGnAjQqN XX5gGBETXEzO4GBvKylTL1kkRkLcHzDAq80VDVMoRdmPd97zaT52QvTzjjLFT9P0QkgX BHaI9aa+1upRj+HDjqfmNODBiewWCOu8VtDuE7LrmqVVenOx2kQwZY7EBtcUFhkt2AV1 Pa/vra2F2azzUwmHa/jzNu1LVhsJmtgpUtL8vKrMnBBc4lRJ09MpWkf1+P8q3HePzZAp ovgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698425956; x=1699030756; 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=5R6dnp6JYl9GTg3p8/cfLvJpZVQTPFVKn1Jc3rRbi2Y=; b=VlXGDuSae4Au30+pE+Oy35lLB2xRKiiEsl8Q9pteG9MKKHIzORloQfYyTG00JviVXh iYZhokPgCphdQCyEGtgkYcRTKyRA3OQEOX7oaFDWZBKDcCxhl6zQGK9dafNnVnT/Ufs/ KrxwjqajHD/Si1CWvf3G0UxKk3SiVxw732IgdNIOPvCy0dPLH0FoK10c7X9NX749IUoW W1m+U2PkusiF3/uquzrvpLs8y3gBZT1RtQUeK3KCubjKz+WZQ5ak1i6OshjO3ieIZ6m9 YJ2gxD8e+QJNCrQFwwwPPmMIn4xSiKrXv4tiZln4qitq5hAY4k6zAO+3Y8KOg+dAZyMZ HEbA== X-Gm-Message-State: AOJu0Yxuv5fYMw6L+p/iIoJV64xO2M6RJqYNZlbYSOcuiu03d3/TWigp 0zQJNiZOIZ72D3LKhc5Z3cfpQQNag3U= X-Google-Smtp-Source: AGHT+IGKn3WMc6OBc8kKe4JkxH8X2ZWrozRHWu6T+6S+ZBzTtDZM8a8mjcxLZWnStYmHSFiQ1ePvig== X-Received: by 2002:a17:90b:3781:b0:27d:d36:763b with SMTP id mz1-20020a17090b378100b0027d0d36763bmr3013167pjb.31.1698425956153; Fri, 27 Oct 2023 09:59:16 -0700 (PDT) Received: from localhost ([2a00:79e1:abd:4a00:6c80:7c10:75a0:44f4]) by smtp.gmail.com with ESMTPSA id pj1-20020a17090b4f4100b00273744e6eccsm1446083pjb.12.2023.10.27.09.59.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 09:59:15 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/7] drm/msm/gem: Remove "valid" tracking Date: Fri, 27 Oct 2023 09:58:35 -0700 Message-ID: <20231027165859.395638-2-robdclark@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231027165859.395638-1-robdclark@gmail.com> References: <20231027165859.395638-1-robdclark@gmail.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: Rob Clark , linux-arm-msm@vger.kernel.org, Abhinav Kumar , open list , Sean Paul , Dmitry Baryshkov , Marijn Suijten , freedreno@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Rob Clark This was a small optimization for pre-soft-pin userspace. But mesa switched to soft-pin nearly 5yrs ago. So lets drop the optimization and simplify the code. Signed-off-by: Rob Clark --- drivers/gpu/drm/msm/msm_gem.h | 2 -- drivers/gpu/drm/msm/msm_gem_submit.c | 44 +++++----------------------- 2 files changed, 8 insertions(+), 38 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_gem.h b/drivers/gpu/drm/msm/msm_gem.h index 8ddef5443140..c36c1c1fa222 100644 --- a/drivers/gpu/drm/msm/msm_gem.h +++ b/drivers/gpu/drm/msm/msm_gem.h @@ -271,7 +271,6 @@ struct msm_gem_submit { struct msm_gpu_submitqueue *queue; struct pid *pid; /* submitting process */ bool fault_dumped; /* Limit devcoredump dumping to one per submit */ - bool valid; /* true if no cmdstream patching needed */ bool in_rb; /* "sudo" mode, copy cmds into RB */ struct msm_ringbuffer *ring; unsigned int nr_cmds; @@ -288,7 +287,6 @@ struct msm_gem_submit { } *cmd; /* array of size nr_cmds */ struct { /* make sure these don't conflict w/ MSM_SUBMIT_BO_x */ -#define BO_VALID 0x8000 /* is current addr in cmdstream correct/valid? */ #define BO_LOCKED 0x4000 /* obj lock is held */ #define BO_PINNED 0x2000 /* obj (pages) is pinned and on active list */ uint32_t flags; diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c index 6d8ec1337e8b..996274ef32a6 100644 --- a/drivers/gpu/drm/msm/msm_gem_submit.c +++ b/drivers/gpu/drm/msm/msm_gem_submit.c @@ -150,8 +150,6 @@ static int submit_lookup_objects(struct msm_gem_submit *submit, submit->bos[i].handle = submit_bo.handle; submit->bos[i].flags = submit_bo.flags; - /* in validate_objects() we figure out if this is true: */ - submit->bos[i].iova = submit_bo.presumed; } spin_lock(&file->table_lock); @@ -278,9 +276,6 @@ static void submit_unlock_unpin_bo(struct msm_gem_submit *submit, int i) { unsigned cleanup_flags = BO_PINNED | BO_LOCKED; submit_cleanup_bo(submit, i, cleanup_flags); - - if (!(submit->bos[i].flags & BO_VALID)) - submit->bos[i].iova = 0; } /* This is where we make sure all the bo's are reserved and pin'd: */ @@ -390,8 +385,6 @@ static int submit_pin_objects(struct msm_gem_submit *submit) struct msm_drm_private *priv = submit->dev->dev_private; int i, ret = 0; - submit->valid = true; - for (i = 0; i < submit->nr_bos; i++) { struct drm_gem_object *obj = submit->bos[i].obj; struct msm_gem_vma *vma; @@ -407,14 +400,7 @@ static int submit_pin_objects(struct msm_gem_submit *submit) if (ret) break; - if (vma->iova == submit->bos[i].iova) { - submit->bos[i].flags |= BO_VALID; - } else { - submit->bos[i].iova = vma->iova; - /* iova changed, so address in cmdstream is not valid: */ - submit->bos[i].flags &= ~BO_VALID; - submit->valid = false; - } + submit->bos[i].iova = vma->iova; } /* @@ -451,7 +437,7 @@ static void submit_attach_object_fences(struct msm_gem_submit *submit) } static int submit_bo(struct msm_gem_submit *submit, uint32_t idx, - struct drm_gem_object **obj, uint64_t *iova, bool *valid) + struct drm_gem_object **obj, uint64_t *iova) { if (idx >= submit->nr_bos) { SUBMIT_ERROR(submit, "invalid buffer index: %u (out of %u)\n", @@ -463,8 +449,6 @@ static int submit_bo(struct msm_gem_submit *submit, uint32_t idx, *obj = submit->bos[idx].obj; if (iova) *iova = submit->bos[idx].iova; - if (valid) - *valid = !!(submit->bos[idx].flags & BO_VALID); return 0; } @@ -477,9 +461,6 @@ static int submit_reloc(struct msm_gem_submit *submit, struct drm_gem_object *ob uint32_t *ptr; int ret = 0; - if (!nr_relocs) - return 0; - if (offset % 4) { SUBMIT_ERROR(submit, "non-aligned cmdstream buffer: %u\n", offset); return -EINVAL; @@ -500,7 +481,6 @@ static int submit_reloc(struct msm_gem_submit *submit, struct drm_gem_object *ob struct drm_msm_gem_submit_reloc submit_reloc = relocs[i]; uint32_t off; uint64_t iova; - bool valid; if (submit_reloc.submit_offset % 4) { SUBMIT_ERROR(submit, "non-aligned reloc offset: %u\n", @@ -519,13 +499,10 @@ static int submit_reloc(struct msm_gem_submit *submit, struct drm_gem_object *ob goto out; } - ret = submit_bo(submit, submit_reloc.reloc_idx, NULL, &iova, &valid); + ret = submit_bo(submit, submit_reloc.reloc_idx, NULL, &iova); if (ret) goto out; - if (valid) - continue; - iova += submit_reloc.reloc_offset; if (submit_reloc.shift < 0) @@ -879,8 +856,7 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data, struct drm_gem_object *obj; uint64_t iova; - ret = submit_bo(submit, submit->cmd[i].idx, - &obj, &iova, NULL); + ret = submit_bo(submit, submit->cmd[i].idx, &obj, &iova); if (ret) goto out; @@ -894,17 +870,13 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data, submit->cmd[i].iova = iova + (submit->cmd[i].offset * 4); - if (submit->valid) + if (likely(!submit->cmd[i].nr_relocs)) continue; if (!gpu->allow_relocs) { - if (submit->cmd[i].nr_relocs) { - SUBMIT_ERROR(submit, "relocs not allowed\n"); - ret = -EINVAL; - goto out; - } - - continue; + SUBMIT_ERROR(submit, "relocs not allowed\n"); + ret = -EINVAL; + goto out; } ret = submit_reloc(submit, obj, submit->cmd[i].offset * 4, From patchwork Fri Oct 27 16:58:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 13438658 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 B92B3C25B47 for ; Fri, 27 Oct 2023 16:59:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4CB0410EA17; Fri, 27 Oct 2023 16:59:20 +0000 (UTC) Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5E9DE10EA16; Fri, 27 Oct 2023 16:59:19 +0000 (UTC) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1c9de3f66e5so18333355ad.3; Fri, 27 Oct 2023 09:59:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698425958; x=1699030758; darn=lists.freedesktop.org; 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=iCHqUpshEkU4uWbTOdbsyvXx4BZI7LlABnlafBr9UIc=; b=WKfQluKJfs+ceID1oIPOs4IdmbMROYObRiMyPpiXDiTRIh5Na30xRU71xxMPWrJGlK Apq8fwjN5VtBin/mB/45kqGDK5fvAxf7UD5nnY2SomqzqXBI6EwRbrM25NyNHEJR083S mR4Z3yqdt45qslthznpOUKp+cJGxO5D8kk908Mkhb+ykNPn/HmIxj+gmFjVgYB9dh41t T4OAPMTzH5pTHopx2FqVXzuFqR50W8LN5A0G49i0zIYzzx9xAJ0R+2pKkNHCLWgORP30 g3mUDDjSW8Cc56LbVTUN3qSXXnpMoMjtI+gPpK8wHIsN/NtwOcHyDxL4mz2d9Zm5lPx2 4kFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698425958; x=1699030758; 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=iCHqUpshEkU4uWbTOdbsyvXx4BZI7LlABnlafBr9UIc=; b=L4LUUUNi+EcNe7KvSVUpDejUEcAZHzTLJMGceaM9sf3nmK26kHKczQFLf4+pT9zfID ZB6EsSAf89TweVm1KBPl01Y0x9yd3GVviyyTmegqzrNGY8u9vz4zs+c1hTmzSob/6d/O M4Jh7KTMww2lt5jJixVuOjqICA7GwGjNvFv2SxJ+fyj+PgcgkMfIs+/krgCdOwnT7cRB Q6xS9dIp8eHLXsQhf5C4n02+jgj6etDmPBrM6ViDukkFM2tu6UzbPBIj/SwmmKorATDe 5caC7eZx4tgpNDmR3jhimOKIRafhuY/VWtEm+0Hcir0IUR7Hcv0dSuwpaqWt+TLyh5Zo 39YA== X-Gm-Message-State: AOJu0Yz406FPDRkQmhzHOqvY50fklUgbaJ8wJVFtl5qKa7yGq8J0Lax+ ftv5Xh831R3B7bW/+EkHoWoGm1cfwfc= X-Google-Smtp-Source: AGHT+IE1CRcZ68zfn23VeMoSQ6OlsNc9UY4jVYsIdmVtGSYUiW5fTt9cYVK7YDD7M/nHh0YLWuRTjA== X-Received: by 2002:a17:902:f34d:b0:1ca:e4b:148d with SMTP id q13-20020a170902f34d00b001ca0e4b148dmr2584344ple.65.1698425958278; Fri, 27 Oct 2023 09:59:18 -0700 (PDT) Received: from localhost ([2a00:79e1:abd:4a00:6c80:7c10:75a0:44f4]) by smtp.gmail.com with ESMTPSA id w9-20020a170902e88900b001b7fd27144dsm1797802plg.40.2023.10.27.09.59.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 09:59:17 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/7] drm/msm/gem: Remove submit_unlock_unpin_bo() Date: Fri, 27 Oct 2023 09:58:36 -0700 Message-ID: <20231027165859.395638-3-robdclark@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231027165859.395638-1-robdclark@gmail.com> References: <20231027165859.395638-1-robdclark@gmail.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: Rob Clark , linux-arm-msm@vger.kernel.org, Abhinav Kumar , open list , Sean Paul , Dmitry Baryshkov , Marijn Suijten , freedreno@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Rob Clark The only point it is called is before pinning objects, so the "unpin" part of the name is fiction. Just remove call submit_cleanup_bo() directly. Signed-off-by: Rob Clark Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/msm_gem_submit.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c index 996274ef32a6..2d5527dc3e1a 100644 --- a/drivers/gpu/drm/msm/msm_gem_submit.c +++ b/drivers/gpu/drm/msm/msm_gem_submit.c @@ -272,12 +272,6 @@ static void submit_cleanup_bo(struct msm_gem_submit *submit, int i, dma_resv_unlock(obj->resv); } -static void submit_unlock_unpin_bo(struct msm_gem_submit *submit, int i) -{ - unsigned cleanup_flags = BO_PINNED | BO_LOCKED; - submit_cleanup_bo(submit, i, cleanup_flags); -} - /* This is where we make sure all the bo's are reserved and pin'd: */ static int submit_lock_objects(struct msm_gem_submit *submit) { @@ -313,10 +307,10 @@ static int submit_lock_objects(struct msm_gem_submit *submit) } for (; i >= 0; i--) - submit_unlock_unpin_bo(submit, i); + submit_cleanup_bo(submit, i, BO_LOCKED); if (slow_locked > 0) - submit_unlock_unpin_bo(submit, slow_locked); + submit_cleanup_bo(submit, slow_locked, BO_LOCKED); if (ret == -EDEADLK) { struct drm_gem_object *obj = submit->bos[contended].obj; From patchwork Fri Oct 27 16:58:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 13438659 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 9C823C25B48 for ; Fri, 27 Oct 2023 16:59:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C690F10E141; Fri, 27 Oct 2023 16:59:24 +0000 (UTC) Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8A0DB10EA1B; Fri, 27 Oct 2023 16:59:21 +0000 (UTC) Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-564af0ac494so1928608a12.0; Fri, 27 Oct 2023 09:59:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698425960; x=1699030760; darn=lists.freedesktop.org; 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=hu1FhjWQAAQQu/erPFOwuagpkPUc4fNsZ+YMm7C14LI=; b=CNfLHjt+9Pl7BslZVNBa0gQJJWlfc/Qzq0hzEvl+MOzWyp+Mg7QJMEzXb1L+eleKNx oa3a4W4jcmjIYLukDRPaLXeop8cFIGYtSRff6ciP+bBBFKyZhenjU5vxAl5jjp/kxAbp m/36c8weGzXOv2WsXqupK3S656wrjUj4Uxw6E5pRC7STY/qnz8gq75hIUYHCrQUOy/5e ssnutglzSFDQM/irSyjXeaOeJ8BYf5qU/zOYfJRRBsSqjL56VKLnmwoNphF6Cx9s0XZH w28p01yFL1nHcY9v8chmkHzYnGcVqtZe/XPgyqLF8xsXxYuCDh9oFPEEqNA/EXdjPlUy 2hTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698425960; x=1699030760; 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=hu1FhjWQAAQQu/erPFOwuagpkPUc4fNsZ+YMm7C14LI=; b=q2fQXj8HoJrX57bb5u01/We1FzP36ev8zIB/CyK3E7xyO0rDYKhKdgD+pcwryJcOak wJXrMYDXO/CGkjO2udlC/KrfATp7jnhp0ZCj0Jfhfgil9kX5Hl9PWGhzFbzAwuFycJ6l CW5GpxkKINYCj+jiXzooUBa7+MHbo7XV2qc1EdicSuumwzxGbZioei0xl39/vjaDKo1A YtTRkk4rrzdH0BKKk8QjRO9aIoV1uW69k50OeMm3C7MA3uTdBW/QJ0XP2YWYI3vTTkWK wfKwloHjLKEvMjknuNh/kGpoV+2ZoXHQ11wTBnBA10dHPYQxalD1UwAMXg2tM3X3jYR+ afjw== X-Gm-Message-State: AOJu0YyT5EUTlGhRbTKrqI0KxNXmjK//jU2ZnzhctOyeMF7ZQXeBwqYr BbnRKTpFHglGAUR37GTMaXmG2TQy4Pg= X-Google-Smtp-Source: AGHT+IGq/OT51OWFTDYcHIvbMyrTngDK3vmX2a/+eGD+RvH40j5mBW0SCq03abTpvLoM4Y/jLrb/8A== X-Received: by 2002:a17:90a:77c2:b0:27d:5cca:9b69 with SMTP id e2-20020a17090a77c200b0027d5cca9b69mr3056136pjs.45.1698425960498; Fri, 27 Oct 2023 09:59:20 -0700 (PDT) Received: from localhost ([2a00:79e1:abd:4a00:6c80:7c10:75a0:44f4]) by smtp.gmail.com with ESMTPSA id x5-20020a17090abc8500b002800eeafd79sm1301858pjr.52.2023.10.27.09.59.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 09:59:19 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/7] drm/msm/gem: Don't queue job to sched in error cases Date: Fri, 27 Oct 2023 09:58:37 -0700 Message-ID: <20231027165859.395638-4-robdclark@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231027165859.395638-1-robdclark@gmail.com> References: <20231027165859.395638-1-robdclark@gmail.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: Rob Clark , linux-arm-msm@vger.kernel.org, Abhinav Kumar , open list , Sean Paul , Dmitry Baryshkov , Marijn Suijten , freedreno@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Rob Clark We shouldn't be running the job in error cases. This also avoids having to think too hard about where the objs get unpinned (and if necessary, the resv takes over tracking that the obj is busy).. ie. error cases it always happens synchronously, and normal cases it happens from scheduler job_run() callback. Signed-off-by: Rob Clark Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/msm_gem_submit.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c index 2d5527dc3e1a..786b48a55309 100644 --- a/drivers/gpu/drm/msm/msm_gem_submit.c +++ b/drivers/gpu/drm/msm/msm_gem_submit.c @@ -946,6 +946,9 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data, } } + if (ret) + goto out; + submit_attach_object_fences(submit); /* The scheduler owns a ref now: */ From patchwork Fri Oct 27 16:58:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 13438660 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 03A93C25B47 for ; Fri, 27 Oct 2023 16:59:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1CD6F10EA1D; Fri, 27 Oct 2023 16:59:32 +0000 (UTC) Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by gabe.freedesktop.org (Postfix) with ESMTPS id C8B3910E141; Fri, 27 Oct 2023 16:59:23 +0000 (UTC) Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1c5cd27b1acso20718035ad.2; Fri, 27 Oct 2023 09:59:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698425963; x=1699030763; darn=lists.freedesktop.org; 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=XjlFqD57WfpyH15rLpP1GN1DPt5ddZpCcGr9BQH7/rg=; b=TPCKdjLf/qPr+kPCDQ3U6MPhzNMm+HKahvkhNXpzfy8sV8SktPugA8bOz85TFwIqlA IpcOXM0jUXADaCim9kjauJs7nxO6ww4b7oR2V8Llo+mFizDSqD5jXA9tzO7vyxMiBe2x 88MudDcXLnXyCQzkSYFf9oUxFdEyMnKPhBMX1cdmb8rBhLjCW8fTsJfMYfTKN9Hf00uu /nQic+vkjCVvSIs7tfSKQZ5ZGILUFnMfR53fehy4YCZeyvZmEaKapor1CkqtZHx4oBMf bk61oY4yxULqTDR3hzsZwyGMgguXYENlDb9IRG5HhH2vPiIriWDg/6+/8Pf2M6wZmyPv uY8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698425963; x=1699030763; 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=XjlFqD57WfpyH15rLpP1GN1DPt5ddZpCcGr9BQH7/rg=; b=pzvnZKPRHE3F+jlXYtk+294rTdyX0q8JzZuBzaAC+sUO2HLoFPLaA0teAPSzFNqULZ hwKBEdh0ippwsNtmYPE3VMOcVs/yuHxYlVBO/pBvV8XUbOC/454s+IuUZCIuMU5HVbvm HYeMfQb2aIB6ab74RbNJxvaitz6QHnOej7OVnIlLtsnq0QbSg4S38WkGIqDDDIbEk7UE U0E1WI69WCsCKputHhABOQN88EBMjDtTjNRq1HYdUjVx6ssTdF1F885bKi9x1sMpoIAt DsTvMsI9q2vl0+28tTRqR1FiFJIIXW9JESb9nlgE4tX13n24Cel+IiCBqCWMkqIYb+Mv GzcA== X-Gm-Message-State: AOJu0YwZzqyLAXAsjFTQOcph8bAgMYF4dIzKLnUul/+cd41PpPxZ5Jjk JAmWIY2KfDrLMrcV5kauw6tNZcbgi30= X-Google-Smtp-Source: AGHT+IGPy24qVA2bmVsf4hNeMCi1FeUtZRRCpcB1pe5z5inrUzOFQz1HOi4HLF/CMbxMpJNP96x7oA== X-Received: by 2002:a17:902:f54c:b0:1c9:cc88:5029 with SMTP id h12-20020a170902f54c00b001c9cc885029mr3772962plf.32.1698425962797; Fri, 27 Oct 2023 09:59:22 -0700 (PDT) Received: from localhost ([2a00:79e1:abd:4a00:6c80:7c10:75a0:44f4]) by smtp.gmail.com with ESMTPSA id m18-20020a170902db1200b001bde6fa0a39sm1800366plx.167.2023.10.27.09.59.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 09:59:22 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Subject: [PATCH 4/7] drm/msm/gem: Split out submit_unpin_objects() helper Date: Fri, 27 Oct 2023 09:58:38 -0700 Message-ID: <20231027165859.395638-5-robdclark@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231027165859.395638-1-robdclark@gmail.com> References: <20231027165859.395638-1-robdclark@gmail.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: Rob Clark , linux-arm-msm@vger.kernel.org, Abhinav Kumar , open list , Sean Paul , Dmitry Baryshkov , Marijn Suijten , freedreno@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Rob Clark Untangle unpinning from unlock/unref loop. The unpin only happens in error paths so it is easier to decouple from the normal unlock path. Since we never have an intermediate state where a subset of buffers are pinned (ie. we never bail out of the pin or unpin loops) we can replace the bo state flag bit with a global flag in the submit. Signed-off-by: Rob Clark --- drivers/gpu/drm/msm/msm_gem.h | 6 +++--- drivers/gpu/drm/msm/msm_gem_submit.c | 22 +++++++++++++++++----- drivers/gpu/drm/msm/msm_ringbuffer.c | 3 ++- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_gem.h b/drivers/gpu/drm/msm/msm_gem.h index c36c1c1fa222..af884ced7a0d 100644 --- a/drivers/gpu/drm/msm/msm_gem.h +++ b/drivers/gpu/drm/msm/msm_gem.h @@ -270,8 +270,9 @@ struct msm_gem_submit { int fence_id; /* key into queue->fence_idr */ struct msm_gpu_submitqueue *queue; struct pid *pid; /* submitting process */ - bool fault_dumped; /* Limit devcoredump dumping to one per submit */ - bool in_rb; /* "sudo" mode, copy cmds into RB */ + bool bos_pinned : 1; + bool fault_dumped:1;/* Limit devcoredump dumping to one per submit */ + bool in_rb : 1; /* "sudo" mode, copy cmds into RB */ struct msm_ringbuffer *ring; unsigned int nr_cmds; unsigned int nr_bos; @@ -288,7 +289,6 @@ struct msm_gem_submit { struct { /* make sure these don't conflict w/ MSM_SUBMIT_BO_x */ #define BO_LOCKED 0x4000 /* obj lock is held */ -#define BO_PINNED 0x2000 /* obj (pages) is pinned and on active list */ uint32_t flags; union { struct drm_gem_object *obj; diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c index 786b48a55309..d001bf286606 100644 --- a/drivers/gpu/drm/msm/msm_gem_submit.c +++ b/drivers/gpu/drm/msm/msm_gem_submit.c @@ -265,9 +265,6 @@ static void submit_cleanup_bo(struct msm_gem_submit *submit, int i, */ submit->bos[i].flags &= ~cleanup_flags; - if (flags & BO_PINNED) - msm_gem_unpin_locked(obj); - if (flags & BO_LOCKED) dma_resv_unlock(obj->resv); } @@ -407,13 +404,28 @@ static int submit_pin_objects(struct msm_gem_submit *submit) mutex_lock(&priv->lru.lock); for (i = 0; i < submit->nr_bos; i++) { msm_gem_pin_obj_locked(submit->bos[i].obj); - submit->bos[i].flags |= BO_PINNED; } mutex_unlock(&priv->lru.lock); + submit->bos_pinned = true; + return ret; } +static void submit_unpin_objects(struct msm_gem_submit *submit) +{ + if (!submit->bos_pinned) + return; + + for (int i = 0; i < submit->nr_bos; i++) { + struct drm_gem_object *obj = submit->bos[i].obj; + + msm_gem_unpin_locked(obj); + } + + submit->bos_pinned = false; +} + static void submit_attach_object_fences(struct msm_gem_submit *submit) { int i; @@ -525,7 +537,7 @@ static void submit_cleanup(struct msm_gem_submit *submit, bool error) unsigned i; if (error) - cleanup_flags |= BO_PINNED; + submit_unpin_objects(submit); for (i = 0; i < submit->nr_bos; i++) { struct drm_gem_object *obj = submit->bos[i].obj; diff --git a/drivers/gpu/drm/msm/msm_ringbuffer.c b/drivers/gpu/drm/msm/msm_ringbuffer.c index 9d6e2e10d25a..7ea5eca118eb 100644 --- a/drivers/gpu/drm/msm/msm_ringbuffer.c +++ b/drivers/gpu/drm/msm/msm_ringbuffer.c @@ -29,9 +29,10 @@ static struct dma_fence *msm_job_run(struct drm_sched_job *job) struct drm_gem_object *obj = submit->bos[i].obj; msm_gem_unpin_active(obj); - submit->bos[i].flags &= ~BO_PINNED; } + submit->bos_pinned = false; + mutex_unlock(&priv->lru.lock); msm_gpu_submit(gpu, submit); From patchwork Fri Oct 27 16:58:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 13438661 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 D19B5C25B6F for ; Fri, 27 Oct 2023 16:59:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AD0B810EA1F; Fri, 27 Oct 2023 16:59:32 +0000 (UTC) Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by gabe.freedesktop.org (Postfix) with ESMTPS id DD52B10EA1D; Fri, 27 Oct 2023 16:59:25 +0000 (UTC) Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-280208d0679so139584a91.3; Fri, 27 Oct 2023 09:59:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698425965; x=1699030765; darn=lists.freedesktop.org; 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=2BA1fIFWWJwK3F1h9NsiUN1cc0sAjE3mQ5LVwLgXV8Q=; b=Ec5oCFSDOBihlIiFRsq3UnPFPVvLK10ul2bocPgT0YAfxt65re8m5p1ci9rlxEk1Hy YOf4/RaDRO+dbpMuGp+GvRRPgZwDJYAcw4h+9kf25LlRHnRru+yojvuyRyUWzN/OE06f bPsqnhHtTDy5pgnv2b4+krp0EW06fjuWWgZqJzLR4gwSNmNXOimVPdn5+ssVi7YqgkFW +E1Pr1pld9uBCPzf0cvPaIueCSXbg2SYRGx3Cyh2EJ58pwGbnRGTpBYqn6/w3Q1fx1fT svE6YVAr5mJd4ACtM1asP/0u/vRb5JjWG5+/T9e6S5TuwEqm+6RSDkIqffAx3Hq/wI1M 2uJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698425965; x=1699030765; 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=2BA1fIFWWJwK3F1h9NsiUN1cc0sAjE3mQ5LVwLgXV8Q=; b=nifJ8n1zg4Th9HPPa1O1fPyAtD8IHSbTj3YnZ52vjbtIu+nNSY991tJBFgaefEEqAr 1wG4FT9AGoDcKRSOqA7xNX7JTX31NNoIBKGtrKTQkbvNmeS2DMf6BafpRZQvZDMQjAS4 VkdVCpeqJra2kd6FIkDxSJuU12uK9FhCUV84cl8wEqEBAWHRSESzsigy8s8GDYcgj1Ri vQX1rO3ixN78ZnUSh69XIVKw5t2re0zL3qZR/UljDOkDaPR/FViQ+QwkJfyN/S4L62Al 90nsS8sUaiDGunl5cdusIITKnbKeeii8YhSdyDI5UEnQ1G+OlD22FaEz1R7Mag8U4Ynr CEwQ== X-Gm-Message-State: AOJu0YwUWdxOIVcOzCoCFiz9lstCv5AgXa/PETWJf2R127uf2y3wJyk1 9vb8aXLrD8xCCAOLfJPoYkxPko7+DXY= X-Google-Smtp-Source: AGHT+IH/uki0khux3haTMmLK51tgfszYjsxvRsbP4tOoqeorUKEKoGJdToiXOeNo+Y2KebPoIO/3GA== X-Received: by 2002:a17:90a:6e48:b0:27d:9f6:47b1 with SMTP id s8-20020a17090a6e4800b0027d09f647b1mr2892882pjm.33.1698425964884; Fri, 27 Oct 2023 09:59:24 -0700 (PDT) Received: from localhost ([2a00:79e1:abd:4a00:6c80:7c10:75a0:44f4]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001bd99fd1114sm1780352plh.288.2023.10.27.09.59.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 09:59:24 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Subject: [PATCH 5/7] drm/msm/gem: Cleanup submit_cleanup_bo() Date: Fri, 27 Oct 2023 09:58:39 -0700 Message-ID: <20231027165859.395638-6-robdclark@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231027165859.395638-1-robdclark@gmail.com> References: <20231027165859.395638-1-robdclark@gmail.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: Rob Clark , linux-arm-msm@vger.kernel.org, Abhinav Kumar , open list , Sean Paul , Dmitry Baryshkov , Marijn Suijten , freedreno@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Rob Clark Now that it only handles unlock duty, drop the superfluous arg and rename it. Signed-off-by: Rob Clark --- drivers/gpu/drm/msm/msm_gem_submit.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c index d001bf286606..603f04d851d9 100644 --- a/drivers/gpu/drm/msm/msm_gem_submit.c +++ b/drivers/gpu/drm/msm/msm_gem_submit.c @@ -248,14 +248,10 @@ static int submit_lookup_cmds(struct msm_gem_submit *submit, return ret; } -/* Unwind bo state, according to cleanup_flags. In the success case, only - * the lock is dropped at the end of the submit (and active/pin ref is dropped - * later when the submit is retired). - */ -static void submit_cleanup_bo(struct msm_gem_submit *submit, int i, - unsigned cleanup_flags) +static void submit_unlock_bo(struct msm_gem_submit *submit, int i) { struct drm_gem_object *obj = submit->bos[i].obj; + unsigned cleanup_flags = BO_LOCKED; unsigned flags = submit->bos[i].flags & cleanup_flags; /* @@ -304,10 +300,10 @@ static int submit_lock_objects(struct msm_gem_submit *submit) } for (; i >= 0; i--) - submit_cleanup_bo(submit, i, BO_LOCKED); + submit_unlock_bo(submit, i); if (slow_locked > 0) - submit_cleanup_bo(submit, slow_locked, BO_LOCKED); + submit_unlock_bo(submit, slow_locked); if (ret == -EDEADLK) { struct drm_gem_object *obj = submit->bos[contended].obj; @@ -533,7 +529,6 @@ static int submit_reloc(struct msm_gem_submit *submit, struct drm_gem_object *ob */ static void submit_cleanup(struct msm_gem_submit *submit, bool error) { - unsigned cleanup_flags = BO_LOCKED; unsigned i; if (error) @@ -541,7 +536,7 @@ static void submit_cleanup(struct msm_gem_submit *submit, bool error) for (i = 0; i < submit->nr_bos; i++) { struct drm_gem_object *obj = submit->bos[i].obj; - submit_cleanup_bo(submit, i, cleanup_flags); + submit_unlock_bo(submit, i); if (error) drm_gem_object_put(obj); } From patchwork Fri Oct 27 16:58:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 13438662 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 13190C25B6F for ; Fri, 27 Oct 2023 16:59:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E4D8810EA1B; Fri, 27 Oct 2023 16:59:41 +0000 (UTC) Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3B55310EA1F; Fri, 27 Oct 2023 16:59:32 +0000 (UTC) Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6b201a93c9cso2188034b3a.0; Fri, 27 Oct 2023 09:59:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698425971; x=1699030771; darn=lists.freedesktop.org; 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=q8RmDco3yC3v+3yvrh6eYN9grmgq77s+0DKqGNckmlM=; b=Gbep6wYJaxrb9wj+bsCTVpXjJtWLCDYK8P3k89UpAM03ThR/c8XseoCTBdR/yFPl5x MV/dMI27WLZjcEDt8eCyRdsh920aGnXDeLDRcJC6+3kpxICvfvQ3v3p2hosTm7c5D/ck 1X6cyG+LPpan3LHjYD13J4OZHG5ItDntfYDFsFvpcBm3N+cArpn7CuTbmpo4c3oRr3uM TpBKbItSfRheMDQ8fvG8gXJp3aPVrlXbYyF4KNBE0HKWTveDW9k6R3qnS8Rljihwrmup YQvrXMRlFLjjnN8sRhnikklbG0d7/CSE872gJ0Y9HB5kUe5SLsAAhmA9iQvhjpPYAu5t Jw0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698425971; x=1699030771; 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=q8RmDco3yC3v+3yvrh6eYN9grmgq77s+0DKqGNckmlM=; b=uSVNQByHJtnYhKhmyeh4ch51iT2ldmme3pP4n2Hrto0+XE1k4evy1jDz/kGtWn2kWQ NA+dIpyRbvd5gOvhNjlkC1S5ue8gpkxvCx1CXZYv+Oo1ev8VUV8DBpoyNSnPF6DYP5FX XTyOfu/E8UH1kS/fHkEXtNPVFgvTelrY6YiSOCSCHSxXTomBpYTWxJUpE3zUvXvBFlbv QVPwHO00h0naOCeaeSA9xiqv4swkHYQOWPMz68u/kHUP2hCcJtDp6+C0PiM2tdGNTyD6 w8VEAz1iXtEc5UdqTxQ8yfFwS3QjJSgK8KA2/Jd/xT8xcEE3aVqJueJbdFYYN+OrtI6L +SDQ== X-Gm-Message-State: AOJu0YzJAld9c2dWv+JDmTStniWcCiYLcEuU7dPdD9DVSiuykaUWAHTz GZ69SesFMUcjWHdH2F14JEbPaoBqAcaIWg== X-Google-Smtp-Source: AGHT+IGcCDjD1BW09esItqwaRO3LZ9+ZgRLPW1fpZoKAd4lXmN90PAUSB93jicmG79kEPwmifa05mw== X-Received: by 2002:a05:6a00:2356:b0:6b1:bf32:4fb5 with SMTP id j22-20020a056a00235600b006b1bf324fb5mr3294581pfj.28.1698425971178; Fri, 27 Oct 2023 09:59:31 -0700 (PDT) Received: from localhost ([2a00:79e1:abd:4a00:6c80:7c10:75a0:44f4]) by smtp.gmail.com with ESMTPSA id r8-20020aa78b88000000b006b4ca26f3c9sm1605609pfd.74.2023.10.27.09.59.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 09:59:30 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Subject: [PATCH 6/7] drm/exec: Pass in initial # of objects Date: Fri, 27 Oct 2023 09:58:40 -0700 Message-ID: <20231027165859.395638-7-robdclark@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231027165859.395638-1-robdclark@gmail.com> References: <20231027165859.395638-1-robdclark@gmail.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: Kefeng Wang , Karol Herbst , "open list:DRM DRIVER FOR NVIDIA GEFORCE/QUADRO GPUS" , Mario Limonciello , Srinivasan Shanmugam , Rob Clark , Guchun Chen , Shashank Sharma , "open list:RADEON and AMDGPU DRM DRIVERS" , Dong Chenchen , Luben Tuikov , Ben Skeggs , Philip Yang , Arunpravin Paneer Selvam , linux-arm-msm@vger.kernel.org, Maxime Ripard , Suren Baghdasaryan , Jack Xiao , Jonathan Kim , freedreno@lists.freedesktop.org, Felix Kuehling , "Pan, Xinhui" , open list , Thomas Zimmermann , Alex Deucher , Andrew Morton , Lang Yu , =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Rob Clark In cases where the # is known ahead of time, it is silly to do the table resize dance. Signed-off-by: Rob Clark --- 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); /* 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); From patchwork Fri Oct 27 16:58:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 13438663 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 BA958C25B47 for ; Fri, 27 Oct 2023 16:59:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CD90110EA19; Fri, 27 Oct 2023 16:59:41 +0000 (UTC) Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9A35B10EA21; Fri, 27 Oct 2023 16:59:34 +0000 (UTC) Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1ca816f868fso18705255ad.1; Fri, 27 Oct 2023 09:59:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698425973; x=1699030773; darn=lists.freedesktop.org; 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=lBQNNIt/vkL5JM4K598Nxz2cKMUcFsO25vk1EUXbR50=; b=aEV1LyDb/XygcDNbMtEHBDgMeu0IhIyzvmOq1ELZuiLNGbRORGYR5mZJaqmVg/ptok z9nKkW3mKLEELckxXiR1Pls4MpvmlEuWEqpRGVUJ9VLLzhsLFDw+GkLeVN0RxFUe7IIn QQ7HWisl37d7lA8OzbAGeKpMp44FOpyVE6V/LYg9TTCBTULAeov/pBD/rIxtD5q5802Z k2Dxgs4cDqgjCgpzZoh4D3O5UqN6JEOfFg/nuwz18MjIjn8pu8yXvy3+D7z2mixRn+2l tFMUTsoLTOtEBb3qH75YpqWd3tIR+q5esT5va9bSzSIZWBgMEMXdMD6usNU4VaHrg/7Y +/Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698425973; x=1699030773; 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=lBQNNIt/vkL5JM4K598Nxz2cKMUcFsO25vk1EUXbR50=; b=GmSoLi9BE0pAPyAk+aQ8ToAv11C0hmQh8ZM5vsienm3ROOfmJ800e8d7c5mVX2bTpp WGw65qEePLzdyZChy75nja5pY6KdSqDhqGwTxMD8SxcFXM7yRwFcRh+HgHjnp5rpY0Qs wFT7GUI2O447PoBz2wihbvlMjCkTE64UWcZt964zDWINAWStksURtzjjePOJ+Tv0aR64 1cf7DGxyJyGv24HLFvOGvLWqydYlp/92Dnb/WPd5zVuvIwam40HUaXIaVvxRbtWzcxYW 4hO76y3vkkCtkJRz0RFu5r/2hX8ycUM6UGxdsjKL8SmJlFEAh2i2s2i1eB7pAF/0QWxP DKcw== X-Gm-Message-State: AOJu0Yzgb7GyvwGTd+NTf13lupOlo145cqRweq1c4/mN9dWgcZvYyX13 WBeWhvjL1KNiBiLdAHrfK8z7jgKayv8= X-Google-Smtp-Source: AGHT+IHBTm+5z/fHBWh00iOPRyv7KaJ98NHocJTvikC6+us105MrhdbrvmxsHi4kdGraKDPXyJ9M0w== X-Received: by 2002:a17:903:110d:b0:1ca:d778:a9ce with SMTP id n13-20020a170903110d00b001cad778a9cemr4041902plh.38.1698425973365; Fri, 27 Oct 2023 09:59:33 -0700 (PDT) Received: from localhost ([2a00:79e1:abd:4a00:6c80:7c10:75a0:44f4]) by smtp.gmail.com with ESMTPSA id n14-20020a170902d2ce00b001c322a41188sm1801445plc.117.2023.10.27.09.59.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 09:59:32 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Subject: [PATCH 7/7] drm/msm/gem: Convert to drm_exec Date: Fri, 27 Oct 2023 09:58:41 -0700 Message-ID: <20231027165859.395638-8-robdclark@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231027165859.395638-1-robdclark@gmail.com> References: <20231027165859.395638-1-robdclark@gmail.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: Rob Clark , linux-arm-msm@vger.kernel.org, Abhinav Kumar , open list , Sean Paul , Dmitry Baryshkov , Marijn Suijten , freedreno@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Rob Clark Replace the ww_mutex locking dance with the drm_exec helper. Signed-off-by: Rob Clark --- drivers/gpu/drm/msm/Kconfig | 1 + drivers/gpu/drm/msm/msm_gem.h | 5 +- drivers/gpu/drm/msm/msm_gem_submit.c | 117 +++++---------------------- 3 files changed, 24 insertions(+), 99 deletions(-) diff --git a/drivers/gpu/drm/msm/Kconfig b/drivers/gpu/drm/msm/Kconfig index 6309a857ca31..f91d87afc0d3 100644 --- a/drivers/gpu/drm/msm/Kconfig +++ b/drivers/gpu/drm/msm/Kconfig @@ -16,6 +16,7 @@ config DRM_MSM select DRM_DP_AUX_BUS select DRM_DISPLAY_DP_HELPER select DRM_DISPLAY_HELPER + select DRM_EXEC select DRM_KMS_HELPER select DRM_PANEL select DRM_BRIDGE diff --git a/drivers/gpu/drm/msm/msm_gem.h b/drivers/gpu/drm/msm/msm_gem.h index af884ced7a0d..7f34263048a3 100644 --- a/drivers/gpu/drm/msm/msm_gem.h +++ b/drivers/gpu/drm/msm/msm_gem.h @@ -9,6 +9,7 @@ #include #include +#include "drm/drm_exec.h" #include "drm/gpu_scheduler.h" #include "msm_drv.h" @@ -254,7 +255,7 @@ struct msm_gem_submit { struct msm_gpu *gpu; struct msm_gem_address_space *aspace; struct list_head node; /* node in ring submit list */ - struct ww_acquire_ctx ticket; + struct drm_exec exec; uint32_t seqno; /* Sequence number of the submit on the ring */ /* Hw fence, which is created when the scheduler executes the job, and @@ -287,8 +288,6 @@ struct msm_gem_submit { struct drm_msm_gem_submit_reloc *relocs; } *cmd; /* array of size nr_cmds */ struct { -/* make sure these don't conflict w/ MSM_SUBMIT_BO_x */ -#define BO_LOCKED 0x4000 /* obj lock is held */ uint32_t flags; union { struct drm_gem_object *obj; diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c index 603f04d851d9..f8d14d4ccfef 100644 --- a/drivers/gpu/drm/msm/msm_gem_submit.c +++ b/drivers/gpu/drm/msm/msm_gem_submit.c @@ -248,85 +248,31 @@ static int submit_lookup_cmds(struct msm_gem_submit *submit, return ret; } -static void submit_unlock_bo(struct msm_gem_submit *submit, int i) -{ - struct drm_gem_object *obj = submit->bos[i].obj; - unsigned cleanup_flags = BO_LOCKED; - unsigned flags = submit->bos[i].flags & cleanup_flags; - - /* - * Clear flags bit before dropping lock, so that the msm_job_run() - * path isn't racing with submit_cleanup() (ie. the read/modify/ - * write is protected by the obj lock in all paths) - */ - submit->bos[i].flags &= ~cleanup_flags; - - if (flags & BO_LOCKED) - dma_resv_unlock(obj->resv); -} - /* This is where we make sure all the bo's are reserved and pin'd: */ static int submit_lock_objects(struct msm_gem_submit *submit) { - int contended, slow_locked = -1, i, ret = 0; - -retry: - for (i = 0; i < submit->nr_bos; i++) { - struct drm_gem_object *obj = submit->bos[i].obj; - - if (slow_locked == i) - slow_locked = -1; + int ret; - contended = i; + drm_exec_init(&submit->exec, DRM_EXEC_INTERRUPTIBLE_WAIT, submit->nr_bos); - if (!(submit->bos[i].flags & BO_LOCKED)) { - ret = dma_resv_lock_interruptible(obj->resv, - &submit->ticket); + drm_exec_until_all_locked (&submit->exec) { + for (unsigned i = 0; i < submit->nr_bos; i++) { + struct drm_gem_object *obj = submit->bos[i].obj; + ret = drm_exec_prepare_obj(&submit->exec, obj, 1); + drm_exec_retry_on_contention(&submit->exec); if (ret) - goto fail; - submit->bos[i].flags |= BO_LOCKED; + goto error; } } - ww_acquire_done(&submit->ticket); - return 0; -fail: - if (ret == -EALREADY) { - SUBMIT_ERROR(submit, "handle %u at index %u already on submit list\n", - submit->bos[i].handle, i); - ret = -EINVAL; - } - - for (; i >= 0; i--) - submit_unlock_bo(submit, i); - - if (slow_locked > 0) - submit_unlock_bo(submit, slow_locked); - - if (ret == -EDEADLK) { - struct drm_gem_object *obj = submit->bos[contended].obj; - /* we lost out in a seqno race, lock and retry.. */ - ret = dma_resv_lock_slow_interruptible(obj->resv, - &submit->ticket); - if (!ret) { - submit->bos[contended].flags |= BO_LOCKED; - slow_locked = contended; - goto retry; - } - - /* Not expecting -EALREADY here, if the bo was already - * locked, we should have gotten -EALREADY already from - * the dma_resv_lock_interruptable() call. - */ - WARN_ON_ONCE(ret == -EALREADY); - } - +error: + drm_exec_fini(&submit->exec); return ret; } -static int submit_fence_sync(struct msm_gem_submit *submit, bool no_implicit) +static int submit_fence_sync(struct msm_gem_submit *submit) { int i, ret = 0; @@ -334,22 +280,6 @@ static int submit_fence_sync(struct msm_gem_submit *submit, bool no_implicit) struct drm_gem_object *obj = submit->bos[i].obj; bool write = submit->bos[i].flags & MSM_SUBMIT_BO_WRITE; - /* NOTE: _reserve_shared() must happen before - * _add_shared_fence(), which makes this a slightly - * strange place to call it. OTOH this is a - * convenient can-fail point to hook it in. - */ - ret = dma_resv_reserve_fences(obj->resv, 1); - if (ret) - return ret; - - /* If userspace has determined that explicit fencing is - * used, it can disable implicit sync on the entire - * submit: - */ - if (no_implicit) - continue; - /* Otherwise userspace can ask for implicit sync to be * disabled on specific buffers. This is useful for internal * usermode driver managed buffers, suballocation, etc. @@ -531,15 +461,13 @@ static void submit_cleanup(struct msm_gem_submit *submit, bool error) { unsigned i; - if (error) + if (error) { submit_unpin_objects(submit); - - for (i = 0; i < submit->nr_bos; i++) { - struct drm_gem_object *obj = submit->bos[i].obj; - submit_unlock_bo(submit, i); - if (error) - drm_gem_object_put(obj); + /* job wasn't enqueued to scheduler, so early retirement: */ + msm_submit_retire(submit); } + + drm_exec_fini(&submit->exec); } void msm_submit_retire(struct msm_gem_submit *submit) @@ -733,7 +661,6 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data, struct msm_submit_post_dep *post_deps = NULL; struct drm_syncobj **syncobjs_to_reset = NULL; int out_fence_fd = -1; - bool has_ww_ticket = false; unsigned i; int ret; @@ -839,15 +766,15 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data, goto out; /* copy_*_user while holding a ww ticket upsets lockdep */ - ww_acquire_init(&submit->ticket, &reservation_ww_class); - has_ww_ticket = true; ret = submit_lock_objects(submit); if (ret) goto out; - ret = submit_fence_sync(submit, !!(args->flags & MSM_SUBMIT_NO_IMPLICIT)); - if (ret) - goto out; + if (!(args->flags & MSM_SUBMIT_NO_IMPLICIT)) { + ret = submit_fence_sync(submit); + if (ret) + goto out; + } ret = submit_pin_objects(submit); if (ret) @@ -978,8 +905,6 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data, out: submit_cleanup(submit, !!ret); - if (has_ww_ticket) - ww_acquire_fini(&submit->ticket); out_unlock: mutex_unlock(&queue->lock); out_post_unlock: