Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp5622945iog; Thu, 23 Jun 2022 01:50:00 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tnY8Wnny0gfxdQVvi9l6INEnfn9jV0ViMXhUv5DEybRte6lGLJ6870rD0N4N/STk9Wt5Hl X-Received: by 2002:a17:907:6d24:b0:70c:81d9:d5b9 with SMTP id sa36-20020a1709076d2400b0070c81d9d5b9mr6806352ejc.597.1655974200040; Thu, 23 Jun 2022 01:50:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1655974200; cv=pass; d=google.com; s=arc-20160816; b=NgYMwju6RixAPGf4wfL/fyM5sF8M/ofNNC+ss19hCwrHt/9nyAekooO29NHauUYSzE YbL73z021TULrEo53Snt8jbyDPxvPFFASqfmq9YlyJwMUoir4L/qAf6CRanV/3Y8clwj TjSf8kCWvPXYNSBpcS0cAYDdpgGTmG7gqOYvyTgVGmTCdClE6iwB52XrxHXsZS6aOPsm XoIcMkR+Xr8qk5CJKpnA2wAuvcHjR4AsCP41IDItC+OgXl1jCicUeuDjkHh20LpzTJEN zJA0syrFvFOS0ch7/8QcL6A6ow7dsyrWgwjazziyqARYU8uISoVW26GH4XOolyhxDETF a41Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=hQsFDacx59Iv26uF7bWCBKAa1IdgvG25e5FMtsIF09Y=; b=oGNWFgm1DJ25SzHx1Joacy8siHXgfyzmKmQr9G+2wNY9yS8WDcpVO/ZEW04uQfTBTX 2sTSpNJAIPe5KjzZ5ii0Tk/mANX3OV+Rl0LyY5tv++kt7Py8OOlmouboPun4hba7ui8t 3dp6EiuPf2+0U1KAW2oXQ5/CMMSiB9Mv40O7ltHLKP6Pir3peL9QM+PqeHBMm64cDYOL tYHwv3qUfM365kJr5PAVHHfeC2ESM+97k2augHmvGWetOENS+3KTEw3quwSUAhEpbXbQ a0TROqpmXuhzNx6AtxjnYl30P4DJEfpfp5DvV4m1knfaXqVltX/NAspBcLJUOfFvStim ppqw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=QsWXc6HL; 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 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t17-20020a056402525100b00435924b0ba7si11613873edd.580.2022.06.23.01.49.35; Thu, 23 Jun 2022 01:50:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=QsWXc6HL; 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 2620:137:e000::1:20 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 S230346AbiFWIOh (ORCPT + 99 others); Thu, 23 Jun 2022 04:14:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230011AbiFWIOf (ORCPT ); Thu, 23 Jun 2022 04:14:35 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2052.outbound.protection.outlook.com [40.107.243.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F7B847AF9; Thu, 23 Jun 2022 01:14:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Dx5ohH0I4MXl9SosOC0TC5lG9sKGj6lhDq8od/grUaxs4NOwOSaGWiBoQbj41ardG9/HAfLgBl1re2Q+kNXVXG30VG3wWsaVtcUnSQuTm7qOdPl7oXMmk7zYngXqF/2xCCm7xuS2YV9g8zIFB/DXiwimbz4jMV2/oew4A8B2pIVEYB0CkXXV1LTfIvbMuk4RiZvwtTXiviD7KJHTZcOYVprliXcYschPIKj/9kq97F6mx6fTIbgjRHBECRcxd0G3pceF95wcuOXsMBruFfT4iJmfnlWlO62UAliHN8bup7U+vSc24j8pyOurd3uUkNJz09E7Pl9BfwJp2AwraKVkYg== 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=hQsFDacx59Iv26uF7bWCBKAa1IdgvG25e5FMtsIF09Y=; b=TI3JTQqGXw/VMv9I65zqSw7SyyS8VV6dBx2QMO/8LYq7x9mws5wsHoxpZKtinEfa5zFNJZ371qZ6UnhW7S/fV2furjRWqLcmQbzkRuceVQo4CntVA1jBhNe+GOINFmbc3Q1tje53BAsO/pSjoatC/pLhkq0dK2sm8FvGXDuWy46HXUqCZPnHnGkVFvL5eKWUtYavvPbIJHavO/ovaBqT+vhefG8a1hRge65xr8nMB/JH77IFjvkWK3Np3LoCLR3bjTKhky0kZrwLmejvX1Q7OUR+lhR1h0UUui88WT7/ODAOgXOmVpsEaljTcRSzEZS4d8Iul6K/FDbk/kAH2733HA== 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=hQsFDacx59Iv26uF7bWCBKAa1IdgvG25e5FMtsIF09Y=; b=QsWXc6HLytAQBpzXu5kiZ7v/InBLdYFG66Xr1xZFhFNIpfEs3qDOP1SaRtbVP5i6EyUZi/OgK6zlcV9h03c8H36Mrj81eyfjR96M1jEmK0PBb/loUBB2UUOrSQ0xKDkbjiKobkSM8kPjNN3hcRZ4m42gfekNKFbCmUYanNjUduY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3587.namprd12.prod.outlook.com (2603:10b6:408:43::13) by BN6PR1201MB0099.namprd12.prod.outlook.com (2603:10b6:405:5a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.15; Thu, 23 Jun 2022 08:14:29 +0000 Received: from BN8PR12MB3587.namprd12.prod.outlook.com ([fe80::e0fd:45cf:c701:2731]) by BN8PR12MB3587.namprd12.prod.outlook.com ([fe80::e0fd:45cf:c701:2731%6]) with mapi id 15.20.5373.015; Thu, 23 Jun 2022 08:14:28 +0000 Message-ID: Date: Thu, 23 Jun 2022 10:14:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: DMA-buf and uncached system memory Content-Language: en-US To: Lucas Stach , Pekka Paalanen Cc: "Sharma, Shashank" , lkml , dri-devel , Nicolas Dufresne , linaro-mm-sig@lists.linaro.org, Sumit Semwal , linux-media References: <91ff0bbb-ea3a-2663-3453-dea96ccd6dd8@amd.com> <9178e19f5c0e141772b61b759abaa0d176f902b6.camel@ndufresne.ca> <20220623101326.18beeab3@eldfell> <954d0a9b-29ef-52ef-f6ca-22d7e6aa3f4d@amd.com> <4b69f9f542d6efde2190b73c87096e87fa24d8ef.camel@pengutronix.de> From: =?UTF-8?Q?Christian_K=c3=b6nig?= In-Reply-To: <4b69f9f542d6efde2190b73c87096e87fa24d8ef.camel@pengutronix.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: AS9P250CA0015.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:532::20) To BN8PR12MB3587.namprd12.prod.outlook.com (2603:10b6:408:43::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 117a1a7d-305e-47e3-f4ca-08da54f064c7 X-MS-TrafficTypeDiagnostic: BN6PR1201MB0099:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LbewfRMcY0x+xbxQUkJ++PAqByxrYUsbUeodncyrcHVO9Fu9NPWNjQoKmKr7N/J4R6nHfwGRDFro1vPQk2fSiKvmgCeHvH1WTr6j+faRcu/IIDzHa/l0AdCUoy2AvPT15VKZv6BeiMER6nmy46/p7+RxVrpupB7K6d/OQqdOalV/p6QGVCQOPS4ciAj/rbSLfeZbWs0ZWDV0vdXUvu/yjAA+Jbf2YxJpXjTUGRH0+UJnsCyFvoFp6pAda9JBE7aYpLWIFHtR3df7M2LZVIBrDqa6T2Rt0wbfEeRCePCu5jjJuNOptfrt9BArV9Cwqs04kpJFFy6SbOLdo5i7sxHQ/IS9kH9oN5uL5hRMbRbdNCyYGpe0QGvXCs/fNFpZunCZswYnzB5/b1YHDojRnbt+bnTp6FknCZrnxcHk6V0YHpY92Kqo7He7hWgtWtLCfgL0QGtLmUSaipgEtFSJ5lxjBrfdUFBBhe8pGrSQ3Q90CxNmh7ecYBOtxn+iU1qnixxyuzyFXFJITPzpEnG6CIxbz/SzNODAtPS8rMNoH/5tpOmMcb6I7p94BG6f4BK4LoC7mSfakYbfI78ddqfxNrmgG6Pg4W/wFujNnK3RMqKNfAmygbXeV3kdMKcicxCgMeoT2keHTb6DacDpldRrc1OyYY9CX6Gyvvf9hHk3yZ/OkqGlp3bPWaZGYvzPO1x3EXa3WO5WcsHR6LTEv9AJD/ZTmZXbAUkHlBNqlzqHZmFA4Hb/JFAhx54OyULzqfNIecibeVaE6E8jof4pE1UjD2aOsgh3UGa8/7yLVaEq2dJ5VPI= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3587.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(136003)(346002)(366004)(39860400002)(396003)(376002)(186003)(66574015)(6512007)(41300700001)(26005)(66556008)(2616005)(6506007)(38100700002)(31696002)(86362001)(316002)(66476007)(6486002)(6666004)(478600001)(8936002)(54906003)(66946007)(2906002)(36756003)(5660300002)(110136005)(8676002)(4326008)(31686004)(83380400001)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?emx6Y0F0R0wrTXVhelQxckFQcFp5aTc2RU5ZSnlMeVd3MmJMN2d2R1JSQ2U4?= =?utf-8?B?SEJEMGd0T3RLa2FjRm8zVGVaZE5LaGVMTkZlRnB6RFJSV3FFUUxnQk1QZWhv?= =?utf-8?B?cUZmYTRTZEZ6d0IyT3FWbkJuQTV3eVc4SGJ3TEFXL3JwOGgvT2drSHpuQzJY?= =?utf-8?B?OUhORFNxS2hhSlZCQzVLSExhL3FESTFVdmpaYWtFNjlVb3k2TndoU3ZRWXJU?= =?utf-8?B?S2dCWjRTazN3bVpZKzZuK2F5QjhHRkEvaUw3S0pnUnJ2WVZaOE9vZUN4aW1J?= =?utf-8?B?ZTNhVCtRYXdhTWRoNmRzV1U0RHFyRTI1T1NzV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+0nt0l32DfDcRfcN2DoN5G?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 117a1a7d-305e-47e3-f4ca-08da54f064c7 X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3587.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jun 2022 08:14:28.9181 (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: StNkQEZXf1qtcP9fFUqkOgfdYEpaPuagAoHjIq/eLm4rkk8K7bvb0okVi4SuD2pz X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR1201MB0099 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 23.06.22 um 10:04 schrieb Lucas Stach: > Am Donnerstag, dem 23.06.2022 um 09:26 +0200 schrieb Christian König: >> Am 23.06.22 um 09:13 schrieb Pekka Paalanen: >>> On Thu, 23 Jun 2022 08:59:41 +0200 >>> Christian König wrote: >>> >>>> The exporter isn't doing anything wrong here. DMA-buf are supposed to be >>>> CPU cached and can also be cache hot. >>> Hi, >>> >>> what is that statement based on? >> On the design documentation of DMA-buf and the actual driver >> implementations. >> >> Coherency and snooping of the CPU cache is mandatory for devices and >> root complexes in the PCI specification. Incoherent access is just an >> extension. >> >> We inherited that by basing DMA-buf on the Linux kernel DMA-API which in >> turn is largely based on the PCI specification. >> >>> Were the (mandatory for CPU access) cpu_access_begin/end functions & >>> ioctls not supposed to ensure that CPU cache is up-to-date / CPU cache >>> is fully flushed out? >> No, those functions are to inform the exporter that the importer has >> started and finished accessing the buffer using the CPU. >> >> There is no signaling in the other direction. In other words the >> exporter doesn't inform the importer about CPU accesses because it is >> the owner of the buffer. >> >> It's the responsibility of the importer to make sure that it can >> actually access the data in the buffer. If it can't guarantee that the >> importer shouldn't import the buffer in the first place. > This is not really correct. DMA-buf inherited the the map/unmap part > from the DMA API, which on cache coherent architecture is mostly a no- > op or ties into the IOMMU implementation to set up the pagetables for > the translation. On non cache coherent architectures this is the point > where any any necessary cache maintenance happens. DRM breaks this > model by caching the DMA-buf mapping for performance reasons. That's not only because of performance reasons, but also because of correctness. At least the Vulkan API and a bunch of OpenGL extensions make it mandatory for the buffer to be cache coherent. The kernel is simply not informed about domain transfers. For example you can just do a CPU copy to a ring buffer and the expectation is that an already running shader sees that. > In the DMA API keeping things mapped is also a valid use-case, but then > you need to do explicit domain transfers via the dma_sync_* family, > which DMA-buf has not inherited. Again those sync are no-ops on cache > coherent architectures, but do any necessary cache maintenance on non > coherent arches. Correct, yes. Coherency is mandatory for DMA-buf, you can't use dma_sync_* on it when you are the importer. The exporter could of course make use of that because he is the owner of the buffer. Regards, Christian. > > Regards, > Lucas >