From patchwork Wed Jul 12 14:50:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowki X-Patchwork-Id: 9836915 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 30D9860363 for ; Wed, 12 Jul 2017 14:51:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22B99285DD for ; Wed, 12 Jul 2017 14:51:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 176C9285E8; Wed, 12 Jul 2017 14:51:19 +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 B2F18285DD for ; Wed, 12 Jul 2017 14:51:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 279656E430; Wed, 12 Jul 2017 14:51:18 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5BE016E426 for ; Wed, 12 Jul 2017 14:51:11 +0000 (UTC) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP; 12 Jul 2017 07:51:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,350,1496127600"; d="scan'208";a="126282606" Received: from linux.intel.com ([10.54.29.200]) by fmsmga006.fm.intel.com with ESMTP; 12 Jul 2017 07:51:10 -0700 Received: from workstation.fi.intel.com (workstation.fi.intel.com [10.237.68.144]) by linux.intel.com (Postfix) with ESMTP id E55735804B7; Wed, 12 Jul 2017 07:51:08 -0700 (PDT) From: Paul Kocialkowski To: intel-gfx@lists.freedesktop.org Date: Wed, 12 Jul 2017 17:50:27 +0300 Message-Id: <20170712145031.3531-4-paul.kocialkowski@linux.intel.com> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170712145031.3531-1-paul.kocialkowski@linux.intel.com> References: <20170705080435.26789-1-paul.kocialkowski@linux.intel.com> <20170712145031.3531-1-paul.kocialkowski@linux.intel.com> Cc: Lyude Subject: [Intel-gfx] [PATCH i-g-t v4 3/7] lib/igt_debugfs: Introduce CRC check function, with logic made common X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP This introduces an igt_check_crc_equal function in addition to igt_assert_crc_equal and makes the CRC comparison logic from the latter common. In particular, an igt_find_crc_mismatch function indicates whether there is a mistmatch and at what index, so that the calling functions can print the diverging values. Signed-off-by: Paul Kocialkowski --- lib/igt_debugfs.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++--- lib/igt_debugfs.h | 1 + 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c index 80f25c61..78c22e67 100644 --- a/lib/igt_debugfs.c +++ b/lib/igt_debugfs.c @@ -281,6 +281,26 @@ bool igt_debugfs_search(int device, const char *filename, const char *substring) * Pipe CRC */ +static bool igt_find_crc_mismatch(const igt_crc_t *a, const igt_crc_t *b, + int *index) +{ + int i; + + if (a->n_words != b->n_words) + return true; + + for (i = 0; i < a->n_words; i++) { + if (a->crc[i] != b->crc[i]) { + if (index) + *index = i; + + return true; + } + } + + return false; +} + /** * igt_assert_crc_equal: * @a: first pipe CRC value @@ -294,10 +314,37 @@ bool igt_debugfs_search(int device, const char *filename, const char *substring) */ void igt_assert_crc_equal(const igt_crc_t *a, const igt_crc_t *b) { - int i; + int index; + bool mismatch; + + mismatch = igt_find_crc_mismatch(a, b, &index); + if (mismatch) + igt_debug("CRC mismatch at index %d: 0x%x != 0x%x\n", index, + a->crc[index], b->crc[index]); + + igt_assert(!mismatch); +} + +/** + * igt_check_crc_equal: + * @a: first pipe CRC value + * @b: second pipe CRC value + * + * Compares two CRC values and return whether they match. + * + * Returns: A boolean indicating whether the CRC values match + */ +bool igt_check_crc_equal(const igt_crc_t *a, const igt_crc_t *b) +{ + int index; + bool mismatch; + + mismatch = igt_find_crc_mismatch(a, b, &index); + if (mismatch) + igt_debug("CRC mismatch at index %d: 0x%x != 0x%x\n", index, + a->crc[index], b->crc[index]); - for (i = 0; i < a->n_words; i++) - igt_assert_eq_u32(a->crc[i], b->crc[i]); + return !mismatch; } /** diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h index 7b846a83..fe355919 100644 --- a/lib/igt_debugfs.h +++ b/lib/igt_debugfs.h @@ -114,6 +114,7 @@ enum intel_pipe_crc_source { }; void igt_assert_crc_equal(const igt_crc_t *a, const igt_crc_t *b); +bool igt_check_crc_equal(const igt_crc_t *a, const igt_crc_t *b); char *igt_crc_to_string(igt_crc_t *crc); void igt_require_pipe_crc(int fd);