Received: by 2002:ab2:7a09:0:b0:1f8:46dc:890e with SMTP id k9csp33925lqo; Wed, 15 May 2024 07:04:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV5cvS5ZkRRl1IOgdx58rR3fzkD7Fr8MKeXrBjxk5kp8OA3K3i4mChdUztr8B0mSk0sEHxWxpvdV2Z4WxzAf2J9yvCJymNuYfiZMuSRGg== X-Google-Smtp-Source: AGHT+IE0Bn0ROv4/07JbKFMlGRWUWNRfw+0svMOTc+IsDUuiOyl5FBPZKvM5kEwNytpCdqP8Ogga X-Received: by 2002:a05:6a20:7350:b0:1af:a72e:8b7e with SMTP id adf61e73a8af0-1afde1b6f32mr19255021637.50.1715781858614; Wed, 15 May 2024 07:04:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715781858; cv=pass; d=google.com; s=arc-20160816; b=XcAYdG7yLK5C+jACzJnOO/tUbUqzeVEjtzlVF9OjKGEjKcIhxm8EdphlUDV7MzTZ8g EX7OuhWfHhMsEAnSMw9Pc5wb8LmoWcipZxy1XmABGKrAfdXECqfjrNw/9e3VQ2zjYS5D Jk1ZYin6UdByUhuxhaQZ4AekD9Mw+qT57igS106BLTX5/btdj0IcZMkXQlFIXOY/nzuH r9n6I2DybrdTHQlo17bazA5wEwDbBNK2kSXfaFCgFSU/EhBTU1twrBPkyUMBK9JX1YvX MR+2HXmbCSx4BeP6fD+DyCEAHgZkLgc9YoLvdzL2+xN5Z9QHi5XDskfdOSHNg0WivrLH 0Mfg== 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=bLj+QPqlxYH2csCHYiDMLxd2PjwY1rItLhv+ngpuzeg=; fh=oKXp7eYw+ueF/PASYm8o1QMj1RprGGi2Ykngp1NB+LU=; b=g7g4ADJ+d7LSkAe7XPUfIF/CejdFDFq9JakW9DNklud+mzu7oj6qn4CDiGIJbUhLCw A+I9/EHexh0sf9BtZoigW5Eo062O/LHZpP6k3HrbFYFVfjFzMgrxtd9qTB8pn33mexaI Y4XJNfKp03EHBU5BvMwL6+Du3nkywe0Icxl/0DHJiH8vrI8+rGof4opqJyLEYWiNoGwQ OupxKPO3jOjxoSSeFWmFN2ovkxi0Xy+sy1hVf8adbRo6F5tAjrSmwLFzGOr16dDEZG4C 97q+67mV8SRno1kZLvRddfwMgioDJhEfpdNiyaCrXfKFiuRlJoob6aDop/qnUSjvpUN9 AbIA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Oj3FlSFO; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-179954-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179954-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d2e1a72fcca58-6f4d2aef0f1si14194998b3a.221.2024.05.15.07.04.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 07:04:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179954-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Oj3FlSFO; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-179954-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179954-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 530A0B24109 for ; Wed, 15 May 2024 13:58:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A42A513FD96; Wed, 15 May 2024 13:57:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Oj3FlSFO" 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 C612813EFF3; Wed, 15 May 2024 13:57:48 +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=1715781468; cv=none; b=nThswmWa0MKM5FwI5wjLuXMev/1Wb6Qb2oqgH1TXomLpqwERateKK8U6EsVyCRTG4vVYg4V1dc0LdcLd8w5VAg3Lex83EzC+LNx0IVPSzUBGaYjaZxghw20cIP/a3aXVNoqZ06boMtpuCrkh+v7ErmxBGg/jPLItfhGZvlyVFRE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715781468; c=relaxed/simple; bh=8ZuUxwBuqIl5xv9FwD6zxHdkEr4bqeDZSbsEsg2zPmU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mygWS5UKztmktTTeJ7pwevLbNAsgE+Mm4h5qowbUB/Vh7/4hoRhnKDM++7ApaudeCRxX8KgPh3lO/+H4fyTpF4fH/dlJkOA3uWIToOFKYJU8ZkcQLlu4sx+FXGiU6ZjtXBtgkCuKEGioP3Z3mdZ1FuhR3EORiEeze2rno9pI4pw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Oj3FlSFO; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4CB9C4AF08; Wed, 15 May 2024 13:57:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715781468; bh=8ZuUxwBuqIl5xv9FwD6zxHdkEr4bqeDZSbsEsg2zPmU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Oj3FlSFOr68/qWfihvTAujUUhPEGoUh0a2EeRfwvOp8t6TcAJblJSqUhG15QQTajm X0ZypIvahxAHTF82FIRmlU2JmeCiZMwvZg+EGvVdwOy+OSOe2xcXF1JXL/koBjWJ8f uY1eH1kzAK3EKpSlqeE4zNl58tmABu/OHRqvET7KDksCSKN7RmxdJnLqrBLyDwRdHT tj9PWxBrP/AM1H0vdT+uxhTO2BFPXx2o3XWUE0K/GWe/3iVt7N8oPjgzVElc+MOGeJ 74zzL/+8OcKcEv9NJp/Th0hDHXFns5PI1R9GkALEM+tDghU+PYNfMeHNgQ21rMnH+z MvHx0X9dwRxgQ== From: Maxime Ripard Date: Wed, 15 May 2024 15:56:57 +0200 Subject: [PATCH 2/8] of: Add helper to retrieve ECC memory bits 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-2-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=1585; i=mripard@kernel.org; h=from:subject:message-id; bh=8ZuUxwBuqIl5xv9FwD6zxHdkEr4bqeDZSbsEsg2zPmU=; b=owGbwMvMwCmsHn9OcpHtvjLG02pJDGku+/3WZlme0eHdaHF23mbWzIrm86HrbRLD7LyCko8rz uJ85re0YyoLgzAng6yYIssTmbDTy9sXVznYr/wBM4eVCWQIAxenAEzkYjpjndaJwD3Xp39eISqZ bOWhaGUqfPC+tbxHZce+b2VbV6lc4Ap8mKG7L8Nf/dPlvvmn739RZmw4p9u4J+i/zY7Hpn97nvC k2mQ5mV6d/XPaqwcblXumnVxr6J4cufGVjJSY2aW6VRcUq44BAA== X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D The /memory device tree bindings allow to store the ECC detection and correction bits through the ecc-detection-bits and ecc-correction-bits properties. Our next patches rely on whether ECC is enabled, so let's add a helper to retrieve the ECC correction bits from the /memory node. Signed-off-by: Maxime Ripard --- include/linux/of.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/include/linux/of.h b/include/linux/of.h index a0bedd038a05..2fbee65a7aa9 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -1510,10 +1510,35 @@ static inline int of_get_available_child_count(const struct device_node *np) num++; return num; } +/** + * of_memory_get_ecc_correction_bits() - Returns the number of ECC correction bits + * + * Search for the number of bits in memory that can be corrected by the + * ECC algorithm. + * + * Returns: + * The number of ECC bits, 0 if there's no ECC support, a negative error + * code on failure. + */ +static inline int of_memory_get_ecc_correction_bits(void) +{ + struct device_node *mem; + u32 val = 0; + + mem = of_find_node_by_path("/memory"); + if (!mem) + return -ENODEV; + + of_property_read_u32(mem, "ecc-correction-bits", &val); + of_node_put(mem); + + return val; +} + #define _OF_DECLARE_STUB(table, name, compat, fn, fn_type) \ static const struct of_device_id __of_table_##name \ __attribute__((unused)) \ = { .compatible = compat, \ .data = (fn == (fn_type)NULL) ? fn : fn } -- 2.44.0