From patchwork Fri Jan 28 20:08:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sierra Guiza, Alejandro (Alex)" X-Patchwork-Id: 12729028 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0625BC43219 for ; Fri, 28 Jan 2022 20:09:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AF9AA6B0106; Fri, 28 Jan 2022 15:08:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AA8206B0108; Fri, 28 Jan 2022 15:08:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 973CF6B010C; Fri, 28 Jan 2022 15:08:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0168.hostedemail.com [216.40.44.168]) by kanga.kvack.org (Postfix) with ESMTP id 82B716B0106 for ; Fri, 28 Jan 2022 15:08:59 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 3BAD79518B for ; Fri, 28 Jan 2022 20:08:59 +0000 (UTC) X-FDA: 79080784398.15.4AEC864 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1anam02on2041.outbound.protection.outlook.com [40.107.96.41]) by imf21.hostedemail.com (Postfix) with ESMTP id 9DFDA1C000A for ; Fri, 28 Jan 2022 20:08:58 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KKW2u8eN2V/lb2x70V94SyGJMwPr2u5JZo/jZzuzsCwqWipXIU9jh3cIw5sH57RWJMn3fQv8WmUBp0N48IvEos4Hx9LlmW7PzBtUg4z5Y0ceDVEgqafTT60JfauJycyIkQDB9bhcO4Bxejo02eWx+ix/UVHhyiIbs44dD367EHK7lcfGtZjtxC3nySKGMWb/sbxuPfojwqD6VvqlGU5PEYTyYNMzzHCTBKosDLP/EKOJbHI3aE3fMrek/QVmOZP7VLfRVAUFfTi7fuqNZAs29V1gD+0T3oMUKbcdgbHehdHqJDhrp/K3/f586dT18Vecu45BkVpnM3UqQiZh3KNZ0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cKdah9ociAAjWA8oWytWUkonkykx0MrDTa+hoh93Wfs=; b=BalulE5x/gHeqpWxONIxaixkE6JnOpBi7Rf3I4yHCpZ6+go+L30GCa/Q3pyUV34/E841lvA2d++lICsKsjJhSTC7ZE1KTEbnpVyN/x3hHpWyoovmixYab5IJtdQ2Wn5Ora/G94hP+WARw/aDHdXbMPXy5wwRS0gy6cZZYZU2HlOi79i1//yag4e+w5X93EZqWwCqCiBXgi+4ZUvVBP1BGRC+aaXswhnf89Oernmpf7RaZaFQGxPmS9AlFCfEUDER6A3qeXaapo/eR7+hsQkLEg6iPsihj3eSGZnnUJwvX7N4TUUCeOmqd1b1UP81fjftAja1fKpuencJqMZR+tIQew== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linux-foundation.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cKdah9ociAAjWA8oWytWUkonkykx0MrDTa+hoh93Wfs=; b=M8Gvx6oGJiBTIIPDW+tOI8Ix4BbJCgCduQ9tzEp+UJ2Ntm07Fa5dz7miSeaXNDYtkQf1ukMHxKonDJjYVvVTSIvuE8YXAVI3trw4PS/q52zqVLuZDUFiA/ioUEOGs12uIFuN+qFsdHbFKKg/3omwL/rCECWDXUsNh6IvWF6rr2k= Received: from MWHPR19CA0072.namprd19.prod.outlook.com (2603:10b6:300:94::34) by BY5PR12MB4068.namprd12.prod.outlook.com (2603:10b6:a03:203::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Fri, 28 Jan 2022 20:08:55 +0000 Received: from CO1NAM11FT022.eop-nam11.prod.protection.outlook.com (2603:10b6:300:94:cafe::17) by MWHPR19CA0072.outlook.office365.com (2603:10b6:300:94::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17 via Frontend Transport; Fri, 28 Jan 2022 20:08:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT022.mail.protection.outlook.com (10.13.175.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4930.15 via Frontend Transport; Fri, 28 Jan 2022 20:08:55 +0000 Received: from alex-MS-7B09.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Fri, 28 Jan 2022 14:08:53 -0600 From: Alex Sierra To: , , , , , CC: , , , , , , Subject: [PATCH v5 05/10] drm/amdkfd: coherent type as sys mem on migration to ram Date: Fri, 28 Jan 2022 14:08:20 -0600 Message-ID: <20220128200825.8623-6-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220128200825.8623-1-alex.sierra@amd.com> References: <20220128200825.8623-1-alex.sierra@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c4a7eac3-f2b5-4dfb-4595-08d9e29a0320 X-MS-TrafficTypeDiagnostic: BY5PR12MB4068:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ivIm9OFEQDGJtC1pCqekWnu5B3EY/r8eY4s0x3DxbUwwd48NNY1oXLGCVHl68ZZMA9YU194LNP3Sm6magQqGghIkSV3FwNYjezb92n0vaL3kAcUWn5g1osuFe6STvccZMei2//Yct6J3oEmO8kCT8yEWwVglqz9tb5CdBFmhcqHUapEjJPGFkpjfrbzBx66+8xaaDYlA0+1C93TLiCWVnp5PDmqf/SwiK3ftrCjLiz+00BlwSjEHyXywEMcY13K4DQfnzCd0HMnsv2G+RqaZYOjCaGHw9PLQ6ASUw2SHPStIROPldb9dOoq+tkOzcKqW754WRjPObZ1qAgw4XfMcmvCszFu2eJ6kFEBSqGl8OiwegBZ+XYKiaUk8Q+UxYRtjHnvdda01brl4Euukcqao/e435oSBVc3alnyDblkcb8EM7FOjLEpojHOYCLh5Iiq1WJyayvMMETeQPiwRhIHZecCrnenglz+jev5RpRhptruFzJusO3dGhX18gjXNQyt4bqwzfZxW28QYwsFxWqER0bz/UhYeYGHQ/ViTm/uMJNkMY/Q8/FQFrb1izI00A9amg63rwcSCrgm15NxsnOBLtbqp9rWT0bL6q7Qv8Fy2RfYvUow5pc3vHewUa0dITdxtnVOE2KzA8EVrf/+XkFPG/ccKuwIJ1stvmW7K/pZohfzCOTd/P/Hg7IN/tGA37O01rffyXa08zehKsfAyT6P3iA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(7696005)(6666004)(40460700003)(36756003)(508600001)(54906003)(110136005)(316002)(26005)(7416002)(4326008)(70586007)(70206006)(8936002)(8676002)(82310400004)(2906002)(16526019)(426003)(2616005)(1076003)(83380400001)(86362001)(47076005)(336012)(186003)(5660300002)(81166007)(44832011)(356005)(36860700001)(36900700001)(20210929001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2022 20:08:55.3048 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c4a7eac3-f2b5-4dfb-4595-08d9e29a0320 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT022.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4068 X-Stat-Signature: nigw9p4kyzwjaohqacypiiocr7saap7n X-Rspam-User: nil Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=M8Gvx6oG; spf=pass (imf21.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.96.41 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 9DFDA1C000A X-HE-Tag: 1643400538-208203 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Coherent device type memory on VRAM to RAM migration, has similar access as System RAM from the CPU. This flag sets the source from the sender. Which in Coherent type case, should be set as MIGRATE_VMA_SELECT_DEVICE_COHERENT. Signed-off-by: Alex Sierra Reviewed-by: Felix Kuehling --- drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c index 5e8d944d359e..846ba55723fb 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c @@ -659,9 +659,12 @@ svm_migrate_vma_to_ram(struct amdgpu_device *adev, struct svm_range *prange, migrate.vma = vma; migrate.start = start; migrate.end = end; - migrate.flags = MIGRATE_VMA_SELECT_DEVICE_PRIVATE; migrate.pgmap_owner = SVM_ADEV_PGMAP_OWNER(adev); + if (adev->gmc.xgmi.connected_to_cpu) + migrate.flags = MIGRATE_VMA_SELECT_DEVICE_COHERENT; + else + migrate.flags = MIGRATE_VMA_SELECT_DEVICE_PRIVATE; size = 2 * sizeof(*migrate.src) + sizeof(uint64_t) + sizeof(dma_addr_t); size *= npages; buf = kvmalloc(size, GFP_KERNEL | __GFP_ZERO);