From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83392C433FE for ; Fri, 10 Sep 2021 14:16:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6B35261026 for ; Fri, 10 Sep 2021 14:16:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233945AbhIJORq (ORCPT ); Fri, 10 Sep 2021 10:17:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233879AbhIJORo (ORCPT ); Fri, 10 Sep 2021 10:17:44 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7FBAC061756 for ; Fri, 10 Sep 2021 07:16:32 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id f3-20020a17090a638300b00199097ddf1aso1617894pjj.0 for ; Fri, 10 Sep 2021 07:16:32 -0700 (PDT) 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; bh=gw+gLCH4fCh3RyF148MnGJMCmmJ7GK/O+08Kg6ZzZIU=; b=iGKa/dQ/+1b2SCObj5WlpAPCGiElDzjo26XEpjecBcMIOUB+ABwSNwYetiNhbPpjjP BtSbRcbsv8OjFrr8xovigvNf7WiTiIocIAATducN2RkKRBxpCRx2ZXDia3mZptZQTLWb Vl4jDx1kT4QYXTRkK4WNOpMo4w7e/YOknPwS8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=gw+gLCH4fCh3RyF148MnGJMCmmJ7GK/O+08Kg6ZzZIU=; b=19GqFgB6d5eWA9lHNx98eeUL6hIJHrB8Xzl+f5meBsrRGm7txWywSBzimlY/pmP721 qds0WTgEN/OJXddjrnLXuaXCoB/vxAjp7O42JjchcC1kp0sfI+l5vbL1hPhUedu5yv8r Y8nqLtXlnRx8eu/0krJXqcukjaxTW9HveNrP81Y4B76YTonPzJnZk1VoKzeQZbclAZQu Wn6xhNpG2v7RKParuveZnzFBOhmiON9LNQYLVldsRPb8TDegD+cDgVRoshUxQrMSno67 4GkPgwejvmTgqpEuX5sELiJah/16HNtj0htVnYsJP9KP2aftn5dNGby2XKhKYCHuB0cN oJvw== X-Gm-Message-State: AOAM530KA8KYC2+VjOY9/TJm2Pb+96z1wPWKQM5gCDjfvsl1vU+VtcPs umWyviPiQWUbBD5H/I4TXW8Z7G7Rq1wLGw== X-Google-Smtp-Source: ABdhPJx/ZYE/fslknnTb9EgXTfXCY/KJOZR+QfvjM/8WANgcJTX0p3oHcALf2sE4fe/3ZRje9ASGgQ== X-Received: by 2002:a17:902:be0f:b0:13a:95e:a51 with SMTP id r15-20020a170902be0f00b0013a095e0a51mr7888442pls.44.1631283392125; Fri, 10 Sep 2021 07:16:32 -0700 (PDT) Received: from google.com ([2409:10:2e40:5100:7627:5944:d90:b374]) by smtp.gmail.com with ESMTPSA id e13sm270051pfc.137.2021.09.10.07.16.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Sep 2021 07:16:31 -0700 (PDT) Date: Fri, 10 Sep 2021 23:16:27 +0900 From: Sergey Senozhatsky To: Hans Verkuil Cc: Tomasz Figa , Ricardo Ribalda , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Sergey Senozhatsky Subject: Re: [PATCH] v4l-compliance: re-introduce NON_COHERENT and cache hints tests Message-ID: References: <20210709092227.1051346-1-senozhatsky@chromium.org> <619afe51-4cba-95e0-69bc-bb96e1f88aae@xs4all.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (21/09/10 22:31), Sergey Senozhatsky wrote: > > Looking into it now. I ran v4l2-compliance, but not "contrib/test/test-media" > > AFAICT the problem is in v4l2-compliance patch. > > We clear request flags if queue does not support user-space cache hints: > > q->allow_cache_hints && q->memory == VB2_MEMORY_MMAP > > But for DMABUF buffers (only) we set cache hints internally in > set_buffer_cache_hints() and always skip cache sync/flush on > prepare/finish regardless of what is passed from the user-space: > > if (q->memory == VB2_MEMORY_DMABUF) { > vb->skip_cache_sync_on_finish = 1; > vb->skip_cache_sync_on_prepare = 1; > return; > } > > Technically we don't support user-space cache hints for DMABUF, so we > clear passed user-space cache hint flags. > > I think the fix should look like this (tested with "test-media vivid"): > > --- > > diff --git a/utils/v4l2-compliance/v4l2-test-buffers.cpp b/utils/v4l2-compliance/v4l2-test-buffers.cpp > index 9b87c90f..baa306f1 100644 > --- a/utils/v4l2-compliance/v4l2-test-buffers.cpp > +++ b/utils/v4l2-compliance/v4l2-test-buffers.cpp > @@ -1865,9 +1865,10 @@ static int setupDmaBuf(struct node *expbuf_node, struct node *node, > fail_on_test(!buf.g_bytesused(p)); > } > flags = buf.g_flags(); > - /* We always skip cache sync/flush for DMABUF memory type */ > - fail_on_test(!(flags & V4L2_BUF_FLAG_NO_CACHE_INVALIDATE)); > - fail_on_test(!(flags & V4L2_BUF_FLAG_NO_CACHE_CLEAN)); > + > + /* Make sure that flags are cleared */ > + fail_on_test((flags & V4L2_BUF_FLAG_NO_CACHE_INVALIDATE)); > + fail_on_test((flags & V4L2_BUF_FLAG_NO_CACHE_CLEAN)); > fail_on_test(flags & V4L2_BUF_FLAG_DONE); > fail_on_test(buf.querybuf(node, i)); > fail_on_test(buf.check(q, Queued, i)); Alternatively, we can do something like below on the kernel side instead: do nothing in v4l2 for DMABUF and preserve b->flags (if user-space has passed cache management flags). // But I think it'll be better to clear b->flags cache hints for DMABUF. To // indicate that we don't accept cache-hints for DMABUF. --- diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c index 6edf4508c636..fc8e31b7dced 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -345,6 +345,13 @@ static void set_buffer_cache_hints(struct vb2_queue *q, struct vb2_buffer *vb, struct v4l2_buffer *b) { + /* + * No user-space cache hints for DMABUF, but we preserve b->flags + * cache hints (if user-space has passed any). + */ + if (q->memory == VB2_MEMORY_DMABUF) + return; + if (!vb2_queue_allows_cache_hints(q)) { /* * Clear buffer cache flags if queue does not support user