From patchwork Thu Aug 20 20:51:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bas Nieuwenhuizen X-Patchwork-Id: 7047071 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 90E70C05AC for ; Thu, 20 Aug 2015 20:53:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A01352021F for ; Thu, 20 Aug 2015 20:53:01 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 7EFA620502 for ; Thu, 20 Aug 2015 20:53:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EC24A6E2F2; Thu, 20 Aug 2015 13:52:57 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com [209.85.212.169]) by gabe.freedesktop.org (Postfix) with ESMTPS id 054BB6E1EF for ; Thu, 20 Aug 2015 13:52:57 -0700 (PDT) Received: by wicja10 with SMTP id ja10so338547wic.1 for ; Thu, 20 Aug 2015 13:52:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=5ZupOrMVDdTLuRpe5DW2T+SyfJDSow4szkXHB/vuQdc=; b=Yws9gCegiQpVhagU2q5/VD/e2zpZFOAd2IkVKIIYJSFrf4mL0CVrhSo8JXVKh1e2CE yicQgLdrqadUJ59t8XsFWirpN2lV0N4JEr5BnULjJKw58YJp92cJ6Sji5ACZZorGJ2m+ 90MoELHc/Kf+bg0IYdBnXERuoaX/QfwJcG207TMAPIMlDeQto+oQmr89FhegsaNiCsDc ot0y15NmtYKErZJPXpAbBOZmejbBg5WNszeVtdj/tsk5PjEjM42S2J9pD8OffIfaYuva 1nCrna8h6Ls48qBd5YiBpj0cZTkWFmbgDNJXEqpVBoGgiIHxSVpQXqsACdPj9SE/Wivw hnKA== X-Gm-Message-State: ALoCoQn82EGDm0pmOIdhOSYEgckELlAQGN+v2sGL9qgv8uxCU94CCMgRShTMv+IZkgSt9ae6RLx9 X-Received: by 10.194.93.166 with SMTP id cv6mr9488445wjb.63.1440103975268; Thu, 20 Aug 2015 13:52:55 -0700 (PDT) Received: from bas-desktop.localdomain (4dafc19f.ftth.telfortglasvezel.nl. [77.175.193.159]) by smtp.gmail.com with ESMTPSA id ll1sm34761wic.14.2015.08.20.13.52.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Aug 2015 13:52:54 -0700 (PDT) From: Bas Nieuwenhuizen To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/2] drm/amdgpu: call amdgpu_cs_parser_fini at most once per parser. Date: Thu, 20 Aug 2015 22:51:52 +0200 Message-Id: <1440103912-1014-2-git-send-email-bas@basnieuwenhuizen.nl> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1440103912-1014-1-git-send-email-bas@basnieuwenhuizen.nl> References: <1440103912-1014-1-git-send-email-bas@basnieuwenhuizen.nl> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Bas Nieuwenhuizen --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 16 +++++++--------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 454d4e2..207d963 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -1247,6 +1247,7 @@ struct amdgpu_cs_parser { /* relocations */ struct amdgpu_bo_list_entry *vm_bos; struct list_head validated; + bool bos_reserved; struct amdgpu_ib *ibs; uint32_t num_ibs; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index 2c49dd4..10ba301 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c @@ -369,6 +369,7 @@ int amdgpu_cs_list_validate(struct amdgpu_cs_parser *p) if (unlikely(r != 0)) { return r; } + p->bos_reserved = true; list_for_each_entry(lobj, &p->validated, tv.head) { bo = lobj->robj; @@ -469,7 +470,7 @@ static int cmp_size_smaller_first(void *priv, struct list_head *a, return (int)la->robj->tbo.num_pages - (int)lb->robj->tbo.num_pages; } -static void amdgpu_cs_parser_fini_early(struct amdgpu_cs_parser *parser, int error, bool backoff) +static void amdgpu_cs_parser_fini_early(struct amdgpu_cs_parser *parser, int error) { if (!error) { /* Sort the buffer list from the smallest to largest buffer, @@ -487,7 +488,7 @@ static void amdgpu_cs_parser_fini_early(struct amdgpu_cs_parser *parser, int err ttm_eu_fence_buffer_objects(&parser->ticket, &parser->validated, &parser->ibs[parser->num_ibs-1].fence->base); - } else if (backoff) { + } else if (parser->bos_reserved) { ttm_eu_backoff_reservation(&parser->ticket, &parser->validated); } @@ -527,9 +528,9 @@ static void amdgpu_cs_parser_fini_late(struct amdgpu_cs_parser *parser) * If error is set than unvalidate buffer, otherwise just free memory * used by parsing context. **/ -static void amdgpu_cs_parser_fini(struct amdgpu_cs_parser *parser, int error, bool backoff) +static void amdgpu_cs_parser_fini(struct amdgpu_cs_parser *parser, int error) { - amdgpu_cs_parser_fini_early(parser, error, backoff); + amdgpu_cs_parser_fini_early(parser, error); amdgpu_cs_parser_fini_late(parser); } @@ -816,7 +817,6 @@ static int amdgpu_cs_parser_prepare_job(struct amdgpu_cs_parser *sched_job) int r, i; struct amdgpu_cs_parser *parser = sched_job; struct amdgpu_device *adev = sched_job->adev; - bool reserved_buffers = false; r = amdgpu_cs_parser_relocs(parser); if (r) { @@ -829,7 +829,6 @@ static int amdgpu_cs_parser_prepare_job(struct amdgpu_cs_parser *sched_job) } if (!r) { - reserved_buffers = true; r = amdgpu_cs_ib_fill(adev, parser); } if (!r) { @@ -838,7 +837,6 @@ static int amdgpu_cs_parser_prepare_job(struct amdgpu_cs_parser *sched_job) DRM_ERROR("Failed in the dependencies handling %d!\n", r); } if (r) { - amdgpu_cs_parser_fini(parser, r, reserved_buffers); return r; } @@ -894,7 +892,7 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) r = amdgpu_cs_parser_init(parser, data); if (r) { DRM_ERROR("Failed to initialize parser !\n"); - amdgpu_cs_parser_fini(parser, r, false); + amdgpu_cs_parser_fini(parser, r); up_read(&adev->exclusive_lock); r = amdgpu_cs_handle_lockup(adev, r); return r; @@ -937,7 +935,7 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) cs->out.handle = parser->ibs[parser->num_ibs - 1].sequence; out: - amdgpu_cs_parser_fini(parser, r, true); + amdgpu_cs_parser_fini(parser, r); up_read(&adev->exclusive_lock); r = amdgpu_cs_handle_lockup(adev, r); return r;