From patchwork Wed Dec 6 08:15:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?WXVuZmVpIERvbmcgKOiRo+S6kemjnik=?= X-Patchwork-Id: 751389 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="IKdLnIG7" Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E3C0D3; Wed, 6 Dec 2023 00:15:50 -0800 (PST) X-UUID: a6618ab6940f11eea33bb35ae8d461a2-20231206 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=Gtxt/C4CIwXGjWvyCwDlPRCsxH6BQ3m1lajwI0U2H/U=; b=IKdLnIG7QRgMwItgumiEt9xwdq5SbopCgrJ6f5g1Kl4amHuhPrhxwKeQuinsmjgLx/MCc1trvmB/uYJBWFbuCgKGDGGgwSZNLiIivCoR5k7psPnkTVW7LnNbdvl3czKNukupwytsRBTVLDPfLyCWMG9n5aSpD0rhKUc6SGILyPc=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.34, REQID:84038762-c0ff-40f4-b327-d31c9d9da937, IP:0, U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:abefa75, CLOUDID:182c59fd-4a48-46e2-b946-12f04f20af8c, B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File: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: a6618ab6940f11eea33bb35ae8d461a2-20231206 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1042332511; Wed, 06 Dec 2023 16:15:43 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Wed, 6 Dec 2023 16:15:41 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Wed, 6 Dec 2023 16:15:40 +0800 From: Yunfei Dong To: Jeffrey Kardatzke , =?utf-8?q?N=C3=ADcolas_F_=2E_?= =?utf-8?q?R_=2E_A_=2E_Prado?= , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Nathan Hebert 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_K=C3=B6nig?= , Matthias Brugger , , , , , , , Subject: [PATCH v3,01/21] v4l2: add secure memory flags Date: Wed, 6 Dec 2023 16:15:18 +0800 Message-ID: <20231206081538.17056-2-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231206081538.17056-1-yunfei.dong@mediatek.com> References: <20231206081538.17056-1-yunfei.dong@mediatek.com> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--4.791700-8.000000 X-TMASE-MatchedRID: jAP7Z+txIHYXSulpnju2H4SvKOGqLLPKK2i9pofGVStcU0dNErOD+mlF 7OhYLlctcYKRVYWgduVAw/iJrysrSm+IsUfG75P2joyKzEmtrEeQoBr+SFneJJj9R7obtcgyH5L 2GhBQtff4ei4a6fEfjpynPbWEKM6u8xjBEybW2by3HA8h5a0MOXnL427v8Q461gisw2JKo8lYua /kyrSLKzqKm/4qdbn8gDLqnrRlXrZ8nn9tnqel2MprJP8FBOIa2ntLqnPa1U32O6TmKuehrIU0+ TfNuMYBg5SfNRWImmHKWqep8B//Hg6qbFFxcFTguN8K5GvhTbfHIhLbWKGpxiA2fMrPTSd/T07L PKPPWmXzYaPZALfIbSyZdUr8fx4fMbuyvvGhtIDNwMS8lpRKBQ== X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--4.791700-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: 97FF8B845C51ADA254BD35568E7F9B4AB38BDE9BF69A393FCA1FA0275D045FFC2000:8 X-MTK: N From: Jeffrey Kardatzke Adds a V4L2 flag which indicates that a queue is using secure 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 5557d78b6f20..98eba43661c1 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -518,6 +518,9 @@ struct vb2_buf_ops { * ->finish(). * @non_coherent_mem: when set queue will attempt to allocate buffers using * non-coherent memory. + * @allow_secure_mem: when set user-space can pass the %V4L2_MEMORY_FLAG_SECURE + * flag to indicate the dma bufs are secure. + * @secure_mem: when set queue will verify that the dma bufs are secure. * @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 @@ -601,6 +604,8 @@ struct vb2_queue { unsigned int uses_requests:1; unsigned int allow_cache_hints:1; unsigned int non_coherent_mem:1; + unsigned int allow_secure_mem:1; + unsigned int secure_mem:1; struct mutex *lock; void *owner; @@ -770,7 +775,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_SECURE. * @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 68e7ac178cc2..570b11552818 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_SECURE (1 << 1) /* capabilities for struct v4l2_requestbuffers and v4l2_create_buffers */ #define V4L2_BUF_CAP_SUPPORTS_MMAP (1 << 0) @@ -1036,6 +1037,7 @@ struct v4l2_requestbuffers { #define V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF (1 << 5) #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_SECURE_MEM (1 << 8) /** * struct v4l2_plane - plane info for multi-planar buffers