Received: by 2002:ab2:7041:0:b0:1f4:bcc8:f211 with SMTP id x1csp20390lql; Fri, 12 Apr 2024 02:13:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWluRIxdzRcLhxUEzpFJFSL8EuGS/C4f13829XnfXQRxmPtF9Fp+ePyY9w7AAOP5efDcytm5/JxR59tJD9phnPcKTsLVCAHPsLhF3VQRw== X-Google-Smtp-Source: AGHT+IHBBM41BC2rqzyFZkLAdX/MuiAVr61IJ6l8Jo1tUEbCw7Pjp6lHdIGQqNHgRM9I1EVJjo8O X-Received: by 2002:a05:6a20:4c11:b0:1a6:fced:424f with SMTP id fm17-20020a056a204c1100b001a6fced424fmr1814190pzb.62.1712913188587; Fri, 12 Apr 2024 02:13:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712913188; cv=pass; d=google.com; s=arc-20160816; b=XkROBeFDjCb2Jj22RDvhyxcKPZTOHw8U6H1at7vj1kPwJpeZPgA9KFncLx+L9MTC6B tl62C2HeFK4g0TqVV3+vjIBt9okwcQuKPBSQokUa3N5L42wCMyRg/ppuNKSPwgz9ueS3 PRludVOunuuplocGetkqitfMT3NXcpGm+qx6oTxLaj7Nn90RKml6QdkhJUDu4KfDk6ZI sWFDBQLzXhbucvi2bQLOvTPRkQvSs6XimuWHiJZqHtvwPrBmsDqNR7rOgjJ3s+f7+a/t McpAR41emcEUr+dZYqC/IptDC6SmIaLPgjNeigtZsB3D3iPBFD+79GbQSECub2HqofKT 6W/Q== 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=3p8gfY4Rn/FyJFhjmwCdh++6pjf+9s2xV9FoSngG3XQ=; fh=biKe3ab6vu9B2YV/BY0rSGdgJ9M/b05dGcvzyA7ivrs=; b=djTkWOHauT5YARzawfHNApviBUaRbd41bMstwpxr2nY/70AGmiFw+OPcA2umpTafWi k/ZCRIdQD51kJtopSKao0yk0cFs044PKdl/FLZZrNq7MNod4edLo7NJzwPXCvkEWQ7nn yKRa+d+IlGh5MOodxj3lt0pmwyCtXZM1kWjjTAoVWmTaqv+4sy0JTOai/KbQDh62o2Hd iSCs0cNuurHUEKPa0YAShnV+zbboQvwVp+4Kdxaww3jerYcXVvRgx4nAzUVet3q5HZQl s4VpVX4Bkd8lL3qjAfX+yWdjKxa0fIyI9krjXDPzFoXP7qksm+39Eiw5Tcz9BUng9xTK wKCw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=fu3WWz+X; 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-142341-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142341-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id e9-20020a170902f10900b001e0b60f9063si2668357plb.369.2024.04.12.02.13.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 02:13:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142341-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=fu3WWz+X; 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-142341-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142341-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 0C12D2896D8 for ; Fri, 12 Apr 2024 09:09:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 274AB50A88; Fri, 12 Apr 2024 09:09:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="fu3WWz+X" Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (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 61C603EA73; Fri, 12 Apr 2024 09:09:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712912943; cv=none; b=XCYpl8p/PGuCyVtDxV5Pi5a3mPDWHX8LOJAJ9349LArwuG23QwP7w1jiw2HfUThG6p5l4DScVNKNqyHuaqxaMX5+Gx5NedRUtwd7qWBstGOhRB4fHUzmFCZSVqLSzv+nCQCtgzRoEoEgO4dOkk4F7JP/PWkW0DC1tDXU7wKUOHQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712912943; c=relaxed/simple; bh=Ee1ehBrIdPfAqkGOw5aW9V2RW6k4KcGGjtUCYR1jul4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hq4XqQfYCCGIDrMC4IeNlK8TSlZ99fAYlL6MUw0GgRzg4M7+JCKElGlnKOp/ZQK0PvN8KaKa8hiAdGy3WUym5GAKVceljj7WLZuQcH7agZk3Z2meGDngQh6/sHlVWaFMtsbktpjJFOukvwELRr/UndQ+5qCOTg307mZn5fIDd/0= 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=fu3WWz+X; arc=none smtp.client-ip=60.244.123.138 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: 4b0987d4f8ac11eeb8927bc1f75efef4-20240412 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=3p8gfY4Rn/FyJFhjmwCdh++6pjf+9s2xV9FoSngG3XQ=; b=fu3WWz+XT0DivyVb43CNK+1k32CuRuDoqen0zaC/CY+wawO0gHI7mOute6o5CVK2gk+e1BTNuzxmp8/Hwl21EYr/TZaXeQ8V2A/XMnrRI3nmk8ciFz9JKR5yo7MFMKtOoOF/AUfPgqtdqxqK9OZjRANHGvQFISoQ1FxlZjcfHIY=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.37,REQID:cdf7ae45-3280-48a2-801f-6ee7072365ee,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:6f543d0,CLOUDID:92af1986-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: 4b0987d4f8ac11eeb8927bc1f75efef4-20240412 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1617369635; Fri, 12 Apr 2024 17:08:57 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs13n2.mediatek.inc (172.21.101.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Fri, 12 Apr 2024 17:08:55 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Fri, 12 Apr 2024 17:08:54 +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 v5,01/23] v4l2: add restricted memory flags Date: Fri, 12 Apr 2024 17:08:29 +0800 Message-ID: <20240412090851.24999-2-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240412090851.24999-1-yunfei.dong@mediatek.com> References: <20240412090851.24999-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-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 2663213b76a4..b6fbbd276bf1 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -1026,6 +1026,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) @@ -1037,6 +1038,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.18.0