From patchwork Thu Feb 2 09:08:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9551393 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 88BB360236 for ; Thu, 2 Feb 2017 09:10:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77D1528411 for ; Thu, 2 Feb 2017 09:10:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6CC1228425; Thu, 2 Feb 2017 09:10:31 +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 2C28128411 for ; Thu, 2 Feb 2017 09:10:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9F5876E9A4; Thu, 2 Feb 2017 09:09:42 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7CE216E99B for ; Thu, 2 Feb 2017 09:09:39 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id r18so11763287wmd.3 for ; Thu, 02 Feb 2017 01:09:39 -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=5hBSt2FSZ5rgJK09JKv3+mBsSa650s9D9fISD5aT8Ws=; b=RBKQkHBxeAxbqQNWHCEx1vTJLwmM2WzKVSV33XkVhErhzyGHY9rYUzsUm8wMrzUfVK vqv/5JtUZr/LxgYn+aawep086lWOvWD2LgNdIQ4Fk/hFEh5OnNCXVxaCNitx8eJbskIc 2TVdAjiAAoc1QsxPENpXTmiVTkbNT73Vrys+TXG6zySgzobV8rHL52W+enEmGvwV2COM ntN5ERPpmdcX74Oxza25SbQscaWC32Z26vYtkI1tkPVlfZiDVSqPKhSiZ+IazH6Qx1wz T1b7qOTJ1tuvNfEw0opXcQhGSmGk7losIR52XapUVq8SE9nmsDo9Zn++AgAk8V4BACc7 R8Xg== 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=5hBSt2FSZ5rgJK09JKv3+mBsSa650s9D9fISD5aT8Ws=; b=olI0VC2umufp4zHNF2hWFN2e8ms4vl5WmD9BNNcbK+Py7HloCwFI4LJQ/jsqK/y0+C QmUcW2TY4byXUmghtwnqarR/hcrmN064D/EDQHtP1cjKGJ2U6sRsMrKbvDrt5UTIc8j8 UEu/u1I1eRuv9v4gUv3M+yq9eSrqNwzSPNh7V3FdPR09/a2af42VwSJLGQqz1O03zeM6 fIj4fHdK9VzVvv9w6QRuCSQHb8m7715yK6x5XeCtLEuOev9sCC17RHp1jaKUyqOaY0f+ jvhtiQ4/pA/lBWZ/y8lwuhHHsEtGHh98O8LuK9P6lkI7+6tdTivGIal0nWShvYL1qHCj HnVA== X-Gm-Message-State: AMke39li3+smjkhdIPEOwFVgeyhZVGPznvBN/p/qJNGL+OU0s2O2lKovVKqdiilt+w1HPQ== X-Received: by 10.28.224.67 with SMTP id x64mr1970749wmg.20.1486026577898; Thu, 02 Feb 2017 01:09:37 -0800 (PST) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id s17sm38675584wrc.6.2017.02.02.01.09.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Feb 2017 01:09:36 -0800 (PST) From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Thu, 2 Feb 2017 09:08:47 +0000 Message-Id: <20170202090905.29028-29-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170202090905.29028-1-chris@chris-wilson.co.uk> References: <20170202090905.29028-1-chris@chris-wilson.co.uk> Subject: [Intel-gfx] [PATCH 28/46] drm/i915: Sanity check all registers for matching fw domains 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 Add a late selftest that walks over all forcewake registers (those below 0x40000) and uses the mmio debug register to check to see if any are unclaimed. This is possible if we fail to wake the appropriate powerwells for the register. Signed-off-by: Chris Wilson Reviewed-by: Matthew Auld --- drivers/gpu/drm/i915/selftests/intel_uncore.c | 53 +++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/drivers/gpu/drm/i915/selftests/intel_uncore.c b/drivers/gpu/drm/i915/selftests/intel_uncore.c index c563962eaad7..2fb8122944b2 100644 --- a/drivers/gpu/drm/i915/selftests/intel_uncore.c +++ b/drivers/gpu/drm/i915/selftests/intel_uncore.c @@ -107,6 +107,55 @@ int intel_uncore_mock_selftests(void) return 0; } +static int intel_uncore_check_forcewake_domains(struct drm_i915_private *dev_priv) +{ +#define FW_RANGE 0x40000 + unsigned long *valid; + u32 offset; + int err; + + if (!HAS_FPGA_DBG_UNCLAIMED(dev_priv) && + !IS_VALLEYVIEW(dev_priv) && + !IS_CHERRYVIEW(dev_priv)) + return 0; + + valid = kzalloc(BITS_TO_LONGS(FW_RANGE) * sizeof(*valid), + GFP_TEMPORARY); + if (!valid) + return -ENOMEM; + + intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); + + check_for_unclaimed_mmio(dev_priv); + for (offset = 0; offset < FW_RANGE; offset += 4) { + i915_reg_t reg = { offset }; + + (void)I915_READ_FW(reg); + if (!check_for_unclaimed_mmio(dev_priv)) + set_bit(offset, valid); + } + + intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); + + err = 0; + for_each_set_bit(offset, valid, FW_RANGE) { + i915_reg_t reg = { offset }; + + intel_uncore_forcewake_reset(dev_priv, false); + check_for_unclaimed_mmio(dev_priv); + + (void)I915_READ(reg); + if (check_for_unclaimed_mmio(dev_priv)) { + pr_err("Unclaimed mmio read to register 0x%04x\n", + offset); + err = -EINVAL; + } + } + + kfree(valid); + return err; +} + int intel_uncore_live_selftests(struct drm_i915_private *i915) { int err; @@ -118,5 +167,9 @@ int intel_uncore_live_selftests(struct drm_i915_private *i915) if (err) return err; + err = intel_uncore_check_forcewake_domains(i915); + if (err) + return err; + return 0; }