Received: by 10.213.65.68 with SMTP id h4csp675586imn; Tue, 13 Mar 2018 17:45:25 -0700 (PDT) X-Google-Smtp-Source: AG47ELuU8wlPFVjLEScJR1neTvJbWOZhP2nLWQHVEfhbVaIddfdwgOEQURXmnFjb3vlN5E1H2wHn X-Received: by 2002:a17:902:8b85:: with SMTP id ay5-v6mr2201328plb.329.1520988325172; Tue, 13 Mar 2018 17:45:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520988325; cv=none; d=google.com; s=arc-20160816; b=xyhjWN0X4/Je807lLlVAJfbUJyIFL7iKwi65JlufIk+D3cegO7hR1gxuy+cqB6ai2v i3eiTXhilrONGGcWrYimVpDzjLSCAOy0PN6JN07sI4ak6BX8pV3jjaoKYLxZHoUcrWts yENynVHl+fuaYcX/mCwHarOLUERcj0vZLt2ycHI6XbvVLMdjPMaKp5pmu2GcN5x5IlkP uFypkskkltSKndmzPs8oR56iZwzvnYOMqrIqYWYyu1P8SNrYmdmlfKD2Vbl2CzdON0xK XivBfzi5aaM9/0ZOr55qFc2Mt/PmlGPZjdTQP1/KVVurvrzCcz3uVmaZ3l3+BebDwnGt I2mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature:arc-authentication-results; bh=hHf2x8CzWIy4DhZa53wSrLGZfOdOQmmuXCPP5F+PHPg=; b=goIn6vcUgQ/NfWPvY4G4fOMdLWGnp/8cA2UHhln+8IfM+Bojit0N9V6bnJ2iunb4tq wOLbAzILqNjzBqIwrkkD2zpW9Z0b93dSrvNeA+V6tXRNbzMwuKMEcGQbEPe2qZqXuF8j UuoR5evIT7sjOPVcF5/d5qhxh1+dX1GJU9ncz4UdGg8AolX955AzsgMTyHeoeU6+Sp2I 5J0bycIzJUqyaeo9gg0zVSXDMRYKyNRzH7wCMWMzC4gKH4Vjd6hL0/kfCJPDYc+iCH+/ J/m0kyk6gseJSzvne48fTR02PNsd3puKRna3PCvfpK7KRSQvUjNpn8Kw4YAB+FkHVWpA DF+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ndufresne-ca.20150623.gappssmtp.com header.s=20150623 header.b=Ebsu/CqD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x20-v6si1010150plr.352.2018.03.13.17.45.11; Tue, 13 Mar 2018 17:45:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ndufresne-ca.20150623.gappssmtp.com header.s=20150623 header.b=Ebsu/CqD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933146AbeCNAoP (ORCPT + 99 others); Tue, 13 Mar 2018 20:44:15 -0400 Received: from mail-qt0-f178.google.com ([209.85.216.178]:46839 "EHLO mail-qt0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932722AbeCNAoM (ORCPT ); Tue, 13 Mar 2018 20:44:12 -0400 Received: by mail-qt0-f178.google.com with SMTP id m13so1703684qtg.13 for ; Tue, 13 Mar 2018 17:44:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ndufresne-ca.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=hHf2x8CzWIy4DhZa53wSrLGZfOdOQmmuXCPP5F+PHPg=; b=Ebsu/CqDBAWP+one9byuqsYT7Dwcsjwj6VILebjxYIdIkbWLasOp+fgc8JOdPGUbMo ot4kW4OZ7RJ3qqWUXO7wyaIVLZLIxKqMGO9lWL/SV6s6SykcehDiFeiPSTysWoE1lG/h 7tFFO+zzbbq3cJn7JDVsArFebtJmCD+QPVb3GN6JZYqpjOnJGGh4nR3lQd0GWduqM61T gg0ci9juJsqNSncBJega0HVntcYs9xviWGq63XBn9oM/Gzu6JxXmhyIFaTMRrsPhkTmV W1TsEQ2+Jc+6nTPm88w6k4gL254cy8QMj124at0JbknD2NP1ZIo8QYTjQwQsK49/vD1P LJSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=hHf2x8CzWIy4DhZa53wSrLGZfOdOQmmuXCPP5F+PHPg=; b=UEzPkIfE/gukm3QVg9uBEDJSTy/7NInnYaHHMnrvuuGw8I4cdv6YEKtnyNJGN+wDXr 57URu1Q90L90mQt4Tn1dlxdQuFkjA9fkwO0c0mbAt6J3UA689DL+qyGR1dYpdq+c2YZs P1zW4g7iUSWapEnlXZXIQfjQe6WW+YXsjAAYqtsW+scxHYMesrouqq1f8RjHGOjzHwky rIG+xWuZfm5T5DlLxM0e1ybabdNY9OA37DSJocA1GdAe1lOoQc+KVNiUXHMwrCvbX7rs JvHD+Mo4kLFjYNUqdXC++7OZ6vMuBA/5gjZP31C7mxgmIjiZ0kVA56JKfHzC25h2pGdi vaug== X-Gm-Message-State: AElRT7HueMbi056NJ9tMFd8eJAUWW57drmiklhsLZA2NyjvCnB7x1m2n /SG+3s9IDo6scIkDkotDWXYQTQ== X-Received: by 10.237.45.231 with SMTP id i94mr4358247qtd.29.1520988251775; Tue, 13 Mar 2018 17:44:11 -0700 (PDT) Received: from skullcanyon (cable-192.222.221.38.electronicbox.net. [192.222.221.38]) by smtp.gmail.com with ESMTPSA id l23sm1089463qtj.2.2018.03.13.17.44.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Mar 2018 17:44:10 -0700 (PDT) Message-ID: <1520988249.5128.13.camel@ndufresne.ca> Subject: Re: [PATCH] media: vb2: unify calling of set_page_dirty_lock From: Nicolas Dufresne To: Stanimir Varbanov , Sakari Ailus Cc: Mauro Carvalho Chehab , Pawel Osciak , Marek Szyprowski , Kyungmin Park , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 13 Mar 2018 20:44:09 -0400 In-Reply-To: <8f1eda59-fc51-b77e-ae43-9603b5759b14@linaro.org> References: <20170829112603.32732-1-stanimir.varbanov@linaro.org> <1507650010.2784.11.camel@ndufresne.ca> <20171015204014.2awhhygw6hi3lxas@valkosipuli.retiisi.org.uk> <1508108964.4502.6.camel@ndufresne.ca> <20171017101420.5a5cvyhkadmcqgfy@valkosipuli.retiisi.org.uk> <1508249953.19297.4.camel@ndufresne.ca> <8f1eda59-fc51-b77e-ae43-9603b5759b14@linaro.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.5 (3.26.5-1.fc27) Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le mercredi 18 octobre 2017 à 11:34 +0300, Stanimir Varbanov a écrit : > > On 10/17/2017 05:19 PM, Nicolas Dufresne wrote: > > Le mardi 17 octobre 2017 à 13:14 +0300, Sakari Ailus a écrit : > > > On Sun, Oct 15, 2017 at 07:09:24PM -0400, Nicolas Dufresne wrote: > > > > Le dimanche 15 octobre 2017 à 23:40 +0300, Sakari Ailus a écrit > > > > : > > > > > Hi Nicolas, > > > > > > > > > > On Tue, Oct 10, 2017 at 11:40:10AM -0400, Nicolas Dufresne > > > > > wrote: > > > > > > Le mardi 29 août 2017 à 14:26 +0300, Stanimir Varbanov a > > > > > > écrit : > > > > > > > Currently videobuf2-dma-sg checks for dma direction for > > > > > > > every single page and videobuf2-dc lacks any dma > > > > > > > direction > > > > > > > checks and calls set_page_dirty_lock unconditionally. > > > > > > > > > > > > > > Thus unify and align the invocations of > > > > > > > set_page_dirty_lock > > > > > > > for videobuf2-dc, videobuf2-sg memory allocators with > > > > > > > videobuf2-vmalloc, i.e. the pattern used in vmalloc has > > > > > > > been > > > > > > > copied to dc and dma-sg. > > > > > > > > > > > > Just before we go too far in "doing like vmalloc", I would > > > > > > like to > > > > > > share this small video that display coherency issues when > > > > > > rendering > > > > > > vmalloc backed DMABuf over various KMS/DRM driver. I can > > > > > > reproduce > > > > > > this > > > > > > easily with Intel and MSM display drivers using UVC or > > > > > > Vivid as > > > > > > source. > > > > > > > > > > > > The following is an HDMI capture of the following GStreamer > > > > > > pipeline > > > > > > running on Dragonboard 410c. > > > > > > > > > > > > gst-launch-1.0 -v v4l2src device=/dev/video2 ! video/x- > > > > > > raw,format=NV16,width=1280,height=720 ! kmssink > > > > > > https://people.collabora.com/~nicolas/vmalloc-issue.mov > > > > > > > > > > > > Feedback on this issue would be more then welcome. It's not > > > > > > clear > > > > > > to me > > > > > > who's bug is this (v4l2, drm or iommu). The software is > > > > > > unlikely to > > > > > > be > > > > > > blamed as this same pipeline works fine with non-vmalloc > > > > > > based > > > > > > sources. > > > > > > > > > > Could you elaborate this a little bit more? Which Intel CPU > > > > > do you > > > > > have > > > > > there? > > > > > > > > I have tested with Skylake and Ivy Bridge and on Dragonboard > > > > 410c > > > > (Qualcomm APQ8016 SoC) (same visual artefact) > > > > > > I presume kmssink draws on the display. Which GPU did you use? > > > > In order, GPU will be Iris Pro 580, Intel® Ivybridge Mobile and an > > Adreno (3x ?). Why does it matter ? I'm pretty sure the GPU is not > > used > > on the DB410c for this use case. > > Nicolas, for me this looks like a problem in v4l2. In the case of > vivid > the stats overlay (where the coherency issues are observed, and most > probably the issue will be observed on the whole image but > fortunately > it is a static image pattern) are filled by the CPU but I cannot see > where the cache is flushed. Also I'm wondering why .finish method is > missing for dma-vmalloc mem_ops. > > To be sure that the problem is in vmalloc v4l2 allocator, could you > change the allocator to dma-contig, there is a module param for that > called 'allocators'. I've looked into this again. I have hit the same issue but with CPU to DRM, using DMABuf allocated from DRM Dumb buffers. In that case, using DMA_BUF_IOCTL_SYNC fixes the issues. This raises a lot of question around the model used in V4L2. As you mention, prepare/finish are missing in dma-vmalloc mem_ops. I'll give a try implementing that, it should cover my initial use case, but then I believe it will fail if my pipeline is: UVC -> in plane CPU modification -> DRM Because we don't implement begin/end_cpu_access on our exported DMABuf. It should also fail for the following use case: UVC (importer) -> DRM UVC driver won't call the remote dmabuf being/end_cpu_access method. This one is difficult because UVC driver and vivid don't seem to be aware of being an importer, exported or simply exporting to CPU (through mmap). I believe what we have now pretty much assumes the what we export as vmalloc is to be used by CPU only. Also, the usual direction used by prepare/finish ops won't work for drivers like vivid and UVC that write into the buffers using the cpu. To be continued ... Nicolas