From patchwork Mon Apr 27 09:00:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 11511691 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 C5ADA15AB for ; Mon, 27 Apr 2020 09:00:23 +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 ADDAF2080C for ; Mon, 27 Apr 2020 09:00:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ADDAF2080C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.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 A8DFF6E12F; Mon, 27 Apr 2020 09:00:21 +0000 (UTC) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 412986E12F; Mon, 27 Apr 2020 09:00:20 +0000 (UTC) IronPort-SDR: xfPBlNr4aJtBxQus441xMJhtfpo+MypkHPjE+oXQT3/CiaNZU3CJ4mJTECRfU1bj3vqEBq4/Lr S6VhkD5rnzHA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2020 02:00:19 -0700 IronPort-SDR: uLW3l7guPMeG6mnRtow7mG5BYRVshg71CLTHxfTrRMvtzZMxsJCl8Tf7fpkCkNlgq4E5d316jI 0jIpoNshnViA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,323,1583222400"; d="scan'208";a="292405546" Received: from apopescu-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.252.53.226]) by fmsmga002.fm.intel.com with ESMTP; 27 Apr 2020 02:00:18 -0700 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org Date: Mon, 27 Apr 2020 10:00:14 +0100 Message-Id: <20200427090014.10041-1-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t] gem_wsim: Fix preempt period assert 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: , Cc: Intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Tvrtko Ursulin Recently added assert in a common helper used for calculating batch duration and preemption period is harmful when preemption is disabled on a context. Split out into low level and high level helper and use the former for preemption period queries. Signed-off-by: Tvrtko Ursulin Reviewed-by: Chris Wilson --- benchmarks/gem_wsim.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c index 81f47b86d619..ad4edb936920 100644 --- a/benchmarks/gem_wsim.c +++ b/benchmarks/gem_wsim.c @@ -1151,7 +1151,7 @@ __get_ctx(struct workload *wrk, const struct w_step *w) } static unsigned long -get_bb_sz(const struct w_step *w, unsigned int duration) +__get_bb_sz(const struct w_step *w, unsigned int duration) { enum intel_engine_id engine = w->engine; struct ctx *ctx = __get_ctx(w->wrk, w); @@ -1165,6 +1165,15 @@ get_bb_sz(const struct w_step *w, unsigned int duration) d = ALIGN(duration * engine_calib_map[engine] * sizeof(uint32_t) / nop_calibration_us, sizeof(uint32_t)); + + return d; +} + +static unsigned long +get_bb_sz(const struct w_step *w, unsigned int duration) +{ + unsigned long d = __get_bb_sz(w, duration); + igt_assert(d); return d; @@ -1174,7 +1183,7 @@ static void init_bb(struct w_step *w, unsigned int flags) { const unsigned int arb_period = - get_bb_sz(w, w->preempt_us) / sizeof(uint32_t); + __get_bb_sz(w, w->preempt_us) / sizeof(uint32_t); const unsigned int mmap_len = ALIGN(w->bb_sz, 4096); unsigned int i; uint32_t *ptr; @@ -1395,7 +1404,7 @@ alloc_step_batch(struct workload *wrk, struct w_step *w, unsigned int flags) if (w->unbound_duration) /* nops + MI_ARB_CHK + MI_BATCH_BUFFER_START */ - w->bb_sz = max(PAGE_SIZE, get_bb_sz(w, w->preempt_us)) + + w->bb_sz = max(PAGE_SIZE, __get_bb_sz(w, w->preempt_us)) + (1 + 3) * sizeof(uint32_t); else w->bb_sz = get_bb_sz(w, w->duration.max);