From patchwork Sat Nov 21 05:21:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 11923193 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4329C63798 for ; Sat, 21 Nov 2020 05:21:43 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6EC8522210 for ; Sat, 21 Nov 2020 05:21:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="tO10wIF1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6EC8522210 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DA5626E96C; Sat, 21 Nov 2020 05:21:37 +0000 (UTC) Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-eopbgr750081.outbound.protection.outlook.com [40.107.75.81]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5B40F6E96A; Sat, 21 Nov 2020 05:21:35 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L8XNz8iCErpODKRFJIbcAAjQSuntwiSPkmvGzFdXHE53h0jcwvmi/cFB5iyBR5v9M9zp0Ovp+J2Z0ZBAbP5P7vflS8ZgUfEBOdRPlIjAHHIbyq7QG+4Jz5jnRFanZY8FLmOvlNBSgkaPl/uL/x9EvZE9oCz+WApIbtU94+LrsswQtRsj0ih8XAeVz83gSB5vavik2c9aT/ueYlAB6uPBGqmzVOULYlC7C9oec4yINlIjnSoqfws1Bsa2xc2/0JCatZv6AF9IoWMJDuQuBAk2ZlTZQbJWLdHgi0pcxgKkoMsX9GSbHJEJVpGS1K4rw5f/9z0NQalB58DHWVh+93W1CQ== 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-SenderADCheck; bh=FQzCdtQ2K48KVtT9H/eLOa2oIZsx1AnvbxAv+rzHrsk=; b=OdEalaq7TqyjErM1O+pZyyfPRWOTXTMoZq5sJgKR8khEawmM/A73scBvgtJo44cK31XkAmdI+aUpb7v2fFbz63KhvQL13YbtMZRhGR5rcISC1NLMv1+GPeQkRlIeHv7msuDqafnGA/h0J3RAsX7Iw5K28txxtwJlt36hkNbSbI6Y15ulSU+06u57lCdCNS0Ng4zWqZWTo6nUVbVnAg3QU6OH8b+MMvUAIPHuspyra8Tv/pWXDnKrpGH335VFqx0f8ni2sd8/2MvUndcVRUJYeInAHPa3PGEVCFW2jBJcG4WMvc2QwaqyX1f2rCWClfDGaEbRmtWkMy/LPGtkX8UuCw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=fail (p=none sp=none 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=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FQzCdtQ2K48KVtT9H/eLOa2oIZsx1AnvbxAv+rzHrsk=; b=tO10wIF1P7i49BWlfV4hIZiQ5jfYJKIm93hJyextzk3NLit9ngMnn4MTyqB+W5MDVvrNyCcpeyTh1wyzCL2UfKn+HHJRBXOWsRda3SJHovgLX/ETt3LnJzx/O4vUvQVSQIJtKiTa8WlAMNq1ZcJpu4WSQJUjceattGO3aXgr+NE= Received: from DM5PR06CA0077.namprd06.prod.outlook.com (2603:10b6:3:4::15) by CH2PR12MB3861.namprd12.prod.outlook.com (2603:10b6:610:2a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.20; Sat, 21 Nov 2020 05:21:32 +0000 Received: from DM6NAM11FT040.eop-nam11.prod.protection.outlook.com (2603:10b6:3:4:cafe::6c) by DM5PR06CA0077.outlook.office365.com (2603:10b6:3:4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.20 via Frontend Transport; Sat, 21 Nov 2020 05:21:32 +0000 X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=fail action=none header.from=amd.com; Received-SPF: SoftFail (protection.outlook.com: domain of transitioning amd.com discourages use of 165.204.84.17 as permitted sender) Received: from SATLEXMB02.amd.com (165.204.84.17) by DM6NAM11FT040.mail.protection.outlook.com (10.13.173.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3589.22 via Frontend Transport; Sat, 21 Nov 2020 05:21:31 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB02.amd.com (10.181.40.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 20 Nov 2020 23:21:30 -0600 Received: from SATLEXMB01.amd.com (10.181.40.142) 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.1979.3; Fri, 20 Nov 2020 23:21:30 -0600 Received: from ubuntu-1604-test.amd.com (10.180.168.240) by SATLEXMB01.amd.com (10.181.40.142) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Fri, 20 Nov 2020 23:21:29 -0600 From: Andrey Grodzovsky To: , , , , , , , Subject: [PATCH v3 01/12] drm: Add dummy page per device or GEM object Date: Sat, 21 Nov 2020 00:21:11 -0500 Message-ID: <1605936082-3099-2-git-send-email-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1605936082-3099-1-git-send-email-andrey.grodzovsky@amd.com> References: <1605936082-3099-1-git-send-email-andrey.grodzovsky@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5f6f6e7b-0080-4ac8-a69e-08d88ddd4e56 X-MS-TrafficTypeDiagnostic: CH2PR12MB3861: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:316; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 94T2/u/IGSs574gFN6jlj2cuucGCuP7d5kP7hrtO4pmkhNee3/93NPQMFjKqVgrL0K3/qZUaPxjx96AQGPSk7TNchT8x3V/sxBA0bckFCza2SE63XbMZLTj/tZU+RYRQA3QuVAVGkayeETZLHU8c/6N5TNy08dsvPMqkDFN64QWf1g723heIhLRN9jiSHgSRB82bP5K5zpnOAeED9gZMV2hrHgRfYB7aVlBh+orGENzeDYMWLwGG+/umvmRfYeIZgWb4E+QgWKNVqp7uxuCajniRneX4BsMa/KbA/9dd5fKMz6yYsNhqk2NdTNkIV0MGrrFtqvtXM4DHDLAKy1S3ilDvHrLC4RBtggpUP/eQpIQgJMg1bYcqOroDRRdHRt21WCP8yPEPyWwGHr8vBllh2Q== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SATLEXMB02.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(376002)(396003)(136003)(39860400002)(346002)(46966005)(4326008)(82310400003)(356005)(54906003)(110136005)(478600001)(36756003)(2906002)(6666004)(336012)(5660300002)(86362001)(2616005)(81166007)(47076004)(186003)(7696005)(83380400001)(70586007)(426003)(70206006)(44832011)(26005)(8676002)(8936002)(7416002)(316002)(82740400003); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2020 05:21:31.3516 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5f6f6e7b-0080-4ac8-a69e-08d88ddd4e56 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=[SATLEXMB02.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT040.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB3861 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: Alexander.Deucher@amd.com, gregkh@linuxfoundation.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Will be used to reroute CPU mapped BO's page faults once device is removed. Signed-off-by: Andrey Grodzovsky --- drivers/gpu/drm/drm_file.c | 8 ++++++++ drivers/gpu/drm/drm_prime.c | 10 ++++++++++ include/drm/drm_file.h | 2 ++ include/drm/drm_gem.h | 2 ++ 4 files changed, 22 insertions(+) diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c index 0ac4566..ff3d39f 100644 --- a/drivers/gpu/drm/drm_file.c +++ b/drivers/gpu/drm/drm_file.c @@ -193,6 +193,12 @@ struct drm_file *drm_file_alloc(struct drm_minor *minor) goto out_prime_destroy; } + file->dummy_page = alloc_page(GFP_KERNEL | __GFP_ZERO); + if (!file->dummy_page) { + ret = -ENOMEM; + goto out_prime_destroy; + } + return file; out_prime_destroy: @@ -289,6 +295,8 @@ void drm_file_free(struct drm_file *file) if (dev->driver->postclose) dev->driver->postclose(dev, file); + __free_page(file->dummy_page); + drm_prime_destroy_file_private(&file->prime); WARN_ON(!list_empty(&file->event_list)); diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c index 1693aa7..987b45c 100644 --- a/drivers/gpu/drm/drm_prime.c +++ b/drivers/gpu/drm/drm_prime.c @@ -335,6 +335,13 @@ int drm_gem_prime_fd_to_handle(struct drm_device *dev, ret = drm_prime_add_buf_handle(&file_priv->prime, dma_buf, *handle); + + if (!ret) { + obj->dummy_page = alloc_page(GFP_KERNEL | __GFP_ZERO); + if (!obj->dummy_page) + ret = -ENOMEM; + } + mutex_unlock(&file_priv->prime.lock); if (ret) goto fail; @@ -1020,6 +1027,9 @@ void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg) dma_buf_unmap_attachment(attach, sg, DMA_BIDIRECTIONAL); dma_buf = attach->dmabuf; dma_buf_detach(attach->dmabuf, attach); + + __free_page(obj->dummy_page); + /* remove the reference */ dma_buf_put(dma_buf); } diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h index 716990b..2a011fc 100644 --- a/include/drm/drm_file.h +++ b/include/drm/drm_file.h @@ -346,6 +346,8 @@ struct drm_file { */ struct drm_prime_file_private prime; + struct page *dummy_page; + /* private: */ #if IS_ENABLED(CONFIG_DRM_LEGACY) unsigned long lock_count; /* DRI1 legacy lock count */ diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h index 337a483..76a97a3 100644 --- a/include/drm/drm_gem.h +++ b/include/drm/drm_gem.h @@ -311,6 +311,8 @@ struct drm_gem_object { * */ const struct drm_gem_object_funcs *funcs; + + struct page *dummy_page; }; /** From patchwork Sat Nov 21 05:21:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 11923195 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A59B7C388F9 for ; Sat, 21 Nov 2020 05:21:46 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4942522226 for ; Sat, 21 Nov 2020 05:21:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="WTxNutdH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4942522226 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A874B6E970; Sat, 21 Nov 2020 05:21:38 +0000 (UTC) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2081.outbound.protection.outlook.com [40.107.220.81]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2D3156E96C; Sat, 21 Nov 2020 05:21:35 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kytmUGLmC0ttygU99EWAY3bDOLkfH7yqAcgKn7dvUY7+5rEC8WKRsp4UyjRg4VupqqlCiHv6vzZyjIYWgOCdhunnAnyNaK80BpM693t6fbsBbpnQXO5cgjxKd+LTUkZvvoSzRFWRnz70mvoseDpfHGlOd7/mXHI2vAmmQyS1ZcPzwSH2j0whbcA67dDgmh/ApPu7CsYdfiIAOU04LaYQcgDYFBsOQAxBzNiin91LGY9BAyE4eepguVTFWe1BVGN9xDQFurYegDU5mrGxjyY1hJqWSPPgfgYWSBlwKM5USS7vkMjXTOWCAKcHw3DaXv2GIIv3cE9pYxnh/4ujK70nlA== 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-SenderADCheck; bh=3g4P2bOlGrOwKXmH0k0bxcxQULMQBq239UQg2DedGwo=; b=OsIyUfD+mBgC3v8X0BafC22kVnD/mb8gzLOmHnE+p/4dN7RHbiEFf3Cseo1qP1p63pAhlKs4M434PpFu2FSakxa45xdoDs05JBH08j4LnLhHWyHHvwxik83VKS49DzDlmbL+L8P4zlZ+IN7hsNMWpLXzJT305WaYzqnzhPhCURSHxLl7EIvZRdZz9EIw7wmYg4PNqY5/TE5LlRBodVuaS9/xBtS65j8ZKMrNpJ2OdJhyOnY7WpxFKf0v4Xi6OE3l5oPvi7scKQCxn3adhg5qQ/SgODQjlOaorUHSMV8jQvT2T/3zOqsliOd77jfIxMu2Pw8xzP1ZcCL7E0IorWEeGQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=fail (p=none sp=none 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=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3g4P2bOlGrOwKXmH0k0bxcxQULMQBq239UQg2DedGwo=; b=WTxNutdHxu5c9F6FtJyRDyvubvzmeDOogn7laCQwrCS6wzXxoMmmpzpdyx/k+ycPMHJd4e8e1tg4fENQl4TQbAyvf+CMgkgiXHNM3sGCQrdOv0WCed+yWK230cvS/RJMDvWy/45+N1pahDEmZEY/NWaljIyN/FYPxGR7I2IkmjQ= Received: from BN3PR05CA0036.namprd05.prod.outlook.com (2603:10b6:400::46) by MN2PR12MB3582.namprd12.prod.outlook.com (2603:10b6:208:cd::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3564.30; Sat, 21 Nov 2020 05:21:33 +0000 Received: from BN8NAM11FT030.eop-nam11.prod.protection.outlook.com (2603:10b6:400:0:cafe::a7) by BN3PR05CA0036.outlook.office365.com (2603:10b6:400::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3611.15 via Frontend Transport; Sat, 21 Nov 2020 05:21:33 +0000 X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=fail action=none header.from=amd.com; Received-SPF: SoftFail (protection.outlook.com: domain of transitioning amd.com discourages use of 165.204.84.17 as permitted sender) Received: from SATLEXMB01.amd.com (165.204.84.17) by BN8NAM11FT030.mail.protection.outlook.com (10.13.177.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3589.22 via Frontend Transport; Sat, 21 Nov 2020 05:21:32 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB01.amd.com (10.181.40.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 20 Nov 2020 23:21:32 -0600 Received: from SATLEXMB01.amd.com (10.181.40.142) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 20 Nov 2020 23:21:32 -0600 Received: from ubuntu-1604-test.amd.com (10.180.168.240) by SATLEXMB01.amd.com (10.181.40.142) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Fri, 20 Nov 2020 23:21:31 -0600 From: Andrey Grodzovsky To: , , , , , , , Subject: [PATCH v3 02/12] drm: Unamp the entire device address space on device unplug Date: Sat, 21 Nov 2020 00:21:12 -0500 Message-ID: <1605936082-3099-3-git-send-email-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1605936082-3099-1-git-send-email-andrey.grodzovsky@amd.com> References: <1605936082-3099-1-git-send-email-andrey.grodzovsky@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 74a2cc97-98b7-4dae-6493-08d88ddd4f16 X-MS-TrafficTypeDiagnostic: MN2PR12MB3582: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:773; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: terXCgw3NQ2R31REEXzV5EX2bRVljhEYDQISvJg9h2A+x94EcrCQZ+ECSDld3gVUM90DjrrRS17c/P8GD5rT8Hdp8IRjz56XYQZV6TzNPo/UQ32i/XWff6H85TBnXziA3Ghqi/2J4kKj40gTaxK+tMKahwwpzo/MtMC/4mpDXHcsJyK2TJW7fIKJUFf2fW28v7KDrEbrbcPe8PBo5hdX9ZgKD6n8S6liG3JDSVnttGpLN6tjzMA6i+QjlzoEE8uO7ayMMjnCxmuFA7ht8Zwt40TkbXPpZx5Dh86p6niNLfGPB7DF8VXZs7sZ+PON2zmNlx9188kLl+vYxsbwR3ukmu7sBcEzWnz3Ufo3am4LZ1VLC9we0vwpNzgMauyVFTBCnyRd/jS7mbJ8oINM07zJxA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SATLEXMB01.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(39860400002)(136003)(376002)(396003)(346002)(46966005)(4744005)(426003)(8676002)(336012)(70586007)(356005)(54906003)(478600001)(2616005)(82740400003)(47076004)(81166007)(70206006)(5660300002)(186003)(316002)(110136005)(44832011)(86362001)(4326008)(7696005)(36756003)(6666004)(83380400001)(8936002)(7416002)(82310400003)(2906002)(26005); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2020 05:21:32.6621 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 74a2cc97-98b7-4dae-6493-08d88ddd4f16 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=[SATLEXMB01.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT030.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3582 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: Alexander.Deucher@amd.com, gregkh@linuxfoundation.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Invalidate all BOs CPU mappings once device is removed. v3: Move the code from TTM into drm_dev_unplug Signed-off-by: Andrey Grodzovsky Reviewed-by: Christian König Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_drv.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 13068fd..d550fd5 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -479,6 +479,9 @@ void drm_dev_unplug(struct drm_device *dev) synchronize_srcu(&drm_unplug_srcu); drm_dev_unregister(dev); + + /* Clear all CPU mappings pointing to this device */ + unmap_mapping_range(dev->anon_inode->i_mapping, 0, 0, 1); } EXPORT_SYMBOL(drm_dev_unplug); From patchwork Sat Nov 21 05:21:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 11923201 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5718EC63697 for ; Sat, 21 Nov 2020 05:21:53 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0205A22210 for ; Sat, 21 Nov 2020 05:21:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="QA8Ift0D" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0205A22210 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3D3226E971; Sat, 21 Nov 2020 05:21:44 +0000 (UTC) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2042.outbound.protection.outlook.com [40.107.94.42]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1538C6E96E; Sat, 21 Nov 2020 05:21:41 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kZmU1pxwJFJ5NDbte4eH8PXQAV2dQP4ZuMfjZjRnG+KIgHVvG+SNcYAMZxKqckWuwIa98Hxr9GpiOIJx7unYstLwnVfvCqdsEpOSAH6fWMDdCdR1kmN4xElYaiJapORfhh+Rf39vtiC0AIyr03gdDO5ehiOgvh8J72CZ3ak+/htLPYKPumho1/GaVxIBQmLl//gauQ3AxZYMeiegWrrP37ymhHnLkAoKzMGoS6+/JiuPJ2alMLWaLfN8BM/L79GzjjYvhpwVP63xrIkpa3kwzSzlCksRCowWyJC+whZ1wmhjLhIziIRwnjNlcRa419r5JZ8S+ufrXk2cslY8Bnt+ZA== 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-SenderADCheck; bh=9KdivjN7Oh9cJqu9H8om7yVfPITx5vxLjTC2i/j/QHw=; b=STiggak1fnuVGFiFnz7hSXXKeJSZGDD9qa7FCMCxRNTk7xNqeJKkoyXPSEVylewamjnxALx7y6IWfLcX3AUPs9J5hjjNiQ8rhjLsMDeqhdwJZSAcedTMj0oJyI6c9B7NTgQC1STw0KjSZZ939QWFo5o3ZpdFRBIuQOSGpZvhnpkZWBfdICwoZGs7/9MHJM4pwdtGM8xqowxgOQLhPSYQgsltreR4JKSG5e5M3JEevziX6woXjkaXpbgw0tpwdh6d9GgsYmRvqdroJLXgxoWC8ZphVMpYlQ6mES0Advl6z6Naw9qNbNcr8stnKPgcCFg1qqoiqMeDVcE634Zw04cDpA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=fail (p=none sp=none 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=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9KdivjN7Oh9cJqu9H8om7yVfPITx5vxLjTC2i/j/QHw=; b=QA8Ift0DuwRWLQ8kXiseO+de0UoIMyauBt70i08lMeNwIJxy8jGaYnHwZaD+D5CQppQ1XBDIh+BqHrRsjETP21acHOAnicObwMWWcHvhSL7TcmipZZNqV+qQDlZd07EqWWHQ6wVx6t1FtnlMHcahcAQzM3kJ76Ntrss/k+9HVrQ= Received: from DM6PR06CA0093.namprd06.prod.outlook.com (2603:10b6:5:336::26) by BYAPR12MB4629.namprd12.prod.outlook.com (2603:10b6:a03:111::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.25; Sat, 21 Nov 2020 05:21:35 +0000 Received: from DM6NAM11FT062.eop-nam11.prod.protection.outlook.com (2603:10b6:5:336:cafe::74) by DM6PR06CA0093.outlook.office365.com (2603:10b6:5:336::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.20 via Frontend Transport; Sat, 21 Nov 2020 05:21:34 +0000 X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=fail action=none header.from=amd.com; Received-SPF: SoftFail (protection.outlook.com: domain of transitioning amd.com discourages use of 165.204.84.17 as permitted sender) Received: from SATLEXMB02.amd.com (165.204.84.17) by DM6NAM11FT062.mail.protection.outlook.com (10.13.173.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3589.22 via Frontend Transport; Sat, 21 Nov 2020 05:21:34 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB02.amd.com (10.181.40.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 20 Nov 2020 23:21:33 -0600 Received: from SATLEXMB01.amd.com (10.181.40.142) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 20 Nov 2020 23:21:33 -0600 Received: from ubuntu-1604-test.amd.com (10.180.168.240) by SATLEXMB01.amd.com (10.181.40.142) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Fri, 20 Nov 2020 23:21:32 -0600 From: Andrey Grodzovsky To: , , , , , , , Subject: [PATCH v3 03/12] drm/ttm: Remap all page faults to per process dummy page. Date: Sat, 21 Nov 2020 00:21:13 -0500 Message-ID: <1605936082-3099-4-git-send-email-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1605936082-3099-1-git-send-email-andrey.grodzovsky@amd.com> References: <1605936082-3099-1-git-send-email-andrey.grodzovsky@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1eeaaa99-cfac-4a5a-7d7e-08d88ddd5015 X-MS-TrafficTypeDiagnostic: BYAPR12MB4629: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1186; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JATpGtlXXpyRwVcnbMAbRBcxlu4FmW442Mb++mlix+0p8n2cT11kx8DPBOf8w9o600nyDbBB40/ZZlWrLwMyzIMpYa2HKeZJEIwbniNSs76d+OHQoAFDr0k0csN/UaJ4WYrGv/pf6Vp34auBb3ZlW+W/sc4OcZVQqAdNyYtO12CKWEROh5oRqfX36+o3EbYjbR90Ct62jS76TxH7P7v2pM42R7iOjlcgCwfGEYUqNhN+ZeGbxRABQqY0/mXWf8PNV2dsOf4c075gOWBVUe7EfOlf2ButxhL5/H7qJmblycpgd6WbypYdtXvv4gK1JE1G+u5N7tYIy8WxEzztzS9jjXODt+7KYPHKRWXyRhvZYX9K7Y5/5uj5hJSFSBJhkXb1zq+wee6SZdLyP803Xe26KQ== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SATLEXMB02.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(136003)(376002)(39860400002)(396003)(346002)(46966005)(7416002)(36756003)(2906002)(316002)(110136005)(54906003)(83380400001)(6666004)(356005)(70586007)(70206006)(478600001)(4326008)(82740400003)(44832011)(81166007)(5660300002)(426003)(186003)(26005)(336012)(2616005)(8936002)(8676002)(82310400003)(47076004)(86362001)(7696005); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2020 05:21:34.2830 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1eeaaa99-cfac-4a5a-7d7e-08d88ddd5015 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=[SATLEXMB02.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT062.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB4629 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: Alexander.Deucher@amd.com, gregkh@linuxfoundation.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On device removal reroute all CPU mappings to dummy page per drm_file instance or imported GEM object. v3: Remove loop to find DRM file and instead access it by vma->vm_file->private_data. Move dummy page installation into a separate function. Signed-off-by: Andrey Grodzovsky --- drivers/gpu/drm/ttm/ttm_bo_vm.c | 54 +++++++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c index 01693e8..f2dbb93 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c @@ -35,6 +35,8 @@ #include #include #include +#include +#include #include #include #include @@ -420,23 +422,59 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf, } EXPORT_SYMBOL(ttm_bo_vm_fault_reserved); +vm_fault_t ttm_bo_vm_dummy_page(struct vm_fault *vmf) +{ + struct vm_area_struct *vma = vmf->vma; + struct ttm_buffer_object *bo = vma->vm_private_data; + struct drm_file *file = NULL; + struct page *dummy_page = NULL; + + /* We are faulting on imported BO from dma_buf */ + if (bo->base.dma_buf && bo->base.import_attach) { + dummy_page = bo->base.dummy_page; + /* We are faulting on local BO */ + } else { + file = vma->vm_file->private_data; + dummy_page = file->dummy_page; + } + + /* Let do_fault complete the PTE install e.t.c using vmf->page */ + get_page(dummy_page); + vmf->page = dummy_page; + + return 0; +} + vm_fault_t ttm_bo_vm_fault(struct vm_fault *vmf) { struct vm_area_struct *vma = vmf->vma; pgprot_t prot; struct ttm_buffer_object *bo = vma->vm_private_data; vm_fault_t ret; + int idx; + struct drm_device *ddev = bo->base.dev; - ret = ttm_bo_vm_reserve(bo, vmf); - if (ret) - return ret; - prot = vma->vm_page_prot; - ret = ttm_bo_vm_fault_reserved(vmf, prot, TTM_BO_VM_NUM_PREFAULT, 1); - if (ret == VM_FAULT_RETRY && !(vmf->flags & FAULT_FLAG_RETRY_NOWAIT)) - return ret; + if (!drm_dev_enter(ddev, &idx)) { + ret = ttm_bo_vm_dummy_page(vmf); + if (ret) + return ret; + } else { + ret = ttm_bo_vm_reserve(bo, vmf); + if (ret) + goto exit; - dma_resv_unlock(bo->base.resv); + prot = vma->vm_page_prot; + + ret = ttm_bo_vm_fault_reserved(vmf, prot, TTM_BO_VM_NUM_PREFAULT, 1); + if (ret == VM_FAULT_RETRY && !(vmf->flags & FAULT_FLAG_RETRY_NOWAIT)) + goto exit; + + dma_resv_unlock(bo->base.resv); + +exit: + drm_dev_exit(idx); + } return ret; } From patchwork Sat Nov 21 05:21:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 11923199 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B80CC388F9 for ; Sat, 21 Nov 2020 05:21:51 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2E25122210 for ; Sat, 21 Nov 2020 05:21:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="dk/NZ+7c" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2E25122210 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AFD9C6E977; Sat, 21 Nov 2020 05:21:44 +0000 (UTC) Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-eopbgr750073.outbound.protection.outlook.com [40.107.75.73]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0D6306E96D; Sat, 21 Nov 2020 05:21:38 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L5XdZlvXMZjuY61dMz+1K4reHUNmJ0QAD9qcBMBgOV+k1EJZyUipO+z3FPkf4hzSE+6C009h9PHSvb3PUCyKf8RbSMpiQdFHLEvOZqlDDXS57hRSXZfzSILdqK187GX6y6ywuBzdB7lcm/RF7NHDOE8ctsB3mG74dNPX2ikyWCQ+7CDfZ8EYHR786ZlrXiHTUyvmC78WACPegSAu/1UQFiksQ0uTAdcz5T7LiB9+G8LMv7UQNE9hti5nztShh6dB53Jf6ZUgnhcg0+b+7vHOD1uJlIHCDvTS0DDtSbUVqgoGv2SQ6Si6UYFfechaVvYe40bBZRbJSvT7v9j1+Ccigg== 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-SenderADCheck; bh=BRfmHleFpu2ppDhY+aqpqxcLDIiMPfMYW1MsRlV9bCw=; b=D3KU/5tUoJQWp8CVt+XOnZffmpVdDu3+8F89EorzD7Ev+7dT9zc82+I8mX8Nf8n+Ns9ToDUcYuWRTep86X/hKw0fTk8dt7EOQIn0nBcA9nxxYv3ZQrMbAzqKzkaUPGU0pjXjPD/CL7SLboOzLY6mI25MR3Rl49HMh/5o4jZM7r/vukwEvXW9Mc3iG8cXuYEpPHNEPnk0d0sgpkclSpa4bHRuP770L9NtfhpUl2LMcDD9Mzi3ndehmOxR2A1eBIWTRGBAccViQAvy+b37HzzaS7qqHaaWBrmkPZ+SWhLmeNnriMLAUcFmoX298XxLVdYD+sMWqt8Xx3Ge8wiqH266kA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=fail (p=none sp=none 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=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BRfmHleFpu2ppDhY+aqpqxcLDIiMPfMYW1MsRlV9bCw=; b=dk/NZ+7cAIYN9bftAe/YayGD7aNq2W2tHtc4+iH3OO7MHxGmgK3dwCopBEtTum3ghXWMRfRaKjAxmMp9iq1PSOuQL4lrvzXxmKjyJr5EVMv1ui6sUVvz46yXsaCwhnpgsSydi7AG7ruR31nkfXX3fm5Heajt5R6Dqvztbq/Lvds= Received: from BN6PR2001CA0014.namprd20.prod.outlook.com (2603:10b6:404:b4::24) by DM6PR12MB3130.namprd12.prod.outlook.com (2603:10b6:5:11b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.22; Sat, 21 Nov 2020 05:21:36 +0000 Received: from BN8NAM11FT015.eop-nam11.prod.protection.outlook.com (2603:10b6:404:b4:cafe::68) by BN6PR2001CA0014.outlook.office365.com (2603:10b6:404:b4::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.20 via Frontend Transport; Sat, 21 Nov 2020 05:21:35 +0000 X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=fail action=none header.from=amd.com; Received-SPF: SoftFail (protection.outlook.com: domain of transitioning amd.com discourages use of 165.204.84.17 as permitted sender) Received: from SATLEXMB01.amd.com (165.204.84.17) by BN8NAM11FT015.mail.protection.outlook.com (10.13.176.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3589.22 via Frontend Transport; Sat, 21 Nov 2020 05:21:35 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB01.amd.com (10.181.40.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 20 Nov 2020 23:21:35 -0600 Received: from SATLEXMB01.amd.com (10.181.40.142) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 20 Nov 2020 23:21:34 -0600 Received: from ubuntu-1604-test.amd.com (10.180.168.240) by SATLEXMB01.amd.com (10.181.40.142) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Fri, 20 Nov 2020 23:21:34 -0600 From: Andrey Grodzovsky To: , , , , , , , Subject: [PATCH v3 04/12] drm/ttm: Set dma addr to null after freee Date: Sat, 21 Nov 2020 00:21:14 -0500 Message-ID: <1605936082-3099-5-git-send-email-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1605936082-3099-1-git-send-email-andrey.grodzovsky@amd.com> References: <1605936082-3099-1-git-send-email-andrey.grodzovsky@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1dd688e1-307d-40c9-591b-08d88ddd50b4 X-MS-TrafficTypeDiagnostic: DM6PR12MB3130: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:243; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BLVZSlqgTCluOLrK5pePv0UqK+R51gPx7AK67Py4KQAncsnMKcY5+/S2NFJweZg9Q6XX53Peg+sPktnbFCNHLrXfTAbXqAXropdgopq4eg/jXffjABPqYmIaJyL8LDjc6DEG/dLiT/643+STrLYblh4IWeUVcsqOzCvevVTfw3zTNbyfSHVXKoEJEVnHfC/rmGePufa0nTqh4daNcIYhQwkHx3bJ2EbiEuDS+odOov5ddKQtQ0bvTKozL6cHqlzoJ/6kHIOScmGL4R+xjZrEf7WLZMA+ejzBsYnWve+3wWtvzcFUOm3ZFLvNbDWLm3YSsgKT4wfhzntk83Fgya7NZPn/QD018rOM3gVyMJxHDUEXqIDOUpH3Z2ktnqY13NZfgSynBFC+P7+cI5zEbmW/OGoY3NjKVgxAl9z+1KL8W38= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SATLEXMB01.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(39860400002)(396003)(136003)(346002)(376002)(46966005)(426003)(8676002)(336012)(4326008)(70206006)(5660300002)(2906002)(4744005)(6666004)(8936002)(2616005)(54906003)(44832011)(70586007)(186003)(86362001)(47076004)(82740400003)(316002)(110136005)(36756003)(7416002)(81166007)(7696005)(356005)(82310400003)(26005)(478600001)(127203001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2020 05:21:35.3760 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1dd688e1-307d-40c9-591b-08d88ddd50b4 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=[SATLEXMB01.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT015.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3130 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: Alexander.Deucher@amd.com, gregkh@linuxfoundation.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Fixes oops. Signed-off-by: Andrey Grodzovsky --- drivers/gpu/drm/ttm/ttm_page_alloc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c index b40a467..b0df328 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c @@ -1160,6 +1160,8 @@ void ttm_unmap_and_unpopulate_pages(struct device *dev, struct ttm_dma_tt *tt) dma_unmap_page(dev, tt->dma_address[i], num_pages * PAGE_SIZE, DMA_BIDIRECTIONAL); + tt->dma_address[i] = 0; + i += num_pages; } ttm_pool_unpopulate(&tt->ttm); From patchwork Sat Nov 21 05:21:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 11923197 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F17ADC63798 for ; Sat, 21 Nov 2020 05:21:49 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9329822210 for ; Sat, 21 Nov 2020 05:21:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="blS/lK10" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9329822210 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F21F36E973; Sat, 21 Nov 2020 05:21:43 +0000 (UTC) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2077.outbound.protection.outlook.com [40.107.237.77]) by gabe.freedesktop.org (Postfix) with ESMTPS id 802596E96E; Sat, 21 Nov 2020 05:21:39 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DYdHVGhhGHaQ0Aln5NqYN9Ol5NUaWV6B7Lm9hwBglc4CRnc/4bm3YEf0fHMaC27drpA8xMv8E2svIVA05ZXcKW8f7rCXXrIvGYOMheUsYlm7cKcTg89EgUZRDWAiKSFWhBgsCxHjHh+X9Qi0KgxseIfyzJerRpp9T01ZASkhFj87+1XXew2+c3wEoEgNQn8SrjNTfvDCKTD3s9NBwtzMzwtpmpJp5Sy8ZBdoVi6j2EzwBknaFbaNwPNGXu9k0f5qVuUv2/RpvFPeF9ylE9o1yM1elLB67IfOLfxhwJpuxEDKMP52zwHIQlWbyUrUANKGiXQGiThxxA54H1j5gzM1Hw== 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-SenderADCheck; bh=17NDhdriXC56m3GTpqqX/lPVFSaQt82E3Tw4hkDDTJk=; b=GqTNQIrkoxb13BpEV8SCJNO50U6OBHa8fIdRATxf7vtOgHI2zyTi7SQwGUL4yHxOZkvfyNLxcsSnY5IwkgKfGZFHNt9u/XJ4BCV5bgU7MAyDSmh32yvJpvQAkGHXCdXUyiPnDSL1xnLzZc3+pT3Mw+EDxz11b67XURcecC/lco5dP7TtaL1ffPZlUP/D9G7KlLnGMTXra2BGNsp3RaQIPzes6wBpi7gfw2SUX//HERpUGel4icUKhjmxWpRRt3tRhYwR9RDNJd6KyRzGyGq3EMdYVHFBo9tD9G3HiaVVswF21JsNGgqzV8oJtse2+WDHj/nFznTh1BansGhGsQcStw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=fail (p=none sp=none 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=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=17NDhdriXC56m3GTpqqX/lPVFSaQt82E3Tw4hkDDTJk=; b=blS/lK109IKnvNv8AxoFxZjL6pn9SGyUrLVBprX4eMGSyP1SGjoR5oomwurBAbM/p4aC5t+iJtJ1KpaDSJnIDtS57iw6Ev2W2w+u026Zg2H/3C5M4FkoWPwNuZyvEPamCxXZYWhsCsD5aOukMSV/zX0YwhdmfjEKu1d5w/5OTHg= Received: from DM5PR17CA0062.namprd17.prod.outlook.com (2603:10b6:3:13f::24) by MN2PR12MB4333.namprd12.prod.outlook.com (2603:10b6:208:1d3::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.22; Sat, 21 Nov 2020 05:21:37 +0000 Received: from DM6NAM11FT057.eop-nam11.prod.protection.outlook.com (2603:10b6:3:13f:cafe::85) by DM5PR17CA0062.outlook.office365.com (2603:10b6:3:13f::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.20 via Frontend Transport; Sat, 21 Nov 2020 05:21:37 +0000 X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=fail action=none header.from=amd.com; Received-SPF: SoftFail (protection.outlook.com: domain of transitioning amd.com discourages use of 165.204.84.17 as permitted sender) Received: from SATLEXMB02.amd.com (165.204.84.17) by DM6NAM11FT057.mail.protection.outlook.com (10.13.172.252) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3589.22 via Frontend Transport; Sat, 21 Nov 2020 05:21:37 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB02.amd.com (10.181.40.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 20 Nov 2020 23:21:36 -0600 Received: from SATLEXMB01.amd.com (10.181.40.142) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 20 Nov 2020 23:21:36 -0600 Received: from ubuntu-1604-test.amd.com (10.180.168.240) by SATLEXMB01.amd.com (10.181.40.142) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Fri, 20 Nov 2020 23:21:35 -0600 From: Andrey Grodzovsky To: , , , , , , , Subject: [PATCH v3 05/12] drm/ttm: Expose ttm_tt_unpopulate for driver use Date: Sat, 21 Nov 2020 00:21:15 -0500 Message-ID: <1605936082-3099-6-git-send-email-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1605936082-3099-1-git-send-email-andrey.grodzovsky@amd.com> References: <1605936082-3099-1-git-send-email-andrey.grodzovsky@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2784e4d7-d5d8-4490-8d5a-08d88ddd51cc X-MS-TrafficTypeDiagnostic: MN2PR12MB4333: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:404; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qkfh1EO+pC5T1KE+ufhB1E2Yo4RgfmQnC+DtX8Q/nitD9tBKnvlJaUQ3B95C0XbZKUKZj+61NxmIgOrjGibXjmFxjaDrVwDou8ogLjByHxA4z9t/y6ww6FqUOfvuw3UgahMtrxNpK/Egx9UsJK07WtjDiU+D7h+rQC02HyE81yf7Qe5wf37494u8LxUsRpHtl5Kl2dZHKgRYmofsE0kg9v7sqIR1SxvCTTeWZY22KU/BeSUQEUafxYIil9b8wKNxnQtnm2CAedTTqPD1TVNLebvA3d5ZfHnXMtu6Azz07mL+xK6wyVpvGPiq6GoALz8SAIXXz5l3NRCdg1aoy+rrJ9pWmFFfXlcYwbJQMf0sSWXqngu0rhReacOeQQHGvyqzgYGx6cWxToe0r8UDTU5eQw== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SATLEXMB02.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(396003)(346002)(136003)(376002)(39860400002)(46966005)(2616005)(36756003)(478600001)(2906002)(86362001)(7416002)(6666004)(5660300002)(4326008)(4744005)(110136005)(7696005)(426003)(8676002)(82740400003)(54906003)(8936002)(44832011)(316002)(186003)(70586007)(26005)(356005)(47076004)(336012)(70206006)(82310400003)(81166007); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2020 05:21:37.1644 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2784e4d7-d5d8-4490-8d5a-08d88ddd51cc 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=[SATLEXMB02.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT057.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4333 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: Alexander.Deucher@amd.com, gregkh@linuxfoundation.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" It's needed to drop iommu backed pages on device unplug before device's IOMMU group is released. Signed-off-by: Andrey Grodzovsky --- drivers/gpu/drm/ttm/ttm_tt.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c index 1ccf1ef..29248a5 100644 --- a/drivers/gpu/drm/ttm/ttm_tt.c +++ b/drivers/gpu/drm/ttm/ttm_tt.c @@ -495,3 +495,4 @@ void ttm_tt_unpopulate(struct ttm_tt *ttm) else ttm_pool_unpopulate(ttm); } +EXPORT_SYMBOL(ttm_tt_unpopulate); From patchwork Sat Nov 21 05:21:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 11923203 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0DE7C63777 for ; Sat, 21 Nov 2020 05:21:54 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5871722210 for ; Sat, 21 Nov 2020 05:21:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="LZ8QskTy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5871722210 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9896A6E976; Sat, 21 Nov 2020 05:21:44 +0000 (UTC) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2087.outbound.protection.outlook.com [40.107.223.87]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7C5A16E96E; Sat, 21 Nov 2020 05:21:40 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F5p0YxrecMFdDPk7/M2k+AhqnP5BlVOJhZc3YQca/+7qYM13n06TaZFOnjiWn4YU16jw37NKU4DkXGZEuHxaqT3+E6eftDqPYQNBEgBTslvgF1doYobrgzhi9f0MAZm7UP0SBl4RWFZQubbb0KO/jC8imT2S2tlbzb1b0ErJBNm0Tl+GaUfihzFnwdjTco+6tvdWNH4Z5/emqxNCC3lJihqeAUxd99FQok+NxDIMtkWqzXP/O7rLXJzCee08QcFziIKZ/pHdDhVMH+PBE0lYyjq8M9ZbsD9oYimoL+ObuaF9ulHpZfYGOpzK86uxW8hGoLbLjOdscWMP8okGCno2ow== 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-SenderADCheck; bh=njtlVtWRFe6SSIOvTGY1Q7rjydiClrLx7fl20jsUB50=; b=jB5yeQ+vwc+qp1Qm9BcJiCQJnnrh0hYpVe3KAQ+2UisKthuPfiYRAfmER+xjYAAnUMDX4UUUlYV85376X/66iUXrVyqrgJVw2FQQcK4wWZNwdRfk3MkELGYP/b189SblOqYv/dx7PEAjVNKitJAHAucnv05KNsVv1QHcdgcvCQZJ4mtY35mIN/CvWgHWj8TgprYBS44QeSxqG9MNdwEyWfi344vh/A8nHi/O+w79UY0DuMZbIrUCl8wYJmIbocPH9bpZSWxqpGZkZYhs9NDStjBuYP7HhDSUsay+a6QVeBrRE9Hve0Dy+qh6MiLRpWLgeMAlMyjD2OCaAsa8eSUXag== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=fail (p=none sp=none 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=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=njtlVtWRFe6SSIOvTGY1Q7rjydiClrLx7fl20jsUB50=; b=LZ8QskTy2D4+0yB84+HKuFyoYSSEGld96yGm+K0DxsLqjSnxKddoadcvhIaWd3+2ncv/dOjKCDRToLGZcHxRx1WJBjxaehF0et916ha2qRfDGXKWgO5cuMcr/EHUGNOeKyTFTRoJUqkHgDD3aecolSaUa/dEJNfkTKht+JWeZLc= Received: from BN6PR11CA0067.namprd11.prod.outlook.com (2603:10b6:404:f7::29) by MN2PR12MB3421.namprd12.prod.outlook.com (2603:10b6:208:cd::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.20; Sat, 21 Nov 2020 05:21:38 +0000 Received: from BN8NAM11FT038.eop-nam11.prod.protection.outlook.com (2603:10b6:404:f7:cafe::4) by BN6PR11CA0067.outlook.office365.com (2603:10b6:404:f7::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.20 via Frontend Transport; Sat, 21 Nov 2020 05:21:38 +0000 X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=fail action=none header.from=amd.com; Received-SPF: SoftFail (protection.outlook.com: domain of transitioning amd.com discourages use of 165.204.84.17 as permitted sender) Received: from SATLEXMB01.amd.com (165.204.84.17) by BN8NAM11FT038.mail.protection.outlook.com (10.13.176.246) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3589.22 via Frontend Transport; Sat, 21 Nov 2020 05:21:38 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB01.amd.com (10.181.40.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 20 Nov 2020 23:21:37 -0600 Received: from SATLEXMB01.amd.com (10.181.40.142) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 20 Nov 2020 23:21:37 -0600 Received: from ubuntu-1604-test.amd.com (10.180.168.240) by SATLEXMB01.amd.com (10.181.40.142) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Fri, 20 Nov 2020 23:21:37 -0600 From: Andrey Grodzovsky To: , , , , , , , Subject: [PATCH v3 06/12] drm/sched: Cancel and flush all oustatdning jobs before finish. Date: Sat, 21 Nov 2020 00:21:16 -0500 Message-ID: <1605936082-3099-7-git-send-email-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1605936082-3099-1-git-send-email-andrey.grodzovsky@amd.com> References: <1605936082-3099-1-git-send-email-andrey.grodzovsky@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7f77d367-9136-4755-095a-08d88ddd526b X-MS-TrafficTypeDiagnostic: MN2PR12MB3421: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:318; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dy24OfyvFUqsc3v/BmLOGWrHXtSta7Zz2xdMMy8k3LulYr8ReNPHZXZrC/n9tA4EGWMlqZhMMI7+NF7K9t7Qbd3DsVrSUc7fAKMRjTCJmTMlKDsROX63MHtRj4MIBnIqibReYE8OgkoH2xkLUCYqckm+SedQGYPGQwgEo/3u5xdDLNnBAgJykcje1IMi6pRdG/0wi5+i59U8tYnEt4svEZXGk52WEq7SIM44tkqrCzoCoNPQGA5G+xGD7vnAlX/Hw7DKioWbp2C62rS3Lwte+GyT0mFHvoogqdtelksv8x9m2bG+rD98ErP0U418lMHWciCzdNFw9eclV9gA7BvkGYh0vcg4E9rYoXtajzf/MKRvHSLN5Y9tEt7ZORqDmrbAmHDE0fzRBsRsXXHAejQnVA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SATLEXMB01.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(136003)(346002)(39860400002)(396003)(376002)(46966005)(8936002)(47076004)(478600001)(82740400003)(8676002)(7416002)(44832011)(83380400001)(4744005)(186003)(36756003)(70206006)(82310400003)(4326008)(70586007)(7696005)(54906003)(81166007)(336012)(2616005)(316002)(5660300002)(6666004)(110136005)(356005)(26005)(426003)(86362001)(2906002); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2020 05:21:38.2500 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7f77d367-9136-4755-095a-08d88ddd526b 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=[SATLEXMB01.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT038.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3421 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: Alexander.Deucher@amd.com, gregkh@linuxfoundation.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To avoid any possible use after free. Signed-off-by: Andrey Grodzovsky Reviewed-by: Christian König --- drivers/gpu/drm/scheduler/sched_main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c index da24c4e..c3f0bd0 100644 --- a/drivers/gpu/drm/scheduler/sched_main.c +++ b/drivers/gpu/drm/scheduler/sched_main.c @@ -891,6 +891,9 @@ void drm_sched_fini(struct drm_gpu_scheduler *sched) if (sched->thread) kthread_stop(sched->thread); + /* Confirm no work left behind accessing device structures */ + cancel_delayed_work_sync(&sched->work_tdr); + sched->ready = false; } EXPORT_SYMBOL(drm_sched_fini); From patchwork Sat Nov 21 05:21:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 11923207 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7376C388F9 for ; Sat, 21 Nov 2020 05:22:00 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6966B22210 for ; Sat, 21 Nov 2020 05:22:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="TgT7i/L4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6966B22210 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8E74A6E97D; Sat, 21 Nov 2020 05:21:58 +0000 (UTC) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2067.outbound.protection.outlook.com [40.107.223.67]) by gabe.freedesktop.org (Postfix) with ESMTPS id A9C016E971; Sat, 21 Nov 2020 05:21:43 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cfGHmguGzJcPHrWqXe2LM7qU11+B1Gn0l82GUrEvLJjeFieq1tt9EkZFGKL7J8/D5Z14Ot7i1hwTZ8+aa2c2obbmTq+H8KSB3hgnDmZp48hUHh/slpDyx8ntx6Rde1QZGOJDCYdVSAJbJN0qsDWsWwlzwqbXlvGcUM9SrxfKj0Q6mHR3q47WxO4PXjjtkjE3ZeO01n3e4Kt0q4WADsR7ddwpgMlgzPQl8EflwRdgdAYpCOEyPdQemSk2DXxiu7nwTdKkmeZtM37MSEmjm2qNuTB46zERezXnYIi3+6vOilumFBokXjOeUejC40XDuJoz0wFnb25McI7dXNaMc70Ltg== 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-SenderADCheck; bh=0HtQgivQv3sdKp3khI2iAdsl9Bv7A9yFoV5IOj4Sjeo=; b=dAbJBC2u1LtrN55vjuzoZ+hDUInx2lW7eCNOhrUvhqyLo91HDYYb6+qf5MV7Jq1h3cCnCn91/EaZk7YZW/cWBlW9c4rco5Uj/KbAJklLGDpGclr2k/krutqySlM/eRcWYErBbflEvnkWRoQoezuuM4k8BmlRjkwaHlKf/BQMYXqDvq08FH/VbSbmVMimmvSA3GsiiHz54PFiR6UbgxFYKPi0dg/b9DxIgQ2bxsA9Uisr7JOjBzBsvcIdGEk4ErCcP6HbD4jHvXDJa9AOqg6I647+m4B3rGT3Rq3stHUOEe7IMaHZGcwKrbFvpeyC4OZcSXG9AEt5FI/7mqzs9eFWcg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=fail (p=none sp=none 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=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0HtQgivQv3sdKp3khI2iAdsl9Bv7A9yFoV5IOj4Sjeo=; b=TgT7i/L4EfQKe3Kl07YJHRlCAZZVWYHbnxEVWgsHgJCVVg09vqH2mGysJ7OmWd/2Yd3pZq+b63XWebviAIjTbssuipIWZy5p0LIuE3LcM7vyMZnTbKrKdbkaW30yv8mp+hSJuBCcVEzPOQ1a1rkyGODUVAhLORcpJu1foJYL6EI= Received: from DM5PR08CA0031.namprd08.prod.outlook.com (2603:10b6:4:60::20) by BY5PR12MB3969.namprd12.prod.outlook.com (2603:10b6:a03:195::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.20; Sat, 21 Nov 2020 05:21:41 +0000 Received: from DM6NAM11FT056.eop-nam11.prod.protection.outlook.com (2603:10b6:4:60:cafe::79) by DM5PR08CA0031.outlook.office365.com (2603:10b6:4:60::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.20 via Frontend Transport; Sat, 21 Nov 2020 05:21:40 +0000 X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=fail action=none header.from=amd.com; Received-SPF: SoftFail (protection.outlook.com: domain of transitioning amd.com discourages use of 165.204.84.17 as permitted sender) Received: from SATLEXMB02.amd.com (165.204.84.17) by DM6NAM11FT056.mail.protection.outlook.com (10.13.173.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3589.22 via Frontend Transport; Sat, 21 Nov 2020 05:21:39 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB02.amd.com (10.181.40.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 20 Nov 2020 23:21:39 -0600 Received: from SATLEXMB01.amd.com (10.181.40.142) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 20 Nov 2020 23:21:39 -0600 Received: from ubuntu-1604-test.amd.com (10.180.168.240) by SATLEXMB01.amd.com (10.181.40.142) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Fri, 20 Nov 2020 23:21:38 -0600 From: Andrey Grodzovsky To: , , , , , , , Subject: [PATCH v3 07/12] drm/sched: Prevent any job recoveries after device is unplugged. Date: Sat, 21 Nov 2020 00:21:17 -0500 Message-ID: <1605936082-3099-8-git-send-email-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1605936082-3099-1-git-send-email-andrey.grodzovsky@amd.com> References: <1605936082-3099-1-git-send-email-andrey.grodzovsky@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: acc0439d-da50-4849-4d8a-08d88ddd5370 X-MS-TrafficTypeDiagnostic: BY5PR12MB3969: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2887; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hgRiH3TX1e4h4DS/W9NX6vMXLxP/KFi8ByblzsqzUHq6GzwhhF9N4cFRadsyjN4jmbsVtfWOEOOyQqdRaEZ8hmQ7H8LLNuDFXV2kwXz5UzQC7GQ5FQMCfBZvQWT7w+eq26+aVvQ76jzaS5G2Oo4MO57Y0yqq2NlDKYaPMxYiMkSbyY4OeL60JuY62ReBtd5iqNgpb/ARz7pVYVRp09suD11poVqCuA1PjWC0ig2OiQOEP6eIYtBxCC6zKHUtMyAIR4MGretgawoJnHqP7KGenbdlUJoAyAiHJCyeXMW4lIE06fViyjJJxe8vZfrqyVStjAdgvIsOX9tIbt81LSgi2AmdZPnrlznlVdirjTXWy+gbd1Yod5K+N947BRbll6MY0iYRtlmzODgfAPt62/gM/Q== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SATLEXMB02.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(376002)(346002)(136003)(396003)(39860400002)(46966005)(356005)(2906002)(8936002)(47076004)(82310400003)(81166007)(86362001)(7696005)(4326008)(8676002)(82740400003)(83380400001)(5660300002)(478600001)(36756003)(2616005)(44832011)(186003)(26005)(110136005)(54906003)(426003)(70586007)(70206006)(336012)(316002)(6666004)(7416002); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2020 05:21:39.9133 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: acc0439d-da50-4849-4d8a-08d88ddd5370 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=[SATLEXMB02.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT056.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB3969 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: Alexander.Deucher@amd.com, gregkh@linuxfoundation.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" No point to try recovery if device is gone, it's meaningless. Signed-off-by: Andrey Grodzovsky --- drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 2 +- drivers/gpu/drm/etnaviv/etnaviv_sched.c | 3 ++- drivers/gpu/drm/lima/lima_sched.c | 3 ++- drivers/gpu/drm/panfrost/panfrost_job.c | 2 +- drivers/gpu/drm/scheduler/sched_main.c | 15 ++++++++++++++- drivers/gpu/drm/v3d/v3d_sched.c | 15 ++++++++++----- include/drm/gpu_scheduler.h | 6 +++++- 7 files changed, 35 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c index d56f402..d0b0021 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c @@ -487,7 +487,7 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring, r = drm_sched_init(&ring->sched, &amdgpu_sched_ops, num_hw_submission, amdgpu_job_hang_limit, - timeout, ring->name); + timeout, ring->name, &adev->ddev); if (r) { DRM_ERROR("Failed to create scheduler on ring %s.\n", ring->name); diff --git a/drivers/gpu/drm/etnaviv/etnaviv_sched.c b/drivers/gpu/drm/etnaviv/etnaviv_sched.c index cd46c88..7678287 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_sched.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_sched.c @@ -185,7 +185,8 @@ int etnaviv_sched_init(struct etnaviv_gpu *gpu) ret = drm_sched_init(&gpu->sched, &etnaviv_sched_ops, etnaviv_hw_jobs_limit, etnaviv_job_hang_limit, - msecs_to_jiffies(500), dev_name(gpu->dev)); + msecs_to_jiffies(500), dev_name(gpu->dev), + gpu->drm); if (ret) return ret; diff --git a/drivers/gpu/drm/lima/lima_sched.c b/drivers/gpu/drm/lima/lima_sched.c index dc6df9e..8a7e5d7ca 100644 --- a/drivers/gpu/drm/lima/lima_sched.c +++ b/drivers/gpu/drm/lima/lima_sched.c @@ -505,7 +505,8 @@ int lima_sched_pipe_init(struct lima_sched_pipe *pipe, const char *name) return drm_sched_init(&pipe->base, &lima_sched_ops, 1, lima_job_hang_limit, msecs_to_jiffies(timeout), - name); + name, + pipe->ldev->ddev); } void lima_sched_pipe_fini(struct lima_sched_pipe *pipe) diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c b/drivers/gpu/drm/panfrost/panfrost_job.c index 30e7b71..37b03b01 100644 --- a/drivers/gpu/drm/panfrost/panfrost_job.c +++ b/drivers/gpu/drm/panfrost/panfrost_job.c @@ -520,7 +520,7 @@ int panfrost_job_init(struct panfrost_device *pfdev) ret = drm_sched_init(&js->queue[j].sched, &panfrost_sched_ops, 1, 0, msecs_to_jiffies(500), - "pan_js"); + "pan_js", pfdev->ddev); if (ret) { dev_err(pfdev->dev, "Failed to create scheduler: %d.", ret); goto err_sched; diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c index c3f0bd0..95db8c6 100644 --- a/drivers/gpu/drm/scheduler/sched_main.c +++ b/drivers/gpu/drm/scheduler/sched_main.c @@ -53,6 +53,7 @@ #include #include #include +#include #define CREATE_TRACE_POINTS #include "gpu_scheduler_trace.h" @@ -283,8 +284,16 @@ static void drm_sched_job_timedout(struct work_struct *work) struct drm_gpu_scheduler *sched; struct drm_sched_job *job; + int idx; + sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work); + if (!drm_dev_enter(sched->ddev, &idx)) { + DRM_INFO("%s - device unplugged skipping recovery on scheduler:%s", + __func__, sched->name); + return; + } + /* Protects against concurrent deletion in drm_sched_get_cleanup_job */ spin_lock(&sched->job_list_lock); job = list_first_entry_or_null(&sched->ring_mirror_list, @@ -316,6 +325,8 @@ static void drm_sched_job_timedout(struct work_struct *work) spin_lock(&sched->job_list_lock); drm_sched_start_timeout(sched); spin_unlock(&sched->job_list_lock); + + drm_dev_exit(idx); } /** @@ -845,7 +856,8 @@ int drm_sched_init(struct drm_gpu_scheduler *sched, unsigned hw_submission, unsigned hang_limit, long timeout, - const char *name) + const char *name, + struct drm_device *ddev) { int i, ret; sched->ops = ops; @@ -853,6 +865,7 @@ int drm_sched_init(struct drm_gpu_scheduler *sched, sched->name = name; sched->timeout = timeout; sched->hang_limit = hang_limit; + sched->ddev = ddev; for (i = DRM_SCHED_PRIORITY_MIN; i < DRM_SCHED_PRIORITY_COUNT; i++) drm_sched_rq_init(sched, &sched->sched_rq[i]); diff --git a/drivers/gpu/drm/v3d/v3d_sched.c b/drivers/gpu/drm/v3d/v3d_sched.c index 0747614..f5076e5 100644 --- a/drivers/gpu/drm/v3d/v3d_sched.c +++ b/drivers/gpu/drm/v3d/v3d_sched.c @@ -401,7 +401,8 @@ v3d_sched_init(struct v3d_dev *v3d) &v3d_bin_sched_ops, hw_jobs_limit, job_hang_limit, msecs_to_jiffies(hang_limit_ms), - "v3d_bin"); + "v3d_bin", + &v3d->drm); if (ret) { dev_err(v3d->drm.dev, "Failed to create bin scheduler: %d.", ret); return ret; @@ -411,7 +412,8 @@ v3d_sched_init(struct v3d_dev *v3d) &v3d_render_sched_ops, hw_jobs_limit, job_hang_limit, msecs_to_jiffies(hang_limit_ms), - "v3d_render"); + "v3d_render", + &v3d->drm); if (ret) { dev_err(v3d->drm.dev, "Failed to create render scheduler: %d.", ret); @@ -423,7 +425,8 @@ v3d_sched_init(struct v3d_dev *v3d) &v3d_tfu_sched_ops, hw_jobs_limit, job_hang_limit, msecs_to_jiffies(hang_limit_ms), - "v3d_tfu"); + "v3d_tfu", + &v3d->drm); if (ret) { dev_err(v3d->drm.dev, "Failed to create TFU scheduler: %d.", ret); @@ -436,7 +439,8 @@ v3d_sched_init(struct v3d_dev *v3d) &v3d_csd_sched_ops, hw_jobs_limit, job_hang_limit, msecs_to_jiffies(hang_limit_ms), - "v3d_csd"); + "v3d_csd", + &v3d->drm); if (ret) { dev_err(v3d->drm.dev, "Failed to create CSD scheduler: %d.", ret); @@ -448,7 +452,8 @@ v3d_sched_init(struct v3d_dev *v3d) &v3d_cache_clean_sched_ops, hw_jobs_limit, job_hang_limit, msecs_to_jiffies(hang_limit_ms), - "v3d_cache_clean"); + "v3d_cache_clean", + &v3d->drm); if (ret) { dev_err(v3d->drm.dev, "Failed to create CACHE_CLEAN scheduler: %d.", ret); diff --git a/include/drm/gpu_scheduler.h b/include/drm/gpu_scheduler.h index 9243655..a980709 100644 --- a/include/drm/gpu_scheduler.h +++ b/include/drm/gpu_scheduler.h @@ -32,6 +32,7 @@ struct drm_gpu_scheduler; struct drm_sched_rq; +struct drm_device; /* These are often used as an (initial) index * to an array, and as such should start at 0. @@ -267,6 +268,7 @@ struct drm_sched_backend_ops { * @score: score to help loadbalancer pick a idle sched * @ready: marks if the underlying HW is ready to work * @free_guilty: A hit to time out handler to free the guilty job. + * @ddev: Pointer to drm device of this scheduler. * * One scheduler is implemented for each hardware ring. */ @@ -288,12 +290,14 @@ struct drm_gpu_scheduler { atomic_t score; bool ready; bool free_guilty; + struct drm_device *ddev; }; int drm_sched_init(struct drm_gpu_scheduler *sched, const struct drm_sched_backend_ops *ops, uint32_t hw_submission, unsigned hang_limit, long timeout, - const char *name); + const char *name, + struct drm_device *ddev); void drm_sched_fini(struct drm_gpu_scheduler *sched); int drm_sched_job_init(struct drm_sched_job *job, From patchwork Sat Nov 21 05:21:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 11923205 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E14CBC6379D for ; Sat, 21 Nov 2020 05:21:58 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 952A322210 for ; Sat, 21 Nov 2020 05:21:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="tlrjOG0z" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 952A322210 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B269C6E97C; Sat, 21 Nov 2020 05:21:56 +0000 (UTC) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2060.outbound.protection.outlook.com [40.107.243.60]) by gabe.freedesktop.org (Postfix) with ESMTPS id D379E6E97A; Sat, 21 Nov 2020 05:21:45 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NLzesN2OqJq+t7ehQsXq5FCC1JfFi0hKZzGZ7BatolT9b0ToGStFAdlTGpKOvCl6qqwkUX7DKFY9k+vwoKS05+fqQp7X/hD81SzWjTHLL4h+llSbUCzT/rhf1kxIkSJKNFjQ0DtVfgsnLVmDhsYlwrGJ9Y3Cl6Ujio2iBhklV6P6Xvlm5HpMuQ/DXNgZV767tt1Wxx4EgixBb9dnnvb+TZnJGuBK72zmJkO4AfQHoZ/h0dkiOTEDLwfQPWne7QxCA6I6amahKZyRYvgpeR2QUf0dVyi5x7v1kdtavCOdHkNyCc3/bjuw0GJr3P+F0Xe3gF69kKKn6u55H/DwdzdxWg== 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-SenderADCheck; bh=MgMWi3xYrccwsvDiW7z6LfUJ5lt/aTxWV05VaBGMssI=; b=EkhPmwB9j4mOXTxJFHl/urmhpaZFnRn4It+AuMd4TzGjNDa5dgpWTyLV0Lwwt1gq1Wrhw3rmZ+gCpDZ0Pfo2S0919npBchkBHbiugSJp4o3Y9jwCS+rBPdpc3DxsBMCysCGmELkbLSfZxr2a9PTeu6P8nWybK4xyeKB9AbBNWE9VeZnsrEAIftcxSI2Tbd7c3exePBNS3gvmxwNIZi/pv1/b/EW0iE90/mviEBdYW4RZBLUI92vIDXxopy4HMhrRXYYIu/K1xRHALkESrK3knTFSPn3XRkiXg7PKJ65pLkvz5GgR5vM/kqoHp6iEG255L74yKB22WDTxsNro00l+uQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=fail (p=none sp=none 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=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MgMWi3xYrccwsvDiW7z6LfUJ5lt/aTxWV05VaBGMssI=; b=tlrjOG0zrjC2k6p6EfUcMM8XP98Cip3vV13UAMl3Qr8XTwmq2CdGEjmVpvRK9BkZBH+BTCzySQIVKC8GKSsyGUx0nO2IblhdNY/0vIF63E7OQx7sUWm5v5YeYkMGv3Y7CiYAKJIcMF4IeaSewCis6SoOW5PyAXLCJuG4A1yJ8os= Received: from BN6PR07CA0007.namprd07.prod.outlook.com (2603:10b6:404:8c::17) by BL0PR12MB5012.namprd12.prod.outlook.com (2603:10b6:208:1ca::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3541.21; Sat, 21 Nov 2020 05:21:42 +0000 Received: from BN8NAM11FT020.eop-nam11.prod.protection.outlook.com (2603:10b6:404:8c:cafe::a5) by BN6PR07CA0007.outlook.office365.com (2603:10b6:404:8c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.20 via Frontend Transport; Sat, 21 Nov 2020 05:21:42 +0000 X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=fail action=none header.from=amd.com; Received-SPF: SoftFail (protection.outlook.com: domain of transitioning amd.com discourages use of 165.204.84.17 as permitted sender) Received: from SATLEXMB01.amd.com (165.204.84.17) by BN8NAM11FT020.mail.protection.outlook.com (10.13.176.223) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3589.22 via Frontend Transport; Sat, 21 Nov 2020 05:21:41 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB01.amd.com (10.181.40.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 20 Nov 2020 23:21:41 -0600 Received: from SATLEXMB01.amd.com (10.181.40.142) 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.1979.3; Fri, 20 Nov 2020 23:21:40 -0600 Received: from ubuntu-1604-test.amd.com (10.180.168.240) by SATLEXMB01.amd.com (10.181.40.142) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Fri, 20 Nov 2020 23:21:40 -0600 From: Andrey Grodzovsky To: , , , , , , , Subject: [PATCH v3 08/12] drm/amdgpu: Split amdgpu_device_fini into early and late Date: Sat, 21 Nov 2020 00:21:18 -0500 Message-ID: <1605936082-3099-9-git-send-email-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1605936082-3099-1-git-send-email-andrey.grodzovsky@amd.com> References: <1605936082-3099-1-git-send-email-andrey.grodzovsky@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6427a973-ae48-4cb2-42f2-08d88ddd5463 X-MS-TrafficTypeDiagnostic: BL0PR12MB5012: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:669; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: f+sbQqnsCNoDcRxlLva0w31a65T0e0/2i3YxWESi19jDlEuwwIfQBuqqIPQD+2XqisGuic+EVrhlfBjoa94CYOSktx/gotCgylZzxocI7LTJV7lVQLQuwhy0q8or6ljTzXhHDEvrTdk2et9OSuqalR5+igQo37q1poq2P3mx/kk+HSN1VJdtykPzCK8yTQhREdcsG5L2lf0lpzdWi3FnF0HDrB1TiaDQV5I52rFqwwj/dcareGQ6GSpSIXTL3/TiXot+fkYzu6wI3vKeHLGBH9iflaNSkJsoUXjGjiPT9TXu5Uic1vyVyWf/kdGaJ7/bsGjBFycJ6mfmBMu+VwjqzB9na0NgbfqsWoMsg7fObOut3XNg+3Mk5OOU6y2GGnjZgB5eu/t5xf3Hho/SeBg2sg== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SATLEXMB01.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(136003)(396003)(346002)(376002)(39860400002)(46966005)(82740400003)(54906003)(426003)(7696005)(8676002)(6666004)(110136005)(47076004)(36756003)(316002)(4326008)(2906002)(8936002)(70206006)(70586007)(86362001)(2616005)(5660300002)(186003)(356005)(7416002)(336012)(82310400003)(478600001)(81166007)(83380400001)(26005)(44832011); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2020 05:21:41.5555 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6427a973-ae48-4cb2-42f2-08d88ddd5463 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=[SATLEXMB01.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT020.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB5012 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: Alexander.Deucher@amd.com, gregkh@linuxfoundation.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Some of the stuff in amdgpu_device_fini such as HW interrupts disable and pending fences finilization must be done right away on pci_remove while most of the stuff which relates to finilizing and releasing driver data structures can be kept until drm_driver.release hook is called, i.e. when the last device reference is dropped. Signed-off-by: Andrey Grodzovsky --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 +++++- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 16 ++++++++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 7 ++----- drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 15 ++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 24 +++++++++++++++--------- drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 12 +++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 3 ++- 9 files changed, 65 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 83ac06a..6243f6d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -1063,7 +1063,9 @@ static inline struct amdgpu_device *amdgpu_ttm_adev(struct ttm_bo_device *bdev) int amdgpu_device_init(struct amdgpu_device *adev, uint32_t flags); -void amdgpu_device_fini(struct amdgpu_device *adev); +void amdgpu_device_fini_early(struct amdgpu_device *adev); +void amdgpu_device_fini_late(struct amdgpu_device *adev); + int amdgpu_gpu_wait_for_idle(struct amdgpu_device *adev); void amdgpu_device_vram_access(struct amdgpu_device *adev, loff_t pos, @@ -1275,6 +1277,8 @@ void amdgpu_driver_lastclose_kms(struct drm_device *dev); int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv); void amdgpu_driver_postclose_kms(struct drm_device *dev, struct drm_file *file_priv); +void amdgpu_driver_release_kms(struct drm_device *dev); + int amdgpu_device_ip_suspend(struct amdgpu_device *adev); int amdgpu_device_suspend(struct drm_device *dev, bool fbcon); int amdgpu_device_resume(struct drm_device *dev, bool fbcon); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 2f60b70..797d94d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -3557,14 +3557,12 @@ int amdgpu_device_init(struct amdgpu_device *adev, * Tear down the driver info (all asics). * Called at driver shutdown. */ -void amdgpu_device_fini(struct amdgpu_device *adev) +void amdgpu_device_fini_early(struct amdgpu_device *adev) { dev_info(adev->dev, "amdgpu: finishing device.\n"); flush_delayed_work(&adev->delayed_init_work); adev->shutdown = true; - kfree(adev->pci_state); - /* make sure IB test finished before entering exclusive mode * to avoid preemption on IB test * */ @@ -3581,11 +3579,18 @@ void amdgpu_device_fini(struct amdgpu_device *adev) else drm_atomic_helper_shutdown(adev_to_drm(adev)); } - amdgpu_fence_driver_fini(adev); + amdgpu_fence_driver_fini_early(adev); if (adev->pm_sysfs_en) amdgpu_pm_sysfs_fini(adev); amdgpu_fbdev_fini(adev); + + amdgpu_irq_fini_early(adev); +} + +void amdgpu_device_fini_late(struct amdgpu_device *adev) +{ amdgpu_device_ip_fini(adev); + amdgpu_fence_driver_fini_late(adev); release_firmware(adev->firmware.gpu_info_fw); adev->firmware.gpu_info_fw = NULL; adev->accel_working = false; @@ -3621,6 +3626,9 @@ void amdgpu_device_fini(struct amdgpu_device *adev) amdgpu_pmu_fini(adev); if (adev->mman.discovery_bin) amdgpu_discovery_fini(adev); + + kfree(adev->pci_state); + } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index 7f98cf1..3d130fc 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -1244,14 +1244,10 @@ amdgpu_pci_remove(struct pci_dev *pdev) { struct drm_device *dev = pci_get_drvdata(pdev); -#ifdef MODULE - if (THIS_MODULE->state != MODULE_STATE_GOING) -#endif - DRM_ERROR("Hotplug removal is not supported\n"); drm_dev_unplug(dev); amdgpu_driver_unload_kms(dev); + pci_disable_device(pdev); - pci_set_drvdata(pdev, NULL); drm_dev_put(dev); } @@ -1557,6 +1553,7 @@ static struct drm_driver kms_driver = { .dumb_create = amdgpu_mode_dumb_create, .dumb_map_offset = amdgpu_mode_dumb_mmap, .fops = &amdgpu_driver_kms_fops, + .release = &amdgpu_driver_release_kms, .prime_handle_to_fd = drm_gem_prime_handle_to_fd, .prime_fd_to_handle = drm_gem_prime_fd_to_handle, diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c index d0b0021..c123aa6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c @@ -523,7 +523,7 @@ int amdgpu_fence_driver_init(struct amdgpu_device *adev) * * Tear down the fence driver for all possible rings (all asics). */ -void amdgpu_fence_driver_fini(struct amdgpu_device *adev) +void amdgpu_fence_driver_fini_early(struct amdgpu_device *adev) { unsigned i, j; int r; @@ -544,6 +544,19 @@ void amdgpu_fence_driver_fini(struct amdgpu_device *adev) if (!ring->no_scheduler) drm_sched_fini(&ring->sched); del_timer_sync(&ring->fence_drv.fallback_timer); + } +} + +void amdgpu_fence_driver_fini_late(struct amdgpu_device *adev) +{ + unsigned int i, j; + + for (i = 0; i < AMDGPU_MAX_RINGS; i++) { + struct amdgpu_ring *ring = adev->rings[i]; + + if (!ring || !ring->fence_drv.initialized) + continue; + for (j = 0; j <= ring->fence_drv.num_fences_mask; ++j) dma_fence_put(ring->fence_drv.fences[j]); kfree(ring->fence_drv.fences); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c index 300ac73..a833197 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c @@ -49,6 +49,7 @@ #include #include #include +#include #include "amdgpu.h" #include "amdgpu_ih.h" #include "atom.h" @@ -297,6 +298,20 @@ int amdgpu_irq_init(struct amdgpu_device *adev) return 0; } + +void amdgpu_irq_fini_early(struct amdgpu_device *adev) +{ + if (adev->irq.installed) { + drm_irq_uninstall(&adev->ddev); + adev->irq.installed = false; + if (adev->irq.msi_enabled) + pci_free_irq_vectors(adev->pdev); + + if (!amdgpu_device_has_dc_support(adev)) + flush_work(&adev->hotplug_work); + } +} + /** * amdgpu_irq_fini - shut down interrupt handling * @@ -310,15 +325,6 @@ void amdgpu_irq_fini(struct amdgpu_device *adev) { unsigned i, j; - if (adev->irq.installed) { - drm_irq_uninstall(adev_to_drm(adev)); - adev->irq.installed = false; - if (adev->irq.msi_enabled) - pci_free_irq_vectors(adev->pdev); - if (!amdgpu_device_has_dc_support(adev)) - flush_work(&adev->hotplug_work); - } - for (i = 0; i < AMDGPU_IRQ_CLIENTID_MAX; ++i) { if (!adev->irq.client[i].sources) continue; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h index c718e94..718c70f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h @@ -104,6 +104,7 @@ irqreturn_t amdgpu_irq_handler(int irq, void *arg); int amdgpu_irq_init(struct amdgpu_device *adev); void amdgpu_irq_fini(struct amdgpu_device *adev); +void amdgpu_irq_fini_early(struct amdgpu_device *adev); int amdgpu_irq_add_id(struct amdgpu_device *adev, unsigned client_id, unsigned src_id, struct amdgpu_irq_src *source); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c index a0af8a7..9e30c5c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c @@ -29,6 +29,7 @@ #include "amdgpu.h" #include #include +#include #include "amdgpu_sched.h" #include "amdgpu_uvd.h" #include "amdgpu_vce.h" @@ -94,7 +95,7 @@ void amdgpu_driver_unload_kms(struct drm_device *dev) } amdgpu_acpi_fini(adev); - amdgpu_device_fini(adev); + amdgpu_device_fini_early(adev); } void amdgpu_register_gpu_instance(struct amdgpu_device *adev) @@ -1147,6 +1148,15 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev, pm_runtime_put_autosuspend(dev->dev); } + +void amdgpu_driver_release_kms(struct drm_device *dev) +{ + struct amdgpu_device *adev = drm_to_adev(dev); + + amdgpu_device_fini_late(adev); + pci_set_drvdata(adev->pdev, NULL); +} + /* * VBlank related functions. */ diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c index 9d11b84..caf828a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c @@ -2142,9 +2142,12 @@ int amdgpu_ras_pre_fini(struct amdgpu_device *adev) { struct amdgpu_ras *con = amdgpu_ras_get_context(adev); + //DRM_ERROR("adev 0x%llx", (long long unsigned int)adev); + if (!con) return 0; + /* Need disable ras on all IPs here before ip [hw/sw]fini */ amdgpu_ras_disable_all_features(adev, 0); amdgpu_ras_recovery_fini(adev); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h index 7112137..074f36b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h @@ -107,7 +107,8 @@ struct amdgpu_fence_driver { }; int amdgpu_fence_driver_init(struct amdgpu_device *adev); -void amdgpu_fence_driver_fini(struct amdgpu_device *adev); +void amdgpu_fence_driver_fini_early(struct amdgpu_device *adev); +void amdgpu_fence_driver_fini_late(struct amdgpu_device *adev); void amdgpu_fence_driver_force_completion(struct amdgpu_ring *ring); int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring, From patchwork Sat Nov 21 05:21:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 11923209 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA799C63798 for ; Sat, 21 Nov 2020 05:22:02 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7DEC622226 for ; Sat, 21 Nov 2020 05:22:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="DCKAfOQi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7DEC622226 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 178576E96A; Sat, 21 Nov 2020 05:22:00 +0000 (UTC) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2048.outbound.protection.outlook.com [40.107.243.48]) by gabe.freedesktop.org (Postfix) with ESMTPS id 32E4E6E979; Sat, 21 Nov 2020 05:21:49 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SuIoHTnszt+GKWqc/XMdiWFrfM/kdO7QJjzbKkYMs6MF9bJiQDZHc2YUUy4qiSbP89u4JhgHKvcOQ9Qn0HdREToD/BQrHSJK6QyXyOEX/hRs6AdvcLCS5iHv1GJAYvx0URu+pdyTTwOCbtorgNdJ3BSe2zVyzHGoe4wDYJptEw1I9rDbqR/Ad9XB0Syh8GF4JeiY5wwWNnZLWlmCycj+FJoIHHvb90dHiVC775lSSitdpMNfVsHz4hxz8EqilWGC/SVUqyKME5Oor6QAxsZPEZm+UblNMQgFkOoIDWvxm+sd7HgjI4XxyjJsyICm1xeh6jeDtIX7hLEOq116fnIjYw== 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-SenderADCheck; bh=2CJcWXvJx4JG4fcDamvXOyfxEoEeFM6lSIVPRugs/Dg=; b=Th2ddQ0JDztSSpoqkOwX4Yg76UspRy2Bn1wgAf2bk0tiKUEBGXKiFqpXp/KThyTYQy4If9QgwCo7xmg6KrLsO0+MFs7UDyuuJbI4PFKiHQV4N3GaPE0/2bK8y1ThJGTLnStdlKs7rDbJagIteKbLp6wZrlORDktV73FFmD0o5aMrTV426s+Xp7VApVvQApU10dRQrmYj7uJWMRwAsXmcGnwPv25HpkMIFQa9SMEFvGEDnN32jdUosmpkk6hTla0u2JuQsHSbJNiy6dVvnyRy3Fxtdu6KL6lDPPMI/i+9GUy6RRhnbiFVEZ1iF+YsiWlNGMvkRCntq7wQz3EJ3YNJpQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=fail (p=none sp=none 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=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2CJcWXvJx4JG4fcDamvXOyfxEoEeFM6lSIVPRugs/Dg=; b=DCKAfOQivR7NeSgsEWmZ2sqnHuWGJbmyaTe0XQsHFqx9i80z0qyTMIUNUumfjYb44C78yIcYP/ttXQveGV865rB4EvvWzIrrm6eEfumj3/09k+56Lvb4VKf+LJMY81T0R0AHQHesBMeAV9BSvDKNIY7R3na2yaBa3jFBN5Ssc1Q= Received: from DM6PR11CA0024.namprd11.prod.outlook.com (2603:10b6:5:190::37) by MWHPR12MB1215.namprd12.prod.outlook.com (2603:10b6:300:d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.20; Sat, 21 Nov 2020 05:21:43 +0000 Received: from DM6NAM11FT027.eop-nam11.prod.protection.outlook.com (2603:10b6:5:190:cafe::fb) by DM6PR11CA0024.outlook.office365.com (2603:10b6:5:190::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.20 via Frontend Transport; Sat, 21 Nov 2020 05:21:43 +0000 X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=fail action=none header.from=amd.com; Received-SPF: SoftFail (protection.outlook.com: domain of transitioning amd.com discourages use of 165.204.84.17 as permitted sender) Received: from SATLEXMB02.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.3589.22 via Frontend Transport; Sat, 21 Nov 2020 05:21:43 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB02.amd.com (10.181.40.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 20 Nov 2020 23:21:42 -0600 Received: from SATLEXMB01.amd.com (10.181.40.142) 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.1979.3; Fri, 20 Nov 2020 23:21:42 -0600 Received: from ubuntu-1604-test.amd.com (10.180.168.240) by SATLEXMB01.amd.com (10.181.40.142) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Fri, 20 Nov 2020 23:21:41 -0600 From: Andrey Grodzovsky To: , , , , , , , Subject: [PATCH v3 09/12] drm/amdgpu: Add early fini callback Date: Sat, 21 Nov 2020 00:21:19 -0500 Message-ID: <1605936082-3099-10-git-send-email-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1605936082-3099-1-git-send-email-andrey.grodzovsky@amd.com> References: <1605936082-3099-1-git-send-email-andrey.grodzovsky@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8f788d76-77a8-442c-42cb-08d88ddd5560 X-MS-TrafficTypeDiagnostic: MWHPR12MB1215: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FlDZbwTfuMYXFy1eKMbGceHhPZ6ijQrb/IxF2VchIHNrzb86vhPt/X9H5IJ9lJldbTPsIDE+ldMm7ZGGPx5Cr9h6sc8AZtmV9OgMpJQfBASwFJHUZ3eaSvaNda6vMNt9P4Z7ds2i8/YVxeh/IvI5w/m+Y0cABY7znxEMZA881++tJjaLSmey5YDAtWz4L7pHF8MgctTTfKp0VWf/4+xdlahxKjdxuO263sJAQh17aqY5cjVHBLaL1kxXIcSw1NlYoXe+LKY6fP8surECev9fFqiaL9oGVxKZ/Yt3Xw17hJLjd1S2WvWXa6ScvhUe90FDx9VIChAwlozOn14KOq3CNvzStfxXJ6i8lrleIy/QVRGuCYH8zy4YP2Xye0DXNiLjLy97pQDYpucllvAdnak/5A== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SATLEXMB02.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(346002)(136003)(39860400002)(396003)(376002)(46966005)(8676002)(8936002)(36756003)(7696005)(2906002)(81166007)(82310400003)(356005)(47076004)(5660300002)(82740400003)(70206006)(70586007)(110136005)(186003)(26005)(54906003)(83380400001)(336012)(316002)(478600001)(6666004)(44832011)(4326008)(86362001)(2616005)(426003)(7416002); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2020 05:21:43.1036 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8f788d76-77a8-442c-42cb-08d88ddd5560 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=[SATLEXMB02.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: MWHPR12MB1215 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: Alexander.Deucher@amd.com, gregkh@linuxfoundation.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Use it to call disply code dependent on device->drv_data before it's set to NULL on device unplug Signed-off-by: Andrey Grodzovsky --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 20 ++++++++++++++++++++ drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 12 ++++++++++-- drivers/gpu/drm/amd/include/amd_shared.h | 2 ++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 797d94d..96368a8 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -2508,6 +2508,24 @@ static int amdgpu_device_ip_late_init(struct amdgpu_device *adev) return 0; } +static int amdgpu_device_ip_fini_early(struct amdgpu_device *adev) +{ + int i, r; + + for (i = 0; i < adev->num_ip_blocks; i++) { + if (!adev->ip_blocks[i].version->funcs->early_fini) + continue; + + r = adev->ip_blocks[i].version->funcs->early_fini((void *)adev); + if (r) { + DRM_DEBUG("early_fini of IP block <%s> failed %d\n", + adev->ip_blocks[i].version->funcs->name, r); + } + } + + return 0; +} + /** * amdgpu_device_ip_fini - run fini for hardware IPs * @@ -3585,6 +3603,8 @@ void amdgpu_device_fini_early(struct amdgpu_device *adev) amdgpu_fbdev_fini(adev); amdgpu_irq_fini_early(adev); + + amdgpu_device_ip_fini_early(adev); } void amdgpu_device_fini_late(struct amdgpu_device *adev) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index 1da4ad5..278d1f6 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -1158,6 +1158,15 @@ static int amdgpu_dm_init(struct amdgpu_device *adev) return -EINVAL; } +static int amdgpu_dm_early_fini(void *handle) +{ + struct amdgpu_device *adev = (struct amdgpu_device *)handle; + + amdgpu_dm_audio_fini(adev); + + return 0; +} + static void amdgpu_dm_fini(struct amdgpu_device *adev) { int i; @@ -1166,8 +1175,6 @@ static void amdgpu_dm_fini(struct amdgpu_device *adev) drm_encoder_cleanup(&adev->dm.mst_encoders[i].base); } - amdgpu_dm_audio_fini(adev); - amdgpu_dm_destroy_drm_device(&adev->dm); #ifdef CONFIG_DRM_AMD_DC_HDCP @@ -2150,6 +2157,7 @@ static const struct amd_ip_funcs amdgpu_dm_funcs = { .late_init = dm_late_init, .sw_init = dm_sw_init, .sw_fini = dm_sw_fini, + .early_fini = amdgpu_dm_early_fini, .hw_init = dm_hw_init, .hw_fini = dm_hw_fini, .suspend = dm_suspend, diff --git a/drivers/gpu/drm/amd/include/amd_shared.h b/drivers/gpu/drm/amd/include/amd_shared.h index 9676016..63bb846 100644 --- a/drivers/gpu/drm/amd/include/amd_shared.h +++ b/drivers/gpu/drm/amd/include/amd_shared.h @@ -239,6 +239,7 @@ enum amd_dpm_forced_level; * @late_init: sets up late driver/hw state (post hw_init) - Optional * @sw_init: sets up driver state, does not configure hw * @sw_fini: tears down driver state, does not configure hw + * @early_fini: tears down stuff before dev detached from driver * @hw_init: sets up the hw state * @hw_fini: tears down the hw state * @late_fini: final cleanup @@ -267,6 +268,7 @@ struct amd_ip_funcs { int (*late_init)(void *handle); int (*sw_init)(void *handle); int (*sw_fini)(void *handle); + int (*early_fini)(void *handle); int (*hw_init)(void *handle); int (*hw_fini)(void *handle); void (*late_fini)(void *handle); From patchwork Sat Nov 21 05:21:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 11923211 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 512E8C63697 for ; Sat, 21 Nov 2020 05:22:10 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DD73C22210 for ; Sat, 21 Nov 2020 05:22:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="cont+OEi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DD73C22210 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2C8536E980; Sat, 21 Nov 2020 05:22:09 +0000 (UTC) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2062.outbound.protection.outlook.com [40.107.94.62]) by gabe.freedesktop.org (Postfix) with ESMTPS id 76E106E97A; Sat, 21 Nov 2020 05:21:47 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DPGeaGIHFJRQZmtb4AWK95kUXaHF2+Syq87USaqCca6Fw1PIUCcewoqQyXKMlVKhigZo/DIWrxAqNHs/pI1as4Xgz5tlfPxHVF4G85mqnO001tFlQT74QAou1llNWWQ4HV4UnBYAPDABdh9bMCarO/lpsjLJzKbeUJIHnio7d979B+qO400tPq+IJdl58aYW6sX5HpX7uSXm+FclbnLgw/tum2oeFruacwqqXxNPMXC8S3BsnrvLpzlEzE9jH/IbsQNQ/CaTeSRLmzQg/rOo0dZWhLgq5WNxBUdFbT8DLBRs+IPzBcq/NXrnHbZZYifgUtgJ7XzFUJsCXGkoOkVo/w== 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-SenderADCheck; bh=QqvJ0ki6km4calgkaeOmhsKH+BuDCHRao+v76nQRuTU=; b=FaKPNcQMRh9DOL+wooT4nVF9oKwKgvdINAM8rHQtZi9bCIP/c6c97L7FEaujgKBnnfU/r/ty7VmtAjp19U8lV3JhcmqG3XDpnz7EPiHY0Ht3nUB036Wd4aTJfdT8h+AglAavVJIfO6mdBxZoMkVwkmerbbBZkQ17psujmZ3e9v8+4i89fRmTJDXvE720TqzYZuEeu6TaLlqMFvdQQxkeGGHuDg857M1DezRfkx9pQ2RomxphOQhtbz28wJBDsqJxnbpcZPAPn67oHHwFBM23vb3vqzTTUkdctBaZMdYsHZgw28eSljYAyBIrtpCJNsXQGw+jJzj4e5G83dsulWHo8g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=fail (p=none sp=none 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=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QqvJ0ki6km4calgkaeOmhsKH+BuDCHRao+v76nQRuTU=; b=cont+OEiVgBmrVk8Ca70yDBU/1Z0U6YGlG8fRgU/gtxcfaIg2Q01iBk+E46U4/ZPGd+PTzEGP2HsDzUiR3KvqEeUv+H1T8JZwH5wQbGsI8Tji6+z6omcZ9a1P/YUbWm35X7n1/MH8yeoj6CTLJFuvdCboFAMRkSSEkFxYShSTZg= Received: from BN6PR04CA0098.namprd04.prod.outlook.com (2603:10b6:404:c9::24) by DM6PR12MB4025.namprd12.prod.outlook.com (2603:10b6:5:1c8::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.20; Sat, 21 Nov 2020 05:21:44 +0000 Received: from BN8NAM11FT028.eop-nam11.prod.protection.outlook.com (2603:10b6:404:c9:cafe::96) by BN6PR04CA0098.outlook.office365.com (2603:10b6:404:c9::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.20 via Frontend Transport; Sat, 21 Nov 2020 05:21:44 +0000 X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=fail action=none header.from=amd.com; Received-SPF: SoftFail (protection.outlook.com: domain of transitioning amd.com discourages use of 165.204.84.17 as permitted sender) Received: from SATLEXMB01.amd.com (165.204.84.17) by BN8NAM11FT028.mail.protection.outlook.com (10.13.176.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3589.22 via Frontend Transport; Sat, 21 Nov 2020 05:21:44 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB01.amd.com (10.181.40.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 20 Nov 2020 23:21:43 -0600 Received: from SATLEXMB01.amd.com (10.181.40.142) 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.1979.3; Fri, 20 Nov 2020 23:21:43 -0600 Received: from ubuntu-1604-test.amd.com (10.180.168.240) by SATLEXMB01.amd.com (10.181.40.142) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Fri, 20 Nov 2020 23:21:42 -0600 From: Andrey Grodzovsky To: , , , , , , , Subject: [PATCH v3 10/12] drm/amdgpu: Avoid sysfs dirs removal post device unplug Date: Sat, 21 Nov 2020 00:21:20 -0500 Message-ID: <1605936082-3099-11-git-send-email-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1605936082-3099-1-git-send-email-andrey.grodzovsky@amd.com> References: <1605936082-3099-1-git-send-email-andrey.grodzovsky@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 769f32f5-6e32-4bf8-dac0-08d88ddd55fc X-MS-TrafficTypeDiagnostic: DM6PR12MB4025: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:489; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KgbvmCoULHQCCJfkE14MHDFA8Ob2EkEcXMBITNdiRa1om/PTnWn4Uj1hfzLkU0kY0Ys5UtqCk4GZfhN11nqn5B1R3x/H2SXcfy0ZInRJLuf79TRWxwwQkIhhTFt1QPrQb6jzNKv10YMhuCGSqJ7+zLjHolblMoXv9mWsu4MlyneJJRwbEGO2y2AF75I6dk+m5fqvckEwx2RHxSSun6oj4fMvGu2vPiQbOn7Cr/5lrka2MAd+aqKvPR2oS36uf5kFlCQGY08N5kJSSIxQu0fXmMgAvBGd8dpRKkhVOqaiRLSwlgVRpxtcYu8Hmdr/V3BcAowc7rshv6xTaH4K1QmVsh/RtrcqI+/LfofnmpcmPo7WYDFxZHrRNwhpZJtNP9TqB7JXlBApvfg3E0lGhWvc/w== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SATLEXMB01.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(39860400002)(136003)(346002)(376002)(396003)(46966005)(81166007)(86362001)(7696005)(47076004)(426003)(2906002)(336012)(82310400003)(186003)(6666004)(4326008)(36756003)(44832011)(8676002)(83380400001)(5660300002)(316002)(8936002)(82740400003)(26005)(356005)(2616005)(54906003)(478600001)(70206006)(7416002)(70586007)(110136005); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2020 05:21:44.2398 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 769f32f5-6e32-4bf8-dac0-08d88ddd55fc 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=[SATLEXMB01.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT028.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4025 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: Alexander.Deucher@amd.com, gregkh@linuxfoundation.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Avoids NULL ptr due to kobj->sd being unset on device removal. Signed-off-by: Andrey Grodzovsky --- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 4 +++- drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c index caf828a..812e592 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "amdgpu.h" #include "amdgpu_ras.h" @@ -1043,7 +1044,8 @@ static int amdgpu_ras_sysfs_remove_feature_node(struct amdgpu_device *adev) .attrs = attrs, }; - sysfs_remove_group(&adev->dev->kobj, &group); + if (!drm_dev_is_unplugged(&adev->ddev)) + sysfs_remove_group(&adev->dev->kobj, &group); return 0; } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c index 2b7c90b..54331fc 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "amdgpu.h" #include "amdgpu_ucode.h" @@ -464,7 +465,8 @@ int amdgpu_ucode_sysfs_init(struct amdgpu_device *adev) void amdgpu_ucode_sysfs_fini(struct amdgpu_device *adev) { - sysfs_remove_group(&adev->dev->kobj, &fw_attr_group); + if (!drm_dev_is_unplugged(&adev->ddev)) + sysfs_remove_group(&adev->dev->kobj, &fw_attr_group); } static int amdgpu_ucode_init_single_fw(struct amdgpu_device *adev, From patchwork Sat Nov 21 05:21:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 11923213 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9938C63777 for ; Sat, 21 Nov 2020 05:22:13 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5F74222210 for ; Sat, 21 Nov 2020 05:22:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="tAhDQ/fu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5F74222210 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B36D16E97F; Sat, 21 Nov 2020 05:22:12 +0000 (UTC) Received: from NAM04-SN1-obe.outbound.protection.outlook.com (mail-eopbgr700087.outbound.protection.outlook.com [40.107.70.87]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4FFA66E97F; Sat, 21 Nov 2020 05:22:11 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XmvGUDzIXfYR4VXAU0RvMjrP/rn3EQGplLTT9HVKlmLkiQ5RnoQCCsWLfVnrDNuoMOwNTr2OGHLNQ1i+mVLeAJxsWFa2RnEYDJlzqfWrBhHuJVDvZrq4uhXBqOfg5JNKtQMGFIfwmNQAzNk3/URXRhXgFT1nBh4/r71/bKXlROtJCPrtcRSkKw38SjGpH5pDm4DB7EGPdkLdA07/8t9sOQPI715GQvCVhovtj0sFe3364ej62HsJ+A270r2Tmx+vqrZeG4YR8V9pqtPuHhrXa6cjqD3FCnaY6xAhB9d4phf7WFH7II6XtOtFYOrSLhWqeKehLC99wSAyVNJxL2H+jw== 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-SenderADCheck; bh=mqY3MPoJ7E3Hjx+D7G/m1j0155nPBhXI6kjk17Om+1s=; b=Lw9/8lTLFmvdMiGyTqeYaJEtWvJlvxwxQkmrqk99SY1VsVoV7XV+h77YggeO2mSXF+SouXAg2ksgfhTrwJl6uUKZ4a1cXeSzi6eqyR0zGfHEqbQkVoqTZ3DAjWz3tqTgtNWfp3dyhZWkEIQaPuDBUnIzWedXwd8G1pGDFsLi0JxiFEdJFrQInFTTNco2PsDyhTbHYQuKBdgrgVPKZcplI+azAovZRzY6IjU4AJuz1h6PUHtvb9Kgfcw2JAnTlEWqlUrv8BFT+Z21v2xwtkKorILY8OncP2D3f7e65mpH35q+4HmsakaL+JHY/sXfDmLkbrSM8kRfSB8yjrvTLD6NoA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=fail (p=none sp=none 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=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mqY3MPoJ7E3Hjx+D7G/m1j0155nPBhXI6kjk17Om+1s=; b=tAhDQ/fu/TysS1QPF2rpr7XJTj2clAeGGLIDMCV23sXev/ILzcXltEUpA8J4qtpxaUxrv4ZgM2XWbnaTG1QGPyEYiWOwim1BtjAAd5osRU+r5SdcpEJDywtaWSwBPHm+V8Idr5nS5xcX4rzeg6AYlTk9jRcGCeOyhgnckxpV9C4= Received: from BN3PR05CA0029.namprd05.prod.outlook.com (2603:10b6:400::39) by BY5PR12MB4274.namprd12.prod.outlook.com (2603:10b6:a03:206::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.22; Sat, 21 Nov 2020 05:22:08 +0000 Received: from BN8NAM11FT027.eop-nam11.prod.protection.outlook.com (2603:10b6:400:0:cafe::2b) by BN3PR05CA0029.outlook.office365.com (2603:10b6:400::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3611.9 via Frontend Transport; Sat, 21 Nov 2020 05:22:07 +0000 X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=fail action=none header.from=amd.com; Received-SPF: SoftFail (protection.outlook.com: domain of transitioning amd.com discourages use of 165.204.84.17 as permitted sender) Received: from SATLEXMB01.amd.com (165.204.84.17) by BN8NAM11FT027.mail.protection.outlook.com (10.13.177.96) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3589.22 via Frontend Transport; Sat, 21 Nov 2020 05:22:07 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB01.amd.com (10.181.40.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 20 Nov 2020 23:22:03 -0600 Received: from SATLEXMB01.amd.com (10.181.40.142) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 20 Nov 2020 23:22:02 -0600 Received: from ubuntu-1604-test.amd.com (10.180.168.240) by SATLEXMB01.amd.com (10.181.40.142) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Fri, 20 Nov 2020 23:22:02 -0600 From: Andrey Grodzovsky To: , , , , , , , Subject: [PATCH v3 11/12] drm/amdgpu: Register IOMMU topology notifier per device. Date: Sat, 21 Nov 2020 00:21:21 -0500 Message-ID: <1605936082-3099-12-git-send-email-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1605936082-3099-1-git-send-email-andrey.grodzovsky@amd.com> References: <1605936082-3099-1-git-send-email-andrey.grodzovsky@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 598de168-be40-4e39-64f9-08d88ddd63bb X-MS-TrafficTypeDiagnostic: BY5PR12MB4274: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3383; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: N2TStV9/+mI28xHWBZj6E9dghlE48IgWRZVbIO9yu/BktHG+vGXd8HYfMcAfEwWyNNyZYA6s8MwWqFEb1mqZ9tcpWvLXxTG9o/8X71VEbo55m5uNBtgw9xweX4YSrDyXiRkrWxfIK6Zc1XK3n1/gTMD0fQPbVoSJVRFumDy31cUhdcN/uN4+9oMiGi9RlELzU/2aQ9XhUHSyKir0TQAjwk6jpLUsRaNdHxWymWjBK+buGmN4pfqVhbz4lpgHIYwY1UjRs7u5dvfAEMSfPpKEjDX9uMhGLyoBzZ0cjA50kpWG+TXBYE2LbAQeOcmi4ImFdX7RetHxpgeCXZcKF9vm+PrzvE+1GF4KTvQpiCXQtHx3QpX/6sAOO4rLki/e38sTJtiCLYRwJSgf6UIlUtP9vw== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SATLEXMB01.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(396003)(136003)(346002)(39860400002)(376002)(46966005)(6666004)(336012)(82310400003)(316002)(110136005)(5660300002)(36756003)(7416002)(7696005)(356005)(426003)(70206006)(81166007)(86362001)(26005)(2616005)(70586007)(54906003)(478600001)(2906002)(186003)(83380400001)(4326008)(8936002)(47076004)(44832011)(8676002)(82740400003); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2020 05:22:07.2989 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 598de168-be40-4e39-64f9-08d88ddd63bb 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=[SATLEXMB01.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT027.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4274 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: Alexander.Deucher@amd.com, gregkh@linuxfoundation.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Handle all DMA IOMMU gropup related dependencies before the group is removed. Signed-off-by: Andrey Grodzovsky --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 5 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 46 ++++++++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 10 +++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 2 ++ 6 files changed, 65 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 6243f6d..c41957e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -51,6 +51,7 @@ #include #include #include +#include #include #include @@ -1044,6 +1045,10 @@ struct amdgpu_device { bool in_pci_err_recovery; struct pci_saved_state *pci_state; + + struct notifier_block nb; + struct blocking_notifier_head notifier; + struct list_head device_bo_list; }; 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 96368a8..bc84c20 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -70,6 +70,8 @@ #include #include +#include + MODULE_FIRMWARE("amdgpu/vega10_gpu_info.bin"); MODULE_FIRMWARE("amdgpu/vega12_gpu_info.bin"); MODULE_FIRMWARE("amdgpu/raven_gpu_info.bin"); @@ -3179,6 +3181,39 @@ static const struct attribute *amdgpu_dev_attributes[] = { }; +static int amdgpu_iommu_group_notifier(struct notifier_block *nb, + unsigned long action, void *data) +{ + struct amdgpu_device *adev = container_of(nb, struct amdgpu_device, nb); + struct amdgpu_bo *bo = NULL; + + /* + * Following is a set of IOMMU group dependencies taken care of before + * device's IOMMU group is removed + */ + if (action == IOMMU_GROUP_NOTIFY_DEL_DEVICE) { + + spin_lock(&ttm_bo_glob.lru_lock); + list_for_each_entry(bo, &adev->device_bo_list, bo) { + if (bo->tbo.ttm) + ttm_tt_unpopulate(bo->tbo.ttm); + } + spin_unlock(&ttm_bo_glob.lru_lock); + + if (adev->irq.ih.use_bus_addr) + amdgpu_ih_ring_fini(adev, &adev->irq.ih); + if (adev->irq.ih1.use_bus_addr) + amdgpu_ih_ring_fini(adev, &adev->irq.ih1); + if (adev->irq.ih2.use_bus_addr) + amdgpu_ih_ring_fini(adev, &adev->irq.ih2); + + amdgpu_gart_dummy_page_fini(adev); + } + + return NOTIFY_OK; +} + + /** * amdgpu_device_init - initialize the driver * @@ -3283,6 +3318,8 @@ int amdgpu_device_init(struct amdgpu_device *adev, INIT_WORK(&adev->xgmi_reset_work, amdgpu_device_xgmi_reset_func); + INIT_LIST_HEAD(&adev->device_bo_list); + adev->gfx.gfx_off_req_count = 1; adev->pm.ac_power = power_supply_is_system_supplied() > 0; @@ -3553,6 +3590,15 @@ int amdgpu_device_init(struct amdgpu_device *adev, if (amdgpu_device_cache_pci_state(adev->pdev)) pci_restore_state(pdev); + BLOCKING_INIT_NOTIFIER_HEAD(&adev->notifier); + adev->nb.notifier_call = amdgpu_iommu_group_notifier; + + if (adev->dev->iommu_group) { + r = iommu_group_register_notifier(adev->dev->iommu_group, &adev->nb); + if (r) + goto failed; + } + return 0; failed: diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c index e01e681..34c17bd 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c @@ -92,7 +92,7 @@ static int amdgpu_gart_dummy_page_init(struct amdgpu_device *adev) * * Frees the dummy page used by the driver (all asics). */ -static void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev) +void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev) { if (!adev->dummy_page_addr) return; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h index afa2e28..5678d9c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h @@ -61,6 +61,7 @@ int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev); void amdgpu_gart_table_vram_unpin(struct amdgpu_device *adev); int amdgpu_gart_init(struct amdgpu_device *adev); void amdgpu_gart_fini(struct amdgpu_device *adev); +void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev); int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset, int pages); int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset, diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index b191701..731c9889 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -94,6 +94,10 @@ static void amdgpu_bo_destroy(struct ttm_buffer_object *tbo) } amdgpu_bo_unref(&bo->parent); + spin_lock(&ttm_bo_glob.lru_lock); + list_del(&bo->bo); + spin_unlock(&ttm_bo_glob.lru_lock); + kfree(bo->metadata); kfree(bo); } @@ -616,6 +620,12 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, if (bp->type == ttm_bo_type_device) bo->flags &= ~AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED; + INIT_LIST_HEAD(&bo->bo); + + spin_lock(&ttm_bo_glob.lru_lock); + list_add_tail(&bo->bo, &adev->device_bo_list); + spin_unlock(&ttm_bo_glob.lru_lock); + return 0; fail_unreserve: diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h index 621c0bf..b53b7e0 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h @@ -112,6 +112,8 @@ struct amdgpu_bo { struct list_head shadow_list; struct kgd_mem *kfd_bo; + + struct list_head bo; }; static inline struct amdgpu_bo *ttm_to_amdgpu_bo(struct ttm_buffer_object *tbo) From patchwork Sat Nov 21 05:21:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 11923215 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2B89C6379F for ; Sat, 21 Nov 2020 05:22:17 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5107C22210 for ; Sat, 21 Nov 2020 05:22:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="gWSXBUPA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5107C22210 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9CCD66E985; Sat, 21 Nov 2020 05:22:16 +0000 (UTC) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2069.outbound.protection.outlook.com [40.107.223.69]) by gabe.freedesktop.org (Postfix) with ESMTPS id 82A4C6E983; Sat, 21 Nov 2020 05:22:14 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Kg0JMvji1VXdHj60HV180+Z8QYnIPxolgLNpvIeKG3gXmXqJxQxyWvcPsCbyA1NGg2vi+oBAOVAytiyTTFIWRRL1z3SfKkrJe1yUwggwpsm/M52PX1oQYBONds+80vNDLQeLXqN5QSyFQsBWJZSXy4cNOqvKI+7jBmfDrWdflm7neLLgHHUTKNxr2AnA5SRXV+bmPvS7DvKLjXPuaVe3ZscgUYVwRx3CXifiQ/FHNsqeTXNlXN+OTnJr4Dk9aExfwAjhohr2ur7ZkSaXz4WQq24Y8DiMKL6ztSnZNPOxaj4mgnbhONqmD7caH7br7voMnQVzgV168met36Vzd61X0w== 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-SenderADCheck; bh=jsrozk3gekHp8aQM2w7jt4fHgrGLcAQ4RWpP0KtUvbQ=; b=ZWwrwKiuxnYOHGqEo/Fiv8b+Pwtbx2Z3m77dKZsntAwUDQQWZhAhSmmGIwmnkchUaTB29IvcfDQCspBMGFoHI/Ilxpg1EdZeYEbunodZOHHPM2b28UgzW/YiM64Kvqq4cCZa1iXL15ZFfSQKS6Je31hzjnFNaA+FpE7nHz9G/9WTUrP2LVjpV0PKsa0pVHI/e9TG+R4fqsOffHIyBwpDXAVCVYjpfY620rkqioOaiYVrEv/H1YiYsyK9ifk+dsb/zPlkJNu9L4rpAeBLcQm/v0vh2Vv3UsNvaE3gsbJqiAC0rXH7BoI5c8qGZLJxc89SD64rBpsD/TEoV4tiI2xtzA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=fail (p=none sp=none 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=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jsrozk3gekHp8aQM2w7jt4fHgrGLcAQ4RWpP0KtUvbQ=; b=gWSXBUPAR8KBzbkGq8kTZq66ZQSWQYs8HFvQab7vYUzr+rZNQJgZ9USZTcQydzy46LrE6LNWV+9YctoWZoB1fpfh/CT2qF8y71R6HPvuFuYV599xg/7LDEQuorSNHFoy18OI4JfR6+nocHYYkgsdec+Okk8huHIXoAOn5yM8i0g= Received: from DM5PR12CA0050.namprd12.prod.outlook.com (2603:10b6:3:103::12) by BY5PR12MB4034.namprd12.prod.outlook.com (2603:10b6:a03:205::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.20; Sat, 21 Nov 2020 05:22:12 +0000 Received: from DM6NAM11FT012.eop-nam11.prod.protection.outlook.com (2603:10b6:3:103:cafe::46) by DM5PR12CA0050.outlook.office365.com (2603:10b6:3:103::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.21 via Frontend Transport; Sat, 21 Nov 2020 05:22:12 +0000 X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=fail action=none header.from=amd.com; Received-SPF: SoftFail (protection.outlook.com: domain of transitioning amd.com discourages use of 165.204.84.17 as permitted sender) Received: from SATLEXMB02.amd.com (165.204.84.17) by DM6NAM11FT012.mail.protection.outlook.com (10.13.173.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3589.22 via Frontend Transport; Sat, 21 Nov 2020 05:22:11 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB02.amd.com (10.181.40.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 20 Nov 2020 23:22:11 -0600 Received: from SATLEXMB01.amd.com (10.181.40.142) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 20 Nov 2020 23:22:10 -0600 Received: from ubuntu-1604-test.amd.com (10.180.168.240) by SATLEXMB01.amd.com (10.181.40.142) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Fri, 20 Nov 2020 23:22:10 -0600 From: Andrey Grodzovsky To: , , , , , , , Subject: [PATCH v3 12/12] drm/amdgpu: Fix a bunch of sdma code crash post device unplug Date: Sat, 21 Nov 2020 00:21:22 -0500 Message-ID: <1605936082-3099-13-git-send-email-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1605936082-3099-1-git-send-email-andrey.grodzovsky@amd.com> References: <1605936082-3099-1-git-send-email-andrey.grodzovsky@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0026c668-b2e6-49c6-acba-08d88ddd667b X-MS-TrafficTypeDiagnostic: BY5PR12MB4034: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:346; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: K1gH245yGhsurSP9Hldjpe6qF2b2xMv8LlVBBcCkdKzPB9rTLY9IZ0bmS5R/oVw5T1bzhvMyMhtT1Z5CNcB3ex2EbfY8mgeEus3N7weiI2Vqt7CYsDPQ0RdL+tNZfFk/uhQ5ppY5ULbCOBaT2QRwuGqcf+6Cxz8Kwl43faKqE2N8GMQTX16c7WWX8TjE2hqnywFkDqOjRdcNxCYrdWykNSWhGjNXnj09GoDG3gk1O7CU+TBm/tmiVvAKPBrK4NnIoF7tCmWipRL5xUhHErkwVoKK8uMlau09raukxc76Yt3g9gUkBla147LeWEwZ/WE81VYUjkJuHYNHVFvU8pvHKrZZ130dc9VDIrxyVbBw4EkbSpivKLXIE8zkyYVxWCVmbHh4gA3ZjO4VU7vOadj7Ow== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SATLEXMB02.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(396003)(376002)(136003)(346002)(39860400002)(46966005)(70206006)(70586007)(6666004)(47076004)(4326008)(356005)(8936002)(2616005)(36756003)(7416002)(82310400003)(336012)(8676002)(82740400003)(26005)(86362001)(81166007)(5660300002)(2906002)(316002)(186003)(54906003)(44832011)(478600001)(426003)(83380400001)(110136005)(7696005); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2020 05:22:11.7886 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0026c668-b2e6-49c6-acba-08d88ddd667b 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=[SATLEXMB02.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT012.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4034 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: Alexander.Deucher@amd.com, gregkh@linuxfoundation.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" We can't allocate and submit IBs post device unplug. Signed-off-by: Andrey Grodzovsky --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index fdbe7d4..a62ad20 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -31,6 +31,7 @@ #include #include +#include #include "amdgpu.h" #include "amdgpu_trace.h" #include "amdgpu_amdkfd.h" @@ -1602,7 +1603,10 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, struct amdgpu_vm_update_params params; enum amdgpu_sync_mode sync_mode; uint64_t pfn; - int r; + int r, idx; + + if (!drm_dev_enter(&adev->ddev, &idx)) + return -ENOENT; memset(¶ms, 0, sizeof(params)); params.adev = adev; @@ -1645,6 +1649,8 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, if (r) goto error_unlock; + + drm_dev_exit(idx); do { uint64_t tmp, num_entries, addr;