Received: by 2002:ab2:7a09:0:b0:1f8:46dc:890e with SMTP id k9csp29771lqo; Wed, 15 May 2024 06:59:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX7vYTXIqjtm6O5khY/3WPleYeUmco6vBYUPANpREzgcflDkcQaS1YrjLiFbIDBHYTspQ/v+VjsqPX/Syfi8BV6eyNr/2rHyxk8+SOG5w== X-Google-Smtp-Source: AGHT+IGbE7p83gj/9muBICzqVJ8UFPSFtDdwsSLWHRODuA3Jca3umrdc+EgyGKHVxbTd3hS8VIbF X-Received: by 2002:a50:fb08:0:b0:573:5c17:f6f2 with SMTP id 4fb4d7f45d1cf-5735c17f781mr9388256a12.24.1715781548165; Wed, 15 May 2024 06:59:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715781548; cv=pass; d=google.com; s=arc-20160816; b=LBpOAzJG2GUjofD8zr86aoreSzhNBYfoSNegB0lal12XVCJAMoXVDc1TWqssAOwzGs OeefNlEMNXUWJ/7QerTfU2ZjbGoUaw5vVvJfjUELauqTYWhu7Ye3jtSOAb7s6fiKxpDz pYktc5olxpzDI/M2QFNKCf3XdoDBocHdS9mc8Ow1e7B6DpAUNDh/64JR1NDUDcyaZJ4w jWl4kAE3UbooTsMMtpmTyEE4D/oBPK47lK8DAVKvMwGYUCHI1GUbeco8IvZsNQ9Y9DAr zTqVsPC2wUsW4kCNe4ZPxSLMU0uY8MhRDEsm+ecPq/veoi8/FLShUBtk8/O2M6h13HZj OXaw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=a5POShETTjghNI8Kmc/cQ0tu2dNWyYdmB0jehdDuRtQ=; fh=oKXp7eYw+ueF/PASYm8o1QMj1RprGGi2Ykngp1NB+LU=; b=A+DK9nDktux9Hk+Xa7iVz4YBVi8oXBwD9JU11UNEJaf/iA/7KHvoRhG7jLFS/vCkYG LpOxvwdV93g/Jv7/3xP2lpoPyvUtLTKX0UcdiY9WL66/QyNVzSM77JhycO+iYzLss5++ RIlfOka8FkC0dUOYSGzqpTjb7q5ungj9VvuzTgJSlzmqq6vphoxQB10skTd8TBgug2zl 4UihW1lFTD6/8lwg8MXsbrhGev+zUbialI3aRyoNg2vZPgGzGrDxI2F6d9jX2iCT4v/Q CVCQGlYFObz9d7yPIYwC2jI6tFRQxttV0RDcsaPN3rrhRhczFz6Dqlq+uRA80R64Od7t dAiA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QXu68TXf; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-179956-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179956-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5733bec0624si7595145a12.156.2024.05.15.06.59.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 06:59:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179956-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=@kernel.org header.s=k20201202 header.b=QXu68TXf; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-179956-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179956-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 E4CEA1F23F9A for ; Wed, 15 May 2024 13:59:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 22D181411CB; Wed, 15 May 2024 13:57:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QXu68TXf" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 4136913F427; Wed, 15 May 2024 13:57:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715781475; cv=none; b=IsIhDa7+lo1LU0BkuFsgz+gmeOtLJt37bRS8BXsV9qNXREt4p0z/W4Wr0kJoqAHQ2np4nugzpWMJslAfhWfN7IAE/RxUhlhJAaXNv9pYCCgbtNjhku2zzLdB4lRFUDLPSpGve26IlwydtJ1yppNLg2NqB+hC2dSvGtTiOstpqhY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715781475; c=relaxed/simple; bh=3a1PkEj7cE+sch219RIbB9Jk0bMgUp62q1dLoyBXtNE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DogI8Qe+m21FvAnqLO+tMIdSQ+NfwRgoUS5D9uRGTZbBPpr5YrWl7T2t6mZ6bUYmo+ErKpbDu6rZvYpN3vL/yWqh9Da48pt8Euc2sHUwBKbE6WiyEL/qvuFQkJ8dijXyX8jIZSJD2o1zdy6FmmaTE+Ds0Ad4iLxGLkT18BQ58Hs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QXu68TXf; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4EF92C116B1; Wed, 15 May 2024 13:57:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715781474; bh=3a1PkEj7cE+sch219RIbB9Jk0bMgUp62q1dLoyBXtNE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=QXu68TXftiz2lZOlszefjpiO6hArafdb17Coy3vmlIKkWX1OTyUhmaxRP9Gkg92cH htkRgOtHMIewMzwPQE9UXTJz7jkSgrRdaRpNs0HD7mkSCmw/NSbr2Me1iPuizOTvpX xjJWdWNZYkbmCExVJkX80T7at917TAo29YHxraWuxwC2hZpBJgWFRWj74MZU/a8K62 QTjhcN9n27uj0cTaUj/VBMnC+dlSa1CYn1E21Pyj6lT5FL6CFXiVAOC/didMJdwlPG RBqhC1ZopZGwWC3mrWGmGpxAHYPFEWTByZ60XzEqdIDZGy3iq3Xe5j9uxQt4n+DeHT R9aKXFT8gVe5g== From: Maxime Ripard Date: Wed, 15 May 2024 15:56:59 +0200 Subject: [PATCH 4/8] dma-buf: heaps: Add ECC protection flags 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: 7bit Message-Id: <20240515-dma-buf-ecc-heap-v1-4-54cbbd049511@kernel.org> References: <20240515-dma-buf-ecc-heap-v1-0-54cbbd049511@kernel.org> In-Reply-To: <20240515-dma-buf-ecc-heap-v1-0-54cbbd049511@kernel.org> To: Rob Herring , Saravana Kannan , Sumit Semwal , Benjamin Gaignard , Brian Starkey , John Stultz , "T.J. Mercier" , =?utf-8?q?Christian_K=C3=B6nig?= Cc: Mattijs Korpershoek , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, Maxime Ripard X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2044; i=mripard@kernel.org; h=from:subject:message-id; bh=3a1PkEj7cE+sch219RIbB9Jk0bMgUp62q1dLoyBXtNE=; b=owGbwMvMwCmsHn9OcpHtvjLG02pJDGku+/2nKmw4Xr3PpCAtJ9HX6rfW47R9Dit2ez1IiU7p5 phpe8G3YyoLgzAng6yYIssTmbDTy9sXVznYr/wBM4eVCWQIAxenAEykhImxYfev3IBfD6+9YDuc 2t2+614VF/dWOcUVfXc41n2rveHQrVlV4x7Qz73kL6f+39v2hZt6GRv+mvRsZot9yu0tP9m/82P TvNeat1UCvjcpnVfI+cYVKSlxuihVdOniK7tfLn0moneHYxYA X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Some systems run with ECC enabled on the memory by default, but with some memory regions with ECC disabled to mitigate the downsides of enabling ECC (reduced performances, increased memory usage) for buffers that don't require it. Let's create some allocation flags to ask for a particular ECC setup when allocate a dma-buf through a heap. Signed-off-by: Maxime Ripard --- drivers/dma-buf/dma-heap.c | 4 ++++ include/uapi/linux/dma-heap.h | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/dma-buf/dma-heap.c b/drivers/dma-buf/dma-heap.c index 84ae708fafe7..a96c1865b627 100644 --- a/drivers/dma-buf/dma-heap.c +++ b/drivers/dma-buf/dma-heap.c @@ -106,10 +106,14 @@ static long dma_heap_ioctl_allocate(struct file *file, void *data) return -EINVAL; if (heap_allocation->heap_flags & ~DMA_HEAP_VALID_HEAP_FLAGS) return -EINVAL; + if ((heap_allocation->heap_flags & DMA_HEAP_FLAG_ECC_PROTECTED) && + (heap_allocation->heap_flags & DMA_HEAP_FLAG_ECC_UNPROTECTED)) + return -EINVAL; + fd = dma_heap_buffer_alloc(heap, heap_allocation->len, heap_allocation->fd_flags, heap_allocation->heap_flags); if (fd < 0) return fd; diff --git a/include/uapi/linux/dma-heap.h b/include/uapi/linux/dma-heap.h index 6f84fa08e074..677b6355552d 100644 --- a/include/uapi/linux/dma-heap.h +++ b/include/uapi/linux/dma-heap.h @@ -16,12 +16,13 @@ */ /* Valid FD_FLAGS are O_CLOEXEC, O_RDONLY, O_WRONLY, O_RDWR */ #define DMA_HEAP_VALID_FD_FLAGS (O_CLOEXEC | O_ACCMODE) -/* Currently no heap flags */ -#define DMA_HEAP_VALID_HEAP_FLAGS (0) +#define DMA_HEAP_FLAG_ECC_PROTECTED BIT(0) +#define DMA_HEAP_FLAG_ECC_UNPROTECTED BIT(1) +#define DMA_HEAP_VALID_HEAP_FLAGS (DMA_HEAP_FLAG_ECC_PROTECTED | DMA_HEAP_FLAG_ECC_UNPROTECTED) /** * struct dma_heap_allocation_data - metadata passed from userspace for * allocations * @len: size of the allocation -- 2.44.0