From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C860C43387 for ; Tue, 15 Jan 2019 16:48:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1B1C720645 for ; Tue, 15 Jan 2019 16:48:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547570899; bh=Rj/cmFtFaLg7xtn58edwVQzAUrYLZVJzoJIYWleiIaY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=soU3Lpcx0K/q/mTWWlbvn2ovzgK/BWGiJiRpmU0q9mSyaXvulLgwbCtds672U8OUg TwIzhnTQWbjkljSfm3hRLvQaDialktLE8rhPhFaAb4t0HHilYdutN0QsCk49TxW+/u z5ALxn2bzwlIsB1UyRxv238vnRyuv72mHHhZ/P/A= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732533AbfAOQsR (ORCPT ); Tue, 15 Jan 2019 11:48:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:34854 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387708AbfAOQpK (ORCPT ); Tue, 15 Jan 2019 11:45:10 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 097552054F; Tue, 15 Jan 2019 16:45:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547570709; bh=Rj/cmFtFaLg7xtn58edwVQzAUrYLZVJzoJIYWleiIaY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o+ATUUBzXCd+40yVF55ouPeDrNBwU8J6pTIGKn8t9i55yyoFPlBKlZFi4xj4B3QF6 TmPJp9yvTRJGSiBdsycseoTueVwieT0dzyIzy7A3C1x2DSL9rsLypGstlJPcLWscIs e9a7inf0hG8T5i1N+1Urw21lkzFybh7wrd/RnZY0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chris Wilson , Joonas Lahtinen , Mika Kuoppala , Matthew Auld , Jani Nikula Subject: [PATCH 4.20 43/57] drm/i915: Unwind failure on pinning the gen7 ppgtt Date: Tue, 15 Jan 2019 17:36:24 +0100 Message-Id: <20190115154913.350212370@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190115154910.734892368@linuxfoundation.org> References: <20190115154910.734892368@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chris Wilson commit 280d479b310298dfeb1d6f9a1617eca37beb6ce4 upstream. If we fail to pin the ggtt vma slot for the ppgtt page tables, we need to unwind the locals before reporting the error. Or else on subsequent attempts to bind the page tables into the ggtt, we will already believe that the vma has been pinned and continue on blithely. If something else should happen to be at that location, choas ensues. Fixes: a2bbf7148342 ("drm/i915/gtt: Only keep gen6 page directories pinned while active") Signed-off-by: Chris Wilson Cc: Joonas Lahtinen Cc: Mika Kuoppala Cc: Matthew Auld Cc: # v4.19+ Reviewed-by: Matthew Auld Link: https://patchwork.freedesktop.org/patch/msgid/20181222030623.21710-1-chris@chris-wilson.co.uk (cherry picked from commit d4de753526f4d99f541f1b6ed1d963005c09700c) Signed-off-by: Jani Nikula Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/i915/i915_gem_gtt.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) --- a/drivers/gpu/drm/i915/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c @@ -2117,6 +2117,7 @@ static struct i915_vma *pd_vma_create(st int gen6_ppgtt_pin(struct i915_hw_ppgtt *base) { struct gen6_hw_ppgtt *ppgtt = to_gen6_ppgtt(base); + int err; /* * Workaround the limited maximum vma->pin_count and the aliasing_ppgtt @@ -2132,9 +2133,17 @@ int gen6_ppgtt_pin(struct i915_hw_ppgtt * allocator works in address space sizes, so it's multiplied by page * size. We allocate at the top of the GTT to avoid fragmentation. */ - return i915_vma_pin(ppgtt->vma, - 0, GEN6_PD_ALIGN, - PIN_GLOBAL | PIN_HIGH); + err = i915_vma_pin(ppgtt->vma, + 0, GEN6_PD_ALIGN, + PIN_GLOBAL | PIN_HIGH); + if (err) + goto unpin; + + return 0; + +unpin: + ppgtt->pin_count = 0; + return err; } void gen6_ppgtt_unpin(struct i915_hw_ppgtt *base)