From patchwork Sat May 9 18:51:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 11538479 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 665891668 for ; Sat, 9 May 2020 18:52:28 +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 450DD2072F for ; Sat, 9 May 2020 18:52:28 +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="vrSj0loO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 450DD2072F Authentication-Results: mail.kernel.org; dmarc=none (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 92E4E6E397; Sat, 9 May 2020 18:52:18 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2046.outbound.protection.outlook.com [40.107.223.46]) by gabe.freedesktop.org (Postfix) with ESMTPS id DAAB46E0AD; Sat, 9 May 2020 18:52:16 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iRf/KugzX1IxpTvv7bAUIhseVBkO80ib9akk/+ihtyEfe61Ei1KpGRnpdKJaE+75OMwxSUMDSFLYE0W9V0rUQ69qC9CGTrhPyZCIc17yBtAsGV4xKBWzKjyv67jSkubSSOWX8YQ89sCjl6NpABD4CseVBsFU9wA/rcIf8p6UG8DpHWt3O7y6zKWS4YzS8RX/2TMb3AogeAv3EOq0PNRTpz4FVe+lRnxW8rhUgdHsLs5aQKUMoGzzRQQvj1T1D+llNsmQLNqioqxYdeBBsmWpMvh1dwC4lkkqHFh8IoxhxwW4GxgXkS4CitiWXDCdlisgYaacihf/38KZktcqcSUleA== 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=lwCMmCKmyZXvvhFINGmUUmA0Vz6VXlMRhr4P3gBVDLM=; b=k6YxLFVibbmURI6uSbZGhPpGur1Ht4n8oUSvdisP0gIX6USS3s8mBjgLl7Fl0K69p2OfmrlagWC+1m9AKlhcFs9HAw5rlC96EDVG40Ro7yr6wdOTumSSEiBLZBmC/YXdMhccpwWr7zELxKRF444rTMvXB0Gozjk1xX0maB50ETEMOnF3/sQMw3swX7uP1OOSa6SPv8MxeMpkX0T8mFAe33EheU06szK63tbO4ocK3XeSzEZCHJt3zoOZ3cbN1DXVM+lFKddmvxTQ65157PhyH1eGEJG+6F76RwFW8u6U7Gj4C2FafqR5cnDx0j5tiJ5H8zNzCPh/KESr+22Zg9I2ZQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=permerror 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=lwCMmCKmyZXvvhFINGmUUmA0Vz6VXlMRhr4P3gBVDLM=; b=vrSj0loOtrX+xDCpWbsiGP839Fs9fbRWnJxLt49afqwqUfNRnn4cO/U7hidpjDDAQvnyFpZy6ksw44wKs5jLZbdhFrlbJq4z3+6nA6mr0GbfyCa0lDPc729KUFMNjSDoIGPhOd6ZT+KwmuaJv56/eckiwMStr1+A4MAkAUOR1Uk= Received: from DM5PR15CA0052.namprd15.prod.outlook.com (2603:10b6:3:ae::14) by CY4PR1201MB2503.namprd12.prod.outlook.com (2603:10b6:903:d1::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.28; Sat, 9 May 2020 18:52:14 +0000 Received: from DM6NAM11FT035.eop-nam11.prod.protection.outlook.com (2603:10b6:3:ae:cafe::e2) by DM5PR15CA0052.outlook.office365.com (2603:10b6:3:ae::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.27 via Frontend Transport; Sat, 9 May 2020 18:52:14 +0000 Authentication-Results: spf=none (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=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXMB02.amd.com (165.204.84.17) by DM6NAM11FT035.mail.protection.outlook.com (10.13.172.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.2979.27 via Frontend Transport; Sat, 9 May 2020 18:52:13 +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.1713.5; Sat, 9 May 2020 13:52:12 -0500 Received: from SATLEXMB02.amd.com (10.181.40.143) 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.1713.5; Sat, 9 May 2020 13:52:12 -0500 Received: from agrodzovsky-All-Series.amd.com (10.180.168.240) by SATLEXMB02.amd.com (10.181.40.143) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Sat, 9 May 2020 13:52:12 -0500 From: Andrey Grodzovsky To: , Subject: [PATCH 1/6] drm/ttm: Add unampping of the entire device address space Date: Sat, 9 May 2020 14:51:45 -0400 Message-ID: <1589050310-19666-2-git-send-email-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1589050310-19666-1-git-send-email-andrey.grodzovsky@amd.com> References: <1589050310-19666-1-git-send-email-andrey.grodzovsky@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant 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; SFTY:; SFS:(4636009)(376002)(396003)(39860400002)(346002)(136003)(46966005)(33430700001)(4326008)(36756003)(426003)(5660300002)(110136005)(8936002)(44832011)(54906003)(86362001)(82740400003)(336012)(316002)(7696005)(2906002)(2616005)(356005)(47076004)(81166007)(33440700001)(82310400002)(70586007)(26005)(478600001)(6666004)(70206006)(8676002)(186003); DIR:OUT; SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c952b311-8393-44f6-3b80-08d7f44a1661 X-MS-TrafficTypeDiagnostic: CY4PR1201MB2503: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1013; X-Forefront-PRVS: 03982FDC1D X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YmMrv2luw0Gcvss2xoP05O/LTZ8l9G84c+bV0NTJVJQlz19iSmr0aVn1K04exS2Zka7wPExbwdSy/c0pyr0Q5K3B/2NvbJDonyn2V9ned4lBONwO42ZGA3H23tHV8zrZG4cfZdKT+7xGkzwTqT0+IVN5rz+aw7ts+kOe0O9QsIgVL29E2upPT3c8791zeqt83GFiUVUU61Y1bFy/tHt5Fz1YorTEOJSEPrdXtPqNnB5zK1zkjp+yDICQk6s3pEGeUSSjjeTbk7ovXKEhKWrGs8YveZbU7yUJsikxYRpZA4V1+Z9CG1cc58v+VHG9tyWD4RrQJjlvWIgkwV8btttLnZNJLVLL7FMiOBje34tQQiPepX5rQ8m+B0TTTbiMxPWmaOOWSUh0nhTHYes5qyF+LtQOocRjiqww7OQ68AS+njMqMuMQuJM+V2qElEXJgNDEPfp86joV7zYKofqYZZQ5V5L7SIGIjgwXKcRukNbhiklOgEWalc3t+C9izOMJW+e4l4WgigbGKBNlHT7MqjD+pvFG8K/CW8AMiDAUeg1tZg6PQYrwifqLZeeoyM8MUDhot+3RMaXXJeSg7sBj4PpPVg== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2020 18:52:13.5533 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c952b311-8393-44f6-3b80-08d7f44a1661 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-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1201MB2503 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: daniel.vetter@ffwll.ch, michel@daenzer.net, ckoenig.leichtzumerken@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Signed-off-by: Andrey Grodzovsky --- drivers/gpu/drm/ttm/ttm_bo.c | 22 +++++++++++++++++++++- include/drm/ttm/ttm_bo_driver.h | 2 ++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index c5b516f..eae61cc 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -1750,9 +1750,29 @@ void ttm_bo_unmap_virtual(struct ttm_buffer_object *bo) ttm_bo_unmap_virtual_locked(bo); ttm_mem_io_unlock(man); } +EXPORT_SYMBOL(ttm_bo_unmap_virtual); +void ttm_bo_unmap_virtual_address_space(struct ttm_bo_device *bdev) +{ + struct ttm_mem_type_manager *man; + int i; -EXPORT_SYMBOL(ttm_bo_unmap_virtual); + for (i = 0; i < TTM_NUM_MEM_TYPES; i++) { + man = &bdev->man[i]; + if (man->has_type && man->use_type) + ttm_mem_io_lock(man, false); + } + + unmap_mapping_range(bdev->dev_mapping, 0, 0 , 1); + /*TODO What about ttm_mem_io_free_vm(bo) ? */ + + for (i = TTM_NUM_MEM_TYPES - 1; i >= 0; i--) { + man = &bdev->man[i]; + if (man->has_type && man->use_type) + ttm_mem_io_unlock(man); + } +} +EXPORT_SYMBOL(ttm_bo_unmap_virtual_address_space); int ttm_bo_wait(struct ttm_buffer_object *bo, bool interruptible, bool no_wait) diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index c9e0fd0..3133463 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -600,6 +600,8 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev, */ void ttm_bo_unmap_virtual(struct ttm_buffer_object *bo); +void ttm_bo_unmap_virtual_address_space(struct ttm_bo_device *bdev); + /** * ttm_bo_unmap_virtual * From patchwork Sat May 9 18:51:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 11538487 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2ED521668 for ; Sat, 9 May 2020 18:52:37 +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 0D9622072F for ; Sat, 9 May 2020 18:52:37 +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="ObvLJD4K" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0D9622072F Authentication-Results: mail.kernel.org; dmarc=none (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 EF61D6E3B8; Sat, 9 May 2020 18:52:24 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2049.outbound.protection.outlook.com [40.107.243.49]) by gabe.freedesktop.org (Postfix) with ESMTPS id E39436E398; Sat, 9 May 2020 18:52:20 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=axiX86+NpVT5DPzkriq3pz/nBu/VJ4vkQAnSp38l256xF6fHOw5Z8R+roNdusU14k9I6e59IrF9aXoz4jw8sFLMF8BRI74DWrU18mqMqYW20C6q6C1Uq43X9DlIkQmARvGDc0ucrDFgeUQykB2oEUNvyDZBzw2qWluq4EqqFwNJ5kqE/snZdvp+PwGnaHxgxTt5Sj/ZqAVDbdIxnqvehKtUqOqFbx1Knriq3HKBOCHyJku9qkU432FJIgD7wtworYQv2s6JG+M7dNVICGInZ6FfaZ5uCcSQkQsq1D3HpvWIPey9KGh/6pdAx54+pe4o6hmvqPv0uGk5RpdYoc1slXg== 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=5W9BKV/jtDYbnBXpvIQ0FEk7nr+GMOiFZC6YHQNjNBs=; b=TtSKz3f0NfKtj4Z4OhD53SBhi+cOB7eM95yK9SSb0DsjI+Nc83/xbf2BjAIq1SjUto/3RfiXEi56i0Pt1D8kIrNF2lYerM6BQliQsmWlB7aoJ3u0kOp0xSTi+2UonfJT79FbdpEZPmj+c7nDDcZof371vF/rk+YSRlfKfv3LqpirBHs55FTa05168AlZwaM4XQxa5/YKo5717nYfyqzXZDpHek8kV0QDNtWt9l9MhAC0LIG55FS8miiOwS3Py5cb4JYOOCskeW/jx+fURGkmInenljKCim7z8mgOfzYxyUAt3CnXKIMHsafyJ+re+n+8YdZEV9nhnwMZGfnDGGp8qw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=permerror 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=5W9BKV/jtDYbnBXpvIQ0FEk7nr+GMOiFZC6YHQNjNBs=; b=ObvLJD4KWGBdW745gEOg33aDA/B1AonQwpX0H5Isz2L5dpbfjwYbve1I4h74Md7Ffe5hGvj/XkxKqUYqeUj1Kur4LqCHfjVU0r0jkDwQVaolPmQTecTDFu83O+JfTl93wgGnivtJf63+V3MaTepvj1rd0BgLApcEE7lian7NVNg= Received: from MWHPR15CA0060.namprd15.prod.outlook.com (2603:10b6:301:4c::22) by DM5PR12MB1532.namprd12.prod.outlook.com (2603:10b6:4:6::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.33; Sat, 9 May 2020 18:52:16 +0000 Received: from CO1NAM11FT008.eop-nam11.prod.protection.outlook.com (2603:10b6:301:4c:cafe::25) by MWHPR15CA0060.outlook.office365.com (2603:10b6:301:4c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.27 via Frontend Transport; Sat, 9 May 2020 18:52:16 +0000 Authentication-Results: spf=none (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=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXMB01.amd.com (165.204.84.17) by CO1NAM11FT008.mail.protection.outlook.com (10.13.175.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.2979.27 via Frontend Transport; Sat, 9 May 2020 18:52:15 +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.1713.5; Sat, 9 May 2020 13:52:14 -0500 Received: from SATLEXMB02.amd.com (10.181.40.143) 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.1713.5; Sat, 9 May 2020 13:52:14 -0500 Received: from agrodzovsky-All-Series.amd.com (10.180.168.240) by SATLEXMB02.amd.com (10.181.40.143) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Sat, 9 May 2020 13:52:13 -0500 From: Andrey Grodzovsky To: , Subject: [PATCH 2/6] drm/amdgpu: Force unmap all user VMAs on device removal. Date: Sat, 9 May 2020 14:51:46 -0400 Message-ID: <1589050310-19666-3-git-send-email-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1589050310-19666-1-git-send-email-andrey.grodzovsky@amd.com> References: <1589050310-19666-1-git-send-email-andrey.grodzovsky@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant 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; SFTY:; SFS:(4636009)(136003)(346002)(396003)(376002)(39860400002)(46966005)(33430700001)(5660300002)(186003)(36756003)(47076004)(8676002)(4326008)(82310400002)(70206006)(26005)(6666004)(70586007)(316002)(54906003)(8936002)(110136005)(7696005)(2906002)(81166007)(2616005)(82740400003)(336012)(33440700001)(86362001)(478600001)(426003)(44832011)(356005); DIR:OUT; SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a2e79030-255f-4ae0-dec5-08d7f44a1770 X-MS-TrafficTypeDiagnostic: DM5PR12MB1532: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-Forefront-PRVS: 03982FDC1D X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ajEflt1lmlYk3TByr9fJ8cafSrdM350h5wTMfnPu7ENNIc+H3EMQdqOteq3IjhS4MuX82s/sHMLWKzc6y4XKqbAWNlsAWcaNUrj0gxGWPfcY5pZrWNQzi96RaO0sf4Txg93PmTz725WPGs8R0dUsGMiN/2SQZqncp45JQ30IhVfYpauGBJHW70kabwP0Tkrq4JaOfpXeDdK02f+D+FfR/utaJOncaBbOi/ddfhFqnVIRzBELb5U9w2o3XGMFCSNjiT+eqbdv/sedevKRlsqiuU/9Bu0F1xvetHpBzMZaeVBThPoBnTzXXhNYPxY3NJH7WFaFai32/4gsei1VO8jzghZCKz5uuOD+rEEoi9mDIAgNk/wcrtzTL9UJ/1MgR+DW0auuIxHkl/q2SQsdXGdtTa6kWaW+hX19wNqodGrqU3xfWT1SVaCxAWDtl2jyLtzjzhxJmF2WAdeA/fWqtPUd7RgZOANd/+oYCWaYIk0Aqx5W3QdNVltEZY2VYT7ZaS1788UIGtWZL54NWEA5dgvXgd4XyRbAc1PvhZB5zl2lp0hanPgY1zl+VPjRnxfKVHTH6/gegEEQI0vxRhZSBgdTzA== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2020 18:52:15.2625 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a2e79030-255f-4ae0-dec5-08d7f44a1770 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-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1532 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: daniel.vetter@ffwll.ch, michel@daenzer.net, ckoenig.leichtzumerken@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Signed-off-by: Andrey Grodzovsky --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 +++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 14 ++++++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 4 ++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index e6978a2..4da52b7 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -1374,8 +1374,10 @@ amdgpu_device_ip_get_ip_block(struct amdgpu_device *adev, enum amd_ip_block_type type) { int i; - for (i = 0; i < adev->num_ip_blocks; i++) + + + if (adev->ip_blocks[i].version->type == type) return &adev->ip_blocks[i]; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index 76a6198..ea2b47e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -1130,16 +1130,22 @@ static int amdgpu_pci_probe(struct pci_dev *pdev, return ret; } +static void amdgpu_force_unmap_user_space_mappings(struct drm_device *dev) +{ + struct amdgpu_device *adev = dev->dev_private; + + ttm_bo_unmap_virtual_address_space(&adev->mman.bdev); +} + static void 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_force_unmap_user_space_mappings(dev); + amdgpu_driver_unload_kms(dev); pci_disable_device(pdev); pci_set_drvdata(pdev, NULL); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 3d822eb..22afd11 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -35,6 +35,7 @@ #include #include +#include #include "amdgpu.h" #include "amdgpu_trace.h" #include "amdgpu_amdkfd.h" @@ -1361,6 +1362,9 @@ int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo) if (!amdgpu_bo_is_amdgpu_bo(bo)) return 0; + if (drm_dev_is_unplugged(adev->ddev)) + return -ENODEV; + abo = ttm_to_amdgpu_bo(bo); /* Remember that this BO was accessed by the CPU */ From patchwork Sat May 9 18:51:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 11538481 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0B7FA139A for ; Sat, 9 May 2020 18:52:31 +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 DE1C22072F for ; Sat, 9 May 2020 18:52:30 +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="2z0j1Zxv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DE1C22072F Authentication-Results: mail.kernel.org; dmarc=none (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 36E6A6E398; Sat, 9 May 2020 18:52:21 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2040.outbound.protection.outlook.com [40.107.92.40]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2CB906E39E; Sat, 9 May 2020 18:52:19 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=enbxzSZy/V1hIt79KuhgHFz3sl0Amr4+3hIoq0WidKm8IVxtTRiFnkYeEacFtQWK7Ap7HwDwWxF9El5B1ZNGFqc0RIaPRG+8lG6lPl4Ys9WWs/eWOhGdzJW2QgMg8+sxbrLlJ3uele7D+Eqps6/rGzORwaydNt+smA2igzh9wT7A0I3pDEy5H/HQzdexsxMtrmn3cvmafTC0h4OXQhEqX4PeDrPsPgeGhrh2vIGtgcB5Z1cCOmrLcfPQYLkfhbRHRCbXKtAT3IbECZ1KkuKMKU0mzIJhkKrT1ANyjW8k74Etlfwv+9ET+Go+HWjFbqsBdXjH5IAM40XNR6S5dKC8YQ== 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=cdl2DAs24j4F/A057eRMv+6H+/of4pv+GMkaU8Nn2M8=; b=nyrOVucG0678VmeW49EjpfNhIz6O0Q1TdAjcTGpnS8aa5ydjLmvgBRWo5wXgMTEnwDe2wFHARmOX10ABbJ2klb+YoYPfsNZdvGBcNFjjgmkc4q0pTALZWh/6uT9lsBwg0Yr0VqzLpcWRXpfmU9sCzL6gCg2tN1L86iajiJXyJsOzzNH9JKlfE39LFXC4MXrkBfanvKpd+rWUb5ZKUI+WX+OpndK0QshHAEA6MLda4zh40TJbDvWRhKX6htlY2wzhBEAWdXzrG54ZFo9e52A1EPUXmQMleF1bP7DQI/kbFzn3dZDk6sHebAPSZuH+R4lZ50/L/0RLCG7sIT29CLoJwQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=permerror 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=cdl2DAs24j4F/A057eRMv+6H+/of4pv+GMkaU8Nn2M8=; b=2z0j1Zxvkj8z4WbLhCvjTGDHYFwbOaN02BAxuCQWu6naWcgt0LuRwyS8qAzcLtxWFfPKdwQGeA84ll6kDCnHHz3zzWZZ7hFSp2oNmPUkEWOkzF6iIFEoa+Cdr9wlpR9/UxF/fXKSutK4kNoiMqdS0AiidckMp20bWUrKaJR9M5s= Received: from DM3PR14CA0141.namprd14.prod.outlook.com (2603:10b6:0:53::25) by BN8PR12MB2868.namprd12.prod.outlook.com (2603:10b6:408:9c::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.33; Sat, 9 May 2020 18:52:17 +0000 Received: from DM6NAM11FT047.eop-nam11.prod.protection.outlook.com (2603:10b6:0:53:cafe::e) by DM3PR14CA0141.outlook.office365.com (2603:10b6:0:53::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.26 via Frontend Transport; Sat, 9 May 2020 18:52:17 +0000 Authentication-Results: spf=none (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=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXMB02.amd.com (165.204.84.17) by DM6NAM11FT047.mail.protection.outlook.com (10.13.172.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.2979.27 via Frontend Transport; Sat, 9 May 2020 18:52:16 +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.1713.5; Sat, 9 May 2020 13:52:15 -0500 Received: from SATLEXMB02.amd.com (10.181.40.143) 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.1713.5; Sat, 9 May 2020 13:52:15 -0500 Received: from agrodzovsky-All-Series.amd.com (10.180.168.240) by SATLEXMB02.amd.com (10.181.40.143) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Sat, 9 May 2020 13:52:15 -0500 From: Andrey Grodzovsky To: , Subject: [PATCH 3/6] drm/amdgpu: Wait for all user clients Date: Sat, 9 May 2020 14:51:47 -0400 Message-ID: <1589050310-19666-4-git-send-email-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1589050310-19666-1-git-send-email-andrey.grodzovsky@amd.com> References: <1589050310-19666-1-git-send-email-andrey.grodzovsky@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant 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; SFTY:; SFS:(4636009)(376002)(346002)(136003)(39860400002)(396003)(46966005)(33430700001)(81166007)(8936002)(82740400003)(4326008)(478600001)(7696005)(82310400002)(33440700001)(86362001)(6666004)(5660300002)(8676002)(356005)(47076004)(2616005)(44832011)(2906002)(36756003)(316002)(426003)(186003)(26005)(70586007)(110136005)(54906003)(336012)(70206006); DIR:OUT; SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e6386a75-e927-4c44-fbf9-08d7f44a181f X-MS-TrafficTypeDiagnostic: BN8PR12MB2868: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:206; X-Forefront-PRVS: 03982FDC1D X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Kje4ZOnIZZyt8lN7XwwB3nfnZQl5Wcmh1CDnreJswVYI+k7LPHEnewMj60LjGYtw56P5ZWw1/I6vBkwRzQfLmdjWH/Tdf0M2/y78jQOTTi6YnLoZBCAcm1yHTlp67twwY2uWMitMOBX+PQV6fDE5/zx/m0b8D6UhfzaWWQ7pFo2MWgHMfKmWCp8bWDaPjzqbiy60R5Dkz5x8qx56sotCkxjEj9XGemfL7+JC12bSet+2/QulnWKRMh1c3Fyutnzv4EBPWy/x73oFxGZ1BMCQY3WBdHX2GpH0WY5KqDov2bV+vZkcJQrzoSgygcJ2mMRGSxfZ1rqLpy4BL+SMmlOskI1Izvn+m0NR5oFfkWbxRPUCl6gFb15/dvpplFhAg0i0Dkac2BAI5uZFT3AxA/+NWUFWa+sZLKQWaEhW+Sg8W1hpyZk+zu3hm/M4G/p9QLjyOf/ToteDZqOBZfwy4J6ST9EEkfTFZnRAh+peGFH1vizELkYJKZOxrBOI+EmenkcOLslgZ3SLdKzZJnrBZa4gpAzol5Kk7yNhjrBAqmtv8jYvzanPy4NeF337xpFgkYpa X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2020 18:52:16.4881 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e6386a75-e927-4c44-fbf9-08d7f44a181f 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-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB2868 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: daniel.vetter@ffwll.ch, michel@daenzer.net, ckoenig.leichtzumerken@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Signed-off-by: Andrey Grodzovsky --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 4 ++++ 4 files changed, 11 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index bc1e0fd..79274d5 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -990,6 +990,8 @@ struct amdgpu_device { char product_number[16]; char product_name[32]; char serial[16]; + + wait_queue_head_t user_clients_done; }; static inline struct amdgpu_device *amdgpu_ttm_adev(struct ttm_bo_device *bdev) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 4da52b7..3bd67cf 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -3271,6 +3271,9 @@ int amdgpu_device_init(struct amdgpu_device *adev, if (r) dev_err(adev->dev, "amdgpu_pmu_init failed\n"); + + init_waitqueue_head(&adev->user_clients_done); + return 0; failed: diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index ea2b47e..0531727 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -1141,10 +1141,12 @@ static void amdgpu_pci_remove(struct pci_dev *pdev) { struct drm_device *dev = pci_get_drvdata(pdev); + struct amdgpu_device *adev = dev->dev_private; drm_dev_unplug(dev); amdgpu_force_unmap_user_space_mappings(dev); + wait_event(adev->user_clients_done, (dev->open_count == 0)); amdgpu_driver_unload_kms(dev); pci_disable_device(pdev); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c index 61fb2ef..d8fc775 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c @@ -957,8 +957,12 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file */ void amdgpu_driver_lastclose_kms(struct drm_device *dev) { + struct amdgpu_device *adev = dev->dev_private; + drm_fb_helper_lastclose(dev); vga_switcheroo_process_delayed_switch(); + + wake_up(&adev->user_clients_done); } /** From patchwork Sat May 9 18:51:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 11538483 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BDC98139A for ; Sat, 9 May 2020 18:52:33 +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 97F002072F for ; Sat, 9 May 2020 18:52:33 +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="z/p4HAg1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 97F002072F Authentication-Results: mail.kernel.org; dmarc=none (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 113EF6E3A4; Sat, 9 May 2020 18:52:23 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-eopbgr770077.outbound.protection.outlook.com [40.107.77.77]) by gabe.freedesktop.org (Postfix) with ESMTPS id 29C446E3A6; Sat, 9 May 2020 18:52:22 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HTMPTDlnsmspcXu8gq8P3ZLwIBqO/SaimONwX+N2KecXJnjp8zVHda27HqbWFhgaBwpCusIz/Kxkh8x6KrXJcnrsIf0+ea0H9ncHwZ3+16qxgVddnqDoveVJZzDtUG7ifpETTwL2cdy3AJFh1lWpciTEzL7rr4MyfPv1Hv8ICHxS8NQq0QOKjMhdqoZzfq6akvkEY2AmYDzAokL7zQxv62gbfZKBRqBPA02FgMaFLgi6vjE60LLY+aqOoXkwlrOmPWJUyHQWSab18LoWlDK3SFSCIVVBQeea7erQ8CckEzF7qGhA99/Sz+lWDD6cCBcUMQJuo3XTwqV9FvAqU8R7+Q== 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=0OuA9hcXlbpYuljuBqRSfrNrMlTppY5+Bg2sEvxGFd0=; b=aJwWXJhWlUOQRjnAu9U68ldwwDQ0EqCQaIQFRShvVstTyhCmSDOXLGTkdi6jGwapaE67FiKb+r5giXbbuU2yeOyw1Ar9eaW4J/noKKh+qEq84mq3V/pMCye5zuMTzET0VAo3ffE2NTZX9toMwZ0+fiHKZ4LU4TsOwqMvogbgK7HKRyApadem5t2Fb9cR9nP52z2y1ymAYDH9nQ1+zM4NmnHBgPes78DQjk95YYjdlP0/tcsz5wowRHI0s1Pf+SBkuUiUGNisk31DbdpOH30SsjvIVK6xHJStoxsXBQsEio8hmIlNHR7HOIc5nM5ySrdt2viIwGbg6RPuZ4PC+lp89w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=permerror 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=0OuA9hcXlbpYuljuBqRSfrNrMlTppY5+Bg2sEvxGFd0=; b=z/p4HAg1ZoTCoOHFGQjR31Lb2J/Uf7jOejJOs0W6A7WkPQAmShHazHu1wN0gpDSaW56yZZsP/cGH/TMDyt79PTyaG2R2/0ca/5B40kIKTJ3yclzpnRHqhVJ8FxG55sjW4gBIy4gqSMVywJrmkuwGF48/MTdt0FKtJpYMHRDWfPk= Received: from CO2PR18CA0051.namprd18.prod.outlook.com (2603:10b6:104:2::19) by DM5PR12MB1290.namprd12.prod.outlook.com (2603:10b6:3:74::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.33; Sat, 9 May 2020 18:52:18 +0000 Received: from CO1NAM11FT056.eop-nam11.prod.protection.outlook.com (2603:10b6:104:2:cafe::f8) by CO2PR18CA0051.outlook.office365.com (2603:10b6:104:2::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.27 via Frontend Transport; Sat, 9 May 2020 18:52:18 +0000 Authentication-Results: spf=none (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=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXMB01.amd.com (165.204.84.17) by CO1NAM11FT056.mail.protection.outlook.com (10.13.175.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.2979.27 via Frontend Transport; Sat, 9 May 2020 18:52:18 +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.1713.5; Sat, 9 May 2020 13:52:17 -0500 Received: from SATLEXMB02.amd.com (10.181.40.143) 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.1713.5; Sat, 9 May 2020 13:52:16 -0500 Received: from agrodzovsky-All-Series.amd.com (10.180.168.240) by SATLEXMB02.amd.com (10.181.40.143) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Sat, 9 May 2020 13:52:16 -0500 From: Andrey Grodzovsky To: , Subject: [PATCH 4/6] drm/amdgpu: Wait for all clients importing out dma-bufs. Date: Sat, 9 May 2020 14:51:48 -0400 Message-ID: <1589050310-19666-5-git-send-email-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1589050310-19666-1-git-send-email-andrey.grodzovsky@amd.com> References: <1589050310-19666-1-git-send-email-andrey.grodzovsky@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant 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; SFTY:; SFS:(4636009)(136003)(376002)(346002)(39860400002)(396003)(46966005)(33430700001)(81166007)(8936002)(82740400003)(4326008)(478600001)(7696005)(82310400002)(33440700001)(6666004)(5660300002)(86362001)(8676002)(47076004)(186003)(44832011)(2906002)(36756003)(2616005)(426003)(316002)(356005)(26005)(70586007)(110136005)(336012)(54906003)(70206006); DIR:OUT; SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 217e7184-cc46-45af-eb9b-08d7f44a191f X-MS-TrafficTypeDiagnostic: DM5PR12MB1290: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:60; X-Forefront-PRVS: 03982FDC1D X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4sYVdKyx3BHt+EewDiVroL6QgdHogh75B+nWf0/klEE1BnZmaNmcquU9rTr0vhcnjR7EztFDEfMYUQ2w2+u7NEdET00oIk8p2FC5NUxZCzuOEHOhqQdX0HLRWqOSGZR8xjzNo+SJ/fqIWneCm161jH3hLaxfQ64YDtJqqzuKsDrU27stozx067x02SqXqnyITlxjoJph386Az6qqp+cS5JFQtsG7Aw/X1X2YCZiMu8PMXUzNSHprh+u+bkjBtpiko9ognq+idKTgmDij50XIBL94IQOJQPur57g1KBkeHhacaOizdxua+phvLdlUtXSHCkBm7ombtK6teGxkYksUcvsjxi/3fpy2YDYWtRQZLnTgbbMg8iMXFeX23JAllMvRcklUXshdXntz+c7RxAeQqQoDbF67TxUdaIDo66Zp9DPdWqh+0wfbmgdh5BX3l2GvHtoh44vhupWHb60fDEKAGzdxg/eklfs44UUyi7cjO4oRzQsv/mTKzYFDMLzNMDWa+ZDUQVKtiO4N7Qhcy0wOKn516T3BfBE2fGfGzTHMtDRyxqk+SoqDa4Xoap7rjuz1HONdQKD0zlkB+6LNrXkeUQ== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2020 18:52:18.0795 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 217e7184-cc46-45af-eb9b-08d7f44a191f 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-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1290 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: daniel.vetter@ffwll.ch, michel@daenzer.net, ckoenig.leichtzumerken@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Also avoid GPU recovery if device is unplagged Signed-off-by: Andrey Grodzovsky --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 27 +++++++++++++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 +++- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 9 +++++++++ 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 79274d5..f212622 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -992,6 +992,7 @@ struct amdgpu_device { char serial[16]; wait_queue_head_t user_clients_done; + atomic_t exported_dma_bufs_count; }; static inline struct amdgpu_device *amdgpu_ttm_adev(struct ttm_bo_device *bdev) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c index ffeb20f..479ff98 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c @@ -36,6 +36,7 @@ #include "amdgpu_gem.h" #include "amdgpu_dma_buf.h" #include +#include #include #include @@ -116,6 +117,7 @@ int amdgpu_gem_prime_mmap(struct drm_gem_object *obj, return ret; ret = ttm_bo_mmap(vma->vm_file, vma, &adev->mman.bdev); + drm_vma_node_revoke(&obj->vma_node, vma->vm_file->private_data); return ret; @@ -179,6 +181,9 @@ static int amdgpu_dma_buf_attach(struct dma_buf *dmabuf, struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); int r; + if (drm_dev_is_unplugged(adev->ddev)) + return -ENODEV; + if (attach->dev->driver == adev->dev->driver) return 0; @@ -363,6 +368,19 @@ static int amdgpu_dma_buf_begin_cpu_access(struct dma_buf *dma_buf, return ret; } + +static void amdgpu_dma_buf_release(struct dma_buf *dma_buf) +{ + struct amdgpu_bo *bo = gem_to_amdgpu_bo(dma_buf->priv); + struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); + + drm_gem_dmabuf_release(dma_buf); + + atomic_dec(&adev->exported_dma_bufs_count); + wake_up(&adev->user_clients_done); + +} + const struct dma_buf_ops amdgpu_dmabuf_ops = { .attach = amdgpu_dma_buf_attach, .detach = amdgpu_dma_buf_detach, @@ -370,13 +388,14 @@ const struct dma_buf_ops amdgpu_dmabuf_ops = { .unpin = amdgpu_dma_buf_unpin, .map_dma_buf = amdgpu_dma_buf_map, .unmap_dma_buf = amdgpu_dma_buf_unmap, - .release = drm_gem_dmabuf_release, + .release = amdgpu_dma_buf_release, .begin_cpu_access = amdgpu_dma_buf_begin_cpu_access, .mmap = drm_gem_dmabuf_mmap, .vmap = drm_gem_dmabuf_vmap, .vunmap = drm_gem_dmabuf_vunmap, }; + /** * amdgpu_gem_prime_export - &drm_driver.gem_prime_export implementation * @gobj: GEM BO @@ -391,6 +410,7 @@ struct dma_buf *amdgpu_gem_prime_export(struct drm_gem_object *gobj, int flags) { struct amdgpu_bo *bo = gem_to_amdgpu_bo(gobj); + struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); struct dma_buf *buf; if (amdgpu_ttm_tt_get_usermm(bo->tbo.ttm) || @@ -398,8 +418,10 @@ struct dma_buf *amdgpu_gem_prime_export(struct drm_gem_object *gobj, return ERR_PTR(-EPERM); buf = drm_gem_prime_export(gobj, flags); - if (!IS_ERR(buf)) + if (!IS_ERR(buf)) { buf->ops = &amdgpu_dmabuf_ops; + atomic_inc(&((adev)->exported_dma_bufs_count)); + } return buf; } @@ -558,5 +580,6 @@ struct drm_gem_object *amdgpu_gem_prime_import(struct drm_device *dev, get_dma_buf(dma_buf); obj->import_attach = attach; + return obj; } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index 0531727..11410a9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -1146,7 +1146,9 @@ amdgpu_pci_remove(struct pci_dev *pdev) drm_dev_unplug(dev); amdgpu_force_unmap_user_space_mappings(dev); - wait_event(adev->user_clients_done, (dev->open_count == 0)); + wait_event(adev->user_clients_done, + !atomic_read(&dev->open_count) && + !atomic_read(&adev->exported_dma_bufs_count)); amdgpu_driver_unload_kms(dev); pci_disable_device(pdev); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c index 4720718..20cf36d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c @@ -28,6 +28,9 @@ #include "amdgpu.h" #include "amdgpu_trace.h" +#include + + static void amdgpu_job_timedout(struct drm_sched_job *s_job) { struct amdgpu_ring *ring = to_amdgpu_ring(s_job->sched); @@ -37,6 +40,12 @@ static void amdgpu_job_timedout(struct drm_sched_job *s_job) memset(&ti, 0, sizeof(struct amdgpu_task_info)); + + if (drm_dev_is_unplugged(adev->ddev)) { + DRM_WARN("amdgpu_job_timedout - device is unplugged, skiping!"); + return; + } + if (amdgpu_ring_soft_recovery(ring, job->vmid, s_job->s_fence->parent)) { DRM_ERROR("ring %s timeout, but soft recovered\n", s_job->sched->name); From patchwork Sat May 9 18:51:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 11538485 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3EB5B139A for ; Sat, 9 May 2020 18:52:35 +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 19FB22072F for ; Sat, 9 May 2020 18:52:35 +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="WJ6L9POx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 19FB22072F Authentication-Results: mail.kernel.org; dmarc=none (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 DD3D06E3A8; Sat, 9 May 2020 18:52:23 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2058.outbound.protection.outlook.com [40.107.243.58]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1068E6E3A4; Sat, 9 May 2020 18:52:22 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cz45G31MQjbyucWLbE28RwS7DdDE38G3RHcqGIDgQLEmJh8aGmiOjFvJJE5jF7InOiKD+hAnx7ApONLPwwIv2ss/cfj+xKAJSfaSPSd0rBaaGQ9QvgC758cpi759VIP6p/VA6n4km3gaKd4RHudDYjCa+05TT4d+P3UEDCB0QA7tyx3bHhCgzGdIjw53cmdaovqdikk6inLIMceSj3GEFy3RbauV1PtCMW2VRwLa9Lnh85R4WOx3Z3tTI6msDLRaB7LMSmTrd2DJnNoVqDNja7gkzTt9H6ZFBK/LrQPBdaqjX5riCTIFd9vrUjSPVRxh0AUXKq/ZXPtgfU0gx/LEyw== 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=jjeDr4vh00REZhKlhOWQnvTcL0JviTbO0j9R0Tu/D7U=; b=ARmxlFMOKR/0rthiAZA2+R08Fz4wWv1OGyqGVs+HLfH1Irw3vi+cY+9/hIKEfpuSdDVd758GtKc+cpAkzkuX6aWJfXT051Ae0PwWStP7WXS41WnE4wJqmkTPi0TWUUfUOI5g51f9+XwIQ4yBOKgLj47YsJq9uqZeCQC5fUfxng+1llcp9kkQn4UJWiIJCzmYvNGh0z9gxTRn8nZKlSDWHjxV3oktp7zZBBN3fucVref23HHbppNnUbEki3P5THhNAh9XGik0HQzmiXf32lkdgWMrKosV9JVKx4UXScIOylUouG/FtdGfs9dgdyOKYsHtjEZrwFpKF4U5kx4UxWXYSA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=permerror 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=jjeDr4vh00REZhKlhOWQnvTcL0JviTbO0j9R0Tu/D7U=; b=WJ6L9POxtEfQdZvafZkE09V+HC9HlqC7hw4tH68C1gI2B+HnR3r5wOS9K79qxhoWRa6be2ekH47SM716/zmJGrwhmy8KjoEEm+bDZ/r4exWJwV9jkoq4uCNN0V6+yPOxyBDPl3RXADpWDAePrubNXSW2UuxbKwVKrjq3M5BNVHI= Received: from DM5PR20CA0020.namprd20.prod.outlook.com (2603:10b6:3:93::30) by BN6PR12MB1396.namprd12.prod.outlook.com (2603:10b6:404:1b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.26; Sat, 9 May 2020 18:52:19 +0000 Received: from DM6NAM11FT037.eop-nam11.prod.protection.outlook.com (2603:10b6:3:93:cafe::10) by DM5PR20CA0020.outlook.office365.com (2603:10b6:3:93::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.27 via Frontend Transport; Sat, 9 May 2020 18:52:19 +0000 Authentication-Results: spf=none (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=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXMB02.amd.com (165.204.84.17) by DM6NAM11FT037.mail.protection.outlook.com (10.13.172.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.2979.27 via Frontend Transport; Sat, 9 May 2020 18:52:19 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) 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.1713.5; Sat, 9 May 2020 13:52:18 -0500 Received: from SATLEXMB02.amd.com (10.181.40.143) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Sat, 9 May 2020 13:52:18 -0500 Received: from agrodzovsky-All-Series.amd.com (10.180.168.240) by SATLEXMB02.amd.com (10.181.40.143) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Sat, 9 May 2020 13:52:17 -0500 From: Andrey Grodzovsky To: , Subject: [PATCH 5/6] drm/ttm: Add destroy flag in TTM BO eviction interface Date: Sat, 9 May 2020 14:51:49 -0400 Message-ID: <1589050310-19666-6-git-send-email-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1589050310-19666-1-git-send-email-andrey.grodzovsky@amd.com> References: <1589050310-19666-1-git-send-email-andrey.grodzovsky@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant 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; SFTY:; SFS:(4636009)(136003)(39860400002)(396003)(376002)(346002)(46966005)(33430700001)(316002)(7696005)(2616005)(4326008)(426003)(478600001)(356005)(70206006)(44832011)(110136005)(33440700001)(82310400002)(70586007)(54906003)(8676002)(2906002)(8936002)(47076004)(5660300002)(36756003)(186003)(81166007)(86362001)(82740400003)(6666004)(336012)(26005); DIR:OUT; SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d6e1134a-d550-4c93-f7c5-08d7f44a19b8 X-MS-TrafficTypeDiagnostic: BN6PR12MB1396: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:80; X-Forefront-PRVS: 03982FDC1D X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: q3c3lxqooF8D9HRubA+yEiIWXRaGlm9+zhMvjRBOwo7s4MM2nXde3GQvDhd8tJafcshJcK9rscdAyd+ed91JmFJz9GtLV+2pB/YfAQUbgTrSjRl6n4ts6hI+uV/pnZI0GrJTBOIV8rliMENbTcgQygmmpPxgAZ1gnb+zq4HsYUt1BLkOfgZkxLymvALBlD0UbqDQCDDp0vZKlMkExENARv3o541A5HbeaRird7lFp/ReID84620RcxVosQfkmEIW1D1p4A+E/00KdxTIEPq62d9/ch9m+p+E4LcX8hp0Ynm3qYyElNPOWxgUV8qAsTmnJpa+ZvoLfdpoksaC4Irk2CEPMSbgY0t1hoWe358aScjBGbJFi1xEr58G6XESzKAF/vckRv6OJiRS/5/lSPPP29AFo0dEuSGu1rhjAAJRhCTw5Ajq4vDQxbuzMmUI1h32gszr/WzyvcHJTKVEbiVz2t0xtXT57+kqd5rE1UuB1G6+25jsJwJ4S32n+W9gB4c+8HMzoASU3ZhwndUqaUqKuk2QY+alRkiU0/n52aSfQqCIwzbfsASuOJHkg1UR37BZiH5l2iRPm/mYJOdxm9y+aA== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2020 18:52:19.1604 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d6e1134a-d550-4c93-f7c5-08d7f44a19b8 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-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1396 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: daniel.vetter@ffwll.ch, michel@daenzer.net, ckoenig.leichtzumerken@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This will allow to invalidate, destroy backing storage and notify users of BOs when device is unpluged. Signed-off-by: Andrey Grodzovsky --- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 +- drivers/gpu/drm/nouveau/nouveau_drm.c | 2 +- drivers/gpu/drm/qxl/qxl_object.c | 4 +-- drivers/gpu/drm/radeon/radeon_object.c | 2 +- drivers/gpu/drm/ttm/ttm_bo.c | 41 ++++++++++++++++++----------- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 6 ++--- include/drm/ttm/ttm_bo_api.h | 2 +- 8 files changed, 35 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c index 1a4894f..f96c6d1 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c @@ -1145,7 +1145,7 @@ static int amdgpu_debugfs_evict_gtt(struct seq_file *m, void *data) if (r < 0) return r; - seq_printf(m, "(%d)\n", ttm_bo_evict_mm(&adev->mman.bdev, TTM_PL_TT)); + seq_printf(m, "(%d)\n", ttm_bo_evict_mm(&adev->mman.bdev, TTM_PL_TT, false)); pm_runtime_mark_last_busy(dev->dev); pm_runtime_put_autosuspend(dev->dev); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 22afd11..82d43d0 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -1046,7 +1046,7 @@ int amdgpu_bo_evict_vram(struct amdgpu_device *adev) return 0; } #endif - return ttm_bo_evict_mm(&adev->mman.bdev, TTM_PL_VRAM); + return ttm_bo_evict_mm(&adev->mman.bdev, TTM_PL_VRAM, false); } static const char *amdgpu_vram_names[] = { diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 6b1629c..f3eea89 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -759,7 +759,7 @@ nouveau_do_suspend(struct drm_device *dev, bool runtime) } NV_DEBUG(drm, "evicting buffers...\n"); - ttm_bo_evict_mm(&drm->ttm.bdev, TTM_PL_VRAM); + ttm_bo_evict_mm(&drm->ttm.bdev, TTM_PL_VRAM, false); NV_DEBUG(drm, "waiting for kernel channels to go idle...\n"); if (drm->cechan) { diff --git a/drivers/gpu/drm/qxl/qxl_object.c b/drivers/gpu/drm/qxl/qxl_object.c index ab72dc3..45bb89b 100644 --- a/drivers/gpu/drm/qxl/qxl_object.c +++ b/drivers/gpu/drm/qxl/qxl_object.c @@ -359,10 +359,10 @@ int qxl_bo_check_id(struct qxl_device *qdev, struct qxl_bo *bo) int qxl_surf_evict(struct qxl_device *qdev) { - return ttm_bo_evict_mm(&qdev->mman.bdev, TTM_PL_PRIV); + return ttm_bo_evict_mm(&qdev->mman.bdev, TTM_PL_PRIV, false); } int qxl_vram_evict(struct qxl_device *qdev) { - return ttm_bo_evict_mm(&qdev->mman.bdev, TTM_PL_VRAM); + return ttm_bo_evict_mm(&qdev->mman.bdev, TTM_PL_VRAM, false); } diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c index 140d94c..3eeeb8d 100644 --- a/drivers/gpu/drm/radeon/radeon_object.c +++ b/drivers/gpu/drm/radeon/radeon_object.c @@ -429,7 +429,7 @@ int radeon_bo_evict_vram(struct radeon_device *rdev) return 0; } #endif - return ttm_bo_evict_mm(&rdev->mman.bdev, TTM_PL_VRAM); + return ttm_bo_evict_mm(&rdev->mman.bdev, TTM_PL_VRAM, false); } void radeon_bo_force_delete(struct radeon_device *rdev) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index eae61cc..a17f87c2 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -42,6 +42,7 @@ #include #include #include +#include static void ttm_bo_global_kobj_release(struct kobject *kobj); @@ -652,7 +653,8 @@ void ttm_bo_unlock_delayed_workqueue(struct ttm_bo_device *bdev, int resched) EXPORT_SYMBOL(ttm_bo_unlock_delayed_workqueue); static int ttm_bo_evict(struct ttm_buffer_object *bo, - struct ttm_operation_ctx *ctx) + struct ttm_operation_ctx *ctx, + bool destroy) { struct ttm_bo_device *bdev = bo->bdev; struct ttm_mem_reg evict_mem; @@ -665,18 +667,23 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, placement.num_busy_placement = 0; bdev->driver->evict_flags(bo, &placement); - if (!placement.num_placement && !placement.num_busy_placement) { + evict_mem = bo->mem; + evict_mem.mm_node = NULL; + evict_mem.bus.io_reserved_vm = false; + evict_mem.bus.io_reserved_count = 0; + + if (destroy || !placement.num_placement && !placement.num_busy_placement) { ret = ttm_bo_pipeline_gutting(bo); if (ret) return ret; - return ttm_tt_create(bo, false); - } + ret = ttm_tt_create(bo, false); - evict_mem = bo->mem; - evict_mem.mm_node = NULL; - evict_mem.bus.io_reserved_vm = false; - evict_mem.bus.io_reserved_count = 0; + if (bdev->driver->move_notify) + bdev->driver->move_notify(bo, true, &evict_mem); + + return ret; + } ret = ttm_bo_mem_space(bo, &placement, &evict_mem, ctx); if (ret) { @@ -785,7 +792,8 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev, uint32_t mem_type, const struct ttm_place *place, struct ttm_operation_ctx *ctx, - struct ww_acquire_ctx *ticket) + struct ww_acquire_ctx *ticket, + bool destroy) { struct ttm_buffer_object *bo = NULL, *busy_bo = NULL; struct ttm_mem_type_manager *man = &bdev->man[mem_type]; @@ -846,7 +854,7 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev, spin_unlock(&ttm_bo_glob.lru_lock); - ret = ttm_bo_evict(bo, ctx); + ret = ttm_bo_evict(bo, ctx, destroy); if (locked) ttm_bo_unreserve(bo); @@ -919,7 +927,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo, if (mem->mm_node) break; ret = ttm_mem_evict_first(bdev, mem->mem_type, place, ctx, - ticket); + ticket, false); if (unlikely(ret != 0)) return ret; } while (1); @@ -1428,7 +1436,8 @@ int ttm_bo_create(struct ttm_bo_device *bdev, EXPORT_SYMBOL(ttm_bo_create); static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev, - unsigned mem_type) + unsigned mem_type, + bool destroy) { struct ttm_operation_ctx ctx = { .interruptible = false, @@ -1450,7 +1459,7 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev, while (!list_empty(&man->lru[i])) { spin_unlock(&glob->lru_lock); ret = ttm_mem_evict_first(bdev, mem_type, NULL, &ctx, - NULL); + NULL, destroy); if (ret) return ret; spin_lock(&glob->lru_lock); @@ -1494,7 +1503,7 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type) ret = 0; if (mem_type > 0) { - ret = ttm_bo_force_list_clean(bdev, mem_type); + ret = ttm_bo_force_list_clean(bdev, mem_type, false); if (ret) { pr_err("Cleanup eviction failed\n"); return ret; @@ -1510,7 +1519,7 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type) } EXPORT_SYMBOL(ttm_bo_clean_mm); -int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type) +int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type, bool destroy) { struct ttm_mem_type_manager *man = &bdev->man[mem_type]; @@ -1524,7 +1533,7 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type) return 0; } - return ttm_bo_force_list_clean(bdev, mem_type); + return ttm_bo_force_list_clean(bdev, mem_type, destroy); } EXPORT_SYMBOL(ttm_bo_evict_mm); diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index 71e45b56..350064f 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c @@ -468,7 +468,7 @@ static int vmw_request_device(struct vmw_private *dev_priv) if (dev_priv->cman) vmw_cmdbuf_remove_pool(dev_priv->cman); if (dev_priv->has_mob) { - (void) ttm_bo_evict_mm(&dev_priv->bdev, VMW_PL_MOB); + (void) ttm_bo_evict_mm(&dev_priv->bdev, VMW_PL_MOB, false); vmw_otables_takedown(dev_priv); } if (dev_priv->cman) @@ -501,7 +501,7 @@ static void vmw_release_device_early(struct vmw_private *dev_priv) vmw_cmdbuf_remove_pool(dev_priv->cman); if (dev_priv->has_mob) { - ttm_bo_evict_mm(&dev_priv->bdev, VMW_PL_MOB); + ttm_bo_evict_mm(&dev_priv->bdev, VMW_PL_MOB, false); vmw_otables_takedown(dev_priv); } } @@ -1227,7 +1227,7 @@ void vmw_svga_disable(struct vmw_private *dev_priv) if (dev_priv->bdev.man[TTM_PL_VRAM].use_type) { dev_priv->bdev.man[TTM_PL_VRAM].use_type = false; spin_unlock(&dev_priv->svga_lock); - if (ttm_bo_evict_mm(&dev_priv->bdev, TTM_PL_VRAM)) + if (ttm_bo_evict_mm(&dev_priv->bdev, TTM_PL_VRAM, false)) DRM_ERROR("Failed evicting VRAM buffers.\n"); vmw_write(dev_priv, SVGA_REG_ENABLE, SVGA_REG_ENABLE_HIDE | diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h index b9bc1b0..9d57b8c 100644 --- a/include/drm/ttm/ttm_bo_api.h +++ b/include/drm/ttm/ttm_bo_api.h @@ -597,7 +597,7 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type); * -ERESTARTSYS: The call was interrupted by a signal while waiting to * evict a buffer. */ -int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type); +int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type, bool destroy); /** * ttm_kmap_obj_virtual From patchwork Sat May 9 18:51:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 11538489 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8035A1668 for ; Sat, 9 May 2020 18:52:38 +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 5E7F12072F for ; Sat, 9 May 2020 18:52:38 +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="ZH0eLpmf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5E7F12072F Authentication-Results: mail.kernel.org; dmarc=none (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 118B16E3AA; Sat, 9 May 2020 18:52:27 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2082.outbound.protection.outlook.com [40.107.243.82]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4231A6E3AA; Sat, 9 May 2020 18:52:26 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Reyl+T6yfme4nl0QNheDO/Bv4N8euU3Sxf8J36lE9Za3WjVChJCMedu1NYbwKGTj9i38Rhd0lyErXSn+Xl/V8OFBnwwIn/1mUTSYgvrMFl8nw3zykuLtFNC9p+CBcMML7uxtpgokMbVTmZwgO+i+OZLQWjM6n1A9MovlcicqRE5N0P3Lq/Zd0787atom+ggtOh5ST1w38w0SuDxM+u0iSp8rljq8/hdZ+dIkiPGNz9ZuFau3mwNl2y2q3O8ZX+4SdMqcLkO3XCcy9T5hXggssBqgXTMYpapIy3CF9lw8b9K2J1zkLIhhjP3mzvOuAQbZcRgS3Kn7LU9DxtLmMQx07Q== 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=GTlcwSYa5JrGVeAxmWhBbCz16wSKrkzCfnRUtvpEEpk=; b=fDu4ecsaUV9qiFf3QK9rmfOXRXfuqLXNTvvLDaK+p2yUf5RIQ259+v6MGnQww91lhtjzkZ2nRRfpWvwpW4Pk8xib0pLRu5IVKkfDScnsQP4QsFfAV531jmH7z0d1T0NWZk2zLeP4IKbFNHhwSRAtdTfKp0+2m09u/lUbDVdwikYjiZaXkULA1pksvapy18aYQyHNXgXXPrNG7jTWW1uBwEgRA906cyu8VX9liLRXoXwqOSU7nYGV09w7ZdnrSMxjeG1LDZBro0/9k4N2jfnVJ9hDLm24u0fupAS9iivBTOudO5Yag+zA3BC/uM6lJIVS0L7wvQJIIjPsvvwbbR6xwQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=permerror 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=GTlcwSYa5JrGVeAxmWhBbCz16wSKrkzCfnRUtvpEEpk=; b=ZH0eLpmf3wZ9PLvTWtjz/4DbNjf6UW7z0/Mv0Lfww9sEM4WOKh6oVQeUwgkPJsMzuk2OmkzriDrmoUr7g7vzjeDKN/mtRelFn1V895eHuzYOCmugscKWkMAp9UfVWIVi7hjl2h+PxYVUeTBTLu78/IskIgo3JhdfVw3mv6HQHY0= Received: from MW2PR16CA0054.namprd16.prod.outlook.com (2603:10b6:907:1::31) by CY4PR12MB1749.namprd12.prod.outlook.com (2603:10b6:903:11d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.34; Sat, 9 May 2020 18:52:21 +0000 Received: from CO1NAM11FT024.eop-nam11.prod.protection.outlook.com (2603:10b6:907:1:cafe::11) by MW2PR16CA0054.outlook.office365.com (2603:10b6:907:1::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.27 via Frontend Transport; Sat, 9 May 2020 18:52:21 +0000 Authentication-Results: spf=none (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=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXMB01.amd.com (165.204.84.17) by CO1NAM11FT024.mail.protection.outlook.com (10.13.174.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.2979.27 via Frontend Transport; Sat, 9 May 2020 18:52:21 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) 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.1713.5; Sat, 9 May 2020 13:52:20 -0500 Received: from SATLEXMB02.amd.com (10.181.40.143) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Sat, 9 May 2020 13:52:19 -0500 Received: from agrodzovsky-All-Series.amd.com (10.180.168.240) by SATLEXMB02.amd.com (10.181.40.143) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Sat, 9 May 2020 13:52:19 -0500 From: Andrey Grodzovsky To: , Subject: [PATCH 6/6] drm/amdgpu: Use TTM MMs destroy interface Date: Sat, 9 May 2020 14:51:50 -0400 Message-ID: <1589050310-19666-7-git-send-email-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1589050310-19666-1-git-send-email-andrey.grodzovsky@amd.com> References: <1589050310-19666-1-git-send-email-andrey.grodzovsky@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant 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; SFTY:; SFS:(4636009)(346002)(376002)(39860400002)(396003)(136003)(46966005)(33430700001)(186003)(26005)(36756003)(2616005)(5660300002)(47076004)(7696005)(44832011)(82740400003)(478600001)(336012)(6666004)(2906002)(356005)(8936002)(316002)(4326008)(33440700001)(426003)(82310400002)(86362001)(54906003)(8676002)(70586007)(70206006)(81166007)(110136005); DIR:OUT; SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4cb8c349-46fe-4eaa-fee5-08d7f44a1aec X-MS-TrafficTypeDiagnostic: CY4PR12MB1749: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:33; X-Forefront-PRVS: 03982FDC1D X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s9RdyIQVkJYlz4WmvapVJDRS0D3diogpflmcuzlt0GTo5MS+G4qS38kh3nVslMAkWmzyyebcu2bGjAq35fXAO/VDEnjQRFnD1gh1FRim+JSqh8+2kX6wVB7Qfo2yygI2VEAY1hwbRIYrwzkK3emJW9758eu63cgrbFc93kAEUlIrM30TcLRNZXj000tz5NqwP0JuSCyNdW3gpab6hUAtecU566oZOFspdhSMq/emzO2B+/ArRwHxR9XW7928OhdQGL3Gav26n4CPP344O3y+D1JcT0J38R3+lUGl2HvgFdivqQLkajzbkpF3IpgQXElhhq1BoxgfOQAlh3td+/BbWeODwqzIvtw3HD2CtDQ/yKTmmT38w+dh0VzyQcnIoclqJwvqVTU7w0hFbwFQB69WvgMpJRyt9Eam9rDVtuRyOO7zRAz32lrxa9YUqjadK+KrW/bX0qRuBWoBnL1Wl3zOnBgywjWgmvE5IfTchgcplaYG6u1lv82xm+Rd80L8OB64ILW79bYPELhZ7HoNCr1PNJmb7we15SrrMr6I05MumfhnqLwb0SrDg26zdK4xPPyZBNrWaIpoKLblFQTjEiv5jg== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2020 18:52:21.1022 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4cb8c349-46fe-4eaa-fee5-08d7f44a1aec 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-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1749 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: daniel.vetter@ffwll.ch, michel@daenzer.net, ckoenig.leichtzumerken@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Signed-off-by: Andrey Grodzovsky --- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 11 +++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 1 + 3 files changed, 16 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index 11410a9..338b946 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -1145,7 +1145,11 @@ amdgpu_pci_remove(struct pci_dev *pdev) drm_dev_unplug(dev); + /* Will trigger SIGBUS on all subsequent CPU accesses */ amdgpu_force_unmap_user_space_mappings(dev); + + /* Will trigger VMFAULTs on all subsequent GPU successes */ + amdgpu_bo_destroy_mms(adev); wait_event(adev->user_clients_done, !atomic_read(&dev->open_count) && !atomic_read(&adev->exported_dma_bufs_count)); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 82d43d0..7eac00b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -1049,6 +1049,17 @@ int amdgpu_bo_evict_vram(struct amdgpu_device *adev) return ttm_bo_evict_mm(&adev->mman.bdev, TTM_PL_VRAM, false); } +int amdgpu_bo_destroy_mms(struct amdgpu_device *adev) +{ + int r; + + r = ttm_bo_evict_mm(&adev->mman.bdev, TTM_PL_VRAM, true); + if (!r) + return ttm_bo_evict_mm(&adev->mman.bdev, TTM_PL_TT, true); + + return r; +} + static const char *amdgpu_vram_names[] = { "UNKNOWN", "GDDR1", diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h index 7d41f7b..4892265 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h @@ -269,6 +269,7 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain, u64 min_offset, u64 max_offset); int amdgpu_bo_unpin(struct amdgpu_bo *bo); int amdgpu_bo_evict_vram(struct amdgpu_device *adev); +int amdgpu_bo_destroy_mms(struct amdgpu_device *adev); int amdgpu_bo_init(struct amdgpu_device *adev); int amdgpu_bo_late_init(struct amdgpu_device *adev); void amdgpu_bo_fini(struct amdgpu_device *adev);