Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4318092ybl; Tue, 21 Jan 2020 17:40:54 -0800 (PST) X-Google-Smtp-Source: APXvYqyY3pId4Xb7Xw1MUtwHhZ3HK5Fc/q4n9fE4nsYa/L6tkkHxe9J5QTuq+HKnf87dTd+8AVV3 X-Received: by 2002:a9d:ee2:: with SMTP id 89mr5496884otj.270.1579657254385; Tue, 21 Jan 2020 17:40:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579657254; cv=none; d=google.com; s=arc-20160816; b=rzM+c4rc/Z1rhLN5oDym9smtSBx7w03qWgKwgerYYEXAMGmPvKpqUyEUsfaFuItKoE eQHAqrx/uSOcKLWb94ZPH+WzcMb6TTCCXxtB3yZud70rHe6ZYPObUf001vC0lnvUuJJC 2jSFNtDRjBVguZ0RcWn2TseWe5ZvcSdL6Fy/KyJ65wskLLq9g1e6Zz/XGnBkyCgDS2HB S1L14mFPRZZko3JFLFXzRXEjZuhWDRXCp7LZlkxBbOzWxCucf7KCi8G2b7jLl40IPj5E RJacKRFBhs3jwzp04l5Frje+PdqWK3u7xL4/ramo9uRzGsS8yXWMBDWRvx5b4CBOGkiV bcig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=GR5h1tt2wJy5kG2UEKPuOm//LxmTSWIE80O9BC6vjqA=; b=C/Sbvz0YEL+KiUyJ9kgdmBcbWKA6JTVfjM0Yts8HFz7zzdHZzCKjHxyZlnEhxHy+r7 l3Q+nYG6+fW8bDv4eQLywqJgqtsDy98oLlbNqnOPBwae1edlaJwLVzoudpIDCw2zVnVh tQV3BHosozEFy6/nWHwEgGEUQXxCYVbSfK5JdApOEgiGprMGhKUEVLu9ieMjILZVjlZ8 jGlMPwZrjYjKmzn2HMsAQrhIU0DAdEYI5g4GVCwixKldHTcJP883xnYtT1bz12+eJN2T z2fMn1XEwySKZpoy9wcf1z4gpE2ePGK8YcW2hYgS+KPODbU38iuFw4lqFrro4vAnM4WO DvBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=W333QISV; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n9si22018655ota.103.2020.01.21.17.40.42; Tue, 21 Jan 2020 17:40:54 -0800 (PST) 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=@chromium.org header.s=google header.b=W333QISV; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728981AbgAVBjl (ORCPT + 99 others); Tue, 21 Jan 2020 20:39:41 -0500 Received: from mail-pj1-f68.google.com ([209.85.216.68]:38096 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728901AbgAVBjl (ORCPT ); Tue, 21 Jan 2020 20:39:41 -0500 Received: by mail-pj1-f68.google.com with SMTP id l35so2565579pje.3 for ; Tue, 21 Jan 2020 17:39:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=GR5h1tt2wJy5kG2UEKPuOm//LxmTSWIE80O9BC6vjqA=; b=W333QISVONGD08j00/Y3QQwYv0ParIpCj6sdrKhnnuuTcSuDqKiL420+3RE+GuwwGs hnjJKbHvMWu8cZ1a4c2TBFaiQ994byvcG5nIQSz4JYvaVaVEnAeEaMGIUxblvg7naCbm aO+dVJLE9HoeG0xzjx6R0naDuqgvOiTEYRPbU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=GR5h1tt2wJy5kG2UEKPuOm//LxmTSWIE80O9BC6vjqA=; b=nqam0ylmKvtrvtSBNsPaNi4n1u9HcYllRzMfRBb8KbKKFwLiQ2BnOd8JSdm8bZodwv GumUstUdsfnuSYgJ19J3Zxxv4cWdqzWZKURkkgVOo/b2s+QQYNIHByzjA7CU6WRdc3KF fP3bmjJVoDIDtGxUW21ZjolpK2eWBT5zbcxMcC4/J1a9xyShrRBgfm/hGnVJ/nuxd2bT dAOMbm53TNXrbcZMOhb3wCaJ+QHwj8aI5SA6t2w6PgdG7cuKTH44j90RbUFGRytC2Jpi zXVXXpFTS7XVlF2aSOv4AkPdoV7ReH2HQdCCdgpif60P6XIjx2VPzIelEO8lQ2OJEW0q m10A== X-Gm-Message-State: APjAAAUM9g9WuE7Pzm6Aiv+dAKk1vK3CJDKfmaJXnZkkJs67eUKSXSH3 rXD8ACmltazGUg+r+m48BV6LTA== X-Received: by 2002:a17:902:6b4b:: with SMTP id g11mr8223389plt.26.1579657180827; Tue, 21 Jan 2020 17:39:40 -0800 (PST) Received: from localhost ([2401:fa00:8f:203:5bbb:c872:f2b1:f53b]) by smtp.gmail.com with ESMTPSA id w4sm666460pjt.23.2020.01.21.17.39.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2020 17:39:40 -0800 (PST) Date: Wed, 22 Jan 2020 10:39:37 +0900 From: Sergey Senozhatsky To: Hans Verkuil Cc: Sergey Senozhatsky , Hans Verkuil , Tomasz Figa , Mauro Carvalho Chehab , Kyungmin Park , Marek Szyprowski , Sakari Ailus , Laurent Pinchart , Pawel Osciak , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC][PATCH 02/15] videobuf2: handle V4L2 buffer cache flags Message-ID: <20200122013937.GC149602@google.com> References: <20191217032034.54897-1-senozhatsky@chromium.org> <20191217032034.54897-3-senozhatsky@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Sorry for the delayed. On (20/01/10 11:24), Hans Verkuil wrote: > On 12/17/19 4:20 AM, Sergey Senozhatsky wrote: > > Set video buffer cache management flags corresponding to V4L2 cache > > flags. > > > > Both ->prepare() and ->finish() cache management hints should be > > passed during this stage (buffer preparation), because there is no > > other way for user-space to skip ->finish() cache flush. > > > > There are two possible alternative approaches: > > - The first one is to move cache sync from ->finish() to dqbuf(). > > But this breaks some drivers, that need to fix-up buffers before > > dequeueing them. > > > > - The second one is to move ->finish() call from ->done() to dqbuf. > > Please combine this patch with patch 13/15! OK. [..] > > } > > > > +static void set_buffer_cache_hints(struct vb2_queue *q, > > + struct vb2_buffer *vb, > > + struct v4l2_buffer *b) > > +{ > > + vb->need_cache_sync_on_prepare = 1; > > + > > + if (q->dma_dir != DMA_TO_DEVICE) > > What should be done when dma_dir == DMA_BIDIRECTIONAL? Well, ->need_cache_sync_on_prepare/->need_cache_sync_on_finish are set, by default. If the queue supports user-space cache hints (driver has set ->allow_cache_hints), then user-space can override cache behavior. We probably cannot enforce any other behavior here. Am I missing something? > > + vb->need_cache_sync_on_finish = 1; > > + else > > + vb->need_cache_sync_on_finish = 0; > > + > > + if (!q->allow_cache_hints) > > + return; > > + > > + if (b->flags & V4L2_BUF_FLAG_NO_CACHE_INVALIDATE) > > + vb->need_cache_sync_on_finish = 0; > > + > > + if (b->flags & V4L2_BUF_FLAG_NO_CACHE_CLEAN) > > + vb->need_cache_sync_on_prepare = 0; > > +} -ss