From patchwork Thu Apr 15 02:40:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kuehling X-Patchwork-Id: 12204129 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.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 D55C5C433ED for ; Thu, 15 Apr 2021 02:40:36 +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 40573611AB for ; Thu, 15 Apr 2021 02:40:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 40573611AB 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 175966E0E9; Thu, 15 Apr 2021 02:40:33 +0000 (UTC) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2051.outbound.protection.outlook.com [40.107.94.51]) by gabe.freedesktop.org (Postfix) with ESMTPS id A63A96E0E9; Thu, 15 Apr 2021 02:40:32 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fVErOyx77n8YSaaizzrQPywrUSKSuxPNK0gL9OPS70nqpIjeZ2fiOa9F1FQQaH0yZyvhzU/R6Q2S+wkOkHPWRCkDcL0lhptEN542KMe5v/OjplzvT5tyupePjb4ix1sN4CtV4/JA9k7saQDcVX2o/KZe/02hLQvi1ZCQo89ynxC3NME9JYL2SfEcDQMNScjsF7MvlkyzeMYTXltKOpmX0UeEuJF3zM0KAL8IGZvh/oUf44kKHi6jdL0JJfLLSZWETGgGNWfAKtrobPWP1c4FACzpJxqrwCA/nyEF9O2XsbY9ZWjEtmT9gXc/fPbLMMFBudOT/GjWip1/ppkdexxAuA== 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=1vnWDD0VGV91MjnzA6LVbFV0yPVbMn9GQPQ8+RavDdQ=; b=Rpd3W1mNzHo2lm1GH+wzINDzd+Qd2EfXG7sNHhJR1BoLwRRcYuSUo8K9JWt5kxket460Fyfw/sPhja6v1bbSgSvQwK9xuaqNKQvZaZB1q8qbgSFgRaVZn8ZyebGCjUtWsYY/3vpPKFlUCfBl1lrkgkKPQ8EX5//EjOYHZ1ZdKSUCKSBmqIdNq3QmGgZ6MDwgYVzfUbkVaeVpVYJt2sOog4NiXbaV5g3/7TshZOMK7pH+dynV1fpIQVRrUBl9QlAvScpLAiPOa3dLiTpNJ7JZwat+estw/mTChYtTpqhTtDGujiGpZgHb/ssCJ5l9uPSlWiNjBczhOQWu6jKZDhfQVA== 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=1vnWDD0VGV91MjnzA6LVbFV0yPVbMn9GQPQ8+RavDdQ=; b=T/a/Y5yTXapxPQhsZ/2iMkPc3dnNF78BsyAsB4FtCqhWo6eW4I5Xhr+yR+wEDafk24ELgEtxhFEJWGorm4rg99Iomi4T5qXk9eNA6OOb0SQAvn/VC81mMVhj9HSjWoSeokf11hkxjOu7ehcPVT/ad4gX3v9OaJk8rOoHnpjC4GQ= 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 BL0PR12MB4948.namprd12.prod.outlook.com (2603:10b6:208:1cc::20) by MN2PR12MB4206.namprd12.prod.outlook.com (2603:10b6:208:1d5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.21; Thu, 15 Apr 2021 02:40:27 +0000 Received: from BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033]) by BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033%7]) with mapi id 15.20.3933.040; Thu, 15 Apr 2021 02:40:27 +0000 From: Felix Kuehling To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH v2 1/3] drm/amdkfd: Use drm_priv to pass VM from KFD to amdgpu Date: Wed, 14 Apr 2021 22:40:11 -0400 Message-Id: <20210415024013.15522-1-Felix.Kuehling@amd.com> X-Mailer: git-send-email 2.31.1 X-Originating-IP: [165.204.55.251] X-ClientProxiedBy: YTOPR0101CA0045.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:14::22) To BL0PR12MB4948.namprd12.prod.outlook.com (2603:10b6:208:1cc::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from Harpoon.amd.com (165.204.55.251) by YTOPR0101CA0045.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:14::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.21 via Frontend Transport; Thu, 15 Apr 2021 02:40:27 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 61e37a56-7c4f-4414-6430-08d8ffb7d3e5 X-MS-TrafficTypeDiagnostic: MN2PR12MB4206: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:357; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E5GOopQrcR4TSBq6pE+ELx5gdo/dnzMo2VpuVrCPAFN1zvaZw8Jwxb4DQqcYMXqg/a4sV81rAB/C+9vL4N/k50Uhi9n01Izl1bn+rydKkh9ows1uoyiBbE5mfjovmSRfT6wRGHhmdZfNw5k26lPTX11HOwjxeN7DwaEYFQXzw3YzD3P9llhoa3Ya7T6AI+B2AXrkXPQTGVii/LE/xgW8T21eX9ZqevjVeiu7OiUMiuts/g41yusCkz9TAqegt32OQt0ZtbcuD2MrRIZIccM4LVTo31ZgujW1dDohALN5A74XCjjLS43qM8dfI4WkBtYtE+WqP4X3zPVkPjGG8W0ZVC3d2JPOxIFdAQ5uki1DK3GILSnmy2oxKTg5bwSoS5ut3RpCIvgc+OEkixJOfwwghkxNrgor8+MPNzf5yBPaDMbSDNuT04Z4Xl6Ojsgus/Z7aCmGFjlzDVYX/mkIc0r7aVs+76Er/bs/NVtu74S0aPxxPxKqR0N/z1dPTy4PEErvP+vxakPcpPepq1pdrXe5is+Xo8akV8J9qdTG1gBGDQLiz9zB5bRD9UWJzN2vi+Ag0bY4h2sEDvpL1yKsbzH1jXnNEanQ5sJKWsun+eOtie4Z28FWpx2aHotuRxLIn72lcKtNpUBXz5TlpvyvOVNBtnYCfBZoTXF+dWuxFRInPLc= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BL0PR12MB4948.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(136003)(396003)(376002)(366004)(39860400002)(26005)(8676002)(7696005)(2616005)(956004)(16526019)(186003)(66946007)(6486002)(5660300002)(1076003)(316002)(52116002)(38100700002)(6666004)(8936002)(2906002)(38350700002)(30864003)(66556008)(450100002)(83380400001)(478600001)(86362001)(66476007)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: /JStIF+Ct0OFBDoVPTtMiIeJT8BFMSD8LWy8bTGX5pnbldbefvLQ18zvpCZIlxW2oCMecHlsfRDyJuax/xqgti7DYAmb+z4mvh8mH5KBCGhoz4cLJmzME/Rg6vDog75dew/x0ehcXLwOSMp8MDQLVaoPpnqpMFdJZY8jfGB3uB6OVV/NnkIvu0RhCN1J1OrAUKuUX8zVXx5/8hnfSSmBuvAUIDJFTJzISFgjwuccd/bXFdjTBg4vd0sGhW+SPwH+f46vQauTSpqYYsTseQFENBR83j9DwCvmPMSVz5ffMUdlg2Mzp98Jaz3ilPKtIAaDCl2LaBOEvLVGDTxe2TYwomRv4gUqFsfr9HKv3S5n7NKD/300RsVtli3Fgw7Z8/zaVyDrKKyiE0e4n20m2cEYeJmV7Du3P/CXJKj55hNkYZb/XqnX6Sa98yayh8WsRYZeCaTFlY0P3FL9U/tygu+MWh+sa+jwnWmifPwVAI5QbWfUBNvVF3DOmu7heUDO540maYzaUwrCD4dXMB5suz+XV6aX1EUSfrsPQI2YhjyDRu/7YH51NCnWdZrYt84SfOrS+x9U1MVgH5LdLvzVPgheHeXJZJ4DQ51iv7tcwZPM/rzgG++b5JeRM7gH1lL0Bwegm//Bwat+u/hRuw2qi1CEwC2kBFmE2BXmMDziM5+C5T/yb17mDj97ItKDWKrGv+aPvyoLUCG0+SF467K4KkBO0izmd5fdApoZXhWLOXZamxoC4xYPUFVNfePgYPoRg0Qx+CeNuPZgyck7ufS+v/mspdRo8Do/p00kmE++sT5yobVmK/qBGORauGh2tTNOv1C8aKK2NcTs6xvtj+DDiA/BsvcZe00Eu28BuR7Mk0qh04755TuPQnBbE/h6Rv8/7mfgxpPmTajS2hwQxytXFFB8f43+npVjUs8sw++Z27DN4iyq81kzMjCF8dhW/iu1x9vSKa/ahqyClq1UKL3lTHqX/HvPz68yG/oaBbOLsEGIUjOSLM/OjIg/piLhozPyIfkPB/DZS2M6uE/lJRqibXaVtp35b+LLeOITBzMm5lXq5YV2xBRWM4Vd7Exlbu8kBoFw0kJsLTX4kXfKZqTv+OgSkAlzMyWFTupHmJweP0yrPcuReS/xfHFTB27cFLQVbUktOpCZLJU22FUvDm09pmjnQW7OHd35l1BWEgX38M/iIsBpcEdwjQX/gozeVi7lWXhGwkeQw8ZaH8fxYVuj3mw2oa9WlBkXFT1aMQ8T/LW9RzEcSBvvt4fZPyS4s3Vk5YXiD5jVYbnQvHtaX/Gi2s4xttxnQH+YASZLU2vPkLnX1HY83a7kQLIeAulUafns8NKW X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 61e37a56-7c4f-4414-6430-08d8ffb7d3e5 X-MS-Exchange-CrossTenant-AuthSource: BL0PR12MB4948.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Apr 2021 02:40:27.3333 (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: +HxKpteEpCmNtQ1tShZW2HhenFGcseHvmy/BfGZZt9XGG5KdbDzae+/dQthj2yppOSKGhMWXGvucnEpZds5TOQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4206 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu needs the drm_priv to allow mmap to access the BO through the corresponding file descriptor. The VM can also be extracted from drm_priv, so drm_priv can replace the vm parameter in the kfd2kgd interface. Signed-off-by: Felix Kuehling --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 14 ++-- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 69 +++++++++++-------- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 8 +-- .../drm/amd/amdkfd/kfd_device_queue_manager.c | 6 +- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 2 +- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 23 +++---- 6 files changed, 67 insertions(+), 55 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h index 5ffb07b02810..0d59bebd92af 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h @@ -236,20 +236,20 @@ uint8_t amdgpu_amdkfd_get_xgmi_hops_count(struct kgd_dev *dst, struct kgd_dev *s /* GPUVM API */ int amdgpu_amdkfd_gpuvm_acquire_process_vm(struct kgd_dev *kgd, struct file *filp, u32 pasid, - void **vm, void **process_info, + void **process_info, struct dma_fence **ef); -void amdgpu_amdkfd_gpuvm_release_process_vm(struct kgd_dev *kgd, void *vm); -uint64_t amdgpu_amdkfd_gpuvm_get_process_page_dir(void *vm); +void amdgpu_amdkfd_gpuvm_release_process_vm(struct kgd_dev *kgd, void *drm_priv); +uint64_t amdgpu_amdkfd_gpuvm_get_process_page_dir(void *drm_priv); int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu( struct kgd_dev *kgd, uint64_t va, uint64_t size, - void *vm, struct kgd_mem **mem, + void *drm_priv, struct kgd_mem **mem, uint64_t *offset, uint32_t flags); int amdgpu_amdkfd_gpuvm_free_memory_of_gpu( struct kgd_dev *kgd, struct kgd_mem *mem, uint64_t *size); int amdgpu_amdkfd_gpuvm_map_memory_to_gpu( - struct kgd_dev *kgd, struct kgd_mem *mem, void *vm); + struct kgd_dev *kgd, struct kgd_mem *mem, void *drm_priv); int amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu( - struct kgd_dev *kgd, struct kgd_mem *mem, void *vm); + struct kgd_dev *kgd, struct kgd_mem *mem, void *drm_priv); int amdgpu_amdkfd_gpuvm_sync_memory( struct kgd_dev *kgd, struct kgd_mem *mem, bool intr); int amdgpu_amdkfd_gpuvm_map_gtt_bo_to_kernel(struct kgd_dev *kgd, @@ -260,7 +260,7 @@ int amdgpu_amdkfd_gpuvm_get_vm_fault_info(struct kgd_dev *kgd, struct kfd_vm_fault_info *info); int amdgpu_amdkfd_gpuvm_import_dmabuf(struct kgd_dev *kgd, struct dma_buf *dmabuf, - uint64_t va, void *vm, + uint64_t va, void *drm_priv, struct kgd_mem **mem, uint64_t *size, uint64_t *mmap_offset); int amdgpu_amdkfd_get_tile_config(struct kgd_dev *kgd, diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c index 7d4118c8128a..dc86faa03b88 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c @@ -948,6 +948,13 @@ static int process_update_pds(struct amdkfd_process_info *process_info, return 0; } +static struct amdgpu_vm *drm_priv_to_vm(struct drm_file *drm_priv) +{ + struct amdgpu_fpriv *fpriv = drm_priv->driver_priv; + + return &fpriv->vm; +} + static int init_kfd_vm(struct amdgpu_vm *vm, void **process_info, struct dma_fence **ef) { @@ -1036,15 +1043,19 @@ static int init_kfd_vm(struct amdgpu_vm *vm, void **process_info, int amdgpu_amdkfd_gpuvm_acquire_process_vm(struct kgd_dev *kgd, struct file *filp, u32 pasid, - void **vm, void **process_info, + void **process_info, struct dma_fence **ef) { struct amdgpu_device *adev = get_amdgpu_device(kgd); - struct drm_file *drm_priv = filp->private_data; - struct amdgpu_fpriv *drv_priv = drm_priv->driver_priv; - struct amdgpu_vm *avm = &drv_priv->vm; + struct amdgpu_fpriv *drv_priv; + struct amdgpu_vm *avm; int ret; + ret = amdgpu_file_to_fpriv(filp, &drv_priv); + if (ret) + return ret; + avm = &drv_priv->vm; + /* Already a compute VM? */ if (avm->process_info) return -EINVAL; @@ -1059,7 +1070,7 @@ int amdgpu_amdkfd_gpuvm_acquire_process_vm(struct kgd_dev *kgd, if (ret) return ret; - *vm = (void *)avm; + amdgpu_vm_set_task_info(avm); return 0; } @@ -1100,15 +1111,17 @@ void amdgpu_amdkfd_gpuvm_destroy_cb(struct amdgpu_device *adev, } } -void amdgpu_amdkfd_gpuvm_release_process_vm(struct kgd_dev *kgd, void *vm) +void amdgpu_amdkfd_gpuvm_release_process_vm(struct kgd_dev *kgd, void *drm_priv) { struct amdgpu_device *adev = get_amdgpu_device(kgd); - struct amdgpu_vm *avm = (struct amdgpu_vm *)vm; + struct amdgpu_vm *avm; - if (WARN_ON(!kgd || !vm)) + if (WARN_ON(!kgd || !drm_priv)) return; - pr_debug("Releasing process vm %p\n", vm); + avm = drm_priv_to_vm(drm_priv); + + pr_debug("Releasing process vm %p\n", avm); /* The original pasid of amdgpu vm has already been * released during making a amdgpu vm to a compute vm @@ -1119,9 +1132,9 @@ void amdgpu_amdkfd_gpuvm_release_process_vm(struct kgd_dev *kgd, void *vm) amdgpu_vm_release_compute(adev, avm); } -uint64_t amdgpu_amdkfd_gpuvm_get_process_page_dir(void *vm) +uint64_t amdgpu_amdkfd_gpuvm_get_process_page_dir(void *drm_priv) { - struct amdgpu_vm *avm = (struct amdgpu_vm *)vm; + struct amdgpu_vm *avm = drm_priv_to_vm(drm_priv); struct amdgpu_bo *pd = avm->root.base.bo; struct amdgpu_device *adev = amdgpu_ttm_adev(pd->tbo.bdev); @@ -1132,11 +1145,11 @@ uint64_t amdgpu_amdkfd_gpuvm_get_process_page_dir(void *vm) int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu( struct kgd_dev *kgd, uint64_t va, uint64_t size, - void *vm, struct kgd_mem **mem, + void *drm_priv, struct kgd_mem **mem, uint64_t *offset, uint32_t flags) { struct amdgpu_device *adev = get_amdgpu_device(kgd); - struct amdgpu_vm *avm = (struct amdgpu_vm *)vm; + struct amdgpu_vm *avm = drm_priv_to_vm(drm_priv); enum ttm_bo_type bo_type = ttm_bo_type_device; struct sg_table *sg = NULL; uint64_t user_addr = 0; @@ -1347,10 +1360,10 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu( } int amdgpu_amdkfd_gpuvm_map_memory_to_gpu( - struct kgd_dev *kgd, struct kgd_mem *mem, void *vm) + struct kgd_dev *kgd, struct kgd_mem *mem, void *drm_priv) { struct amdgpu_device *adev = get_amdgpu_device(kgd); - struct amdgpu_vm *avm = (struct amdgpu_vm *)vm; + struct amdgpu_vm *avm = drm_priv_to_vm(drm_priv); int ret; struct amdgpu_bo *bo; uint32_t domain; @@ -1391,9 +1404,9 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu( pr_debug("Map VA 0x%llx - 0x%llx to vm %p domain %s\n", mem->va, mem->va + bo_size * (1 + mem->aql_queue), - vm, domain_string(domain)); + avm, domain_string(domain)); - ret = reserve_bo_and_vm(mem, vm, &ctx); + ret = reserve_bo_and_vm(mem, avm, &ctx); if (unlikely(ret)) goto out; @@ -1437,7 +1450,7 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu( } list_for_each_entry(entry, &mem->bo_va_list, bo_list) { - if (entry->bo_va->base.vm == vm && !entry->is_mapped) { + if (entry->bo_va->base.vm == avm && !entry->is_mapped) { pr_debug("\t map VA 0x%llx - 0x%llx in entry %p\n", entry->va, entry->va + bo_size, entry); @@ -1449,7 +1462,7 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu( goto map_bo_to_gpuvm_failed; } - ret = vm_update_pds(vm, ctx.sync); + ret = vm_update_pds(avm, ctx.sync); if (ret) { pr_err("Failed to update page directories\n"); goto map_bo_to_gpuvm_failed; @@ -1485,11 +1498,11 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu( } int amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu( - struct kgd_dev *kgd, struct kgd_mem *mem, void *vm) + struct kgd_dev *kgd, struct kgd_mem *mem, void *drm_priv) { struct amdgpu_device *adev = get_amdgpu_device(kgd); - struct amdkfd_process_info *process_info = - ((struct amdgpu_vm *)vm)->process_info; + struct amdgpu_vm *avm = drm_priv_to_vm(drm_priv); + struct amdkfd_process_info *process_info = avm->process_info; unsigned long bo_size = mem->bo->tbo.base.size; struct kfd_bo_va_list *entry; struct bo_vm_reservation_context ctx; @@ -1497,7 +1510,7 @@ int amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu( mutex_lock(&mem->lock); - ret = reserve_bo_and_cond_vms(mem, vm, BO_VM_MAPPED, &ctx); + ret = reserve_bo_and_cond_vms(mem, avm, BO_VM_MAPPED, &ctx); if (unlikely(ret)) goto out; /* If no VMs were reserved, it means the BO wasn't actually mapped */ @@ -1506,17 +1519,17 @@ int amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu( goto unreserve_out; } - ret = vm_validate_pt_pd_bos((struct amdgpu_vm *)vm); + ret = vm_validate_pt_pd_bos(avm); if (unlikely(ret)) goto unreserve_out; pr_debug("Unmap VA 0x%llx - 0x%llx from vm %p\n", mem->va, mem->va + bo_size * (1 + mem->aql_queue), - vm); + avm); list_for_each_entry(entry, &mem->bo_va_list, bo_list) { - if (entry->bo_va->base.vm == vm && entry->is_mapped) { + if (entry->bo_va->base.vm == avm && entry->is_mapped) { pr_debug("\t unmap VA 0x%llx - 0x%llx from entry %p\n", entry->va, entry->va + bo_size, @@ -1642,14 +1655,14 @@ int amdgpu_amdkfd_gpuvm_get_vm_fault_info(struct kgd_dev *kgd, int amdgpu_amdkfd_gpuvm_import_dmabuf(struct kgd_dev *kgd, struct dma_buf *dma_buf, - uint64_t va, void *vm, + uint64_t va, void *drm_priv, struct kgd_mem **mem, uint64_t *size, uint64_t *mmap_offset) { struct amdgpu_device *adev = (struct amdgpu_device *)kgd; + struct amdgpu_vm *avm = drm_priv_to_vm(drm_priv); struct drm_gem_object *obj; struct amdgpu_bo *bo; - struct amdgpu_vm *avm = (struct amdgpu_vm *)vm; if (dma_buf->ops != &amdgpu_dmabuf_ops) /* Can't handle non-graphics buffers */ diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index 43de260b2230..97da1632f504 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -1297,7 +1297,7 @@ static int kfd_ioctl_alloc_memory_of_gpu(struct file *filep, err = amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu( dev->kgd, args->va_addr, args->size, - pdd->vm, (struct kgd_mem **) &mem, &offset, + pdd->drm_priv, (struct kgd_mem **) &mem, &offset, flags); if (err) @@ -1448,7 +1448,7 @@ static int kfd_ioctl_map_memory_to_gpu(struct file *filep, goto get_mem_obj_from_handle_failed; } err = amdgpu_amdkfd_gpuvm_map_memory_to_gpu( - peer->kgd, (struct kgd_mem *)mem, peer_pdd->vm); + peer->kgd, (struct kgd_mem *)mem, peer_pdd->drm_priv); if (err) { pr_err("Failed to map to gpu %d/%d\n", i, args->n_devices); @@ -1555,7 +1555,7 @@ static int kfd_ioctl_unmap_memory_from_gpu(struct file *filep, goto get_mem_obj_from_handle_failed; } err = amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu( - peer->kgd, (struct kgd_mem *)mem, peer_pdd->vm); + peer->kgd, (struct kgd_mem *)mem, peer_pdd->drm_priv); if (err) { pr_err("Failed to unmap from gpu %d/%d\n", i, args->n_devices); @@ -1701,7 +1701,7 @@ static int kfd_ioctl_import_dmabuf(struct file *filep, } r = amdgpu_amdkfd_gpuvm_import_dmabuf(dev->kgd, dmabuf, - args->va_addr, pdd->vm, + args->va_addr, pdd->drm_priv, (struct kgd_mem **)&mem, &size, NULL); if (r) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c index d3eaa1549bd7..98c2046c7331 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c @@ -738,7 +738,7 @@ static int restore_process_queues_nocpsch(struct device_queue_manager *dqm, pdd = qpd_to_pdd(qpd); /* Retrieve PD base */ - pd_base = amdgpu_amdkfd_gpuvm_get_process_page_dir(pdd->vm); + pd_base = amdgpu_amdkfd_gpuvm_get_process_page_dir(pdd->drm_priv); dqm_lock(dqm); if (WARN_ON_ONCE(!qpd->evicted)) /* already restored, do nothing */ @@ -821,7 +821,7 @@ static int restore_process_queues_cpsch(struct device_queue_manager *dqm, pdd = qpd_to_pdd(qpd); /* Retrieve PD base */ - pd_base = amdgpu_amdkfd_gpuvm_get_process_page_dir(pdd->vm); + pd_base = amdgpu_amdkfd_gpuvm_get_process_page_dir(pdd->drm_priv); dqm_lock(dqm); if (WARN_ON_ONCE(!qpd->evicted)) /* already restored, do nothing */ @@ -873,7 +873,7 @@ static int register_process(struct device_queue_manager *dqm, pdd = qpd_to_pdd(qpd); /* Retrieve PD base */ - pd_base = amdgpu_amdkfd_gpuvm_get_process_page_dir(pdd->vm); + pd_base = amdgpu_amdkfd_gpuvm_get_process_page_dir(pdd->drm_priv); dqm_lock(dqm); list_add(&n->list, &dqm->queues); diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h index 0b6595f7acda..c6357ceb247d 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h @@ -669,7 +669,7 @@ struct kfd_process_device { /* VM context for GPUVM allocations */ struct file *drm_file; - void *vm; + void *drm_priv; /* GPUVM allocations storage */ struct idr alloc_idr; diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c index d97e330a5022..209e9edd6ddd 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c @@ -647,7 +647,7 @@ static void kfd_process_free_gpuvm(struct kgd_mem *mem, { struct kfd_dev *dev = pdd->dev; - amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu(dev->kgd, mem, pdd->vm); + amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu(dev->kgd, mem, pdd->drm_priv); amdgpu_amdkfd_gpuvm_free_memory_of_gpu(dev->kgd, mem, NULL); } @@ -667,11 +667,11 @@ static int kfd_process_alloc_gpuvm(struct kfd_process_device *pdd, int err; err = amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(kdev->kgd, gpu_va, size, - pdd->vm, &mem, NULL, flags); + pdd->drm_priv, &mem, NULL, flags); if (err) goto err_alloc_mem; - err = amdgpu_amdkfd_gpuvm_map_memory_to_gpu(kdev->kgd, mem, pdd->vm); + err = amdgpu_amdkfd_gpuvm_map_memory_to_gpu(kdev->kgd, mem, pdd->drm_priv); if (err) goto err_map_mem; @@ -901,10 +901,10 @@ static void kfd_process_device_free_bos(struct kfd_process_device *pdd) for (i = 0; i < p->n_pdds; i++) { struct kfd_process_device *peer_pdd = p->pdds[i]; - if (!peer_pdd->vm) + if (!peer_pdd->drm_priv) continue; amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu( - peer_pdd->dev->kgd, mem, peer_pdd->vm); + peer_pdd->dev->kgd, mem, peer_pdd->drm_priv); } amdgpu_amdkfd_gpuvm_free_memory_of_gpu(pdd->dev->kgd, mem, NULL); @@ -932,7 +932,7 @@ static void kfd_process_destroy_pdds(struct kfd_process *p) if (pdd->drm_file) { amdgpu_amdkfd_gpuvm_release_process_vm( - pdd->dev->kgd, pdd->vm); + pdd->dev->kgd, pdd->drm_priv); fput(pdd->drm_file); } @@ -1375,7 +1375,7 @@ int kfd_process_device_init_vm(struct kfd_process_device *pdd, if (!drm_file) return -EINVAL; - if (pdd->vm) + if (pdd->drm_priv) return -EBUSY; p = pdd->process; @@ -1383,13 +1383,12 @@ int kfd_process_device_init_vm(struct kfd_process_device *pdd, ret = amdgpu_amdkfd_gpuvm_acquire_process_vm( dev->kgd, drm_file, p->pasid, - &pdd->vm, &p->kgd_process_info, &p->ef); + &p->kgd_process_info, &p->ef); if (ret) { pr_err("Failed to create process VM object\n"); return ret; } - - amdgpu_vm_set_task_info(pdd->vm); + pdd->drm_priv = drm_file->private_data; ret = kfd_process_device_reserve_ib_mem(pdd); if (ret) @@ -1405,7 +1404,7 @@ int kfd_process_device_init_vm(struct kfd_process_device *pdd, err_init_cwsr: err_reserve_ib_mem: kfd_process_device_free_bos(pdd); - pdd->vm = NULL; + pdd->drm_priv = NULL; return ret; } @@ -1429,7 +1428,7 @@ struct kfd_process_device *kfd_bind_process_to_device(struct kfd_dev *dev, return ERR_PTR(-ENOMEM); } - if (!pdd->vm) + if (!pdd->drm_priv) return ERR_PTR(-ENODEV); /* From patchwork Thu Apr 15 02:40:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Felix Kuehling X-Patchwork-Id: 12204131 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.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 D5224C433ED for ; Thu, 15 Apr 2021 02:40:40 +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 64832611B0 for ; Thu, 15 Apr 2021 02:40:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 64832611B0 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 4959A6E4D0; Thu, 15 Apr 2021 02:40:33 +0000 (UTC) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2051.outbound.protection.outlook.com [40.107.94.51]) by gabe.freedesktop.org (Postfix) with ESMTPS id 80FF36E0F6; Thu, 15 Apr 2021 02:40:32 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Yrzvej5ZviwMlJGlEj2jIk4h2lGQCOZuF8o/0bWUVGBFj83ZFUBhVZYOYI0J0TZRolkZjFF1yEmJkEqPhhuLM/bZG4xnPlec6jMAVu7lPBdVBSU0+JGFOseIBMAI4u624upaoYuBed3h/9k0OlMMxt5dNS9kuJM/wr4uZ4Tal1vrCn87m0gwznHH05R84GFGQZiTv3Yq2dfxknEDu70T7TuASR2HFmBJNRImx9LlgINY5mjHSDnOp6DZ3ZwjM5oIPIJq17OOqk+KoHopZJ53LRK4K9/Wbt48GzOc5BKxhcgp9sTGnOA/V7MHjp0PsPF7j8KIv2BzFWsYTHXhrepytQ== 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=56OpfKRAobATF+ekELY98bzNfHBCbAkFTKX1cvuY3oc=; b=XqZpbRfz7Ktxc2ob3jiM/5NJ6kl+2UP7Mn9+NsC2xrBPPup9Nx5yrRLmk5BIV1sRW5IdbNP7TGGOrpTRPH0kjNYSNCnLr0trs4R3pM8IfHy1CGS3o1o7xtDZwmC3vvF9wANs1J1X3592ETiS8SV6gcwDAerWtJcgFxbtwOUEPah7/V+uULhzRGs2vKQUenZcUCsvykeSzt4qPYLR0JiTnwlFXM2xTbr2SjuVFZV5sW82rK7kL1J7eo6u574kQL9c3GxBcE3bY64S4ymG+X3mq/xdlBvsOG/c2YJgMOcLSfDg9J+R8VvKjvgeKivM3r4GIGJDCGIx1RssBv8tCGWZyw== 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=56OpfKRAobATF+ekELY98bzNfHBCbAkFTKX1cvuY3oc=; b=kAp6dKTWAnjhZWwHuTpaHP5Y1/pNRpKzAeDXMq9TpSrx6pRlehdnQFzPyxv+MOqVB+BSORkDxoPwJ2jyrA404Hdz7rITZJG9skzp1+4wPwI+BqgrgmgcHP8MtV0kEptH354M74O6FxRmb7xxKVtvsh7erfqpKJy4MVD/UiP16MI= 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 BL0PR12MB4948.namprd12.prod.outlook.com (2603:10b6:208:1cc::20) by MN2PR12MB4206.namprd12.prod.outlook.com (2603:10b6:208:1d5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.21; Thu, 15 Apr 2021 02:40:27 +0000 Received: from BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033]) by BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033%7]) with mapi id 15.20.3933.040; Thu, 15 Apr 2021 02:40:27 +0000 From: Felix Kuehling To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH v2 2/3] drm/amdkfd: Allow access for mmapping KFD BOs Date: Wed, 14 Apr 2021 22:40:12 -0400 Message-Id: <20210415024013.15522-2-Felix.Kuehling@amd.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210415024013.15522-1-Felix.Kuehling@amd.com> References: <20210415024013.15522-1-Felix.Kuehling@amd.com> X-Originating-IP: [165.204.55.251] X-ClientProxiedBy: YTOPR0101CA0045.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:14::22) To BL0PR12MB4948.namprd12.prod.outlook.com (2603:10b6:208:1cc::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from Harpoon.amd.com (165.204.55.251) by YTOPR0101CA0045.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:14::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.21 via Frontend Transport; Thu, 15 Apr 2021 02:40:27 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c5f6c1f2-7137-4688-7a20-08d8ffb7d427 X-MS-TrafficTypeDiagnostic: MN2PR12MB4206: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3826; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cEKlqql4aMG0keFd2ubaqdHN3JSgA/L/RDcBDdiR/oV25KyeiMGMUEklVVtg5tgt4g94FqToDZQJAKHFKUTWNwRm+DOD+ZLC/8RvUvkKGSfS1SAbn1P6nLss3ZQ8XUUkRe1D4eqD6ozeGZ+iCm5PrhapC//YC3AqjZuNI3v1uGrU1jcZZS0+WfrdVZiRTGNGM6I5oGea6worsETQvhX1CqzQ0781A1BaRj0uEO6x1o6C62sWMQGkEW90AbIougbgN6kHwfrIAQ69o1yfmzjVg18oOmyf3PI+8ccqrTiC7MWMNxyTrKpusODHfZr3CCMiTOZ0qX+zV/tkGfFcxwsguVY125M2ecJY7F3ept1jLlywx5AXXWK3WzypDFDWkWb7lMVC5H7g2Qnuhv6cDNVOdOen/Z7Xd7wGXA63p7RjFmRqR8dAhNNw2+bkf9WgS+Gm612CnatBcv2RGziwVcRVnt22EUWd1od/zfiBDvK1DoBsdIVZ4t4QRQcjoEJmj7etkFSSG5C8SJP7PWg9pxG0UA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BL0PR12MB4948.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(136003)(396003)(376002)(366004)(39860400002)(26005)(8676002)(7696005)(2616005)(956004)(16526019)(186003)(66946007)(6486002)(5660300002)(1076003)(316002)(52116002)(38100700002)(6666004)(8936002)(2906002)(38350700002)(66556008)(450100002)(4326008)(66574015)(83380400001)(478600001)(86362001)(66476007)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?93e4dDkQIq6HbU9+QW3FnfQSTcGdpL?= =?utf-8?q?CcRoUYc4npf4sUuZyJLzFLJeQtjYbqGrUSFEJP+UOcYU7tgNxukmMlnkYjiznYXKf?= =?utf-8?q?WZBxgSvQPxbev7X+MumWkVyQhliiEFfD+Gt2uLvvQNiNUDk3Lk/3bNcqof1Wo0V34?= =?utf-8?q?2cow+qg2yHqt8AylBh+fpYpz59lZ/C3luOgRgXXZ8P9ZlwrvclzPXuoa7WHahuuWj?= =?utf-8?q?pPXMYDdf3eFTM5LvTZ0xobDlH5/BEUxIFL43eknlq6IGYqfWCHRSiEg7wL98A9WUS?= =?utf-8?q?zJU7KJNaUgJyZzqqvKocR3m6PLaLywoTf3kVA8IiMV5EQBh2VgSPtlGQrSEdtLHIZ?= =?utf-8?q?nOdjJ72inZ7zwr/KEQmkoWnHjuAyoeGMNdOqIiurSteOAm+mCGqO1ndqqZrVOYJUC?= =?utf-8?q?SwQ4zb/dPgC7rBX6II3UOmHax3xojS1kiPZ9ANQWsRl3wIk2fTeGYBJtea2ecdaDM?= =?utf-8?q?CTFg92W03vt+Rac7hOmRnjf0pXV1u96EII3NWOhHz1Iv2IdF+l73+QjfHpNyPX8Kq?= =?utf-8?q?09mv9uis1SJTnVyMNvEm37zv+fgd7P2j82//cjTvBU/uIOqJUBgrFyejgP3QklNoE?= =?utf-8?q?zPOBu0MDnnprQYzx97eOeXGrZ6GmXSs/45QP1tj1FuShuiJjyOlsGaRNiDNTsMZhM?= =?utf-8?q?2Oj6wg90FHB6ca6UN3aYeA8y8eabQXBkUwXPbG8lWx/7U4J+3tWluZgB7SVAechLI?= =?utf-8?q?tkp9fTx3tdkYKiht2GF+Lv1Ozc2UVCgxQNBp4CWlaHYokrsFlLFJbi85tEqArWmxq?= =?utf-8?q?vgF/wRBtZNfcZ668Ln2TFALhLHkLMA3CSjNso7IWj14E2phc67X1ODHx+ZPIAKERe?= =?utf-8?q?yk+Wd+nRtwdxwq0/oYSE91lhw4FoRQF30pv8BBOK0WesYSL5/+/hfNBpl3YhFZwZk?= =?utf-8?q?Pvq3Cp7iDt8N3I2jo8M6N8oMLoq0Uj2T+B7EDdNamHA6K/+0z9+rsalw86aHuEFGu?= =?utf-8?q?cXS89ITboZRTIYUGBkkwNG/yY5Chdn/DBuWUtLKFFe8fOsWfkkNN/F0Ds9SNb2YTg?= =?utf-8?q?N7DzcSH59HuRHsTUIkoZPJ42OonugKGO/G1jR/cKO6oriL65V8pUZ6nW5rjn7Uzre?= =?utf-8?q?Z9jPSvXMLAZuFnfl3IdI/KekTHGcvRdHin1qMrRKVNU83qNbhdRpvIcKje+892GC2?= =?utf-8?q?3rORTLltUP8x/wq0MtpbJToqVswPuyusQruhV0aKs3z/izWiNIjti8DLPzR1o7j44?= =?utf-8?q?7Z7hjDCBRvp6dhZ95ic82+ge/hGE+73HtqRj/dQJBsok2lIdodOezvFubMS4SeXBb?= =?utf-8?q?hUVIjsTjtW066P?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: c5f6c1f2-7137-4688-7a20-08d8ffb7d427 X-MS-Exchange-CrossTenant-AuthSource: BL0PR12MB4948.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Apr 2021 02:40:27.7963 (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: nzs9vor+6A1LygJCvCaaIpp6h5LF0iGKPaXTmJ2QCe8xFQOyKIPRQA5U9DBW+qxhb0bZmrjZCgPniLwQvmeEXg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4206 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: =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" DRM render node file handles are used for CPU mapping of BOs using mmap by the Thunk. It uses the DRM render node of the GPU where the BO was allocated. DRM allows mmap access automatically when it creates a GEM handle for a BO. KFD BOs don't have GEM handles, so KFD needs to manage access manually. Use drm_vma_node_allow to allow user mode to mmap BOs allocated with kfd_ioctl_alloc_memory_of_gpu through the DRM render node that was used in the kfd_ioctl_acquire_vm call for the same GPU. Signed-off-by: Felix Kuehling Acked-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 3 ++- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 18 +++++++++++++++++- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 8 +++++--- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 9 ++++++--- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h index 0d59bebd92af..7c8c5e469707 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h @@ -245,7 +245,8 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu( void *drm_priv, struct kgd_mem **mem, uint64_t *offset, uint32_t flags); int amdgpu_amdkfd_gpuvm_free_memory_of_gpu( - struct kgd_dev *kgd, struct kgd_mem *mem, uint64_t *size); + struct kgd_dev *kgd, struct kgd_mem *mem, void *drm_priv, + uint64_t *size); int amdgpu_amdkfd_gpuvm_map_memory_to_gpu( struct kgd_dev *kgd, struct kgd_mem *mem, void *drm_priv); int amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu( diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c index dc86faa03b88..f96c331c9b6d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c @@ -1229,6 +1229,11 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu( domain_string(alloc_domain), ret); goto err_bo_create; } + ret = drm_vma_node_allow(&gobj->vma_node, drm_priv); + if (ret) { + pr_debug("Failed to allow vma node access. ret %d\n", ret); + goto err_node_allow; + } bo = gem_to_amdgpu_bo(gobj); if (bo_type == ttm_bo_type_sg) { bo->tbo.sg = sg; @@ -1258,6 +1263,8 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu( allocate_init_user_pages_failed: remove_kgd_mem_from_kfd_bo_list(*mem, avm->process_info); + drm_vma_node_revoke(&gobj->vma_node, drm_priv); +err_node_allow: amdgpu_bo_unref(&bo); /* Don't unreserve system mem limit twice */ goto err_reserve_limit; @@ -1275,7 +1282,8 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu( } int amdgpu_amdkfd_gpuvm_free_memory_of_gpu( - struct kgd_dev *kgd, struct kgd_mem *mem, uint64_t *size) + struct kgd_dev *kgd, struct kgd_mem *mem, void *drm_priv, + uint64_t *size) { struct amdkfd_process_info *process_info = mem->process_info; unsigned long bo_size = mem->bo->tbo.base.size; @@ -1352,6 +1360,7 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu( } /* Free the BO*/ + drm_vma_node_revoke(&mem->bo->tbo.base.vma_node, drm_priv); drm_gem_object_put(&mem->bo->tbo.base); mutex_destroy(&mem->lock); kfree(mem); @@ -1663,6 +1672,7 @@ int amdgpu_amdkfd_gpuvm_import_dmabuf(struct kgd_dev *kgd, struct amdgpu_vm *avm = drm_priv_to_vm(drm_priv); struct drm_gem_object *obj; struct amdgpu_bo *bo; + int ret; if (dma_buf->ops != &amdgpu_dmabuf_ops) /* Can't handle non-graphics buffers */ @@ -1683,6 +1693,12 @@ int amdgpu_amdkfd_gpuvm_import_dmabuf(struct kgd_dev *kgd, if (!*mem) return -ENOMEM; + ret = drm_vma_node_allow(&obj->vma_node, drm_priv); + if (ret) { + kfree(mem); + return ret; + } + if (size) *size = amdgpu_bo_size(bo); diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index 97da1632f504..242e8b28feac 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -1328,7 +1328,8 @@ static int kfd_ioctl_alloc_memory_of_gpu(struct file *filep, return 0; err_free: - amdgpu_amdkfd_gpuvm_free_memory_of_gpu(dev->kgd, (struct kgd_mem *)mem, NULL); + amdgpu_amdkfd_gpuvm_free_memory_of_gpu(dev->kgd, (struct kgd_mem *)mem, + pdd->drm_priv, NULL); err_unlock: mutex_unlock(&p->mutex); return err; @@ -1365,7 +1366,7 @@ static int kfd_ioctl_free_memory_of_gpu(struct file *filep, } ret = amdgpu_amdkfd_gpuvm_free_memory_of_gpu(dev->kgd, - (struct kgd_mem *)mem, &size); + (struct kgd_mem *)mem, pdd->drm_priv, &size); /* If freeing the buffer failed, leave the handle in place for * clean-up during process tear-down. @@ -1721,7 +1722,8 @@ static int kfd_ioctl_import_dmabuf(struct file *filep, return 0; err_free: - amdgpu_amdkfd_gpuvm_free_memory_of_gpu(dev->kgd, (struct kgd_mem *)mem, NULL); + amdgpu_amdkfd_gpuvm_free_memory_of_gpu(dev->kgd, (struct kgd_mem *)mem, + pdd->drm_priv, NULL); err_unlock: mutex_unlock(&p->mutex); dma_buf_put(dmabuf); diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c index 209e9edd6ddd..0a5379439642 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c @@ -648,7 +648,8 @@ static void kfd_process_free_gpuvm(struct kgd_mem *mem, struct kfd_dev *dev = pdd->dev; amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu(dev->kgd, mem, pdd->drm_priv); - amdgpu_amdkfd_gpuvm_free_memory_of_gpu(dev->kgd, mem, NULL); + amdgpu_amdkfd_gpuvm_free_memory_of_gpu(dev->kgd, mem, pdd->drm_priv, + NULL); } /* kfd_process_alloc_gpuvm - Allocate GPU VM for the KFD process @@ -712,7 +713,8 @@ static int kfd_process_alloc_gpuvm(struct kfd_process_device *pdd, return err; err_map_mem: - amdgpu_amdkfd_gpuvm_free_memory_of_gpu(kdev->kgd, mem, NULL); + amdgpu_amdkfd_gpuvm_free_memory_of_gpu(kdev->kgd, mem, pdd->drm_priv, + NULL); err_alloc_mem: *kptr = NULL; return err; @@ -907,7 +909,8 @@ static void kfd_process_device_free_bos(struct kfd_process_device *pdd) peer_pdd->dev->kgd, mem, peer_pdd->drm_priv); } - amdgpu_amdkfd_gpuvm_free_memory_of_gpu(pdd->dev->kgd, mem, NULL); + amdgpu_amdkfd_gpuvm_free_memory_of_gpu(pdd->dev->kgd, mem, + pdd->drm_priv, NULL); kfd_process_device_remove_obj_handle(pdd, id); } } From patchwork Thu Apr 15 02:40:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kuehling X-Patchwork-Id: 12204133 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.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 F3930C433B4 for ; Thu, 15 Apr 2021 02:40:42 +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 AA18C61019 for ; Thu, 15 Apr 2021 02:40:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AA18C61019 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 698BB6E4E6; Thu, 15 Apr 2021 02:40:33 +0000 (UTC) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2051.outbound.protection.outlook.com [40.107.94.51]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5B0FD6E0E9; Thu, 15 Apr 2021 02:40:32 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IQzBk+q8WDxjd2KAWArg9wFJQNpw8JrZM4eTdpdcrThTH81WaR20KJ7PPlzm1z4nLVWMInk4cVrcXo9nhyey40soL47IyN4BkD2i9afuTWhi01tXbDnv/x0w3SlAIcyaRtUMXseuUVoncFK2RE0efCCqNxc+aMlqXybt2x2EntrQiV7X+hP3wCwMWDFa6Ngdllpx6jvhelbnyWbXEFJXd8to5eoA6dPNvVSo+lQjC7MS6YbbvtoIT1MVrjidmKmrZBCph/s7Lgy+XeaZ9YD1QiFohydDmpx9OhNuCMyrCjYcrevoVwrADAHyir1GVlOgklhf6LYQ6eGoM8oyrgm66g== 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=ri/tUjTulPGEW0IrHqxeOGyJWitWHe66p8XvVNVStLI=; b=MaLmpKEpR1dE32k4yNR8T3ltPPNC8hZpAn2SIbXZgiCOGB8Uyv6e+/RHiFdN51HrvA711oMDrJWb09Qbv74zdFD4RU+OjOXsaMg8mgLwY/sbVMr9uZeOKv2IrAQTgKqKIZXO4MgvClwqtfBYSmgLs84k9kMC9d02/haGXiSW0oKRhgROMpwoCuwSUt2Nw0yzOnwmwAQJWEEMyzWPDjaHruO2d1poZG2yN66h5kAeA/qI6KAupJCrIjuBZeOT/3WpkRWQOq4mmtq6i48PsXSODQQJtQKXdJA4aCH+UwUaGDGHrIPxBoOsNFJATNELiOCgauKKcqb1hCZU8sn9qgCVkg== 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=ri/tUjTulPGEW0IrHqxeOGyJWitWHe66p8XvVNVStLI=; b=cRt/mfDbsiFbNllNKvI+BEOhzZvn1gQ3MdqvuOykmztw2zjNXFD9VID+IWp7mfxCkiE2qQskCSX2AjXc+6YH7e6gYHXBs4pbH7xBu1ehnTJjqJyDn52jKjmDETGHEySr6b5eNCZa9S+1s0cMCzSBSWTYc2fPicAurmlua0fQdWk= 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 BL0PR12MB4948.namprd12.prod.outlook.com (2603:10b6:208:1cc::20) by MN2PR12MB4206.namprd12.prod.outlook.com (2603:10b6:208:1d5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.21; Thu, 15 Apr 2021 02:40:29 +0000 Received: from BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033]) by BL0PR12MB4948.namprd12.prod.outlook.com ([fe80::70f5:99ed:65a1:c033%7]) with mapi id 15.20.3933.040; Thu, 15 Apr 2021 02:40:28 +0000 From: Felix Kuehling To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH v2 3/3] drm/amdgpu: Remove verify_access shortcut for KFD BOs Date: Wed, 14 Apr 2021 22:40:13 -0400 Message-Id: <20210415024013.15522-3-Felix.Kuehling@amd.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210415024013.15522-1-Felix.Kuehling@amd.com> References: <20210415024013.15522-1-Felix.Kuehling@amd.com> X-Originating-IP: [165.204.55.251] X-ClientProxiedBy: YTOPR0101CA0045.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:14::22) To BL0PR12MB4948.namprd12.prod.outlook.com (2603:10b6:208:1cc::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from Harpoon.amd.com (165.204.55.251) by YTOPR0101CA0045.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:14::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.21 via Frontend Transport; Thu, 15 Apr 2021 02:40:27 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 33913512-f58a-4457-14ea-08d8ffb7d46b X-MS-TrafficTypeDiagnostic: MN2PR12MB4206: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:989; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2ewR3accmdrlTMLPWK927m/Esle6bg0DIizIT6Oz5MSIdjq7NEt0praOMfTiI/cond39f6PsZgSVF/sCmjjVjEo1nQMk1yrMqA5XW/ZuX+HAyog1iMxAQZC3azdEoEA43bMN0P/d2g75Ye0vO+Ybd8FJ7ILjVKkp9LUpK/u+NC6nOokD0NOg856pojZzvyqILUTuR252WHC0HcE4OkIFmkD5pgxkc6z+bNGI0p/gZ8Rfu+eSE4AlzT4IMB4GHd5G8IBvw9sVwzVjBZeTkZ6vUi8Ubgl3JLA7H+qb/XkDmL70H3N7KPYewnRvRjW6LgVtu3G3i2ybKlZdpCfSsSp1r84dwCZIDmuPfZPiuqO3IEnBnoJLroDPg+RHKCi+g4RayETD489/E+hokMYtCr54K1dPrTDWgEvBxbmSLEASeLEjBJC56Jidj6SjxP8H9J9x1SbhkElqXr+KfQowXoMBc0Z9yjUs0MtL2/kyS6CH63d10S5fPKMBZJPB/fbQoGxQwKT4fumZ/SgGMlfBZaowBmJu85eQacJIkBZORbQ605kvvF6u8HSGkQ0DfGY8i/2vyj3mHL2VBGP5RIwODQZ1rz+S2kOwZau4j38sPqbzBlL0xIFA/zoKZ6c07a4CS8DZvZjoqSo8H30qzFt/sD3vlGe2a6+XUnHUNqkvcTU9Ago= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BL0PR12MB4948.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(136003)(396003)(376002)(366004)(39860400002)(26005)(8676002)(7696005)(2616005)(956004)(16526019)(186003)(66946007)(6486002)(5660300002)(1076003)(4744005)(316002)(52116002)(38100700002)(15650500001)(6666004)(8936002)(2906002)(38350700002)(66556008)(450100002)(4326008)(83380400001)(478600001)(86362001)(66476007)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: jD6zwHvW7p+UhF8/h/K3aINyYXWjmuBIwBsWQtGWzlECmcOqZXYPH3kRIYOSSTvFaGUqm/ZM8boWSlSZLrYdrbLHius3Fa/S/KZJbLQEWtXE7n4/mCCNPp9lsScp9e39wlhU7ZM0lNpisr4JeAtDTX69C6wkENMUvlOwWq9CPuDaH6dmvfjWvocxFGoPmsKcLuaWmAjlWHaSpgaCdAq4e+9bwLHzD32AVqwES8xJNl2XcCIBiNkHCiIfgZDUKGXbdvhNEvz8HxXv34XG3beSDmUf/qxgAMzBNZCJgYUgaWtaOhdk/+RpexZ9JdDXLVFiC6ZsQfI18ocLNSiKQNsnMi25vsamB1azvQkiqama0T2mIVGKOMxFtdo79WWimON6tXpDvm+fiS0jhSYvuxGq9tXWRsMeAOjFuFpItsiuO0R6nscsReYILaEINJOo0V6PGn2QGiTK6W+jmeaSrIdFxFUqEI4/tCZFmaM0YJawy0N6sPKZACD7PfhkqMJUPe0rvGLxNwVSzd5pPeWdcl3kTwSzkm4VjJTBCeO/E+YMat7Uk9J19CDL8U7iQYYcwRSi7LraIx9Q0Uu00Z7MVy5u43CtgXd9Hj5kkjuV7Ewlx5KOJBbrVbt6DxLP14REBL1ftIQxHQbWJbSFgYlsbz0BVOn0EAkZQQ2qbUMUH11beI3PAjbES4jLa/KzNV63u5tuaB/3d8TXEr/FiN6LVK35d8B+ihhvHv8/TORByDIT9poLCC/TYVPwHpWq0Nbd7b8VnUS6XaycSPps0Vhddo55AmswbCQeLmRDiO5o7Vi5PH6ZQsMusmdSGZypHGVuwGfKEDnm6Vn8gZDaWRHc7i4vzySGbDjBLXM3oI/lJwLGzorj4jfP0ISzC8lUX7wMpFglzYG5dwwancBIsnelEZDfFPRy617iX0A/o8IA3AvcWiL1eVMs5Xj/Y9KeNElfjn/XcUbg4CNZa6MwvAmzVJAxdJsMr83HqjaBKTiupqrTK8wj/2NRgHZLh7gptfGN+J+uPeFcdgU53DCzRtrk/QL4EUZ4lhDulfISyvJ/8LQSU2tB+gvS/k5GHzqGT7iy0wnTH9xcnMsxxoZG5YNokbleeodXwX2PtgdLHKMRlMNXdpqctjAUmS31qIkcqT8QFldkY/bPuKreJm7bXfEobu06X1JlDE56Sz951/3I4Iiiz3ab/QyjEEIGFuBVOdda+U+EGcFgRleVxVaRJGu8qz9Yr1oJuOPJceSuMqHyNUh4bBgBTHRrvSTqgQSmzQHSHFZrpq/ywAEVJWDl95Sbl+DEFBpVXyOJSmrXcCm4BxcStbCeiXJpRPwwhHF+dlB5bIP7 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 33913512-f58a-4457-14ea-08d8ffb7d46b X-MS-Exchange-CrossTenant-AuthSource: BL0PR12MB4948.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Apr 2021 02:40:28.2642 (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: F5EuovRaKAvPklGhnabuY9fiSOnEgXxkyPHp0ZJ8VMJoZOyYRTemPwFe/yHnacuLP5UDs0ZnnmENrK4cxT23ww== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4206 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: Philip Yang Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This shortcut is no longer needed with access managed properly by KFD. Signed-off-by: Felix Kuehling Reviewed-by: Philip Yang --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 936b3cfdde55..4947dfe9aa70 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -165,13 +165,6 @@ static int amdgpu_verify_access(struct ttm_buffer_object *bo, struct file *filp) { struct amdgpu_bo *abo = ttm_to_amdgpu_bo(bo); - /* - * Don't verify access for KFD BOs. They don't have a GEM - * object associated with them. - */ - if (abo->kfd_bo) - return 0; - if (amdgpu_ttm_tt_get_usermm(bo->ttm)) return -EPERM; return drm_vma_node_verify_access(&abo->tbo.base.vma_node,