Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp245366lqo; Thu, 16 May 2024 05:21:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXoQ6ElwESJ+mDlLLt8rj7LHEfJFh/7FirkJVi+832bLsOosbMVlB++XFZIW3IPpPv0XR4JzF20HkPutE8KOSZhmEM8CVAO/FOC+06X/w== X-Google-Smtp-Source: AGHT+IFSp89eWKF94ASEO6HUtWAHtnqJnFynLNLpAkJw9bWgXnk88xfUKsNjIvo5QYGLZS6zAI5Z X-Received: by 2002:a05:6358:8aa:b0:183:f636:8a46 with SMTP id e5c5f4694b2df-193bd0078b5mr1730088455d.27.1715862114403; Thu, 16 May 2024 05:21:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715862114; cv=pass; d=google.com; s=arc-20160816; b=SSfzF4I+5NznKbX3A4wYhuLM9YOI1Qb+5G+SEAP6XPjqKX4Bne2xxfRX9Z+3ti9des vy31I5taBCIbXMGZe9R++if6gfDY/02lb/dGB5st5inXGRnLpjaAjZXCb6blP1WmilyX pEXNI9pP7ubcLkZawEH3LF7JAXC4kXJ2tm9hYUJgz0B23hsPZdvY+z/RYyQXBaV6+YjK 7TYCFx9z0EduTJA2BYmY7h0LQHPZeGiJDqCpDGSMmfjEH96ZX/R2upgzHylKkYHK7EcV nsc/YTATizW38WgwknSLQLpUDAy+qKPIaM85a42my9NaSculJyH8p47aplyiWIzdY577 /JXA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=JcgzcwjR79GO/B9Bt02zMcJhSYP+1rHgGT3MDO93Xbk=; fh=+3keNzaSOvsaq+BXFM2IqKmKMiZV6QsxTCb//k4Cpek=; b=y+SOTEXRCKYqK+ASpj6Uj5uLJhAOB0IOz3mY3MXbUUXT2uZegz5Psue21xCkPUdgYi uesO2+QGMIuFfK2IeS8KHtWIIV8OC29J5PKvolJ280XP/vsih4LUL7+P7O/pfIV47z9i Nup+KiUQQ0wo7Guf009tZmISoAJ4lSS6ZY9Yhf57qMTC7sbbS7pnLLsr1uoGema8Bz2f Yh1CWD+TkG1JWTt9EkmCpd2rgoBAk3GG/jWQGo1k3qdUi4iJNSw3+Q8Tr5n7a3K6ZniH dXNhNweLH/KpXPqGTOovSxz92FCCLj1tV1UqP8XPfKH7Zfagn+0O48ImNo6qNz+xFMR/ Engg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=cZ2QUts7; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-kernel+bounces-180994-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180994-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-657139e50cbsi2440016a12.779.2024.05.16.05.21.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 05:21:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-180994-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=cZ2QUts7; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-kernel+bounces-180994-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180994-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id DD1EE28548C for ; Thu, 16 May 2024 12:21:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5F456145FE5; Thu, 16 May 2024 12:21:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="cZ2QUts7" Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E4B614659E; Thu, 16 May 2024 12:21:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.61.82.184 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715862084; cv=none; b=oQteQGwB62MxwUE+yvrdneoTMDOYINqYDZ92g5QJAxO0JiZXutMc4vW0Ja5MS1Ci+XSRrNEjTaR/Czi2lUPj+9k/yHXtforhsIQF6vpY9sBndVN3FlM+J5MANSGOwJIhiKJZHLTcKVdGMWtbI5NBROEF3u6nEktQwI7aL4b+xZ0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715862084; c=relaxed/simple; bh=m3U8euoZMt4H9r5oczjhjVfeIdGb7f2UKfEwuwWQZMs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qalllbBw1fI8hp5BTgJjG4CnJdOmv999Ow3FiCK3m4G/kIZOYwRgwd9QVy/xiGFjLi56dd/ui+nAt4Ahdh7NLUZL5zMn3rMLGPgOVJOEphBkPBWaqXiOX6Za7cg0dg5Xb2de8qdOXC/VzRw9T8oNn/sNW1+f3gF5QT8C71xttag= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=cZ2QUts7; arc=none smtp.client-ip=210.61.82.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com X-UUID: c7db5e62137e11ef8065b7b53f7091ad-20240516 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=JcgzcwjR79GO/B9Bt02zMcJhSYP+1rHgGT3MDO93Xbk=; b=cZ2QUts7WTVlpVT+/scVmlr6rGBAuXvitjPqDBEd5Z4Qty8sQ8vSP9+C6WjJ4aP/0UPn6LXJe250ZVpZPSVEIOR15bc5C72gyw1W0tCm3tJIscsozSUldK0w+TtPx3b5FNuQG/6b36VnvbEmnFR807N+UDwG7m7FJvDH2a45COY=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.38,REQID:e7a3ad8b-8210-45c8-bf8b-2e2a91c0678b,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:82c5f88,CLOUDID:4f537087-8d4f-477b-89d2-1e3bdbef96d1,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1, SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: c7db5e62137e11ef8065b7b53f7091ad-20240516 Received: from mtkmbs14n2.mediatek.inc [(172.21.101.76)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 2066720893; Thu, 16 May 2024 20:21:11 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by MTKMBS14N1.mediatek.inc (172.21.101.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Thu, 16 May 2024 20:21:09 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Thu, 16 May 2024 20:21:07 +0800 From: Yunfei Dong To: Jeffrey Kardatzke , =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , Nathan Hebert , "Nicolas Dufresne" , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Sebastian Fricke , Tomasz Figa , "Mauro Carvalho Chehab" , Marek Szyprowski CC: Chen-Yu Tsai , Yong Wu , "Hsin-Yi Wang" , Fritz Koenig , "Daniel Vetter" , Steve Cho , Yunfei Dong , Sumit Semwal , "Brian Starkey" , John Stultz , "T . J . Mercier" , =?UTF-8?q?Christian=20K=C3=B6nig?= , Matthias Brugger , , , , , , Subject: [PATCH v6,01/24] v4l2: add restricted memory flags Date: Thu, 16 May 2024 20:20:39 +0800 Message-ID: <20240516122102.16379-2-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240516122102.16379-1-yunfei.dong@mediatek.com> References: <20240516122102.16379-1-yunfei.dong@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--4.149800-8.000000 X-TMASE-MatchedRID: 5AYjULL74rYxaBEU4bKrV4SvKOGqLLPKK2i9pofGVStcU0dNErOD+mlF 7OhYLlctcYKRVYWgduVAw/iJrysrSm+IsUfG75P2joyKzEmtrEeQoBr+SFneJJj9R7obtcgyH5L 2GhBQtff4ei4a6fEfjpynPbWEKM6u8xjBEybW2by3HA8h5a0MOXnL427v8Q461gisw2JKo8lzN8 /snsNYn/j1N4/6HNKlsGRzEHTW2nEfE8yM4pjsDwtuKBGekqUpOlxBO2IcOBaDB3ZqEXAYAIp/8 8s6zH6CLMa1wLyvYEOVsCHg6a9VM9hNU8cP4jYh/G47AcAybTmwM6AJeCWlbm72iaFWNy7GB1UY UHkmE/jiw6uxviJP8r9tsSiUciBlQ5zsaM5qada/lr1yYih0SylGctXaTCsu X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--4.149800-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: 00C8DA871F738AAD29C7BF1F0BB062BED72FEA1C5C526C39E9A7696C95C2C6492000:8 X-MTK: N From: Jeffrey Kardatzke Adds a V4L2 flag which indicates that a queue is using restricted dmabufs and the corresponding capability flag. Signed-off-by: Jeffrey Kardatzke Signed-off-by: Yunfei Dong --- include/media/videobuf2-core.h | 8 +++++++- include/uapi/linux/videodev2.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index 955237ac503d..afd497e93a37 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -517,6 +517,9 @@ struct vb2_buf_ops { * ->finish(). * @non_coherent_mem: when set queue will attempt to allocate buffers using * non-coherent memory. + * @allow_restricted_mem: when set user-space can pass the %V4L2_MEMORY_FLAG_RESTRICTED + * flag to indicate the dma bufs are restricted. + * @restricted_mem: when set queue will verify that the dma bufs are restricted. * @lock: pointer to a mutex that protects the &struct vb2_queue. The * driver can set this to a mutex to let the v4l2 core serialize * the queuing ioctls. If the driver wants to handle locking @@ -621,6 +624,8 @@ struct vb2_queue { unsigned int uses_requests:1; unsigned int allow_cache_hints:1; unsigned int non_coherent_mem:1; + unsigned int allow_restricted_mem:1; + unsigned int restricted_mem:1; struct mutex *lock; void *owner; @@ -792,7 +797,8 @@ void vb2_core_querybuf(struct vb2_queue *q, struct vb2_buffer *vb, void *pb); * @q: pointer to &struct vb2_queue with videobuf2 queue. * @memory: memory type, as defined by &enum vb2_memory. * @flags: auxiliary queue/buffer management flags. Currently, the only - * used flag is %V4L2_MEMORY_FLAG_NON_COHERENT. + * used flags are %V4L2_MEMORY_FLAG_NON_COHERENT and + * %V4L2_MEMORY_FLAG_RESTRICTED. * @count: requested buffer count. * * Videobuf2 core helper to implement VIDIOC_REQBUF() operation. It is called diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index fe6b67e83751..89eb1a3c6555 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -1043,6 +1043,7 @@ struct v4l2_requestbuffers { }; #define V4L2_MEMORY_FLAG_NON_COHERENT (1 << 0) +#define V4L2_MEMORY_FLAG_RESTRICTED (1 << 1) /* capabilities for struct v4l2_requestbuffers and v4l2_create_buffers */ #define V4L2_BUF_CAP_SUPPORTS_MMAP (1 << 0) @@ -1054,6 +1055,7 @@ struct v4l2_requestbuffers { #define V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS (1 << 6) #define V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS (1 << 7) #define V4L2_BUF_CAP_SUPPORTS_REMOVE_BUFS (1 << 8) +#define V4L2_BUF_CAP_SUPPORTS_RESTRICTED_MEM (1 << 9) /** * struct v4l2_plane - plane info for multi-planar buffers -- 2.25.1