From patchwork Fri Jan 26 23:53:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oreoluwa Babatunde X-Patchwork-Id: 1891697 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=quicinc.com header.i=@quicinc.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=Y0JDkIMt; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45d1:ec00::1; helo=ny.mirrors.kernel.org; envelope-from=devicetree+bounces-35682-incoming-dt=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [IPv6:2604:1380:45d1:ec00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TMF3X1hRPz23fJ for ; Sat, 27 Jan 2024 10:56:56 +1100 (AEDT) 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 641081C27E04 for ; Fri, 26 Jan 2024 23:56:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EAACC5FDCC; Fri, 26 Jan 2024 23:55:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="Y0JDkIMt" X-Original-To: devicetree@vger.kernel.org Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (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 B7F255914E; Fri, 26 Jan 2024 23:55:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706313359; cv=none; b=JFYqb7RLVK5Oi3ul6bxC9EhrNKLs1s87REgyWvweT2EE48w9FwLb6OMTZmz+eBsxp9es/S2HsMWz4gOULfFlhyn12YTaa0KyR6gvLBWvYTGLu6G/aOEXr4LTcOqMGw7IDB6+d/08kd8qyiRlym47Ar45jBxYkOEFhrQhR61yJhU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706313359; c=relaxed/simple; bh=+dLXzKA3GHsTNHgH7evQv80RkHciu+n+ZaSAz/AR0/c=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EJQAvosZJ6IMTFHIvlBuuQPmLXDZOAphYrhQsj2Oe2+ldQtDkgIP9I1Iu4HNpr1vbh4d2oDaXQQ8huYXvCT0Ym1NEBv/GWYbepGTXLYUpC6Nqn51pfiYh7U5FEoEnrHrZA7Mn/doH9mLcnOIW8b9k2Zw9aFwtBgKIQ1s8iJLI2U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=Y0JDkIMt; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40QNf8t2022118; Fri, 26 Jan 2024 23:55:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=qcppdkim1; bh=yHkSFlkLJD2JCjneLpD2 tGeP0zrZRJG5TSxIZCtLSpU=; b=Y0JDkIMtaYC79/V7DC96ZtZEioCLG+Pt7de/ JXSIEQHYMBBRwrL8DmsZZEIIi+6Rtwbl+fELpq5ZB+DAtfpJRvTCRdVp5X89UiSe KpCF6+0Efad0OXMdXtKuHwy2Zd1kZN29w/O1lEdAC4VtjMHX17UTedy48b7w/pac 5EzAuF2Bi43P9lxLhbI4RH5R0F4gfr8LbV/YM54AoXuLWQZvjzWPMpr8G7rDiICm lYZGPcDJYPWar/PI/2owSJuQs4HHXEAbowfi69L4FnoIGBWO5pySeBFcRKkohQIB qtwRfjzSCTEELSvZ9iIX8adw5Os01Y06QF1XoQxVwN6PSdMAeg== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vv4nrad0m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 26 Jan 2024 23:55:02 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 40QNt1JU009985 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 26 Jan 2024 23:55:01 GMT Received: from hu-obabatun-lv.qualcomm.com (10.49.16.6) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Fri, 26 Jan 2024 15:54:57 -0800 From: Oreoluwa Babatunde To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , Oreoluwa Babatunde Subject: [PATCH 01/46] of: reserved_mem: Change the order that reserved_mem regions are stored Date: Fri, 26 Jan 2024 15:53:40 -0800 Message-ID: <20240126235425.12233-2-quic_obabatun@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240126235425.12233-1-quic_obabatun@quicinc.com> References: <20240126235425.12233-1-quic_obabatun@quicinc.com> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: Dj5TYbGUioxz3V2ly4mHhjQfPVNWhSRr X-Proofpoint-GUID: Dj5TYbGUioxz3V2ly4mHhjQfPVNWhSRr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-25_14,2024-01-25_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 bulkscore=0 clxscore=1015 priorityscore=1501 malwarescore=0 phishscore=0 impostorscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401190000 definitions=main-2401260176 Some architectures such as arm64 require the page tables to be setup before memblock allocated memory is writable. Therefore, the dynamic allocation of the reserved_mem array will need to be done after the page tables have been setup on these architectures. In most cases this will be after paging_init(). Reserved memory regions can be divided into 2 groups. i) Statically-placed reserved memory regions i.e. regions defined in the DT using the @reg property. ii) Dynamically-placed reserved memory regions. i.e. regions specified in the DT using the @alloc_ranges and @size properties. It is possible to call memblock_reserve() and memblock_mark_nomap() on the statically-placed reserved memory regions and not need to save them to the reserved_mem array until memory is allocated for it using memblock, which will be after the page tables have been setup. For the dynamically-placed reserved memory regions, it is not possible to wait to store its information because the starting address is allocated only at run time, and hence they need to be stored somewhere after they are allocated. Waiting until after the page tables have been setup to allocate memory for the dynamically-placed regions is also not an option because the allocations will come from memory that have already been added to the page tables, which is not good for memory that is supposed to be reserved and/or marked as nomap. Therefore, the processing of the reserved memory regions is split up into two stages, of which the first stage is carried out by early_init_fdt_scan_reserved_mem() and the second is carried out by fdt_init_reserved_mem(). The early_init_fdt_scan_reserved_mem(), which is called before the page tables are setup is used to: 1. Call memblock_reserve() and memblock_mark_nomap() on all the statically-placed reserved memory regions as needed. 2. Allocate memory from memblock for the dynamically-placed reserved memory regions and store them in the static array for reserved_mem. memblock_reserve() and memblock_mark_nomap() are also called as needed on all the memory allocated for the dynamically-placed regions. fdt_init_reserved_mem() is now used to carry out the following: 1. Add the information for the statically-placed reserved memory into reserved_mem array. 2. Run the region specific init functions for each of the reserve memory regions saved in the reserved_mem array. Since fdt_init_reserved_mem() is called from within early_init_fdt_scan_reserved_mem(), subsequent patches will make changes to separate both functions and call fdt_init_reserved_mem() after the page tables have been setup were needed. Signed-off-by: Oreoluwa Babatunde --- drivers/of/fdt.c | 78 +++++++++++++++++++++++++++++---- drivers/of/of_private.h | 2 +- drivers/of/of_reserved_mem.c | 54 ++++++++++------------- include/linux/of_fdt.h | 1 + include/linux/of_reserved_mem.h | 9 ++++ 5 files changed, 104 insertions(+), 40 deletions(-) diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index bf502ba8da95..d02884ec0b6b 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -504,7 +504,6 @@ static int __init __reserved_mem_reserve_reg(unsigned long node, phys_addr_t base, size; int len; const __be32 *prop; - int first = 1; bool nomap; prop = of_get_flat_dt_prop(node, "reg", &len); @@ -532,10 +531,6 @@ static int __init __reserved_mem_reserve_reg(unsigned long node, uname, &base, (unsigned long)(size / SZ_1M)); len -= t_len; - if (first) { - fdt_reserved_mem_save_node(node, uname, base, size); - first = 0; - } } return 0; } @@ -564,11 +559,62 @@ static int __init __reserved_mem_check_root(unsigned long node) } /* - * fdt_scan_reserved_mem() - scan a single FDT node for reserved memory + * Save the reserved_mem reg nodes in the reserved_mem array + */ +void __init fdt_scan_reserved_mem_reg_nodes(void) + +{ + int t_len = (dt_root_addr_cells + dt_root_size_cells) * sizeof(__be32); + const void *fdt = initial_boot_params; + phys_addr_t base, size; + const __be32 *prop; + int node, child; + int len; + + node = fdt_path_offset(fdt, "/reserved-memory"); + if (node < 0) { + pr_err("Reserved memory: Did not find reserved-memory node\n"); + return; + } + + if (__reserved_mem_check_root(node) != 0) { + pr_err("Reserved memory: unsupported node format, ignoring\n"); + return; + } + + fdt_for_each_subnode(child, fdt, node) { + const char *uname; + + prop = of_get_flat_dt_prop(child, "reg", &len); + if (!prop) + continue; + + if (!of_fdt_device_is_available(fdt, child)) + continue; + + uname = fdt_get_name(fdt, child, NULL); + if (len && len % t_len != 0) { + pr_err("Reserved memory: invalid reg property in '%s', skipping node.\n", + uname); + continue; + } + + base = dt_mem_next_cell(dt_root_addr_cells, &prop); + size = dt_mem_next_cell(dt_root_size_cells, &prop); + + if (size) + fdt_reserved_mem_save_node(child, uname, base, size); + } +} + +/* + * fdt_scan_reserved_mem() - scan a single FDT node for reserved memory. */ static int __init fdt_scan_reserved_mem(void) { int node, child; + int dynamic_nodes_cnt = 0; + int dynamic_nodes[MAX_RESERVED_REGIONS]; const void *fdt = initial_boot_params; node = fdt_path_offset(fdt, "/reserved-memory"); @@ -590,8 +636,24 @@ static int __init fdt_scan_reserved_mem(void) uname = fdt_get_name(fdt, child, NULL); err = __reserved_mem_reserve_reg(child, uname); - if (err == -ENOENT && of_get_flat_dt_prop(child, "size", NULL)) - fdt_reserved_mem_save_node(child, uname, 0, 0); + + /* Delay allocation of the dynamically-placed regions + * until after all other statically-placed regions have + * been reserved or marked as nomap + */ + if (err == -ENOENT && of_get_flat_dt_prop(child, "size", NULL)) { + dynamic_nodes[dynamic_nodes_cnt] = child; + dynamic_nodes_cnt++; + } + } + + for (int i = 0; i < dynamic_nodes_cnt; i++) { + const char *uname; + + child = dynamic_nodes[i]; + uname = fdt_get_name(fdt, child, NULL); + + __reserved_mem_alloc_size(child, uname); } return 0; } diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h index f38397c7b582..542e37a37a24 100644 --- a/drivers/of/of_private.h +++ b/drivers/of/of_private.h @@ -36,6 +36,7 @@ struct alias_prop { #endif #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1 +#define MAX_RESERVED_REGIONS 64 extern struct mutex of_mutex; extern raw_spinlock_t devtree_lock; @@ -175,7 +176,6 @@ static inline struct device_node *__of_get_dma_parent(const struct device_node * } #endif -void fdt_init_reserved_mem(void); void fdt_reserved_mem_save_node(unsigned long node, const char *uname, phys_addr_t base, phys_addr_t size); diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c index 7ec94cfcbddb..d62f1956024c 100644 --- a/drivers/of/of_reserved_mem.c +++ b/drivers/of/of_reserved_mem.c @@ -26,7 +26,6 @@ #include "of_private.h" -#define MAX_RESERVED_REGIONS 64 static struct reserved_mem reserved_mem[MAX_RESERVED_REGIONS]; static int reserved_mem_count; @@ -132,8 +131,7 @@ static int __init __reserved_mem_alloc_in_range(phys_addr_t size, * __reserved_mem_alloc_size() - allocate reserved memory described by * 'size', 'alignment' and 'alloc-ranges' properties. */ -static int __init __reserved_mem_alloc_size(unsigned long node, - const char *uname, phys_addr_t *res_base, phys_addr_t *res_size) +int __init __reserved_mem_alloc_size(unsigned long node, const char *uname) { int t_len = (dt_root_addr_cells + dt_root_size_cells) * sizeof(__be32); phys_addr_t start = 0, end = 0; @@ -212,10 +210,7 @@ static int __init __reserved_mem_alloc_size(unsigned long node, uname, (unsigned long)(size / SZ_1M)); return -ENOMEM; } - - *res_base = base; - *res_size = size; - + fdt_reserved_mem_save_node(node, uname, base, size); return 0; } @@ -310,6 +305,8 @@ void __init fdt_init_reserved_mem(void) { int i; + fdt_scan_reserved_mem_reg_nodes(); + /* check for overlapping reserved regions */ __rmem_check_for_overlap(); @@ -328,30 +325,25 @@ void __init fdt_init_reserved_mem(void) if (prop) rmem->phandle = of_read_number(prop, len/4); - if (rmem->size == 0) - err = __reserved_mem_alloc_size(node, rmem->name, - &rmem->base, &rmem->size); - if (err == 0) { - err = __reserved_mem_init_node(rmem); - if (err != 0 && err != -ENOENT) { - pr_info("node %s compatible matching fail\n", - rmem->name); - if (nomap) - memblock_clear_nomap(rmem->base, rmem->size); - else - memblock_phys_free(rmem->base, - rmem->size); - } else { - phys_addr_t end = rmem->base + rmem->size - 1; - bool reusable = - (of_get_flat_dt_prop(node, "reusable", NULL)) != NULL; - - pr_info("%pa..%pa (%lu KiB) %s %s %s\n", - &rmem->base, &end, (unsigned long)(rmem->size / SZ_1K), - nomap ? "nomap" : "map", - reusable ? "reusable" : "non-reusable", - rmem->name ? rmem->name : "unknown"); - } + err = __reserved_mem_init_node(rmem); + if (err != 0 && err != -ENOENT) { + pr_info("node %s compatible matching fail\n", + rmem->name); + if (nomap) + memblock_clear_nomap(rmem->base, rmem->size); + else + memblock_phys_free(rmem->base, + rmem->size); + } else { + phys_addr_t end = rmem->base + rmem->size - 1; + bool reusable = + (of_get_flat_dt_prop(node, "reusable", NULL)) != NULL; + + pr_info("%pa..%pa (%lu KiB) %s %s %s\n", + &rmem->base, &end, (unsigned long)(rmem->size / SZ_1K), + nomap ? "nomap" : "map", + reusable ? "reusable" : "non-reusable", + rmem->name ? rmem->name : "unknown"); } } } diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h index d69ad5bb1eb1..7b2a5d93d719 100644 --- a/include/linux/of_fdt.h +++ b/include/linux/of_fdt.h @@ -73,6 +73,7 @@ extern int early_init_dt_scan_root(void); extern bool early_init_dt_scan(void *params); extern bool early_init_dt_verify(void *params); extern void early_init_dt_scan_nodes(void); +extern void fdt_scan_reserved_mem_reg_nodes(void); extern const char *of_flat_dt_get_machine_name(void); extern const void *of_flat_dt_match_machine(const void *default_match, diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h index 4de2a24cadc9..2a3178920bae 100644 --- a/include/linux/of_reserved_mem.h +++ b/include/linux/of_reserved_mem.h @@ -32,12 +32,14 @@ typedef int (*reservedmem_of_init_fn)(struct reserved_mem *rmem); #define RESERVEDMEM_OF_DECLARE(name, compat, init) \ _OF_DECLARE(reservedmem, name, compat, init, reservedmem_of_init_fn) +void fdt_init_reserved_mem(void); int of_reserved_mem_device_init_by_idx(struct device *dev, struct device_node *np, int idx); int of_reserved_mem_device_init_by_name(struct device *dev, struct device_node *np, const char *name); void of_reserved_mem_device_release(struct device *dev); +int __reserved_mem_alloc_size(unsigned long node, const char *uname); struct reserved_mem *of_reserved_mem_lookup(struct device_node *np); #else @@ -45,6 +47,8 @@ struct reserved_mem *of_reserved_mem_lookup(struct device_node *np); #define RESERVEDMEM_OF_DECLARE(name, compat, init) \ _OF_DECLARE_STUB(reservedmem, name, compat, init, reservedmem_of_init_fn) +static inline void fdt_init_reserved_mem(void) { } + static inline int of_reserved_mem_device_init_by_idx(struct device *dev, struct device_node *np, int idx) { @@ -60,6 +64,11 @@ static inline int of_reserved_mem_device_init_by_name(struct device *dev, static inline void of_reserved_mem_device_release(struct device *pdev) { } +static inline int __reserved_mem_alloc_size(unsigned long node, const char *uname) +{ + return -ENOSYS; +} + static inline struct reserved_mem *of_reserved_mem_lookup(struct device_node *np) { return NULL; From patchwork Fri Jan 26 23:53:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oreoluwa Babatunde X-Patchwork-Id: 1891700 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=quicinc.com header.i=@quicinc.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=Q9MFmI/0; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:4601:e00::3; helo=am.mirrors.kernel.org; envelope-from=devicetree+bounces-35692-incoming-dt=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org [IPv6:2604:1380:4601:e00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TMF674Fq1z23fJ for ; Sat, 27 Jan 2024 10:59:11 +1100 (AEDT) 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 563F81F2104F for ; Fri, 26 Jan 2024 23:59:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1E31D6169B; Fri, 26 Jan 2024 23:56:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="Q9MFmI/0" X-Original-To: devicetree@vger.kernel.org Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 4E1A260891; Fri, 26 Jan 2024 23:56:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706313365; cv=none; b=EgXJtVkDIK8TljsU4MOiK//eUG5tCY2KdQFPfjRRGxB6357/2AraSKvA9cVLeLj9G9e2pZHJFBY50bkVtDezPGzsorsflCSE3M3wjDHvHrwigdFWp5c4iD40yKtyTyiFbhNaNiQ94dT3pcBsl15HLVxm0uYLRK7Sx6yyMnuQrLE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706313365; c=relaxed/simple; bh=NjEBBPmts20IxnmpGdS5v6kjIG4dAFLZZeM15CX6CZE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QMpq7L/v2/3a5WJjikxuTcy4gtM9CnJY58UXRBceOtGG4MaJxAdtwt1T6Xfrz6vqEymF77PjSdKmP6DUFSf6Hr7ce9s/aUF3kkl1ocF0CBl8kfd8u7iYIlq/ovasY0b4D2ePsL1kl2TliYhzWFG4Hg4sGuDLD5GtfrAE3+GeSw0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=Q9MFmI/0; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40QNt2ql006015; Fri, 26 Jan 2024 23:55:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=qcppdkim1; bh=kZa2Pe53+6g14o/QY6sX E+C2csDopSUWS/8cevqSYa0=; b=Q9MFmI/0qU7Eq7vCH9+LsoEjT4jkmvBEFP2b V18Uay8A2aX+UFs/VwyhFxWowzM3v8cV5nhv+GwYFeaOiirDeMnz9s5XRgGatEzH 5F8/c3YnxJDch0cP5O9Njt2C0LGiXnQHSZXn3NDNrFvDeSVnOUxhozcWHu+OKdQs juoHbzv2Kc2xncvwVClwqNQBCTPdhJuSuO4glagnQ2jfkG1ip9IZbMuNijR0S8qM 3Wv9mwMv3F6tfydwy5ofXznCETy3pZ64cQgVItgWKDHz0exYXfNaKmSjJvlgRbDd yn4jEw320ZG8nha5IDM/fruFWxh735g9QGqsClRIp3EpkLWc2g== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vv4f9jd0a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 26 Jan 2024 23:55:02 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 40QNt1JV009985 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 26 Jan 2024 23:55:01 GMT Received: from hu-obabatun-lv.qualcomm.com (10.49.16.6) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Fri, 26 Jan 2024 15:54:57 -0800 From: Oreoluwa Babatunde To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , Oreoluwa Babatunde Subject: [PATCH 02/46] of: reserved_mem: Introduce new early reserved memory scan function Date: Fri, 26 Jan 2024 15:53:41 -0800 Message-ID: <20240126235425.12233-3-quic_obabatun@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240126235425.12233-1-quic_obabatun@quicinc.com> References: <20240126235425.12233-1-quic_obabatun@quicinc.com> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: U2-fU3rRD1n6fc8VYjNIwksODXsmUq9K X-Proofpoint-GUID: U2-fU3rRD1n6fc8VYjNIwksODXsmUq9K X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-25_14,2024-01-25_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1015 priorityscore=1501 impostorscore=0 mlxscore=0 suspectscore=0 mlxlogscore=452 spamscore=0 bulkscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401190000 definitions=main-2401260176 Introduce new reserved memory scan function called early_fdt_scan_reserved_mem() which is a clone of the original early_init_fdt_scan_reserved_mem() function, but does not call fdt_init_reserved_mem() at the end. This will allow architectures to separate the first stage of the reserved memory processing which is done by early_init_fdt_scan_reserved_mem() from the second stage of the reserved memory processing which is done by fdt_init_reserved_mem(). Signed-off-by: Oreoluwa Babatunde --- drivers/of/fdt.c | 27 +++++++++++++++++++++++++++ include/linux/of_fdt.h | 2 ++ 2 files changed, 29 insertions(+) diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index d02884ec0b6b..6bda033936af 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -711,6 +711,33 @@ void __init early_init_fdt_scan_reserved_mem(void) fdt_init_reserved_mem(); } +/** + * early_fdt_scan_reserved_mem() - create reserved memory regions + * + * This function grabs memory from early allocator for device exclusive use + * defined in device tree structures. It should be called by arch specific code + * once the early allocator (i.e. memblock) has been fully activated. + */ +void __init early_fdt_scan_reserved_mem(void) +{ + int n; + u64 base, size; + + if (!initial_boot_params) + return; + + fdt_scan_reserved_mem(); + fdt_reserve_elfcorehdr(); + + /* Process header /memreserve/ fields */ + for (n = 0; ; n++) { + fdt_get_mem_rsv(initial_boot_params, n, &base, &size); + if (!size) + break; + memblock_reserve(base, size); + } +} + /** * early_init_fdt_reserve_self() - reserve the memory used by the FDT blob */ diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h index 7b2a5d93d719..9b849c5c3917 100644 --- a/include/linux/of_fdt.h +++ b/include/linux/of_fdt.h @@ -63,6 +63,7 @@ extern int early_init_dt_scan_memory(void); extern void early_init_dt_check_for_usable_mem_range(void); extern int early_init_dt_scan_chosen_stdout(void); extern void early_init_fdt_scan_reserved_mem(void); +extern void early_fdt_scan_reserved_mem(void); extern void early_init_fdt_reserve_self(void); extern void early_init_dt_add_memory_arch(u64 base, u64 size); extern u64 dt_mem_next_cell(int s, const __be32 **cellp); @@ -88,6 +89,7 @@ extern void early_get_first_memblock_info(void *, phys_addr_t *); static inline void early_init_dt_check_for_usable_mem_range(void) {} static inline int early_init_dt_scan_chosen_stdout(void) { return -ENODEV; } static inline void early_init_fdt_scan_reserved_mem(void) {} +static inline void early_fdt_scan_reserved_mem(void) {} static inline void early_init_fdt_reserve_self(void) {} static inline const char *of_flat_dt_get_machine_name(void) { return NULL; } static inline void unflatten_device_tree(void) {} From patchwork Fri Jan 26 23:53:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oreoluwa Babatunde X-Patchwork-Id: 1891698 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=quicinc.com header.i=@quicinc.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=SNyeXf6R; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:40f1:3f00::1; helo=sy.mirrors.kernel.org; envelope-from=devicetree+bounces-35684-incoming-dt=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org [IPv6:2604:1380:40f1:3f00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TMF410jnbz23fJ for ; Sat, 27 Jan 2024 10:57:21 +1100 (AEDT) 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 A606CB27C11 for ; Fri, 26 Jan 2024 23:57:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 01C12604C4; Fri, 26 Jan 2024 23:56:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="SNyeXf6R" X-Original-To: devicetree@vger.kernel.org Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (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 2D5105C8FD; Fri, 26 Jan 2024 23:55:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706313360; cv=none; b=q6yYY4PSdywBnl1/OUEg6DvJIRxNeQXQzqq+WRfX8lpIT+cUqccZCQDvLUEvhf3YiWs4C7ovsmRcPNb/ZnGgS7Hl/tE72HMKKk46FydBnYh50w7apMaQQFxbothXhR++IOCm0W88QB6pm8gbuehkER2bawVgCHpT0NwMPKpQZQE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706313360; c=relaxed/simple; bh=V6Jfwdz7cfuw8xz0rOiPIfZC0VoGr7aTRGVEnL4nr9g=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Yp1wC9tLsvh2Fm8X9lGpm4q5AIQHILUhB1SWKKvOI3M7SWnu0lgFAdpcnqCU8RxWuM8UlkUE4wF89RZMvbPppzxXFthcUFLYycCn/JBqRrVRYi2F/rcf+POw87rHOM6e/4gYcOmBbxHf82fIHh9IOXwla4yX8HrBnWMPN9WmE6A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=SNyeXf6R; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40QNofxh032435; Fri, 26 Jan 2024 23:55:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=qcppdkim1; bh=RlnfElnCLOGgkR/BB4Cz dA5j3vD5FsmMJ5CohK/Sl8M=; b=SNyeXf6ROn3tbOZF0JFukSBRevxqeDuBXnja YmUdDf+jByNPIccaRTBYaHWOVWaawruRk0B1i7ZW6z4btrxO8KbQDJEAmM5jgfnl o6idmLlYNCjrJMWA2zx5a94bj3eVpUo2Az2e7nmh4MBGhPBagfqhuwwh4lL1x8do JkqYSb715JlWaKP2Va1T8QgwEhggUbVp5J0aVPjgzfX5pPshEf+i4w2n+spYvrZu 3j0en8rkqJXzkJuu8aQ1T4c2lWgv4znM69plR5Swbys5sXau0HS8owwytpjahBbr xxnA21o7ChruKXWNjrz9ZvvEFyFZSXBnxW38npKKK69RLPa8uw== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vv1q5aq5p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 26 Jan 2024 23:55:13 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 40QNtCt8009378 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 26 Jan 2024 23:55:12 GMT Received: from hu-obabatun-lv.qualcomm.com (10.49.16.6) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Fri, 26 Jan 2024 15:55:03 -0800 From: Oreoluwa Babatunde To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , Oreoluwa Babatunde Subject: [PATCH 17/46] of: reserved_mem: Delete the early_init_fdt_scan_reserved_mem() function Date: Fri, 26 Jan 2024 15:53:56 -0800 Message-ID: <20240126235425.12233-18-quic_obabatun@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240126235425.12233-1-quic_obabatun@quicinc.com> References: <20240126235425.12233-1-quic_obabatun@quicinc.com> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: u75yF4T-XBMIScbnN8Ykb2WGNs7x1ki5 X-Proofpoint-GUID: u75yF4T-XBMIScbnN8Ykb2WGNs7x1ki5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-25_14,2024-01-25_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 mlxscore=0 lowpriorityscore=0 adultscore=0 priorityscore=1501 phishscore=0 mlxlogscore=447 impostorscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401190000 definitions=main-2401260175 Delete the early_init_fdt_scan_reserved_mem() function definition since this function is no longer being used anywhere in the kernel. Signed-off-by: Oreoluwa Babatunde --- drivers/of/fdt.c | 29 ----------------------------- include/linux/of_fdt.h | 2 -- 2 files changed, 31 deletions(-) diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 6bda033936af..c6e8560946f4 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -682,35 +682,6 @@ static void __init fdt_reserve_elfcorehdr(void) elfcorehdr_size >> 10, elfcorehdr_addr); } -/** - * early_init_fdt_scan_reserved_mem() - create reserved memory regions - * - * This function grabs memory from early allocator for device exclusive use - * defined in device tree structures. It should be called by arch specific code - * once the early allocator (i.e. memblock) has been fully activated. - */ -void __init early_init_fdt_scan_reserved_mem(void) -{ - int n; - u64 base, size; - - if (!initial_boot_params) - return; - - fdt_scan_reserved_mem(); - fdt_reserve_elfcorehdr(); - - /* Process header /memreserve/ fields */ - for (n = 0; ; n++) { - fdt_get_mem_rsv(initial_boot_params, n, &base, &size); - if (!size) - break; - memblock_reserve(base, size); - } - - fdt_init_reserved_mem(); -} - /** * early_fdt_scan_reserved_mem() - create reserved memory regions * diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h index 9b849c5c3917..9b85bbc5d9f5 100644 --- a/include/linux/of_fdt.h +++ b/include/linux/of_fdt.h @@ -62,7 +62,6 @@ extern int early_init_dt_scan_chosen(char *cmdline); extern int early_init_dt_scan_memory(void); extern void early_init_dt_check_for_usable_mem_range(void); extern int early_init_dt_scan_chosen_stdout(void); -extern void early_init_fdt_scan_reserved_mem(void); extern void early_fdt_scan_reserved_mem(void); extern void early_init_fdt_reserve_self(void); extern void early_init_dt_add_memory_arch(u64 base, u64 size); @@ -88,7 +87,6 @@ extern void early_get_first_memblock_info(void *, phys_addr_t *); #else /* CONFIG_OF_EARLY_FLATTREE */ static inline void early_init_dt_check_for_usable_mem_range(void) {} static inline int early_init_dt_scan_chosen_stdout(void) { return -ENODEV; } -static inline void early_init_fdt_scan_reserved_mem(void) {} static inline void early_fdt_scan_reserved_mem(void) {} static inline void early_init_fdt_reserve_self(void) {} static inline const char *of_flat_dt_get_machine_name(void) { return NULL; } From patchwork Fri Jan 26 23:53:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oreoluwa Babatunde X-Patchwork-Id: 1891699 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=quicinc.com header.i=@quicinc.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=UZtyN71r; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45d1:ec00::1; helo=ny.mirrors.kernel.org; envelope-from=devicetree+bounces-35691-incoming-dt=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [IPv6:2604:1380:45d1:ec00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TMF632qT8z23fJ for ; Sat, 27 Jan 2024 10:59:07 +1100 (AEDT) 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 7D7511C2180A for ; Fri, 26 Jan 2024 23:59:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C6D5C6167F; Fri, 26 Jan 2024 23:56:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="UZtyN71r" X-Original-To: devicetree@vger.kernel.org Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 C79356087C; Fri, 26 Jan 2024 23:56:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706313365; cv=none; b=er/FiY1wndS39JrUNG6J5yLlY7ShWleqrmJkX6w14P1dKYuCurw3Kd7D/lO9DYUJINY+j3yzp5w54UP5bfS1mibblhwdu41ITix3/yPZgu80qbvL4AiBG2nU39yi/UngLXJzn0/jUTCDSOJW2r+FNspoA//VMtz2GlrY1Uzk9KA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706313365; c=relaxed/simple; bh=mnaTXHL7qyvkBg0qOOl7qQWPWG3GB5Bnp457+ulZn3o=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RpsKxeDcRnUX8sq/O1feGER3oK+2zvQT2ucjuCMNLsPZ1Vce8c9pGiZV6IWrDOmRkirH3xFC7h0b05vqMpsgtzpPp1pcm3yZCsIPjmtYhEBfktzMwrKEF9Z1JQZvXq+3T/K6i0Mfc8XoY2WxUmIBDFGzE9pWhPMO6irVZdlYDFE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=UZtyN71r; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40QNjlab020531; Fri, 26 Jan 2024 23:55:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=qcppdkim1; bh=qI6VfLKrBrkEDM9xCiQN Zx23EmHN2UyOxrcxb9sAKGo=; b=UZtyN71rn7dLwmmFHoJXPMujguYOLAnW4PCx RElDN5UGhPa+1YZM7AnM+0WC9S4bmFQAPXfcCTR6S1e8d+nh6rWSp9o6I4uCvHYX e4x8BRN3v3M9Cj2ISg1pJSjllgGAXkN7H+0sfAzLcAN1vwxAfsK/xb3CDo3GagFZ viaFI+OiRbYEDcFYcfmdUmTUFQBKgNRm6w3dubsaNmNa92frzjf507L7/tBCavso e/rbHKd8lGmf4P8fvb0zV/lb2qJk1e1CMo7bb/A8vDbqUh2t3wMqnI9j4mCy3KyT VQCMmc4UcnQadY07eM/x0sncubgX0V10oqNXb6ip9zRxQp+uGg== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vv4f9jd0k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 26 Jan 2024 23:55:14 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 40QNtEer030740 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 26 Jan 2024 23:55:14 GMT Received: from hu-obabatun-lv.qualcomm.com (10.49.16.6) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Fri, 26 Jan 2024 15:55:04 -0800 From: Oreoluwa Babatunde To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , Oreoluwa Babatunde Subject: [PATCH 18/46] of: reserved_mem: Add code to dynamically allocate reserved_mem array Date: Fri, 26 Jan 2024 15:53:57 -0800 Message-ID: <20240126235425.12233-19-quic_obabatun@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240126235425.12233-1-quic_obabatun@quicinc.com> References: <20240126235425.12233-1-quic_obabatun@quicinc.com> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: eVS7f7ccMtCIjS3leU8ZnSql-wIPXqEV X-Proofpoint-GUID: eVS7f7ccMtCIjS3leU8ZnSql-wIPXqEV X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-25_14,2024-01-25_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1015 priorityscore=1501 impostorscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401190000 definitions=main-2401260176 The reserved_mem array is statically allocated with a size of MAX_RESERVED_REGIONS(64). Therefore, if the number of reserved_mem regions exceeds this size, there will not be enough space to store all the data. Hence, extend the use of the static array by introducing a dynamically allocated array based on the number of reserved memory regions specified in the DT. The static array is initally used to store the information for the dynamically-placed regions. At the same time, the number of reserved memory regions specified in the DT is counted. The number counted is then used to dynamically allocate the memory required for the reserved_mem array. Afterwards, all entries from the static array is copied over to the new allocated memory for the array, and all other statically-placed regions are added in as well. The static array is also marked as __initdata so that once the init process is done running, this memory is freed back to buddy since it is no longer used after this point. Signed-off-by: Oreoluwa Babatunde --- drivers/of/fdt.c | 11 ++++++-- drivers/of/of_private.h | 1 + drivers/of/of_reserved_mem.c | 52 +++++++++++++++++++++++++++++++++--- 3 files changed, 59 insertions(+), 5 deletions(-) diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index c6e8560946f4..ebd2fa9e0114 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -613,7 +613,7 @@ void __init fdt_scan_reserved_mem_reg_nodes(void) static int __init fdt_scan_reserved_mem(void) { int node, child; - int dynamic_nodes_cnt = 0; + int dynamic_nodes_cnt = 0, count = 0; int dynamic_nodes[MAX_RESERVED_REGIONS]; const void *fdt = initial_boot_params; @@ -636,6 +636,8 @@ static int __init fdt_scan_reserved_mem(void) uname = fdt_get_name(fdt, child, NULL); err = __reserved_mem_reserve_reg(child, uname); + if (!err) + count++; /* Delay allocation of the dynamically-placed regions * until after all other statically-placed regions have @@ -649,12 +651,17 @@ static int __init fdt_scan_reserved_mem(void) for (int i = 0; i < dynamic_nodes_cnt; i++) { const char *uname; + int err; child = dynamic_nodes[i]; uname = fdt_get_name(fdt, child, NULL); - __reserved_mem_alloc_size(child, uname); + err = __reserved_mem_alloc_size(child, uname); + if (!err) + count++; } + update_reserved_mem_max_cnt(count); + return 0; } diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h index 542e37a37a24..c338e1c019c7 100644 --- a/drivers/of/of_private.h +++ b/drivers/of/of_private.h @@ -176,6 +176,7 @@ static inline struct device_node *__of_get_dma_parent(const struct device_node * } #endif +void update_reserved_mem_max_cnt(int max_count); void fdt_reserved_mem_save_node(unsigned long node, const char *uname, phys_addr_t base, phys_addr_t size); diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c index d62f1956024c..419b062cb41f 100644 --- a/drivers/of/of_reserved_mem.c +++ b/drivers/of/of_reserved_mem.c @@ -26,7 +26,9 @@ #include "of_private.h" -static struct reserved_mem reserved_mem[MAX_RESERVED_REGIONS]; +static struct reserved_mem reserved_mem_array[MAX_RESERVED_REGIONS] __initdata; +static struct reserved_mem *reserved_mem __refdata = reserved_mem_array; +static int total_reserved_mem_cnt = MAX_RESERVED_REGIONS; static int reserved_mem_count; static int __init early_init_dt_alloc_reserved_memory_arch(phys_addr_t size, @@ -54,6 +56,46 @@ static int __init early_init_dt_alloc_reserved_memory_arch(phys_addr_t size, return err; } +void __init update_reserved_mem_max_cnt(int max_count) +{ + total_reserved_mem_cnt = max_count; +} + +/* + * alloc_reserved_mem_array() - allocate memory for the reserved_mem + * array. + */ +static int alloc_reserved_mem_array(void) +{ + struct reserved_mem *new_array; + size_t alloc_size, copy_size, memset_size; + + alloc_size = array_size(total_reserved_mem_cnt, sizeof(*new_array)); + if (alloc_size == SIZE_MAX) + return -1; + + new_array = memblock_alloc(alloc_size, SMP_CACHE_BYTES); + if (!new_array) + return -ENOMEM; + + copy_size = array_size(reserved_mem_count, sizeof(*new_array)); + if (copy_size == SIZE_MAX) + goto overlow_err; + + memset_size = alloc_size - copy_size; + + memcpy(new_array, reserved_mem, copy_size); + memset(new_array + reserved_mem_count, 0, memset_size); + + reserved_mem = new_array; + return 0; + +overlow_err: + memblock_free(new_array, alloc_size); + total_reserved_mem_cnt = MAX_RESERVED_REGIONS; + return -1; +} + /* * fdt_reserved_mem_save_node() - save fdt node for second pass initialization */ @@ -62,7 +104,7 @@ void __init fdt_reserved_mem_save_node(unsigned long node, const char *uname, { struct reserved_mem *rmem = &reserved_mem[reserved_mem_count]; - if (reserved_mem_count == ARRAY_SIZE(reserved_mem)) { + if (reserved_mem_count == total_reserved_mem_cnt) { pr_err("not enough space for all defined regions.\n"); return; } @@ -303,7 +345,11 @@ static void __init __rmem_check_for_overlap(void) */ void __init fdt_init_reserved_mem(void) { - int i; + int i, ret; + + ret = alloc_reserved_mem_array(); + if (ret) + pr_err("Failed to allocate memory for reserved_mem array with err: %d", ret); fdt_scan_reserved_mem_reg_nodes(); From patchwork Fri Jan 26 23:54:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oreoluwa Babatunde X-Patchwork-Id: 1891704 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=quicinc.com header.i=@quicinc.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=oNDfq1XY; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45d1:ec00::1; helo=ny.mirrors.kernel.org; envelope-from=devicetree+bounces-35715-incoming-dt=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [IPv6:2604:1380:45d1:ec00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TMFGx15rfz23gB for ; Sat, 27 Jan 2024 11:06:49 +1100 (AEDT) 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 57DFD1C28650 for ; Sat, 27 Jan 2024 00:06:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 802B06DCF4; Fri, 26 Jan 2024 23:56:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="oNDfq1XY" X-Original-To: devicetree@vger.kernel.org Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 79A6F6A01B; Fri, 26 Jan 2024 23:56:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706313376; cv=none; b=KArjsh2ywKkUSvxlD9I4ZU+/JIXxQXe65RC/+4GyjFke0cWzoOp2mcht2g6jzV1Kw2jKuCBhrW+80rbJGSSVD3qaj65FnCpjEIenHe/WA1s7/Lat/bzRaUdJgoOouPuu+/Sm0f5sxY3gHc7x2NuB3rVqtOa/ahkE1eXe8nRj2EI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706313376; c=relaxed/simple; bh=P1AkFxQdbHcnFpiYveH/lqCbOhuQDolNZukNjttahTM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=py3KojrCoDhWpCK3T+VqTKt88AJJ5znVZDd1hZYm5qDFUsSY1tPMbzrN+XYeVKiT0WcXIPsnp65lIDxqkdhC8J5WzfOSjGoiyH/AYZmGd8OYeJ4OfiKLBl1hmhRmF8pOjAOEsFYcBQDtdNErZM2sTziluaMnkoCrjbMjmgfr0tY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=oNDfq1XY; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40QNBGT1012061; Fri, 26 Jan 2024 23:55:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=qcppdkim1; bh=SJ2uVxsVzF+RZp0UyxD5 o7P5HuGaB56FNfvEAgO0PZI=; b=oNDfq1XYRkEu/t8bLl0QBHNmiWLwXtCFkH4z R1oEi3uV6zK9BDHhkLAPWuraRI4ztGytg2l7J0ttyGGDXnSLxwXp5B8zuPDfjkOT IwzcoFSMoqDz6AnUomoYTR7HO86jqFrqRvaoyi1yEXyDnwQaEVS/M/0/gN3xCmAD Zn68V5Hcxse4FZgRRRPME8WijeXz39V19ejoqTtyImHFdbwpW5ziRy5T88D/MKeU C5+xRiwYZ2vhJYzj8/l3tvCBDjkSnzXrPLJzLi6IwMfqi+ESa3Q2lJqZY9KcqW9n YnZU/l8XiSXe23OAYljeb0fo0GvkkG15U8f0Qd6r+DT9SfpghQ== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vvjbg8g0s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 26 Jan 2024 23:55:30 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 40QNtTDZ010350 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 26 Jan 2024 23:55:29 GMT Received: from hu-obabatun-lv.qualcomm.com (10.49.16.6) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Fri, 26 Jan 2024 15:55:12 -0800 From: Oreoluwa Babatunde To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , Oreoluwa Babatunde Subject: [PATCH 30/46] of: reserved_mem: Add code to use unflattened DT for reserved_mem nodes Date: Fri, 26 Jan 2024 15:54:09 -0800 Message-ID: <20240126235425.12233-31-quic_obabatun@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240126235425.12233-1-quic_obabatun@quicinc.com> References: <20240126235425.12233-1-quic_obabatun@quicinc.com> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: oCU4TW6ixTZQc4WOuFDNAARpo2_btXl0 X-Proofpoint-ORIG-GUID: oCU4TW6ixTZQc4WOuFDNAARpo2_btXl0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-25_14,2024-01-25_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 spamscore=0 priorityscore=1501 mlxlogscore=752 phishscore=0 impostorscore=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 adultscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401190000 definitions=main-2401260176 The unflattened devicetree APIs are available to be used not long after the processing is done for the reserved memory regions on some architectures, and is available even before that on other architectures. Therefore, use the unflattened devicetree APIs to process and store information for the reserved memory regions. Using the unflattened devicetree APIs is more efficient than using the flattened devicetree APIs. Signed-off-by: Oreoluwa Babatunde --- drivers/of/fdt.c | 49 ---------------------- drivers/of/of_private.h | 4 +- drivers/of/of_reserved_mem.c | 74 ++++++++++++++++++++++++++------- include/linux/of_fdt.h | 1 - include/linux/of_reserved_mem.h | 2 +- kernel/dma/coherent.c | 4 +- kernel/dma/contiguous.c | 8 ++-- kernel/dma/swiotlb.c | 10 ++--- 8 files changed, 72 insertions(+), 80 deletions(-) diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index ebd2fa9e0114..2bc01ffdabfe 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -558,55 +558,6 @@ static int __init __reserved_mem_check_root(unsigned long node) return 0; } -/* - * Save the reserved_mem reg nodes in the reserved_mem array - */ -void __init fdt_scan_reserved_mem_reg_nodes(void) - -{ - int t_len = (dt_root_addr_cells + dt_root_size_cells) * sizeof(__be32); - const void *fdt = initial_boot_params; - phys_addr_t base, size; - const __be32 *prop; - int node, child; - int len; - - node = fdt_path_offset(fdt, "/reserved-memory"); - if (node < 0) { - pr_err("Reserved memory: Did not find reserved-memory node\n"); - return; - } - - if (__reserved_mem_check_root(node) != 0) { - pr_err("Reserved memory: unsupported node format, ignoring\n"); - return; - } - - fdt_for_each_subnode(child, fdt, node) { - const char *uname; - - prop = of_get_flat_dt_prop(child, "reg", &len); - if (!prop) - continue; - - if (!of_fdt_device_is_available(fdt, child)) - continue; - - uname = fdt_get_name(fdt, child, NULL); - if (len && len % t_len != 0) { - pr_err("Reserved memory: invalid reg property in '%s', skipping node.\n", - uname); - continue; - } - - base = dt_mem_next_cell(dt_root_addr_cells, &prop); - size = dt_mem_next_cell(dt_root_size_cells, &prop); - - if (size) - fdt_reserved_mem_save_node(child, uname, base, size); - } -} - /* * fdt_scan_reserved_mem() - scan a single FDT node for reserved memory. */ diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h index c338e1c019c7..f7da22108e7a 100644 --- a/drivers/of/of_private.h +++ b/drivers/of/of_private.h @@ -177,7 +177,7 @@ static inline struct device_node *__of_get_dma_parent(const struct device_node * #endif void update_reserved_mem_max_cnt(int max_count); -void fdt_reserved_mem_save_node(unsigned long node, const char *uname, - phys_addr_t base, phys_addr_t size); +void fdt_reserved_mem_save_node(struct device_node *node, const char *uname, + phys_addr_t base, phys_addr_t size); #endif /* _LINUX_OF_PRIVATE_H */ diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c index 419b062cb41f..645b02e27492 100644 --- a/drivers/of/of_reserved_mem.c +++ b/drivers/of/of_reserved_mem.c @@ -96,11 +96,58 @@ static int alloc_reserved_mem_array(void) return -1; } +/* + * Save the reserved_mem reg nodes in the reserved_mem array + */ +static void __init dt_scan_reserved_mem_reg_nodes(void) +{ + int t_len = (dt_root_addr_cells + dt_root_size_cells) * sizeof(__be32); + struct device_node *node, *child; + phys_addr_t base, size; + const __be32 *prop; + int len; + + node = of_find_node_by_path("/reserved-memory"); + if (node < 0) { + pr_err("Reserved memory: Did not find reserved-memory node\n"); + return; + } + + for_each_child_of_node(node, child) { + const char *uname; + struct reserved_mem *rmem; + + if (!of_device_is_available(child)) + continue; + + prop = of_get_property(child, "reg", &len); + if (!prop) { + rmem = of_reserved_mem_lookup(child); + if (rmem) + rmem->dev_node = child; + continue; + } + + uname = of_node_full_name(child); + if (len && len % t_len != 0) { + pr_err("Reserved memory: invalid reg property in '%s', skipping node.\n", + uname); + continue; + } + + base = dt_mem_next_cell(dt_root_addr_cells, &prop); + size = dt_mem_next_cell(dt_root_size_cells, &prop); + + if (size) + fdt_reserved_mem_save_node(child, uname, base, size); + } +} + /* * fdt_reserved_mem_save_node() - save fdt node for second pass initialization */ -void __init fdt_reserved_mem_save_node(unsigned long node, const char *uname, - phys_addr_t base, phys_addr_t size) +void __init fdt_reserved_mem_save_node(struct device_node *node, const char *uname, + phys_addr_t base, phys_addr_t size) { struct reserved_mem *rmem = &reserved_mem[reserved_mem_count]; @@ -109,7 +156,7 @@ void __init fdt_reserved_mem_save_node(unsigned long node, const char *uname, return; } - rmem->fdt_node = node; + rmem->dev_node = node; rmem->name = uname; rmem->base = base; rmem->size = size; @@ -252,7 +299,7 @@ int __init __reserved_mem_alloc_size(unsigned long node, const char *uname) uname, (unsigned long)(size / SZ_1M)); return -ENOMEM; } - fdt_reserved_mem_save_node(node, uname, base, size); + fdt_reserved_mem_save_node(NULL, uname, base, size); return 0; } @@ -272,7 +319,7 @@ static int __init __reserved_mem_init_node(struct reserved_mem *rmem) reservedmem_of_init_fn initfn = i->data; const char *compat = i->compatible; - if (!of_flat_dt_is_compatible(rmem->fdt_node, compat)) + if (!of_device_is_compatible(rmem->dev_node, compat)) continue; ret = initfn(rmem); @@ -305,11 +352,6 @@ static int __init __rmem_cmp(const void *a, const void *b) if (ra->size > rb->size) return 1; - if (ra->fdt_node < rb->fdt_node) - return -1; - if (ra->fdt_node > rb->fdt_node) - return 1; - return 0; } @@ -351,23 +393,23 @@ void __init fdt_init_reserved_mem(void) if (ret) pr_err("Failed to allocate memory for reserved_mem array with err: %d", ret); - fdt_scan_reserved_mem_reg_nodes(); + dt_scan_reserved_mem_reg_nodes(); /* check for overlapping reserved regions */ __rmem_check_for_overlap(); for (i = 0; i < reserved_mem_count; i++) { struct reserved_mem *rmem = &reserved_mem[i]; - unsigned long node = rmem->fdt_node; + struct device_node *node = rmem->dev_node; int len; const __be32 *prop; int err = 0; bool nomap; - nomap = of_get_flat_dt_prop(node, "no-map", NULL) != NULL; - prop = of_get_flat_dt_prop(node, "phandle", &len); + nomap = of_get_property(node, "no-map", NULL) != NULL; + prop = of_get_property(node, "phandle", &len); if (!prop) - prop = of_get_flat_dt_prop(node, "linux,phandle", &len); + prop = of_get_property(node, "linux,phandle", &len); if (prop) rmem->phandle = of_read_number(prop, len/4); @@ -383,7 +425,7 @@ void __init fdt_init_reserved_mem(void) } else { phys_addr_t end = rmem->base + rmem->size - 1; bool reusable = - (of_get_flat_dt_prop(node, "reusable", NULL)) != NULL; + (of_get_property(node, "reusable", NULL)) != NULL; pr_info("%pa..%pa (%lu KiB) %s %s %s\n", &rmem->base, &end, (unsigned long)(rmem->size / SZ_1K), diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h index 9b85bbc5d9f5..fb7b437141bd 100644 --- a/include/linux/of_fdt.h +++ b/include/linux/of_fdt.h @@ -73,7 +73,6 @@ extern int early_init_dt_scan_root(void); extern bool early_init_dt_scan(void *params); extern bool early_init_dt_verify(void *params); extern void early_init_dt_scan_nodes(void); -extern void fdt_scan_reserved_mem_reg_nodes(void); extern const char *of_flat_dt_get_machine_name(void); extern const void *of_flat_dt_match_machine(const void *default_match, diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h index 2a3178920bae..e92babd669c2 100644 --- a/include/linux/of_reserved_mem.h +++ b/include/linux/of_reserved_mem.h @@ -10,7 +10,7 @@ struct reserved_mem_ops; struct reserved_mem { const char *name; - unsigned long fdt_node; + struct device_node *dev_node; unsigned long phandle; const struct reserved_mem_ops *ops; phys_addr_t base; diff --git a/kernel/dma/coherent.c b/kernel/dma/coherent.c index ff5683a57f77..5ab26fe11c29 100644 --- a/kernel/dma/coherent.c +++ b/kernel/dma/coherent.c @@ -362,9 +362,9 @@ static const struct reserved_mem_ops rmem_dma_ops = { static int __init rmem_dma_setup(struct reserved_mem *rmem) { - unsigned long node = rmem->fdt_node; + struct device_node *node = rmem->dev_node; - if (of_get_flat_dt_prop(node, "reusable", NULL)) + if (of_get_property(node, "reusable", NULL)) return -EINVAL; #ifdef CONFIG_ARM diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c index f005c66f378c..b54cf128a9d9 100644 --- a/kernel/dma/contiguous.c +++ b/kernel/dma/contiguous.c @@ -462,8 +462,8 @@ static const struct reserved_mem_ops rmem_cma_ops = { static int __init rmem_cma_setup(struct reserved_mem *rmem) { - unsigned long node = rmem->fdt_node; - bool default_cma = of_get_flat_dt_prop(node, "linux,cma-default", NULL); + struct device_node *node = rmem->dev_node; + bool default_cma = of_get_property(node, "linux,cma-default", NULL); struct cma *cma; int err; @@ -473,8 +473,8 @@ static int __init rmem_cma_setup(struct reserved_mem *rmem) return -EBUSY; } - if (!of_get_flat_dt_prop(node, "reusable", NULL) || - of_get_flat_dt_prop(node, "no-map", NULL)) + if (!of_get_property(node, "reusable", NULL) || + of_get_property(node, "no-map", NULL)) return -EINVAL; if (!IS_ALIGNED(rmem->base | rmem->size, CMA_MIN_ALIGNMENT_BYTES)) { diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c index b079a9a8e087..ea1f734c8c35 100644 --- a/kernel/dma/swiotlb.c +++ b/kernel/dma/swiotlb.c @@ -1732,12 +1732,12 @@ static const struct reserved_mem_ops rmem_swiotlb_ops = { static int __init rmem_swiotlb_setup(struct reserved_mem *rmem) { - unsigned long node = rmem->fdt_node; + struct device_node *node = rmem->dev_node; - if (of_get_flat_dt_prop(node, "reusable", NULL) || - of_get_flat_dt_prop(node, "linux,cma-default", NULL) || - of_get_flat_dt_prop(node, "linux,dma-default", NULL) || - of_get_flat_dt_prop(node, "no-map", NULL)) + if (of_get_property(node, "reusable", NULL) || + of_get_property(node, "linux,cma-default", NULL) || + of_get_property(node, "linux,dma-default", NULL) || + of_get_property(node, "no-map", NULL)) return -EINVAL; rmem->ops = &rmem_swiotlb_ops; From patchwork Fri Jan 26 23:54:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oreoluwa Babatunde X-Patchwork-Id: 1891701 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=quicinc.com header.i=@quicinc.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=YDh/4SGd; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=139.178.88.99; helo=sv.mirrors.kernel.org; envelope-from=devicetree+bounces-35701-incoming-dt=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [139.178.88.99]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TMF7L20Jmz23fD for ; Sat, 27 Jan 2024 11:00:14 +1100 (AEDT) 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 89B0728F6C2 for ; Sat, 27 Jan 2024 00:00:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B1D036341B; Fri, 26 Jan 2024 23:56:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="YDh/4SGd" X-Original-To: devicetree@vger.kernel.org Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 001CC60BB4; Fri, 26 Jan 2024 23:56:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706313367; cv=none; b=Kxy17T7ZG1HQ+fA/04yWuhZhpm0crDjzH2emt/bLFap1H+Ld7jiH7S54yxj/sJ4O5tJkhAcVgMvMkqcoBq1vH6wuVYuzxC+zwAu/ksTUQeetASE4Nd+WyPQlErEvZc5kpXWFGv2IAhQlSRIOyM5LEkwA/56Q6ATald5Me8KVa8I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706313367; c=relaxed/simple; bh=AudqulAQ60IfEtaODp3Zx8VOJIFET5JKLr5kS7oiVrw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uCsiCwO9rMhrOB2axpNDSDmBgfBPFeYLggBVovwmAeigXBBp5HowBcLLkmC5y1915z3tzt7ZNEQmajIyfFYtcvUyzWzU2wSdfjZo2pYmO+ZzUWxtWmHsUCPZuyg6Q3neXZ5+q/lIHoa8fjhvbc5zjwfCvxJ6uLfij/sFFN5rt5M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=YDh/4SGd; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40QNrM4F027772; Fri, 26 Jan 2024 23:55:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=qcppdkim1; bh=rEH2huP6AGk9XFpyAeli kvp4R8pHCMfGjVuoQPZZseo=; b=YDh/4SGdUAyiP7uLcqDFOTc8Wc+f2gHwJpQi Vetg124F5hTd8MmzhbfZmnLPaqPpurVg1Nz2c0SAzadwsgUu+oPD3+3Enzbtstrx zjOmzbqHRV/Tct3yinXT5JGfBS7ZnzX6uYQ6y4ikkydS8AmESFT4zREYR/+/26FM 9bnx0feU6k4ewYRaYNZnLYqUv/gaxcKizVpC4VgWt+mmk+Tla/tf14ACEd3kycXC oSYjxwnHxsO1CCRywoG+l4AT2CIXLIjVcr7TDNQwTE7dcKQxVAnfrYQc4nRfiOEx Diff5us3UpXIP9H9XLMy5CKr+Nbiq6lcmHZC7zTbvz7lLRAOfQ== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vvmmmg7we-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 26 Jan 2024 23:55:29 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 40QNtSKh010339 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 26 Jan 2024 23:55:29 GMT Received: from hu-obabatun-lv.qualcomm.com (10.49.16.6) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Fri, 26 Jan 2024 15:55:13 -0800 From: Oreoluwa Babatunde To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , Oreoluwa Babatunde Subject: [PATCH 31/46] of: reserved_mem: Rename fdt_* functions to refelct use of unflattened devicetree APIs Date: Fri, 26 Jan 2024 15:54:10 -0800 Message-ID: <20240126235425.12233-32-quic_obabatun@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240126235425.12233-1-quic_obabatun@quicinc.com> References: <20240126235425.12233-1-quic_obabatun@quicinc.com> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: Hr4TeDNRkurySOwvrP4x31WI9EEga49r X-Proofpoint-ORIG-GUID: Hr4TeDNRkurySOwvrP4x31WI9EEga49r X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-25_14,2024-01-25_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 impostorscore=0 mlxscore=0 phishscore=0 adultscore=0 spamscore=0 mlxlogscore=659 priorityscore=1501 malwarescore=0 lowpriorityscore=0 clxscore=1015 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401190000 definitions=main-2401260176 Rename the relevant fdt_* functions to a new scheme dt_* to reflect the use of the unflattened devicetree APIs to process the reserved memory regions. Signed-off-by: Oreoluwa Babatunde --- drivers/of/of_private.h | 4 +-- drivers/of/of_reserved_mem.c | 64 ++++++++++++++++++++++++++++++--- include/linux/of_reserved_mem.h | 3 ++ 3 files changed, 64 insertions(+), 7 deletions(-) diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h index f7da22108e7a..1092615faa90 100644 --- a/drivers/of/of_private.h +++ b/drivers/of/of_private.h @@ -177,7 +177,7 @@ static inline struct device_node *__of_get_dma_parent(const struct device_node * #endif void update_reserved_mem_max_cnt(int max_count); -void fdt_reserved_mem_save_node(struct device_node *node, const char *uname, - phys_addr_t base, phys_addr_t size); +void dt_reserved_mem_save_node(struct device_node *node, const char *uname, + phys_addr_t base, phys_addr_t size); #endif /* _LINUX_OF_PRIVATE_H */ diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c index 645b02e27492..3650efab0afd 100644 --- a/drivers/of/of_reserved_mem.c +++ b/drivers/of/of_reserved_mem.c @@ -139,15 +139,15 @@ static void __init dt_scan_reserved_mem_reg_nodes(void) size = dt_mem_next_cell(dt_root_size_cells, &prop); if (size) - fdt_reserved_mem_save_node(child, uname, base, size); + dt_reserved_mem_save_node(child, uname, base, size); } } /* - * fdt_reserved_mem_save_node() - save fdt node for second pass initialization + * dt_reserved_mem_save_node() - save dt node for second pass initialization */ -void __init fdt_reserved_mem_save_node(struct device_node *node, const char *uname, - phys_addr_t base, phys_addr_t size) +void __init dt_reserved_mem_save_node(struct device_node *node, const char *uname, + phys_addr_t base, phys_addr_t size) { struct reserved_mem *rmem = &reserved_mem[reserved_mem_count]; @@ -299,7 +299,7 @@ int __init __reserved_mem_alloc_size(unsigned long node, const char *uname) uname, (unsigned long)(size / SZ_1M)); return -ENOMEM; } - fdt_reserved_mem_save_node(NULL, uname, base, size); + dt_reserved_mem_save_node(NULL, uname, base, size); return 0; } @@ -436,6 +436,60 @@ void __init fdt_init_reserved_mem(void) } } +/** + * dt_init_reserved_mem() - allocate and init all saved reserved memory regions + */ +void __init dt_init_reserved_mem(void) +{ + int i, ret; + + ret = alloc_reserved_mem_array(); + if (ret) + pr_err("Failed to allocate memory for reserved_mem array with err: %d", ret); + + dt_scan_reserved_mem_reg_nodes(); + + /* check for overlapping reserved regions */ + __rmem_check_for_overlap(); + + for (i = 0; i < reserved_mem_count; i++) { + struct reserved_mem *rmem = &reserved_mem[i]; + struct device_node *node = rmem->dev_node; + int len; + const __be32 *prop; + int err = 0; + bool nomap; + + nomap = of_get_property(node, "no-map", NULL) != NULL; + prop = of_get_property(node, "phandle", &len); + if (!prop) + prop = of_get_property(node, "linux,phandle", &len); + if (prop) + rmem->phandle = of_read_number(prop, len/4); + + err = __reserved_mem_init_node(rmem); + if (err != 0 && err != -ENOENT) { + pr_info("node %s compatible matching fail\n", + rmem->name); + if (nomap) + memblock_clear_nomap(rmem->base, rmem->size); + else + memblock_phys_free(rmem->base, + rmem->size); + } else { + phys_addr_t end = rmem->base + rmem->size - 1; + bool reusable = + (of_get_property(node, "reusable", NULL)) != NULL; + + pr_info("%pa..%pa (%lu KiB) %s %s %s\n", + &rmem->base, &end, (unsigned long)(rmem->size / SZ_1K), + nomap ? "nomap" : "map", + reusable ? "reusable" : "non-reusable", + rmem->name ? rmem->name : "unknown"); + } + } +} + static inline struct reserved_mem *__find_rmem(struct device_node *node) { unsigned int i; diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h index e92babd669c2..b1f71a4894aa 100644 --- a/include/linux/of_reserved_mem.h +++ b/include/linux/of_reserved_mem.h @@ -32,6 +32,7 @@ typedef int (*reservedmem_of_init_fn)(struct reserved_mem *rmem); #define RESERVEDMEM_OF_DECLARE(name, compat, init) \ _OF_DECLARE(reservedmem, name, compat, init, reservedmem_of_init_fn) +void dt_init_reserved_mem(void); void fdt_init_reserved_mem(void); int of_reserved_mem_device_init_by_idx(struct device *dev, struct device_node *np, int idx); @@ -47,6 +48,8 @@ struct reserved_mem *of_reserved_mem_lookup(struct device_node *np); #define RESERVEDMEM_OF_DECLARE(name, compat, init) \ _OF_DECLARE_STUB(reservedmem, name, compat, init, reservedmem_of_init_fn) +static inline void dt_init_reserved_mem(void) { } + static inline void fdt_init_reserved_mem(void) { } static inline int of_reserved_mem_device_init_by_idx(struct device *dev, From patchwork Fri Jan 26 23:54:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oreoluwa Babatunde X-Patchwork-Id: 1891702 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=quicinc.com header.i=@quicinc.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=RcS0XWtL; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=139.178.88.99; helo=sv.mirrors.kernel.org; envelope-from=devicetree+bounces-35708-incoming-dt=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [139.178.88.99]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TMF9D2tq6z23fD for ; Sat, 27 Jan 2024 11:01:52 +1100 (AEDT) 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 2BD4228D110 for ; Sat, 27 Jan 2024 00:01:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E228665BB5; Fri, 26 Jan 2024 23:56:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="RcS0XWtL" X-Original-To: devicetree@vger.kernel.org Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (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 6F23063130; Fri, 26 Jan 2024 23:56:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706313369; cv=none; b=pYyBcPg3j3bjDnUghSv+0psnFvhlnFPi6rrvoWM9srG3XGIxUAeIF22VHGziXdtbbt2oB7UOe0F1DTGMOZq4yiD3zkFWpf9eRHE1XWPZVomJTYx0teJ+BdyIvB9LjFPWYwmyCsWlCJZerjp+pp5NhZrVGNrEsmtaYhywhTM9c28= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706313369; c=relaxed/simple; bh=4kE40rentgCzKkOcqUeGGTq5KdPNr9+7RUBnuYinc/A=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jrU2vIiUKCDzlR4LKJCwwX/1npydzPGqYRkna0ok2Hjt920gBB6reOuvW/SMgPFAk6DKuVWX3MSt8BK9rGc8QAGdXA/4Tha65qQoHK0jyyWy+4SPQdlaFOX1sVJn6s8NS403Dk4DZUPW/o3TIzZe1YUYXtWQ93zXTZFDEoWUSFM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=RcS0XWtL; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40QMoBpP016990; Fri, 26 Jan 2024 23:55:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=qcppdkim1; bh=NSJIpzRt23eV6cwLNaH4 bWRVS5c+2PsTe/XQM/ncC7Q=; b=RcS0XWtL768b2HlqXCg7qaVbfuHia+Sf8KoG sWcFqfiCM3xJY5b+Khh5WynJO8LX4v/KWbzbd4FCNC9ix8FVIMOo7KyEouGl3VQN XAUcfzS1HINpNPhxgaCDvMpiTG2DkR86j4M553RtOy76u94Q+E5UkKU1zje5J7TD NA9tDxQGLL1UXvjURO9pndNsONKVY/2EZx+Yoy8zgpNPFln1CFi0iVclYI75cw7T /pGtpruHJhQYqtSHLNylDrubfKSGQo5cF/JaNnvsHHwHT9xUxz3ks9N5H+30bF6b 3AkNx3rwQYvBf3RIC3CuaeA2bQ9joJqsW96ypEbDOB6HgBujlw== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vvfc8h027-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 26 Jan 2024 23:55:33 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 40QNtUwp018645 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 26 Jan 2024 23:55:32 GMT Received: from hu-obabatun-lv.qualcomm.com (10.49.16.6) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Fri, 26 Jan 2024 15:55:20 -0800 From: Oreoluwa Babatunde To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , Oreoluwa Babatunde Subject: [PATCH 46/46] of: reserved_mem: Delete the fdt_init_reserved_mem() function Date: Fri, 26 Jan 2024 15:54:25 -0800 Message-ID: <20240126235425.12233-47-quic_obabatun@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240126235425.12233-1-quic_obabatun@quicinc.com> References: <20240126235425.12233-1-quic_obabatun@quicinc.com> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 2QLwr9m8kGb_VZUlrTBCN69DQQNWIECu X-Proofpoint-ORIG-GUID: 2QLwr9m8kGb_VZUlrTBCN69DQQNWIECu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-25_14,2024-01-25_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxscore=0 adultscore=0 clxscore=1015 phishscore=0 malwarescore=0 spamscore=0 suspectscore=0 priorityscore=1501 bulkscore=0 mlxlogscore=449 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401190000 definitions=main-2401260176 Delete the fdt_init_reserved_mem() function as all architectures have been switched to using dt_init_reserved_mem(), which is basically a copy of the function, but uses the unflatten devicetree APIs instead of the fdt APIs. Signed-off-by: Oreoluwa Babatunde --- drivers/of/of_reserved_mem.c | 54 --------------------------------- include/linux/of_reserved_mem.h | 3 -- 2 files changed, 57 deletions(-) diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c index 3650efab0afd..3d1ab2325217 100644 --- a/drivers/of/of_reserved_mem.c +++ b/drivers/of/of_reserved_mem.c @@ -382,60 +382,6 @@ static void __init __rmem_check_for_overlap(void) } } -/** - * fdt_init_reserved_mem() - allocate and init all saved reserved memory regions - */ -void __init fdt_init_reserved_mem(void) -{ - int i, ret; - - ret = alloc_reserved_mem_array(); - if (ret) - pr_err("Failed to allocate memory for reserved_mem array with err: %d", ret); - - dt_scan_reserved_mem_reg_nodes(); - - /* check for overlapping reserved regions */ - __rmem_check_for_overlap(); - - for (i = 0; i < reserved_mem_count; i++) { - struct reserved_mem *rmem = &reserved_mem[i]; - struct device_node *node = rmem->dev_node; - int len; - const __be32 *prop; - int err = 0; - bool nomap; - - nomap = of_get_property(node, "no-map", NULL) != NULL; - prop = of_get_property(node, "phandle", &len); - if (!prop) - prop = of_get_property(node, "linux,phandle", &len); - if (prop) - rmem->phandle = of_read_number(prop, len/4); - - err = __reserved_mem_init_node(rmem); - if (err != 0 && err != -ENOENT) { - pr_info("node %s compatible matching fail\n", - rmem->name); - if (nomap) - memblock_clear_nomap(rmem->base, rmem->size); - else - memblock_phys_free(rmem->base, - rmem->size); - } else { - phys_addr_t end = rmem->base + rmem->size - 1; - bool reusable = - (of_get_property(node, "reusable", NULL)) != NULL; - - pr_info("%pa..%pa (%lu KiB) %s %s %s\n", - &rmem->base, &end, (unsigned long)(rmem->size / SZ_1K), - nomap ? "nomap" : "map", - reusable ? "reusable" : "non-reusable", - rmem->name ? rmem->name : "unknown"); - } - } -} - /** * dt_init_reserved_mem() - allocate and init all saved reserved memory regions */ diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h index b1f71a4894aa..dd67b9b2488e 100644 --- a/include/linux/of_reserved_mem.h +++ b/include/linux/of_reserved_mem.h @@ -33,7 +33,6 @@ typedef int (*reservedmem_of_init_fn)(struct reserved_mem *rmem); _OF_DECLARE(reservedmem, name, compat, init, reservedmem_of_init_fn) void dt_init_reserved_mem(void); -void fdt_init_reserved_mem(void); int of_reserved_mem_device_init_by_idx(struct device *dev, struct device_node *np, int idx); int of_reserved_mem_device_init_by_name(struct device *dev, @@ -50,8 +49,6 @@ struct reserved_mem *of_reserved_mem_lookup(struct device_node *np); static inline void dt_init_reserved_mem(void) { } -static inline void fdt_init_reserved_mem(void) { } - static inline int of_reserved_mem_device_init_by_idx(struct device *dev, struct device_node *np, int idx) {