Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2750778pxb; Mon, 31 Jan 2022 03:35:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJyiLBD8iRjViypPVTLK1MiYZgcJc7SDP1DYXhHAfY6axrBQmZD5Zrf5CutChYIcbwnmeR6L X-Received: by 2002:a63:4741:: with SMTP id w1mr16104851pgk.214.1643628905066; Mon, 31 Jan 2022 03:35:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1643628905; cv=pass; d=google.com; s=arc-20160816; b=UpcIqTqXmELGnkYH2vk4TAZgDeHcsz85HvZxXV4TLJQiqLfPqzzkernYiqrJv/rgZk PCRUltpNtPUiLgqq8y3cCW+sFDZlrB2sEo0EToUHVcrX//ZA+D6CVf1FSfKWlReXW/Ij M3y22bdy0cnfpdyliqot1EyzIrcHLJKgF1sIIXbskhAeMgoZ7mEcfMWzZt4iXi3xq7lz Gx7ohKYun6LAXOQCoVRIYfM3bXiRT0Y/SBtrRM1oSK2iXoUn6L+mmJqV7NeiM18nzwUd A6YjNdyxH1GUctClABZu0Z/a+B/Yb80zRtY/sSHRpFyvAL0iTCVCvEw2S7URKX3IMPTE /Aiw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=H6Dg+JXQ9T7IJxjdebVIQf/JKMmpP4b0PXF0E4ioiTI=; b=JWtza7OdEnCjKbeCkvmbel0Ry+LTAL34gn+AMewMzzv3WRQapfIEFjxVXE3/yA7Xso 2xTnZz54oR1j0D1Wu3FYm6zRaQPsbwIEIyJyG17tjP65M2TMAxk4HwVEsQzVXloaVUyb JXaK5MnqXRH0as92Ej0oKQ67PrZE8lLUj6z8dOQFES5bOk5cr3Ko8V0htVVT5w+lE36l UEjlFoP071fCJZd97g2Sq/uEVd2WLCzK8oYcnx7oU6gw97FDfh5QhRCilrdAOYWE6qZe il76nfoiXuSqA+dMuL0uv1dgcncprpnjBwsVSwLzBzZkGmoyjtI5b+QhGVh1s/4aa7N/ wU5Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=M3uJLlKj; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l4si12649947pgu.185.2022.01.31.03.34.52; Mon, 31 Jan 2022 03:35:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=M3uJLlKj; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351134AbiA1UJA (ORCPT + 99 others); Fri, 28 Jan 2022 15:09:00 -0500 Received: from mail-mw2nam12on2065.outbound.protection.outlook.com ([40.107.244.65]:46734 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1351117AbiA1UI4 (ORCPT ); Fri, 28 Jan 2022 15:08:56 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wbp6LZFGr15WuC/k3BogyZ4Ib+lox9C3RKcWEks9wEVuxaDlr4kSi2PIsd8u4u5y+dKVM9C5J3tSdm9JUH4jrdFM/JVx6sgNiORp0P5pQ9GOCEjfbRCPwVlJ4PT1pogPgUtD62EMXH6RWrtu94uFldLIhdUd0kVMO01LUmEFWoh7KP8J96B2mFpf3p5b5CgU/F+Vpi93d5ODUNN/DsGmHYhFUukL0LUnugzAoFg2tQ22nGaiwoUaqHAm4qCxPhIwO5QyL+tNSB2bTmQFv+dKu3WDJccD1xkR2G6PkPGY9fDN/GcJ2oTpFku2qbb5D2z9ACUi99AUUvhIYaz3YHubhg== 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=H6Dg+JXQ9T7IJxjdebVIQf/JKMmpP4b0PXF0E4ioiTI=; b=XU9BuQ7bwKtp3bp7F+DZE/Gt3tQ+Rw37n07657VSnk1kJuVgr8+qOXPuNgI/r/jg1wshuy3Rgb+mT7H6+lBpy211nmb/h1IXqB8WJtDpX5ksVXi7cJWJk617t8fLi5PuqdC4KRL/jxR2Ym1xflGDQmljHkJaYfHc1jQZ0da6TiEVhnz5k3eHVJjnP6KmrrrhzP8oifmlJ3E+ESIUA2/eduTwinpjG1iRMKuApxb/s4kD+hHXMNdvBwePy9NL89ay23DNNnYkfj+ODanSYJvNzGCySGqJWEo3BWf6LklO6RLSSdRhTPKfpxqfwvlwRu1QCq/1axoAgggTkPnUKzipQA== 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=H6Dg+JXQ9T7IJxjdebVIQf/JKMmpP4b0PXF0E4ioiTI=; b=M3uJLlKjkVSkX45pjr+R9jcnZvA8bZ479bljP3oAJFoHB3nPxbilEYILfIcNvEHUsOhsD+nA5fWAlufCg2D0tRYjlcRhiPvtnnFtkn5dxBbr1B7F7+lLoRLlNcX8r4wKkGl61kk7LeNjFt7YD+28VV/mQAuJa8UV+hHh8ou2zGM= Received: from MWHPR19CA0071.namprd19.prod.outlook.com (2603:10b6:300:94::33) by DM4PR12MB5374.namprd12.prod.outlook.com (2603:10b6:5:39a::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.11; Fri, 28 Jan 2022 20:08:55 +0000 Received: from CO1NAM11FT022.eop-nam11.prod.protection.outlook.com (2603:10b6:300:94:cafe::80) by MWHPR19CA0071.outlook.office365.com (2603:10b6:300:94::33) 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:54 +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:54 +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:52 -0600 From: Alex Sierra To: , , , , , CC: , , , , , , Subject: [PATCH v5 04/10] drm/amdkfd: add SPM support for SVM Date: Fri, 28 Jan 2022 14:08:19 -0600 Message-ID: <20220128200825.8623-5-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 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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: 2f838c2b-9257-4ef3-ff35-08d9e29a0295 X-MS-TrafficTypeDiagnostic: DM4PR12MB5374:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5+rEp/I1mIBD9imRBf5q54sr/tD37GcuH8hFQx2fhJN35FMbCUbHADhZzfIjAWO/O5gqwJXZZZu58qJutQb0AX0n6bKLMfX/1TdeoMn8H4+8tB4mP3H0Pfu62psmUbofWREWZII7Q1m7brxx3h8m6s3KchPItYFxsJ2dK1dPqzKNh5xkn1X31K1opxV9diVBwIyuRHYetD3AQm9ob6f8qD9vzYybCga5Ii019Di6fOYFp/0t45m6+o8XijY0dum2QEqFLPs5avZQi0VAwSpbY4mjTsOE1TEFg+qJzJDnPpjy5HPYyHcSPFd6Z/WJyF9wCrO361wkl0HU2b7r42AoOUK0zoRoO53oXN6KUy5uy0VoAyjGIJghR9ZZf7KPnfG9DEX9zfNaZ2Oh/g7ze3F47amLKYYwCMLeB0JC42mX8VDF4B3PR7grbNSDGzcME/17ZXTYIvCBdIsVRE3p4R+kHoI/2Obu9KsXloPKhNowP0e76IqEimDVweVkAL8ZLCK8dxS71mOEXDH1Mv7zOR9k8GIB4Xzf6VgMdGGwZljRHog0ZkVFasf8P/DSKPsLHztpvS8jGE4QF0SyiuKuX9C3u1avPOPV928tMHmTlKtUWBzxq1qSyHRLk+8J55SVDfRvbWnA7aR85JJ3ToNWUYTT0MYXuACE5V1Y6ZDbV702jLQgjPC1/QQqE8xbrVGZP/IoCDrXkCii7uwjH9+K5CXN3YRslJHs4dyFdTPDQk1g+g4XjnmiuhBmkZcxZaM2du+ao0GwepPiDVM3pYU7XW/3aDjBSj74gr+86ELLf7tMmx0= 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:(4636009)(40470700004)(36840700001)(46966006)(186003)(26005)(426003)(1076003)(8936002)(40460700003)(82310400004)(5660300002)(2906002)(110136005)(316002)(336012)(70206006)(7696005)(508600001)(86362001)(54906003)(16526019)(83380400001)(70586007)(36860700001)(7416002)(44832011)(2616005)(81166007)(4326008)(356005)(8676002)(6666004)(47076005)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2022 20:08:54.4142 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2f838c2b-9257-4ef3-ff35-08d9e29a0295 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: DM4PR12MB5374 Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org When CPU is connected throug XGMI, it has coherent access to VRAM resource. In this case that resource is taken from a table in the device gmc aperture base. This resource is used along with the device type, which could be DEVICE_PRIVATE or DEVICE_COHERENT to create the device page map region. Signed-off-by: Alex Sierra Reviewed-by: Felix Kuehling --- drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 29 +++++++++++++++--------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c index ed5385137f48..5e8d944d359e 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c @@ -933,7 +933,7 @@ int svm_migrate_init(struct amdgpu_device *adev) { struct kfd_dev *kfddev = adev->kfd.dev; struct dev_pagemap *pgmap; - struct resource *res; + struct resource *res = NULL; unsigned long size; void *r; @@ -948,28 +948,34 @@ int svm_migrate_init(struct amdgpu_device *adev) * should remove reserved size */ size = ALIGN(adev->gmc.real_vram_size, 2ULL << 20); - res = devm_request_free_mem_region(adev->dev, &iomem_resource, size); - if (IS_ERR(res)) - return -ENOMEM; + if (adev->gmc.xgmi.connected_to_cpu) { + pgmap->range.start = adev->gmc.aper_base; + pgmap->range.end = adev->gmc.aper_base + adev->gmc.aper_size - 1; + pgmap->type = MEMORY_DEVICE_COHERENT; + } else { + res = devm_request_free_mem_region(adev->dev, &iomem_resource, size); + if (IS_ERR(res)) + return -ENOMEM; + pgmap->range.start = res->start; + pgmap->range.end = res->end; + pgmap->type = MEMORY_DEVICE_PRIVATE; + } - pgmap->type = MEMORY_DEVICE_PRIVATE; pgmap->nr_range = 1; - pgmap->range.start = res->start; - pgmap->range.end = res->end; pgmap->ops = &svm_migrate_pgmap_ops; pgmap->owner = SVM_ADEV_PGMAP_OWNER(adev); - pgmap->flags = MIGRATE_VMA_SELECT_DEVICE_PRIVATE; - + pgmap->flags = 0; /* Device manager releases device-specific resources, memory region and * pgmap when driver disconnects from device. */ r = devm_memremap_pages(adev->dev, pgmap); if (IS_ERR(r)) { pr_err("failed to register HMM device memory\n"); - /* Disable SVM support capability */ pgmap->type = 0; - devm_release_mem_region(adev->dev, res->start, resource_size(res)); + if (pgmap->type == MEMORY_DEVICE_PRIVATE) + devm_release_mem_region(adev->dev, res->start, + res->end - res->start + 1); return PTR_ERR(r); } @@ -982,3 +988,4 @@ int svm_migrate_init(struct amdgpu_device *adev) return 0; } + -- 2.32.0