From patchwork Wed May 12 14:26:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 12253881 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,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 273C1C43460 for ; Wed, 12 May 2021 14:27: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 3E73B61418 for ; Wed, 12 May 2021 14:27:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3E73B61418 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 CEAD76EC12; Wed, 12 May 2021 14:27:25 +0000 (UTC) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2086.outbound.protection.outlook.com [40.107.237.86]) by gabe.freedesktop.org (Postfix) with ESMTPS id AE08D6EC0C; Wed, 12 May 2021 14:27:23 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SpNDX9420W8P1KRsWpRaOfmCxf4mLm4PL9PeO1OKVRM3yiznowwyIgzRdC7ys4m1tykbbGDNgyEHxzf9ePyRggWncnxLxI2VKP3XePpOLhr6EASbYOVLSOiHIOxMEqgaiO1MXSFnDorLtjk+LBKRk/G+7SYyk0M/dObbFGBirWw0UfNlSrVJh20Gu9s4Tz/y9P8FR61MVEL0iEaAM42oylFoIvi4TicRKr05TWTdJA08IJN6JAc+R16HXG5fIDXjN8/U3d/VFqRIU2RKNauWqEHFLRmt4jc7zgc9OVScEryjdxwCy7wJe7uta5Mughzt1BgVFAAcn9qYRGrXeWF7DA== 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=ImiQhpPoXfItMc84rz4U+sl7ukQBW3gycLm8/fXkr9o=; b=gWTzaIXAJ31jbrWawfH1P/KCJs9mhHnqIIS0Dw+Q1nJ4JNcqJhh5Vn8CnZqqUNwpihQbojvYDH7gEzV0ldovc7zZmzuau26CjS3JpAm/zuQ86qAvWkOEONPc2gcWPp3nx1FTepclH1jdO5MNjHKpbtPKWI9IpLfrZziKKyIwrrBELKnGEn7K3GzNmwBbFVSbpRF2jFzSTGPFYZPvgWtUEgjc1LUsEQ+/ZO6fu4Zu0A+2fp68RWl1TxWHAz2JVlk/TjNFHGn8zw909sd4N0koaEZT/dkR5LBPSppWtwG9mggti5sazE2RLrykIZTGgubnMvuw7/evnVpSE9ipvGhVrA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ImiQhpPoXfItMc84rz4U+sl7ukQBW3gycLm8/fXkr9o=; b=x8z4WG+qWMtdNnH/khw7DZxsDYMTaE9m5Hl05qGM+1+QgNG6Lsrrp2s26o3QjusmJrtld/g5iqMtbV6PLNnhbOfBnO/KbR5zwQo+CLN8+ni8F9ng72i+xURnrV74UStwJSuouHaGSjdNmr6jycpujzMT1nbOJN+xKCtGIzSmM8k= Authentication-Results: lists.freedesktop.org; dkim=none (message not signed) header.d=none; lists.freedesktop.org; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB4623.namprd12.prod.outlook.com (2603:10b6:805:e9::17) by SN6PR12MB2845.namprd12.prod.outlook.com (2603:10b6:805:75::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25; Wed, 12 May 2021 14:27:21 +0000 Received: from SN6PR12MB4623.namprd12.prod.outlook.com ([fe80::ad51:8c49:b171:856c]) by SN6PR12MB4623.namprd12.prod.outlook.com ([fe80::ad51:8c49:b171:856c%7]) with mapi id 15.20.4129.026; Wed, 12 May 2021 14:27:21 +0000 From: Andrey Grodzovsky To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-pci@vger.kernel.org, ckoenig.leichtzumerken@gmail.com, daniel.vetter@ffwll.ch, Harry.Wentland@amd.com Subject: [PATCH v7 06/16] drm/amdgpu: Remap all page faults to per process dummy page. Date: Wed, 12 May 2021 10:26:38 -0400 Message-Id: <20210512142648.666476-7-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210512142648.666476-1-andrey.grodzovsky@amd.com> References: <20210512142648.666476-1-andrey.grodzovsky@amd.com> X-Originating-IP: [2607:fea8:3edf:49b0:7576:4f76:97d8:1487] X-ClientProxiedBy: YTOPR0101CA0032.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:15::45) To SN6PR12MB4623.namprd12.prod.outlook.com (2603:10b6:805:e9::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from agrodzovsky-All-Series.hitronhub.home (2607:fea8:3edf:49b0:7576:4f76:97d8:1487) by YTOPR0101CA0032.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:15::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.30 via Frontend Transport; Wed, 12 May 2021 14:27:20 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4f0ef048-18cd-4925-9568-08d915520dd4 X-MS-TrafficTypeDiagnostic: SN6PR12MB2845: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: w6+Kysu0z59GAH1eWP+zeLVLHVStGr0KRMW4OWeORaHz/JJIXMluUbNXL0Udsr3d4ZOjwNr9fr/e9CdNBFrM4npUk7yF1fxNvYOtKImJZahveSiK1hqdgZlR6MtBeExDdtSWLSsd4DjJ9oYsG5ayZICu2hFrwHgZRMeLJKtxE1gP8zy5EMV8BAjbhOqZX2PLUrU/EXUVCtQbwakEH+Y8Iwhy0LKUrmvPoLJVi2HjvTaCRx1g7qNLwBSAG7yhIC5WSME5P2+309D99g46TxVSpmd61ln9HH+j5pTDGh2cnwGSEqjyADyQFxbTeDBpse7lOUX8zOe3ZlCp/hupZ3+Lxc3GVp+PWKYg4lZ1dZg9O+GxCHPILwO+zVJ7FYD3sJbCEcS1mUWTRFpYZbJgrrjI0ANDOncPOd2GeuUQVg2ZkR77jC+bb9ts/6R3GjRUIvDprt81R/2ZroahydZJo/X9zNlx8MXV+jESHh+cxR+PiIBo4TXZWwGwD2jYWB23S21JmfzHz38LJ5IrTsa/77ydV0/HZryf5XZ9KJZaRZowyrv6sN4CzTDR/ZuU8W6s5UQvn5H0gNDZI4X+ldmUgrFsdXldSagAz/yPEDiPmK0fpHo= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR12MB4623.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39860400002)(396003)(346002)(136003)(366004)(6486002)(8676002)(54906003)(316002)(6512007)(16526019)(6636002)(478600001)(1076003)(186003)(4326008)(44832011)(2906002)(6506007)(8936002)(5660300002)(2616005)(38100700002)(66574015)(36756003)(86362001)(6666004)(66476007)(66946007)(66556008)(83380400001)(52116002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?3P+HcZmqKXvEjGv+RDjcd0WsSeHgj5?= =?utf-8?q?tyty/xhNsjDG6xsKSDyKSBozXWKz8/MVr//64xNDcZXnh0S1clo3n+GxS4noXWutS?= =?utf-8?q?/kKb0iIT3VVWNwxRZhpQvT+WKLlnAaUrZDyqk4QvpbYU8Mv/AvugTQRWGTYr4hIOR?= =?utf-8?q?6fVX17ndHJuqgOhCCkm8X4nj6u9npZGZH2+38JX8brlDkkYvWE2bCfwYeWE9wrTDj?= =?utf-8?q?jD6rtcbjIjFlVbs5GC/IiHObhh9GzcRZ51s5CdAlDqd5t97OgWBsMK0y9padof8+4?= =?utf-8?q?7WPVP75jXchZvGU3VBTLydGude1JDooFW3VRKQYeyAGtX3Y8zKWOOw/XJjEzox/7d?= =?utf-8?q?d7oHgzm3j2vMct9UIHYAIH3AToutP0QMH+Nku2w6oni14QpPFBhpWB3bGeagTrL3+?= =?utf-8?q?Jh8lBZB3v6IE6K/k+wESaDbGQl5joT4r62FSRrAH+8SuXby0uo47vNGsOX5YvChul?= =?utf-8?q?geOPNSJTwNL4D5AgN457zPIC4L5egkVF/Wuex2/WpEViBZ0XzezmoMqQDcVkU5ESA?= =?utf-8?q?44oTESwuMKvKDzeEhKgAECPxeMGvonKDYwtZViRSSdY07F6SwKmIS+d9YKe3DNbZQ?= =?utf-8?q?WKvVByHJV54aMpkUaQGnstXLBsIFj5dsOPkQfDMQtVtukIBe2W3D6u+n/XoV/soU3?= =?utf-8?q?z1RYVqkDp7j8fLhOcpbEnstUJpiZEfF3VBoYwQS5aPnavlOqnZ7TViUnIW8hTFhm4?= =?utf-8?q?064Ixr9P/gaoCSKMK8VXcdUjHcceu1kESyI0ROnxdkG1OS6FO7BJakpnRcJN7UvjR?= =?utf-8?q?VAtmF/qEDbUuFJXkeGTv84Mhn4+RDEKLTyzKTcTx8cVe60O2aFIdjkDLlBplrcIQ4?= =?utf-8?q?NRZC0ZLH8Tr3B2+XSXsRJwZZd/NMCZDsLMOgBB78JwpJyqSEdNObrGMhkGOuTcTYU?= =?utf-8?q?725zsjw2F90yEHR1Pe/66xBKMgd8X9ZF3+bbp4uJrw66bA46ihxNGYY/KMKrhsWNw?= =?utf-8?q?O4rKL97FO5lk4WudDTX6+ERoCR5PmeT7SEFvXPez9opSnyjz8LoonMm/sGKz+tCJd?= =?utf-8?q?2pf84eJzhOS9xFj0oo5b3R5JLOGnZ0Ksn0ce3wE/Kk398ofz3XEL/zwnSa1ahxGIJ?= =?utf-8?q?GmUNNLrET8I/UkwSony86ibDe3IzmyIhRGt7wPAJrqv+lKhfaPm0d9y7QV93qJ6PS?= =?utf-8?q?25v3H9ESRvO/cmbCJABdFHx0zPZ+mv/QYbW1HycgBP3CudOgGOA/VeB62UaEHs5rZ?= =?utf-8?q?+R8cCt+MHWC6QJcB25N5pEGaLgtF0KPri4rFhkbdRTdxWmFYRJiRds+6jWZD3t0bT?= =?utf-8?q?GYgLgfKYMeRrvyLuewC8325p5UWeUTChXesA1v4lr9t2PyFD/j4VUwQGV/CfIszQk?= =?utf-8?q?8ezZXNQEBrJCD?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4f0ef048-18cd-4925-9568-08d915520dd4 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB4623.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2021 14:27:21.4732 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ZL1LntA3e3ALoedGO+5LZMq9jWQ7a09q2F+oWuGY77O3DbeMwwK1UXrzv+CHEhV4EU8uxcRRx2G0gJ9VkVzF+w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2845 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: gregkh@linuxfoundation.org, Felix.Kuehling@amd.com, helgaas@kernel.org, Alexander.Deucher@amd.com, =?utf-8?q?Christian_K=C3=B6nig?= 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. v4: Update for modified ttm_bo_vm_dummy_page Signed-off-by: Andrey Grodzovsky Reviewed-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 8c7ec09eb1a4..0d54e70278ca 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -48,6 +48,7 @@ #include #include +#include #include "amdgpu.h" #include "amdgpu_object.h" @@ -1905,18 +1906,28 @@ void amdgpu_ttm_set_buffer_funcs_status(struct amdgpu_device *adev, bool enable) static vm_fault_t amdgpu_ttm_fault(struct vm_fault *vmf) { struct ttm_buffer_object *bo = vmf->vma->vm_private_data; + struct drm_device *ddev = bo->base.dev; vm_fault_t ret; + int idx; ret = ttm_bo_vm_reserve(bo, vmf); if (ret) return ret; - ret = amdgpu_bo_fault_reserve_notify(bo); - if (ret) - goto unlock; + if (drm_dev_enter(ddev, &idx)) { + ret = amdgpu_bo_fault_reserve_notify(bo); + if (ret) { + drm_dev_exit(idx); + goto unlock; + } - ret = ttm_bo_vm_fault_reserved(vmf, vmf->vma->vm_page_prot, - TTM_BO_VM_NUM_PREFAULT, 1); + ret = ttm_bo_vm_fault_reserved(vmf, vmf->vma->vm_page_prot, + TTM_BO_VM_NUM_PREFAULT, 1); + + drm_dev_exit(idx); + } else { + ret = ttm_bo_vm_dummy_page(vmf, vmf->vma->vm_page_prot); + } if (ret == VM_FAULT_RETRY && !(vmf->flags & FAULT_FLAG_RETRY_NOWAIT)) return ret;