Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp5758828iog; Thu, 23 Jun 2022 04:57:45 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vSxqfoAW++HUMOAwQTO0GANsuplJmOi/LU54UYTaJiMDUaYbhnNiEVopv3wYalk7A7Kazs X-Received: by 2002:a17:906:730f:b0:711:db20:666b with SMTP id di15-20020a170906730f00b00711db20666bmr7662416ejc.763.1655985465648; Thu, 23 Jun 2022 04:57:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1655985465; cv=pass; d=google.com; s=arc-20160816; b=VRf+vpM/LbShF088jNgrkV3JPg7WPBsAOSjB0ohYGXfNaoz+F13HOT2aItAbAbECmr +GB/CM/I2Mqu17s4iXEuoreHdFR9yHa/u6WlI2T8q0Qn7Op3a1fXf7NW+WQvk2ctGU/0 d+TvN0bYyKd4fxb6Uhh7pMYXAv6G0mKu5JYpvQyHV/XFqvoRPNMD3hIK4cxLH6JU67jM 2n/bm2njuuR45DGBH8CL6hXjWhbu8ecye1a/1DOKZAyNohz3Y4aL124vRXdvIE4KMznD 3JhB6avL4bXCLprmAScwoMVVwRJu8wUPLhbtVx2YLHLyFY6Yu27N29KQ/eAQxUDArBIr 7O5w== 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=iZmPe9T8HYP/sRmJXJqUnt4rxmom/RAuzEcGG4HMJGY=; b=FDd+VJR4jhQWWAt3crh9BfARZIC+TMxQ2oanlKvROqJYXvOCXZam/E0Nyw4Q7iwIN3 /Tbr3u+XQXlSXEG96xF3zY1HULynIbBYTJNL16GEbH64DqynKl5d6Xey6NZivJ1lxqtA p6k17VRNciHmq4nT0VOvLC1JqS0xFsQP5PPLW/xTS6YUQZVHZfakdHVgiXJ6D2YOEOPv hqpvfVmaoIGjrzF+wIFAZvW6jRcpS8KbfBF6wIb65oOy3DSQApwUKriUADXldgmd2VNT 6FQD/blEkkTYp+EzB0KbFCZB+rhNESv0R8bKYB6u3KX9GIaAryh9qX4okz9r0P58uNT1 gYCg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=0Xtsdkip; 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 z2-20020a1709060be200b00711db10965asi19556649ejg.590.2022.06.23.04.57.19; Thu, 23 Jun 2022 04:57:45 -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=0Xtsdkip; 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 S231292AbiFWLLJ (ORCPT + 99 others); Thu, 23 Jun 2022 07:11:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230209AbiFWLLI (ORCPT ); Thu, 23 Jun 2022 07:11:08 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2080.outbound.protection.outlook.com [40.107.244.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81B6948E6A; Thu, 23 Jun 2022 04:11:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FB45glYhqnmxg7bzoiVl8GTrcENo6VLlFoDKqGhgaMJGDQqoBHXjoXHtf3AXqIulgIUem+3UGjaYii6WpjAmjCvFQax9D761JiMa87nKlZn6NXGcMbTA6a8wCheHcwmcPytj5Nnd2GkiWYzOaXG7YGlVO/iGkh1Hk8f2nObR/AacsAXofljVxrnlK47pq8ONctVbTnvW1mgluDwoUfig71B+hoTiNzflaFvTqqlf41mZm6iWgMivznpAtREQlvTh0jbm+ADeGkJhjot9C0dbHoXnkpaKc/m5xQTwYg/aEE4FNwnwX/0GmhqvI1gUNYwOo9eQ6ANCfB8dFO1R88D+sA== 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=iZmPe9T8HYP/sRmJXJqUnt4rxmom/RAuzEcGG4HMJGY=; b=NVJl44R74PxHEX6CDA9u2PScl1jUGFIo83V8cmmz90Bmc+BpO8NQumqrlR5AouEw2vBEyIILVeCl2C+Xeqiv0eVj5JJuRi09PllMrfUk9Ihd6qLFYXneJQxYEzzeRCpBK6AMv4hjIyS3zQBQU7pWZWcsCYAU0b0mo3pEAMzCjjaZtCWKl3mLK1a2KJCQ7B5G5t/4H9LWyjZldMsJ2VnqNgoyVuCszF2jNpBIGHOqsr1mMfbPMT+rsRDzC4o6G6lZynqGOYpqQa3S7GMkvagVaDN7ykfStGSVx+zgRE6j0vUW8s1UvPWvDWDxE93N0a9TZsJkGN7ms98AslQEz5BSgA== 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=iZmPe9T8HYP/sRmJXJqUnt4rxmom/RAuzEcGG4HMJGY=; b=0XtsdkipG1fZWfK0k8kLsuUbDfANS27U8P3giV4+vzUT0IjUapB+OSEHheOSsjL7CTOVCO+lPGor9lt9ObVwjxaH4HKES9YZpbTS8W5TG5WHfOPTH15XFoSnqmg7IL0CUnJOkkWweS/pXeXTqnVXL5uKZEcudHrR+Ma6r3pDyOc= 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 DM6PR12MB4877.namprd12.prod.outlook.com (2603:10b6:5:1bb::24) 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 11:11:04 +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 11:11:04 +0000 Message-ID: <6287f5f8-d9af-e03d-a2c8-ea8ddcbdc0d8@amd.com> Date: Thu, 23 Jun 2022 13:10:59 +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> <95cca943bbfda6af07339fb8d2dc7f4da3aa0280.camel@pengutronix.de> <05814ddb-4f3e-99d8-025a-c31db7b2c46b@amd.com> <708e27755317a7650ca08ba2e4c14691ac0d6ba2.camel@pengutronix.de> From: =?UTF-8?Q?Christian_K=c3=b6nig?= In-Reply-To: <708e27755317a7650ca08ba2e4c14691ac0d6ba2.camel@pengutronix.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: AM5PR04CA0001.eurprd04.prod.outlook.com (2603:10a6:206:1::14) 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: a482e23b-0270-4bae-2d9a-08da55091066 X-MS-TrafficTypeDiagnostic: DM6PR12MB4877: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: ZWnYly2+OBpRyqlmsOeF+I2xM1x1hiAmgWCRjv1fu8NGr/upjA4HIMsFRZicSUXDGAm2BC2Vd2HenRjdNktWLiE1gWih7Xjgi+nlfyVlvKYGbwE+Y647U+SDMESQEIb2kEJ7mS607flCV/5DJFVxdRSZWayiFjmh1azbJWFNUL1yibjZDTkkrF4DdA0ulfSJmeEChG6pw/LETnsSg8wVhedF31tpxckjUVGhQAJvK0lHu9nZoqs/+MAP0Nlhubma9wSnjBiNopqawzYUmfP/+SQl7MMqS22hlr7mX6eINEfysLcKEHIF/sHstMR9xa0eDcBhbBAqcidTEPziRShNbEIClMhFlyqVjVcERAgimRHe8TsH7ro1H6GImHX0vFqwmVRWK7OJhrhZ98/34BPpuPVFND13T9OOh2vonOnvZhD/OwWW46ye2HCjBC/mZRaCS/hIIytTpYADOvPbwnP0VVTpgMELsM6s/MnlgtqNreivC7185Jqlu52Uu79gpLroEpNccE49GJfItwCxIt7O7U77i0g+txk6gD3+r4JYsgoQgGArrMYQePc5JUx4fL1YX90vHaRv3wwlvhDgfjECqXD9FH4UqS/fhjB/w8fRe/zSzqUVot4WfveqBV8vUtjwpusS7usQNmK5JvdC42PVvZ1U82pxJmbjaYHcJ8OegywmN9uMuig4Qns1/TkUcca+A6L2Hqjr6I3hYTL3Ke7xC9XfNpSAN3c2dQVVvtk/tsULMPpDAYU0oAqs6r4mW2wepHwyxsdBF1SsVIezTxXmPjDreDIGBTp/4qUdTr/tJdY= 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)(396003)(346002)(136003)(366004)(39860400002)(376002)(6486002)(478600001)(6666004)(186003)(6506007)(54906003)(26005)(8936002)(2616005)(31696002)(5660300002)(6512007)(86362001)(66476007)(4326008)(316002)(83380400001)(41300700001)(8676002)(66946007)(66556008)(38100700002)(31686004)(36756003)(2906002)(110136005)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?enF3SHNpTkVFeEdqeWFYVlZ3YkpjU3paY1BvWWRMblFSWWpzYU9jZlMxemdi?= =?utf-8?B?VVFhRm9BdjNlMDhZaWkxdXY2WHZMTTcraG96MUlXZmRFMFJqSU1SVnBSNys0?= =?utf-8?B?c1RORGJoVDBibjNZeThJU0lVbUUvcTA4Ui92NWs0R3pHeWNaTm5RZDk0ajR1?= =?utf-8?B?YVFhUG80ZGEvMGRzb2VlK3EzcUM1SXh6UzhTdmExTVV6cnNYSS9OTE1jZnV3?= =?utf-8?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g1Z2J5SjBINVdo?= =?utf-8?B?WnBOUlExa1EvVEMzVkU5d3dxQlNuY05PRE1qTlZSNlJFRXhPdk5xMmNrU0U1?= =?utf-8?Q?njyMa5CXnnkMy31/5rgX3/z07?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: a482e23b-0270-4bae-2d9a-08da55091066 X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3587.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jun 2022 11:11:04.6888 (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: vhMi7gSCjWF3f23AzBSmGTUiP04FF2A3E6L/5L5aC2v4WvIiV8Eayb2II58gOeLo X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4877 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 12:13 schrieb Lucas Stach: > [SNIP] >>> On most of the multimedia >>> targeted ARM SoCs being unable to snoop the cache is the norm, not an >>> exception. >>> >>>> See for example on AMD/Intel hardware most of the engines can perfectly >>>> deal with cache coherent memory accesses. Only the display engines can't. >>>> >>>> So on import time we can't even say if the access can be coherent and >>>> snoop the CPU cache or not because we don't know how the imported >>>> DMA-buf will be used later on. >>>> >>> So for those mixed use cases, wouldn't it help to have something >>> similar to the dma_sync in the DMA-buf API, so your scanout usage can >>> tell the exporter that it's going to do non-snoop access and any dirty >>> cache lines must be cleaned? Signaling this to the exporter would allow >>> to skip the cache maintenance if the buffer is in CPU uncached memory, >>> which again is a default case for the ARM SoC world. >> Well for the AMD and Intel use cases we at least have the opportunity to >> signal cache flushing, but I'm not sure if that counts for everybody. >> > Sure, all the non-coherent arches have some way to do the cache > maintenance in some explicit way. Non coherent and no cache maintenance > instruction would be a recipe for desaster. ;) > >> What we would rather do for those use cases is an indicator on the >> DMA-buf if the underlying backing store is CPU cached or not. The >> importer can then cleanly reject the use cases where it can't support >> CPU cache snooping. >> >> This then results in the normal fallback paths which we have anyway for >> those use cases because DMA-buf sharing is not always possible. >> > That's a very x86 centric world view you have there. 99% of DMA-buf > uses on those cheap ARM SoCs is non-snooping. We can not do any > fallbacks here, as the whole graphics world on those SoCs with their > different IP cores mixed together depends on DMA-buf sharing working > efficiently even when the SoC is mostly non coherent. > > In fact DMA-buf sharing works fine on most of those SoCs because > everyone just assumes that all the accelerators don't snoop, so the > memory shared via DMA-buf is mostly CPU uncached. It only falls apart > for uses like the UVC cameras, where the shared buffer ends up being > CPU cached. Well then the existing DMA-buf framework is not what you want to use for this. > Non-coherent without explicit domain transfer points is just not going > to work. So why can't we solve the issue for DMA-buf in the same way as > the DMA API already solved it years ago: by adding the equivalent of > the dma_sync calls that do cache maintenance when necessary? On x86 (or > any system where things are mostly coherent) you could still no-op them > for the common case and only trigger cache cleaning if the importer > explicitly says that is going to do a non-snooping access. Because DMA-buf is a framework for buffer sharing between cache coherent devices which don't signal transitions. We intentionally didn't implemented any of the dma_sync_* functions because that would break the intended use case. You can of course use DMA-buf in an incoherent environment, but then you can't expect that this works all the time. This is documented behavior and so far we have bluntly rejected any of the complains that it doesn't work on most ARM SoCs and I don't really see a way to do this differently. Regards, Christian. > > Regards, > Lucas >