From patchwork Mon Jun 15 14:54:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 11605297 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1B43290 for ; Mon, 15 Jun 2020 15:05:09 +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 EAE0D20739 for ; Mon, 15 Jun 2020 15:05:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AUYeuwlk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EAE0D20739 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 314346E33E; Mon, 15 Jun 2020 15:05:07 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by gabe.freedesktop.org (Postfix) with ESMTPS id CFD9D89D5F; Mon, 15 Jun 2020 14:54:19 +0000 (UTC) Received: by mail-wm1-x342.google.com with SMTP id r9so14960184wmh.2; Mon, 15 Jun 2020 07:54:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=AI5FhLk9FP9TGZGo8fRTGDecjA5Rowrr5/b2Hx2l40Y=; b=AUYeuwlkzeTEMmKgkzuG7NQaiCFAqtRRURHNkXegKZ4aAEqchXQ2HtmG2tFMQoyVZp HJiOi/501eEEOMkupz/zBxekgirdUq9qCDFtGoaEqnoQzFZVvAGTurku1HQ1vj74UoOv s1Jorx7T+s/hi1ms4vfFK7qKvES1X0dn9tDPjhhAjL0NB1ztdkBvDJOOxBJQDjo3lrzi fJDRkXZkkr3xJiLbmv5Tj6wvqmSsGnZP+J30etVnaHawvtYIW2Ajo0VoQr/yRdASxyS7 sUMtn2Dh96f0qp0lc/lsMzzOZkQFXTS5CvO3q7dCJfGFINiXdCdtOjcu8CQdzXm5O0z6 7SLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AI5FhLk9FP9TGZGo8fRTGDecjA5Rowrr5/b2Hx2l40Y=; b=L/xn5k3SBqPgy4kFdIVGungduOpOpsVIOg+pOSEfbmNzKJeHByIL/lJTjRhqECpihd NkqLT7dxGt8Kk4fDbzlySKK/UOthAFHghXAXPkO5lox/S93PHkNRjTTYRTm4oBAPjwSm ww4MmwCEHyoxB8KBihWreVH2jJB39JRmUbfLX6mphsXCGEHfEWn7M+z5Sb8jqckAl+1b YazZ2v4l0Et5h45pyHQy1elzxn0wOYeEm1CnXIdBma/vOewRw6zWHDJZQX5HAp4W8+Zf V/KhDyw7cXi/SwWzSKu2sf+g5/7waITXlNVKHouv514vJO1iwamptMQZdRs6fIUtCbB2 tLCA== X-Gm-Message-State: AOAM530cSiXOkQy/kOB6aUoWZZxrm49JgxGPjpPpijBP9M5CUKRKPSeE 9neyTQA1c1SumWFLMMxBVygg1rQr X-Google-Smtp-Source: ABdhPJzs34cUZA9c8hhih4GsKBtPO5mVLb8jD3HNJbjUYETf2wBiCMUtuHDdJ5AJYFvtQcxQVLyq3Q== X-Received: by 2002:a1c:9ec5:: with SMTP id h188mr13399954wme.9.1592232858550; Mon, 15 Jun 2020 07:54:18 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:a5ab:7330:3773:519a]) by smtp.gmail.com with ESMTPSA id j4sm24277442wma.7.2020.06.15.07.54.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jun 2020 07:54:17 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: chris@chris-wilson.co.uk, intel-gfx@lists.freedesktop.org, nirmoy.das@amd.com, dri-devel@lists.freedesktop.org Date: Mon, 15 Jun 2020 16:54:14 +0200 Message-Id: <20200615145415.1775-2-christian.koenig@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200615145415.1775-1-christian.koenig@amd.com> References: <20200615145415.1775-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 15 Jun 2020 15:05:06 +0000 Subject: [Intel-gfx] [PATCH 2/3] drm/mm: optimize find_hole() as well 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" Abort early if there isn't enough space to allocate from a subtree. Signed-off-by: Christian König Acked-by: Nirmoy Das --- drivers/gpu/drm/drm_mm.c | 11 +++++++---- drivers/gpu/drm/selftests/test-drm_mm.c | 11 ----------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c index 425fcd3590e8..177a5df0fe95 100644 --- a/drivers/gpu/drm/drm_mm.c +++ b/drivers/gpu/drm/drm_mm.c @@ -325,7 +325,7 @@ static struct drm_mm_node *best_hole(struct drm_mm *mm, u64 size) return best; } -static struct drm_mm_node *find_hole(struct drm_mm *mm, u64 addr) +static struct drm_mm_node *find_hole_addr(struct drm_mm *mm, u64 addr, u64 size) { struct rb_node *rb = mm->holes_addr.rb_node; struct drm_mm_node *node = NULL; @@ -333,6 +333,9 @@ static struct drm_mm_node *find_hole(struct drm_mm *mm, u64 addr) while (rb) { u64 hole_start; + if (rb_hole_addr_to_node(rb)->subtree_max_hole < size) + break; + node = rb_hole_addr_to_node(rb); hole_start = __drm_mm_hole_node_start(node); @@ -358,10 +361,10 @@ first_hole(struct drm_mm *mm, return best_hole(mm, size); case DRM_MM_INSERT_LOW: - return find_hole(mm, start); + return find_hole_addr(mm, start, size); case DRM_MM_INSERT_HIGH: - return find_hole(mm, end); + return find_hole_addr(mm, end, size); case DRM_MM_INSERT_EVICT: return list_first_entry_or_null(&mm->hole_stack, @@ -497,7 +500,7 @@ int drm_mm_reserve_node(struct drm_mm *mm, struct drm_mm_node *node) return -ENOSPC; /* Find the relevant hole to add our node to */ - hole = find_hole(mm, node->start); + hole = find_hole_addr(mm, node->start, 0); if (!hole) return -ENOSPC; diff --git a/drivers/gpu/drm/selftests/test-drm_mm.c b/drivers/gpu/drm/selftests/test-drm_mm.c index ca5f35def905..b879aedfc00d 100644 --- a/drivers/gpu/drm/selftests/test-drm_mm.c +++ b/drivers/gpu/drm/selftests/test-drm_mm.c @@ -1981,16 +1981,6 @@ static int __igt_once(unsigned int mode) } memset(&node, 0, sizeof(node)); - err = drm_mm_insert_node_generic(&mm, &node, - 2, 0, 0, - mode | DRM_MM_INSERT_ONCE); - if (!err) { - pr_err("Unexpectedly inserted the node into the wrong hole: node.start=%llx\n", - node.start); - err = -EINVAL; - goto err_node; - } - err = drm_mm_insert_node_generic(&mm, &node, 2, 0, 0, mode); if (err) { pr_err("Could not insert the node into the available hole!\n"); @@ -1998,7 +1988,6 @@ static int __igt_once(unsigned int mode) goto err_hi; } -err_node: drm_mm_remove_node(&node); err_hi: drm_mm_remove_node(&rsvd_hi);