Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp773131ybg; Wed, 3 Jun 2020 13:16:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyImFTHCT7RdxtR5tjaUsHK8RfEJLhsThZAa5GEaCggHyBe9zw85Pm1IujP8PUq4NEJyIj X-Received: by 2002:a50:a602:: with SMTP id d2mr1224947edc.112.1591215383165; Wed, 03 Jun 2020 13:16:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1591215383; cv=pass; d=google.com; s=arc-20160816; b=F/ms5A86nI2EVUtEXMPjIEaBmPrmETilJ9Zo7QVdezIT7bdW8ZIi1fU7sckp928b52 jE5QJqnxzis3VgPEFSR561jeV6LWxHmwECE6/JkT8HIY4IOt7ucQA0HbNyqancb7X0Le HVTXmAgtINbrhAP7FKGt+2hUyV8oV6ZuliU0YqVft+RThcnvuEg6beBYTMnXg0QCDDTK CVYFTZhAlpvCzmd4VvLqRHl13hQQX0G4RGO6QQ7eiIevZUIRwwVSyC3E6neVW14TBN4w W24zkFl7v0QEVCj3NRxGb2V6YGXISTpZsZbSW9xOYZs3ohZP32qq1fD/F1T5KHRCXZ6x 3YxA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:in-reply-to :content-transfer-encoding:content-disposition:references:message-id :subject:cc:to:from:date:dkim-signature; bh=vHcRcr+afO3Qs4zkkCgV2ucA9xp7mBMigCKrn5AqN6o=; b=l1P69W5bB2reVYtiQnY9oOShDqpc8akJRbOds8CPgS/UDaSTbaOAVMwgyZHx1WfMNU jfuPwRNmWu340AYJNb3SK9UGcOvafJ6OgvOTkXUyWaqZRfhxGCrcp4FypeQXH/HMZLpa WDQlV4+b4B+8mhRk+6/b93vH77CYAa/UFY6FvBl5YqnBUR1GbqkWqQennJv5ggv8i/kO oc/ZzJ9a95HdhZYB7Lyeo25KBij9mNQNbpKY+tIWkxNmSpcWekocY7+JYDPM3IATxJGg MiEADo353YUsQZEP6HT/SPhoyEidwkAB+4gUAvx+WzQeTEHys1O0E0QNgMlV7o/+E9Nm u+GA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Mellanox.com header.s=selector1 header.b=E3FpMLtU; arc=pass (i=1 spf=pass spfdomain=mellanox.com dkim=pass dkdomain=mellanox.com dmarc=pass fromdomain=mellanox.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dm17si370082ejc.707.2020.06.03.13.15.58; Wed, 03 Jun 2020 13:16:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@Mellanox.com header.s=selector1 header.b=E3FpMLtU; arc=pass (i=1 spf=pass spfdomain=mellanox.com dkim=pass dkdomain=mellanox.com dmarc=pass fromdomain=mellanox.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726134AbgFCUNv (ORCPT + 99 others); Wed, 3 Jun 2020 16:13:51 -0400 Received: from mail-eopbgr140041.outbound.protection.outlook.com ([40.107.14.41]:2575 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725821AbgFCUNu (ORCPT ); Wed, 3 Jun 2020 16:13:50 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gqGtEZUotHwvImq6gQMI3bB586y0d8XYDAoWHH5j9iuGiI4yKNllKbIzDlMJ3wYfANfh9J5ChldxpEs2dkcq7a2TZYGerUhuDEBdDaGdIFOJQBKm4jey3PqQ3tjafiFopkwXHP5YAG51ZupTkb6SehgqCi4z3Awga7YaJC5Tq1ZE5d/OhCQClUq3DsMkNoofcsoSMs3RaBUSnwsrIfisFkQEQlsYEXeJ20KaHG5Dc7Itc1m8/JLYtKcke/tIMtHs+BBGSK/efP/Zxsbdxg4IaWPXA1oEm1sGqqhvZnolKIvxKPL54gbMuvixg0AuIB5QvHcbpZ33jZrARRZ8+Of71w== 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=vHcRcr+afO3Qs4zkkCgV2ucA9xp7mBMigCKrn5AqN6o=; b=O2+zSbkbIjR1CKIHPp0oI/W2sCJl1R8ZP+G9zjtE1hJk+RBuQfpJ+ASOlpOW1DIg+VuWXjsTFI/5kcCbOHfYm3cp+oGvOfPFHzW5rphVqlFTmjMopCbX93DCvi7l2DRkOBCK7oi2wCbGhojsEsoty+YhPWZIDorgOCZp/syKYCEUgSatbGP6pVypHt20HQMj9d1IwNRm7/kzcM9/ChZeMtfu4R4WYLEMZnqpCNCjSdhsJAh98kmoiwNYLcd0Uce0fqSWCG77BhlXHEnpOB2mICQz7Y/goeisaCKuhKdf9N6oxZxxQMIpw48kSOCSV97JberlGYTBYFzZdijJe3gr5g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vHcRcr+afO3Qs4zkkCgV2ucA9xp7mBMigCKrn5AqN6o=; b=E3FpMLtUev+f/kmt5loMM0plKCCsHXTI9j1Hex4VL2qlgEggRj0vQIL6apZDlXL7o34oRY0PRkye5kwVSB8FQFzPi2Wp3/qGejrR04BBh1Abe1AQF23sPIDDXx5zfT28uuYfjDhZarNX6DvugQYMXqIu2AdSpmcUdaYeCMU7shA= Authentication-Results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=mellanox.com; Received: from VI1PR05MB4141.eurprd05.prod.outlook.com (2603:10a6:803:44::15) by VI1PR05MB4461.eurprd05.prod.outlook.com (2603:10a6:803:40::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.17; Wed, 3 Jun 2020 20:13:46 +0000 Received: from VI1PR05MB4141.eurprd05.prod.outlook.com ([fe80::848b:fcd0:efe3:189e]) by VI1PR05MB4141.eurprd05.prod.outlook.com ([fe80::848b:fcd0:efe3:189e%7]) with mapi id 15.20.3066.018; Wed, 3 Jun 2020 20:13:45 +0000 Date: Wed, 3 Jun 2020 17:13:37 -0300 From: Jason Gunthorpe To: Dave Airlie , Christoph Hellwig , Christian =?utf-8?B?S8O2bmln?= Cc: Linus Torvalds , Daniel Vetter , dri-devel , LKML , Logan Gunthorpe Subject: Re: [git pull] drm for 5.8-rc1 Message-ID: <20200603201337.GA225528@ziepe.ca> References: Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-ClientProxiedBy: MN2PR15CA0053.namprd15.prod.outlook.com (2603:10b6:208:237::22) To VI1PR05MB4141.eurprd05.prod.outlook.com (2603:10a6:803:44::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mlx.ziepe.ca (193.47.165.251) by MN2PR15CA0053.namprd15.prod.outlook.com (2603:10b6:208:237::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18 via Frontend Transport; Wed, 3 Jun 2020 20:13:45 +0000 Received: from jgg by mlx with local (Exim 4.93) (envelope-from ) id 1jgZlZ-000wuT-6Q; Wed, 03 Jun 2020 17:13:37 -0300 X-Originating-IP: [193.47.165.251] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: f854f429-4ea0-4ca5-cc45-08d807fa9e55 X-MS-TrafficTypeDiagnostic: VI1PR05MB4461: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:989; X-Forefront-PRVS: 04238CD941 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: f7dphUCF79o5P+QCoLjy8doT0f0iiQy1x2gNSgGeD3z0AfJw+uOvlFDJy2dewrV/1+cRlsJhU1aafVmtohsv2+MkiJR/SYwlBR0vmk9sKytRCqQP+aw+qsqNUo6CViq4cY82wGOM92cPz2sxIulNI2Q8rmpbG0/tPJOxIvngG2CjDytB/3k1JfxO3fdampgVxjF8C/MgeWrNG114baeCGh9YsimvPbm+Z6k1Fw3fHyDQYugPq/93dT0oEiYGFjf1PQudYpgp/Tqr1V2oaACVMVKPZbt9s+ET0YxLRiPXWK6dirXb+nlcB2OC6+jt18GkodgCe7GEal8DzSEwvfTN5tVoFJoGrCjwx8zdgsQTD+FsiAHZCMsmYOswH+Pbc43lbkL6zISNElzrscmaoion1e5oRUbnUzcLaxcB5VjM2iGjoBN9gKp5tat6upsyPTaQ9jT+0ljLx1lxRJLv2iZI0w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR05MB4141.eurprd05.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(346002)(366004)(376002)(136003)(396003)(39860400002)(2906002)(8936002)(316002)(33656002)(426003)(86362001)(8676002)(4326008)(9686003)(26005)(66574014)(186003)(36756003)(9746002)(9786002)(66476007)(110136005)(478600001)(54906003)(83380400001)(1076003)(66556008)(66946007)(966005)(5660300002)(27376004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: W3awLMfh4boklwVoIALszg/zdG91lmylg4OehcXuP6cc2zocxUaLNUMpv44KDEe4PxJfFJGgHC+6CSbteicxWG+xWc50eNDNEoeJc0gCerUXslsHxT9cVO9rUWCfobQfKECP2zbgifoXpfstn8Hb9EPYf/wZnydBEaNgUBjyexoG2Up75Eb0NY318pgi46LtmRMKLdaKx53QfWMriFSEiktJGdMndg8DVGnlDD5eCRbw3ZEyHjXLhl4gSEHcZ5yXMGHM0decYH1Wx0xW/IAoCPUc0hQwShWdJjEFhM/HGk/wK6YgnxJ+I8HtuoUZqc15sJDQk65n9hihb1wmnYcKt/gvUxjC35ILhDmZXYBuvrECmamDHuJtScJInRidjgUlZbG1SzUthPH1dbKjokd1ahC8og9atxpIW1JQL0gjqoL15uQF8QYW3ggEgo0jZa/9sLJGZqvLWs+oP6XlUZ6HaEf77z97r015QKmq3WmtujFufdZ7h7MSYajgg3lt5mpz X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: f854f429-4ea0-4ca5-cc45-08d807fa9e55 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2020 20:13:45.7343 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: uUv08PUESsfMQo9YK2C7zLjPWDkGYJHYLLE9MFM3/ZeLOLOrMt5m0VI4dsjM9WR2e8RcdCBs4mKW3ltjp2K/nw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB4461 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 02, 2020 at 04:06:32PM +1000, Dave Airlie wrote: > Hi Linus, > > This is the main drm pull request for 5.8-rc1. > > Highlights: > Core DRM had a lot of refactoring around managed drm resources to make > drivers simpler. > Intel Tigerlake support is on by default > amdgpu now support p2p PCI buffer sharing and encrypted GPU memory Christoph Hellwig basically NAK'd this approach, why is it getting merged all of a sudden?? https://lore.kernel.org/intel-gfx/20200311152838.GA24280@infradead.org/ Are we now OK with this same approach open coded in a driver? This wasn't Cc'd to the usual people doing work in this PCI P2P area?? See commit f44ffd677fb3562ac0a1ff9c8ae52672be741f00 Author: Christian König Date: Fri Mar 23 16:56:37 2018 +0100 drm/amdgpu: add support for exporting VRAM using DMA-buf v3 We should be able to do this now after checking all the prerequisites. v2: fix entrie count in the sgt v3: manually construct the sg Signed-off-by: Christian König Acked-by: Daniel Vetter Acked-by: Sumit Semwal Link: https://patchwork.freedesktop.org/patch/359295 [..] diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c index 82a3299e53c042..128a667ed8fa0d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c @@ -22,6 +22,7 @@ * Authors: Christian König */ +#include #include "amdgpu.h" #include "amdgpu_vm.h" #include "amdgpu_atomfirmware.h" @@ -458,6 +459,104 @@ static void amdgpu_vram_mgr_del(struct ttm_mem_type_manager *man, mem->mm_node = NULL; } +/** + * amdgpu_vram_mgr_alloc_sgt - allocate and fill a sg table + * + * @adev: amdgpu device pointer + * @mem: TTM memory object + * @dev: the other device + * @dir: dma direction + * @sgt: resulting sg table + * + * Allocate and fill a sg table from a VRAM allocation. + */ +int amdgpu_vram_mgr_alloc_sgt(struct amdgpu_device *adev, + struct ttm_mem_reg *mem, + struct device *dev, + enum dma_data_direction dir, + struct sg_table **sgt) +{ + struct drm_mm_node *node; + struct scatterlist *sg; + int num_entries = 0; + unsigned int pages; + int i, r; + + *sgt = kmalloc(sizeof(*sg), GFP_KERNEL); + if (!*sgt) + return -ENOMEM; + + for (pages = mem->num_pages, node = mem->mm_node; + pages; pages -= node->size, ++node) + ++num_entries; + + r = sg_alloc_table(*sgt, num_entries, GFP_KERNEL); + if (r) + goto error_free; + + for_each_sg((*sgt)->sgl, sg, num_entries, i) + sg->length = 0; + + node = mem->mm_node; + for_each_sg((*sgt)->sgl, sg, num_entries, i) { + phys_addr_t phys = (node->start << PAGE_SHIFT) + + adev->gmc.aper_base; + size_t size = node->size << PAGE_SHIFT; + dma_addr_t addr; + + ++node; + addr = dma_map_resource(dev, phys, size, dir, + DMA_ATTR_SKIP_CPU_SYNC); + r = dma_mapping_error(dev, addr); + if (r) + goto error_unmap; + + sg_set_page(sg, NULL, size, 0); + sg_dma_address(sg) = addr; + sg_dma_len(sg) = size; ^^^^^^^^^^^^^^ Jason