From patchwork Tue Dec 20 13:08:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9481537 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 7606E606DB for ; Tue, 20 Dec 2016 13:10:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67966283E8 for ; Tue, 20 Dec 2016 13:10:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A1D82846A; Tue, 20 Dec 2016 13:10:49 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 E460D283E8 for ; Tue, 20 Dec 2016 13:10:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 12CA76EE11; Tue, 20 Dec 2016 13:10:48 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wj0-x243.google.com (mail-wj0-x243.google.com [IPv6:2a00:1450:400c:c01::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id EA9096E077 for ; Tue, 20 Dec 2016 13:08:29 +0000 (UTC) Received: by mail-wj0-x243.google.com with SMTP id xy5so27555508wjc.1 for ; Tue, 20 Dec 2016 05:08:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=zUj9LXJsAhjp8mGW9S9hrjb+manAr0TFoOywG482d4E=; b=gi8Qi6ugs2gHvAzsiJjFJsVxtsNUmcEuAZvr40RpEtbESjsKcVITaOTOjxzzj1VxPg rv2CK7MBCZHBVzSSg46JPjQjjxRZNY1gQnZTxo3CFkV9TfE9QwsBoIF+EM8+ZLmaTrSR JoWgkZKszp36m+pRAEdM9RTU+/tnAC+31nAJotI9zjzub6EsEisax5ZcuGGApCrmxzMK NKNmgcTfkE+kGCxwIubvZbYoRMC+SG0v8lWtcjAoRT+3wmSVunegrCTBo/Hc9gXfyLw4 sI9p1pacoj790iu/H8iwGm+kIiGvJiCtyLNVlWtVvoXerJUZS3J/1uwtbZkFKplbGcSR ZJ4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=zUj9LXJsAhjp8mGW9S9hrjb+manAr0TFoOywG482d4E=; b=oMv+CFJC52R+eUfdMnQN9Lmnx/MXRq3FrGGXhzhPJTOuAydATYSQPTc6rfSMHsoF5B qqamWdueq+dct9VAWv74Mdlj8wSGF8Gi9agkFRRbr5wyRnSUYlLaHKJaAXc72Xk0Aft1 i1IekTJeH2mK8BUJZiZ0YKuMg/0opgrF4gi7U8EUBBWk9zcFwh6REMcuQl/eBdFbJTN2 1RHcbt9mrnKXinyCOWvX8+5LPbAw52pjA7/2MF7CIarNday8H6P8xcU38Bz6bTnI/zOU Fyo8t1OcmMCg8LOeSfVWyDW8Wi++EVaoSkKyOVQ+aDJLs9bF3eweQgVY9SZhoOBC0jOe 2JkA== X-Gm-Message-State: AKaTC01KMqHMTA6HTIUWU0dTvDPGPiU2jz9LptDpmIoTQWZf/nX09NyTmg0wQA4TytDedQ== X-Received: by 10.195.14.103 with SMTP id ff7mr17511555wjd.126.1482239308068; Tue, 20 Dec 2016 05:08:28 -0800 (PST) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id f3sm22102502wmf.10.2016.12.20.05.08.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Dec 2016 05:08:27 -0800 (PST) From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Tue, 20 Dec 2016 13:08:06 +0000 Message-Id: <20161220130814.10213-11-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20161220130814.10213-1-chris@chris-wilson.co.uk> References: <20161220130814.10213-1-chris@chris-wilson.co.uk> Subject: [Intel-gfx] [RFCv2 11/19] drm/i915: Add a simple request selftest for waiting 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 A trivial kselftest to submit a request and wait upon it. Signed-off-by: Chris Wilson --- drivers/gpu/drm/i915/selftests/i915_gem_request.c | 44 +++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_request.c b/drivers/gpu/drm/i915/selftests/i915_gem_request.c index 43d92d8c8377..743a641b1cd9 100644 --- a/drivers/gpu/drm/i915/selftests/i915_gem_request.c +++ b/drivers/gpu/drm/i915/selftests/i915_gem_request.c @@ -47,10 +47,54 @@ static int igt_add_request(void *arg) return err; } +static int igt_wait_request(void *arg) +{ + const long T = HZ / 4; + struct drm_i915_private *i915 = arg; + struct drm_i915_gem_request *request; + int err = -EINVAL; + + mutex_lock(&i915->drm.struct_mutex); + request = mock_request(i915->engine[RCS], i915->kernel_context, T); + if (!request) { + err = -ENOMEM; + goto out_unlock; + } + + i915_add_request(request); + + if (i915_gem_request_completed(request)) { + pr_err("request completed immediately!\n"); + goto out_unlock; + } + + if (i915_wait_request(request, I915_WAIT_LOCKED, T / 2) != -ETIME) { + pr_err("request wait succeeded (expected tiemout!)\n"); + goto out_unlock; + } + + if (i915_wait_request(request, I915_WAIT_LOCKED, T) == -ETIME) { + pr_err("request wait timed out!\n"); + goto out_unlock; + } + + if (!i915_gem_request_completed(request)) { + pr_err("request not complete after waiting!\n"); + goto out_unlock; + } + + err = 0; +out_unlock: + mock_device_flush(i915); + mutex_unlock(&i915->drm.struct_mutex); + return err; +} + int i915_gem_request_selftest(void) { static const struct i915_subtest tests[] = { SUBTEST(igt_add_request), + SUBTEST(igt_wait_request), }; struct drm_i915_private *i915; int err;