From patchwork Fri Apr 3 11:47:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11472579 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B828817EA for ; Fri, 3 Apr 2020 11:47:52 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9FAFD2078C for ; Fri, 3 Apr 2020 11:47:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9FAFD2078C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 323356EB78; Fri, 3 Apr 2020 11:47:52 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id BD2F06E105; Fri, 3 Apr 2020 11:47:50 +0000 (UTC) IronPort-SDR: 1clLGZGBD7kYqUHcBfcw394Nga4eG6lgKOA9m2gAscxbDgCIo6eeb4VG2Vv7fVcpz5h0WHraRI 1YggrkCHLwnA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2020 04:47:50 -0700 IronPort-SDR: 50cFYT3nV1VDcEeu8b4OBwddCZiouI/GJsF0vLPeDoU+oFVG+x9I8VK6L6rJWGXN4hVGLFs9w/ dCwO8ngkPj7w== X-IronPort-AV: E=Sophos;i="5.72,339,1580803200"; d="scan'208";a="273921952" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2020 04:47:48 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 3 Apr 2020 13:47:27 +0200 Message-Id: <20200403114727.27760-1-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2] lib: Fix device lists not cleaned up sufficiently before rescan X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Some effort is already taken to clean up previous content of device lists before forced device rescan is performed but it is not sufficient. An attempt to use forced device rescan in a test results in that test crashing or spinning until being killed by OOM killer. Fix it. v2: Remove device from the list before device attributes are destroyed Signed-off-by: Janusz Krzysztofik Reviewed-by: Zbigniew KempczyƄski --- lib/igt_device_scan.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/igt_device_scan.c b/lib/igt_device_scan.c index cf7c4d951..30a9704a5 100644 --- a/lib/igt_device_scan.c +++ b/lib/igt_device_scan.c @@ -353,14 +353,11 @@ static void set_vendor_device(struct igt_device *dev) dev->device = strndup(pci_id + 5, 4); } -/* Allocate arrays for keeping scanned devices */ +/* Initialize lists for keeping scanned devices */ static bool prepare_scan(void) { - if (igt_devs.all.prev == NULL || igt_devs.all.next == NULL) - IGT_INIT_LIST_HEAD(&igt_devs.all); - - if (igt_devs.filtered.prev == NULL || igt_devs.filtered.next == NULL) - IGT_INIT_LIST_HEAD(&igt_devs.filtered); + IGT_INIT_LIST_HEAD(&igt_devs.all); + IGT_INIT_LIST_HEAD(&igt_devs.filtered); return true; } @@ -595,7 +592,14 @@ void igt_devices_scan(bool force) { if (force && igt_devs.devs_scanned) { struct igt_device *dev, *tmp; + + igt_list_for_each_entry_safe(dev, tmp, &igt_devs.filtered, + link) { + igt_list_del(&dev->link); + free(dev); + } igt_list_for_each_entry_safe(dev, tmp, &igt_devs.all, link) { + igt_list_del(&dev->link); igt_device_free(dev); free(dev); }