Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp902076lqj; Mon, 3 Jun 2024 04:41:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXgBI3ps4x/Qr44GgJ42zhbK99uOQ0YtRKmnsnlA+PGjezjiHCsH6al6QQNUJOCibxTL5rVQgN3wDW8avebP86m7aNj2ZU4n5ENUOjBEw== X-Google-Smtp-Source: AGHT+IFkISK9NHDMr649bwZvLkTCZjgQgDOfUgWn0/UTqPgMJG6f4l5ZOljuaPLpMkOvyHT2RFUq X-Received: by 2002:a17:906:258d:b0:a5c:dcd4:351b with SMTP id a640c23a62f3a-a6821982787mr608889066b.58.1717414861708; Mon, 03 Jun 2024 04:41:01 -0700 (PDT) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a68b93949edsi257176066b.112.2024.06.03.04.41.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 04:41:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199060-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@oppo.com header.s=selector1 header.b="Q/DFzWx5"; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-199060-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199060-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=oppo.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 6AF181F25D2A for ; Mon, 3 Jun 2024 11:41:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D42DB84A58; Mon, 3 Jun 2024 11:40:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=oppo.com header.i=@oppo.com header.b="Q/DFzWx5" Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2068.outbound.protection.outlook.com [40.107.255.68]) (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 B934B84D05; Mon, 3 Jun 2024 11:40:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.255.68 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717414852; cv=fail; b=B0AJdcmIwEJTKqkL5iLGxM8KqvABc9wIz9IICiN5UBvIfdWeAssEsabW3FQH6hXRiQdWC1G0QAtLdAxh2mmwrnQxWe5Y9nomWq/V/0VD8KSNq9EKe73czcxXlpWUk+2E0HL+kdIoLf6z68UfnEPl9p/seKZXKAUb/VUUK4Oh38s= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717414852; c=relaxed/simple; bh=VWQXlrWaqgeWJGNJEQGyrWGp5OBw+8/CihEgW72KAz4=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=ShqrdDxPecjpB/umzCqc9ylLLkXhwhlZIaS2b1QHyJRONaXRkvcTmTwso+pBpZu6IDIflZ1XVPi/ER2rSMMmG1ONyevZWcw5A09yDy09cPuStIBiofrb7sd6YEz8ntEXJj+o+l0+J9bDOpdfT/j9kUBkc8CkV2jd+9ntkl41SlE= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oppo.com; spf=pass smtp.mailfrom=oppo.com; dkim=pass (1024-bit key) header.d=oppo.com header.i=@oppo.com header.b=Q/DFzWx5; arc=fail smtp.client-ip=40.107.255.68 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oppo.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oppo.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ReHEXSbxPFaj32VjD0sHxhn8+d/MfQniPC1YN6ycckO/K/OEiWTb4ulgRLGx6InKHs7Df9m1CpCzrr6fwpamT6qndDKEsST5jj8M8mYQzvZlfgSrxS3nTM2h+urmwUDujOwnFs575Mx4FEtWwJIbfjITO08QFEDY/9qP99/po+ZUScJlqHQ6PvfWgnP9L8F3O/FQx8+lvo8hATcnAHmbPuE5G7tHPlGMUc63B4Y5coHTmiwA2XaFrTnMwlqNQWHflf6aTbFek+6GxaQkqbU+TF9U9wx9vTp5YNxIJ6q9GVrodZwUOjaO79/ABt+j+WAFj6ecRAMI2o84N850CF5Akg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yoIM7lC3W2CmzRv5ldHqXT4NLmee7//rWVqgOuxoapU=; b=Jn15r9SryYqAxsdKhMpvALdBExiIthl5c33WVxb1sPy1iESS04xLXbtZO1KWXgk4XDlffdMY28jomNx/Lv4f9ji468zGQl6yMAiOM+46mTD8kVEz+nbcGY+82t4cD02EEJtj3ZyzFuNpTbcVKHz9sVYK5x3IbTsecarccnygVTCgnBl55tyWbSWdrl5iL+iLQzk62oMbKsFPvzD2Ulwsekdhm71PcLvnMnISW1gvIwnBLLlSOerM0lfwLOybLezJpWKewrFmqfxfvr9jfrXYAHm5mXFapY/Mxphpt0EhWj0jO7PJhteYfCgUilbcJrrXgboTyJ2ru/jclq9OS/f7QQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 58.252.5.68) smtp.rcpttodomain=linaro.org smtp.mailfrom=oppo.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=oppo.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oppo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yoIM7lC3W2CmzRv5ldHqXT4NLmee7//rWVqgOuxoapU=; b=Q/DFzWx5bafjt7/E5pgCq7hcJYc0Dy/FvJe2pjgmDvQzqPkMyJ9Pm3Il9K3RNuHejcR4bUsfO0VyqKT54T6aUGEMWcQ6cq5i4WTTnlV2yMuYz0irHWlkor3g/7kGDTfcf8Fgw7dZiFJhB/LiwvzLCDq8mydg7WvgvFv6musvTgs= Received: from SG2PR01CA0134.apcprd01.prod.exchangelabs.com (2603:1096:4:8f::14) by TY0PR02MB6803.apcprd02.prod.outlook.com (2603:1096:405:b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.23; Mon, 3 Jun 2024 11:40:47 +0000 Received: from SG2PEPF000B66D0.apcprd03.prod.outlook.com (2603:1096:4:8f:cafe::60) by SG2PR01CA0134.outlook.office365.com (2603:1096:4:8f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.29 via Frontend Transport; Mon, 3 Jun 2024 11:40:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 58.252.5.68) smtp.mailfrom=oppo.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=oppo.com; Received-SPF: Pass (protection.outlook.com: domain of oppo.com designates 58.252.5.68 as permitted sender) receiver=protection.outlook.com; client-ip=58.252.5.68; helo=mail.oppo.com; pr=C Received: from mail.oppo.com (58.252.5.68) by SG2PEPF000B66D0.mail.protection.outlook.com (10.167.240.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.15 via Frontend Transport; Mon, 3 Jun 2024 11:40:46 +0000 Received: from PH80250894.adc.com (172.16.40.118) by mailappw31.adc.com (172.16.56.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 3 Jun 2024 19:40:46 +0800 From: To: Sumit Semwal , Benjamin Gaignard , Brian Starkey , John Stultz , "T.J. Mercier" , =?UTF-8?q?Christian=20K=C3=B6nig?= CC: <21cnbao@gmail.com>, Hailong.Liu , , , , Subject: [RFC PATCH v1] dma-buf: heaps: move the verification of heap_flags to the corresponding heap Date: Mon, 3 Jun 2024 19:40:05 +0800 Message-ID: <20240603114008.16235-1-hailong.liu@oppo.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: mailappw31.adc.com (172.16.56.198) To mailappw31.adc.com (172.16.56.198) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SG2PEPF000B66D0:EE_|TY0PR02MB6803:EE_ X-MS-Office365-Filtering-Correlation-Id: 586d08e1-1f6f-4a70-f977-08dc83c2029d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|7416005|376005|1800799015|36860700004|82310400017; X-Microsoft-Antispam-Message-Info: =?utf-8?B?QWdWdVYrMU5iTUswc2RHbmJxd2pWR3ZlUGdrZWZMMHFuVVBudUNCSWlyWUt0?= =?utf-8?B?bXk2QXdseFFLclZGMnlVZ3BQM1kxM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Q?7zoKTe01c9Hr9?= X-Forefront-Antispam-Report: CIP:58.252.5.68;CTRY:CN;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.oppo.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(7416005)(376005)(1800799015)(36860700004)(82310400017);DIR:OUT;SFP:1101; X-OriginatorOrg: oppo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2024 11:40:46.9475 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 586d08e1-1f6f-4a70-f977-08dc83c2029d X-MS-Exchange-CrossTenant-Id: f1905eb1-c353-41c5-9516-62b4a54b5ee6 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f1905eb1-c353-41c5-9516-62b4a54b5ee6;Ip=[58.252.5.68];Helo=[mail.oppo.com] X-MS-Exchange-CrossTenant-AuthSource: SG2PEPF000B66D0.apcprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY0PR02MB6803 From: "Hailong.Liu" This help module use heap_flags to determine the type of dma-buf, so that some mechanisms can be used to speed up allocation, such as memory_pool, to optimize the allocation time of dma-buf. Signed-off-by: Hailong.Liu --- drivers/dma-buf/dma-heap.c | 3 --- drivers/dma-buf/heaps/cma_heap.c | 3 +++ drivers/dma-buf/heaps/system_heap.c | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/dma-buf/dma-heap.c b/drivers/dma-buf/dma-heap.c index 84ae708fafe7..6c78ee6c7a58 100644 --- a/drivers/dma-buf/dma-heap.c +++ b/drivers/dma-buf/dma-heap.c @@ -105,9 +105,6 @@ static long dma_heap_ioctl_allocate(struct file *file, void *data) if (heap_allocation->fd_flags & ~DMA_HEAP_VALID_FD_FLAGS) return -EINVAL; - if (heap_allocation->heap_flags & ~DMA_HEAP_VALID_HEAP_FLAGS) - return -EINVAL; - fd = dma_heap_buffer_alloc(heap, heap_allocation->len, heap_allocation->fd_flags, heap_allocation->heap_flags); diff --git a/drivers/dma-buf/heaps/cma_heap.c b/drivers/dma-buf/heaps/cma_heap.c index 4a63567e93ba..ae4fa974372b 100644 --- a/drivers/dma-buf/heaps/cma_heap.c +++ b/drivers/dma-buf/heaps/cma_heap.c @@ -288,6 +288,9 @@ static struct dma_buf *cma_heap_allocate(struct dma_heap *heap, int ret = -ENOMEM; pgoff_t pg; + if (heap_flags & ~DMA_HEAP_VALID_HEAP_FLAGS) + return ERR_PTR(-EINVAL); + buffer = kzalloc(sizeof(*buffer), GFP_KERNEL); if (!buffer) return ERR_PTR(-ENOMEM); diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c index 9076d47ed2ef..80858719a819 100644 --- a/drivers/dma-buf/heaps/system_heap.c +++ b/drivers/dma-buf/heaps/system_heap.c @@ -347,6 +347,9 @@ static struct dma_buf *system_heap_allocate(struct dma_heap *heap, struct page *page, *tmp_page; int i, ret = -ENOMEM; + if (heap_flags & ~DMA_HEAP_VALID_HEAP_FLAGS) + return ERR_PTR(-EINVAL); + buffer = kzalloc(sizeof(*buffer), GFP_KERNEL); if (!buffer) return ERR_PTR(-ENOMEM); --- In fact, there are many differences between the main Linux code and Android code, I’m not sure if it’s appropriate to submit here. -- 2.34.1