Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2091183ybp; Thu, 10 Oct 2019 02:02:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqxivYUMfoIQox1tpbqp8oMAPlazGyBVe+o6G/QgPkrCwZqgb6V8Gp27qCjB9nVB7k5CGMWN X-Received: by 2002:a17:906:6bcd:: with SMTP id t13mr6964183ejs.133.1570698145219; Thu, 10 Oct 2019 02:02:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570698145; cv=none; d=google.com; s=arc-20160816; b=LANZRYyBNSN8AJe6fSe86BuVkypywgmJ2ENq4Rs5cd57Qj+n2174dllJ2mzsiKCivs JEgXbYm5MpkTC5wST832uQNQdFRHpse4d309AReTsBqGK+UX1vGR//QShdb/3v0ygIkC y3NNHKBveJehH5DKEyGNxEtiw+7UOWPheSLK33UbnTog1MgCU/mZk58lXtYvvfPFf46g m8glRXTQSC2gVLDVpLOZj/87vNhku6oFf5F8DFdQZrP57Vl6jYGwumkgotBX8Kw/g1Lq BUuaPyljD5z+JwPOV1NCEZjGMfhH5wZjyMPGl+0pqYkrrmEDV9kCKkCLymkWyrnWl4D8 Z3Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZnN0ND4e+8tntSLAjdbbl96XrbVfniH5Xkg/5xzuevI=; b=SWb3sQBTRYGmMSvBdK3QgAmuUun2J1jzRkYo7VqtNXsc2uVDmlPbbP5zFKvuCQgAY/ 0OHHks3m+cycbcNSKa5+VyeEuxpJlWwMN6zztN28N18UlYz+cHzoSQ3uHSfJkYMxJY7N tFM+LtDDHH/7rFzXPGWT0AEUDpKqCR0fNHHa8vKBB/H5hkwSaY74YW8K+aAYfltLm/1r q0oRUkR8T+kfaZ0K07usHlqG8b9uqaKweGp17f1hKJAJ5fYk+mMew3H+rTSThuJ8BiEG hsGB5PuF0SNkuwxNykaHyrFKjTAhi3M4FkdZb74k+Yoy4I4Fm/C34IB2BcIXTDGxKP+Z Ik6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QWHS2UrZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g21si2668036ejk.23.2019.10.10.02.02.01; Thu, 10 Oct 2019 02:02:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QWHS2UrZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388188AbfJJIks (ORCPT + 99 others); Thu, 10 Oct 2019 04:40:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:44916 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387545AbfJJIkr (ORCPT ); Thu, 10 Oct 2019 04:40:47 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 0A5A2218AC; Thu, 10 Oct 2019 08:40:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570696846; bh=Ie0By+KUnOkwmDWpsFLRzWys8/g/MupAZOH9aBYUGdI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QWHS2UrZ6biemLVcSOwyoF/VqKcFkhMETxBG67bxQLkrolstDaPPPSE2AWiEzvBi4 +5fBbI0belrBJNkoX6WWmdtxk7gmFOTl8QfLmAA8EjwB/dIUTjrplyL+xy7l43rV/E SZGuBjo3ZsEbCLf+E5X0zxvn+ku+MriSIHpMe+Js= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiaolin Zhang , Chris Wilson , Rodrigo Vivi Subject: [PATCH 5.3 072/148] drm/i915: to make vgpu ppgtt notificaiton as atomic operation Date: Thu, 10 Oct 2019 10:35:33 +0200 Message-Id: <20191010083615.760135349@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191010083609.660878383@linuxfoundation.org> References: <20191010083609.660878383@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Xiaolin Zhang commit 9e77f5001b9833a6bdd3940df245053c2212a32b upstream. vgpu ppgtt notification was split into 2 steps, the first step is to update PVINFO's pdp register and then write PVINFO's g2v_notify register with action code to tirgger ppgtt notification to GVT side. currently these steps were not atomic operations due to no any protection, so it is easy to enter race condition state during the MTBF, stress and IGT test to cause GPU hang. the solution is to add a lock to make vgpu ppgtt notication as atomic operation. Cc: stable@vger.kernel.org Signed-off-by: Xiaolin Zhang Acked-by: Chris Wilson Signed-off-by: Chris Wilson Link: https://patchwork.freedesktop.org/patch/msgid/1566543451-13955-1-git-send-email-xiaolin.zhang@intel.com (cherry picked from commit 52988009843160c5b366b4082ed6df48041c655c) Signed-off-by: Rodrigo Vivi Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_gem_gtt.c | 12 +++++++----- drivers/gpu/drm/i915/i915_vgpu.c | 1 + 3 files changed, 9 insertions(+), 5 deletions(-) --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -1073,6 +1073,7 @@ struct i915_frontbuffer_tracking { }; struct i915_virtual_gpu { + struct mutex lock; /* serialises sending of g2v_notify command pkts */ bool active; u32 caps; }; --- a/drivers/gpu/drm/i915/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c @@ -1248,14 +1248,15 @@ free_scratch_page: return ret; } -static int gen8_ppgtt_notify_vgt(struct i915_ppgtt *ppgtt, bool create) +static void gen8_ppgtt_notify_vgt(struct i915_ppgtt *ppgtt, bool create) { - struct i915_address_space *vm = &ppgtt->vm; - struct drm_i915_private *dev_priv = vm->i915; + struct drm_i915_private *dev_priv = ppgtt->vm.i915; enum vgt_g2v_type msg; int i; - if (i915_vm_is_4lvl(vm)) { + mutex_lock(&dev_priv->vgpu.lock); + + if (i915_vm_is_4lvl(&ppgtt->vm)) { const u64 daddr = px_dma(ppgtt->pd); I915_WRITE(vgtif_reg(pdp[0].lo), lower_32_bits(daddr)); @@ -1275,9 +1276,10 @@ static int gen8_ppgtt_notify_vgt(struct VGT_G2V_PPGTT_L3_PAGE_TABLE_DESTROY); } + /* g2v_notify atomically (via hv trap) consumes the message packet. */ I915_WRITE(vgtif_reg(g2v_notify), msg); - return 0; + mutex_unlock(&dev_priv->vgpu.lock); } static void gen8_free_scratch(struct i915_address_space *vm) --- a/drivers/gpu/drm/i915/i915_vgpu.c +++ b/drivers/gpu/drm/i915/i915_vgpu.c @@ -79,6 +79,7 @@ void i915_check_vgpu(struct drm_i915_pri dev_priv->vgpu.caps = __raw_uncore_read32(uncore, vgtif_reg(vgt_caps)); dev_priv->vgpu.active = true; + mutex_init(&dev_priv->vgpu.lock); DRM_INFO("Virtual GPU for Intel GVT-g detected.\n"); }