Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3024264iog; Mon, 27 Jun 2022 07:41:10 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vpKe8cQfARpDdA6NmYtaiDiVAINfx2az0lu3o2ol+UHX9O/zIO/XaCbQM4i6ToFXdxIrNp X-Received: by 2002:a17:902:8bc1:b0:16a:187c:8719 with SMTP id r1-20020a1709028bc100b0016a187c8719mr15209635plo.43.1656340870387; Mon, 27 Jun 2022 07:41:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656340870; cv=none; d=google.com; s=arc-20160816; b=cd8NfwLJKsFakndO0zXX16f5gnzOknSsZjILjE2RO696MvJ2R4bVX5X8EG6D1eVAw/ g19TFuzhgVupZyzTuaH34Tqlh0ybSUiCwOvb2qTuBnIUcaUhuPeqFAJKZ7KKkFTUZIR+ t3RJRsQGUSO9qvEkcyDJcRT6vQDwvxW7OITBstNF8gycAzlTa0qt7YCvxCXFmuUIo99g D4xhiwib3SquV04EUiVGgSfat2gOMnhyfF5lwwx0ucpA92omRzMNwvu9S7EiR0id1/Wz uZKZ8xd/ZAEueO307tbklL7ahVwOI2iDJgWkfE4RMsT1tsivFA1/EL0X+guAnSF9czoW xk0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=h3AFQmfTD7upgcIWRkb4Re1XIHs+9UGJ35+kGL2q97k=; b=wb0tKGMX0GvRmtioo6j3+x4F8xQl3h1FQYsr9ni2/52ixv5TTliUXO90hdO7u94OYN I+ZaG/HI/XF2/exZIJYlRK5VkIXTBWeg5dckNybQPW/JBbrX7DB9pdXAXHWp+ri4tFtD 9Cbs6MB0fltaEymN8NeoFl44COz1izbwtpdP8wRm8ezvOJ83dOZRb68gYjqPsPalDCPD QbCYwWrzwEhDzDk37vNlZySQsA4D8zbfv42JP5z7JsTt2xG04MWfb+VC5RzvvLlJB7Ny NyVMTDKTyrbus7SztBm87lU2xayuDlBoBKKmqlijOfNndfVyEdEKp+I3xwY75F1dAGj0 ojeg== ARC-Authentication-Results: i=1; mx.google.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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cw24-20020a056a00451800b0050de3100e2asi13742679pfb.97.2022.06.27.07.40.57; Mon, 27 Jun 2022 07:41:10 -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; 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 S236706AbiF0OGp (ORCPT + 99 others); Mon, 27 Jun 2022 10:06:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236645AbiF0OGk (ORCPT ); Mon, 27 Jun 2022 10:06:40 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EAE012A92 for ; Mon, 27 Jun 2022 07:06:38 -0700 (PDT) Received: from gallifrey.ext.pengutronix.de ([2001:67c:670:201:5054:ff:fe8d:eefb] helo=[IPv6:::1]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o5pNq-0003Bu-Ga; Mon, 27 Jun 2022 16:06:34 +0200 Message-ID: Subject: Re: DMA-buf and uncached system memory From: Lucas Stach To: Nicolas Dufresne , 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 16:06:31 +0200 In-Reply-To: <0abe475a7b4b04758c03a9d19b228e86d95ac1dd.camel@ndufresne.ca> 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" User-Agent: Evolution 3.40.4 (3.40.4-1.fc34) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2001:67c:670:201:5054:ff:fe8d:eefb X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,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 Montag, dem 27.06.2022 um 09:54 -0400 schrieb Nicolas Dufresne: > Le jeudi 23 juin 2022 à 11:33 +0200, Lucas Stach a écrit : > > > > > > 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. > > Telling the exporter for every scan is unneeded overhead. If that information is > made available "properly", then tracking it in attach/detach is sufficient and > lightweight. 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. 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. Regards, Lucas