Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp104797ybg; Mon, 8 Jun 2020 17:42:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLxp75N3jawF46tXx15ulqyZVlkA8HpLMcw1mqlZiTnemX9RSlZ2vNM1iDsFHPGB00n2GW X-Received: by 2002:a17:906:7acf:: with SMTP id k15mr24046550ejo.410.1591663364404; Mon, 08 Jun 2020 17:42:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591663364; cv=none; d=google.com; s=arc-20160816; b=KZ+O7YVejCw0K8aKynJTK/JZFBr0K3Q0ZlceP8ohAsJDz+rr353mbKLXH/CrXSFRlD L166Mpryv4+WZwefYAuOn5eStpY6AK9Ogb9WG7CrFTk7GAP8vxG0dYceIB04F0Yu7OIa oSH6IRQnqtr7VBkBgXakLdU9OP7iYUK67rSrd/pY4iya47QO9UfPO0/pDiyMKIa+/Lul NiuUKeXD+YCNfpx5Ovdsv/r2iIs1yJKZLXo0YJ3avb35fBGEN9P83Ps2f7TzP2p7immJ 55tty86cmg94pVYeBf4+5/RjA21mWY0+iHo+7WoQ0hwtS8JoNxN4rF32fzhDVhP6hUov 60hA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gq0rxHL6rUMUfnxupyavYB2nNystiDanP3877BShJQI=; b=1FsxDWhlcTYWUE2xw+3jE5k5uaZ1fBHS6raG+TeTifr6tGtdoh9oHBLk+FLsmfRP1t OKFHKm9Q4O7Yj7CXVPhZnVajetjjKsjwn0pSBSHmypj1cr+ACLfXF5kemaCFBaUGPrMI qXbpUA9fjSTKi+2cHKCPQRn9Jdvohy4PChqr9CYI24pF7/6n8Ynl7IXKJ8v8gdTXBTE+ SCll+NhcAfkReU6tKLr83THac62UDR9bXky5T96xjVfkzFBl6XDFqEEkbtRaUpwhDELq lcLiq0WLgjL4aKDetFgxRcKewTRWsWFoaxUWOur17p4cRhzKPIpb4KxoodzUerBwNuhg ZqZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nY3tjfeO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m10si9686255edv.322.2020.06.08.17.42.21; Mon, 08 Jun 2020 17:42:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nY3tjfeO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728076AbgFHXMy (ORCPT + 99 others); Mon, 8 Jun 2020 19:12:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:57638 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728809AbgFHXLC (ORCPT ); Mon, 8 Jun 2020 19:11:02 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E42EF2100A; Mon, 8 Jun 2020 23:11:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591657861; bh=FSSEj0I+Qs96LnMPO/9ObpRwOVHhKyOHosCzGUsdNQk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nY3tjfeOqLqgfHbWwjoH5T27o3y8gH28q9tJMm/TN+uLkzmsmETD7q9GbZGbt3Fzk x6UXe4Of/sKdjqdk6XzkpyLFiBUxWY38cM+xhfdeKmOGyi2QZWaQ+AdNoehyxmQ59V ZXutCAWtYP3Li6wveroouNtF2jTLn7h+SzEQ7WoM= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Felix Kuehling , Jay Cornwall , =?UTF-8?q?Christian=20K=C3=B6nig?= , Alex Deucher , Sasha Levin , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.7 224/274] drm/amdgpu: Sync with VM root BO when switching VM to CPU update mode Date: Mon, 8 Jun 2020 19:05:17 -0400 Message-Id: <20200608230607.3361041-224-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200608230607.3361041-1-sashal@kernel.org> References: <20200608230607.3361041-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Felix Kuehling [ Upstream commit 90ca78deb004abe75b5024968a199acb96bb70f9 ] This fixes an intermittent bug where a root PD clear operation still in progress could overwrite a PDE update done by the CPU, resulting in a VM fault. Fixes: 108b4d928c03 ("drm/amd/amdgpu: Update VM function pointer") Reported-by: Jay Cornwall Tested-by: Jay Cornwall Signed-off-by: Felix Kuehling Reviewed-by: Christian König Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 6d9252a27916..06242096973c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -2996,10 +2996,17 @@ int amdgpu_vm_make_compute(struct amdgpu_device *adev, struct amdgpu_vm *vm, !amdgpu_gmc_vram_full_visible(&adev->gmc)), "CPU update of VM recommended only for large BAR system\n"); - if (vm->use_cpu_for_update) + if (vm->use_cpu_for_update) { + /* Sync with last SDMA update/clear before switching to CPU */ + r = amdgpu_bo_sync_wait(vm->root.base.bo, + AMDGPU_FENCE_OWNER_UNDEFINED, true); + if (r) + goto free_idr; + vm->update_funcs = &amdgpu_vm_cpu_funcs; - else + } else { vm->update_funcs = &amdgpu_vm_sdma_funcs; + } dma_fence_put(vm->last_update); vm->last_update = NULL; vm->is_compute_context = true; -- 2.25.1