From patchwork Tue Jan 10 14:40:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9507731 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 873CD601E9 for ; Tue, 10 Jan 2017 14:40:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77F192857D for ; Tue, 10 Jan 2017 14:40:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B0102857F; Tue, 10 Jan 2017 14:40:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EEBC12857D for ; Tue, 10 Jan 2017 14:40:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8ED336E311; Tue, 10 Jan 2017 14:40:38 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id DF4256E311 for ; Tue, 10 Jan 2017 14:40:35 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id l2so30285150wml.2 for ; Tue, 10 Jan 2017 06:40:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=WJDMgUS7mD5ewJ5mrKPi9aNm+GVP4eDsuFOg1l/NIHQ=; b=DmeZecdNznqlAQNyYtjYkXDYyW0Lk+XZ4eLoqo3pk0sDWKrPPissWxtCnF3uYEKcoc pAufvqtCbClzkb8ZAsFtpzlUBW8sWGppphlGnLZJ3/lfU366njnhGB92ljco3XL9tqWG MV3crtV/+PiU7H0wM/4NkHb81zHVsWaMg+xcxP7G+KgnPGHm0R/LuDrbDdPk+bHzLDNf pd4sHM14EGqBvAzQ/p+mrkFcnEzhrZcJ1GnRDTTXWgiEF6uLomgnNw+xAr6mRSVTFypt OU4f+8yMv2TMAAwJPJGuCR3AXXnryWnLF2g/NbyL7nuQH4wSLZtMgfes45qSJU4Jwimc TnDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=WJDMgUS7mD5ewJ5mrKPi9aNm+GVP4eDsuFOg1l/NIHQ=; b=COSoRQXaOcXDvZtfQvWhrd2xna4ydmkK3/g3zAwGy79ithsPMm580p9jFUR02o/gtH Y0Jp8RhYWIEtMOd7S0JMtT+jSmuh4fCV88knC/Gd3K3W7eFkVS+c3YTwocbxY/zNjdmT ehfoSmyV6dPJs9B6bJ75Wzaj0kt8xVK8BNrb6/0QJOlFZXANyDGv0PRDjZ3ov2njXarW Agi9RgLJB6K55MlrAwfOr6gdu3L4No1HfufAuIFJAVUuDVf4CkD5AiiXN2lUH9qgRZW1 AbvEBpXEESitfn+Yx2kzrPlZHEcoVB2w0q6KQ0p8MdymhvtowW0bgCALrpX1csMsV3Fr nJdw== X-Gm-Message-State: AIkVDXLotqNbxOhb5IuT1aR7km7ZtCWHxt/42W3okDdFT/sDcUdmYuHyy7Yus3oa8qNJTg== X-Received: by 10.223.171.149 with SMTP id s21mr2193987wrc.64.1484059233925; Tue, 10 Jan 2017 06:40:33 -0800 (PST) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id g6sm3622222wjp.28.2017.01.10.06.40.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Jan 2017 06:40:33 -0800 (PST) From: Chris Wilson To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm: Fix error handling in drm_mm eviction kselftest Date: Tue, 10 Jan 2017 14:40:31 +0000 Message-Id: <20170110144031.7609-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.11.0 Cc: Daniel Vetter , Joonas Lahtinen X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP drivers/gpu/drm/selftests/test-drm_mm.c:1277 evict_everything() warn: calling list_del() inside list_for_each The list_del() inside the error handling in the eviction loop is overkill. We have to undo the eviction scan to return the drm_mm back to a recoverable state, so have to iterate over the full list, but we only want to report the error once and once we have an error we can return early. Reported-by: Dan Carpenter Fixes: 560b32842912 ("drm: kselftest for drm_mm and eviction") Signed-off-by: Chris Wilson Cc: Joonas Lahtinen Cc: Daniel Vetter Reviewed-by: Joonas Lahtinen --- drivers/gpu/drm/selftests/test-drm_mm.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/selftests/test-drm_mm.c b/drivers/gpu/drm/selftests/test-drm_mm.c index ab091042f317..1e71bc182ca9 100644 --- a/drivers/gpu/drm/selftests/test-drm_mm.c +++ b/drivers/gpu/drm/selftests/test-drm_mm.c @@ -1272,13 +1272,19 @@ static bool evict_everything(struct drm_mm *mm, if (drm_mm_scan_add_block(&scan, &e->node)) break; } + + err = 0; list_for_each_entry(e, &evict_list, link) { if (!drm_mm_scan_remove_block(&scan, &e->node)) { - pr_err("Node %lld not marked for eviction!\n", - e->node.start); - list_del(&e->link); + if (!err) { + pr_err("Node %lld not marked for eviction!\n", + e->node.start); + err = -EINVAL; + } } } + if (err) + return false; list_for_each_entry(e, &evict_list, link) drm_mm_remove_node(&e->node);