Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1916287pxb; Thu, 16 Sep 2021 20:09:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTc8qJakC/iNYwl7OLgIMDx9uC4zRICPeHFMUMvA3MyuYn+j26NfCKOcEjXrD5AOO1f62b X-Received: by 2002:a17:906:dbf3:: with SMTP id yd19mr10198023ejb.475.1631848182155; Thu, 16 Sep 2021 20:09:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631848182; cv=none; d=google.com; s=arc-20160816; b=CTLIa2I0Yjp/AzmvmT4+wFB6ajnMiYhAAlSMlxADpK3vgchMdx2hC/xtdv7KJEe/Kj +pXjy/tcNoBYo8lWxwoHc5VqsMFFNXHLkCCyGGJbzrbb1unIUR2M393DeFrG5K9SjMrg f/E67LNZnHQOhEG7YRxln/q5Pokx0JQwO/3NM8gVdv4QBDBBzu+QZMd1k5clUmy45pga cMghRNBtyspM86/IO+xfWZXCayD6WD2FFX05agP8qKHel8z8CWuq5L/zf+cPaMa8qMV5 w20uhOiGNVdPP5I2hNmSfsNb56gdwxKAs0FQcpTycsWvkXnVmuy2r+RhI5GcdyPHQ79u lkhQ== 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=dQ5xP73v/KddFF1plwma8mAzsDwiTbuFyJsu2s9cY00=; b=RtznuXeB2gbbItFRmbpOqM2nuCYPNs1DwNrLZY0eyo21aRsiV9jZTVD/s9Q2cxCLvN WrPveFYqLkpYsooEzr8YmopYhN4EepRLZOwAgdIRfDsaA/uaaRMZoKkeeT5Bun+LSVa8 Os8R45U4tDq1O6jbHrNuQpxvYGc20aW7Ok0dK9YgLoyowfZu8TSxYiOjNHx023uuXTDV lvp6mI9XugJB880ZahMy94muW0UcBjfnTsBto48vAXJRRIDfL1gSjuXOVJ27Y1rY18EM L5AufF8/65xGDnWPP+ukq2l8wys+j3M/PFT1i0/BTI8VpS2NlB9Kh398yksupi/bbW56 4eUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bkp+yiYt; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k2si5512340ejo.293.2021.09.16.20.09.18; Thu, 16 Sep 2021 20:09:42 -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=@linuxfoundation.org header.s=korg header.b=bkp+yiYt; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348139AbhIPR1O (ORCPT + 99 others); Thu, 16 Sep 2021 13:27:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:44344 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351714AbhIPRT1 (ORCPT ); Thu, 16 Sep 2021 13:19:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 11E7960D07; Thu, 16 Sep 2021 16:41:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631810493; bh=G8dpfV2PElFHwAWhg2+m5dwGxUJR7xrvlAx2BMa7kq0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bkp+yiYtcnZJKrbVghDu0UCghkuQhVoegOy+jel8oqk0pfFn0j43AHk+EoSPHeKxy r+I8hOLHichUjr6zTG3XM0YBXCmZyK3Qio3ckBQwkHRNHEO8G4wnB1Qp31CbXA79kd NAFMMyrV4/X7bYXNXfPud/Em9mp1gaZz/oJYWoYs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrey Grodzovsky , =?UTF-8?q?Christian=20K=C3=B6nig?= , Sasha Levin Subject: [PATCH 5.14 160/432] drm/ttm: Fix multihop assert on eviction. Date: Thu, 16 Sep 2021 17:58:29 +0200 Message-Id: <20210916155816.166139983@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155810.813340753@linuxfoundation.org> References: <20210916155810.813340753@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrey Grodzovsky [ Upstream commit 403797925768d9fa870f5b1ebcd20016b397083b ] Problem: Under memory pressure when GTT domain is almost full multihop assert will come up when trying to evict LRU BO from VRAM to SYSTEM. Fix: Don't assert on multihop error in evict code but rather do a retry as we do in ttm_bo_move_buffer Signed-off-by: Andrey Grodzovsky Reviewed-by: Christian König Link: https://patchwork.freedesktop.org/patch/msgid/20210622162339.761651-6-andrey.grodzovsky@amd.com Signed-off-by: Sasha Levin --- drivers/gpu/drm/ttm/ttm_bo.c | 63 +++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 8d7fd65ccced..32202385073a 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -488,6 +488,31 @@ void ttm_bo_unlock_delayed_workqueue(struct ttm_device *bdev, int resched) } EXPORT_SYMBOL(ttm_bo_unlock_delayed_workqueue); +static int ttm_bo_bounce_temp_buffer(struct ttm_buffer_object *bo, + struct ttm_resource **mem, + struct ttm_operation_ctx *ctx, + struct ttm_place *hop) +{ + struct ttm_placement hop_placement; + struct ttm_resource *hop_mem; + int ret; + + hop_placement.num_placement = hop_placement.num_busy_placement = 1; + hop_placement.placement = hop_placement.busy_placement = hop; + + /* find space in the bounce domain */ + ret = ttm_bo_mem_space(bo, &hop_placement, &hop_mem, ctx); + if (ret) + return ret; + /* move to the bounce domain */ + ret = ttm_bo_handle_move_mem(bo, hop_mem, false, ctx, NULL); + if (ret) { + ttm_resource_free(bo, &hop_mem); + return ret; + } + return 0; +} + static int ttm_bo_evict(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx) { @@ -527,12 +552,17 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, goto out; } +bounce: ret = ttm_bo_handle_move_mem(bo, evict_mem, true, ctx, &hop); - if (unlikely(ret)) { - WARN(ret == -EMULTIHOP, "Unexpected multihop in eviction - likely driver bug\n"); - if (ret != -ERESTARTSYS) + if (ret == -EMULTIHOP) { + ret = ttm_bo_bounce_temp_buffer(bo, &evict_mem, ctx, &hop); + if (ret) { pr_err("Buffer eviction failed\n"); - ttm_resource_free(bo, &evict_mem); + ttm_resource_free(bo, &evict_mem); + goto out; + } + /* try and move to final place now. */ + goto bounce; } out: return ret; @@ -847,31 +877,6 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo, } EXPORT_SYMBOL(ttm_bo_mem_space); -static int ttm_bo_bounce_temp_buffer(struct ttm_buffer_object *bo, - struct ttm_resource **mem, - struct ttm_operation_ctx *ctx, - struct ttm_place *hop) -{ - struct ttm_placement hop_placement; - struct ttm_resource *hop_mem; - int ret; - - hop_placement.num_placement = hop_placement.num_busy_placement = 1; - hop_placement.placement = hop_placement.busy_placement = hop; - - /* find space in the bounce domain */ - ret = ttm_bo_mem_space(bo, &hop_placement, &hop_mem, ctx); - if (ret) - return ret; - /* move to the bounce domain */ - ret = ttm_bo_handle_move_mem(bo, hop_mem, false, ctx, NULL); - if (ret) { - ttm_resource_free(bo, &hop_mem); - return ret; - } - return 0; -} - static int ttm_bo_move_buffer(struct ttm_buffer_object *bo, struct ttm_placement *placement, struct ttm_operation_ctx *ctx) -- 2.30.2