From patchwork Tue May 14 14:56:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paneer Selvam, Arunpravin" X-Patchwork-Id: 13664221 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 67069C25B78 for ; Tue, 14 May 2024 14:57:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8245310EA9A; Tue, 14 May 2024 14:57:08 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="wqRPXv1T"; dkim-atps=neutral Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2088.outbound.protection.outlook.com [40.107.236.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id CD06610E1FE; Tue, 14 May 2024 14:57:06 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h7munSpfiQ+BlYTf6aJPRZFgOAycbOI34IaNhSL28nX7f308IpTgB0O2+gvzaB03IphJgr8rGBDA8IqDHgzZawdyTr5CGU7QMVcXospJXzWIJtUeb8LG7QhWr/c+x9mVFacE84Vz5cNdGm6jcfk9UlPyKZA/IkTNjrjaMjcVF2f43AeD/RjelcxVSYntl25+n8N+pauPjifgLvyRfzOxyQK6NZK17GmBiGSLcts1YvKl8O4W1woUTKt5yzU0+r857n+2aA08mTuejvJgZGvor8PB87lTTpLu1PL6A6ueJSo95OHua0YReilBBtqDNSenngp+IQTgbiMTndnrjUEhPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=p/E20Z9gdCX1NEAyYnfWKNJ4Y16ui2hB1v2a6g0lSRc=; b=WcSD7TqF/NEZ4t5r0ct85p5/RgLj06uIilrrPGKhv0AY9f3YU/xsah/aioGBcSO+wR6EPgUR1Eoe8vWTVIc6hzX2J3hzY97kx95pDtSfdvjXQzTlLuQ5oZkV3NvwF2FNHBIAJTth7Aqyj8MY4MoBrcR7Mr0PMI/ii37vSJ05nT2T8tPWa2nakVq2KzG5CqwrtKZr23OPYW7jw9CoTkxJOfl57hI5OWZdv60XBbcHt7ijjLgd6rn/OxxxH72peJseXOld6cE2OfY0a1dw+73KTwkIy18gfvyMM2iFZGFeGUABAj07VI7AuSCT8M9t+dfzyiowoGSVOno1TI8iwiXAmA== 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=p/E20Z9gdCX1NEAyYnfWKNJ4Y16ui2hB1v2a6g0lSRc=; b=wqRPXv1TIq6RhDxBJLv2vDYQlIExjonmiyYeJy1AVAg1KWLWwWlPhIxcsjqvIdhF33yuCQD2Vk+JPVUHyPvRf0qF6bTdGwwK15wzQaA1Lk2Nwp0tOJJuusqWp5hd5AAh7R4G3OLeefkg/jtN0EaYgQ909skM5TvHEoa9wUVauUg= Received: from BN9PR03CA0756.namprd03.prod.outlook.com (2603:10b6:408:13a::11) by PH0PR12MB7472.namprd12.prod.outlook.com (2603:10b6:510:1e9::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.26; Tue, 14 May 2024 14:57:00 +0000 Received: from BN2PEPF0000449D.namprd02.prod.outlook.com (2603:10b6:408:13a:cafe::5f) by BN9PR03CA0756.outlook.office365.com (2603:10b6:408:13a::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55 via Frontend Transport; Tue, 14 May 2024 14:56:58 +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 BN2PEPF0000449D.mail.protection.outlook.com (10.167.243.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7587.21 via Frontend Transport; Tue, 14 May 2024 14:56:58 +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.35; Tue, 14 May 2024 09:56:55 -0500 From: Arunpravin Paneer Selvam To: , , CC: , , , Arunpravin Paneer Selvam Subject: [PATCH v3 1/2] drm/buddy: Fix the range bias clear memory allocation issue Date: Tue, 14 May 2024 20:26:35 +0530 Message-ID: <20240514145636.16253-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: BN2PEPF0000449D:EE_|PH0PR12MB7472:EE_ X-MS-Office365-Filtering-Correlation-Id: 9f910886-b6d2-403f-e809-08dc74261a99 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|36860700004|376005|1800799015|82310400017; X-Microsoft-Antispam-Message-Info: jIaTX8Jh/p+4QSyMZSnMhu+BelEulj1tRz7/NlLus4MVXoMyF42YMA52VMcV4YSBLXVI47v2EiWzYuAyeFF9M6QPWBogqoKFKPa2ctw8f8p/W9oU+16p93I+CyDYHesbohiyvs/0zerzPbunVo1iW7ZyIkArrDZx2IDN8LMaquRGfU07VzzPqAROcWQcrlSe9SIJ4FwkECc6b8DRGq+rn/UBPjsQ+tVe/ErQKL2jCkbp2by40K8iCdRYWxYTe8pPFOPMhsZgk+8rvz9MjLqWdtWhUyui4gWdCY8zJtADodpai1Ulz1Ox4Kkmz2n5TVVfmIxdYZODdGRGsWgcailwtsydN5rMXjRcnhUrt0y9qPyNM/luLMOAn6pUL5T6cpz5pHypR5awvvCNT/etXau67sQdjfdrcQnRmGMAXD2Uz9iArzi6y8SU+VZ9++oCRi4j4bJK0ex3t6Tcn43xejEkrBPr/rvjsSJdRFbSbJs1G5kHXY+L/LCuKxvj2QlhvC3FUF0OoQZbgqOGD05RNyORlIfPlot7MXKjon6zsi01xbwOxWd/45Hes5jwq5Z0sDG0G/9kcn3P9ydAQdwcQCIMEESr750wvQTwxpqXcyxppguaWvMj2HPqYMkZv9Wsitq2PM4ab4yWuUjoXCyeqXH3tAgOXKNNwyI/c8gcrtMkRZPOZB/6Kdr4RGcDjUqsoHoqQhlEJvzi4MOKEW+HDlnVpl36eNFiG8MnQILA5JFijePi59+F+Eik9FICaFzBRhh3Ew6ddINHliEJnYD+oY6zBcmXw0mWsyY1ekU2T7Ds4t+6Owa1ld870NIejd5+HTgZx+xqkRxexf+dx2VOenVeM1oGt3nUHW/FpzqeRcC2YvdcZejruRTKYeoeDGvuhdiI/ttaGbWNVHzogCaloR/12PvIKrnG1lJ2mgDhfapFg+SFhlLG79B4qf0dRGJmrsWuef5SEhCIP6hEIqCM2zoC4ls0y+rETsug6HLqiUcnpV0Tfv6gudWQvx3xFH5KgYhn0GAo08jTO0Hr7KP6v74hBA7DKI1xJ2Uinm/o1itGkf58+37gTCCXA+kz49Uh9bNAIauQsH7aK2z/F6Kp+726dNISdabT2TnZYdl3pz+2lUPkv9H3+7VtNA1Ov2gF4W/QIp99mQvXaRMpOZWN4N7BiKTtV2IXOusYURxhL+uKN1vVj+AWvVNK4ZYCUroDkFljTyhlj1mvURwNXCRFWHvsSeP4FaYs/BTLNm9mJOZCnBb1eR/UeGrKeuPXjtzAEuxczEP7ixRONFiTpObsUc8Z6ws5uPsH9Yvo/kkUIYE6yuACciSJ3uh8LUBUzgLOIkeUc7HNQ81cH4RzF73RCDmcs8pVuCuY1cloKaEY3fXBUCRH8exfO4cC2prB3+v3xlJK 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:(13230031)(36860700004)(376005)(1800799015)(82310400017); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 May 2024 14:56:58.3172 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9f910886-b6d2-403f-e809-08dc74261a99 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: BN2PEPF0000449D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7472 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" Problem statement: During the system boot time, an application request for the bulk volume of cleared range bias memory when the clear_avail is zero, we dont fallback into normal allocation method as we had an unnecessary clear_avail check which prevents the fallback method leads to fb allocation failure following system goes into unresponsive state. Solution: Remove the unnecessary clear_avail check in the range bias allocation function. v2: add a kunit for this corner case (Daniel Vetter) Signed-off-by: Arunpravin Paneer Selvam Fixes: 96950929eb23 ("drm/buddy: Implement tracking clear page feature") Reviewed-by: Matthew Auld --- drivers/gpu/drm/drm_buddy.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_buddy.c b/drivers/gpu/drm/drm_buddy.c index 284ebae71cc4..1daf778cf6fa 100644 --- a/drivers/gpu/drm/drm_buddy.c +++ b/drivers/gpu/drm/drm_buddy.c @@ -249,6 +249,7 @@ int drm_buddy_init(struct drm_buddy *mm, u64 size, u64 chunk_size) mm->size = size; mm->avail = size; + mm->clear_avail = 0; mm->chunk_size = chunk_size; mm->max_order = ilog2(size) - ilog2(chunk_size); @@ -574,7 +575,7 @@ __drm_buddy_alloc_range_bias(struct drm_buddy *mm, block = __alloc_range_bias(mm, start, end, order, flags, fallback); - if (IS_ERR(block) && mm->clear_avail) + if (IS_ERR(block)) return __alloc_range_bias(mm, start, end, order, flags, !fallback); From patchwork Tue May 14 14:56:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paneer Selvam, Arunpravin" X-Patchwork-Id: 13664220 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 9F929C04FFE for ; Tue, 14 May 2024 14:57:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C638710EA61; Tue, 14 May 2024 14:57:07 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="Vnp5jUub"; dkim-atps=neutral Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2044.outbound.protection.outlook.com [40.107.243.44]) by gabe.freedesktop.org (Postfix) with ESMTPS id 00BAC10E1FE; Tue, 14 May 2024 14:57:05 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Qf7JMQpOXm5+ZTbO+cqjHswnuAQIGFTpoU3SUwJBnB4KrTyuVqX0Af4bhstl/PVEatKbIpbrzwJD5A87rSSVDpNpWUnLyOZiY9U1iGeLBWcGgh9oVD/zK3U5zwPCu/ec5sRB9p1v7xBIwghouaE7PrqXijSGqzOj+YeNelt7981LvEs0fmeFpvs25xMcvX3+Eu8C5nRaB+8/QZYiyddzorzhpig817pUcX+xaRdLIRSrKvncgNSYQLaqsAdBNv1fgyE1Y31I/DD9lWKDYZhB+RQ+F1AwhiqOcesPudxACuOX7S6Hb73G4ul5wlLQ1yxhh6ePMZL19119Y+6v0hbnaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=56KunicnTsSdRTkBwd/LlBacAqcNmkrzsjJkRmqKLn8=; b=VMV+rm5oJCULp4B+2gtsejXtp29Zxr6cdHD+KLtCTDDFY7MDnvExzBrUYVJRrguWOc3xQSE+/dCDkZMtZxcUsEl/lVMFhyyoZWTxruncYYwStpFNoT8LXHaIuRINdo1/W7l7eybzgx9UJ/p3/Hr/UjNhVl3uPHr0VPMVNyDKYx8qE8WOWl0F4LAiPhVAmvfRnSTddzrY1pmIgFJmJAdxi24WunEnQ9X5QUlCX9Lwv1yM0O8ff6xsmPpqvb5ielIXgDqdcGeRBmCViUWqxcspp3cbP6EQSf/uU2AF10JbqOi50NzxNIgJ6c+sRbXpaFZHHZCk+qo5QsRO2Icli3uQ7Q== 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=56KunicnTsSdRTkBwd/LlBacAqcNmkrzsjJkRmqKLn8=; b=Vnp5jUub+MvGurEB7tphoNG1ctKDheW83kV69+dR+d9aZGpt/NhI/iYIQsWwgBMxOp3sWmfcSfoRSuJc1WdxvyiTdPieHX2pM6dcg/Lx/0obXRNdbotH3brSsrU77rfH9P0vekP2ApzEcO0DTqPnE+yb1RScvLC+88ivf43INlI= Received: from BN9PR03CA0766.namprd03.prod.outlook.com (2603:10b6:408:13a::21) by MW5PR12MB5652.namprd12.prod.outlook.com (2603:10b6:303:1a0::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55; Tue, 14 May 2024 14:57:01 +0000 Received: from BN2PEPF0000449D.namprd02.prod.outlook.com (2603:10b6:408:13a:cafe::95) by BN9PR03CA0766.outlook.office365.com (2603:10b6:408:13a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55 via Frontend Transport; Tue, 14 May 2024 14:57:01 +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 BN2PEPF0000449D.mail.protection.outlook.com (10.167.243.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7587.21 via Frontend Transport; Tue, 14 May 2024 14:57:01 +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.35; Tue, 14 May 2024 09:56:58 -0500 From: Arunpravin Paneer Selvam To: , , CC: , , , Arunpravin Paneer Selvam Subject: [PATCH v3 2/2] drm/tests: Add a unit test for range bias allocation Date: Tue, 14 May 2024 20:26:36 +0530 Message-ID: <20240514145636.16253-2-Arunpravin.PaneerSelvam@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240514145636.16253-1-Arunpravin.PaneerSelvam@amd.com> References: <20240514145636.16253-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: BN2PEPF0000449D:EE_|MW5PR12MB5652:EE_ X-MS-Office365-Filtering-Correlation-Id: d2ed6a45-9602-4d43-e830-08dc74261c3f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|1800799015|376005|36860700004|82310400017; X-Microsoft-Antispam-Message-Info: RhCL38XjYccKy43+ob9xfp3Xl9nEOJy9d/wcxe7b6QSytdiNJHT0dTlDw6TmWISeg3ak32ZMh2zMffFKvA6xY9IB17eUgLxpleSGOOKQyGDIRJITR5DYHZaYbwsO6taOUMSXlMt81keyuZRKy6nI5oIj21VDY9uHzj8AuXIKQdY3g4UVhjTMaeE77GH+qsU5+D52kBdLZTeNVIQyLxqWr6Q1Pw91zvOoaOGRkVm1P0dKR5Rh1N6Zt4bpTCFDlQoloMYc51NfxUD5EMnxlykg+WWOT+Y3FTT9gppeNN2kzMPgSwf4L/3xMmWXxR7lCEIQniLbUzzL6GpIXvArET/jyaR8dpgyAio4CXNzC88IOqsmIZtSfiQcbW0erAjb1wdcpmsUUe86na/mD//+X9H/HVqtKDoXT2GkO/xuwm667Mfd2UacpaqLkGF69+thdtHevoP80kNrP+6ulCYnrj41ru3pjAiODT5Sp4mO37dr1GmtqKjS3czGzY82bAIj0nKMjhl7j9MLZeNzfS1cYt8G/kkvKL5MUZ/We3nIzpebx/f1mXRQqQhqEOEuppcwVGsenkqlmFX2yEgz2tWo1EDYqc2KRPTE4U70KTTTsbKWyFJBaL8iAZZaGZbu85qcvXRO8z02i9beD6sPMseXSN0Q1INQhg86JGb1R5GdgqtsGxSS3mToavFDZ9UcsjuTCmkt2vRlmhe/CDoQyy3CqBdCfSdOPUcx8n5DklkNth7U+C605QObUMXIUkGrlvYFusACrvtKo9PJyXQbwpP6PMRSc67Ac4umtrbyN6cU8ELgQB3uVsUUc4T/tVutDzZa0P6SfQNckSKBujfQQBWJsvgMRT+M6WPiBU35BZ3J/DtZE9l7knHS13o7fm6WOoYTAF4GkegO+kULHhnMY51vgg/hwdPV9CqDXEy5XjKnILYc5B8hHE5D7Aw0G8gaqtcDSjI72UVuXnDOJquy3NVezDPIWVZAxSiBqknibFUi5HBixKPzx9XvZ0eyGxBEKeAG8VwnV63FRDALF+WlCV7OP8bTzW86OFBg3nPjf0wo6DsEDbdFm3+0mI9L0RwfxhzOpuy5eX9fCTRkZbed1OiSNKiqoDpyPpvx7S4VvL963G+xMG22I4B5hdMpPAmdRGKI6zPPyRlAoPPWPDUPZBuQUCuUuc6YWQgx+C0UYNsPNFDRqJVEb5M6kJBCXBv4F5UePxAgQANnDnkqvciPvTM+Bra6w8HRyys7paVQUTtMqpazJRf/8ESU/ipv8HHoZdI+osEkBp7TCSGIr68VIQecm6XeR5MAihaW288Ppw6AMybS+s5Kga3WlR4nQA8xy34TEGgFmv+GolzRKAAtgZI6upRKtYfm5GX0t3RTFoBKcInyUPUgOUAkvy+zDg3+n48hVwhw 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:(13230031)(1800799015)(376005)(36860700004)(82310400017); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 May 2024 14:57:01.0828 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d2ed6a45-9602-4d43-e830-08dc74261c3f 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: BN2PEPF0000449D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR12MB5652 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" Allocate cleared blocks in the bias range when the DRM buddy's clear avail is zero. This will validate the bias range allocation in scenarios like system boot when no cleared blocks are available and exercise the fallback path too. The resulting blocks should always be dirty. v1:(Matthew) - move the size to the variable declaration section. - move the mm.clear_avail init to allocator init. Signed-off-by: Arunpravin Paneer Selvam Reviewed-by: Matthew Auld --- drivers/gpu/drm/tests/drm_buddy_test.c | 36 +++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/tests/drm_buddy_test.c b/drivers/gpu/drm/tests/drm_buddy_test.c index e3b50e240d36..b3be68b03610 100644 --- a/drivers/gpu/drm/tests/drm_buddy_test.c +++ b/drivers/gpu/drm/tests/drm_buddy_test.c @@ -23,9 +23,11 @@ static inline u64 get_size(int order, u64 chunk_size) static void drm_test_buddy_alloc_range_bias(struct kunit *test) { - u32 mm_size, ps, bias_size, bias_start, bias_end, bias_rem; + u32 mm_size, size, ps, bias_size, bias_start, bias_end, bias_rem; DRM_RND_STATE(prng, random_seed); unsigned int i, count, *order; + struct drm_buddy_block *block; + unsigned long flags; struct drm_buddy mm; LIST_HEAD(allocated); @@ -222,6 +224,38 @@ static void drm_test_buddy_alloc_range_bias(struct kunit *test) drm_buddy_free_list(&mm, &allocated, 0); drm_buddy_fini(&mm); + + /* + * Allocate cleared blocks in the bias range when the DRM buddy's clear avail is + * zero. This will validate the bias range allocation in scenarios like system boot + * when no cleared blocks are available and exercise the fallback path too. The resulting + * blocks should always be dirty. + */ + + KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_init(&mm, mm_size, ps), + "buddy_init failed\n"); + + bias_start = round_up(prandom_u32_state(&prng) % (mm_size - ps), ps); + bias_end = round_up(bias_start + prandom_u32_state(&prng) % (mm_size - bias_start), ps); + bias_end = max(bias_end, bias_start + ps); + bias_rem = bias_end - bias_start; + + flags = DRM_BUDDY_CLEAR_ALLOCATION | DRM_BUDDY_RANGE_ALLOCATION; + size = max(round_up(prandom_u32_state(&prng) % bias_rem, ps), ps); + + KUNIT_ASSERT_FALSE_MSG(test, + drm_buddy_alloc_blocks(&mm, bias_start, + bias_end, size, ps, + &allocated, + flags), + "buddy_alloc failed with bias(%x-%x), size=%u, ps=%u\n", + bias_start, bias_end, size, ps); + + list_for_each_entry(block, &allocated, link) + KUNIT_EXPECT_EQ(test, drm_buddy_block_is_clear(block), false); + + drm_buddy_free_list(&mm, &allocated, 0); + drm_buddy_fini(&mm); } static void drm_test_buddy_alloc_clear(struct kunit *test)