From: Damien Lespiau Subject: [PATCH i-g-t 2/3] skl_ddb_allocation: Add checks on the DDB entries Date: Tue, 14 Oct 2014 17:33:59 +0100 Message-ID: <1413304440-1177-2-git-send-email-damien.lespiau@intel.com> References: <1413304440-1177-1-git-send-email-damien.lespiau@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTP id 8C27C89CC9 for ; Tue, 14 Oct 2014 09:34:06 -0700 (PDT) In-Reply-To: <1413304440-1177-1-git-send-email-damien.lespiau@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org Signed-off-by: Damien Lespiau --- tests/skl_ddb_allocation.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/tests/skl_ddb_allocation.c b/tests/skl_ddb_allocation.c index 7faed0e..ba5f8ba 100644 --- a/tests/skl_ddb_allocation.c +++ b/tests/skl_ddb_allocation.c @@ -277,11 +277,38 @@ skl_allocate_pipe_ddb(struct drm_crtc *crtc, } +static void skl_ddb_check_entry(struct skl_ddb_entry *entry, int16_t *cursor) +{ + + if (skl_ddb_entry_size(entry) == 0) + return; + + /* check that ->start is the next available block */ + if (entry->start <= *cursor) + printf("error: allocation overlaps previous block\n"); + else if (entry->start > *cursor + 1) + printf("warning: allocation leaves a hole\n"); + + *cursor = entry->end; +} + +static void skl_ddb_check_last_allocation(int16_t cursor) +{ + uint16_t last_offset = SKL_DDB_SIZE - 1 - 4; + + if (cursor < last_offset) + printf("warning: %d blocks not allocated\n", + last_offset - cursor); + else if (cursor > last_offset) + printf("error: allocation greater than available space\n"); +} + static void skl_ddb_print(struct skl_ddb_allocation *ddb) { struct skl_ddb_entry *entry; enum pipe pipe; int plane; + int16_t cursor = -1; printf("%-15s%8s%8s%8s\n", "", "Start", "End", "Size"); @@ -290,17 +317,22 @@ static void skl_ddb_print(struct skl_ddb_allocation *ddb) for_each_plane(pipe, plane) { entry = &ddb->plane[pipe][plane]; + printf(" Plane%-8d%8u%8u%8u\n", plane + 1, entry->start, entry->end, skl_ddb_entry_size(entry)); + + skl_ddb_check_entry(entry, &cursor); } entry = &ddb->cursor[pipe]; printf(" %-13s%8u%8u%8u\n", "Cursor", entry->start, entry->end, skl_ddb_entry_size(entry)); - } + skl_ddb_check_entry(entry, &cursor); + } + skl_ddb_check_last_allocation(cursor); } static struct drm_device drm_device; -- 1.8.3.1