Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3024737iog; Mon, 27 Jun 2022 07:41:50 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sbWR2Cek78GZn/mBSDDf+a+8uSfV4madsbp2hrfoSOan2GoFFmbKG7lP4fHLRV1aoUY2mA X-Received: by 2002:a17:902:bd95:b0:16a:417a:839c with SMTP id q21-20020a170902bd9500b0016a417a839cmr14938978pls.87.1656340909867; Mon, 27 Jun 2022 07:41:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656340909; cv=none; d=google.com; s=arc-20160816; b=Q6oo2u5A3q+/ruVvVTAGsVVySLOFRFscTIzLo4tUuG3oBvd5YRyk82Esmlp3RlobTt ytXTZ0YJjJSwtEoyTMKHxQ1nwfVcAtgu6uaJV2rcytvVyMUICvDgDuJ4nu2ntfxxp4ts oOldksW7SXpRVgbRxbp0QyGw9SThDZ+sWfXdGD1dmDEb/s0GHxLhTDSeHjXmD+0/Q0Jr r0Z9byVfMqQSoycyItNAYrocXWqd2c0S0bZ91dKHfGc1EUmDLponntfhb6q3NL9Mvpl1 Azp+Edebo+qjVg8PJ2q8chmZOdL7y95D5gc62o3jzZV7B3A5ASNych9MJMjp1ZqbJQKY T8Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=+cJ3oW5JhP5CUvm7VtdWYx3n1WPkEHSvCw63kv0T4LU=; b=D7I0M8DNVnOmqK+4qqZ/nu6BfSLdUM3M4R5C/jp+0NfFN+PaLgy6fwnn/DgO7fctoW mTMy8WzTzBWMADp6TbYbDVjz5LpBWRdUkvkGUF1hhQGDCrnLeHKf7AEfIWqq/4FZa6/B Ad3xBNH9vROo2MGETFl3IyED9vk9qOYWaJMW1LdcLFHhy+XSU8MmkbX4g3ErfGoBhSqP X4NtZ/6frlZ3800utX2sa6F4TXfrTWGLYUj/bY3POZAmTHZ3CnhcD6Gf/36pvV9eJ0V8 QM/oUk3kf8hd6r+tjZZb6XlKGNOJT4COZvANimNYZIV/HgBUTBOwFfAJdptj1L98STAD 4Tgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ndufresne-ca.20210112.gappssmtp.com header.s=20210112 header.b=zKSz6Fh1; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z15-20020aa7888f000000b005251ab96060si15491877pfe.247.2022.06.27.07.41.37; Mon, 27 Jun 2022 07:41:49 -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=@ndufresne-ca.20210112.gappssmtp.com header.s=20210112 header.b=zKSz6Fh1; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232831AbiF0Oaf (ORCPT + 99 others); Mon, 27 Jun 2022 10:30:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236266AbiF0Oad (ORCPT ); Mon, 27 Jun 2022 10:30:33 -0400 Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B27DCFC2 for ; Mon, 27 Jun 2022 07:30:32 -0700 (PDT) Received: by mail-qk1-x731.google.com with SMTP id b24so6209020qkn.4 for ; Mon, 27 Jun 2022 07:30:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ndufresne-ca.20210112.gappssmtp.com; s=20210112; h=message-id:subject:from:to:cc:date:in-reply-to:references :content-transfer-encoding:user-agent:mime-version; bh=+cJ3oW5JhP5CUvm7VtdWYx3n1WPkEHSvCw63kv0T4LU=; b=zKSz6Fh1HpYzt9lkFd4E5jvmSjpRZNIYbJsVE9KPIGCT8TrvuwD0p98HjFoUKqxI9/ c1EDzYqPD2Q5jinMHD+OTh0tm2cRoJhw279fQjgZJI8iqyBEeti0R2vTz6GL0vAKTFnw z8Qzj7kV8vLHrnNUFgIlfi1kgEy2YfDYtcEOHHG4Kn448ZEFGQAmmLG82T4LOOV1ZI83 NldkkmZgsCMbxE3QLeNNFI3auIUy3idvVI5U8tQP2r7H6NZNzwU1Y/+hl6apmTacEwwq s47xzvu9mphE24bX7TpPAqcFQoJG617eSse6aEU5Zhm2ZKjapJg5EDAnfdKn9VUCbVHX EH7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:content-transfer-encoding:user-agent:mime-version; bh=+cJ3oW5JhP5CUvm7VtdWYx3n1WPkEHSvCw63kv0T4LU=; b=dExwluAsz3/A05sqCdF9pneFU3DsCOvfrcYhbm5GEU1scVTR0B9fWlX6wlpGEocUSU 4Zq4nl0P4+ijL00oufL6+7jNrzOeFcwlCZv9EJ31viVkBlko7Nrt4uX+NCfRhhcEdcWv u1ywkx/9MdRUS1D66uBgg2JAiFnHL03KKCE9V0l5ZjpfKMMhavaxkKDJNxqpYtPZ4DvF kmTFJ31ppZr7LMp3RNLFi5LOQbwpvsd4UM6TbfpueWQH6H5iTI9yCv2Vrtwc7L1vsXLY dST2zGwm3ApsTxT2zu+t+aACwO/XwsQsiEXc9WhTXDJ1dSgQJI10m1riAW7pyfbbc7V6 IP7w== X-Gm-Message-State: AJIora+qu5wusd4ujiyCeYBI0hW6CDaKHtx8W8h4++NzoL79ow3NbPDX tjZlHRSiOLYWC/QYYzxugxmaJg== X-Received: by 2002:a05:620a:4412:b0:6af:2f47:7de2 with SMTP id v18-20020a05620a441200b006af2f477de2mr2679155qkp.649.1656340231749; Mon, 27 Jun 2022 07:30:31 -0700 (PDT) Received: from nicolas-tpx395.localdomain (192-222-136-102.qc.cable.ebox.net. [192.222.136.102]) by smtp.gmail.com with ESMTPSA id i1-20020a05620a404100b006a6ae636ce0sm9535296qko.131.2022.06.27.07.30.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jun 2022 07:30:31 -0700 (PDT) Message-ID: Subject: Re: DMA-buf and uncached system memory From: Nicolas Dufresne To: Lucas Stach , Christian =?ISO-8859-1?Q?K=F6nig?= , Pekka Paalanen Cc: "Sharma, Shashank" , lkml , dri-devel , linaro-mm-sig@lists.linaro.org, Sumit Semwal , linux-media Date: Mon, 27 Jun 2022 10:30:30 -0400 In-Reply-To: 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> <0abe475a7b4b04758c03a9d19b228e86d95ac1dd.camel@ndufresne.ca> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.2 (3.44.2-1.fc36) MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, 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 Le lundi 27 juin 2022 =C3=A0 16:06 +0200, Lucas Stach a =C3=A9crit=C2=A0: > Am Montag, dem 27.06.2022 um 09:54 -0400 schrieb Nicolas Dufresne: > > Le jeudi 23 juin 2022 =C3=A0 11:33 +0200, Lucas Stach a =C3=A9crit=C2= =A0: > > > >=20 > > > > See for example on AMD/Intel hardware most of the engines can perfe= ctly=20 > > > > deal with cache coherent memory accesses. Only the display engines = can't. > > > >=20 > > > > So on import time we can't even say if the access can be coherent a= nd=20 > > > > snoop the CPU cache or not because we don't know how the imported= =20 > > > > DMA-buf will be used later on. > > > >=20 > > > 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 dirt= y > > > cache lines must be cleaned? Signaling this to the exporter would all= ow > > > to skip the cache maintenance if the buffer is in CPU uncached memory= , > > > which again is a default case for the ARM SoC world. > >=20 > > Telling the exporter for every scan is unneeded overhead. If that infor= mation is > > made available "properly", then tracking it in attach/detach is suffici= ent and > > lightweight. >=20 > That isn't sufficient. The AMD GPU is a single device, but internally > has different engines that have different capabilities with regard to > snooping the caches. So you will likely end up with needing the cache > clean if the V4L2 buffer is going directly to scanout, which doesn't > snoop, but if the usage changes to sampling you don't need any cache > flushes. >=20 > Also I don't see a big overhead when comparing a kernel internal call > that tells the exporter that the importer is going to access the buffer > without snooping and thus needs the cache clean once every frame and > the need to always clean the cache before DQBUF when a potentially non- > snooping importer is attached. Ack, thanks for the information. >=20 > Regards, > Lucas >=20