From patchwork Fri Sep 3 06:48:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pan, Xinhui" X-Patchwork-Id: 12473725 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71E5FC433F5 for ; Fri, 3 Sep 2021 06:48:16 +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 3107F6101A for ; Fri, 3 Sep 2021 06:48:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3107F6101A Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5D3F86E845; Fri, 3 Sep 2021 06:48:15 +0000 (UTC) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2054.outbound.protection.outlook.com [40.107.243.54]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2B89B6E845; Fri, 3 Sep 2021 06:48:14 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AquQJI61jLm9YaYn5zyHqVdpWCxJElodO4dBHx11UnhMc0wKYYtHOUdP7tTXdmS4qci+gk4ADCfLQm/5oUUqMdDAjsoXufnhWXVN0P/1Wi/i/VrRjaDxq9V6UWjC/XH9vJQz46O7ag6THXvLVJBwyqDx3VvozTk2ifGLNLApOY1ukhZ3pPd6tjuDwnVaB0IyjksC6h9HzRGJlNLmaPyrmYILTCLNps7ayEyUHq7oVETFWx0xov95eTUqIDsNWPVpv3NaaiIHxA1qwO3AsmpfuCU6e7zoHVX6F5yQ3VEx9exjLhLf5jUAG9SBw00qPJsoEYyer5435iT4tbQk8itXGg== 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; bh=8E+GA45IEaj3NVw/5I6ncEvtZadDXkoEXn2wRjM0YIw=; b=ljTu7o0r2BR8MPs81vvkYDLsQgzTIAuNDdztUxYWEEEE9bbnpXuxFNnLijy5QB75yw8mdNPWQIwCCCDIikE4ZVjOT1vbEbnUVWxCgAdf9iCh5Gh+AHbeQguOw61ZCuKv+Io+HTzDdo+0KcR5YrE+6lbEz9IXyJTOaa83O1/Ck1Bq7rRv29pWA6QNKL5zemZ5b+60D32z82QFoov7mAXgfFrOz/PoUH0EYLyTFgNtWLtsUY8c07o4IF8gLtx+rLGu+jF/jRRWj0NiNJNuu86vkGLmHJFAlKuu14TJXhiVZPCLL0YrZNKqWQ1QSRujpCecqQHsNSaZ1Vn8766AkRE22A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none 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=8E+GA45IEaj3NVw/5I6ncEvtZadDXkoEXn2wRjM0YIw=; b=SuCECue5MEdp0d3AughpqjuJZBQZhYdN5Q8mMAmfmhk0DYFWMPDcFa7ki1bLfF/NMPuUEZgSYwY1NC6caH2Zhjo5oy5CGiUSROwZIdXd6r0T1p1MF15m4rZpDIoec2fl1WgQ0rmTBjouQ+gFxQNgM/aqazKs5yQLcznZGoL1+e4= Received: from DM4PR12MB5165.namprd12.prod.outlook.com (2603:10b6:5:394::9) by DM8PR12MB5414.namprd12.prod.outlook.com (2603:10b6:8:3e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.17; Fri, 3 Sep 2021 06:48:12 +0000 Received: from DM4PR12MB5165.namprd12.prod.outlook.com ([fe80::79d6:3902:9bcd:37ca]) by DM4PR12MB5165.namprd12.prod.outlook.com ([fe80::79d6:3902:9bcd:37ca%9]) with mapi id 15.20.4478.022; Fri, 3 Sep 2021 06:48:12 +0000 From: "Pan, Xinhui" To: amd-gfx , "dri-devel@lists.freedesktop.org" CC: "Deucher, Alexander" , "Koenig, Christian" , "Grodzovsky, Andrey" , "daniel@ffwll.ch" Subject: [PATCH 0/2] Fix a hung during memory pressure test Thread-Topic: [PATCH 0/2] Fix a hung during memory pressure test Thread-Index: AQHXoI+pk4aoVYAKr0qsrY900besgg== Date: Fri, 3 Sep 2021 06:48:12 +0000 Message-ID: <49DAD38C-6DC4-4601-B11E-96F289EC148E@amd.com> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Microsoft-MacOutlook/10.1f.0.191110 authentication-results: lists.freedesktop.org; dkim=none (message not signed) header.d=none; lists.freedesktop.org; dmarc=none action=none header.from=amd.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 3d534572-cb1d-4ba7-66f6-08d96ea6cc88 x-ms-traffictypediagnostic: DM8PR12MB5414: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4125; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Azm9P6wCUFR9kJKhaVC1YSKenID9gukcTfpnMHw3fvzyYatJncDWExLxk9/CFKj1rYXqmV5Ahe0njws8qU6EOjd68n6EJ0PXNZscpkvgwt40WvqRWjywU9bdiehrkC5IyArsZHbMeH3gbonVeBEHciCEe5SuA9sq7GkK43gDXJ1APeyi0B9ue1VXKBMBO6fY2iqTouKwLkzYHHVvBGxZPYnfrYX9i9b7FjG5ZiMhsIadRiJIPWiMirZAlN9YJhp5yvjCMKEghhho6rBqyJr8Tcn+D1LOR9Igan6dgk5Axjx1RG/+/xclALix5Zra4svqPwXEo8QUQgWi9hRyxBVgCT6aPIS02DZM9L3N7EW3/2t1hgjAf2ThbF8N1L8vfJv8drvQeaWtWT/hkKJKYJfimLv841GNbzQ+TendbCTrSsbBVJSHvmSKnJu3gLUTLnRKpallR2f/23S5tdgdgY1dq5UkwZpPVM38hTM0fv4ZbggNniu3UuTmZgNIy1YnsSWXMVM9Had0HLh847KWIfvrqCSZa5XPm56M8y+WdoMCh4vv8cqdVRWAdf8mZ15HiOXi8fdee4BpNYtYMu7FAvPvEMX+327zGSoQj6gC5bpbsFcs6C+3mz3E63w3Q5gYUTaj9zMhh9EQWhK11HA5sXfaDbWsylCZOMFeiB0sC29lpi0UH6DsL4ZvdEzFH1VXn+37+t118bPk1kF2Y5P3yHjqFyNC+RTZc8tSUer/aPmcgY7046hWUIwVDcDBezpfu1Oe x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR12MB5165.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(346002)(366004)(396003)(376002)(39860400002)(71200400001)(38070700005)(6506007)(5660300002)(478600001)(6512007)(36756003)(6486002)(33656002)(83380400001)(26005)(186003)(86362001)(66446008)(66476007)(66946007)(66556008)(64756008)(8676002)(8936002)(4326008)(316002)(110136005)(54906003)(122000001)(38100700002)(2616005)(2906002)(91956017)(76116006)(45980500001); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?SIPOj/5698bnwD00pyCpq/vzb6f2?= =?utf-8?q?elThvH8q5ks78m2R049S5/OKqXII0IdzCbR8+TRFG3YJvrdTEF/SPfDCrx5loKXve?= =?utf-8?q?6rk45rRlwxl5hMXJgw7MbMmkCgnxhxwN5BKm15Va4l0tL4URrbfg5DYeRE+/gJxQu?= =?utf-8?q?6uaftJMA7TzQNFtU3It5gqOp9Fs/UUpktMNls+UPAA0rQET6t3CdnDlScke9vW64s?= =?utf-8?q?wVJoi90+tX/hVb/dzVbzZ2R28/N9ao9cbDxe71uTVpBIpjeWaSZFzBCfPXkxlpOOe?= =?utf-8?q?LY1y6GGO4IwmgOAHgZMn4Y6tvpQLzF1q1kCzpRuVtMEIFY0schiTf4dXycvLsPP09?= =?utf-8?q?cPRFY+jkZILQNnGRfGb4HIVerlVeQArvaDPPj0L1vXaugHcsHPyu/GyHlPHS4CWq9?= =?utf-8?q?EI5l5w4aHxvyK5x0WE+pTWqkFpTmS/kPkPdGdyI0SXtVyC1RUyPLhK3udycTIJYSi?= =?utf-8?q?vu643yJd8O4MGxfv7bNCgyYTIDm/va1ZCoS5ouyY4OW/ckLjPGx/D9zQlKUzXYcUo?= =?utf-8?q?uKw4SAZEAeTL2eI6MI1M5Fi7w1KhVyovLpw0ruuutig2qnnFLJxG5inz77T6LkLel?= =?utf-8?q?/SDsmJ2G88V9Z9m8egpyYRfIaYcp6gYtC/v1zQFaWYlsexGHcxv0y4Fk0gvQGuOBM?= =?utf-8?q?m5EsMfuQ8ZvMlB9KFILyH/i7uvatWK6uWh7peOjJYwlYoRNcNI/a4akH3tlwkhup1?= =?utf-8?q?SJx82pw4rNFc44GJ96W7v0jrsZMJ+bWvzdqc13jMkKD41l0Cm3bygoi7H6lMNyIal?= =?utf-8?q?nlpcFdd4ITc8AM5KwioibLIwCbCVMWD8sfQ04xfXc7MBBp+/gY07UCFL9NwGshA9L?= =?utf-8?q?AHWwt1ZlSVRUNaYuQYMGPZH9cZM2yPpcwR4dvSW1EIZ13cHN/W6aKE02NyLUKN6Ad?= =?utf-8?q?+Oe/swpdNQhoxQI6gJwjGaareZJzqX57FnM5HAMRYH9T1WkRpobI50qCG54KBrlQq?= =?utf-8?q?oImCrcgf0H1xsRiMpMZL+Adgq5PPfkdeF7i3QxJOPQU7YGjv4+GYYyX0CbUy5ZDmL?= =?utf-8?q?3elHgjHC/dCcUR1147qJ6vyv0n1tQKog5NuT8myMQ9LLNVYtP9HKODlHU1f7DL50a?= =?utf-8?q?MG8RQVVfEkrjmeefHaJgfi+EvZLQRJkw9/suCBppu8OGUiorrzYcbJbnjcxPDmDwf?= =?utf-8?q?SOIEzzVvr+F2fEXR3nFx/7W2QJTDMYDwuy2wdTBNRmBjEE4Nn4L6ded58IimRtyWR?= =?utf-8?q?qifSGhC03c6Zt3YQZ4qzfIz9MoNfqyrZES3GxL69NC2/VZHszQzpfp+wUBXJ7HO5r?= =?utf-8?q?g/Vv2FsMV+g/yOgbUuU3ssPOizRbuzodh50dLw=3D=3D?= Content-ID: <52917BB62AD3244CBA14161D3B8E5FC8@namprd12.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM4PR12MB5165.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3d534572-cb1d-4ba7-66f6-08d96ea6cc88 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Sep 2021 06:48:12.3100 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: IG12MGqDnT7Gq95lqlym3QN13hRm1ckDNFEvnCFrP6XQsj9pEk7QiptpI5n+Q/H/ X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR12MB5414 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" A long time ago, someone reports system got hung during memory test. In recent days, I am trying to look for or understand the potential deadlock in ttm/amdgpu code. This patchset aims to fix the deadlock during ttm populate. TTM has a parameter called pages_limit, when allocated GTT memory reaches this limit, swapout would be triggered. As ttm_bo_swapout does not return the correct retval, populate might get hung. UVD ib test uses GTT which might be insufficient. So a gpu recovery would hung if populate hung. I have made one drm test which alloc two GTT BOs, submit gfx copy commands and free these BOs without waiting fence. What's more, these gfx copy commands will cause gfx ring hang. So gpu recovery would be triggered. Now here is one possible deadlock case. gpu_recovery -> stop drm scheduler -> asic reset -> ib test -> tt populate (uvd ib test) -> ttm_bo_swapout (BO A) // this always fails as the fence of BO A would not be signaled by schedluer or HW. Hit deadlock. I paste the drm test patch below. Try it with modprobe ttm pages_limit=65536 --- tests/amdgpu/basic_tests.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/tests/amdgpu/basic_tests.c b/tests/amdgpu/basic_tests.c index dbf02fee..f85ed340 100644 --- a/tests/amdgpu/basic_tests.c +++ b/tests/amdgpu/basic_tests.c @@ -65,13 +65,16 @@ static void amdgpu_direct_gma_test(void); static void amdgpu_command_submission_write_linear_helper(unsigned ip_type); static void amdgpu_command_submission_const_fill_helper(unsigned ip_type); static void amdgpu_command_submission_copy_linear_helper(unsigned ip_type); -static void amdgpu_test_exec_cs_helper(amdgpu_context_handle context_handle, +static void _amdgpu_test_exec_cs_helper(amdgpu_context_handle context_handle, unsigned ip_type, int instance, int pm4_dw, uint32_t *pm4_src, int res_cnt, amdgpu_bo_handle *resources, struct amdgpu_cs_ib_info *ib_info, - struct amdgpu_cs_request *ibs_request); + struct amdgpu_cs_request *ibs_request, int sync, int repeat); +#define amdgpu_test_exec_cs_helper(...) \ + _amdgpu_test_exec_cs_helper(__VA_ARGS__, 1, 1) + CU_TestInfo basic_tests[] = { { "Query Info Test", amdgpu_query_info_test }, { "Userptr Test", amdgpu_userptr_test }, @@ -1341,12 +1344,12 @@ static void amdgpu_command_submission_compute(void) * pm4_src, resources, ib_info, and ibs_request * submit command stream described in ibs_request and wait for this IB accomplished */ -static void amdgpu_test_exec_cs_helper(amdgpu_context_handle context_handle, +static void _amdgpu_test_exec_cs_helper(amdgpu_context_handle context_handle, unsigned ip_type, int instance, int pm4_dw, uint32_t *pm4_src, int res_cnt, amdgpu_bo_handle *resources, struct amdgpu_cs_ib_info *ib_info, - struct amdgpu_cs_request *ibs_request) + struct amdgpu_cs_request *ibs_request, int sync, int repeat) { int r; uint32_t expired; @@ -1395,12 +1398,15 @@ static void amdgpu_test_exec_cs_helper(amdgpu_context_handle context_handle, CU_ASSERT_NOT_EQUAL(ibs_request, NULL); /* submit CS */ - r = amdgpu_cs_submit(context_handle, 0, ibs_request, 1); + while (repeat--) + r = amdgpu_cs_submit(context_handle, 0, ibs_request, 1); CU_ASSERT_EQUAL(r, 0); r = amdgpu_bo_list_destroy(ibs_request->resources); CU_ASSERT_EQUAL(r, 0); + if (!sync) + return; fence_status.ip_type = ip_type; fence_status.ip_instance = 0; fence_status.ring = ibs_request->ring; @@ -1667,7 +1673,7 @@ static void amdgpu_command_submission_sdma_const_fill(void) static void amdgpu_command_submission_copy_linear_helper(unsigned ip_type) { - const int sdma_write_length = 1024; + const int sdma_write_length = (255) << 20; const int pm4_dw = 256; amdgpu_context_handle context_handle; amdgpu_bo_handle bo1, bo2; @@ -1715,8 +1721,6 @@ static void amdgpu_command_submission_copy_linear_helper(unsigned ip_type) &bo1_va_handle); CU_ASSERT_EQUAL(r, 0); - /* set bo1 */ - memset((void*)bo1_cpu, 0xaa, sdma_write_length); /* allocate UC bo2 for sDMA use */ r = amdgpu_bo_alloc_and_map(device_handle, @@ -1727,8 +1731,6 @@ static void amdgpu_command_submission_copy_linear_helper(unsigned ip_type) &bo2_va_handle); CU_ASSERT_EQUAL(r, 0); - /* clear bo2 */ - memset((void*)bo2_cpu, 0, sdma_write_length); resources[0] = bo1; resources[1] = bo2; @@ -1785,17 +1787,11 @@ static void amdgpu_command_submission_copy_linear_helper(unsigned ip_type) } } - amdgpu_test_exec_cs_helper(context_handle, + _amdgpu_test_exec_cs_helper(context_handle, ip_type, ring_id, i, pm4, 2, resources, - ib_info, ibs_request); - - /* verify if SDMA test result meets with expected */ - i = 0; - while(i < sdma_write_length) { - CU_ASSERT_EQUAL(bo2_cpu[i++], 0xaa); - } + ib_info, ibs_request, 0, 100); r = amdgpu_bo_unmap_and_free(bo1, bo1_va_handle, bo1_mc, sdma_write_length); CU_ASSERT_EQUAL(r, 0);