X-Received: by 2002:a17:906:2b4c:b0:6cf:740f:7719 with SMTP id b12-20020a1709062b4c00b006cf740f7719mr52280ejg.569.1645627929911; Wed, 23 Feb 2022 06:52:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645627929; cv=none; d=google.com; s=arc-20160816; b=lwrak9q3La2I6R5q0I3J7EQKRdmENwGQR2E6BfHgndqcIljlnbFkYwX8UsxUmeV6RC SHln4q7BatkVGLTenqUMMvFYdpJ650LmOCFDQNOQRLV9/XkPko19o7OHJJBNUaa+DT0D FOEUXTg+MQdT7I1j8jc8qApA3YOTNuYdRhR1zMoUpvThyRp7WNc7YC1a+m79sTThve5d zTp2B/PRxYrqDeTLhLz4pULywqqQXGiPv3Osouy3YqEUA0h69nrgTiHawwUD6ry7tlxd 5eSI9qGdQ+6xeD0NQTqfKq/ZeRxqiHqpFp4lYzYNDlY87wDNLYUPrAgoHzS74fwzW0Wb LQJg== 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=mMVOs1zpMfjZnoU8mPy5Q9bRTXyzKuuigs+W8r8vaPY=; b=wyOjoxPmxUnc6rf5petQHGe/qrZxveLAWdvYWGvvzb/adm3NqEz7zOTTABMQYryruV gQgltPNZz40LF+CVImFKSXboyyQYec6cb9EDBre8nmv37/xn05TzbXnbXChD6bh27NCa zYSH4D7vYPmEwLyYAvUAqSLyjNKTbClFWeOjq2sawCkMVdHwBBe6ZX7qW/HTvIWkRWXt xb4PvTFk3+0wBhwulCrKfpun9d7h2slVRqknd7HEgUtK2WkzGoGXZrlWkuo+STVzxJ7I BpHuGRjPqIMHvvNiQ3+ZXMAnqRRSBaC4nVKNpcf4KXTXyBVKS+peEZDTM00S9IjpgO9s Rhug== 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 g10si2516948edb.474.2022.02.23.06.51.46; Wed, 23 Feb 2022 06:52:09 -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 S237319AbiBWHsm (ORCPT + 99 others); Wed, 23 Feb 2022 02:48:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238840AbiBWHsg (ORCPT ); Wed, 23 Feb 2022 02:48:36 -0500 Received: from mx1.molgen.mpg.de (mx3.molgen.mpg.de [141.14.17.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADFB57804A for ; Tue, 22 Feb 2022 23:47:51 -0800 (PST) Received: from [192.168.0.2] (ip5f5aee1b.dynamic.kabel-deutschland.de [95.90.238.27]) (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 7009361EA1928; Wed, 23 Feb 2022 08:47:48 +0100 (CET) Message-ID: <2998de6b-bff2-4ef5-135a-1269f948c486@molgen.mpg.de> Date: Wed, 23 Feb 2022 08:47:47 +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 v2] drm/amdgpu: check vm ready by amdgpu_vm->evicting flag Content-Language: en-US To: Qiang Yu Cc: Alex Deucher , =?UTF-8?Q?Christian_K=c3=b6nig?= , Xinhui Pan , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20220222024651.36675-1-qiang.yu@amd.com> From: Paul Menzel In-Reply-To: <20220222024651.36675-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, Am 22.02.22 um 03:46 schrieb Qiang Yu: > 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() latter. 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 this > buffer in "evicted" list but no page table in it) gets done > immediately. > > v2: update commit comments. > > Reviewed-by: Christian König > 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; > } > > /** Acked-by: Paul Menzel Kind regards, Paul