Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp4257550pxb; Mon, 21 Feb 2022 16:10:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJye7xK1jbmzy6nS5j5bKwlbXoFm4D6jOomJ82/Xq38ALvEEJSDFG0yZiLfOYnghlZXErET1 X-Received: by 2002:a17:906:60d6:b0:6cf:e577:c93f with SMTP id f22-20020a17090660d600b006cfe577c93fmr17852299ejk.8.1645488642920; Mon, 21 Feb 2022 16:10:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645488642; cv=none; d=google.com; s=arc-20160816; b=eYiz962pj9Voi5Rquxm9K3Z7yCW47tYeXrolXmw/HjbVcA6sSodJKIqUUo7drJ6jj1 10FDzfqasUdUJmUFRmL87/0/jgkOZbKyR6GZv9NEp9M9VauftvDZSqy+VhQBOovPBgIq hIWX0FzmK7D6SNmW1BUeS6PphxUGT0ZUbW/tQFUZNfisYb0PuhsTqHsZh5FkZ9CaXbv7 qpj3zeMQ6076irsAbdEQg27PFZYif/jo+p/XxmrLpeX8bwF3oItE83s3Gcaas6dN4ah5 85dDe7nMCZlwK+AImrg/PayIVy7pE+tPg3uS6+ldc/Cp+a/l7rEfO25MDTN6e1YuV1CW 1cDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=xJCQhHzOd45wG/UAK1TvhXtTtQM9M3/WsJn/3wjgsRI=; b=r47SCbwc8J9fUvWbLr5IUKnTWKsH6oRIvjQHacNhJGEB9vo31S4A2V1l9LoHsUzhkl Ob/7CB0CX+NS5GTQkL/H7YNJLFb+Xke4V0/tVvdREqoX5aRpAn+PdkJ1uzkD0pqtAbIi qD7me3Tcb8zrvnhaid453duvABp6Hw5U1gAv8nWgJ906RkrJyMiZoGgFaoSt02bVFU/N VWC7o91WOnKmMELK9/qdtNLaBa1hQzjjT3FXVRU+lvs3sAX0tWdU/iZjklw+0zhH+aRX A64iqDaDOKloD/qpsipbsw1PK/zku4Y4sdUnpwx477YHjYOEvvuVWkG7BgwdfHPuOo58 I3TA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 24si9379192eje.481.2022.02.21.16.10.20; Mon, 21 Feb 2022 16:10:42 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355693AbiBULNC (ORCPT + 99 others); Mon, 21 Feb 2022 06:13:02 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:41044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355457AbiBULMa (ORCPT ); Mon, 21 Feb 2022 06:12:30 -0500 Received: from mx1.molgen.mpg.de (mx3.molgen.mpg.de [141.14.17.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEB6E1098 for ; Mon, 21 Feb 2022 02:46:37 -0800 (PST) Received: from [192.168.0.2] (ip5f5aebce.dynamic.kabel-deutschland.de [95.90.235.206]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: pmenzel) by mx.molgen.mpg.de (Postfix) with ESMTPSA id E3ECD61E64846; Mon, 21 Feb 2022 11:46:34 +0100 (CET) Message-ID: Date: Mon, 21 Feb 2022 11:46:34 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH] drm/amdgpu: check vm ready by evicting Content-Language: en-US To: Qiang Yu Cc: Alex Deucher , =?UTF-8?Q?Christian_K=c3=b6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20220221101239.2863-1-qiang.yu@amd.com> From: Paul Menzel In-Reply-To: <20220221101239.2863-1-qiang.yu@amd.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,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 Dear Qiang Yu, Am 21.02.22 um 11:12 schrieb Qiang Yu: Thank you for your patch. Reading the commit message summary, I have no idea what “check vm ready by evicting” means. Can you please rephrase it? > Workstation application ANSA/META get this error dmesg: What version, and how can this be reproduced exactly? Just by starting the application? > [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 check the s/check/checking/ > evicting flag which really stop VM ops latter. stop*s*? Can you please elaborate. Christian’s and your discussions was quite long, so adding a summary, why this approach works and what possible regressions there are going to be might be warranted. Kind regards, Paul > Signed-off-by: Qiang Yu > --- > 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 37acd8911168..2cd9f1a2e5fa 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c > @@ -770,11 +770,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; > } > > /**