Received: by 2002:ab2:7a09:0:b0:1f8:46dc:890e with SMTP id k9csp30059lqo; Wed, 15 May 2024 06:59:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXf6IGBKMUnw6knGx4Y2rG8X+eAdVxQ37ErxsJQu3BWfQjLa/zoAvN3b3ozoJfudUqH2fUoO1t5roqbp4oXCs/8718i3xGLQX6wllleAA== X-Google-Smtp-Source: AGHT+IGeJIIGZ1EU1bWoWcUBSCsiK3NkQ3gL9lqmKC4RynPIt67FsRAT+mSB04z8WQAPRq/lZzTy X-Received: by 2002:a25:b984:0:b0:de5:5702:614f with SMTP id 3f1490d57ef6-dee4f31a4a1mr19122931276.11.1715781583650; Wed, 15 May 2024 06:59:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715781583; cv=pass; d=google.com; s=arc-20160816; b=TUHWexW3KSs/U5u/deaQYe39mbb1fs6mIhyrtdsfjDR7V630g0C6Vf3oy2EMspYDZJ A8mAhR2sEPvXYqwzEMzzvfFDZlORR03hcL8kZqUk0Q1zptEu60YkhJgscfCWqnHxjjHI VS8RPAjPeRYvIwqOS7oxUA6s1xCWrnCMh7s1K8Go7zsy2vibZBxFMIMJ6e98T3YX11Hl BctA6fL8NutxM8KHoNE1745WNHnluM2FE9niFjYcLZJW3EhpJ7+pknZuTuVuMdQ3w+iu l4olG7zR4h0uEcTnSZaeP/lPsXL3fyTwa/T4jmnUhj40xKBDRE8lYZ/8rH79UTHfV6LZ qfyA== 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=RiEVCgLzVdBF6UD6MBl9jzZdvQXA/XL42nMmPU53Dqs=; fh=oKXp7eYw+ueF/PASYm8o1QMj1RprGGi2Ykngp1NB+LU=; b=SUIkXRZRi575nuRYlz315nCYSwEDUgXI5SRnjh08HTxE2pYDtPGRqELMjYEL5zkejB 18O8eascjrZZjdBM8kTFDq2DyKocWH8DFq3ecmthcdGUILEEay/Can3YEA5KUpDmpkd6 4+Cve4aEsQFo3FY0aYqw5R2fwqYmUnhrYl1/M1NqxfbqzTSOtMPgRkhy/zQpWXSxVHQ+ CvTmCxtyaq4sY5pR07hsVg4Zbrs30P1B5QZO07z77XbH7XDQSyOc+tu82SQQX0oxL32r N4tXAgEzJlCFFSScZnHpKXx/3VuYBI2tHTR73HlJ5EIAUFH2Qf5pzh7/iwkHnTgkb3rm O9kA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nIEWiQt3; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-179958-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179958-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6a15f2b6c48si140250446d6.375.2024.05.15.06.59.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 06:59:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179958-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nIEWiQt3; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-179958-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179958-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 5CF141C21E78 for ; Wed, 15 May 2024 13:59:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 006EC1420A6; Wed, 15 May 2024 13:58:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nIEWiQt3" 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 22F9514199C; Wed, 15 May 2024 13:58:00 +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=1715781481; cv=none; b=Be3vBx0MxyDuTbuhcXSE1EdeeVeVdl5nXT33eHM9LojUsGjIb37tjae8aoEXCiveAml+xZtNlVSlqa+XG93ZZBfWQrcdiaSSfTLFo7VO7+yycILIeN5/bzqSQkuxeAb8/P6OZkxm116aszkLtxMQ65szDBDz1CXrV6DYv1w7LL0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715781481; c=relaxed/simple; bh=5mlKKVq2eJW/2EfLe5DfEKj2I4ZhUMzP6qbNsK6waI0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IN5smj/uWZQ2hxTw2bW65Av2jhgka3+gcCY70ZNeAbcmrj4aGE7CKiuAvcAVrE4qkIZzgk4ot7U3tYv3IHJvfXrPO63uBNGPir66Pgwk7Yj4smG3LjO7jWB146oMmo1+hUi9QZRi45a+AF7zoDQxISRyHdam9O1iK6IADaViIOM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nIEWiQt3; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40576C32786; Wed, 15 May 2024 13:58:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715781480; bh=5mlKKVq2eJW/2EfLe5DfEKj2I4ZhUMzP6qbNsK6waI0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=nIEWiQt3XuLSsZQZbWwRK/SZdLBw0yS/Z0FGjHBgaacZPjdEhuvlesyZ8P2aS0pKQ srv93C5wQVlqvWYipTMZJtZkgbHq/VwWSyr800bzc1x5redx59NQJdYgwBXAAOXVp3 bd/xYluu06uM4adros5GaK5yunJRLnzDWy3zsrWOlhAz4ooJ7GaW7Refb43pAaAke+ pD4dZONJjf5kqS7QGfLgjzNkk8J9bmYLNCnLz4HFQBSobuX9Ph5jn4qfMdiIkcX4Fa sMtVnTiOpr2gkKTD8v9lNzqDJXZ5ixtZSVg6BTB/p1gmSmVvl0HWAyEOChq5jbIPfh dJB3NWSekMMSg== From: Maxime Ripard Date: Wed, 15 May 2024 15:57:01 +0200 Subject: [PATCH 6/8] dma-buf: heaps: system: Handle ECC 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-6-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=2333; i=mripard@kernel.org; h=from:subject:message-id; bh=5mlKKVq2eJW/2EfLe5DfEKj2I4ZhUMzP6qbNsK6waI0=; b=owGbwMvMwCmsHn9OcpHtvjLG02pJDGku+wMqyhNdctYvMNP72vKxoNKqpU9Xykhq7o8rXG6Tn j5n3OvTMZWFQZiTQVZMkeWJTNjp5e2LqxzsV/6AmcPKBDKEgYtTACai9oKxviBz/06PH5mvm05b 6tktPvglcFHO/COB24oK7X9dO274mbmNbaropF3il/T3vueOYvK4zlhnOz+6QcGIT+jg7wdWG/p ro9hjbR7cPlj0R+6uyrtsn7LCnum7/dcYenOmb/x/NPNHRxkA X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Now that we have introduced ECC-related flags for the dma-heaps buffer allocations, let's honour these flags depending on the memory setup. Signed-off-by: Maxime Ripard --- drivers/dma-buf/heaps/system_heap.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c index 8b5e6344eea4..dd7c8b6f9cf6 100644 --- a/drivers/dma-buf/heaps/system_heap.c +++ b/drivers/dma-buf/heaps/system_heap.c @@ -18,13 +18,15 @@ #include #include #include #include #include +#include struct system_heap { struct dma_heap *heap; + bool ecc_enabled; }; struct system_heap_buffer { struct dma_heap *heap; struct list_head attachments; @@ -336,10 +338,11 @@ static struct page *alloc_largest_available(unsigned long size, static struct dma_buf *system_heap_allocate(struct dma_heap *heap, unsigned long len, unsigned long fd_flags, unsigned long heap_flags) { + struct system_heap *sys_heap = dma_heap_get_drvdata(heap); struct system_heap_buffer *buffer; DEFINE_DMA_BUF_EXPORT_INFO(exp_info); unsigned long size_remaining = len; unsigned int max_order = orders[0]; struct dma_buf *dmabuf; @@ -347,10 +350,16 @@ static struct dma_buf *system_heap_allocate(struct dma_heap *heap, struct scatterlist *sg; struct list_head pages; struct page *page, *tmp_page; int i, ret = -ENOMEM; + if (!sys_heap->ecc_enabled && (heap_flags & DMA_HEAP_FLAG_ECC_PROTECTED)) + return ERR_PTR(-EINVAL); + + if (sys_heap->ecc_enabled && (heap_flags & DMA_HEAP_FLAG_ECC_UNPROTECTED)) + return ERR_PTR(-EINVAL); + buffer = kzalloc(sizeof(*buffer), GFP_KERNEL); if (!buffer) return ERR_PTR(-ENOMEM); INIT_LIST_HEAD(&buffer->attachments); @@ -430,10 +439,13 @@ static int system_heap_create(void) sys_heap = kzalloc(sizeof(*sys_heap), GFP_KERNEL); if (!sys_heap) return -ENOMEM; + if (of_memory_get_ecc_correction_bits() > 0) + sys_heap->ecc_enabled = true; + exp_info.name = "system"; exp_info.ops = &system_heap_ops; exp_info.priv = sys_heap; sys_heap->heap = dma_heap_add(&exp_info); -- 2.44.0