Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp561703imm; Thu, 13 Sep 2018 04:23:58 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZSVgyBp4k/ntccuq2yY0tlLIw98K1LAqj+xq5Q6ymaDYZNPPGqMLt+Xz6Su3P4drK1d9gD X-Received: by 2002:a17:902:b688:: with SMTP id c8-v6mr6915949pls.114.1536837838395; Thu, 13 Sep 2018 04:23:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536837838; cv=none; d=google.com; s=arc-20160816; b=GL3GzizTMQ2fu2xf/xs6EZZgfJzrnkCCijgIXHDFfHh6iKOqgmcRa4G9EYDC+jyqbr J23rD+S45/6IDp8Vg8TJ4ckMCeHDeCtHAPB0b2mpxGfcwpUfcysB9DnNsKjr3BMtZnyM vZVYbBAab7JNLCRTBRUsKaJHKlo+/fap1pkWRR5C4OF25Gbn7+1fuMvyQZb3QxAF2g1C RypY0KxyBy7WqUhUfAscay5aMDpXHwH+pUFgWHeKdnftdiQRICLr6+9xWlRbGC2LIYvh mNvSSpQZAnNc+TK0Ll2VQhOG8ERAKtAbNhFZwATQ6D/z4+i9ZKvViMUVXXI91zZwOwm6 FypA== 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:to:from :dkim-signature; bh=91QhPC3Xjc3TQAm8K0a68uNGIKKtw9ovWxFTrPH712w=; b=eKhQCvlM1BppHRPjW7gPOsBY8cufJQioIFkse1ICMzAF9rxLSBBsBnS9MBhLouYyOu DHzQGG9WsjZVwcchivaojCR8ovtNfQKT2h0GtP/nTrZx8e/jO0ghDchQIjtNlwhoEY0a ExpSOkaMOyrzWUMlz58Of8eSpHiJJzoaG9DEi/nPxk8mcdY0aTm87mNiVe7EIU7Cm0PW Jeu9yGVUVD2GPfwKChVgscb5aianRbU2gtJqBk8DxkHACWIRl7SXGgzZNlPs9+h1IjSf /9euPl/pKg9Qq7Ilv4PkGKrA9IcTMqP9fnFW/b1sJp4VAsM9WXer6ZyF2RTTb7VFtoAB KZ6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=riZZQpOL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n9-v6si3651639pff.370.2018.09.13.04.23.41; Thu, 13 Sep 2018 04:23:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=riZZQpOL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727791AbeIMQbO (ORCPT + 99 others); Thu, 13 Sep 2018 12:31:14 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:44250 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726828AbeIMQbN (ORCPT ); Thu, 13 Sep 2018 12:31:13 -0400 Received: by mail-wr1-f65.google.com with SMTP id v16-v6so5192041wro.11 for ; Thu, 13 Sep 2018 04:22:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=91QhPC3Xjc3TQAm8K0a68uNGIKKtw9ovWxFTrPH712w=; b=riZZQpOLYYgXvrzanT+oP6q20l7xDTE9KI/t3vpOi8wHs7eQDCxEU0ugz4L2FOGQoD 8z0TGQx7cZVCa6M4QEv9QmG79N97tgQDx/B2vqBG7OlLyYWEWC0pyd4lN+dGJx2ritNG snvxyeTGrljkVOBZKnXLKVWiAOJrBi8qaRboiRhTP/zDrYW4jesRujxPkflceLuwSj0D eitOaCe6sj1KDWLrgUEZsULmKnYwsKp/5K+e6HbACyZ1GiywKVMt1SuaiWBJNsVPfPcm V2O/uUDF0tF9SgMq18YpbVciJbrv9MsPzse5Op+MO6jP4dVcEn5cQEHbRH8LR8zzWo9E y7sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=91QhPC3Xjc3TQAm8K0a68uNGIKKtw9ovWxFTrPH712w=; b=VsQxqBRfczXkR+iKkBNdpSlv3u3w+zmvOgqzWn+be0SiNfBnylp2PIJLfiDxtsUddS VXDFquYhq94dHEJac1DQefR2e3U7SVTp9cgo4es1DvaJezJaaUkGCiN8DMc5GVremrAI T8Y+JrFl7XJUeYYniJzHbhtlKusUdxK3M9EDOG8nA/Vr6abNvtmC+Z9Zen18Beeq2Cpp fUu1Mk9kogkUmFbwN/6zdNUPYzGEoq5wiEok0lAbC3/TmipEaE2qq5b0cLelJKQHJouj BIY8z0R8TbP6C44//BlBfDRJpXLxGqZ42woUmfKLle4OPezPRD14NTgmbbXqnyUBwRuL bRug== X-Gm-Message-State: APzg51Cjyzhyshpcqq6rGtNEQmXlRjxZdxv8t8nJ7rVunLOmapQna0vx pWzqSwoP8neqcpcXIivQJUSl2buC X-Received: by 2002:adf:b2b5:: with SMTP id g50-v6mr4758562wrd.218.1536837730615; Thu, 13 Sep 2018 04:22:10 -0700 (PDT) Received: from baker.fritz.box ([2a02:908:1257:4460:c8f7:2479:525e:9500]) by smtp.gmail.com with ESMTPSA id u65-v6sm5528748wmd.31.2018.09.13.04.22.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Sep 2018 04:22:09 -0700 (PDT) From: "=?UTF-8?q?Christian=20K=C3=B6nig?=" X-Google-Original-From: =?UTF-8?q?Christian=20K=C3=B6nig?= To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] drm/ttm: once more fix ttm_bo_bulk_move_lru_tail v2 Date: Thu, 13 Sep 2018 13:22:08 +0200 Message-Id: <20180913112208.1353-2-christian.koenig@amd.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180913112208.1353-1-christian.koenig@amd.com> References: <20180913112208.1353-1-christian.koenig@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While cutting the lists we sometimes accidentally added a list_head from the stack to the LRUs, effectively corrupting the list. Remove the list cutting and use explicit list manipulation instead. v2: separate out new list_bulk_move_tail helper Signed-off-by: Christian König --- drivers/gpu/drm/ttm/ttm_bo.c | 46 +++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 138c98902033..26b889f86670 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -247,47 +247,38 @@ void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo, } EXPORT_SYMBOL(ttm_bo_move_to_lru_tail); -static void ttm_bo_bulk_move_helper(struct ttm_lru_bulk_move_pos *pos, - struct list_head *lru, bool is_swap) -{ - struct list_head *list; - LIST_HEAD(entries); - LIST_HEAD(before); - - reservation_object_assert_held(pos->last->resv); - list = is_swap ? &pos->last->swap : &pos->last->lru; - list_cut_position(&entries, lru, list); - - reservation_object_assert_held(pos->first->resv); - list = is_swap ? pos->first->swap.prev : pos->first->lru.prev; - list_cut_position(&before, &entries, list); - - list_splice(&before, lru); - list_splice_tail(&entries, lru); -} - void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk) { unsigned i; for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { + struct ttm_lru_bulk_move_pos *pos = &bulk->tt[i]; struct ttm_mem_type_manager *man; - if (!bulk->tt[i].first) + if (!pos->first) continue; - man = &bulk->tt[i].first->bdev->man[TTM_PL_TT]; - ttm_bo_bulk_move_helper(&bulk->tt[i], &man->lru[i], false); + reservation_object_assert_held(pos->first->resv); + reservation_object_assert_held(pos->last->resv); + + man = &pos->first->bdev->man[TTM_PL_TT]; + list_bulk_move_tail(&man->lru[i], &pos->first->lru, + &pos->last->lru); } for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { + struct ttm_lru_bulk_move_pos *pos = &bulk->vram[i]; struct ttm_mem_type_manager *man; - if (!bulk->vram[i].first) + if (!pos->first) continue; - man = &bulk->vram[i].first->bdev->man[TTM_PL_VRAM]; - ttm_bo_bulk_move_helper(&bulk->vram[i], &man->lru[i], false); + reservation_object_assert_held(pos->first->resv); + reservation_object_assert_held(pos->last->resv); + + man = &pos->first->bdev->man[TTM_PL_VRAM]; + list_bulk_move_tail(&man->lru[i], &pos->first->lru, + &pos->last->lru); } for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { @@ -297,8 +288,11 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk) if (!pos->first) continue; + reservation_object_assert_held(pos->first->resv); + reservation_object_assert_held(pos->last->resv); + lru = &pos->first->bdev->glob->swap_lru[i]; - ttm_bo_bulk_move_helper(&bulk->swap[i], lru, true); + list_bulk_move_tail(lru, &pos->first->swap, &pos->last->swap); } } EXPORT_SYMBOL(ttm_bo_bulk_move_lru_tail); -- 2.14.1