Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4810630pxj; Tue, 22 Jun 2021 08:30:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyerL+roip72TYE3yj4pS5Qlo0DMfyYAq9ADgCCS5vEdfoW35Nr57G5m4kvLpFtnpzkeuSV X-Received: by 2002:a05:6638:12cd:: with SMTP id v13mr4510362jas.104.1624375807761; Tue, 22 Jun 2021 08:30:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1624375807; cv=pass; d=google.com; s=arc-20160816; b=b2BdMxYsXZil8cAtIhRI9j+hqWSZITDRAcy0yGpbCgSxFMpDv9+NrQQ3roW0CRPyj3 Tu9g0axGfjdrDA+GLAUdNlx3o+lLuGWt9LUnVKYMV+dYX/3GW8Ki43PXMdB/mgHAMZgM yC7pxOYPvsnphiio8g4xPARKpguMT5bjTLs3Aqq0sX483UA3Vb4hGN3tK0JJVMvkJ1qr tYdHKFSit67Wa/9SlmnGKQu6Xr1n8PRl+kstmIfVlQ86lNCctINuGvtakuF4mBALNwoe sl1KG2/WBHRtNVXpcKpWRymMA2KVI5e6NnB48tjDhTp1Wrbzfad4Wxinz5u+VYny6HFg W5xw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-language :content-transfer-encoding:in-reply-to:user-agent:date:message-id :from:references:cc:to:subject:dkim-signature; bh=knjqMiy9X5NYSpNKZ3d+soIwHzNGU/oF0zuTMPQMTmo=; b=Beyhcyd7sjS30gtjji9xo+VKJQs957l6lbs/w2t+mHEeAy5FLra14K5uKccU3/Cyj7 WRygzaLHrCk/t9xC/20vBTD6LpI4krQ6I/8wpLeNCBhPA3656+CO8EPt+jvJwSyYoOBy /u+Jebz9KX43yOLKr/j8QG7A2r03MFPmnH3E4fqLqrhiANe0QxMKxjAqsxwHCiKkkTTp NTvC/kXczIjC0Zv3aszCXqO312+VX5DM5fYPSTbiAQ8VucutuMTV+F2Ll60lw82wJaYm FRG4lco0GMupsVSCPzUykHQhMbls4Yejm/F2GDo25ltxou/X7iti67F3oe6FbXAExD7o t3QA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Jc+TOv0C; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.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=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 o12si22885620jat.53.2021.06.22.08.29.54; Tue, 22 Jun 2021 08:30:07 -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=@amd.com header.s=selector1 header.b=Jc+TOv0C; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232351AbhFVPbc (ORCPT + 99 others); Tue, 22 Jun 2021 11:31:32 -0400 Received: from mail-dm6nam11on2064.outbound.protection.outlook.com ([40.107.223.64]:57057 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232179AbhFVPbZ (ORCPT ); Tue, 22 Jun 2021 11:31:25 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ElPPwxi0R5Q+6c2XAjso2Y1dllFwiTXaRqcVr8zwJ+0OxDVtuHnRKJDkVdO3SDdf31RyUvwM7xOlfTbbXlMdR1AzuzWdBEDlQ2NR3OyxQ7fDqA1AEqBS19JV6Dgb+6KUmz5XvBDJ4zeRtDoZL6ShCnQX56LO6niGg2JAD4dx8NXGrQbkewd8qGkUOZy/Tb6OIXiF9vt/Ii8glsT1iv3C+1r8mOpbei5mBVnyWM8n1XXVaQNHdx4TTQnuJfOCrDvXpPMO6CO5Ja82rSLQdooRNz0Cs/unwCC9SXyREQB0ZLbToFoJOJBWu9drrEhqGZhDciVb4WDUdrGy4ZMfBQoS6A== 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=knjqMiy9X5NYSpNKZ3d+soIwHzNGU/oF0zuTMPQMTmo=; b=gpZUHURkkbvvWKihwxt0To61Fl21FMSHR6MOZgI/0BD9EcIE+lXP9bxq39HGr3H27xZNY+8FVkX9l5CAOGlb3fHZUWZAU24c6tjt1uqJWmmBAUqhdqxy2xvQgTiOCyMf9yzCV1/p9/pWReGTZex6l2OwX7Jro3cHKdxPlipekpEPH2xx1LF01ATAmz2/rY57+xfd30c+5WElOPXa4wznoe4+OKJTFIQxHjfuXPt2Y9U8iIvxWifEkDfGsQSenkn6RgD4JY67cTu5Lm7Y9iG2t8EYBQEM3Zr2WY3SuUuDUVtvU74wpHSEThYp5flgj1LLzuRGZL5BUEc6CjIgkwXczQ== 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=knjqMiy9X5NYSpNKZ3d+soIwHzNGU/oF0zuTMPQMTmo=; b=Jc+TOv0C5BjyJ+7tvwLSrFy0rn3sjqtZBIV0UT+fVJC7o68XEr2J7z3pHor0pk1aD7nsFZ2ItD0Z1KTjhlrQpNiuHQSqt3E5UANiFebPdv9mSDcUW1YbJ7WNBKEK+Kj04mwXuGbIcgAPPc8qODAYMB3H13BZrBIHvuer3j6mGF4= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from MN2PR12MB3775.namprd12.prod.outlook.com (2603:10b6:208:159::19) by MN2PR12MB4237.namprd12.prod.outlook.com (2603:10b6:208:1d6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.18; Tue, 22 Jun 2021 15:29:07 +0000 Received: from MN2PR12MB3775.namprd12.prod.outlook.com ([fe80::6c9e:1e08:7617:f756]) by MN2PR12MB3775.namprd12.prod.outlook.com ([fe80::6c9e:1e08:7617:f756%5]) with mapi id 15.20.4242.024; Tue, 22 Jun 2021 15:29:07 +0000 Subject: Re: [Linaro-mm-sig] [PATCH v3 1/2] habanalabs: define uAPI to export FD for DMA-BUF To: Jason Gunthorpe Cc: Oded Gabbay , =?UTF-8?Q?Christian_K=c3=b6nig?= , Gal Pressman , sleybo@amazon.com, linux-rdma , Oded Gabbay , Christoph Hellwig , Linux Kernel Mailing List , dri-devel , "moderated list:DMA BUFFER SHARING FRAMEWORK" , Doug Ledford , Tomer Tayar , amd-gfx list , Greg KH , Alex Deucher , Leon Romanovsky , "open list:DMA BUFFER SHARING FRAMEWORK" References: <20210621141217.GE1096940@ziepe.ca> <20210621175511.GI1096940@ziepe.ca> <20210621232912.GK1096940@ziepe.ca> <20210622120142.GL1096940@ziepe.ca> <20210622152343.GO1096940@ziepe.ca> From: =?UTF-8?Q?Christian_K=c3=b6nig?= Message-ID: <3fabe8b7-7174-bf49-5ffe-26db30968a27@amd.com> Date: Tue, 22 Jun 2021 17:29:01 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 In-Reply-To: <20210622152343.GO1096940@ziepe.ca> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Originating-IP: [2a02:908:1252:fb60:9dfd:8ca7:7f8d:67e4] X-ClientProxiedBy: AM0PR06CA0104.eurprd06.prod.outlook.com (2603:10a6:208:fa::45) To MN2PR12MB3775.namprd12.prod.outlook.com (2603:10b6:208:159::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [IPv6:2a02:908:1252:fb60:9dfd:8ca7:7f8d:67e4] (2a02:908:1252:fb60:9dfd:8ca7:7f8d:67e4) by AM0PR06CA0104.eurprd06.prod.outlook.com (2603:10a6:208:fa::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.16 via Frontend Transport; Tue, 22 Jun 2021 15:29:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 457a4ebd-ca5a-46e4-6e2e-08d93592797e X-MS-TrafficTypeDiagnostic: MN2PR12MB4237: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9hxBR8zSqFRP15CeAapWHmg4ugt3PSfU1WBl5rClu1bgoUtndC/9QNMJ5X+HwSw234Ubw8nnUr59u8aHcFC9VK7wVBvdqH7CNM8gPHDgvHckDOCtpLaJ8o7M6vUvctaYbAqLuo52GlDayPrBYW3M5Hhhd4YTFMvo8W1RnH9UN9w7PcAtJJ6JvQ7JyJSQcr51+ElSJYHhnNJNdITnl7ChtA0fy4flm1IXV7SZsW4X//JJCyPJPenVtssAxhnm1shHp9amVv43F6bTNtUfhGCOai1f8/6OXFe5W6FFZ9TD4uxqzsAlhxNfHHzOkO8DJPcwMerqb70fYAIDa1xQ3DjRmtwAhy04A1hWYdG3IpEyeOMSVnnFhfkOQ9b8NWMmEHUNIPJ3lxiDFVgy/i1VJvR/6gT0uMoC1CxoXxp5kJBryFNNzeLQr/5HVJn8wQIbNuaI4kRv5A2t2+dqxjV08B+y1Prm+n8/qxK6yeJH5UEVKO35KHJRnKUv1PkDJe5pYVSfOsfUISFAuynC/BqBoj/gGnggBfW3WRBVO9luAgiNIszav/pHhFpt2KT9rKd2pzVbkPqTMrhZIXJR/Sild2J/vcbuvha4Wmz4JQ7rDeY7/R4pEDbwqh//qycHcsWrM/+UP6D209Hbqwso8YKnjRh/7sGotLpTRaj09dc6BTQvsZv0BpT0ipkWvqMNT9vJSXqd X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR12MB3775.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(136003)(366004)(346002)(39860400002)(376002)(66946007)(53546011)(16526019)(7416002)(66476007)(66556008)(186003)(83380400001)(8676002)(31686004)(86362001)(316002)(54906003)(6666004)(8936002)(478600001)(36756003)(6486002)(6916009)(2616005)(2906002)(31696002)(66574015)(38100700002)(5660300002)(4326008)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?bUxMbFhYMUNaRE1CTllXdG9WdVhBdnVLNXVkRWR4dUNGWHI5aUY1bE1taUV0?= =?utf-8?B?eWJHZUtkYXJGMGd0ejB0NCtiL0NCT1NoZnpZeHdaWER4TUl1SjZSZlpWMUV2?= =?utf-8?B?QkhYRk9VU0N2NzJGQ3c4WUJOV2ljMXlJMm1JejR6TXl6bThYT2tORFdpYWZW?= =?utf-8?B?RlBoa3lwbStvK3dGMGRaaW5uM2pYTUhHVHVnaWdheUlxbzV5Q2lxRW5rZUF3?= =?utf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3F4bmZIbjJESThS?= =?utf-8?B?dXl2VzJDRjBaTTEzVHd1R2NjMmxtMlIrdGQ1S1pTckYybjhYdmdmNGNCbUhk?= =?utf-8?B?RSsraWkvejl0d09lTWU0eGNhS1Fud0pGREtHeUZKQkVVeTErTTcxTkhCV0Fo?= =?utf-8?B?anJMbzNUTnhrNWtuVjkxbFUrOVpSejFhZ0FKaHNOb2t5WnQvTnc4dzFUdGdB?= =?utf-8?B?Lzd1bDVxVFE3YVMzWWFjN3JUcXJtdk1lWDRPc0hjUGNnZytmVVI5UnVNWnpn?= =?utf-8?B?Ukt6UGFRWjJ0UnFjak01bHhFQ3FyYWdKckx6SzFxaHpXRmQzbjV4NjZmdVYz?= =?utf-8?B?K3N0UjRwcUt0Ym55YzRaVkVSY3E0amYrOVFGV1Uydy9zZGl5cUk4MU10Ukx6?= =?utf-8?B?cVRSU0hodnFDNVFKM3Q3eXZGdmVscE1ITDFWOWdObnZZZnlGUHB1QW9RK3pY?= =?utf-8?B?eTNSMzRiU2U4aXQ3dVFkbU5vdHVYU3NnVmtOZ205MnIxcnc5enJOaWVrdGdH?= =?utf-8?B?N2xWdjZwWmFiLy9JUkd5eGU0NXpBeTdBUXVhTGI3K1BBdE94MThyT1c3cEdt?= =?utf-8?B?NkxJOWhNN2VTWUoxcFQwd2dVZVBlc1JrNGVMT1MxZml6SVZUN3MxUGFPNzg4?= =?utf-8?B?VmR5TDhQVzVTOU1yUUw1amlJSFR1b0lCbTNlRzU3bWdrZXJ3NzVBbC85cDVD?= =?utf-8?B?Y0RQdlMzMk5ObWQrK0NKalNWWlFjZ3JqM1hvZ2cybjdTcEo2Y2hwaWJMOWFY?= =?utf-8?Q?/9QjJDBsCmygP?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 457a4ebd-ca5a-46e4-6e2e-08d93592797e X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB3775.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2021 15:29:07.1370 (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: gydCSsQr8MUAcX4Y9s8pY9s3oZXDEl5phA3m7Cpx3mLZKPUe4oLpICM3QR0zDd5J X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4237 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 22.06.21 um 17:23 schrieb Jason Gunthorpe: > On Tue, Jun 22, 2021 at 02:23:03PM +0200, Christian König wrote: >> Am 22.06.21 um 14:01 schrieb Jason Gunthorpe: >>> On Tue, Jun 22, 2021 at 11:42:27AM +0300, Oded Gabbay wrote: >>>> On Tue, Jun 22, 2021 at 9:37 AM Christian König >>>> wrote: >>>>> Am 22.06.21 um 01:29 schrieb Jason Gunthorpe: >>>>>> On Mon, Jun 21, 2021 at 10:24:16PM +0300, Oded Gabbay wrote: >>>>>> >>>>>>> Another thing I want to emphasize is that we are doing p2p only >>>>>>> through the export/import of the FD. We do *not* allow the user to >>>>>>> mmap the dma-buf as we do not support direct IO. So there is no access >>>>>>> to these pages through the userspace. >>>>>> Arguably mmaping the memory is a better choice, and is the direction >>>>>> that Logan's series goes in. Here the use of DMABUF was specifically >>>>>> designed to allow hitless revokation of the memory, which this isn't >>>>>> even using. >>>>> The major problem with this approach is that DMA-buf is also used for >>>>> memory which isn't CPU accessible. >>> That isn't an issue here because the memory is only intended to be >>> used with P2P transfers so it must be CPU accessible. >> No, especially P2P is often done on memory resources which are not even >> remotely CPU accessible. > That is a special AMD thing, P2P here is PCI P2P and all PCI memory is > CPU accessible. No absolutely not. NVidia GPUs work exactly the same way. And you have tons of similar cases in embedded and SoC systems where intermediate memory between devices isn't directly addressable with the CPU. >>>>>> So you are taking the hit of very limited hardware support and reduced >>>>>> performance just to squeeze into DMABUF.. >>> You still have the issue that this patch is doing all of this P2P >>> stuff wrong - following the already NAK'd AMD approach. >> Well that stuff was NAKed because we still use sg_tables, not because we >> don't want to allocate struct pages. > sg lists in general. > >> The plan is to push this forward since DEVICE_PRIVATE clearly can't handle >> all of our use cases and is not really a good fit to be honest. >> >> IOMMU is now working as well, so as far as I can see we are all good here. > How? Is that more AMD special stuff? No, just using the dma_map_resource() interface. We have that working on tons of IOMMU enabled systems. > This patch series never calls to the iommu driver, AFAICT. > >>>> I'll go and read Logan's patch-set to see if that will work for us in >>>> the future. Please remember, as Daniel said, we don't have struct page >>>> backing our device memory, so if that is a requirement to connect to >>>> Logan's work, then I don't think we will want to do it at this point. >>> It is trivial to get the struct page for a PCI BAR. >> Yeah, but it doesn't make much sense. Why should we create a struct page for >> something that isn't even memory in a lot of cases? > Because the iommu and other places need this handle to setup their > stuff. Nobody has yet been brave enough to try to change those flows > to be able to use a physical CPU address. Well that is certainly not true. I'm just not sure if that works with all IOMMU drivers thought. Would need to ping Felix when the support for this was merged. Regards, Christian. > > This is why we have a special struct page type just for PCI BAR > memory. > > Jason