From patchwork Tue Jan 25 22:37:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 12724280 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 96494C433EF for ; Tue, 25 Jan 2022 22:38:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1406D10E5A4; Tue, 25 Jan 2022 22:38:25 +0000 (UTC) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2068.outbound.protection.outlook.com [40.107.237.68]) by gabe.freedesktop.org (Postfix) with ESMTPS id B21D510E5A4; Tue, 25 Jan 2022 22:38:20 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AIo46iiGbR09Ue/UAZpyVMSVtN2t3nJTj/Y38iLUh8JpHUPngitUZShngIrvgkRiqGl4rNADE4g/QGg7VWvwtsbK8n1aLpkwsmB01S06M4y0bqDo2mbv4grfnbBQ74+2vnFtnWG+pBW3DAVYRbJ4JGzr2ZWNCGPPWx1RLlhnv40wypM4PvMix70QuOq9huzk2NCyj387pSgPywZ56IlgjAjxA257uZAxzQWplEHMXZXBlQ05om7Fv7D2zrnCyMbHzw1RmDv335X+WljRZEVXHBEig1dokQs1ZhO8zOTbMrTLIF77FU+TekXztyRe6ZSyfRogti2SWtQWZZnSDo6VTw== 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=0jDyLVNTFQabu8nZ8kZWGIAPZD4i5irSpsyZpfcEzBU=; b=SnTWlag5nmp0WEwSllWd9zs5e0QsGt/Lq+1csSy0oAO3X99vuVhkuJSb/IezOpQr2yBuNKgbbL4/OwM7URI8i43ZN4vqx6WhrF0y/oxRWJOXlBLGlTMg7C8UacKoTn2iqE6XiECWHd5I6VJrujq/1nfbMyxt9xUeX/cq4B6AbUPMki1703duixeZVofoKDVUE/4Pvt4OdqVSsvzi/lal6LfRTd6Q0wMXWwjk5xu4HwlyDOX7ybVz+moXaTXGkYveva/37/AqlyeuRVg4inwbRh+CDp0p43lQzubbqKqwprrKEKORBSO3OsgadtTCGGIEW7/iTk0elXi5giUj/e5j3g== 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 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=0jDyLVNTFQabu8nZ8kZWGIAPZD4i5irSpsyZpfcEzBU=; b=hLEuuckbMZEWcwhOV73qDD6lBduiwxMfLrtGOEevGTUGLwgNWL3opilYNZ3m29ZVKT1ubR3Vmn/SrF3shQ+dm30u0N1Eqnvw+eS7nztYTZurWRPZ1/MUo4ymAww8bxERNZtJiZFADu4x7ruljil0trXpl9/Ev7snI6RGb4yyuao= Received: from DM5PR18CA0085.namprd18.prod.outlook.com (2603:10b6:3:3::23) by CY4PR12MB1176.namprd12.prod.outlook.com (2603:10b6:903:38::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.13; Tue, 25 Jan 2022 22:38:18 +0000 Received: from DM6NAM11FT027.eop-nam11.prod.protection.outlook.com (2603:10b6:3:3:cafe::b9) by DM5PR18CA0085.outlook.office365.com (2603:10b6:3:3::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Tue, 25 Jan 2022 22:38:18 +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; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT027.mail.protection.outlook.com (10.13.172.205) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4909.7 via Frontend Transport; Tue, 25 Jan 2022 22:38:17 +0000 Received: from agrodzovsky-All-Series.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.2375.18; Tue, 25 Jan 2022 16:38:16 -0600 From: Andrey Grodzovsky To: , Subject: [RFC v3 01/12] drm/amdgpu: Introduce reset domain Date: Tue, 25 Jan 2022 17:37:41 -0500 Message-ID: <20220125223752.200211-2-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220125223752.200211-1-andrey.grodzovsky@amd.com> References: <20220125223752.200211-1-andrey.grodzovsky@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fd593564-7dc8-475c-da8f-08d9e05361f2 X-MS-TrafficTypeDiagnostic: CY4PR12MB1176:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /uB39u2WGOHi4Lvul5xs2sZrfezLcHBO3Fh2exkjSiHqKkXQlj+wfkoWnsScQLimeSI8oUKChmS3wklcqMaymnROkHtP0nHgBFggOfkx4/t4OdWc8TOxKp9/benCaV2vQAAEwQcJMbyEHKs31Y+FiqvrgIs9WP+s8Y+BB6v1a9ECbq4V4SssuqBTfLIkPzGEx3N9nuzjX4rf+Ly5uhVY4rDEWsFp7e1ycma2Fldwd2pniULN7fiVKRz8Vk9E+NdICJlH5Z+Ue2Oa1h2KjLf6D+qKnBMhnmb1HgJ6n1mo162nQsNDwerXpa89G3Fsnt8MGfQa9FXqtCApf75Io5Qg6/oXT2lHAmpDXatp9O0WkkA4uf1xX/gT3OGd4FyQvHLjzgerMjmelZxBTGyiVYckIKpyMJm1MsmGfUT9XxO1IA1yXJcD4k+X6Hio6lKbi5S8Yk7rX+VwbTc6rhYRACOS0+Dtl2ZPwUsagXdAQ0cYpgK0dAkLHKB2VQiU/Als9tNhQlPrT13zo+nXrcrtsfrirBOy46SVSdDQD/Sv4JtKCMCf3V1TsbA1D61KS3FngsIdLk0d1FDNvJ1f8C2hRIc/IfWbR7yWIkfnyRJyunMj0GJutzrXn4XtNbRnEcvgwk0tsCIAZLrRHYbnSaOLtCaNbAZUYMKd5s9Cd1Tnm60O+Izf6Oc4BWnZlAXFVVxRakYXeAzyOusvNf7uli7lDdRGEDLuFA+T1Q2RAlJnqsIwHRsCYAtGNZ0cw9c+HaAC8S8GYuTPvi60CA0G2x5Jog6I69jVRSd78Q+Fbf/wpjtWaDg= 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:(4636009)(40470700004)(46966006)(36840700001)(186003)(86362001)(7696005)(1076003)(36860700001)(83380400001)(47076005)(82310400004)(2906002)(16526019)(316002)(5660300002)(508600001)(4326008)(26005)(8676002)(356005)(70586007)(110136005)(44832011)(426003)(81166007)(66574015)(40460700003)(36756003)(336012)(2616005)(8936002)(54906003)(70206006)(6666004)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2022 22:38:17.9067 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fd593564-7dc8-475c-da8f-08d9e05361f2 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: DM6NAM11FT027.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1176 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: , Cc: Daniel Vetter , horace.chen@amd.com, lijo.lazar@amd.com, jingwech@amd.com, =?utf-8?q?Christian_K=C3=B6nig?= , christian.koenig@amd.com, Monk.Liu@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Defined a reset_domain struct such that all the entities that go through reset together will be serialized one against another. Do it for both single device and XGMI hive cases. Signed-off-by: Andrey Grodzovsky Suggested-by: Daniel Vetter Suggested-by: Christian König Reviewed-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 7 +++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 20 +++++++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 9 +++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h | 2 ++ 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 9f017663ac50..b5ff76aae7e0 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -812,6 +812,11 @@ struct amd_powerplay { #define AMDGPU_RESET_MAGIC_NUM 64 #define AMDGPU_MAX_DF_PERFMONS 4 + +struct amdgpu_reset_domain { + struct workqueue_struct *wq; +}; + struct amdgpu_device { struct device *dev; struct pci_dev *pdev; @@ -1096,6 +1101,8 @@ struct amdgpu_device { struct amdgpu_reset_control *reset_cntl; uint32_t ip_versions[HW_ID_MAX][HWIP_MAX_INSTANCE]; + + struct amdgpu_reset_domain reset_domain; }; static inline struct amdgpu_device *drm_to_adev(struct drm_device *ddev) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 90d22a376632..0f3e6c078f88 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -2391,9 +2391,27 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev) if (r) goto init_failed; - if (adev->gmc.xgmi.num_physical_nodes > 1) + if (adev->gmc.xgmi.num_physical_nodes > 1) { + struct amdgpu_hive_info *hive; + amdgpu_xgmi_add_device(adev); + hive = amdgpu_get_xgmi_hive(adev); + if (!hive || !hive->reset_domain.wq) { + DRM_ERROR("Failed to obtain reset domain info for XGMI hive:%llx", hive->hive_id); + r = -EINVAL; + goto init_failed; + } + + adev->reset_domain.wq = hive->reset_domain.wq; + } else { + adev->reset_domain.wq = alloc_ordered_workqueue("amdgpu-reset-dev", 0); + if (!adev->reset_domain.wq) { + r = -ENOMEM; + goto init_failed; + } + } + /* Don't init kfd if whole hive need to be reset during init */ if (!adev->gmc.xgmi.pending_reset) amdgpu_amdkfd_device_init(adev); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c index 567df2db23ac..a858e3457c5c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c @@ -392,6 +392,14 @@ struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev) goto pro_end; } + hive->reset_domain.wq = alloc_ordered_workqueue("amdgpu-reset-hive", 0); + if (!hive->reset_domain.wq) { + dev_err(adev->dev, "XGMI: failed allocating wq for reset domain!\n"); + kfree(hive); + hive = NULL; + goto pro_end; + } + hive->hive_id = adev->gmc.xgmi.hive_id; INIT_LIST_HEAD(&hive->device_list); INIT_LIST_HEAD(&hive->node); @@ -401,6 +409,7 @@ struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev) task_barrier_init(&hive->tb); hive->pstate = AMDGPU_XGMI_PSTATE_UNKNOWN; hive->hi_req_gpu = NULL; + /* * hive pstate on boot is high in vega20 so we have to go to low * pstate on after boot. diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h index d2189bf7d428..6121aaa292cb 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h @@ -42,6 +42,8 @@ struct amdgpu_hive_info { AMDGPU_XGMI_PSTATE_MAX_VEGA20, AMDGPU_XGMI_PSTATE_UNKNOWN } pstate; + + struct amdgpu_reset_domain reset_domain; }; struct amdgpu_pcs_ras_field { From patchwork Tue Jan 25 22:37:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 12724281 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 10B18C433F5 for ; Tue, 25 Jan 2022 22:38:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6E2FB10E5AE; Tue, 25 Jan 2022 22:38:25 +0000 (UTC) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2046.outbound.protection.outlook.com [40.107.244.46]) by gabe.freedesktop.org (Postfix) with ESMTPS id CD67310E5C1; Tue, 25 Jan 2022 22:38:22 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EqgM4CeoJT2KlyGO5JTM+vXBy7xUCkTSUsMyUM73TorCAyDFwOk6HvaG5+F5bxYiToEBLGRGk6TOvcbQz+pu8LLyuQBhKdZUt46Iq38pH9wNxUosMLimuDf66xYWlErivjUT68AEy1Cyragfnv6ze5WlEJzqa3GPJ2sIXTo31w77bNcD7J09qtv2VpNG3om9wwUv5gVGk1QcTqSF5jCI/PmwI3geYC5/Efl72KRa+GC9kxb/r9fZXUtOqDxrXPgCODQi5nAF2hQBNwnOAs9Ahfx4HqwAerqCk8Emibs9AyrbfE99xzFGJS0oU6VU0x9qP12mQTfsrl8r9IGGCfmYog== 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=Lk+/v5Ru5WVHNwhF49eB/zlLQWIh929hS53FBd/x8jo=; b=J5uMu0AFcNwBOwr0nCYiUUnaSqJMDY1nQvKpFoFCDeDFkWGMIMdPzRqxC5Uj5PcXMGo/1Dm7VYq6sYNrR1yzRkbBmeUh7MfHlatYO5Ud0tMjRgXfWI7ppkDtwam+phTfr8i0ZT7YrpAJI92mcpyeWftbnRc/t+1SwJfOJvGODnxQRR9XIrM3kAsQpJP1MjXU9dSZcJ1om9vLxS4A40v9yd5bTW8usEgJlFtUXjBLhGwrqSFOWO+gf2gc2gKkD2ZZoLQGoros+oY2pgb0hqOwPeoG9q4eunH6BVUAynr0JtGFSacuqZufVJH+I4AlFGmOShuQZ/PjfCZCH1Udzh5R8Q== 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 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=Lk+/v5Ru5WVHNwhF49eB/zlLQWIh929hS53FBd/x8jo=; b=hQgt6Dt1kVQCIzCUciI4mPWV35ad7hfOY1OILPdtE+PXq6wXGCEq7CZnVeLswLqmcmTquTg+JFdmLNo8VBHynv477Ur6g86P2QP8yWD+8uUXKWdUQ/vEnVSM9Vso6iH44MbpXRYbFuS6mhucRz0WWmakerU+PC73CGom/+Uia3c= Received: from DM5PR2001CA0022.namprd20.prod.outlook.com (2603:10b6:4:16::32) by BY5PR12MB4933.namprd12.prod.outlook.com (2603:10b6:a03:1d5::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.8; Tue, 25 Jan 2022 22:38:21 +0000 Received: from DM6NAM11FT018.eop-nam11.prod.protection.outlook.com (2603:10b6:4:16:cafe::7e) by DM5PR2001CA0022.outlook.office365.com (2603:10b6:4:16::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Tue, 25 Jan 2022 22:38:20 +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; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT018.mail.protection.outlook.com (10.13.172.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4930.15 via Frontend Transport; Tue, 25 Jan 2022 22:38:19 +0000 Received: from agrodzovsky-All-Series.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.2375.18; Tue, 25 Jan 2022 16:38:17 -0600 From: Andrey Grodzovsky To: , Subject: [RFC v3 02/12] drm/amdgpu: Move scheduler init to after XGMI is ready Date: Tue, 25 Jan 2022 17:37:42 -0500 Message-ID: <20220125223752.200211-3-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220125223752.200211-1-andrey.grodzovsky@amd.com> References: <20220125223752.200211-1-andrey.grodzovsky@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 60e7710c-a2ca-41bf-6d96-08d9e0536311 X-MS-TrafficTypeDiagnostic: BY5PR12MB4933:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:510; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gizId0HATbUtVjib76/WsST3HtlgsRH7X+S2YrUf/brMyftoHJxYBUwn1qScf+jdggoLAIK6CKTuBYAdtTUCQbwaQl/i2AGeuSY53AVEekhoaA3Uk8CMAKSfvP6JXu/FSnqcMQuwML+IpFqj+tf/7SYyzy+7rOPqW9yp89lnNQnIs6aIWslL8unLNwoptnjLF8aH+CPx21P+F1WVgr/XMxRm/0GfLkpgYig5UhOy69aKdCJmkujIKuS+UC8W82XrjltG24Z6+vZh/MghE2lT6imPrgxyHJibjaXesOQ3P8FeP/vkgx+x2zsVmJCHJCqFzmdE5V4IgnVQoe0RT6gH4hqtOCrIsO22jbulYMSQdsjtMA66i87iS4vjHd/SmzY4bBucXG98EeuWX0utvMb7/TndnOhQQzz4uC9DY7gyGsEb4za11pQlX1N3TEY90WhAFg3L1voDrE0Tzgl9DvG9AXPeCa7DLVnGxMraI5gaG0lM/gTUM7TA5hzOQctIHKJAE85G4FdFlYmbPoGd9RbYzxbUm1qqcrdoe0lDS+BMvkowk0GUVUSE6cU9X0Ss1QZl47vbhga978gNmS8ZuKzDSlEFmaoHfiGVbYz04Jes4GCnuaWlRpJyyQ8rtGsnFizFg/G1G4bwIOlMDnEhiB6IWpAU+v4yIPeBQKB1b8IbkVNRn3cXnjq5d4g/RQxoKcdHGReN7KxzmIh2bJeYwpyUNklYcj5FnAURpOkoNKXazuND+pZw7rzvRCIVkej22IbchmNQWtoDThqdkAg83jlxzk0oJESPwGRYZNGEyNoq+yA= 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:(4636009)(46966006)(36840700001)(40470700004)(70586007)(356005)(508600001)(70206006)(2616005)(54906003)(336012)(81166007)(36756003)(426003)(316002)(1076003)(40460700003)(44832011)(47076005)(86362001)(8936002)(7696005)(110136005)(2906002)(6666004)(4326008)(5660300002)(36860700001)(16526019)(82310400004)(83380400001)(8676002)(186003)(26005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2022 22:38:19.7848 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 60e7710c-a2ca-41bf-6d96-08d9e0536311 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: DM6NAM11FT018.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4933 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: , Cc: horace.chen@amd.com, lijo.lazar@amd.com, jingwech@amd.com, christian.koenig@amd.com, Monk.Liu@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Before we initialize schedulers we must know which reset domain are we in - for single device there iis a single domain per device and so single wq per device. For XGMI the reset domain spans the entire XGMI hive and so the reset wq is per hive. Signed-off-by: Andrey Grodzovsky --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 45 ++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 34 ++-------------- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 2 + 3 files changed, 51 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 0f3e6c078f88..7c063fd37389 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -2284,6 +2284,47 @@ static int amdgpu_device_fw_loading(struct amdgpu_device *adev) return r; } +static int amdgpu_device_init_schedulers(struct amdgpu_device *adev) +{ + long timeout; + int r, i; + + for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { + struct amdgpu_ring *ring = adev->rings[i]; + + /* No need to setup the GPU scheduler for rings that don't need it */ + if (!ring || ring->no_scheduler) + continue; + + switch (ring->funcs->type) { + case AMDGPU_RING_TYPE_GFX: + timeout = adev->gfx_timeout; + break; + case AMDGPU_RING_TYPE_COMPUTE: + timeout = adev->compute_timeout; + break; + case AMDGPU_RING_TYPE_SDMA: + timeout = adev->sdma_timeout; + break; + default: + timeout = adev->video_timeout; + break; + } + + r = drm_sched_init(&ring->sched, &amdgpu_sched_ops, + ring->num_hw_submission, amdgpu_job_hang_limit, + timeout, adev->reset_domain.wq, ring->sched_score, ring->name); + if (r) { + DRM_ERROR("Failed to create scheduler on ring %s.\n", + ring->name); + return r; + } + } + + return 0; +} + + /** * amdgpu_device_ip_init - run init for hardware IPs * @@ -2412,6 +2453,10 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev) } } + r = amdgpu_device_init_schedulers(adev); + if (r) + goto init_failed; + /* Don't init kfd if whole hive need to be reset during init */ if (!adev->gmc.xgmi.pending_reset) amdgpu_amdkfd_device_init(adev); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c index 3b7e86ea7167..5527c68c51de 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c @@ -456,8 +456,6 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring, atomic_t *sched_score) { struct amdgpu_device *adev = ring->adev; - long timeout; - int r; if (!adev) return -EINVAL; @@ -477,36 +475,12 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring, spin_lock_init(&ring->fence_drv.lock); ring->fence_drv.fences = kcalloc(num_hw_submission * 2, sizeof(void *), GFP_KERNEL); - if (!ring->fence_drv.fences) - return -ENOMEM; - /* No need to setup the GPU scheduler for rings that don't need it */ - if (ring->no_scheduler) - return 0; + ring->num_hw_submission = num_hw_submission; + ring->sched_score = sched_score; - switch (ring->funcs->type) { - case AMDGPU_RING_TYPE_GFX: - timeout = adev->gfx_timeout; - break; - case AMDGPU_RING_TYPE_COMPUTE: - timeout = adev->compute_timeout; - break; - case AMDGPU_RING_TYPE_SDMA: - timeout = adev->sdma_timeout; - break; - default: - timeout = adev->video_timeout; - break; - } - - r = drm_sched_init(&ring->sched, &amdgpu_sched_ops, - num_hw_submission, amdgpu_job_hang_limit, - timeout, NULL, sched_score, ring->name); - if (r) { - DRM_ERROR("Failed to create scheduler on ring %s.\n", - ring->name); - return r; - } + if (!ring->fence_drv.fences) + return -ENOMEM; return 0; } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h index 4d380e79752c..a4b8279e3011 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h @@ -253,6 +253,8 @@ struct amdgpu_ring { bool has_compute_vm_bug; bool no_scheduler; int hw_prio; + unsigned num_hw_submission; + atomic_t *sched_score; }; #define amdgpu_ring_parse_cs(r, p, ib) ((r)->funcs->parse_cs((p), (ib))) From patchwork Tue Jan 25 22:37:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 12724283 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 706BBC433F5 for ; Tue, 25 Jan 2022 22:38:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AF9EF10E5C6; Tue, 25 Jan 2022 22:38:32 +0000 (UTC) Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam07on2080.outbound.protection.outlook.com [40.107.95.80]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1E42A10E5CD; Tue, 25 Jan 2022 22:38:27 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wby6X9oab06uYbE96G+mTWptPDHUSn9C1pmKYeKo8G3y5Ua0rzQT+C20Evqt/YhgrIyZqUuPvXZrSm89BzyW/7aAWxYaCkK1TZE3Hrnoul8DURVadaAohfjX96mnVf5F+jUJOzfsvW8fsGO7/SBjkcFtdd1ECDlDmCgTihzdp/MrYpu7rVuOp8R+zBGeTJbzo61L87ban5TGOP3pXmOWMjIr3VyTLo686Le370z037EGEqsenreEvKHHDdxlB7MIKt9RnzY572S/1CwOksQ49Zme+h3Io6EpJ6hWJcboBtq26gDbz9xt3Wr8F1gf+M8hIBZeoaATER3aDLhlzX8mmQ== 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=pFGfqZDC/8T0rOWwOksE0wZh3k34VzulojpOCZtEKtk=; b=fPsXOZ1a1an3MfklJweawpB6J5b6kds61vszeTqBbKd21nGxf/nPbXbCsBd9NmPuvk9xPEsqzCr1YV33lTMjCWfVflP/A2YhSV9spy6Sg6Wj6oAPgyI7O8oQNQDw9amqx+qiGapgmvfqL6BOgZO7bNJy6dQjQL6RRK2/0rp+4+s8uZWMcY6lpfe+nrkQ54ZWBc7aWrGECZyuhzsHeYwj3Ol7yz9j7pn6PA2BHRtojvc4Os0KfkX7d/gLhVcdTVl/cYPxbopPRw0BCRFyuO3VYyB6M6Xa9xLvLC5wekbTP74pEYzAPGTwX4IxgCM8FZPPGE6LO5pDYJL/T9YcF5T/BQ== 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 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=pFGfqZDC/8T0rOWwOksE0wZh3k34VzulojpOCZtEKtk=; b=Wude/zsK1aL76SOh9nyBQS4z7DC7QckVgNLA0WenmsQk0sqGhwWkARZrCNUlrWqKIPnBvFsNaLtfJNuiYmpd52FiVX+SnmSdykc31fOVgMDW9k55yAHKFmcvYO37IdMNOZS9T/LQOAzdfJU9b4QnFWp6SDZtwm/ISzHEEWjABHQ= Received: from DM5PR2001CA0005.namprd20.prod.outlook.com (2603:10b6:4:16::15) by CY4PR1201MB2502.namprd12.prod.outlook.com (2603:10b6:903:da::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.8; Tue, 25 Jan 2022 22:38:21 +0000 Received: from DM6NAM11FT018.eop-nam11.prod.protection.outlook.com (2603:10b6:4:16:cafe::4b) by DM5PR2001CA0005.outlook.office365.com (2603:10b6:4:16::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.19 via Frontend Transport; Tue, 25 Jan 2022 22:38:21 +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; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT018.mail.protection.outlook.com (10.13.172.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4930.15 via Frontend Transport; Tue, 25 Jan 2022 22:38:21 +0000 Received: from agrodzovsky-All-Series.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.2375.18; Tue, 25 Jan 2022 16:38:19 -0600 From: Andrey Grodzovsky To: , Subject: [RFC v3 03/12] drm/amdgpu: Fix crash on modprobe Date: Tue, 25 Jan 2022 17:37:43 -0500 Message-ID: <20220125223752.200211-4-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220125223752.200211-1-andrey.grodzovsky@amd.com> References: <20220125223752.200211-1-andrey.grodzovsky@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4683c166-e4d0-4cd4-220f-08d9e053640e X-MS-TrafficTypeDiagnostic: CY4PR1201MB2502:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 62pPbLpwMh2H9+5shhTm0ZsDFwPRT18ezGLtFb99fYXnmP+JSWlt0s4t8yW1qE35LpjDrGAKZphtfR30p9P0kIFNyPAbk6khvdQRK2CQUk3hpGJa+syPPzZcUu1IHM5hX6QtcnlYZsAz/4L79K7NwTdbiGl/NDltULV8AAKzV8BWS4lt890ln+RePoqQINC+JgCOV2wEF2q0rQpMsc2WV7Zk3VSIwj1Octzkv+iYVAwouWDncoMLt+sJ74FL7QNtnBuOYzWgsRAZN2Zz0xXHqYJm2njBu1uatmAz2wnZH4VuHq53RYbXot+kQILhvW4SGJVEPA77GxyX85kBIWGPe2lilVYc6Iw8Fz8fM9Etd49foysBJobRcF4GBrAm1dz8p4hwtV5Md1NNJsUyeSQ20pFUt0+7Itd3P85XHlK7yZ5LJhNZXZN61tCiQLy85v4Kp2C6O5I6uqy8MksdmuLYiwJz1YDsuB65sTeMiW05AyasVQeiZ35jQ+9vgs2veRUKqas8kyKrbO6dAwCj8NXXbebWaoh+VTBjSIGruWD/CQxWPD+r96SJfLzA4gIHXpbpKDVwYCgRkjlxPEr2nbQ6lczNREY8sceGW4KBYIBsH3i6ieHm4A9OQpEpLvVgZi+RYM3m0CKDbbxhfNSt1FDU1614FKZn+ZDuMhX+I74r1aXnaK/ihPHM83EQUzk/hmNBLy2opYJYbORIV5/zlJ0be53APtK9Qdb9ZCfKmR486i4pCyzPuJKy/CAzFWhgAcaijjX7P72AkCPQ+Nej2DyvGpJLf4VPb3urJTycszETE50= 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:(4636009)(40470700004)(36840700001)(46966006)(110136005)(508600001)(26005)(1076003)(54906003)(36756003)(316002)(7696005)(36860700001)(70206006)(5660300002)(70586007)(66574015)(86362001)(40460700003)(186003)(2616005)(44832011)(336012)(4326008)(16526019)(82310400004)(83380400001)(426003)(356005)(8936002)(81166007)(47076005)(8676002)(2906002)(6666004)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2022 22:38:21.4409 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4683c166-e4d0-4cd4-220f-08d9e053640e 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: DM6NAM11FT018.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1201MB2502 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: , Cc: horace.chen@amd.com, lijo.lazar@amd.com, jingwech@amd.com, christian.koenig@amd.com, Monk.Liu@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Restrict jobs resubmission to suspend case only since schedulers not initialised yet on probe. Signed-off-by: Andrey Grodzovsky Reviewed-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c index 5527c68c51de..8904c5a63dfa 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c @@ -582,7 +582,14 @@ void amdgpu_fence_driver_hw_init(struct amdgpu_device *adev) if (!ring || !ring->fence_drv.initialized) continue; - if (!ring->no_scheduler) { + /** + * Restrict jobs resubmission to suspend case + * only since schedulers not initialised yet on + * probe. + * + * TODO - restructure resume to make that unnecessary + */ + if (adev->in_suspend && !ring->no_scheduler) { drm_sched_resubmit_jobs(&ring->sched); drm_sched_start(&ring->sched, true); } From patchwork Tue Jan 25 22:37:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 12724285 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 96917C433EF for ; Tue, 25 Jan 2022 22:38:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7D22810E5E1; Tue, 25 Jan 2022 22:38:34 +0000 (UTC) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2058.outbound.protection.outlook.com [40.107.244.58]) by gabe.freedesktop.org (Postfix) with ESMTPS id E295D10E5C8; Tue, 25 Jan 2022 22:38:29 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lt9nkPTdZRL9ekHE6vooWpkutibm4Av2l6zI5gpAXQoZrz7LSRwHGbPuUZ/qSw0scWUB8JtoNFRd2gWcllEyzoxoryTpnqS73WsW+QjIljGi2NtrOZUs0/P3WQqd6hOa0vICdic24pyya8UN0k0z2zl9uZ8sYcI/P+ZFb5X9nlHyj3Oipg8Miz+tbPkTfjrIxOpSlKjGi3pUI+dWSCGaODNd/HKYIKuvWg0UMLwnkmcfW0hipJIbGLaqoVwntjOZE2EofbBtfSXOO5j6wv1zu6LXlsvpd7vTgu0W9MfvDul5H8mTCb0FhxUnIrx12rekfB2960pjqkH/+HUdYAJCjg== 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=eFi4K7sUyJk1N/qp/t2W0ExOzvuLVTItmEx6TJtX6Xo=; b=Vqvjg779Ij+xHasdT5x1iJjImljqu3resZXeqAzIEQ1TXUhGHYbW19Wr+j0Zz9T5Iv2qJ3squEICpjAWx85PjA07K1grScOao428sozmYz1Uh4oNYEZ/SMdmc8NZ8+39WNtbPltMu8BQmOSmibrsNmsAzmX1JzkBRxYjbR5r+oOUZPY2wh+kX2HKDs0yxE++AGe0NBcHkELZlMT+ENggLCzQoEpEJbStypebLT3kZHXXWUD8onTmGLL4tZj1joWh/BsHllJZdzz1JiW+4srg7SK0qKubvL5C5OBNDiCB36pLNKkUpduWsFodO2ZsGzOwcfaELFrtuN3X7fbNeaYzWQ== 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 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=eFi4K7sUyJk1N/qp/t2W0ExOzvuLVTItmEx6TJtX6Xo=; b=P2UistEuc7pDby7q+xcr/DEp5C8l+Mq+2SCTq0mVkK6/2jwVncgoHiBsikC+B1PgIwQelpoMYA+3hCgk4YPJAxRaAAQMuu75xDMJQv5iatwxh9cZcUrfQgFUyjfEElwnQX4GaQVTxsGotlqC898uXRBX7Rjd2ZlO2f+bnSABSh0= Received: from DM6PR02CA0057.namprd02.prod.outlook.com (2603:10b6:5:177::34) by MN2PR12MB4654.namprd12.prod.outlook.com (2603:10b6:208:1bf::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.10; Tue, 25 Jan 2022 22:38:22 +0000 Received: from DM6NAM11FT024.eop-nam11.prod.protection.outlook.com (2603:10b6:5:177:cafe::5c) by DM6PR02CA0057.outlook.office365.com (2603:10b6:5:177::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.12 via Frontend Transport; Tue, 25 Jan 2022 22:38:22 +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; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT024.mail.protection.outlook.com (10.13.172.159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4930.15 via Frontend Transport; Tue, 25 Jan 2022 22:38:22 +0000 Received: from agrodzovsky-All-Series.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.2375.18; Tue, 25 Jan 2022 16:38:21 -0600 From: Andrey Grodzovsky To: , Subject: [RFC v3 04/12] drm/amdgpu: Serialize non TDR gpu recovery with TDRs Date: Tue, 25 Jan 2022 17:37:44 -0500 Message-ID: <20220125223752.200211-5-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220125223752.200211-1-andrey.grodzovsky@amd.com> References: <20220125223752.200211-1-andrey.grodzovsky@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 082e7d24-565b-4a68-3d05-08d9e05364d8 X-MS-TrafficTypeDiagnostic: MN2PR12MB4654:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qA+nfKZOE2pHSsMi9W56+1JKizXdWS0IDSNXAOwssjGH35iPD1AO40vEsVEksqV+H11RNfZfPUiq5GavbQ5S9exv7F43B2QvcbxP/LwHsD9/hTVdTV8rYwXtdwIrQHifLNlKkHWg+Zxi0XL7A8hPhSAhTe731fRXkIA8tfcSFl4v47AxJ2YLbOIywF/IPfVDMko5xUkdRkC+iOmW/HyZDGXVHW5MHeMnNn2ofMOAWFW6T5JWAo2UkMV3EHRDTVwccIXU1jwmesmC85vPw/7znNJiqRXOYsDgDSk+VJFONcYYHARvYxPnIrFnAGKPVsN8eeRBFO6lE6XqcLlju6OcxwSnvPRv7muwXxw1Ed98Hh4KefkAO0OQTjqsc5HWfbzQPAaqTK+9aMFO+iiG5KYEEhEGmPFjHSpKPCmGH0ud2vWSayG9pldhhI6mbgqie01WuXjLvaO863/YIuk5t4hTzEtABi8g1j4MrjUT/yGaDYccT626OdhUyfI8q3iYkqY0hnx4P8SOkoqHEH9+dVEgOd4rikFfvLiB/39ZUzZys2JNbLpaDJAkQ0vJytht4CXfLBULX4oB6ixmeZhahLdTUD6UDLgyMYYQkov5tFmsLjtteXlybw6nrdisK+bGiAbBdOxixH/D5LL2zYheI91KkVPguDrtISOM39Ifvv9do2jvNC8QfNmPWctrruBxH5y6s2mz0WGXui+PwafdRzFnsEBUIJYQs9Mxwa7VVO575fASACrqD34F6LNjre09BY2KVWKvKl1nBC26w3iFkHrwNl6DdVczDljaxLuCEbMHPF8= 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:(4636009)(40470700004)(36840700001)(46966006)(81166007)(316002)(5660300002)(26005)(6666004)(70586007)(8936002)(66574015)(426003)(47076005)(356005)(110136005)(83380400001)(70206006)(44832011)(186003)(508600001)(2906002)(36756003)(8676002)(82310400004)(2616005)(36860700001)(86362001)(336012)(1076003)(7696005)(40460700003)(54906003)(16526019)(4326008)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2022 22:38:22.7498 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 082e7d24-565b-4a68-3d05-08d9e05364d8 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: DM6NAM11FT024.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4654 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: , Cc: horace.chen@amd.com, lijo.lazar@amd.com, jingwech@amd.com, christian.koenig@amd.com, Monk.Liu@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Use reset domain wq also for non TDR gpu recovery trigers such as sysfs and RAS. We must serialize all possible GPU recoveries to gurantee no concurrency there. For TDR call the original recovery function directly since it's already executed from within the wq. For others just use a wrapper to qeueue work and wait on it to finish. v2: Rename to amdgpu_recover_work_struct Signed-off-by: Andrey Grodzovsky Reviewed-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 33 +++++++++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 +- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index b5ff76aae7e0..8e96b9a14452 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -1296,6 +1296,8 @@ bool amdgpu_device_has_job_running(struct amdgpu_device *adev); bool amdgpu_device_should_recover_gpu(struct amdgpu_device *adev); int amdgpu_device_gpu_recover(struct amdgpu_device *adev, struct amdgpu_job* job); +int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev, + struct amdgpu_job *job); void amdgpu_device_pci_config_reset(struct amdgpu_device *adev); int amdgpu_device_pci_reset(struct amdgpu_device *adev); bool amdgpu_device_need_post(struct amdgpu_device *adev); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 7c063fd37389..258ec3c0b2af 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -4979,7 +4979,7 @@ static void amdgpu_device_recheck_guilty_jobs( * Returns 0 for success or an error on failure. */ -int amdgpu_device_gpu_recover(struct amdgpu_device *adev, +int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev, struct amdgpu_job *job) { struct list_head device_list, *device_list_handle = NULL; @@ -5237,6 +5237,37 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev, return r; } +struct amdgpu_recover_work_struct { + struct work_struct base; + struct amdgpu_device *adev; + struct amdgpu_job *job; + int ret; +}; + +static void amdgpu_device_queue_gpu_recover_work(struct work_struct *work) +{ + struct amdgpu_recover_work_struct *recover_work = container_of(work, struct amdgpu_recover_work_struct, base); + + recover_work->ret = amdgpu_device_gpu_recover_imp(recover_work->adev, recover_work->job); +} +/* + * Serialize gpu recover into reset domain single threaded wq + */ +int amdgpu_device_gpu_recover(struct amdgpu_device *adev, + struct amdgpu_job *job) +{ + struct amdgpu_recover_work_struct work = {.adev = adev, .job = job}; + + INIT_WORK(&work.base, amdgpu_device_queue_gpu_recover_work); + + if (!queue_work(adev->reset_domain.wq, &work.base)) + return -EAGAIN; + + flush_work(&work.base); + + return work.ret; +} + /** * amdgpu_device_get_pcie_info - fence pcie info about the PCIE slot * diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c index bfc47bea23db..38c9fd7b7ad4 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c @@ -63,7 +63,7 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job) ti.process_name, ti.tgid, ti.task_name, ti.pid); if (amdgpu_device_should_recover_gpu(ring->adev)) { - amdgpu_device_gpu_recover(ring->adev, job); + amdgpu_device_gpu_recover_imp(ring->adev, job); } else { drm_sched_suspend_timeout(&ring->sched); if (amdgpu_sriov_vf(adev)) From patchwork Tue Jan 25 22:37:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 12724282 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 2746AC433FE for ; Tue, 25 Jan 2022 22:38:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ED30310E5C8; Tue, 25 Jan 2022 22:38:32 +0000 (UTC) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2071.outbound.protection.outlook.com [40.107.223.71]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1204610E5C8; Tue, 25 Jan 2022 22:38:29 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ckXZy6hIulgGi4VJHHPO/q4BF1ATYMbuyFS21v6PIxiCw4u1xVu3lTK/lQGb8ccSUmNlZpQ13fU36V6ILHrJud4EeBHUAY5HyvQgAWPUZFvi+E+lXRtMKlfUi24oYCeDh8BytRl4Z/f6QLf0iz874lB8FWKypUmMampXwntmONGKNwyp3XUJmkCBAM7r/ZDp8Lo9Rl3HD4ZAGwjGWcPo/hxZ0VC2+JsY1FrQKiciXMVdL7rnQseqBrNe0n5Ux5ZmGylyJWTOlzwRb1pB3l/nFefCVwC/BhB3AHDABqZh8vPHoRq70rQqRjTaVRktjdRHhcX+DMhLDHnUYnEobKkrEw== 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=EXPHRz93dMIbfZthT6QahT88P9RqNy3wVpD2fnD1Fzg=; b=UmQFb2a9196rtGxulK3I5Mu/wuGPmL8+f46LjEOinOlAmbr3/JhAXks6s4lu4DPRUNggVygrKc1Wq3xmRZHrKs/dCFlN02H9IPkLY5b6aaVnciFUyxe0tBmvUkS2g6/tk4v55S3b+CBLzcYb8sasbNdM1xBkgq9yv5nV12nWlzR+Gn0tRxJohMQ0jog3pz9Hhg+TDkv/a5fiOPBWe+2CE/AnnT6TCuG1y7arHDok94iFCs3TNG9/YgXE3OfhlQWRITwkvAWg8XJq0SIKZ2nj15ty7IEXP4zbMbRcxvFR5nMrCADPVaU18UX6TblADycMC18Ph30c85Vx4AlMpH47bw== 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 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=EXPHRz93dMIbfZthT6QahT88P9RqNy3wVpD2fnD1Fzg=; b=PWe9Pe5ayu94Oz/ZSKxz6/XRlIBn1r/Xy1sPrtjgFNXTD2/hjUyiDYLD7Tj8BsOxU62TWxeU590Xz77fxHdTOxxH0uZ9IO46uSoKDAlmmfjam32wd1iT0U+IhrKIH4xsopStBZdsCD9QtlWSfnMvyWH8rGUy6zHCClPXh+6Vhn8= Received: from DM3PR03CA0014.namprd03.prod.outlook.com (2603:10b6:0:50::24) by BY5PR12MB3747.namprd12.prod.outlook.com (2603:10b6:a03:1ac::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7; Tue, 25 Jan 2022 22:38:25 +0000 Received: from DM6NAM11FT021.eop-nam11.prod.protection.outlook.com (2603:10b6:0:50:cafe::80) by DM3PR03CA0014.outlook.office365.com (2603:10b6:0:50::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.8 via Frontend Transport; Tue, 25 Jan 2022 22:38:25 +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; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT021.mail.protection.outlook.com (10.13.173.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4909.7 via Frontend Transport; Tue, 25 Jan 2022 22:38:24 +0000 Received: from agrodzovsky-All-Series.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.2375.18; Tue, 25 Jan 2022 16:38:22 -0600 From: Andrey Grodzovsky To: , Subject: [RFC v3 05/12] drm/amd/virt: For SRIOV send GPU reset directly to TDR queue. Date: Tue, 25 Jan 2022 17:37:45 -0500 Message-ID: <20220125223752.200211-6-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220125223752.200211-1-andrey.grodzovsky@amd.com> References: <20220125223752.200211-1-andrey.grodzovsky@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a585500b-5797-4afd-10f0-08d9e05365c4 X-MS-TrafficTypeDiagnostic: BY5PR12MB3747:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:949; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kf742XcC1KglmzIjfFnpuNt64EMtWj946G8zwfS6HH3XkU9q8VUzLCzTbhDJZQMoUe3NnSVpWJ4/vTFSZSOZ/xE/XTe5P72B7FCUyrCQ2dkbzlNrOaVapco9CHv1Hu4imiFmXdqZvNNmFotKmd1FzsOhvLgBdsonubnzVFzYtRpjp+xeKqvKz+1kYZWLk8mb1w9rvpYVnhPDP6Cdzb9QKd921gswfBs2DRPBWHtLi98+45LUv3KuEhBuqZfR+e9RpgXQxyCj/vio850lLW1RiYYPW/4e4Tzo0d3MhcA+mdyoLMCKrSHI3zY2h1kIn3KeRjjkyfYONI4aZ67wMIJ9BA1R2czkcfjCbCl7She4l/xhRulZytO2iCCGOu0M7jgyuJmXpkLpaomrDE0Vj+8EHoTFlF18dAeS6EWPN5WCPXFAZBQqkG1W+2T7Qhg3n9msuZ4e4hwc6effFrLN3QIvgNeMtHFl6ogMZpLbwTbyePuijrW6k8+uXG94N4MurN+Y+zq4VCw454iujtGxJHfGvPAgXXql6FSHtb3tvISNzvTnPSDfyAfhGfiSSOJG6+z5pONudZ/3g/TpdVbb0gXDgDZU7cHj9RzkfWP0+ZPuiOUF4XnG5hIY209/ewAjTDRWQy0iVWAQnd5t8ZQH/5rJ98YisBkVVMVSF3qJIoXnHdRYR5rD6wMq07zQUepmyeqQU9kx4a2pZBIcM4jXyVucySru0lQQlZNrEJuA6iixlDRtFJpI9yUPAeAGg2I6+TQuN4y48NfFATtAHvCnwhlQ2KyUgvk6gUuojDYfi6jBOYg= 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:(4636009)(40470700004)(36840700001)(46966006)(356005)(426003)(83380400001)(86362001)(81166007)(1076003)(70586007)(54906003)(4326008)(336012)(70206006)(508600001)(40460700003)(47076005)(7696005)(36860700001)(44832011)(2906002)(6666004)(2616005)(26005)(8676002)(8936002)(316002)(5660300002)(36756003)(82310400004)(186003)(110136005)(16526019)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2022 22:38:24.3110 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a585500b-5797-4afd-10f0-08d9e05365c4 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: DM6NAM11FT021.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB3747 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: , Cc: horace.chen@amd.com, lijo.lazar@amd.com, jingwech@amd.com, christian.koenig@amd.com, Monk.Liu@amd.com, Liu Shaoyun Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" No need to to trigger another work queue inside the work queue. v3: Problem: Extra reset caused by host side FLR notification following guest side triggered reset. Fix: Preven qeuing flr_work from mailbox irq if guest already executing a reset. Suggested-by: Liu Shaoyun Signed-off-by: Andrey Grodzovsky --- drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c | 9 ++++++--- drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c | 9 ++++++--- drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c | 9 ++++++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c index 23b066bcffb2..b2b40e169342 100644 --- a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c @@ -276,7 +276,7 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct *work) if (amdgpu_device_should_recover_gpu(adev) && (!amdgpu_device_has_job_running(adev) || adev->sdma_timeout == MAX_SCHEDULE_TIMEOUT)) - amdgpu_device_gpu_recover(adev, NULL); + amdgpu_device_gpu_recover_imp(adev, NULL); } static int xgpu_ai_set_mailbox_rcv_irq(struct amdgpu_device *adev, @@ -301,8 +301,11 @@ static int xgpu_ai_mailbox_rcv_irq(struct amdgpu_device *adev, switch (event) { case IDH_FLR_NOTIFICATION: - if (amdgpu_sriov_runtime(adev)) - schedule_work(&adev->virt.flr_work); + if (amdgpu_sriov_runtime(adev) && !amdgpu_in_reset(adev)) + WARN_ONCE(!queue_work(adev->reset_domain.wq, + &adev->virt.flr_work), + "Failed to queue work! at %s", + __func__); break; case IDH_QUERY_ALIVE: xgpu_ai_mailbox_send_ack(adev); diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c b/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c index a35e6d87e537..08411924150d 100644 --- a/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c +++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c @@ -308,7 +308,7 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct *work) adev->gfx_timeout == MAX_SCHEDULE_TIMEOUT || adev->compute_timeout == MAX_SCHEDULE_TIMEOUT || adev->video_timeout == MAX_SCHEDULE_TIMEOUT)) - amdgpu_device_gpu_recover(adev, NULL); + amdgpu_device_gpu_recover_imp(adev, NULL); } static int xgpu_nv_set_mailbox_rcv_irq(struct amdgpu_device *adev, @@ -336,8 +336,11 @@ static int xgpu_nv_mailbox_rcv_irq(struct amdgpu_device *adev, switch (event) { case IDH_FLR_NOTIFICATION: - if (amdgpu_sriov_runtime(adev)) - schedule_work(&adev->virt.flr_work); + if (amdgpu_sriov_runtime(adev) && !amdgpu_in_reset(adev)) + WARN_ONCE(!queue_work(adev->reset_domain.wq, + &adev->virt.flr_work), + "Failed to queue work! at %s", + __func__); break; /* READY_TO_ACCESS_GPU is fetched by kernel polling, IRQ can ignore * it byfar since that polling thread will handle it, diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c b/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c index aef9d059ae52..02290febfcf4 100644 --- a/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c +++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c @@ -521,7 +521,7 @@ static void xgpu_vi_mailbox_flr_work(struct work_struct *work) /* Trigger recovery due to world switch failure */ if (amdgpu_device_should_recover_gpu(adev)) - amdgpu_device_gpu_recover(adev, NULL); + amdgpu_device_gpu_recover_imp(adev, NULL); } static int xgpu_vi_set_mailbox_rcv_irq(struct amdgpu_device *adev, @@ -550,8 +550,11 @@ static int xgpu_vi_mailbox_rcv_irq(struct amdgpu_device *adev, r = xgpu_vi_mailbox_rcv_msg(adev, IDH_FLR_NOTIFICATION); /* only handle FLR_NOTIFY now */ - if (!r) - schedule_work(&adev->virt.flr_work); + if (!r && !amdgpu_in_reset(adev)) + WARN_ONCE(!queue_work(adev->reset_domain.wq, + &adev->virt.flr_work), + "Failed to queue work! at %s", + __func__); } return 0; From patchwork Tue Jan 25 22:37:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 12724290 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 9524EC433F5 for ; Tue, 25 Jan 2022 22:39:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0742210E60F; Tue, 25 Jan 2022 22:38:49 +0000 (UTC) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2088.outbound.protection.outlook.com [40.107.223.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id E77DF10E5C6; Tue, 25 Jan 2022 22:38:31 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MgjlTlbwn6SZFf9KHzBv9GjkEPJtoxj2A9cWlWcFPJTzvlGjyRVBXJGe++Ohfy7+hlj9kgRsSxZz4M83bq/hGR7RiGeB31G3FAoiDSkCkoRYEJwSE2f95+rB4L5ERz6g8hioO3xLxxCd6PkkPjOPsOs/d+1S6skh5R6hI2DAjVcNk+s/bfBxPcOkGATDfHce98qLUo+CbdRRsevENIgOnuPZf3pnSKyaJnRUTg2nfW3rx/CagwHMQrtTrA3+KOwqwo2f7kXlD3uZzGyI+H5mXabF4UbfAFYhHwGEO7bwgVNUnyPLda4K0KtMrsLbTC4hIyQ4/9kxg0UagaZupTLdhg== 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=KhXyC0flfwv6bNeZ29uT/mET9BrHzj+KxClAUd2H4Vw=; b=IL8Ih6M033k1Mf8H+3FocDsxZXVnh1XwpuoghhLsVlBFRfxeDbkytUD+z5ylLbvkX10zl0RGS5bVCnD+bDvKGrkGxWF8z6kGlV/zySpIkd6WKHSQFvctCRlmEQBTTXPJtGWNF+wcgl7SElExBD0wcFcI21zoWsVUdPoZopRBeTMqgxEh4dSMgMk/lEevdSepdFMi9Bfnak/xg+1FpYQPJhojtnZGg1TVAAjUtn3RxqZB0AQtuSjzB6sT9nfZqPbm8up3wWANShfjvkNW3STjMxYhmYs6cXiOt2bXSoezi+fmXpN24KyLsOV9W6AWB9lMNj45pyBgd1GO2ITKYCggFA== 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 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=KhXyC0flfwv6bNeZ29uT/mET9BrHzj+KxClAUd2H4Vw=; b=QF87UZznlSGS4XhhiA3eNmEv/FTm2LE+WpB9lke6+pYQU7IDTEO9BJkSKnNRLUwBwi4IUQtEDJOimGENAaGAum9SglLpmmP5lUE5xurakwXXoM9KTZs0yWik2g9nMvSqLzZXLq53lAS19+PRg0B6N4SeFnAFZ05dVzjKLrupcK0= Received: from DM3PR03CA0002.namprd03.prod.outlook.com (2603:10b6:0:50::12) by DM5PR12MB2472.namprd12.prod.outlook.com (2603:10b6:4:b9::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.10; Tue, 25 Jan 2022 22:38:26 +0000 Received: from DM6NAM11FT021.eop-nam11.prod.protection.outlook.com (2603:10b6:0:50:cafe::1b) by DM3PR03CA0002.outlook.office365.com (2603:10b6:0:50::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7 via Frontend Transport; Tue, 25 Jan 2022 22:38:26 +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; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT021.mail.protection.outlook.com (10.13.173.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4909.7 via Frontend Transport; Tue, 25 Jan 2022 22:38:26 +0000 Received: from agrodzovsky-All-Series.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.2375.18; Tue, 25 Jan 2022 16:38:24 -0600 From: Andrey Grodzovsky To: , Subject: [RFC v3 06/12] drm/amdgpu: Drop hive->in_reset Date: Tue, 25 Jan 2022 17:37:46 -0500 Message-ID: <20220125223752.200211-7-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220125223752.200211-1-andrey.grodzovsky@amd.com> References: <20220125223752.200211-1-andrey.grodzovsky@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3d2df4c8-bfc9-4753-d814-08d9e05366d3 X-MS-TrafficTypeDiagnostic: DM5PR12MB2472:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:923; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gV/ZDuTA+ghjIWPhcVHrQ+QnFntvSSEtStMC34a2fKAsibpOuEEVYXSJ+0d3qKbNAIl++RqY1lK+3c7jEHupBaWjEa3JEIJ7lsGoYOpTn72b5UJb8t5H81Cf/EQXeUJnWrYENG2MSYTUbdD6Pvm6frxJnpK++/3m+I3/HmwJJxMUxhsu/dkMdWgmEoACEakFekd76FHOxTepoCzKAEdzEvtK4+zlTyASqp+AGvSu8TsimAYTnde5D0/hq2ChD9DTnZAlI6kJydnhOhwPDitg/5jhbDgw9H0KcMgmjBR9nD/A6V6mxDzHnrKlWL69l6PN2mGSHCleK5tNsYZ6DOp2pW30fF9udopjBWA0l9a36XnH7gZscjJxdsOxRM//a+ym0k0lpGj3MEE3jJTG5yJfrUPiTwuoUI78cd3ccUJgGusg7aVoZnqC9dbhaZi6E7SBHMvqv1AofYtM1TkUOSDsTshVRVffrPPhowpYnp9d81uRgZaWoi5zfSp8J3Bcnzs8iCqVXHb1U+uL7T6T9ANnWyWdrI4MjO3dE+8dkT6J32diutMukviUKKyoIO3PmIJpoX4lSyE2b4D0dbjPWcL+u0+altR+Nv7H2uBg3gKjzqVrc5r8oS2cV9WHDfj/WwID41a1YXtijTANQT2rrntZkh59aD7g6fqAmJqEaTnjozUoSU6KxibkX7kH+VcOaDqST+fG2TNOtCp4VnyLRW391DJLA8gvki1XgaXycqNc9OBKgP7Slb/6F1zQx3l/zDj28m1l5wZFgWpTik3Xc/XeEBZowqXHfvlPpZZa0DHX1zo= 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:(4636009)(40470700004)(36840700001)(46966006)(36860700001)(2906002)(44832011)(36756003)(426003)(47076005)(81166007)(16526019)(8936002)(2616005)(7696005)(86362001)(82310400004)(356005)(70206006)(26005)(54906003)(336012)(186003)(4326008)(5660300002)(6666004)(66574015)(70586007)(110136005)(83380400001)(40460700003)(316002)(1076003)(508600001)(8676002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2022 22:38:26.0765 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3d2df4c8-bfc9-4753-d814-08d9e05366d3 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: DM6NAM11FT021.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB2472 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: , Cc: horace.chen@amd.com, lijo.lazar@amd.com, jingwech@amd.com, christian.koenig@amd.com, Monk.Liu@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Since we serialize all resets no need to protect from concurrent resets. Signed-off-by: Andrey Grodzovsky Reviewed-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 19 +------------------ drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 1 - drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h | 1 - 3 files changed, 1 insertion(+), 20 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 258ec3c0b2af..107a393ebbfd 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -5013,25 +5013,9 @@ int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev, dev_info(adev->dev, "GPU %s begin!\n", need_emergency_restart ? "jobs stop":"reset"); - /* - * Here we trylock to avoid chain of resets executing from - * either trigger by jobs on different adevs in XGMI hive or jobs on - * different schedulers for same device while this TO handler is running. - * We always reset all schedulers for device and all devices for XGMI - * hive so that should take care of them too. - */ hive = amdgpu_get_xgmi_hive(adev); - if (hive) { - if (atomic_cmpxchg(&hive->in_reset, 0, 1) != 0) { - DRM_INFO("Bailing on TDR for s_job:%llx, hive: %llx as another already in progress", - job ? job->base.id : -1, hive->hive_id); - amdgpu_put_xgmi_hive(hive); - if (job && job->vm) - drm_sched_increase_karma(&job->base); - return 0; - } + if (hive) mutex_lock(&hive->hive_lock); - } reset_context.method = AMD_RESET_METHOD_NONE; reset_context.reset_req_dev = adev; @@ -5227,7 +5211,6 @@ int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev, skip_recovery: if (hive) { - atomic_set(&hive->in_reset, 0); mutex_unlock(&hive->hive_lock); amdgpu_put_xgmi_hive(hive); } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c index a858e3457c5c..9ad742039ac9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c @@ -404,7 +404,6 @@ struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev) INIT_LIST_HEAD(&hive->device_list); INIT_LIST_HEAD(&hive->node); mutex_init(&hive->hive_lock); - atomic_set(&hive->in_reset, 0); atomic_set(&hive->number_devices, 0); task_barrier_init(&hive->tb); hive->pstate = AMDGPU_XGMI_PSTATE_UNKNOWN; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h index 6121aaa292cb..2f2ce53645a5 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h @@ -33,7 +33,6 @@ struct amdgpu_hive_info { struct list_head node; atomic_t number_devices; struct mutex hive_lock; - atomic_t in_reset; int hi_req_count; struct amdgpu_device *hi_req_gpu; struct task_barrier tb; From patchwork Tue Jan 25 22:37:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 12724291 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 3B303C433FE for ; Tue, 25 Jan 2022 22:39:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 424FE10E610; Tue, 25 Jan 2022 22:38:49 +0000 (UTC) Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2071.outbound.protection.outlook.com [40.107.212.71]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2B58B10E5F7; Tue, 25 Jan 2022 22:38:37 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f87On7V2vW8mXEjj8vsz6XgQ1+ng6Cwkd0UxLxy65NMsH3neAZJ2uq1fFD56sjwsMh53Adua1/BXTRkBXelUEcDq+q3JHPyK8c3xD5/dNDLsiDOSi6B22I3RtNYRnaMVvURNXP/99hGopqV/asbPKnxdl7JS0D9tYtCnOxPmE/T3dl4zWf9Frz2DlCW+Rpk8O0v4vLbOfv0IJPznzulIicY1IdU4lOfJ3/AbN2cZsZfJg3YePwuhmesWOk30t+sMJa2tMCmYCszkdwkFRQFsM1SKUm/DceZbVofCMmSEomxTOcN/X/rXODVkx7XNbDJD0qu01Cofcy6H37Vla238Zw== 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=VrOtf4AlwuVvJ7fN764PzPVSU91mOZX6pPUozlHxkB4=; b=BnBpLrtydnZd66iBOszPxYDhD0TV/ip0uV/idbparq7rxr8rK36Rg1/cqLs29LnzrsF2/SLdvF9Kk5CqlYkdVAlGY0xP+S/lVGBx3Krbvzm7h0I+6368nedVmgpoqvvUMq4X2oJBpphqBMFvWHBPP//BAw5HIbVYgXoGT9BHCJTb/cmxD1ZrWyvysiRXFDmAlmpnbo/w5IrhGptn1+JGUomXmTREvNOZStwxhErRcRf5uG8CHbsqdPCE8jYGqcHfycRWVfZvwZchU9SL/Tyu2R3x+ETPzSrSxwKESt+Zu5o39lFP04CIqkUM7n5p6y1sqzIdTVMieJ25uXcdXcUdbg== 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 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=VrOtf4AlwuVvJ7fN764PzPVSU91mOZX6pPUozlHxkB4=; b=ZqZtlw8EQB2BSUyQvMJUZZniIer2fhVkkc918nsq8WLty/6171TWha1n3LK8o2+4z3Dt52CcZInoXNqUClxr1oqnUahJgNgeZaYzZwVgFjjZdDDXK6Mfk0Ssc2hBctuZ+j7Xt8qrYShlsZzaObt5dLEKgOGxQpWP2dUiuW8jGsE= Received: from DM5PR21CA0027.namprd21.prod.outlook.com (2603:10b6:3:ed::13) by MW2PR12MB2346.namprd12.prod.outlook.com (2603:10b6:907:4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7; Tue, 25 Jan 2022 22:38:29 +0000 Received: from DM6NAM11FT033.eop-nam11.prod.protection.outlook.com (2603:10b6:3:ed:cafe::5e) by DM5PR21CA0027.outlook.office365.com (2603:10b6:3:ed::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.4 via Frontend Transport; Tue, 25 Jan 2022 22:38:28 +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; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT033.mail.protection.outlook.com (10.13.172.221) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4930.15 via Frontend Transport; Tue, 25 Jan 2022 22:38:28 +0000 Received: from agrodzovsky-All-Series.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.2375.18; Tue, 25 Jan 2022 16:38:25 -0600 From: Andrey Grodzovsky To: , Subject: [RFC v3 07/12] drm/amdgpu: Drop concurrent GPU reset protection for device Date: Tue, 25 Jan 2022 17:37:47 -0500 Message-ID: <20220125223752.200211-8-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220125223752.200211-1-andrey.grodzovsky@amd.com> References: <20220125223752.200211-1-andrey.grodzovsky@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f64dbb8b-883c-401f-d7a3-08d9e053682e X-MS-TrafficTypeDiagnostic: MW2PR12MB2346:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Hv6Uxb/mLMPPp9Py+uj7NqSy60TrnUZ8Tsu3fLPSZPXd7qXAchCsphNinI+nkJcyh7cl3ZY7cYoqQ274pmpl40N272TOMwOpM1PPKEUPuoMQyNnR7AjnLrIgCO0L1DxB3RyNFqqzPkcrUOdEdAAOgY4QtQ6H1gVUUm8YZyafunEAlmTUcNXr0cmkZajJ5Umh4Y7WORjjVoH2M3LF0OyavQ/xpWy+uSFaF63QUgiSv2m9g1CZkl8gbdyKnuE8+1VUOY3O1MMcY5ZMd6oGx8/ylRoRmQPeVeq9WJqYRSnOAcjEFnTahTzuK4AY2ar+KwoXixox2BnfnXvdfZLXvzeeTamE9R7LQzRI4UtN7rxS/Vzyq5yZimcL440FFYTCZRVv0puiLg295zWjCPhNv63UhRG4ewlYBteunYBk6h7aZPla25M6YG2mI30wiXJZuohM7gcbxDo7+gRgj+LM4T1dQcatbB2kUaHq6WOjhcWL4NEzZ30iAWcbS6RtgfiGHjqEhaWYLmvJwUxRt3GfWbeYlnHGfM5z5XBM9T5B0CVR9RvWK8c3Rk8g91k6r/H7dP5Gd6iK0TOgERAvCWwfNAQ1obE3YqivNuwX3agd5zTvmI+6VvLe5CB9RvgvcQMrUaBAq33tqmdmOOLHpf+cLo1u/sg4ec+1iXLtCacBB4nnQUaJo1MEKY6UCeRzB8o4p0lsPUCnxxERyvAPY30ovujd9sOG5c9mnUyWJtXd4fOl5lt8yLCiM2RShVu/AceV7mTYHJh7gJSqwJCBp7gdiJLbEhVmPN90+VYgOEHhHblCXKY= 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:(4636009)(40470700004)(46966006)(36840700001)(36756003)(336012)(4326008)(16526019)(2616005)(426003)(6666004)(316002)(66574015)(5660300002)(70206006)(2906002)(508600001)(110136005)(8676002)(8936002)(26005)(81166007)(70586007)(1076003)(82310400004)(47076005)(40460700003)(44832011)(83380400001)(356005)(7696005)(86362001)(186003)(36860700001)(54906003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2022 22:38:28.3349 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f64dbb8b-883c-401f-d7a3-08d9e053682e 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: DM6NAM11FT033.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR12MB2346 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: , Cc: horace.chen@amd.com, lijo.lazar@amd.com, jingwech@amd.com, christian.koenig@amd.com, Monk.Liu@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Since now all GPU resets are serialzied there is no need for this. This patch also reverts 'drm/amdgpu: race issue when jobs on 2 ring timeout' Signed-off-by: Andrey Grodzovsky Reviewed-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 89 ++-------------------- 1 file changed, 7 insertions(+), 82 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 107a393ebbfd..fef952ca8db5 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -4763,11 +4763,10 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle, return r; } -static bool amdgpu_device_lock_adev(struct amdgpu_device *adev, +static void amdgpu_device_lock_adev(struct amdgpu_device *adev, struct amdgpu_hive_info *hive) { - if (atomic_cmpxchg(&adev->in_gpu_reset, 0, 1) != 0) - return false; + atomic_set(&adev->in_gpu_reset, 1); if (hive) { down_write_nest_lock(&adev->reset_sem, &hive->hive_lock); @@ -4786,8 +4785,6 @@ static bool amdgpu_device_lock_adev(struct amdgpu_device *adev, adev->mp1_state = PP_MP1_STATE_NONE; break; } - - return true; } static void amdgpu_device_unlock_adev(struct amdgpu_device *adev) @@ -4798,46 +4795,6 @@ static void amdgpu_device_unlock_adev(struct amdgpu_device *adev) up_write(&adev->reset_sem); } -/* - * to lockup a list of amdgpu devices in a hive safely, if not a hive - * with multiple nodes, it will be similar as amdgpu_device_lock_adev. - * - * unlock won't require roll back. - */ -static int amdgpu_device_lock_hive_adev(struct amdgpu_device *adev, struct amdgpu_hive_info *hive) -{ - struct amdgpu_device *tmp_adev = NULL; - - if (adev->gmc.xgmi.num_physical_nodes > 1) { - if (!hive) { - dev_err(adev->dev, "Hive is NULL while device has multiple xgmi nodes"); - return -ENODEV; - } - list_for_each_entry(tmp_adev, &hive->device_list, gmc.xgmi.head) { - if (!amdgpu_device_lock_adev(tmp_adev, hive)) - goto roll_back; - } - } else if (!amdgpu_device_lock_adev(adev, hive)) - return -EAGAIN; - - return 0; -roll_back: - if (!list_is_first(&tmp_adev->gmc.xgmi.head, &hive->device_list)) { - /* - * if the lockup iteration break in the middle of a hive, - * it may means there may has a race issue, - * or a hive device locked up independently. - * we may be in trouble and may not, so will try to roll back - * the lock and give out a warnning. - */ - dev_warn(tmp_adev->dev, "Hive lock iteration broke in the middle. Rolling back to unlock"); - list_for_each_entry_continue_reverse(tmp_adev, &hive->device_list, gmc.xgmi.head) { - amdgpu_device_unlock_adev(tmp_adev); - } - } - return -EAGAIN; -} - static void amdgpu_device_resume_display_audio(struct amdgpu_device *adev) { struct pci_dev *p = NULL; @@ -5023,22 +4980,6 @@ int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev, reset_context.hive = hive; clear_bit(AMDGPU_NEED_FULL_RESET, &reset_context.flags); - /* - * lock the device before we try to operate the linked list - * if didn't get the device lock, don't touch the linked list since - * others may iterating it. - */ - r = amdgpu_device_lock_hive_adev(adev, hive); - if (r) { - dev_info(adev->dev, "Bailing on TDR for s_job:%llx, as another already in progress", - job ? job->base.id : -1); - - /* even we skipped this reset, still need to set the job to guilty */ - if (job && job->vm) - drm_sched_increase_karma(&job->base); - goto skip_recovery; - } - /* * Build list of devices to reset. * In case we are in XGMI hive mode, resort the device list @@ -5058,6 +4999,9 @@ int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev, /* block all schedulers and reset given job's ring */ list_for_each_entry(tmp_adev, device_list_handle, reset_list) { + + amdgpu_device_lock_adev(tmp_adev, hive); + /* * Try to put the audio codec into suspend state * before gpu reset started. @@ -5209,13 +5153,12 @@ int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev, amdgpu_device_unlock_adev(tmp_adev); } -skip_recovery: if (hive) { mutex_unlock(&hive->hive_lock); amdgpu_put_xgmi_hive(hive); } - if (r && r != -EAGAIN) + if (r) dev_info(adev->dev, "GPU reset end with ret = %d\n", r); return r; } @@ -5438,20 +5381,6 @@ int amdgpu_device_baco_exit(struct drm_device *dev) return 0; } -static void amdgpu_cancel_all_tdr(struct amdgpu_device *adev) -{ - int i; - - for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { - struct amdgpu_ring *ring = adev->rings[i]; - - if (!ring || !ring->sched.thread) - continue; - - cancel_delayed_work_sync(&ring->sched.work_tdr); - } -} - /** * amdgpu_pci_error_detected - Called when a PCI error is detected. * @pdev: PCI device struct @@ -5482,14 +5411,10 @@ pci_ers_result_t amdgpu_pci_error_detected(struct pci_dev *pdev, pci_channel_sta /* Fatal error, prepare for slot reset */ case pci_channel_io_frozen: /* - * Cancel and wait for all TDRs in progress if failing to - * set adev->in_gpu_reset in amdgpu_device_lock_adev - * * Locking adev->reset_sem will prevent any external access * to GPU during PCI error recovery */ - while (!amdgpu_device_lock_adev(adev, NULL)) - amdgpu_cancel_all_tdr(adev); + amdgpu_device_lock_adev(adev, NULL); /* * Block any work scheduling as we do for regular GPU reset From patchwork Tue Jan 25 22:37:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 12724284 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 78599C433F5 for ; Tue, 25 Jan 2022 22:38:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 927BA10E5D6; Tue, 25 Jan 2022 22:38:33 +0000 (UTC) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2062.outbound.protection.outlook.com [40.107.244.62]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4986710E5C6; Tue, 25 Jan 2022 22:38:32 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LBUshsDTePQLh2J1MNiYsnYC2ipwOGhGxDKDJRNsKk4X0TeLHErpfN6yyIasCDO6ocL51MVtW3VyMjSw3RGQbZt+Jxtq5RWCt79A6Ug9wFVYn5a544I8udAMkR7cLbdsE1RdsZx/BxGvLWSdoBVONaNDIWH5Y6F75lVIqqNUKJn4qZ6apggjQdjDgNklro59zNi6CdFt1W3HQDjuJV21+b8nJ0FscCPywDZDJjGzDxFf8VGxV7985AiB4Fi5VfvYNlb9hXDa+IMRwrYkv4sgE5nRRdLN8ZTLgPSOraWxcGOfIInGibi5ipe1r7BV1DSQZP/JgN7PQ8C4/9b4l60UvQ== 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=Tk0lmiHnwhXobIoL+v78mNejaKAHB5ZSYteesuwgxwM=; b=B3rJn0zJw1fpj6Y+f3EYrIGJ3jPjXVQ+TzSYcgfoA6fD8txjvsZ+byPXqFKDC6Glx5gl22EUbyOJhDRad/HrcnQpaqQRbGsQdYidC7Z4g4vfkuaUjsImMnxfenk/qWqprS0xHqUbdsA36J7NSPHw/wniaAxF/4Nr6FlN15KZKYroZPLZr0DPU6PhXPD2xGABMIQOBKNU6xflnXPmqs/ZPgnSm//m0CQZPZMKw8z9H1XSUj7I2IIx2hoLKFUIN2c3db3iMlrE8KcegDbtl1jOAKbijkPfhEHhZ95M56+E96tBsuG15xbKUT3JHyzwf+WQhUUcYCQMrW0Vmdwzq3rlLQ== 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 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=Tk0lmiHnwhXobIoL+v78mNejaKAHB5ZSYteesuwgxwM=; b=bRgJYdDvmhK+HlLV3Wnybru7r/2Z69au7gHG3tATd5Ru9CKeMuTBIRzjDQJ2OpmxlXx+kpZYr2ylXwoYWY8GQ0LRZLWKH80urU709F2uuDJBi1o0xdMXDbjfuydE2rPNa8YhPbALtshYxWlwEhccLYW6FUeilKbEsvREYwKskqU= Received: from DM5PR21CA0037.namprd21.prod.outlook.com (2603:10b6:3:ed::23) by CH2PR12MB3686.namprd12.prod.outlook.com (2603:10b6:610:23::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.8; Tue, 25 Jan 2022 22:38:30 +0000 Received: from DM6NAM11FT033.eop-nam11.prod.protection.outlook.com (2603:10b6:3:ed:cafe::7) by DM5PR21CA0037.outlook.office365.com (2603:10b6:3:ed::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.4 via Frontend Transport; Tue, 25 Jan 2022 22:38:30 +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; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT033.mail.protection.outlook.com (10.13.172.221) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4930.15 via Frontend Transport; Tue, 25 Jan 2022 22:38:29 +0000 Received: from agrodzovsky-All-Series.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.2375.18; Tue, 25 Jan 2022 16:38:27 -0600 From: Andrey Grodzovsky To: , Subject: [RFC v3 08/12] drm/amdgpu: Rework reset domain to be refcounted. Date: Tue, 25 Jan 2022 17:37:48 -0500 Message-ID: <20220125223752.200211-9-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220125223752.200211-1-andrey.grodzovsky@amd.com> References: <20220125223752.200211-1-andrey.grodzovsky@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bea94110-323c-4608-5533-08d9e05368f2 X-MS-TrafficTypeDiagnostic: CH2PR12MB3686:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1186; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1H2ihwTnyXcp/fe+VgJ034e2KUJHOdpF4Kf+gHGKs5dzQ+FWHwBt9+5nk529lws4+kT2Cn2ghw4lHPVnqp0asjlrWTqE6R+yQ1A1x/jJGLkXLE3bBl3zW8mFY5a35QBg42rLmOpPsjg15eUyzR2N7klNeAirSWuYQUT7kyKgFBfI3QJAhZ5URxfCKyRFlBXDfFjlhFGsT+/wnOzumcyLV+TZrK+irQXXFcYbZgDT/K2AZR2sw//5MyjVQpvv0NFS7iYSpC3RUyx5ZcC1eYkWE02HC9L1MDd2d8cwNzJyQgEWY64ubSC35lWknoP3UvRKDKI9eTdhYZjXXtAFv1MrWQa7JdU050/PuNqX/1lMpzYrNpsYiun4izNbaxPe4ZnTMgaQ6Yh8vKYw4dT2wbEOZsMlbUaaxwdtV8ArcKSWDVoGUJ7TtA73Bq3iY6NcmbHw9XPUFI4L/eyjL4QHb6d5VEOpQoWKXnhsX8CbEgXvi4R9Tfzb9V29pIrtXXj+kq3aw59VpBfcljV4MlRPk2RxuUSEI9Nn9MixApn1hExmzi0PArjfAFZXi4Y0LL7C1mKryDBilxh/DIvLFra8R5E8jWO2mOxnxWDsj/38M1j0pihlMFumwN7hEVpA3YOZ+Q7Qec038GQb98eM6FfZG669UDbFy11YxgfrkLLWs/eN2tBzQFWxpgHoWdOxVRfKxgHx5F9vUjp1Q64RmF1lSal0cKZ1TUJORqv0rjzf5rGumAYpVI+q6AbSWxH9Z1sjIDAiYDAdD30mDMZL90JpfC1zwaJDZD/ftzt3f1S40zQ/Db9fiq3yMYouEUTaF4JdqS4ljYagMqRdRIEcBIiVs/XSBBxuDGpUDHoVQRHlbwlAyf8kKFVevwdLhphG2HVMKEwQ 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:(4636009)(40470700004)(46966006)(36840700001)(47076005)(336012)(36860700001)(966005)(426003)(40460700003)(70206006)(70586007)(6666004)(8676002)(186003)(26005)(110136005)(83380400001)(4326008)(7696005)(5660300002)(44832011)(30864003)(1076003)(81166007)(82310400004)(2616005)(54906003)(508600001)(316002)(2906002)(8936002)(36756003)(16526019)(86362001)(356005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2022 22:38:29.6161 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bea94110-323c-4608-5533-08d9e05368f2 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: DM6NAM11FT033.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB3686 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: , Cc: horace.chen@amd.com, lijo.lazar@amd.com, jingwech@amd.com, christian.koenig@amd.com, Monk.Liu@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The reset domain contains register access semaphor now and so needs to be present as long as each device in a hive needs it and so it cannot be binded to XGMI hive life cycle. Adress this by making reset domain refcounted and pointed by each member of the hive and the hive itself. Signed-off-by: Andrey Grodzovsky --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 44 +++++++++++++--------- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 36 ++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 10 +++++ drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 26 ++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h | 2 +- drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c | 4 +- drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c | 4 +- drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c | 4 +- 9 files changed, 105 insertions(+), 31 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 8e96b9a14452..f2ba460bfd59 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -813,9 +813,7 @@ struct amd_powerplay { #define AMDGPU_RESET_MAGIC_NUM 64 #define AMDGPU_MAX_DF_PERFMONS 4 -struct amdgpu_reset_domain { - struct workqueue_struct *wq; -}; +struct amdgpu_reset_domain; struct amdgpu_device { struct device *dev; @@ -1102,7 +1100,7 @@ struct amdgpu_device { struct amdgpu_reset_control *reset_cntl; uint32_t ip_versions[HW_ID_MAX][HWIP_MAX_INSTANCE]; - struct amdgpu_reset_domain reset_domain; + struct amdgpu_reset_domain *reset_domain; }; static inline struct amdgpu_device *drm_to_adev(struct drm_device *ddev) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index fef952ca8db5..b24829096359 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -2313,7 +2313,7 @@ static int amdgpu_device_init_schedulers(struct amdgpu_device *adev) r = drm_sched_init(&ring->sched, &amdgpu_sched_ops, ring->num_hw_submission, amdgpu_job_hang_limit, - timeout, adev->reset_domain.wq, ring->sched_score, ring->name); + timeout, adev->reset_domain->wq, ring->sched_score, ring->name); if (r) { DRM_ERROR("Failed to create scheduler on ring %s.\n", ring->name); @@ -2432,24 +2432,22 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev) if (r) goto init_failed; + /** + * In case of XGMI grab extra reference for reset domain for this device + */ if (adev->gmc.xgmi.num_physical_nodes > 1) { - struct amdgpu_hive_info *hive; - - amdgpu_xgmi_add_device(adev); + if (amdgpu_xgmi_add_device(adev) == 0) { + struct amdgpu_hive_info *hive = amdgpu_get_xgmi_hive(adev); - hive = amdgpu_get_xgmi_hive(adev); - if (!hive || !hive->reset_domain.wq) { - DRM_ERROR("Failed to obtain reset domain info for XGMI hive:%llx", hive->hive_id); - r = -EINVAL; - goto init_failed; - } + if (!hive->reset_domain || + !kref_get_unless_zero(&hive->reset_domain->refcount)) { + r = -ENOENT; + goto init_failed; + } - adev->reset_domain.wq = hive->reset_domain.wq; - } else { - adev->reset_domain.wq = alloc_ordered_workqueue("amdgpu-reset-dev", 0); - if (!adev->reset_domain.wq) { - r = -ENOMEM; - goto init_failed; + /* Drop the early temporary reset domain we created for device */ + kref_put(&adev->reset_domain->refcount, amdgpu_reset_destroy_reset_domain); + adev->reset_domain = hive->reset_domain; } } @@ -3599,6 +3597,15 @@ int amdgpu_device_init(struct amdgpu_device *adev, return r; } + /* + * Reset domain needs to be present early, before XGMI hive discovered + * (if any) and intitialized to use reset sem and in_gpu reset flag + * early on during init. + */ + adev->reset_domain = amdgpu_reset_create_reset_domain("amdgpu-reset-dev"); + if (!adev->reset_domain) + return -ENOMEM; + /* early init functions */ r = amdgpu_device_ip_early_init(adev); if (r) @@ -3949,6 +3956,9 @@ void amdgpu_device_fini_sw(struct amdgpu_device *adev) if (adev->mman.discovery_bin) amdgpu_discovery_fini(adev); + kref_put(&adev->reset_domain->refcount, amdgpu_reset_destroy_reset_domain); + adev->reset_domain = NULL; + kfree(adev->pci_state); } @@ -5186,7 +5196,7 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev, INIT_WORK(&work.base, amdgpu_device_queue_gpu_recover_work); - if (!queue_work(adev->reset_domain.wq, &work.base)) + if (!queue_work(adev->reset_domain->wq, &work.base)) return -EAGAIN; flush_work(&work.base); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c index 02afd4115675..f2d310cd8d40 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c @@ -96,3 +96,39 @@ int amdgpu_reset_perform_reset(struct amdgpu_device *adev, return reset_handler->restore_hwcontext(adev->reset_cntl, reset_context); } + + +void amdgpu_reset_destroy_reset_domain(struct kref *ref) +{ + struct amdgpu_reset_domain *reset_domain = container_of(ref, + struct amdgpu_reset_domain, + refcount); + destroy_workqueue(reset_domain->wq); + kvfree(reset_domain); +} + +struct amdgpu_reset_domain *amdgpu_reset_create_reset_domain(char *wq_name) +{ + struct amdgpu_reset_domain *reset_domain; + + reset_domain = kvzalloc(sizeof(struct amdgpu_reset_domain), GFP_KERNEL); + if (!reset_domain) { + DRM_ERROR("Failed to allocate amdgpu_reset_domain!"); + return NULL; + } + + kref_init(&reset_domain->refcount); + + reset_domain->wq = create_singlethread_workqueue(wq_name); + if (!reset_domain->wq) { + DRM_ERROR("Failed to allocate wq for amdgpu_reset_domain!"); + kref_put(&reset_domain->refcount, amdgpu_reset_destroy_reset_domain); + return NULL; + + } + + return reset_domain; +} + + + diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h index e00d38d9160a..cd030e63e4c6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h @@ -70,6 +70,12 @@ struct amdgpu_reset_control { void (*async_reset)(struct work_struct *work); }; +struct amdgpu_reset_domain { + struct kref refcount; + struct workqueue_struct *wq; +}; + + int amdgpu_reset_init(struct amdgpu_device *adev); int amdgpu_reset_fini(struct amdgpu_device *adev); @@ -82,4 +88,8 @@ int amdgpu_reset_perform_reset(struct amdgpu_device *adev, int amdgpu_reset_add_handler(struct amdgpu_reset_control *reset_ctl, struct amdgpu_reset_handler *handler); +struct amdgpu_reset_domain *amdgpu_reset_create_reset_domain(char *wq_name); + +void amdgpu_reset_destroy_reset_domain(struct kref *ref); + #endif diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c index 9ad742039ac9..5908a3f8208a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c @@ -32,6 +32,8 @@ #include "wafl/wafl2_4_0_0_smn.h" #include "wafl/wafl2_4_0_0_sh_mask.h" +#include "amdgpu_reset.h" + #define smnPCS_XGMI23_PCS_ERROR_STATUS 0x11a01210 #define smnPCS_XGMI3X16_PCS_ERROR_STATUS 0x11a0020c #define smnPCS_GOPX1_PCS_ERROR_STATUS 0x12200210 @@ -226,6 +228,9 @@ static void amdgpu_xgmi_hive_release(struct kobject *kobj) struct amdgpu_hive_info *hive = container_of( kobj, struct amdgpu_hive_info, kobj); + kref_put(&hive->reset_domain->refcount, amdgpu_reset_destroy_reset_domain); + hive->reset_domain = NULL; + mutex_destroy(&hive->hive_lock); kfree(hive); } @@ -392,12 +397,21 @@ struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev) goto pro_end; } - hive->reset_domain.wq = alloc_ordered_workqueue("amdgpu-reset-hive", 0); - if (!hive->reset_domain.wq) { - dev_err(adev->dev, "XGMI: failed allocating wq for reset domain!\n"); - kfree(hive); - hive = NULL; - goto pro_end; + /** + * Avoid recreating reset domain when hive is reconstructed for the case + * of reset the devices in the XGMI hive during probe for SRIOV + * See https://www.spinics.net/lists/amd-gfx/msg58836.html + */ + if (!adev->reset_domain) { + hive->reset_domain = amdgpu_reset_create_reset_domain("amdgpu-reset-hive"); + if (!hive->reset_domain) { + dev_err(adev->dev, "XGMI: failed initializing reset domain for xgmi hive\n"); + ret = -ENOMEM; + kobject_put(&hive->kobj); + kfree(hive); + hive = NULL; + goto pro_end; + } } hive->hive_id = adev->gmc.xgmi.hive_id; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h index 2f2ce53645a5..dcaad22be492 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h @@ -42,7 +42,7 @@ struct amdgpu_hive_info { AMDGPU_XGMI_PSTATE_UNKNOWN } pstate; - struct amdgpu_reset_domain reset_domain; + struct amdgpu_reset_domain *reset_domain; }; struct amdgpu_pcs_ras_field { diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c index b2b40e169342..05e98af30b48 100644 --- a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c @@ -32,6 +32,8 @@ #include "soc15_common.h" #include "mxgpu_ai.h" +#include "amdgpu_reset.h" + static void xgpu_ai_mailbox_send_ack(struct amdgpu_device *adev) { WREG8(AI_MAIBOX_CONTROL_RCV_OFFSET_BYTE, 2); @@ -302,7 +304,7 @@ static int xgpu_ai_mailbox_rcv_irq(struct amdgpu_device *adev, switch (event) { case IDH_FLR_NOTIFICATION: if (amdgpu_sriov_runtime(adev) && !amdgpu_in_reset(adev)) - WARN_ONCE(!queue_work(adev->reset_domain.wq, + WARN_ONCE(!queue_work(adev->reset_domain->wq, &adev->virt.flr_work), "Failed to queue work! at %s", __func__); diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c b/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c index 08411924150d..6e12055f3f4a 100644 --- a/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c +++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c @@ -31,6 +31,8 @@ #include "soc15_common.h" #include "mxgpu_nv.h" +#include "amdgpu_reset.h" + static void xgpu_nv_mailbox_send_ack(struct amdgpu_device *adev) { WREG8(NV_MAIBOX_CONTROL_RCV_OFFSET_BYTE, 2); @@ -337,7 +339,7 @@ static int xgpu_nv_mailbox_rcv_irq(struct amdgpu_device *adev, switch (event) { case IDH_FLR_NOTIFICATION: if (amdgpu_sriov_runtime(adev) && !amdgpu_in_reset(adev)) - WARN_ONCE(!queue_work(adev->reset_domain.wq, + WARN_ONCE(!queue_work(adev->reset_domain->wq, &adev->virt.flr_work), "Failed to queue work! at %s", __func__); diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c b/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c index 02290febfcf4..fe1570c2146e 100644 --- a/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c +++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c @@ -42,6 +42,8 @@ #include "smu/smu_7_1_3_d.h" #include "mxgpu_vi.h" +#include "amdgpu_reset.h" + /* VI golden setting */ static const u32 xgpu_fiji_mgcg_cgcg_init[] = { mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xffffffff, @@ -551,7 +553,7 @@ static int xgpu_vi_mailbox_rcv_irq(struct amdgpu_device *adev, /* only handle FLR_NOTIFY now */ if (!r && !amdgpu_in_reset(adev)) - WARN_ONCE(!queue_work(adev->reset_domain.wq, + WARN_ONCE(!queue_work(adev->reset_domain->wq, &adev->virt.flr_work), "Failed to queue work! at %s", __func__); From patchwork Tue Jan 25 22:37:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 12724286 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 94971C433FE for ; Tue, 25 Jan 2022 22:38:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 55BB510E5CA; Tue, 25 Jan 2022 22:38:47 +0000 (UTC) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2053.outbound.protection.outlook.com [40.107.94.53]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0DF6610E5DE; Tue, 25 Jan 2022 22:38:35 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M1qNXwUa6k8W+bEQCxnAjp7O6C+SJMwPB2WAku3qLpXBA1mQGRKBfP2vNiXdyx7gZjItmqTVhUBJhmTC4VKXuABj4a4vw8qA4XEHPwKL/vzB3NY6q6I+O1818VKYZiV8i66ZPavFH3McBTxusIUVg35PBMW3U5NJOHR6oVT0KdpIpXNQ15bS2LONFWOF0szX+c4GwqbSklT35w67G/9I561EjuhA8pvoyXHAMFhhdRblWbK16Nke7CiEzZcxCjyThtMZGg+ut4UTPejS9TGIoouNdPWbQVG+p+wsoa0QvevfYaELN8mBwAWp6djXN/LEWJH90ZFv0gd2D0D5W+e/QQ== 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=ULSNpqazNJs7dO0hZB5CNlBxQevOI3noWFdpkMwzggA=; b=Gdz0ktzWWW3CkK+DT8GeYc7ohU10Jpoe0qtreWunSFgjOT8hFP5lUR0dVBRy9UT//EBB9XYbirHbzep6h8H1TKxRgPyPe0+TcfAL8XLx+ihaOoJUcTocDMEuKO7ezrjxiMvZJ/pgvE/2vmyXdzsh5MzFiq39jsNPGcM3U9mxHLAtknl7s23Nns8gydXTvjjwVkihMsPym6aVkxL79qDSX8MPzSJ5VSO4PLw5zT5Ioss6OASWab7xXyo7JoAn8G+FMv0HNOZCjIsb1j7utldJish8T47B6SMQQW8sEx8R0EfamJcEtm0SVN5uKLNMVTmawfRadjbxWpa6lJhMyyaeqg== 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 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=ULSNpqazNJs7dO0hZB5CNlBxQevOI3noWFdpkMwzggA=; b=Y+qXMciYjQeiymSAMKFZSI3MjfZiZbXR6JMg7T1E/07NGC417PWAehmbcFX4d46VaRpjiu99R4darlDLrAnp5n+sxP9ZPis/AX3jNidd3SKe0K733gt/kNhhnZ2OK0L4c672M/X7KvYKNJiWTyyDC3jaw3WTQqXHXilpBxuHg/o= Received: from DM5PR21CA0029.namprd21.prod.outlook.com (2603:10b6:3:ed::15) by MN2PR12MB3727.namprd12.prod.outlook.com (2603:10b6:208:15a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.13; Tue, 25 Jan 2022 22:38:31 +0000 Received: from DM6NAM11FT033.eop-nam11.prod.protection.outlook.com (2603:10b6:3:ed:cafe::d4) by DM5PR21CA0029.outlook.office365.com (2603:10b6:3:ed::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.4 via Frontend Transport; Tue, 25 Jan 2022 22:38:31 +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; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT033.mail.protection.outlook.com (10.13.172.221) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4930.15 via Frontend Transport; Tue, 25 Jan 2022 22:38:30 +0000 Received: from agrodzovsky-All-Series.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.2375.18; Tue, 25 Jan 2022 16:38:29 -0600 From: Andrey Grodzovsky To: , Subject: [RFC v3 09/12] drm/amdgpu: Move reset sem into reset_domain Date: Tue, 25 Jan 2022 17:37:49 -0500 Message-ID: <20220125223752.200211-10-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220125223752.200211-1-andrey.grodzovsky@amd.com> References: <20220125223752.200211-1-andrey.grodzovsky@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c2ffe60a-1792-4762-fd8d-08d9e053697e X-MS-TrafficTypeDiagnostic: MN2PR12MB3727:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fCHkh4gBrL/Ug329uOADomX8bmHCAI1CG/lyQR80yB32dKMPHtx2joPtlkIwhakTIklOa8U5twJlXjG80cidXM2j1FreeSl5+UxbvRJZenMJQNaFqMZmu8uRCX57xnLJV7eUbKvWVV9O1+4OJMA7vQexUPKs/QPHcaf03fAwB3kWUBdfSvx9t3RjidJEQI9FVgY33hsHy4FKDOouGXhiWRwCHjROyrluabEcXTgto1bmA9zBH5NTVZ9C+tYtLEgFDtcCWG0MQp3seL21IMlbPl3nlPeARtB2Bh9ZItS7fcWy7aSBT6C+lnrEhCTKwwd434c0iPaVpjrTdtYx2s43pf7F0vxcopNAbYIsKc9JBOkqYg9fc1EyZbQeiLX9nZAaVyt+EtieFPgWvLctwi+TpD2BujyIk76wpd9+1Up/XyBcFs63C6Dea9G8umeQkfswtpEL0XPr/xl+9rZUT3HFrzvH65rkTOlBfK4OzDvq8Sxo40lqoiee9AhNDv6YEFBrApx+bcQLaUg3krc3yZnlqP0LP5nWEFMOHvvuvNO3CPhaWuh34EKmMZZeciSB4azrJNC+Sni5zhyiMrSTKDiZaEzw5R7JPHkhj0/GLSxewqVRfuYu1LlcusZptIZVwjca4jiRMEaSiRiEJt1B6TakhqLTr+LvtbEAk8P1W3b4P7OUN8dxIawt2R6qd9FVkC/mYpClzZMa189D9m/EO/iEw+EsU3H5KQRDBTCnTHhWjECaGeemkYySX60Vn9B6sAJJqMd6ws2DB9P9kK5tJlLHHYDak/zPOiwo9XzRfoEPmVI= 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:(4636009)(40470700004)(46966006)(36840700001)(5660300002)(8676002)(36756003)(7696005)(8936002)(83380400001)(86362001)(2616005)(508600001)(26005)(426003)(186003)(40460700003)(70586007)(82310400004)(16526019)(44832011)(4326008)(47076005)(110136005)(54906003)(30864003)(1076003)(36860700001)(2906002)(81166007)(336012)(316002)(356005)(6666004)(70206006)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2022 22:38:30.5379 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c2ffe60a-1792-4762-fd8d-08d9e053697e 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: DM6NAM11FT033.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3727 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: , Cc: horace.chen@amd.com, lijo.lazar@amd.com, jingwech@amd.com, christian.koenig@amd.com, Monk.Liu@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" We want single instance of reset sem across all reset clients because in case of XGMI we should stop access cross device MMIO because any of them could be in a reset in the moment. Signed-off-by: Andrey Grodzovsky --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 - drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 10 ++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 23 +++++++++---------- .../gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c | 18 ++++++++------- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 1 + drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 6 +++-- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 14 ++++++----- drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c | 4 ++-- 10 files changed, 46 insertions(+), 37 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index f2ba460bfd59..f021cd3c9d34 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -1058,7 +1058,6 @@ struct amdgpu_device { atomic_t in_gpu_reset; enum pp_mp1_state mp1_state; - struct rw_semaphore reset_sem; struct amdgpu_doorbell_index doorbell_index; struct mutex notifier_lock; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c index 164d6a9e9fbb..e7ccd5d16e9d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c @@ -37,6 +37,8 @@ #include "amdgpu_fw_attestation.h" #include "amdgpu_umr.h" +#include "amdgpu_reset.h" + #if defined(CONFIG_DEBUG_FS) /** @@ -1279,7 +1281,7 @@ static int amdgpu_debugfs_test_ib_show(struct seq_file *m, void *unused) } /* Avoid accidently unparking the sched thread during GPU reset */ - r = down_write_killable(&adev->reset_sem); + r = down_write_killable(&adev->reset_domain->sem); if (r) return r; @@ -1308,7 +1310,7 @@ static int amdgpu_debugfs_test_ib_show(struct seq_file *m, void *unused) kthread_unpark(ring->sched.thread); } - up_write(&adev->reset_sem); + up_write(&adev->reset_domain->sem); pm_runtime_mark_last_busy(dev->dev); pm_runtime_put_autosuspend(dev->dev); @@ -1517,7 +1519,7 @@ static int amdgpu_debugfs_ib_preempt(void *data, u64 val) return -ENOMEM; /* Avoid accidently unparking the sched thread during GPU reset */ - r = down_read_killable(&adev->reset_sem); + r = down_read_killable(&adev->reset_domain->sem); if (r) goto pro_end; @@ -1560,7 +1562,7 @@ static int amdgpu_debugfs_ib_preempt(void *data, u64 val) /* restart the scheduler */ kthread_unpark(ring->sched.thread); - up_read(&adev->reset_sem); + up_read(&adev->reset_domain->sem); ttm_bo_unlock_delayed_workqueue(&adev->mman.bdev, resched); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index b24829096359..6991ab4a8191 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -423,10 +423,10 @@ bool amdgpu_device_skip_hw_access(struct amdgpu_device *adev) * the lock. */ if (in_task()) { - if (down_read_trylock(&adev->reset_sem)) - up_read(&adev->reset_sem); + if (down_read_trylock(&adev->reset_domain->sem)) + up_read(&adev->reset_domain->sem); else - lockdep_assert_held(&adev->reset_sem); + lockdep_assert_held(&adev->reset_domain->sem); } #endif return false; @@ -452,9 +452,9 @@ uint32_t amdgpu_device_rreg(struct amdgpu_device *adev, if ((reg * 4) < adev->rmmio_size) { if (!(acc_flags & AMDGPU_REGS_NO_KIQ) && amdgpu_sriov_runtime(adev) && - down_read_trylock(&adev->reset_sem)) { + down_read_trylock(&adev->reset_domain->sem)) { ret = amdgpu_kiq_rreg(adev, reg); - up_read(&adev->reset_sem); + up_read(&adev->reset_domain->sem); } else { ret = readl(((void __iomem *)adev->rmmio) + (reg * 4)); } @@ -537,9 +537,9 @@ void amdgpu_device_wreg(struct amdgpu_device *adev, if ((reg * 4) < adev->rmmio_size) { if (!(acc_flags & AMDGPU_REGS_NO_KIQ) && amdgpu_sriov_runtime(adev) && - down_read_trylock(&adev->reset_sem)) { + down_read_trylock(&adev->reset_domain->sem)) { amdgpu_kiq_wreg(adev, reg, v); - up_read(&adev->reset_sem); + up_read(&adev->reset_domain->sem); } else { writel(v, ((void __iomem *)adev->rmmio) + (reg * 4)); } @@ -3512,7 +3512,6 @@ int amdgpu_device_init(struct amdgpu_device *adev, mutex_init(&adev->virt.vf_errors.lock); hash_init(adev->mn_hash); atomic_set(&adev->in_gpu_reset, 0); - init_rwsem(&adev->reset_sem); mutex_init(&adev->psp.mutex); mutex_init(&adev->notifier_lock); @@ -4779,9 +4778,9 @@ static void amdgpu_device_lock_adev(struct amdgpu_device *adev, atomic_set(&adev->in_gpu_reset, 1); if (hive) { - down_write_nest_lock(&adev->reset_sem, &hive->hive_lock); + down_write_nest_lock(&adev->reset_domain->sem, &hive->hive_lock); } else { - down_write(&adev->reset_sem); + down_write(&adev->reset_domain->sem); } switch (amdgpu_asic_reset_method(adev)) { @@ -4802,7 +4801,7 @@ static void amdgpu_device_unlock_adev(struct amdgpu_device *adev) amdgpu_vf_error_trans_all(adev); adev->mp1_state = PP_MP1_STATE_NONE; atomic_set(&adev->in_gpu_reset, 0); - up_write(&adev->reset_sem); + up_write(&adev->reset_domain->sem); } static void amdgpu_device_resume_display_audio(struct amdgpu_device *adev) @@ -5421,7 +5420,7 @@ pci_ers_result_t amdgpu_pci_error_detected(struct pci_dev *pdev, pci_channel_sta /* Fatal error, prepare for slot reset */ case pci_channel_io_frozen: /* - * Locking adev->reset_sem will prevent any external access + * Locking adev->reset_domain->sem will prevent any external access * to GPU during PCI error recovery */ amdgpu_device_lock_adev(adev, NULL); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c index 05117eda105b..d3e055314804 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c @@ -31,6 +31,8 @@ #include #include +#include "amdgpu_reset.h" + #define EEPROM_I2C_MADDR_VEGA20 0x0 #define EEPROM_I2C_MADDR_ARCTURUS 0x40000 #define EEPROM_I2C_MADDR_ARCTURUS_D342 0x0 @@ -193,12 +195,12 @@ static int __write_table_header(struct amdgpu_ras_eeprom_control *control) __encode_table_header_to_buf(&control->tbl_hdr, buf); /* i2c may be unstable in gpu reset */ - down_read(&adev->reset_sem); + down_read(&adev->reset_domain->sem); res = amdgpu_eeprom_write(&adev->pm.smu_i2c, control->i2c_address + control->ras_header_offset, buf, RAS_TABLE_HEADER_SIZE); - up_read(&adev->reset_sem); + up_read(&adev->reset_domain->sem); if (res < 0) { DRM_ERROR("Failed to write EEPROM table header:%d", res); @@ -387,13 +389,13 @@ static int __amdgpu_ras_eeprom_write(struct amdgpu_ras_eeprom_control *control, int res; /* i2c may be unstable in gpu reset */ - down_read(&adev->reset_sem); + down_read(&adev->reset_domain->sem); buf_size = num * RAS_TABLE_RECORD_SIZE; res = amdgpu_eeprom_write(&adev->pm.smu_i2c, control->i2c_address + RAS_INDEX_TO_OFFSET(control, fri), buf, buf_size); - up_read(&adev->reset_sem); + up_read(&adev->reset_domain->sem); if (res < 0) { DRM_ERROR("Writing %d EEPROM table records error:%d", num, res); @@ -547,12 +549,12 @@ amdgpu_ras_eeprom_update_header(struct amdgpu_ras_eeprom_control *control) goto Out; } - down_read(&adev->reset_sem); + down_read(&adev->reset_domain->sem); res = amdgpu_eeprom_read(&adev->pm.smu_i2c, control->i2c_address + control->ras_record_offset, buf, buf_size); - up_read(&adev->reset_sem); + up_read(&adev->reset_domain->sem); if (res < 0) { DRM_ERROR("EEPROM failed reading records:%d\n", res); @@ -642,13 +644,13 @@ static int __amdgpu_ras_eeprom_read(struct amdgpu_ras_eeprom_control *control, int res; /* i2c may be unstable in gpu reset */ - down_read(&adev->reset_sem); + down_read(&adev->reset_domain->sem); buf_size = num * RAS_TABLE_RECORD_SIZE; res = amdgpu_eeprom_read(&adev->pm.smu_i2c, control->i2c_address + RAS_INDEX_TO_OFFSET(control, fri), buf, buf_size); - up_read(&adev->reset_sem); + up_read(&adev->reset_domain->sem); if (res < 0) { DRM_ERROR("Reading %d EEPROM table records error:%d", num, res); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c index f2d310cd8d40..011585e330f6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c @@ -127,6 +127,8 @@ struct amdgpu_reset_domain *amdgpu_reset_create_reset_domain(char *wq_name) } + init_rwsem(&reset_domain->sem); + return reset_domain; } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h index cd030e63e4c6..7451089b0c06 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h @@ -73,6 +73,7 @@ struct amdgpu_reset_control { struct amdgpu_reset_domain { struct kref refcount; struct workqueue_struct *wq; + struct rw_semaphore sem; }; diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c index 3ec5ff5a6dbe..29d3a222181e 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c @@ -48,6 +48,8 @@ #include "athub_v2_0.h" #include "athub_v2_1.h" +#include "amdgpu_reset.h" + #if 0 static const struct soc15_reg_golden golden_settings_navi10_hdp[] = { @@ -328,7 +330,7 @@ static void gmc_v10_0_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid, */ if (adev->gfx.kiq.ring.sched.ready && (amdgpu_sriov_runtime(adev) || !amdgpu_sriov_vf(adev)) && - down_read_trylock(&adev->reset_sem)) { + down_read_trylock(&adev->reset_domain->sem)) { struct amdgpu_vmhub *hub = &adev->vmhub[vmhub]; const unsigned eng = 17; u32 inv_req = hub->vmhub_funcs->get_invalidate_req(vmid, flush_type); @@ -338,7 +340,7 @@ static void gmc_v10_0_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid, amdgpu_virt_kiq_reg_write_reg_wait(adev, req, ack, inv_req, 1 << vmid); - up_read(&adev->reset_sem); + up_read(&adev->reset_domain->sem); return; } diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c index cb82404df534..d5e8d4709d8b 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c @@ -62,6 +62,8 @@ #include "amdgpu_ras.h" #include "amdgpu_xgmi.h" +#include "amdgpu_reset.h" + /* add these here since we already include dce12 headers and these are for DCN */ #define mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION 0x055d #define mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION_BASE_IDX 2 @@ -766,13 +768,13 @@ static void gmc_v9_0_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid, */ if (adev->gfx.kiq.ring.sched.ready && (amdgpu_sriov_runtime(adev) || !amdgpu_sriov_vf(adev)) && - down_read_trylock(&adev->reset_sem)) { + down_read_trylock(&adev->reset_domain->sem)) { uint32_t req = hub->vm_inv_eng0_req + hub->eng_distance * eng; uint32_t ack = hub->vm_inv_eng0_ack + hub->eng_distance * eng; amdgpu_virt_kiq_reg_write_reg_wait(adev, req, ack, inv_req, 1 << vmid); - up_read(&adev->reset_sem); + up_read(&adev->reset_domain->sem); return; } @@ -868,7 +870,7 @@ static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev, if (amdgpu_in_reset(adev)) return -EIO; - if (ring->sched.ready && down_read_trylock(&adev->reset_sem)) { + if (ring->sched.ready && down_read_trylock(&adev->reset_domain->sem)) { /* Vega20+XGMI caches PTEs in TC and TLB. Add a * heavy-weight TLB flush (type 2), which flushes * both. Due to a race condition with concurrent @@ -895,7 +897,7 @@ static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev, if (r) { amdgpu_ring_undo(ring); spin_unlock(&adev->gfx.kiq.ring_lock); - up_read(&adev->reset_sem); + up_read(&adev->reset_domain->sem); return -ETIME; } @@ -904,10 +906,10 @@ static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev, r = amdgpu_fence_wait_polling(ring, seq, adev->usec_timeout); if (r < 1) { dev_err(adev->dev, "wait for kiq fence error: %ld.\n", r); - up_read(&adev->reset_sem); + up_read(&adev->reset_domain->sem); return -ETIME; } - up_read(&adev->reset_sem); + up_read(&adev->reset_domain->sem); return 0; } diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c index 05e98af30b48..5dab06fce26a 100644 --- a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c @@ -254,7 +254,7 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct *work) * otherwise the mailbox msg will be ruined/reseted by * the VF FLR. */ - if (!down_write_trylock(&adev->reset_sem)) + if (!down_write_trylock(&adev->reset_domain->sem)) return; amdgpu_virt_fini_data_exchange(adev); @@ -272,7 +272,7 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct *work) flr_done: atomic_set(&adev->in_gpu_reset, 0); - up_write(&adev->reset_sem); + up_write(&adev->reset_domain->sem); /* Trigger recovery for world switch failure if no TDR */ if (amdgpu_device_should_recover_gpu(adev) diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c b/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c index 6e12055f3f4a..868144fff16a 100644 --- a/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c +++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c @@ -283,7 +283,7 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct *work) * otherwise the mailbox msg will be ruined/reseted by * the VF FLR. */ - if (!down_write_trylock(&adev->reset_sem)) + if (!down_write_trylock(&adev->reset_domain->sem)) return; amdgpu_virt_fini_data_exchange(adev); @@ -301,7 +301,7 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct *work) flr_done: atomic_set(&adev->in_gpu_reset, 0); - up_write(&adev->reset_sem); + up_write(&adev->reset_domain->sem); /* Trigger recovery for world switch failure if no TDR */ if (amdgpu_device_should_recover_gpu(adev) From patchwork Tue Jan 25 22:37:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 12724289 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 24C84C433EF for ; Tue, 25 Jan 2022 22:39:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E47ED10E5F7; Tue, 25 Jan 2022 22:38:47 +0000 (UTC) Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam07on2089.outbound.protection.outlook.com [40.107.95.89]) by gabe.freedesktop.org (Postfix) with ESMTPS id 03BA010E5DA; Tue, 25 Jan 2022 22:38:35 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BZ7nC8m/eWY83Q2bJwRTDt5iP5KFUsE/pBt156ZY0v9CZHTjnQgEvr2w3piOxD8AqL5mato6QFuT6VzhPD1O398XEk+BPMAa/BecjNatsZ/L6wk+zLbIIv8UqKrr09gsAVjxhCfCoSWfTjqi18GPRoPmFhNId/3LZlCCrXvC22zCqS+S98g1fDefd9a/1Yi78q4TMIbrM23SyKULgBEy7uSZfBvVE/U8mDa0xwKHOsz2UT1JVuVt3vs2XtCihtwEmCs7NJwJy6yaXEIOeGfJvV6+bDf80QhZvqRGhE86ml8+AZ7oGDYhuZTNth0fL8qR/eMm8qrIh8rYcoh4NVQQug== 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=fm5PX92PEbyjiTVhDa7CxIOGfvRFr8DJ2CxkHrnwccY=; b=jHj8DWg0sf/lWqZX9i+K5GJA2xBEOWRyz7jsKQijQVZuXyhMzYKRzyBf97jnVqUCr3d7NEmS4L5IFmpYmJQnIYHU0VUcShB2xATH6B8JhzftWqF9m7AetOQnyoJ7zL8ELA1Lkz2+hK42mpJiPrjdo71hfHCG3BRkrslkXTebvPwpIUNd8KM9TCD0knU1uXkv6e0kX7xLXmhL0rg5CJy2wTsDzM0mElHfZUvuT0mZgXK6yM8ErKhuk80gzlU+YQOxT8d5hrpQuV6U1D1darXdqf827Fj58F/o8rTjYrfLapsFpAk+vTBfnrdMIV48W/1SLUBNYN7v0Oj2UmVR3EoPGg== 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 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=fm5PX92PEbyjiTVhDa7CxIOGfvRFr8DJ2CxkHrnwccY=; b=zndcqgLqx2gMvLpcO+qegBVpzpxaPEu70qEjfnveT+EqiHXpZmRrfSMWXJmh1rRvveJ05urUyettObOrf5WRyCAcm8y+V/nD1//L5D4bgNYVWmDrsScc9aNtH89oAx3PUwzjLkyHOQQ5CdJqqTsmP47XtaC/ZPAyKpIssoV/ZO4= Received: from DM5PR21CA0041.namprd21.prod.outlook.com (2603:10b6:3:ed::27) by DM6PR12MB3516.namprd12.prod.outlook.com (2603:10b6:5:18b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.14; Tue, 25 Jan 2022 22:38:33 +0000 Received: from DM6NAM11FT033.eop-nam11.prod.protection.outlook.com (2603:10b6:3:ed:cafe::22) by DM5PR21CA0041.outlook.office365.com (2603:10b6:3:ed::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.4 via Frontend Transport; Tue, 25 Jan 2022 22:38:32 +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; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT033.mail.protection.outlook.com (10.13.172.221) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4930.15 via Frontend Transport; Tue, 25 Jan 2022 22:38:32 +0000 Received: from agrodzovsky-All-Series.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.2375.18; Tue, 25 Jan 2022 16:38:30 -0600 From: Andrey Grodzovsky To: , Subject: [RFC v3 10/12] drm/amdgpu: Move in_gpu_reset into reset_domain Date: Tue, 25 Jan 2022 17:37:50 -0500 Message-ID: <20220125223752.200211-11-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220125223752.200211-1-andrey.grodzovsky@amd.com> References: <20220125223752.200211-1-andrey.grodzovsky@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4fc5add5-76dd-453a-c312-08d9e0536aad X-MS-TrafficTypeDiagnostic: DM6PR12MB3516:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:110; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: V/NLgI01CBCh8k+Bi3QrVq/oKrKbQ4FHV8R3lix4a/4z6NWk1EDp4IZYPDp/veZgci8+76PZxSSyboG9IfkPOiSH3qf77+Xv8fiQq/TQyHilYmi8Oy+rSN4EIynswgfLHWtKJvY/beOcEeN8fbjHVNM4l7XEF5S2l5XA/XBHKf/2e7Es6ZXbgZNFcdDkcf0ZmQ4vqqZIxkO74R/cpNqDZ/NEwpaK8U/RGgGpfemPxG+xf7OBWT5NeoteE6u04F+iohzS9KyDuBQkbevV2UgX6sAqX6TGX+Yhm3pg8tlCeTt1OlmcQQEHT+FnvA0jSuOFcj3S0/nRN1f+UMvwCPKFEewpae1bTAvgK3VmqmOvWloVzbBTvnJLlGroTFVr2WyU4cFA4EteaUf227kUe2FQca9G8Q66J0z/hj6rcxsRgTUXbj50EqdQRQnB6Y5b8BC86PuZ+c5VRfHnYuUzcnXEUDFHPAzQQlRfRQnm4bI2kMH/+dr4PjfmOfKhA2FxFOvUmvg3bdHhv33/RzNMWitWH0D9N1I4AaaNZ5F5sNcYR+sa5k3uy16Vxfc+O6VfWQ+u7UFGShcXJtstU0ueLkiWm3wPsgBWjkD6kr3bDcIAfslvX2RNB+LC6CXU6J5UllmSn5bNd2tuz++SeTbURmS2AJSA9DOrxb6CPhrspgLAb+XP4eAW4Pl7JKK8TgAQY/NXs4aES7FN+xlBPbfQopZObPnNLsKz1ccd/o2FResDzmVODaQFV3iVJz8oEXZhLHZOtfxDzH3zk9RsGjHWVNEWM1bYlyPh2zRvK95sLbQLZaM= 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:(4636009)(46966006)(40470700004)(36840700001)(36860700001)(86362001)(5660300002)(44832011)(82310400004)(336012)(6666004)(40460700003)(426003)(186003)(508600001)(54906003)(26005)(16526019)(2906002)(8676002)(2616005)(70206006)(316002)(83380400001)(110136005)(4326008)(47076005)(7696005)(8936002)(81166007)(70586007)(356005)(36756003)(1076003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2022 22:38:32.5222 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4fc5add5-76dd-453a-c312-08d9e0536aad 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: DM6NAM11FT033.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3516 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: , Cc: horace.chen@amd.com, lijo.lazar@amd.com, jingwech@amd.com, christian.koenig@amd.com, Monk.Liu@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" We should have a single instance per entrire reset domain. Signed-off-by: Andrey Grodzovsky Suggested-by: Lijo Lazar --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 7 ++----- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 +++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 1 + drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c | 4 ++-- 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index f021cd3c9d34..087796e389ab 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -1056,7 +1056,6 @@ struct amdgpu_device { bool in_s4; bool in_s0ix; - atomic_t in_gpu_reset; enum pp_mp1_state mp1_state; struct amdgpu_doorbell_index doorbell_index; @@ -1461,8 +1460,6 @@ static inline bool amdgpu_is_tmz(struct amdgpu_device *adev) return adev->gmc.tmz_enabled; } -static inline int amdgpu_in_reset(struct amdgpu_device *adev) -{ - return atomic_read(&adev->in_gpu_reset); -} +int amdgpu_in_reset(struct amdgpu_device *adev); + #endif diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 6991ab4a8191..aa43af443ebe 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -3511,7 +3511,6 @@ int amdgpu_device_init(struct amdgpu_device *adev, mutex_init(&adev->mn_lock); mutex_init(&adev->virt.vf_errors.lock); hash_init(adev->mn_hash); - atomic_set(&adev->in_gpu_reset, 0); mutex_init(&adev->psp.mutex); mutex_init(&adev->notifier_lock); @@ -4775,7 +4774,7 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle, static void amdgpu_device_lock_adev(struct amdgpu_device *adev, struct amdgpu_hive_info *hive) { - atomic_set(&adev->in_gpu_reset, 1); + atomic_set(&adev->reset_domain->in_gpu_reset, 1); if (hive) { down_write_nest_lock(&adev->reset_domain->sem, &hive->hive_lock); @@ -4800,7 +4799,7 @@ static void amdgpu_device_unlock_adev(struct amdgpu_device *adev) { amdgpu_vf_error_trans_all(adev); adev->mp1_state = PP_MP1_STATE_NONE; - atomic_set(&adev->in_gpu_reset, 0); + atomic_set(&adev->reset_domain->in_gpu_reset, 0); up_write(&adev->reset_domain->sem); } @@ -5643,3 +5642,8 @@ void amdgpu_device_invalidate_hdp(struct amdgpu_device *adev, amdgpu_asic_invalidate_hdp(adev, ring); } + +int amdgpu_in_reset(struct amdgpu_device *adev) +{ + return atomic_read(&adev->reset_domain->in_gpu_reset); +} diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c index 011585e330f6..e9b804a89b34 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c @@ -127,6 +127,7 @@ struct amdgpu_reset_domain *amdgpu_reset_create_reset_domain(char *wq_name) } + atomic_set(&reset_domain->in_gpu_reset, 0); init_rwsem(&reset_domain->sem); return reset_domain; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h index 7451089b0c06..413982f4e1ce 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h @@ -74,6 +74,7 @@ struct amdgpu_reset_domain { struct kref refcount; struct workqueue_struct *wq; struct rw_semaphore sem; + atomic_t in_gpu_reset; }; diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c index 5dab06fce26a..6c79746d18db 100644 --- a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c @@ -258,7 +258,7 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct *work) return; amdgpu_virt_fini_data_exchange(adev); - atomic_set(&adev->in_gpu_reset, 1); + atomic_set(&adev->reset_domain->in_gpu_reset, 1); xgpu_ai_mailbox_trans_msg(adev, IDH_READY_TO_RESET, 0, 0, 0); @@ -271,7 +271,7 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct *work) } while (timeout > 1); flr_done: - atomic_set(&adev->in_gpu_reset, 0); + atomic_set(&adev->reset_domain->in_gpu_reset, 0); up_write(&adev->reset_domain->sem); /* Trigger recovery for world switch failure if no TDR */ diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c b/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c index 868144fff16a..39f7e1e9ab81 100644 --- a/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c +++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c @@ -287,7 +287,7 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct *work) return; amdgpu_virt_fini_data_exchange(adev); - atomic_set(&adev->in_gpu_reset, 1); + atomic_set(&adev->reset_domain->in_gpu_reset, 1); xgpu_nv_mailbox_trans_msg(adev, IDH_READY_TO_RESET, 0, 0, 0); @@ -300,7 +300,7 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct *work) } while (timeout > 1); flr_done: - atomic_set(&adev->in_gpu_reset, 0); + atomic_set(&adev->reset_domain->in_gpu_reset, 0); up_write(&adev->reset_domain->sem); /* Trigger recovery for world switch failure if no TDR */ From patchwork Tue Jan 25 22:37:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 12724288 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 9D423C433EF for ; Tue, 25 Jan 2022 22:38:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DC7EA10E5DA; Tue, 25 Jan 2022 22:38:47 +0000 (UTC) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2066.outbound.protection.outlook.com [40.107.237.66]) by gabe.freedesktop.org (Postfix) with ESMTPS id D89C910E5CA; Tue, 25 Jan 2022 22:38:36 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G6QWvHZNHtXKrPQsYxd+fRiSEKRjXaXn+a9dkAfAZMUKEC0N8juB16HHakduPk5oEo8ib5Jzlce5fq/gI4cgCTF03O+GoQC9NC1Cc+K9SDLOt0plZThg9tiLDH8kGsSB1nmPBPLjP11W1hcodZzoKR/AbANCglaA/KQy+aKRN01Xp+yDhi5h3YOx6JOQCWPu6hBlSgM739RydeHE6MF3ua8qxpOGGj98o+yxIllLlZOOQ4J4AbJHmvmseW2FlGesXa8JKzqZ0OWlFKANzMJVDOm6mdlQCJCy5qWbTLMMWrX0dUN4v9MqLGYwtG5g1iS6gmvqKshnF44fQQCRr1tJpg== 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=GZ2E8Ay0UNE69ydF/yYCWKT8PZWVh0dc91EBkG/i2p0=; b=jn753go67kvebR8bh0NOB1Vrk4mfiCF+4JeUhteOtOTAiKsXGMdE5ty+jrlu2gCE9nSVmaZ5rj+2iwksdc1z7ASAYI7sk56n2GBu+kSvMS8Dq8tr3PiRsDwaSejOCdryjdkXcdgcdasAoc2d3fHXSXNnOW6qXJJCfT2jUxSSJgd/qb5kn9yk1e9UnP5xt7WkmLti8VnYBNLPz3TuD28dtgOTIbxynnYMA6HtppSo+vFXteZ3WdgEmno7t/8+u1dtdCf0URbrzEEVtVr99fN3VlMWe9yUXa2Zyf5xRZo/ew5hYAvf8SP3GqsWJywpd74+dEycXFZgXM790RIGp+Ma9A== 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 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=GZ2E8Ay0UNE69ydF/yYCWKT8PZWVh0dc91EBkG/i2p0=; b=FcevbAt4eXlnIAHPnmQKp9TYnvr1mMo+JOoRZWfEP0tkyXO12AdsBJfW2fFVm+6qrs3J7UR7EbojsNOpQ20mCvNrwxya5iBFQD0Qskz0/+gKMhUbLbyNk/vwsCGnQ1uUcrl10UGrhh8cmSYuPdlZqanpesE1ON/P1RQZTN+8bxc= Received: from DS7P222CA0018.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::33) by CY4PR12MB1127.namprd12.prod.outlook.com (2603:10b6:903:44::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.8; Tue, 25 Jan 2022 22:38:34 +0000 Received: from DM6NAM11FT015.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2e:cafe::a2) by DS7P222CA0018.outlook.office365.com (2603:10b6:8:2e::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Tue, 25 Jan 2022 22:38:34 +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; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT015.mail.protection.outlook.com (10.13.172.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4909.7 via Frontend Transport; Tue, 25 Jan 2022 22:38:33 +0000 Received: from agrodzovsky-All-Series.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.2375.18; Tue, 25 Jan 2022 16:38:32 -0600 From: Andrey Grodzovsky To: , Subject: [RFC v3 11/12] drm/amdgpu: Rework amdgpu_device_lock_adev Date: Tue, 25 Jan 2022 17:37:51 -0500 Message-ID: <20220125223752.200211-12-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220125223752.200211-1-andrey.grodzovsky@amd.com> References: <20220125223752.200211-1-andrey.grodzovsky@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ba1378b0-1dee-4706-88c3-08d9e0536b68 X-MS-TrafficTypeDiagnostic: CY4PR12MB1127:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IrOtfvpO555IuNIPg/ySgLOZNTHtJDYwp24q9k2G2blAXpkZ6RR9Ls2JthFZ1WS73uP7jddk0GA/W+4KDphI66+f4nhtW4ISjMnwgdFhGbvngw+YD9EVTimfnPgxajYuTyXFK6ztMDtMPz0/U3LeXcvK5P/9MPcwuEl4WWPdAf0uqyKCY9dRnxA8uGPAD9n+OoJlr+a8X68Vje9IV6YKVTBuUADlfQN736D5pTLOSZBY0ejp7aeiflCr5mul50d8o99stIp5qyAWQlyxjBrJMzPuWyFUAQsPm8d6MV5m1eb5x6o9qOSFo+Dqmmn96F9Hdn30eEqCiOSJvPmLYBEgBvx6530ggR1gt4bdMHLBIWUz+kRMRXGhHAZGVk8QBGUKXxmcL5mB7DXsMQhjtyMZbzujle/V4FKe8U9Lj2HnMRJzhw+p2ATLjlYGlq4qOgy+qD8yVD8IsWU+++yd3+uXImQQkwcxzhjVPV1bOcViJuuRAFVH/orgXFV0rdSngqQTe8JkDxjkBqCQHHB9JN86hmq4cRPsDbGj0kgAnRIYs2azMQ3YtDaWVt6dLzXy7/5cmnEORJGwhTbD7sHnDfk2aFat8oNWp4QmuEdZD4M4kWZHRNzqfIs4Fi3tp0juRsXFZPbRfz15pEyOdYD92/DxoRMte1Ket+sgILh5V8fEogTC27x/QLrFvPwg2BtMRfHV4U2uWESkWJJiyjoJ9J0aI5Udbn0PIyV1evOavOUXxH0s2rtyKykjXstCo6R6k9bU0NzKGL1cX0iy8hqRXKdmKUNYfFTRxF9MdT88Raq4BaQ= 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:(4636009)(36840700001)(46966006)(40470700004)(7696005)(186003)(16526019)(2906002)(8936002)(83380400001)(44832011)(86362001)(426003)(8676002)(6666004)(508600001)(4326008)(70586007)(47076005)(82310400004)(26005)(36756003)(54906003)(2616005)(110136005)(36860700001)(336012)(70206006)(5660300002)(356005)(81166007)(40460700003)(1076003)(316002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2022 22:38:33.7774 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ba1378b0-1dee-4706-88c3-08d9e0536b68 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: DM6NAM11FT015.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1127 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: , Cc: horace.chen@amd.com, lijo.lazar@amd.com, jingwech@amd.com, christian.koenig@amd.com, Monk.Liu@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This functions needs to be split into 2 parts where one is called only once for locking single instance of reset_domain's sem and reset flag and the other part which handles MP1 states should still be called for each device in XGMI hive. Signed-off-by: Andrey Grodzovsky --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 48 ++++++++++++++++------ 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index aa43af443ebe..31310922b6bf 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -4771,16 +4771,20 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle, return r; } -static void amdgpu_device_lock_adev(struct amdgpu_device *adev, - struct amdgpu_hive_info *hive) +static void amdgpu_device_lock_reset_domain(struct amdgpu_reset_domain *reset_domain, + struct amdgpu_hive_info *hive) { - atomic_set(&adev->reset_domain->in_gpu_reset, 1); + atomic_set(&reset_domain->in_gpu_reset, 1); if (hive) { - down_write_nest_lock(&adev->reset_domain->sem, &hive->hive_lock); + down_write_nest_lock(&reset_domain->sem, &hive->hive_lock); } else { - down_write(&adev->reset_domain->sem); + down_write(&reset_domain->sem); } +} + +static void amdgpu_device_set_mp1_state(struct amdgpu_device *adev) +{ switch (amdgpu_asic_reset_method(adev)) { case AMD_RESET_METHOD_MODE1: @@ -4795,14 +4799,19 @@ static void amdgpu_device_lock_adev(struct amdgpu_device *adev, } } -static void amdgpu_device_unlock_adev(struct amdgpu_device *adev) +static void amdgpu_device_unset_mp1_state(struct amdgpu_device *adev) { amdgpu_vf_error_trans_all(adev); adev->mp1_state = PP_MP1_STATE_NONE; - atomic_set(&adev->reset_domain->in_gpu_reset, 0); - up_write(&adev->reset_domain->sem); } +static void amdgpu_device_unlock_reset_domain(struct amdgpu_reset_domain *reset_domain) +{ + atomic_set(&reset_domain->in_gpu_reset, 0); + up_write(&reset_domain->sem); +} + + static void amdgpu_device_resume_display_audio(struct amdgpu_device *adev) { struct pci_dev *p = NULL; @@ -5005,10 +5014,15 @@ int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev, device_list_handle = &device_list; } + /* We need to lock reset domain only once both for XGMI and single device */ + tmp_adev = list_first_entry(device_list_handle, struct amdgpu_device, + reset_list); + amdgpu_device_lock_reset_domain(tmp_adev->reset_domain, hive); + /* block all schedulers and reset given job's ring */ list_for_each_entry(tmp_adev, device_list_handle, reset_list) { - amdgpu_device_lock_adev(tmp_adev, hive); + amdgpu_device_set_mp1_state(tmp_adev); /* * Try to put the audio codec into suspend state @@ -5158,9 +5172,14 @@ int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev, if (audio_suspended) amdgpu_device_resume_display_audio(tmp_adev); - amdgpu_device_unlock_adev(tmp_adev); + + amdgpu_device_unset_mp1_state(tmp_adev); } + tmp_adev = list_first_entry(device_list_handle, struct amdgpu_device, + reset_list); + amdgpu_device_unlock_reset_domain(tmp_adev->reset_domain); + if (hive) { mutex_unlock(&hive->hive_lock); amdgpu_put_xgmi_hive(hive); @@ -5422,7 +5441,8 @@ pci_ers_result_t amdgpu_pci_error_detected(struct pci_dev *pdev, pci_channel_sta * Locking adev->reset_domain->sem will prevent any external access * to GPU during PCI error recovery */ - amdgpu_device_lock_adev(adev, NULL); + amdgpu_device_lock_reset_domain(adev->reset_domain, NULL); + amdgpu_device_set_mp1_state(adev); /* * Block any work scheduling as we do for regular GPU reset @@ -5529,7 +5549,8 @@ pci_ers_result_t amdgpu_pci_slot_reset(struct pci_dev *pdev) DRM_INFO("PCIe error recovery succeeded\n"); } else { DRM_ERROR("PCIe error recovery failed, err:%d", r); - amdgpu_device_unlock_adev(adev); + amdgpu_device_unset_mp1_state(adev); + amdgpu_device_unlock_reset_domain(adev->reset_domain); } return r ? PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_RECOVERED; @@ -5566,7 +5587,8 @@ void amdgpu_pci_resume(struct pci_dev *pdev) drm_sched_start(&ring->sched, true); } - amdgpu_device_unlock_adev(adev); + amdgpu_device_unset_mp1_state(adev); + amdgpu_device_unlock_reset_domain(adev->reset_domain); } bool amdgpu_device_cache_pci_state(struct pci_dev *pdev) From patchwork Tue Jan 25 22:37:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 12724287 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 AAC6CC433EF for ; Tue, 25 Jan 2022 22:38:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DEBA410E5E6; Tue, 25 Jan 2022 22:38:47 +0000 (UTC) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2067.outbound.protection.outlook.com [40.107.244.67]) by gabe.freedesktop.org (Postfix) with ESMTPS id 41E6110E5CA; Tue, 25 Jan 2022 22:38:38 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ACvAm64y16oL00Vv6KCKF23qPdnfUt8vGEaUjFvyepvbCDmwwoqCmvh+UONviL87zhFQcLkosikfW2Nib+RrbTVV9P7v9kIwrmmq7vlHeWCeAvVc4Si9ntwsenttdoP90MCxuOQ5z5xGkU18FUiaBOvurWRjZ/Oo6bzTNGn9lA9mFlgou3+PX9ccUAjUsCm0U0YIEm+vtXpHDrsFmD4hDaef8APvXhXj58SHPHxWbpSvbrgfJR6bytZ4+3TcjJFysfCqQd09+zYb8pAUQbd7CcoVkyBvZCD2nP+aZ8ehSwfKChn82gAl4SqoVa8A1iZ7CECLOyhiZ3JwZdQKiO3GPg== 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=B10OtCgYZBnhrca4d6Blqujycw2uSdGQDIW4zCZL8nU=; b=SvQYSRA1u872tptWypM7ls5BotOoeYr1wBpyypQKSNwv06gRWcPP2O6Y9BuCGLIbcc7L1XWKHPRPxgQHUVsvUXqUUFkpf9lY9KhqkE2/+4kZvDbyy5U06z5/FjZVpwFat8FHt3FJLNrX7tU8mkMLRZhNMZ/4I4gAbmH741t152puP03eDJG9/lcdqwbQu/a65C2lyoK6TMDIlv+7Dv1nCmHXHn55l92EohHhU+YaYhDzmte0IEtqaqFvBykWp0SHmMnNb7UsXGPd+LLP+xH+ewFV9KDJx3zy7gQIvFA6wVDNiPcOoD4ByHH1Ynrc/TPhFaiBJAC1gRqENKIt+TnIpA== 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 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=B10OtCgYZBnhrca4d6Blqujycw2uSdGQDIW4zCZL8nU=; b=XoHybXFcBTu3VSDznYL019aS8wqm9o5qy5dixQrKlHG41eNJu+o+3H+nY2ePneLTJDiCYz/5ejOQsav6D9PKZMGq0b5+mudsXMWUerndw7vEofPjcypCkvuyAE8E9bBi9seR6jsZ7GtxaayqqN6r4VmxbJmwhS1XxsxgmrbKV5g= Received: from DS7PR03CA0280.namprd03.prod.outlook.com (2603:10b6:5:3ad::15) by MW2PR12MB2442.namprd12.prod.outlook.com (2603:10b6:907:4::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.13; Tue, 25 Jan 2022 22:38:35 +0000 Received: from DM6NAM11FT016.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3ad:cafe::5e) by DS7PR03CA0280.outlook.office365.com (2603:10b6:5:3ad::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Tue, 25 Jan 2022 22:38:35 +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; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT016.mail.protection.outlook.com (10.13.173.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4909.7 via Frontend Transport; Tue, 25 Jan 2022 22:38:35 +0000 Received: from agrodzovsky-All-Series.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.2375.18; Tue, 25 Jan 2022 16:38:33 -0600 From: Andrey Grodzovsky To: , Subject: [RFC v3 12/12] Revert 'drm/amdgpu: annotate a false positive recursive locking' Date: Tue, 25 Jan 2022 17:37:52 -0500 Message-ID: <20220125223752.200211-13-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220125223752.200211-1-andrey.grodzovsky@amd.com> References: <20220125223752.200211-1-andrey.grodzovsky@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a2c23b58-bff0-4fc6-18ca-08d9e0536c6e X-MS-TrafficTypeDiagnostic: MW2PR12MB2442:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2657; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wNEzohstmA+3IuHfRpk794Cb/Ss9SAyapOPQAlCIGmda+68Xfr1zy0wQvcan5Mq3VtR/eITEDLPISQP+30nZjHn7vpQgeX5bGi+oK6JERz2/Go0PrDY/dtEJXDhTtQ9COO+15jdEl8+4moWGciO7JBMUxgtgV2kG7If8RC/nxxYnhMSLyOTo4mD/+ciIO2znOjfgKSCpy2Z7sGwDhOzOIt/hlA8QWUY4vo2lDbpHnCyR9XbR2Qi/ndXTMOJerj3dXwYoj0Dol0CqzRpLXdTjaglQTQkVUkxOo2iimr9T3HU8GyTj5tqBECAhaNyzgBQhDeRZVx+zZXJEQF5SuD63gGjm7Hc74s/4p8Ia+lUer6fXlIb+rBmLQOakaT9gBUd7tQjQbzAbsny8D3YtPnadD/cz3iUabToG6Xx9d/n8s6R3iMTLVCwjdxq98Jk7e6us5jIkjYrDT+IRG9qMR5i/meYw4jbWBK6Eqzf/1H7YWiOvL/Hw7zQzccvUC3P7ITRo6ZMph8Z6837uEzqZueVtrRzYTx5l7pbNFwR0vvWxX9FQDzZHBKrUk1Szfvs0lDUkYgZU+vuXO2yzHkqC4C/yFa1w8sLD8/Lu0VvoVzVRecaWhkQRnzhNH8Th2KnUOS3yd6u045T4H/jRM+LSl3is8niMCpUNmUHZgGyeNbwlJG0RCBPJy44E7u9GaVBtvd/9vmrqX7qYwNf/oEaKP/mGOetxlrSN670urQ/Ic7nDxcW6YHw9ysZ0OPbXN7XZi1iFzi/3cRiP8ymg6DrejLWJL4mp8/bM14VHLwMYMxKWpCk= 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:(4636009)(36840700001)(46966006)(40470700004)(86362001)(316002)(7696005)(83380400001)(2906002)(40460700003)(16526019)(26005)(186003)(110136005)(5660300002)(54906003)(426003)(81166007)(8936002)(8676002)(47076005)(36860700001)(336012)(1076003)(508600001)(70586007)(2616005)(4326008)(36756003)(356005)(82310400004)(44832011)(6666004)(70206006)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2022 22:38:35.4604 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a2c23b58-bff0-4fc6-18ca-08d9e0536c6e 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: DM6NAM11FT016.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR12MB2442 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: , Cc: horace.chen@amd.com, lijo.lazar@amd.com, jingwech@amd.com, christian.koenig@amd.com, Monk.Liu@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Since we have a single instance of reset semaphore which we lock only once even for XGMI hive we don't need the nested locking hint anymore. Signed-off-by: Andrey Grodzovsky --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 31310922b6bf..b97992d62db5 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -4771,16 +4771,10 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle, return r; } -static void amdgpu_device_lock_reset_domain(struct amdgpu_reset_domain *reset_domain, - struct amdgpu_hive_info *hive) +static void amdgpu_device_lock_reset_domain(struct amdgpu_reset_domain *reset_domain) { atomic_set(&reset_domain->in_gpu_reset, 1); - - if (hive) { - down_write_nest_lock(&reset_domain->sem, &hive->hive_lock); - } else { - down_write(&reset_domain->sem); - } + down_write(&reset_domain->sem); } static void amdgpu_device_set_mp1_state(struct amdgpu_device *adev) @@ -5017,7 +5011,7 @@ int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev, /* We need to lock reset domain only once both for XGMI and single device */ tmp_adev = list_first_entry(device_list_handle, struct amdgpu_device, reset_list); - amdgpu_device_lock_reset_domain(tmp_adev->reset_domain, hive); + amdgpu_device_lock_reset_domain(tmp_adev->reset_domain); /* block all schedulers and reset given job's ring */ list_for_each_entry(tmp_adev, device_list_handle, reset_list) { @@ -5441,7 +5435,7 @@ pci_ers_result_t amdgpu_pci_error_detected(struct pci_dev *pdev, pci_channel_sta * Locking adev->reset_domain->sem will prevent any external access * to GPU during PCI error recovery */ - amdgpu_device_lock_reset_domain(adev->reset_domain, NULL); + amdgpu_device_lock_reset_domain(adev->reset_domain); amdgpu_device_set_mp1_state(adev); /*