From patchwork Thu Nov 9 21:24:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10051959 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 31A03603FA for ; Thu, 9 Nov 2017 21:25:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 236862AC4B for ; Thu, 9 Nov 2017 21:25:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 15DFB2B104; Thu, 9 Nov 2017 21:25:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 58C552AC4B for ; Thu, 9 Nov 2017 21:25:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 237036E010; Thu, 9 Nov 2017 21:25:01 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [109.228.58.192]) by gabe.freedesktop.org (Postfix) with ESMTPS id 04C106E010; Thu, 9 Nov 2017 21:24:58 +0000 (UTC) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 9537256-1500050 for multiple; Thu, 09 Nov 2017 21:24:46 +0000 Received: by haswell.alporthouse.com (sSMTP sendmail emulation); Thu, 09 Nov 2017 21:24:46 +0000 From: Chris Wilson To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/2] drm/selftests/mm: Add callsite indicator to common asserts Date: Thu, 9 Nov 2017 21:24:35 +0000 Message-Id: <20171109212435.9265-2-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171109212435.9265-1-chris@chris-wilson.co.uk> References: <20171109212435.9265-1-chris@chris-wilson.co.uk> X-Originating-IP: 78.156.65.138 X-Country: code=GB country="United Kingdom" ip=78.156.65.138 Cc: Daniel Vetter , intel-gfx@lists.freedesktop.org, Joonas Lahtinen 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-Virus-Scanned: ClamAV using ClamSMTP The majority of the asserts (validating nodes and ranges) are shared amongst several subtests. This makes identification of which caller failed hard; but we uniquely identify them if we include the callsite into the assertion error message (a single frame stacktrace). Signed-off-by: Chris Wilson Cc: Joonas Lahtinen Cc: Daniel Vetter Reviewed-by: Joonas Lahtinen --- drivers/gpu/drm/selftests/test-drm_mm.c | 46 +++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/selftests/test-drm_mm.c b/drivers/gpu/drm/selftests/test-drm_mm.c index 7cc935d7b7aa..5f1477329bee 100644 --- a/drivers/gpu/drm/selftests/test-drm_mm.c +++ b/drivers/gpu/drm/selftests/test-drm_mm.c @@ -59,13 +59,16 @@ static bool assert_no_holes(const struct drm_mm *mm) drm_mm_for_each_hole(hole, mm, hole_start, hole_end) count++; if (count) { - pr_err("Expected to find no holes (after reserve), found %lu instead\n", count); + pr_err("%pS: Expected to find no holes (after reserve), found %lu instead\n", + __builtin_return_address(0), + count); return false; } drm_mm_for_each_node(hole, mm) { if (drm_mm_hole_follows(hole)) { - pr_err("Hole follows node, expected none!\n"); + pr_err("%pS: Hole follows node, expected none!\n", + __builtin_return_address(0)); return false; } } @@ -87,7 +90,8 @@ static bool assert_one_hole(const struct drm_mm *mm, u64 start, u64 end) drm_mm_for_each_hole(hole, mm, hole_start, hole_end) { if (start != hole_start || end != hole_end) { if (ok) - pr_err("empty mm has incorrect hole, found (%llx, %llx), expect (%llx, %llx)\n", + pr_err("%pS: empty mm has incorrect hole, found (%llx, %llx), expect (%llx, %llx)\n", + __builtin_return_address(0), hole_start, hole_end, start, end); ok = false; @@ -95,7 +99,9 @@ static bool assert_one_hole(const struct drm_mm *mm, u64 start, u64 end) count++; } if (count != 1) { - pr_err("Expected to find one hole, found %lu instead\n", count); + pr_err("%pS: Expected to find one hole, found %lu instead\n", + __builtin_return_address(0), + count); ok = false; } @@ -108,40 +114,48 @@ static bool assert_continuous(const struct drm_mm *mm, u64 size) unsigned long n; u64 addr; - if (!assert_no_holes(mm)) + if (!assert_no_holes(mm)) { + pr_err("%pS: expected no holes!\n", + __builtin_return_address(0)); return false; + } n = 0; addr = 0; drm_mm_for_each_node(node, mm) { if (node->start != addr) { - pr_err("node[%ld] list out of order, expected %llx found %llx\n", + pr_err("%pS: node[%ld] list out of order, expected %llx found %llx\n", + __builtin_return_address(0), n, addr, node->start); return false; } if (node->size != size) { - pr_err("node[%ld].size incorrect, expected %llx, found %llx\n", + pr_err("%pS: node[%ld].size incorrect, expected %llx, found %llx\n", + __builtin_return_address(0), n, size, node->size); return false; } if (drm_mm_hole_follows(node)) { - pr_err("node[%ld] is followed by a hole!\n", n); + pr_err("%pS: node[%ld] is followed by a hole!\n", + __builtin_return_address(0), n); return false; } found = NULL; drm_mm_for_each_node_in_range(check, mm, addr, addr + size) { if (node != check) { - pr_err("lookup return wrong node, expected start %llx, found %llx\n", + pr_err("%pS: lookup return wrong node, expected start %llx, found %llx\n", + __builtin_return_address(0), node->start, check->start); return false; } found = check; } if (!found) { - pr_err("lookup failed for node %llx + %llx\n", + pr_err("%pS: lookup failed for node %llx + %llx\n", + __builtin_return_address(0), addr, size); return false; } @@ -170,24 +184,28 @@ static bool assert_node(struct drm_mm_node *node, struct drm_mm *mm, bool ok = true; if (!drm_mm_node_allocated(node) || node->mm != mm) { - pr_err("node not allocated\n"); + pr_err("%pS: node not allocated\n", + __builtin_return_address(0)); ok = false; } if (node->size != size) { - pr_err("node has wrong size, found %llu, expected %llu\n", + pr_err("%pS: node has wrong size, found %llu, expected %llu\n", + __builtin_return_address(0), node->size, size); ok = false; } if (misalignment(node, alignment)) { - pr_err("node is misaligned, start %llx rem %llu, expected alignment %llu\n", + pr_err("%pS: node is misaligned, start %llx rem %llu, expected alignment %llu\n", + __builtin_return_address(0), node->start, misalignment(node, alignment), alignment); ok = false; } if (node->color != color) { - pr_err("node has wrong color, found %lu, expected %lu\n", + pr_err("%pS: node has wrong color, found %lu, expected %lu\n", + __builtin_return_address(0), node->color, color); ok = false; }