From nobody Mon Oct 6 15:18:15 2025 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 E5ABF1DE89A for ; Fri, 18 Jul 2025 23:45:45 +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=1752882347; cv=none; b=hB6Eyx/RKHRNCnTTTkx+5BXerGnO4nkaYKEqJL/0b7V1Lm3E6MpdRzZ1Hje5jz0KET2EHlwUtzl+VLjmjLO/0CjWjkCPBXj8uFRhvsT53Qwp2/GV4boYMIzRzsbX7Qo+L1nFHWjvqzsTgfSjZvU2LRPUbWLSt2+3uz3fdY4MbiI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752882347; c=relaxed/simple; bh=0QofGAQMlO59BDn/yqU3QVVC/RYdZi+Gp9Dmsqgt9no=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=oz8Wb3KpU1ajbUHqk9tyM7zdi8RorwXsI8FOhpxLJVXSuhvGzfFjbE+C1bBL+0liJdsHUn5eASpBZO2IGP7YTiwUuYZJQHmTX+d84JhnLhY1rMtOOyfuJ0ySxjKExoWw19nom4O9tApJOuATjTFxmrAOOwCqxG1U5SXCABQLdmw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=bhqyBXRq; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="bhqyBXRq" Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56IHOJ7c025177 for ; Fri, 18 Jul 2025 23:45:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:message-id:mime-version :subject:to; s=qcppdkim1; bh=s2hFRW8d2TuQIx351Ymt58JAKUkqRkGljpI 9CEDds04=; b=bhqyBXRqUtfPDZYNBh98+vqUDh9jRs/az8ULa3WMqEBqXNLRZz+ l1kik6UNgg8nXFJtzneh43bfY8YBrrWMTXyHonxY2JKNzDxf3q9Xa3qvHjZKZjFi YPh6jQRVLNVOb51s/TezaVqZT498BMZIYnSzkcxJFxpN7c9ESPwsEYz/9hXSoHq7 bUSiyei4uBbSf0AHmRT5mpCk9hx2XCsgNX8tUUfa0aJ97DlHfN9koEacdx7BtGW9 B9R7U94ODEzqTlddwl9hlb/Z73+FBd7YcIdeFoPiFNdh0Dn5+uB4+JW6zWUYjgCD WGumBI/xK1WqLhQUPTUd8Xr/Px1vdZMPfYg== Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 47xbsqhcd8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Fri, 18 Jul 2025 23:45:44 +0000 (GMT) Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-311d670ad35so2444027a91.3 for ; Fri, 18 Jul 2025 16:45:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752882343; x=1753487143; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject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jT7dANRTEMaizMYgpQm6fc3V7XZck3Ocke+RLACbTxfw/a55Mq 4plrmnOv7CJMdAVQLTtsVwx8sKjY= X-Received: by 2002:a17:90b:4985:b0:311:ea13:2e63 with SMTP id 98e67ed59e1d1-31c9f47c919mr16443474a91.13.1752882343121; Fri, 18 Jul 2025 16:45:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGqKxGq9Un3H1awITtkW+25JkbHdED47p+uP+qJy4C8O68xs8XewgumeJVAl/pe8tZ0gC+WEQ== X-Received: by 2002:a17:90b:4985:b0:311:ea13:2e63 with SMTP id 98e67ed59e1d1-31c9f47c919mr16443441a91.13.1752882342583; Fri, 18 Jul 2025 16:45:42 -0700 (PDT) Received: from hu-obabatun-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-31c9f29e424sm5975609a91.40.2025.07.18.16.45.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jul 2025 16:45:41 -0700 (PDT) From: Oreoluwa Babatunde To: robh@kernel.org, m.szyprowski@samsung.com, robin.murphy@arm.com Cc: saravanak@google.com, quic_obabatun@quicinc.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux.dev, william.zhang@broadcom.com, kernel@oss.qualcomm.com, will@kernel.org, djakov@kernel.org, Oreoluwa Babatunde Subject: [PATCH v2] of: reserved_mem: Restructure call site for dma_contiguous_early_fixup() Date: Fri, 18 Jul 2025 16:45:04 -0700 Message-Id: <20250718234504.2702128-1-oreoluwa.babatunde@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Analysis: v=2.4 cv=ad1hnQot c=1 sm=1 tr=0 ts=687adca8 cx=c_pps a=vVfyC5vLCtgYJKYeQD43oA==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=Wb1JkmetP80A:10 a=EUspDBNiAAAA:8 a=d8epbNILfmFvmG3XuFMA:9 a=rl5im9kqc5Lf4LNbBjHf:22 X-Proofpoint-ORIG-GUID: IUV7KuOsRe3g5-qKjUg7dyNIcimY5t7S X-Proofpoint-GUID: IUV7KuOsRe3g5-qKjUg7dyNIcimY5t7S X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzE4MDE5NyBTYWx0ZWRfX+51QJ/5MBWSx mSGHFmUJq2hMHLKlltOf54oyIvnc/cJYnE4xzrMvtK53sUbzghv9k8eKtuPII+SLupQdvikFhLq /uYtrCLkzdkJOZ8ZYAyerFJ9hpNP8wB/V/DM/vM63woA6pkQGpK4NBtTJMwLWv6UGGJfrpOOlT0 vswOGhq+Yxg3ynvLMz3aARI49mz2Wtr7uILmZVsqSI/E0k+RxamDofTVUr8WtDzit2smZMDvIvc xC83LxwDdC6FHk65GkPiF8T8IHlPorGjJjUImDPKDeSJf5FAooIIDe1dPthdxEPTsKCOfI08MIe quy7e5LLjfJQbUTE7fwrqGqTVbQE+HrZXkQFzjYYrhQ7aPwYS0HnEMPmNe6Q4ss9Exl66YiemvZ gEChlPiSAJFPoz95rbtzNWqq0PnF9Dub5CyzPtfmDGOtnYb7aqnngznbn1AOkSrtW2Qr20uC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-07-18_05,2025-07-17_02,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 bulkscore=0 mlxlogscore=625 suspectscore=0 spamscore=0 malwarescore=0 phishscore=0 mlxscore=0 lowpriorityscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507180197 Content-Type: text/plain; charset="utf-8" Restructure the call site for dma_contiguous_early_fixup() to where the reserved_mem nodes are being parsed from the DT so that dma_mmu_remap[] is populated before dma_contiguous_remap() is called. Fixes: 8a6e02d0c00e ("of: reserved_mem: Restructure how the reserved memory= regions are processed") Signed-off-by: Oreoluwa Babatunde Tested-by: William Zhang --- v2: Add a check for the "reusable" property to narrow things down to only cma regions. Also add __weak function definition for dma_contiguous_early_fixup() to avoid compile errors on architectures that do not define the function. drivers/of/of_reserved_mem.c | 21 ++++++++++++++++++--- kernel/dma/contiguous.c | 2 -- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c index 77016c0cc296..eee96172883a 100644 --- a/drivers/of/of_reserved_mem.c +++ b/drivers/of/of_reserved_mem.c @@ -25,6 +25,7 @@ #include #include #include +#include =20 #include "of_private.h" =20 @@ -147,6 +148,11 @@ static int __init early_init_dt_reserve_memory(phys_ad= dr_t base, return memblock_reserve(base, size); } =20 +void __weak +dma_contiguous_early_fixup(phys_addr_t base, unsigned long size) +{ +} + /* * __reserved_mem_reserve_reg() - reserve all memory described in 'reg' pr= operty */ @@ -175,13 +181,18 @@ static int __init __reserved_mem_reserve_reg(unsigned= long node, base =3D dt_mem_next_cell(dt_root_addr_cells, &prop); size =3D dt_mem_next_cell(dt_root_size_cells, &prop); =20 - if (size && - early_init_dt_reserve_memory(base, size, nomap) =3D=3D 0) + if (size && early_init_dt_reserve_memory(base, size, nomap) =3D=3D 0) { + /* Architecture specific contiguous memory fixup. */ + if (of_flat_dt_is_compatible(node, "shared-dma-pool") && + of_get_flat_dt_prop(node, "reusable", NULL)) + dma_contiguous_early_fixup(base, size); + pr_debug("Reserved memory: reserved region for node '%s': base %pa, siz= e %lu MiB\n", uname, &base, (unsigned long)(size / SZ_1M)); - else + } else { pr_err("Reserved memory: failed to reserve memory for node '%s': base %= pa, size %lu MiB\n", uname, &base, (unsigned long)(size / SZ_1M)); + } =20 len -=3D t_len; } @@ -472,6 +483,10 @@ static int __init __reserved_mem_alloc_size(unsigned l= ong node, const char *unam uname, (unsigned long)(size / SZ_1M)); return -ENOMEM; } + /* Architecture specific contiguous memory fixup. */ + if (of_flat_dt_is_compatible(node, "shared-dma-pool") && + of_get_flat_dt_prop(node, "reusable", NULL)) + dma_contiguous_early_fixup(base, size); =20 /* Save region in the reserved_mem array */ fdt_reserved_mem_save_node(node, uname, base, size); diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c index 67af8a55185d..d9b9dcba6ff7 100644 --- a/kernel/dma/contiguous.c +++ b/kernel/dma/contiguous.c @@ -483,8 +483,6 @@ static int __init rmem_cma_setup(struct reserved_mem *r= mem) pr_err("Reserved memory: unable to setup CMA region\n"); return err; } - /* Architecture specific contiguous memory fixup. */ - dma_contiguous_early_fixup(rmem->base, rmem->size); =20 if (default_cma) dma_contiguous_default_area =3D cma; --=20 2.34.1