From patchwork Thu Mar 8 23:46:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniele Ceraolo Spurio X-Patchwork-Id: 10269435 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 1E98F602BD for ; Thu, 8 Mar 2018 23:47:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 103DB2015F for ; Thu, 8 Mar 2018 23:47:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 04BB320415; Thu, 8 Mar 2018 23:47:01 +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 4DBDA299D0 for ; Thu, 8 Mar 2018 23:47:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9DB4A6EB53; Thu, 8 Mar 2018 23:46:59 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id A00806EB53 for ; Thu, 8 Mar 2018 23:46:58 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Mar 2018 15:46:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,443,1515484800"; d="scan'208";a="26448206" Received: from relo-linux-1.fm.intel.com ([10.1.27.112]) by fmsmga002.fm.intel.com with ESMTP; 08 Mar 2018 15:46:57 -0800 From: Daniele Ceraolo Spurio To: intel-gfx@lists.freedesktop.org Date: Thu, 8 Mar 2018 15:46:28 -0800 Message-Id: <20180308234629.27021-2-daniele.ceraolospurio@intel.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180308234629.27021-1-daniele.ceraolospurio@intel.com> References: <20180308234629.27021-1-daniele.ceraolospurio@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 2/3] drm/i915: add a selftest for the mmio_bases table X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 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" X-Virus-Scanned: ClamAV using ClamSMTP Check that the entries are in reverse gen order and that the first entry and all the following entries with gen > 0 have an mmio base set. Suggested-by: Chris Wilson Cc: Chris Wilson Signed-off-by: Daniele Ceraolo Spurio --- drivers/gpu/drm/i915/intel_engine_cs.c | 1 + .../gpu/drm/i915/selftests/i915_mock_selftests.h | 1 + drivers/gpu/drm/i915/selftests/intel_engine_cs.c | 48 ++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 drivers/gpu/drm/i915/selftests/intel_engine_cs.c diff --git a/drivers/gpu/drm/i915/intel_engine_cs.c b/drivers/gpu/drm/i915/intel_engine_cs.c index 08711665061c..a33171d82aee 100644 --- a/drivers/gpu/drm/i915/intel_engine_cs.c +++ b/drivers/gpu/drm/i915/intel_engine_cs.c @@ -2131,4 +2131,5 @@ void intel_disable_engine_stats(struct intel_engine_cs *engine) #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST) #include "selftests/mock_engine.c" +#include "selftests/intel_engine_cs.c" #endif diff --git a/drivers/gpu/drm/i915/selftests/i915_mock_selftests.h b/drivers/gpu/drm/i915/selftests/i915_mock_selftests.h index 9a48aa441743..2842f93ca29e 100644 --- a/drivers/gpu/drm/i915/selftests/i915_mock_selftests.h +++ b/drivers/gpu/drm/i915/selftests/i915_mock_selftests.h @@ -23,3 +23,4 @@ selftest(vma, i915_vma_mock_selftests) selftest(evict, i915_gem_evict_mock_selftests) selftest(gtt, i915_gem_gtt_mock_selftests) selftest(hugepages, i915_gem_huge_page_mock_selftests) +selftest(engine, intel_engine_cs_mock_selftests) diff --git a/drivers/gpu/drm/i915/selftests/intel_engine_cs.c b/drivers/gpu/drm/i915/selftests/intel_engine_cs.c new file mode 100644 index 000000000000..8ef453905520 --- /dev/null +++ b/drivers/gpu/drm/i915/selftests/intel_engine_cs.c @@ -0,0 +1,48 @@ +/* + * SPDX-License-Identifier: GPL-2.0 + * + * Copyright © 2018 Intel Corporation + */ + +#include "../i915_selftest.h" + +static int intel_mmio_bases_check(void) +{ + const struct engine_info *info; + int i, j; + u32 gen; + s32 prev; + + for (i = 0; i < ARRAY_SIZE(intel_engines); i++) { + info = &intel_engines[i]; + + for (prev = -1, j = MAX_MMIO_BASES -1; j >= 0; j--) { + gen = info->mmio_bases[j].gen; + + if (prev >= (s32)gen) { + pr_err("%s: engine[%d]: mmio base for gen %x " + "is before the one for gen %x\n", + __func__, i, gen, prev); + return -EINVAL; + } + + if ((j == 0 || gen > 0) && !info->mmio_bases[j].base) { + pr_err("%s: engine[%d]: invalid mmio base (%x) " + "for gen %x at entry %u\n", + __func__, i, info->mmio_bases[j].base, gen, j); + return -EINVAL; + } + + /* we can have multiple empty entries in a row */ + if (gen > 0) + prev = gen; + } + } + + return 0; +} + +int intel_engine_cs_mock_selftests(void) +{ + return intel_mmio_bases_check(); +}