From patchwork Thu Aug 26 09:33:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 12459333 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AFA5FC4320A for ; Thu, 26 Aug 2021 09:33:43 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 3784C610C9 for ; Thu, 26 Aug 2021 09:33:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3784C610C9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B68426E598; Thu, 26 Aug 2021 09:33:42 +0000 (UTC) Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 93AFC6E59D for ; Thu, 26 Aug 2021 09:33:41 +0000 (UTC) Received: by mail-wm1-x32d.google.com with SMTP id z9-20020a7bc149000000b002e8861aff59so2227043wmi.0 for ; Thu, 26 Aug 2021 02:33:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JJwF0PYPmqolDQLzp/yyP0Yq0kNRDALRe2iRCTul0qQ=; b=SH0mRD4lFXjf5zfnArdRmdr/H92IkTiRG83+lu46nthRk6g7hsBLFtgm+PlV987nZb 8qS0NSbfSQEVvJHrd9UuRQQZyRYMk9Om3DXftZgrjCWaMM58LLL7moZvaOPhHV2P6OQY zlQ0dHofnwILHwlhcoYEc4vFcvIjxdR6txsQc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JJwF0PYPmqolDQLzp/yyP0Yq0kNRDALRe2iRCTul0qQ=; b=O20cO78TntYVpQNFV2a8FQWunOQtN8MywrFL296499XdF5QlMXDPwMEgXktLo13xBT ke4vm6QxiUa5EFo+1QcjXnkN9KU+dSbBD3LEluNrlxX2fvtGXOG6wqo+AR3pra1fIIm4 1qgFm8hrJOh9ad0X0Z63yqwLVVqc1OHw2Y37NAY9gPuIxPThfIQGJIkrUpgM3emsLYDM HKXGY+41/5uxWEWdRi/K3s8SGNMR99/FcrH2vNC3Wbm4gNTyRPIvdC2dA97q64HoYHVC 3ctgsT6eL/irRGm3tcIkCi2pjstQ1R+fVb2ESuHa4k8+XN0Q4dnzESB8Z4IcQgpFq2t1 vWdQ== X-Gm-Message-State: AOAM530PBasiVLS2L/cIAesBUqHukdgfTE6uFBPJ1Mc9sdgKSMv9AX3z fnRARsX7eORA7+Nh+xRQm6Fbw5kvWuPpJw== X-Google-Smtp-Source: ABdhPJzc23DuJoTC8nNJ25VQNbiKhhUYQ5XEsHa4ESe0XB/c1un0JqfR7O83A2HYXCq/etCBggdOqg== X-Received: by 2002:a05:600c:1d27:: with SMTP id l39mr2677127wms.146.1629970420205; Thu, 26 Aug 2021 02:33:40 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id z6sm2088220wmp.1.2021.08.26.02.33.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 02:33:39 -0700 (PDT) From: Daniel Vetter To: DRI Development Cc: Intel Graphics Development , Daniel Vetter , Rob Clark , Rob Clark , Sean Paul , Sumit Semwal , =?utf-8?q?Christian_K=C3=B6nig?= , linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, Daniel Vetter Date: Thu, 26 Aug 2021 11:33:34 +0200 Message-Id: <20210826093334.1117944-1-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210817085308.3557257-1-daniel.vetter@ffwll.ch> References: <20210817085308.3557257-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH] drm/msm: Improve drm/sched point of no return rules X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Originally drm_sched_job_init was the point of no return, after which drivers really should submit a job. I've split that up, which allows us to fix this issue pretty easily. Only thing we have to take care of is to not skip to error paths after that. Other drivers do this the same for out-fence and similar things. v2: It's not really a bugfix, just an improvement, since all drm_sched_job_arm does is reserve the fence number. And gaps should be fine, as long as the drm_sched_job doesn't escape anywhere at all. For robustness it's still better to align with other drivers here and not bail out after job_arm(). v3: I misplaced drm_sched_job_arm by _one_ line! Thanks to Rob for testing and debug help. Cc: Rob Clark Cc: Rob Clark Cc: Sean Paul Cc: Sumit Semwal Cc: "Christian König" Cc: linux-arm-msm@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: freedreno@lists.freedesktop.org Cc: linux-media@vger.kernel.org Cc: linaro-mm-sig@lists.linaro.org Signed-off-by: Daniel Vetter --- drivers/gpu/drm/msm/msm_gem_submit.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c index 4d1c4d5f6a2a..71b8c8f752a3 100644 --- a/drivers/gpu/drm/msm/msm_gem_submit.c +++ b/drivers/gpu/drm/msm/msm_gem_submit.c @@ -52,8 +52,6 @@ static struct msm_gem_submit *submit_create(struct drm_device *dev, return ERR_PTR(ret); } - drm_sched_job_arm(&job->base); - xa_init_flags(&submit->deps, XA_FLAGS_ALLOC); kref_init(&submit->ref); @@ -880,6 +878,8 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data, submit->nr_cmds = i; + drm_sched_job_arm(&submit->base); + submit->user_fence = dma_fence_get(&submit->base.s_fence->finished); /* @@ -891,17 +891,16 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data, if (submit->fence_id < 0) { ret = submit->fence_id = 0; submit->fence_id = 0; - goto out; } - if (args->flags & MSM_SUBMIT_FENCE_FD_OUT) { + if (ret == 0 && args->flags & MSM_SUBMIT_FENCE_FD_OUT) { struct sync_file *sync_file = sync_file_create(submit->user_fence); if (!sync_file) { ret = -ENOMEM; - goto out; + } else { + fd_install(out_fence_fd, sync_file->file); + args->fence_fd = out_fence_fd; } - fd_install(out_fence_fd, sync_file->file); - args->fence_fd = out_fence_fd; } submit_attach_object_fences(submit);