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: 159016 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp749850vqb; Fri, 27 Oct 2023 10:01:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG5tqLsU2YBnMnwEEuy/qqVvROL3afE/HxSY4wbmxU0pbQO/PqOdQsZs3G7kwpgpzgSU4li X-Received: by 2002:a81:af5a:0:b0:583:307d:41bc with SMTP id x26-20020a81af5a000000b00583307d41bcmr3247540ywj.27.1698426076459; Fri, 27 Oct 2023 10:01:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698426076; cv=none; d=google.com; s=arc-20160816; b=MPJO1zavz1xOPEYtKYDn+tvbBB4YrmQQyjsQklFVb4FpeZNOWtMT6d6Ub7HS9zTqg7 o1jkTTOpo7IvldUwZRD7PAzqXIJIi2M0+WqkWlnFj/KI9c/V44rFq0atCgAEPzsdUYAz cDIytBIBb/gDfPL0mTSHEyud9cOYtdZfQ6tPVxbZhokY+L3a+D9ZA7WxFELA1j3i6rUh d6Nh9Bd/qCwqhQ8liA11LxFISgrd0kXCNxuR210z3XS9omvF+XBx3o10yZLwpRnvH2bX KcrX4PPDcNEYQInNrsRqCYlT/uma0+4QdFGGDMHVYE7SqIjz+d6ziH3vD8LNpDnUO7nJ v+pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5R6dnp6JYl9GTg3p8/cfLvJpZVQTPFVKn1Jc3rRbi2Y=; fh=D+EPs4f1tbcirM+xOcOZ25ESgeHsz4zHs+gyKhf0s0I=; b=rruxZJxumHLt1Lpm180mLR6+rBXEHkgNyMAuVjN/d5dzpxe5r80vcNlCSWx3/UhtYO +0sE82X2lnnIGoTx54gXVyeJ6inugMXPgP3tWnq4db1hs9FYiNYVnzVdxBbzD8PBRXyX 6dXQKuDCh7g0ydt70Usw//Gw9YTVpFbu4RMnmreIeRcDKJXmKb8Rytu1HETe8jmr4Vcc r994yKli4JCf45u2d6N5z4/vDc1YLRNzGugyVjcY0Jjz5sJZrMDwKxcFNBq91Z/BbvxX Z8vvTnUKOxwTv3oFIFyrrbeaB9HT5UA5tQJNl991PytCIru7JjjyuDg88BYWXpkpBs80 XiyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=KagQFQXO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id z14-20020a81c20e000000b005920e2100c8si3124931ywc.234.2023.10.27.10.01.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 10:01:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=KagQFQXO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 55E8F8373431; Fri, 27 Oct 2023 10:00:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345907AbjJ0Q7V (ORCPT + 25 others); Fri, 27 Oct 2023 12:59:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229454AbjJ0Q7T (ORCPT ); Fri, 27 Oct 2023 12:59:19 -0400 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB42B128; Fri, 27 Oct 2023 09:59:16 -0700 (PDT) Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-5b8c39a2dceso1807122a12.2; Fri, 27 Oct 2023 09:59:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698425956; x=1699030756; darn=vger.kernel.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=KagQFQXObISaEISU+45Xa5HA+1ctecJbfNQDuigNAdrSELcbIDNH5PX+ovC4OIZr63 Tl2MofT8FPkRB4ti8e0X3Ur5/ySrxhuxYEaQZOYpGOBOdrwDaa0DSR0eUQMSA6yHFTZp QMVAQxEwwng6A9hRPSVQNPRg7SMZGX4poU4BU2Djh4JLU9ehYzL1e3zKNIIimygtndlX PrJDiTe/BMfonnOXE2wFdW/BRnetG7uYTqlyFqMe+Xwkseoy3qXZ0P6wQR1AKRTuN48t AkQwgO2fwoyrfwxF8DZMteNQZovcUowGabIauZGehVrMStrK0MpTSWtwDSF8DtJJ8GTZ 6oPA== 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=mAgRPxlG5wZNMW+x13WaP+kS2iAjceLANveb+KparvCaVxGv0SEA6/wcDtKeJjvzSb C6XCYxZxeo+m3NWm/9UX80Yyiyo64pXtMGbamMR9Co/GRnFGm0tosM85wIQSxq2CmCTx ncSCPF7Oyi3Cg7SRsB/pGIRYYdVUgyLFBJD4Y8qNKQlxI+5d/W3TVxW2+g229gZ4r9rL KVlJLQ4ktWtuXF3z6aDaMCtKPPL6B2HF9DvCxoGY25rFrrpGDndeOG/EfcBW0wjDvTaK iWX0EJOmTqMR3scOn/7w8EAhnVQHk3Up3gzgKURGEhTmLDpruaOCbKZ9mYeCL/JT7dtQ +T1Q== X-Gm-Message-State: AOJu0YxCC/G6h+rkWMTajjUkX0/tgG5gAje1mdTDP4QAjZt4Kj+6zUCP QNlpRBKc5dJcG+1o/MPuXpY= 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 Cc: freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, Rob Clark , Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter , linux-kernel@vger.kernel.org (open list) 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-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 27 Oct 2023 10:00:06 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780928821274244145 X-GMAIL-MSGID: 1780928821274244145 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: 159012 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp748644vqb; Fri, 27 Oct 2023 09:59:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGG6UlN3czCpDy35bhum7UGTdnehB0MIiNljxOF9ECHhe64GTONjPxVg2IVSGMXo4WSFyYS X-Received: by 2002:a25:cb47:0:b0:d9a:6855:14cd with SMTP id b68-20020a25cb47000000b00d9a685514cdmr3147038ybg.39.1698425985908; Fri, 27 Oct 2023 09:59:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698425985; cv=none; d=google.com; s=arc-20160816; b=RF+3NyFL3mi8T/6dkzjs1CTNKYnDQ936P5vH98qJuA2iGwszfcBwusLa4Xs/ZyhE3h WlwZtG/pUlDc058KVvszO6jz5cV+c0BkwDAPp1bFabMktJ8ROIn2hZhVQYwYK2weZ/R4 kdk0d0CKmw5FrlMImqCIGtCBtAMqckFbFPfObiYnObl3gxYiaE6T1sq07iSG2iTRbS1G Bm11UUjPpAkrDWk2q+tolxWiiPGxr8//Q6qYEh6ni6Z9psLj1FS6qct8F1MLAaCfrc5R j5takXj8KD5gRLFxORUA38vKKtb9ACkUVM9IH38VsUKDBpFbGq/0rPDBQNj+CVii3cdX NhuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iCHqUpshEkU4uWbTOdbsyvXx4BZI7LlABnlafBr9UIc=; fh=D+EPs4f1tbcirM+xOcOZ25ESgeHsz4zHs+gyKhf0s0I=; b=VJ1NX7P/Uj45YjfS/p9Fpzx0c4+ASgAX3oTpXzv29KkidcnG4hLcEaLDtdaswllXzI kQaZcxtmYJ7hhWxUZUWHQqAiqjXwJo8AI4hfWtFOBE71eX4v77OjGvQBfY3fENiJSQnZ eyOPfaZsq0NMAHrB+FvDSXkWuBp01c/n0rJwlObDqIZ2XdxgZQbIohCoL4GLyQ//Mpkg jKN1DdNQxpCcz1+XOzoOSEJdgF3e4fnoR3PB5ygHbqneeTFGwg1C2QkqZIMuah7BgA4q VbJa8N2zFuTwN8lmIZt4x80WM6k8j8AMJ8L3d53JQcS+o5hY53jW6sBx3/nY9g9lLgAG MB4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Y2D3Dev0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id f13-20020a25854d000000b00da0ad715df5si3283790ybn.305.2023.10.27.09.59.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 09:59:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Y2D3Dev0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 5FE0A82D3551; Fri, 27 Oct 2023 09:59:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345941AbjJ0Q7Y (ORCPT + 25 others); Fri, 27 Oct 2023 12:59:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345900AbjJ0Q7U (ORCPT ); Fri, 27 Oct 2023 12:59:20 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2CB4E1; Fri, 27 Oct 2023 09:59:18 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1c9bf22fe05so18345035ad.2; Fri, 27 Oct 2023 09:59:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698425958; x=1699030758; darn=vger.kernel.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=Y2D3Dev0YxhSuZG7DQue0kJbsaTscjpE8ecYc9xzg6gjvPc/vaB3SvTa5Hdbwx++6M onswnAMpneOB+pP50r21w48VMq0IuMyji38Sd7mxtearc8e9SM5hzl1khdIccAkUR9CJ TUloYaROz9CVUpmO+3jBcs647220Ncwb66onAQz89LCug9Cwn0pE9D7WK+YoinkfPLCd 3UW4t0oDjo3byqzuK9y+Vj0m0NRYYYUuDSk/y9afDHkaLQ/kZlMVtlZSGWj1ZjtbQhPt 5Qv71FBO6509bwKAf+c5wKDsjMSeyjpCwyOqV8L7j4S9x3UdFbbE7/Nfrw3OpBDMxGKL GXZQ== 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=T217RI5MlvPkCt/D93bt+eJZTP2eBqHcszPNkPCLcwuTpdrkpSxcvVcFhLejMO41AS XKS+D6daH+hVe1m1AHqTzFJ4//ixVrRAI6yrmq9wHURoOxmfkqkwSWwF/DpbmkWt/1Wf 1sk/JQG9EGfPW30+2nISD7fNo3YORCe23pOfcIFqbQRsAERwZYF98QxOEVY6LmLT+7zD 7cKfvbEcZxXMb2kB8FCcWFPAzj8kJddUjU0UEB5QHa9i32pSjVQCqmUws39e0KD1N2Tm VGbkhxZ9V9ocKHjgdQQbqPCOI2k+GWTsFzIfM5Oo+MEua4KwlQDKEgzTpdcvv8TyBFd9 AhKA== X-Gm-Message-State: AOJu0Yzn0pp6aJ37DICfxCoYMFXZtiMY6wrHjptTjYU1ai2EInzF4/xR /ZZERE2p1qgPaEi6dpO6lJc= 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 Cc: freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, Rob Clark , Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter , linux-kernel@vger.kernel.org (open list) 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-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 27 Oct 2023 09:59:43 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780928726678310014 X-GMAIL-MSGID: 1780928726678310014 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: 159015 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp749693vqb; Fri, 27 Oct 2023 10:01:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGlorx8ZUmI9ukMo5K2ZgIhXfQqH8Ilg/CjYkZbno5DGEb2n5v4ifb2L4DfkD/zta5eXz3E X-Received: by 2002:a9d:7752:0:b0:6b7:6e07:4951 with SMTP id t18-20020a9d7752000000b006b76e074951mr2947724otl.25.1698426065444; Fri, 27 Oct 2023 10:01:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698426065; cv=none; d=google.com; s=arc-20160816; b=NLhmy+FY0QzdvvJ9oSOZvc6vrTIHzUNLqUWV6g7jYWvPkm/gNxbVPmJQUKSgn4HFQj yqRRDdLBwBuz/fCGQLgjDrd8fGWzpt5HSF1TaZ/bdvB7mfUrM+IQj6NY1K9zXycYkQ/d lep2i3jvHeQGm+U/eGqpno5I1LuNdcUct3gm2pntG5tDdO12fxqv35xL+WrAWHBnSr31 qlwCNpfk4xTQqwEsV5LZKt6ijzQ0q8YRRrfQQvjwBKZKSjhxT03bZvOeGqD3J6zDb7G/ Rwg/mXfWor65QJc2jkhWdQcTwqN9UHrrECvmz4zA8ksLdL5oGEPI5NSdsFYyM2gTNeoi ++kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hu1FhjWQAAQQu/erPFOwuagpkPUc4fNsZ+YMm7C14LI=; fh=D+EPs4f1tbcirM+xOcOZ25ESgeHsz4zHs+gyKhf0s0I=; b=pVTd2iLKbEyvIeuv3+2uzPbjfJMM1etKCR2Jjm1xJewCL8JUBTlVHz1J8csy13ai5Z BJI/YM40JveTbtcVzTlGTUts1YLAbW8csFJxPE9wsanQ1wGAGRZbhyK14JfJbu1JL4wk xVHuKIREUmh4S/1FS/W4y+22Wb3sfkS0Gw5f+90pX+aQuGGE/N6gLO4FzezyxOrULaq0 WpN4VMo1DkjTbxGqIY9ghmxfYj8T1qRotGNjBEOnCnITCyHkZ/Lv1b/1DY/ZlkVtQn4K N/ZeGzyZVX1BxBLIShuhHleaYS1vqal/umgCVunHl12h6HkTTgHEeN8k5dgFQDgNvNR4 yPqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Z8Px8FgQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id q18-20020a056102205200b0045781a268fasi331484vsr.348.2023.10.27.10.00.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 10:01:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Z8Px8FgQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 381CA8051617; Fri, 27 Oct 2023 10:00:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345955AbjJ0Q7a (ORCPT + 25 others); Fri, 27 Oct 2023 12:59:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232192AbjJ0Q7W (ORCPT ); Fri, 27 Oct 2023 12:59:22 -0400 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24C971A5; Fri, 27 Oct 2023 09:59:21 -0700 (PDT) Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-5ac865d1358so1909468a12.3; 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=vger.kernel.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=Z8Px8FgQIUfLikDfmRD+S+Ca7zUkT2G3MvDc3Er6y2m2MQ+ngRbFsTtXlmofrc26vd nc24McslOsK7fWtBVfkJwYbSLGPetHBHV09phZ64Mu/OkFdMvrC/t+xSnAA6q8A8rBuL fmUaKqthzl6zBJv2A4aRWPNrvUKs6NtUFTLbQQy3wpInTikdZ8nxT6vsL7HKPIqdREpD kw3Mb9EDZZU4lR+HgtZUbVKaktkbDYfsg7CCzKcYWCNgw/s0H2uvlJ4iT6srig6clmxk mSTPek9De1+FEGi6/aKk4aWWGcrk8aSYUotPW73QNPrW0r3Yt931XYsbS+i39bzmwpAp ur/g== 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=f2IGeS3g4HCMOParykFikm4JosohtcmPTMRGTCYEIp1gjJyiPRXZx//aj7IQZGg2P4 r/ihpjje2q6MMQaYrLNJUIz096ZdCp9YJdgsl5eeUYZaHfM5dwPquDK3FBJFlKSHIDXD pS+R2bVG3I8wheHZV2qOap9msu1YnUzIo5mx6QbvznG/aJmJOFpi3MrUwi3BgwtcNv9+ 32qOworrJ+mIkvWmAD6Oky+W3lVgCNt81X36epehCONg2UQZAW0bCJzqLcx9aOt8UXhr stf5I+1QoWk6d5lctXuoQ6psU9EuiZ1CJfJrOr2kexJ93HfkWAoalneoNV5TlHIgLhyx DkEg== X-Gm-Message-State: AOJu0YzpUjgCtCrLuhiNHNnVmumsMSUaSLm2Cs66sL8wkFaYQWSjRUfn qq5gscFLm3dVriyBu8sDcVQ= 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 Cc: freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, Rob Clark , Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter , linux-kernel@vger.kernel.org (open list) 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-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 27 Oct 2023 10:00:01 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780928809781884043 X-GMAIL-MSGID: 1780928809781884043 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: 159011 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp748629vqb; Fri, 27 Oct 2023 09:59:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEXqp8LJkVFFgg1SRQwrPb6Y47dRJUMV3VSOmwLdijKcmXD5ydRUz7X8ROsJy2q0OWS5EXM X-Received: by 2002:a05:6358:8825:b0:168:e3c2:d1e4 with SMTP id hv37-20020a056358882500b00168e3c2d1e4mr3624348rwb.27.1698425984851; Fri, 27 Oct 2023 09:59:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698425984; cv=none; d=google.com; s=arc-20160816; b=UtKoJ7dUiPv0TNkqx2rLHXJy74lXTgC33kFVG0lcluBSjh1FAjqqwADCyzjm2V+2bD uklISZEtJqj3Vn5oQCWCFmVGGWDQenlDAJrdPgAS/JbPKaDcTV77vzmXgOn7B+RG3Mo6 5FKbkyl2kY6dKJzCKAomM6EMZugsgni8qaYaN0jZuI6RGXiw8CiBlgu12isbfwGbmaIL ViH+zD/d0JyQfpOS4WBDL7TaDZOlA886MTdAA8CXAE9Cb5C23ODq3OEl3tGOtjSqig8i 7pvqvjLxIeQ8S40A1iOPuqqvSwj16Dmy5zZOZtxwAiK7B/oUp03WPJPh1lVs2EIUVyu2 6E5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XjlFqD57WfpyH15rLpP1GN1DPt5ddZpCcGr9BQH7/rg=; fh=D+EPs4f1tbcirM+xOcOZ25ESgeHsz4zHs+gyKhf0s0I=; b=zjk88Yl38hVoIL16OXJeXFTr9lDt7oTJH7dKLiOA6nsLy5QTMKDTedKwX7jFid1q73 qDDxCnHafdCvVTSWuW9dcN9ttWmQ/TnJ3odv9LTKbqefFZJcg0jI7IQGJlpYM5Zc/Yar UsWppSFkL2B34OITu/jBfI1NO/cFehPQ3Te464JxfHwTaaaO9pFk76MdDTC0Pj8oz1cv dLsIFhm2q+AxGJc7xgZH7AkS8S7Sqk18swiYchHn0LqRMtdPHydoqMOu4tCF3UqYh7Qo 9G+LaGDfsyLwzz0EDYKV/fZiFVIzGL4uuTb3UbHTvPxz4f/OJyRBHHkcBlUyWAmJoLL3 CRRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="cUxvS/9V"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id s12-20020a81bf4c000000b005af903bdb66si3355522ywk.118.2023.10.27.09.59.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 09:59:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="cUxvS/9V"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 445E283792EF; Fri, 27 Oct 2023 09:59:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345964AbjJ0Q7e (ORCPT + 25 others); Fri, 27 Oct 2023 12:59:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345913AbjJ0Q72 (ORCPT ); Fri, 27 Oct 2023 12:59:28 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 646DE1B1; Fri, 27 Oct 2023 09:59:23 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1c9d407bb15so20893715ad.0; 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=vger.kernel.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=cUxvS/9Vt4SbdKAaWIcghUzSJRPF8rhvraxigXXQigm8kMQ7GHtq0joXA+l/RtaXNE GzKcFdSuXAtLKuy9XdshCVOfgtCkqWvTRwQkBp6SxuGoKJ2FJHSHZf6dWaAYE+yJq8W1 Qu5rtFXeRp+ohrQuC3BtoA4yELCm4ehVxCnzzSsdQ7sH9dxZRjrBwEyxpnE0iz0XLTOF hIIAdhBoc+xeYpdSlICxmiYPh9Gz+6HixSlj5Sv/YH0oLXAkvbiJnG/w7y7g+9wXB1aV GbGgpnepZY8Z8yi6i6qOJYbWglRvC/JmomrfczrA74z2Xidr2O/9eZi4hD50c3BtCbiK hftQ== 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=BnVE8odZfnXSmQ67wBOLa8tQBIAwLTTUhgniXGAR79j6/tCayJyBF+nS5kaRVNISE1 7Tw2Zfm3X5UZPt32UWKB+UtEd1S6QCMz0RaM874m4cLx19dElDFLaRMD2TNzIWBEjz+k vAVBrihHeNYSWZWtSLUOGGHAp+5dDDBOmJL8g/pxGH7g7gmWKnDphM5DSfQcw6D5kN+g wOeBb8QsUNyVviwvxcZM116R/odkYR94g3lCuOZnjfz3V87s4EpWrmrijULgYt0bzz+W ETJoYuLfzquyFats6Qgd/o914w6geAl6ZfsZJyrnrJzpuYfswl6oY7BtsRM9F7WcaTuJ /6KQ== X-Gm-Message-State: AOJu0YzGjLcX+lEELChB3iwL0q3Bmuwz1PY2Tn0CECOCMiAGyXyAqS/b 01T4+aKRo0lwjE0X7BgKBog= 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 Cc: freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, Rob Clark , Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter , linux-kernel@vger.kernel.org (open list) 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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 27 Oct 2023 09:59:43 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780928725624535447 X-GMAIL-MSGID: 1780928725624535447 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: 159013 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp748681vqb; Fri, 27 Oct 2023 09:59:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF2YraG70SPLDPa/oJcwCCNjq1ilh1U+umJDCxn1sIkSi2eeZ/uhgcXA+RTO35h3NVUywO1 X-Received: by 2002:a25:a428:0:b0:d9a:be79:c902 with SMTP id f37-20020a25a428000000b00d9abe79c902mr2685877ybi.53.1698425989767; Fri, 27 Oct 2023 09:59:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698425989; cv=none; d=google.com; s=arc-20160816; b=ogqO75Zx2kfU6GJLcV1Vw2EGTQUXG4IJFQdhHj37rCG/VnZf3b6o0jYYJcj5PcQVyX sol58JxNCgdAmHJ4tJLVKB6J5hqcKkWaqXI89aotEGt/eGv6Dv0zxbvkRou0Q+Jce2+n N9LdH3nEM7ybyAxGyqqtX+zVh0T20i/AbtY1Mv3qbXcX6ZFITk6PsrEw2kp7UbOXltEr qutUwo0v+57bErqFBBql9Z1VbKLwDbNhmLdReY3PTvasrMnZdvYLERhXXopO9UQ4KfPO 5plbgYJUumZw9hgE2oWR2y4wVCpWsBkUUnOPVSyIhatFEpxeQRqAS4jrhBYJRuN4WuxC idIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2BA1fIFWWJwK3F1h9NsiUN1cc0sAjE3mQ5LVwLgXV8Q=; fh=D+EPs4f1tbcirM+xOcOZ25ESgeHsz4zHs+gyKhf0s0I=; b=MNm5ebRX6dBFTq8a4l91jdG6pfX/zdsAjF4oLm8CyoYVa0KOZzc0PTgL0jjQ+c3tpz V304tsISnoJGo9uhspzMknSP187TwcAuofB97QIY2SMD9Ta/SqwS0ug6BE2b5Bmm0TG7 SiINOHQm59Qq2bpzTTgcSHYaeUwF9vwCl9Jm7GMAgVtZrunLVDH6CFWcOGbM+9Hw7Mvf zViTdbjJ5dziq3S50xbMWoSpro+QEi6voHVk79d88X77zU+7u7awl/48WUuwVSptL8zF 4D4DqutTDmAs+xUJizqamnwloVyGP17OmPd6EBnNkkVgqQFE/+XNHGs9D/OokTl0hkCs zKUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=grtnAZkM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id m62-20020a255841000000b00d800b9ae8f4si3362237ybb.242.2023.10.27.09.59.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 09:59:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=grtnAZkM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 9D13583AC0F3; Fri, 27 Oct 2023 09:59:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346104AbjJ0Q7i (ORCPT + 25 others); Fri, 27 Oct 2023 12:59:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345989AbjJ0Q73 (ORCPT ); Fri, 27 Oct 2023 12:59:29 -0400 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97D6ED43; Fri, 27 Oct 2023 09:59:25 -0700 (PDT) Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-5b94489e82eso499386a12.2; 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=vger.kernel.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=grtnAZkMBiacy9wvz1HmcE51JavK+Hv/lzCSAgm1dozsmdIf5wJ7b4e+Q/h6k1eBV5 J2WzCZmcqIYGEBgFu1MBYaBmAeI6lMlACMkx9WobyAJB5xa61n/DfjemdT3M3zGl/fxj Qu5GaBlIrZUx7FJkZBWizY3j1qtW5G0gI6C7K0IP+u4FHsPdN82Mauok6jAJPQT5U176 uGL+AXlfU4eRDiB5vsJd5FkRE2hnkgiNGiyOiR3XY9sGVhGtct8uq4x7i/WIyvhLssn1 XZiB/MHE2HUW2/t6eQ+8ztXcEBiVtufhduj1fzm6XB/cWf7EZXF5a3pwKQFAzjo6C1TH N+JA== 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=FpFJZIAGljesVjnWf2VGmxasWuWZ+UYwRzcNUAPQDnfVHxnd6WdhccicJr9xvTwQ6+ PiOTYLAxtD1yydaVQYuPwRhV56FiiZXEP/wKXUgRw/g7sr4gKnz4qwMeGMZf4Tqu3PCa Gaem7adb6q15jirumD0Alct33Lv8nNYsMALI2yQzUjTrlPxHFjuuQqH49fKgAukuoC4O dj5iou8Tn1UVDZKnVu5ofzN7h3kd7rnzjlUlBBy/tMsZ482WnOXInBEMvNgvNJzfmidl XXvvqQlQGV62+IqTYVa8kHYyuk2vnlPNWJJIizRoR/pmc/Ab7qrvgnUaDFM2KkxOh3+x vgJw== X-Gm-Message-State: AOJu0YxkG8OApizcVgzLnwAVUTKw8JFKTC1YdYLSKN27BvCv0uma6knN m4c8g4sU0TzNiWpCGzsA0So= 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 Cc: freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, Rob Clark , Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter , linux-kernel@vger.kernel.org (open list) 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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 27 Oct 2023 09:59:47 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780928730811283544 X-GMAIL-MSGID: 1780928730811283544 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: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: 159014 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp748899vqb; Fri, 27 Oct 2023 10:00:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHY8Ih7SwrmE3QNiE/DmRwSR7D1hfoiwgXSc2/HXmp7Lm8L3xtRlBj1W4mw4O+uzq+JmAUi X-Received: by 2002:a05:6870:1395:b0:1e9:87ce:133e with SMTP id 21-20020a056870139500b001e987ce133emr3518755oas.8.1698426008258; Fri, 27 Oct 2023 10:00:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698426008; cv=none; d=google.com; s=arc-20160816; b=Sx8vKvLEOS13Mj7k/W1DZ7OZsoRwKNjy+pOJCdrXESQFUYRrHA9FM/SWsz0YoKC6dG 6db6bXCOn7VEGGs7/f75Y4Bw5efQGwZ01z39kAbW1tl9IeU0+2gpoZI5G8haGoK0tJ2Z aoik/6kcDZXlTPEOxUZcxGwv7Ss9ZpXi/GhsQaVVBZUFZjAQwqiEQh2dI9YxyfSe58/a jm7pzoJ6NC2dlmwdp9ziHkjnuX+cbwtAJ1s1ApMAnUeFT8soPRxlN6vzngKmGZEPKtbx UiLixDC4F+vNVLS2vHJARizeVhrW9D5MsDgX9hDzfwYaTMEZHbatsuwrGkk2RtNT3qBr Bipg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lBQNNIt/vkL5JM4K598Nxz2cKMUcFsO25vk1EUXbR50=; fh=D+EPs4f1tbcirM+xOcOZ25ESgeHsz4zHs+gyKhf0s0I=; b=m2a/3rVwHuj1e/uFzbZgTX94YJy2dWd5GjyR4bylXan07MXxhDDlt6L1LJ4poADm4A ixbyAO0BdLjET+96ow4OlEgYuI0jSfz+crs+7ozYo2NQDCe6bWbYSeow8Lq5UrJ7ogS3 V8Lx8NR+7xbucQ6YvGIOEKnqOrUvnXR6RyIuaTdoHluZF2iPljMOkWQXP3T4qFNM0b3+ FTFXBXNCFQ0nLgTLN8DisgbJHYlj+QjUni6QaNGa+m6hQhN4F8Z3Ywj6lam7wD2oOB5J 3Il8qbYOwGy+HQqeCM2jA8b2YJx8rqflyKHqCzanxakTnTyfcat0uqPiTLf0WsmHSAg0 9Ixg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DEMabdwo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id q9-20020a258209000000b00d7fd681a51asi3466066ybk.732.2023.10.27.10.00.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 10:00:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DEMabdwo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 9D78582D3564; Fri, 27 Oct 2023 10:00:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346095AbjJ0Q7v (ORCPT + 25 others); Fri, 27 Oct 2023 12:59:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346061AbjJ0Q7j (ORCPT ); Fri, 27 Oct 2023 12:59:39 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E98E1B9; Fri, 27 Oct 2023 09:59:34 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1cacde97002so18684055ad.2; 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=vger.kernel.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=DEMabdwoNO48n81DRRGoyRioIddcGPVJlp9f76gpZn3eIIL2GiALcS7i1sfkERwxbA 3MpCvd30CnXrW+fbRBRN8GleOhqiZceiWy7Xio/29n8FZ9gS15EwcHckVDCtb7h1Mqa1 sHPmYFkdhDM018oYpE+Mpc0Pci1JU1MXPaPDljjFXTdtrmFyAX79SPjamOUtTjBHh05Q fNDMUadBRAqxL4mz8ZH9pTLtY4UYYzJ2nYLTgNqqp1i6oEgwe/t0G6guM1nb+NqF5Xw2 Or+UOSY3xlFEx1JpcvunsVXdT4Qh/pRzV1K6bRIMqRQ0mCX4WCCgAGgmrU2CUghmbXBZ 0Y0g== 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=sTTVpOnHPh1Y5BTs3piO5F0KbXErw5I8no6iJ0BJYFZJ7LCWVG6qZSZPk9vy370jCL g4QhHZyRrM8tr4KapKgAEilMU5K34+IxvtzqgKGopRMY58c4F4vyfzuLw4B3URpSyKkp LlDwCkt5yTbEhc5mzAf0JZYGmBIit+f5mx6n84J4gsvfH7RjvJKrDnRt7yhoKMXzkJml 0evmM8+USt0rMLcgSmWP1bfflp1gLfX9krU04NCY0UY0rcRRZ0QI1E9ZgWXRUJZtvhdo Jp7xMv8vEfs0m4X11TdV0yKMBKKW75sIuXWHbcWvXR4qfUrMM1v0qx49XYv1znomhbFV vrJA== X-Gm-Message-State: AOJu0YygNL0d0n6CG8Jpr5J2+/Hy0r8touvza9cHLD9f2mG9ckmgQDIO KaTSx0dHdPncVJfUahD7eog= 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 Cc: freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, Rob Clark , Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter , linux-kernel@vger.kernel.org (open list) 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-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 27 Oct 2023 10:00:01 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780928750347541083 X-GMAIL-MSGID: 1780928750347541083 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: