Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1784612pxp; Mon, 7 Mar 2022 02:14:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJwwTc6kyGwFVQu9XJLNQGd4jcQ+ZlN3LpPLTxqoQsRx+UaNKeCk3JGWzJseyf9kvbATnshT X-Received: by 2002:a05:6402:40c4:b0:416:3e66:1825 with SMTP id z4-20020a05640240c400b004163e661825mr5307717edb.284.1646648075063; Mon, 07 Mar 2022 02:14:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646648075; cv=none; d=google.com; s=arc-20160816; b=cUzNuFsUAYSJPYohe8lkEUtcrigleBGeHwF41pN4BSxgu9Nxd/DrON+HJ7KT3+uUWk 8YjTUoR6+vhjIoh63q2BrN73XUA+jK6518PNnecEunUMxpl+djkpNJb2MXnUe0xfS4gz oGgK1AqYhCSso08fdwuKTtjQuX6FJNRrOFJDYbcz7j/Sry+PUNyTVilUFF2EFdAwyYUF U5zv/Ihbtnm7/ejt+rkfibu7OEXyK+Xd2+8vcCgL8J86kWu2zulwkMjv5c+EcZ1FPgl+ qpY6OzqY7Mf6xh8S+cjcLAfBbkQVP1O8uLmS6jtBzUXj9mb2HRNqtuSMpMGG8NLj10Hx UTLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AkHYJdZg2+MkxVGMFzlzvqIkji3hxnepGQUwc8Xl0A0=; b=TNzYaly3GI+xguj9Pzfrc3pCsO74rdGpfy4aKFbM9h1gmX98AJI8xqp8gEcBFSnEhX VAxHnj1BB2VMq065uFTnG5rrQbYEQvM1uXRKV3E7IZd2onS7+yqj8wj/BJloM2/wEhWL sbNwOM5ARLjQv/JhkngAnFcJeKTvao56pCs7rKNoU8uQD7VRQrtaJYc7qevqT/M0XOqJ NXTjxkK7F4DV2MeWhAOFnkc+UVdMDf/qNSV+aEvjn/CSIAlj2Bvri1i7gg97PmWZhhq/ icZZHd8tOHfu9riefT+3IidlCJ6whZPqlV7iQOWeuhPp8ERBAZpFvnutwOoaPDc2t3F0 w+CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="nZ4cGLl/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g1-20020a1709065d0100b006dae9f22c12si7722553ejt.664.2022.03.07.02.14.12; Mon, 07 Mar 2022 02:14:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="nZ4cGLl/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238211AbiCGJqj (ORCPT + 99 others); Mon, 7 Mar 2022 04:46:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238193AbiCGJiD (ORCPT ); Mon, 7 Mar 2022 04:38:03 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4D7C69CEB; Mon, 7 Mar 2022 01:32:11 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 56755B810B6; Mon, 7 Mar 2022 09:32:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C384C340E9; Mon, 7 Mar 2022 09:32:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645530; bh=y4kYIpkFuT8+05Fj86LzKPcq4g22FEMpZFASFU/kXo4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nZ4cGLl/ezZh0AWie6nLwpPK1JCN0I0kNFyrmvDz1Sk1/sJAshPOA8/MGY9RqTEzg +X0rf9aKzeta8yGY/Mt3eWeYuFYmSvKJPbD89RqzbZjv7cFB1zEESCZHg9PFuPhQdX u5bNSDspF2T6Br4W+xYBcULMd0XfxBKkCroabpmE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paul Menzel , =?UTF-8?q?Christian=20K=C3=B6nig?= , Qiang Yu , Alex Deucher , Sasha Levin Subject: [PATCH 5.10 023/105] drm/amdgpu: check vm ready by amdgpu_vm->evicting flag Date: Mon, 7 Mar 2022 10:18:26 +0100 Message-Id: <20220307091644.834793763@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091644.179885033@linuxfoundation.org> References: <20220307091644.179885033@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Qiang Yu [ Upstream commit c1a66c3bc425ff93774fb2f6eefa67b83170dd7e ] Workstation application ANSA/META v21.1.4 get this error dmesg when running CI test suite provided by ANSA/META: [drm:amdgpu_gem_va_ioctl [amdgpu]] *ERROR* Couldn't update BO_VA (-16) This is caused by: 1. create a 256MB buffer in invisible VRAM 2. CPU map the buffer and access it causes vm_fault and try to move it to visible VRAM 3. force visible VRAM space and traverse all VRAM bos to check if evicting this bo is valuable 4. when checking a VM bo (in invisible VRAM), amdgpu_vm_evictable() will set amdgpu_vm->evicting, but latter due to not in visible VRAM, won't really evict it so not add it to amdgpu_vm->evicted 5. before next CS to clear the amdgpu_vm->evicting, user VM ops ioctl will pass amdgpu_vm_ready() (check amdgpu_vm->evicted) but fail in amdgpu_vm_bo_update_mapping() (check amdgpu_vm->evicting) and get this error log This error won't affect functionality as next CS will finish the waiting VM ops. But we'd better clear the error log by checking the amdgpu_vm->evicting flag in amdgpu_vm_ready() to stop calling amdgpu_vm_bo_update_mapping() later. Another reason is amdgpu_vm->evicted list holds all BOs (both user buffer and page table), but only page table BOs' eviction prevent VM ops. amdgpu_vm->evicting flag is set only for page table BOs, so we should use evicting flag instead of evicted list in amdgpu_vm_ready(). The side effect of this change is: previously blocked VM op (user buffer in "evicted" list but no page table in it) gets done immediately. v2: update commit comments. Acked-by: Paul Menzel Reviewed-by: Christian König Signed-off-by: Qiang Yu Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index b47829ff30af7..47cc038d7d506 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -715,11 +715,16 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm, * Check if all VM PDs/PTs are ready for updates * * Returns: - * True if eviction list is empty. + * True if VM is not evicting. */ bool amdgpu_vm_ready(struct amdgpu_vm *vm) { - return list_empty(&vm->evicted); + bool ret; + + amdgpu_vm_eviction_lock(vm); + ret = !vm->evicting; + amdgpu_vm_eviction_unlock(vm); + return ret; } /** -- 2.34.1