From patchwork Thu Dec 26 07:01:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arunpravin Paneer Selvam X-Patchwork-Id: 13921122 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id CE4C7E77188 for ; Thu, 26 Dec 2024 07:02:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5A0CD10E771; Thu, 26 Dec 2024 07:02:02 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="IURBx7Lt"; dkim-atps=neutral Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2068.outbound.protection.outlook.com [40.107.243.68]) by gabe.freedesktop.org (Postfix) with ESMTPS id 26C9010E771; Thu, 26 Dec 2024 07:02:01 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IGG8Z3cMaLRpgJ5uC+vMfmz6vSTjo9yzv+gzy5PzfaPSGtLoh/DFS+PRkyQ6+inIrU1N5P+nAzzuZrR9fiGZBrBKksQ2XxxePqt4AedVD298K8qw71LWGNzitzc/tKJbEMPM2B8q4gWc+UAGe2IfV4KORMdCpyl+LTsYvWCNMz1QZfxwMHnFaNb94gJaePEXfTZaaNSzG9y0ouq4FCt2ki/UhVVGUOZGBKGe8R+LGFhjubC/l834TMAhjKcsesT9Yefvr/L6PW5dGT2jsPFnOx8qFhikRXkAkIaRbpk/iP4GLbXHPrhMFGc8gK7EBV6bHXyjoHhJ1SSKPTX5eudkZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=aWth6srRmDegIkzsqY1k48tkqENt/uY5OTE0Gdjqxgw=; b=Kgriu1BGqidnStg1hQqZ1ATB5+uRyWC2mKMzK+2h8A4tcZ1dH32oThj3FJtjmcOT7WywhCNhnx4UIAPyBTMC7jF4pwnNZ7h3OKOkAnrpmPgFMIlX8F1AiPr+R8fngXoE2KJw8+18VNZEoRaMvbjcc3fGaoT0CIDBQzVAdmd7BTS+OgE/OsXsLyOZntZviqjBRL36/14SnGJymVzQPG6qt2vVWs5O5lKAUJ0oesoQXQKnPHP/dKbi3razl7NPhNgixaIhGfiViS2SKPI50MdmHS9uJKvQ5Cv89V995VeZDNFUYARVpaBeAHFrlN/Z0P9rOD4XSRXx1C+7Z+Sy+FRtAw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aWth6srRmDegIkzsqY1k48tkqENt/uY5OTE0Gdjqxgw=; b=IURBx7LtAkEfzokQafAaHL94H1HSgiEY3wqkukZphrAH8QkwZBkudeMRzHsm1PRVLEDNjidvMNazd1p1gU19D7VUHHT41KGlCC373CrHhyw+efVTqWpKiEUr/eLdgn0h58R65F/4nOhWJH9vrCWHYALyaEA0zJ1z0+Ex7ULNDqU= Received: from SN7PR04CA0040.namprd04.prod.outlook.com (2603:10b6:806:120::15) by IA1PR12MB7493.namprd12.prod.outlook.com (2603:10b6:208:41b::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8293.14; Thu, 26 Dec 2024 07:01:38 +0000 Received: from SN1PEPF00036F3D.namprd05.prod.outlook.com (2603:10b6:806:120:cafe::c5) by SN7PR04CA0040.outlook.office365.com (2603:10b6:806:120::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8293.14 via Frontend Transport; Thu, 26 Dec 2024 07:01:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF00036F3D.mail.protection.outlook.com (10.167.248.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8293.12 via Frontend Transport; Thu, 26 Dec 2024 07:01:38 +0000 Received: from amd-X570-AORUS-ELITE.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 26 Dec 2024 01:01:35 -0600 From: Arunpravin Paneer Selvam To: , , CC: , , "Arunpravin Paneer Selvam" , "Lin . Cao" Subject: [PATCH v2 1/2] drm/buddy: fix issue that force_merge cannot free all roots Date: Thu, 26 Dec 2024 12:31:15 +0530 Message-ID: <20241226070116.309290-1-Arunpravin.PaneerSelvam@amd.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00036F3D:EE_|IA1PR12MB7493:EE_ X-MS-Office365-Filtering-Correlation-Id: 5da3bf37-4193-4587-0034-08dd257b24c6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|82310400026|36860700013|376014; X-Microsoft-Antispam-Message-Info: VcOyDNaseH84L46RTa+dQuxAnGMTi/Do3nNjgDiOn7/0MdeWjvQbpLewqzOGMIJBsbiQ0u2PGgp6SZTbtDRlzTE8faRYUuQkN4MYdWmClmKRI52f5FP71+jvvTN84t5PFIiqKt7SwontNXHSokETwGk72MiCpwGVs07MffeDWZMPLGdqsjgHWe0Qr1E1+r70WA+2l/WHxOz2fxd8WoVbGAtP3M+yVbe7ePxJqoIB/QH5qvnA6uuWjhSBN9X7aEPEgcFCodqeNixAlNKJxV16Kuwx9v6la9CjOa8a0BZWNOg97/DLqMUQpU0oeqsomdGaQGQNxJayMcV8zi0LSfa7wXIxCGf74vLBaAzbape2YnG1AUSL2G/9gpEIsRAPrNaP7p17A6Xtp9ah6NfCSfydKm4pa/NesN+agqvq2WQO8QyR65NiiWOcOnNlWBK1Zfxs2gstUbDsbh8Ooulcbr+mhpBgSaMr4kFwbBfcPdz221FCXec3Ot2GC/zi6IFMx/Hlirg0/r5bqgBYSXXvMJelZ6naK7AYDwoie0n20H6c3CMVKAD0vk70/Me5rszI9KDil5aF37hzhCKmkwEDyfZWEE2HE+2isrWIfCeqopxeDcrDhYEwAK///jdhYUGk4fLYXHbCYio2PMlyHPzVD4lFpSn4lUoucmvx9itX+QUCLJbyJY5YZrdxZKOXyoVKr9CcRnSeABQ00Hd6FdtLvjDbvonvImfcHGWJkv1pnbP/PMCMeeDPgoGw91gUpPicaJEdtc7+U6zodvueJ3aGIZo+0xPabTv8ukdrnIgOkQzPre06Bnxh75myT0iQBZBRafB8Ahu+oXe3vQ1+bxmEdnEdrAazpraOUlP9pP8GUQjDeA9Iuw1oYyXkDN4R9jmDyJfH4RYL4lJCPpfrh381ST2c96y+kZNdr4GkC+w+xrENm+DXmdlTSYVx6J1+NSVxRY6oKJ7bYWoiRWhVTjuuyqMagLajkR0HqksZGILkwGfqUH/ayoyajNP6M3455SoNq52IqLzZHUtMImuhE8OBvPUkwestRkKlaPkJeKDe7QXelgzAndXzKed6kFInd9WwsnOK1Vnhur7tzoLilSmCJbuluDt0kARkQN/eyaHFp+b5kOgpIz3Ihe8wB6L07SGXUl+0ua4G4ihjTbBgfKn/16h6t3RsHlLBbk1Lvdyqv1OpoF5Uj5Pa9EnYhcVxu2Qoe8a1Q3yu5aCAhJryUyL2yBPXm63eDNhf6pb6v3Ztb07yGX+obdxMvB5ba5S1rC/y8WR/B7jRZK3HsEkUHsmooaGQLyhSKN6oXLnp1kyhIKctHdk8wO5agkBQ1lQNAngojCsSz/d9ASXF7UG8m3DqXb0ML9pJ7+VbBJdZTtKsVK39EcfNPTj8y1FBgy1oXYCAUUq2FrXOvBIeekh4C/EpHtc0vUiyrbjeReVLic0Y443HnLFhEvqUUJjGhBoJmER6MPiMZ8qHsQeYsE3DU/v+Nbnrz0W99Mr6d/AgvU5LTCBJ0LQ= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(82310400026)(36860700013)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Dec 2024 07:01:38.3702 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5da3bf37-4193-4587-0034-08dd257b24c6 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF00036F3D.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7493 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Lin.Cao If buddy manager have more than one roots and each root have sub-block need to be free. When drm_buddy_fini called, the first loop of force_merge will merge and free all of the sub block of first root, which offset is 0x0 and size is biggest(more than have of the mm size). In subsequent force_merge rounds, if we use 0 as start and use remaining mm size as end, the block of other roots will be skipped in __force_merge function. It will cause the other roots can not be freed. Solution: use roots' offset as the start could fix this issue. Signed-off-by: Lin.Cao Reviewed-by: Matthew Auld --- drivers/gpu/drm/drm_buddy.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_buddy.c b/drivers/gpu/drm/drm_buddy.c index 103c185bb1c8..ca42e6081d27 100644 --- a/drivers/gpu/drm/drm_buddy.c +++ b/drivers/gpu/drm/drm_buddy.c @@ -324,7 +324,7 @@ EXPORT_SYMBOL(drm_buddy_init); */ void drm_buddy_fini(struct drm_buddy *mm) { - u64 root_size, size; + u64 root_size, size, start; unsigned int order; int i; @@ -332,7 +332,8 @@ void drm_buddy_fini(struct drm_buddy *mm) for (i = 0; i < mm->n_roots; ++i) { order = ilog2(size) - ilog2(mm->chunk_size); - __force_merge(mm, 0, size, order); + start = drm_buddy_block_offset(mm->roots[i]); + __force_merge(mm, start, start + size, order); WARN_ON(!drm_buddy_block_is_free(mm->roots[i])); drm_block_free(mm, mm->roots[i]); From patchwork Thu Dec 26 07:01:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arunpravin Paneer Selvam X-Patchwork-Id: 13921121 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 511C0E77188 for ; Thu, 26 Dec 2024 07:01:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7968E10E770; Thu, 26 Dec 2024 07:01:49 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="fsAX4Ins"; dkim-atps=neutral Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on20626.outbound.protection.outlook.com [IPv6:2a01:111:f403:2009::626]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6F4A910E76F; Thu, 26 Dec 2024 07:01:48 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dAJg3r0tGI7Rkm4d+bN8oh6/00CBOG8RCOBzPgp4MPnEOa7jMXjM9IewAgZ76a08rIeLtiQQHXbeDrEnBEyDsTiL40bIAhOJcchFtZimEmdXCLm5/B4fZsFq0OOvt+fWUDtpPjh58YUV6S7wHdX1r5MdZqsAaYPRncDhIa4xtl8nRkCbkHIXSwsC2R9JI/QXbvI5bTuhjK5uOUAhG0xEp19getdnbSu7C37P7qJvbpjjhH8YzAn/ya3gB7YgrscbT0gjh/QivklGR1dSDOocyaeZud/XEhDZ21Lw0FYZJsJlcZfdvVNCnceveR3iViDyMlF8R9hHwvTxflFJxKEVPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xOX2tPGGtpPP16seFY3EzxZgGDea7JdFrZGAg8l7Ldo=; b=bm6p4+dCkPcMNHMS60IE1CCH8M9ZolbxNNw+IjLCq2RQ0hFOzGjflBChRkl0KDUrmFgiivhJTDpqEGmot6PFg4AFZj3EWTsQUYDrvM3UpLwqleimvIs58U0T/N2mkpx+gwwAYLDbvvfs76XGAnrxpe6yYpmJbiN12aIzcvRqH1EGDFUFI+QKQC17ap55gTXXEBqPHoip9IKYLsJ71cW/bBz2BcmEPMaDkb5vyzlwnnzcAjTPJZwor53RIaVvA61XmLxmaM1zCgIyEsTcluvbaxbajVeAlppzwd5TEcw+GaMIaDmHgGRCie4Q4iRoCc426D5UyMV1NOtzYbbDQJTn2w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xOX2tPGGtpPP16seFY3EzxZgGDea7JdFrZGAg8l7Ldo=; b=fsAX4Insdi1g/5bVAGfzo2gD8DjD48g6GUnUzNwhqA9IFDmb82fkQZfw1Kie7JBbuoWYBGiIVKM9BDXLjVj8lSS7XyWWjyhD6MOKYGii4IdawftFLV+3+l2B6cPWDxa9cxDLG4yHyAzlLT863Wu+OmfRI/f+0RyE1Ey5GS92x3Q= Received: from SA0PR11CA0097.namprd11.prod.outlook.com (2603:10b6:806:d1::12) by DM4PR12MB6255.namprd12.prod.outlook.com (2603:10b6:8:a4::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8293.14; Thu, 26 Dec 2024 07:01:41 +0000 Received: from SN1PEPF00036F3E.namprd05.prod.outlook.com (2603:10b6:806:d1:cafe::27) by SA0PR11CA0097.outlook.office365.com (2603:10b6:806:d1::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8293.15 via Frontend Transport; Thu, 26 Dec 2024 07:01:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF00036F3E.mail.protection.outlook.com (10.167.248.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8293.12 via Frontend Transport; Thu, 26 Dec 2024 07:01:40 +0000 Received: from amd-X570-AORUS-ELITE.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 26 Dec 2024 01:01:38 -0600 From: Arunpravin Paneer Selvam To: , , CC: , , "Arunpravin Paneer Selvam" , "Lin . Cao" Subject: [PATCH v2 2/2] drm/buddy: Add a testcase to verify the multiroot fini Date: Thu, 26 Dec 2024 12:31:16 +0530 Message-ID: <20241226070116.309290-2-Arunpravin.PaneerSelvam@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241226070116.309290-1-Arunpravin.PaneerSelvam@amd.com> References: <20241226070116.309290-1-Arunpravin.PaneerSelvam@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00036F3E:EE_|DM4PR12MB6255:EE_ X-MS-Office365-Filtering-Correlation-Id: f1d172c4-77ed-4956-a790-08dd257b2636 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?rHlYVOII2Dl8YqpCbd9qu4OAb1d9VIv?= =?utf-8?q?SuGbXRo5QttwCQ1MNCds9bgBO0eSg5F1IWU6+EiTd6hmnNqH+PbAg8OLxeLQtFM7/?= =?utf-8?q?Wu8dl97cs1ooAQ5QZB/9/5cj3xQ/a9uiBl3X3sEI6TmKC+lkaA4YkVuMEtpPNh/CK?= =?utf-8?q?xOoB8TYOEc2KLBCArdDlpqBrGEp8nwDBi7pXvXrdlZO/q03NrJLc8P+6sOkSn+Xig?= =?utf-8?q?amZrf8r1NLZw2kIKQxNcTdMnfDBhxmsg17iysWnzkv+/yb7ToZeKgQ4DkVUauX8SF?= =?utf-8?q?aWdgshSDM1Mi0yRIbvajHpRgHBrK/IQr+/evkGOft1vCyQ3/CIOf4bthVSV/EKI7q?= =?utf-8?q?xLAlVIUGU0tQdVj2m2goVgE3/+pjALqfNsg1KP/M9DuP4zd2oyL3LGTX6IW79/86q?= =?utf-8?q?+MdceQ272qvRS89y2JMHtOG44fVxhiwXX/ZoIgqBuMrNfyARJU5vGxsYgwJgvlHFW?= =?utf-8?q?BhgDwQ2ztUDo+X/z7bDX4ghtzK0SjW30zXTLQ5ezhfeKFVv7RsfLz4ET592lihR+B?= =?utf-8?q?l4zxnvUoYXSDUweRSfphaq3b5oILSV7r1zRTgcAkJTIoS+107UcstYsOV9Gz4IsM0?= =?utf-8?q?i0r8g4MfiLCiwyu7ZLFHr5m+VRivuowB1jQHmvqVRchBuMicG2er0yMmq5GKcBK2V?= =?utf-8?q?fyJTEeNZilburn+nypuhbyZwxvHz9lgOAUoJSThm1BMT+T2tH0jEsN2IuK43T8RPO?= =?utf-8?q?EsuHOml2UiYhPTRRynKCKkCS2T7x/SnlMr2gPXCgG/p7RtNVm/Nu5XrayG5YN9mAS?= =?utf-8?q?jPjbUUs8rCnZqOQidjMtbaE6r+fm9AA5am/XTNpueq8YVsHD2I18Q+FoHmaA5KHOD?= =?utf-8?q?+UuRgjSgU2uuRMGwuj9uAHP4YygpwiH8ZRrhbkVxdN8UkO+7mHVGbfMOA9HDAMZM5?= =?utf-8?q?MzRmxW9A2gUAEg8PGdQdNlW8pjOoHh5HxZ4yWLgiksdyx7L28Kx53T/lEItjE3nT5?= =?utf-8?q?DBA5Q31polQ4DvS+lnpxFNia34flvZ38iJILUAY/NSc9p+q4ZtGvRlGSGQKPwVBjO?= =?utf-8?q?8STErkjcPr2WFg33jIdSdNyvPRcMAnp+0Y7OQXW8yRD0XCb5axM1iwvPAzzAfRHEk?= =?utf-8?q?Hcr8QfPlZLj1FV3Cj0H6POw/uuywf129epPjjNYJBqVjT0OGqyYLEQcR7v1FgOjjs?= =?utf-8?q?1cuvEaFX4x2gLWji4Pda57vGhB4k2ngpZfSF3f0ZMcYLB6LdIO1E6G8OIAPSMMWzD?= =?utf-8?q?kIrvNXAlz6I1+a6asSrpZYHXSZF1IYZLTZfnIFH7hFT/qY6wWVBWYNMZYZKCFFY5h?= =?utf-8?q?ETPvNZuuvbfPMNtTM7KZgsS05PCaDa4CkA31ZXY31oUvPI9Uh2w6QpSIoFM558xbI?= =?utf-8?q?Z7lOnaG5TUnoDN4yiVRNavQ6jPDyQ2fJCURX1rFrNERgbdh+OM/wWfhthPJRmRLNd?= =?utf-8?q?eCzIr+Jvc2sLXc7g/1x+zDytpU0uO4CX7eKv9vLuLM4W2Nu6/QEJwk=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(36860700013)(1800799024)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Dec 2024 07:01:40.7862 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f1d172c4-77ed-4956-a790-08dd257b2636 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF00036F3E.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6255 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" - Added a testcase to verify the multiroot force merge fini. - Added a new field in_use to track the mm freed status. v2:(Matthew) - Add kunit_fail_current_test() when WARN_ON is true. Signed-off-by: Arunpravin Paneer Selvam Signed-off-by: Lin.Cao --- drivers/gpu/drm/drm_buddy.c | 6 +++++- drivers/gpu/drm/tests/drm_buddy_test.c | 29 ++++++++++++++++++-------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/drm_buddy.c b/drivers/gpu/drm/drm_buddy.c index ca42e6081d27..241c855f891f 100644 --- a/drivers/gpu/drm/drm_buddy.c +++ b/drivers/gpu/drm/drm_buddy.c @@ -3,6 +3,8 @@ * Copyright © 2021 Intel Corporation */ +#include + #include #include #include @@ -335,7 +337,9 @@ void drm_buddy_fini(struct drm_buddy *mm) start = drm_buddy_block_offset(mm->roots[i]); __force_merge(mm, start, start + size, order); - WARN_ON(!drm_buddy_block_is_free(mm->roots[i])); + if (WARN_ON(!drm_buddy_block_is_free(mm->roots[i]))) + kunit_fail_current_test("buddy_fini() root"); + drm_block_free(mm, mm->roots[i]); root_size = mm->chunk_size << order; diff --git a/drivers/gpu/drm/tests/drm_buddy_test.c b/drivers/gpu/drm/tests/drm_buddy_test.c index 9662c949d0e3..4b5818f9f2a9 100644 --- a/drivers/gpu/drm/tests/drm_buddy_test.c +++ b/drivers/gpu/drm/tests/drm_buddy_test.c @@ -385,17 +385,28 @@ static void drm_test_buddy_alloc_clear(struct kunit *test) drm_buddy_fini(&mm); /* - * Create a new mm with a non power-of-two size. Allocate a random size, free as - * cleared and then call fini. This will ensure the multi-root force merge during - * fini. + * Create a new mm with a non power-of-two size. Allocate a random size from each + * root, free as cleared and then call fini. This will ensure the multi-root + * force merge during fini. */ - mm_size = 12 * SZ_4K; - size = max(round_up(prandom_u32_state(&prng) % mm_size, ps), ps); + mm_size = (SZ_4K << max_order) + (SZ_4K << (max_order - 2)); + KUNIT_EXPECT_FALSE(test, drm_buddy_init(&mm, mm_size, ps)); - KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_alloc_blocks(&mm, 0, mm_size, - size, ps, &allocated, - DRM_BUDDY_TOPDOWN_ALLOCATION), - "buddy_alloc hit an error size=%u\n", size); + KUNIT_EXPECT_EQ(test, mm.max_order, max_order); + KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_alloc_blocks(&mm, 0, SZ_4K << max_order, + 4 * ps, ps, &allocated, + DRM_BUDDY_RANGE_ALLOCATION), + "buddy_alloc hit an error size=%lu\n", 4 * ps); + drm_buddy_free_list(&mm, &allocated, DRM_BUDDY_CLEARED); + KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_alloc_blocks(&mm, 0, SZ_4K << max_order, + 2 * ps, ps, &allocated, + DRM_BUDDY_CLEAR_ALLOCATION), + "buddy_alloc hit an error size=%lu\n", 2 * ps); + drm_buddy_free_list(&mm, &allocated, DRM_BUDDY_CLEARED); + KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_alloc_blocks(&mm, SZ_4K << max_order, mm_size, + ps, ps, &allocated, + DRM_BUDDY_RANGE_ALLOCATION), + "buddy_alloc hit an error size=%lu\n", ps); drm_buddy_free_list(&mm, &allocated, DRM_BUDDY_CLEARED); drm_buddy_fini(&mm); }