From nobody Mon Feb 9 09:32:42 2026 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 7E540335067 for ; Mon, 26 Jan 2026 12:26:50 +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=1769430413; cv=none; b=l2ojB0tT9et34hJXks4DrjcZqdMMelhNnj1+6gupHaXRBFMtj3RIIIVLR2G9LEmDCqSkxj+hJ5ln0o3XNsmLsoyF/bFOLb/gI6Q3P9FokuvsFNYGBL2PdXSbIMsgbF4qDaKj0LG9hqIrfGjVNinIHWyaQTV8iAAGzMwagn8qFzo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769430413; c=relaxed/simple; bh=IqJsRexS/6twiyjUn6Ip0MjRVU5qD6SvEyWdsCIv7Ak=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fWoc+gUf9Q6d1odCjMybqmQzYuQJerXNBohBbwIhXvuQoueB+YyZN1FiCzfdcDCVHI1Hjq0lW8Kh6EczFAJ9zN80hTtJ/6RVBZ5jsXupS0hcGR/OkEC6ViIUXWDT/0wiq8XHlow6cfEWUg0smh6kJpl5Nws2axWJclIqr1OqgKE= 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=MKmoR3Gw; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=JzOsdHID; arc=none smtp.client-ip=205.220.168.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="MKmoR3Gw"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="JzOsdHID" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 60Q8j3YD2279683 for ; Mon, 26 Jan 2026 12:26:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= pVCkh/W6bHIxppZtdEhqPaJQn9q3J1ln2hdlI6R74MI=; b=MKmoR3GwMLta2QG6 7ouqrxlRyeLGJRWZ1YoNshe9RR2Km53S990v6p0oeNU1f046/1wcci0o4gCkJjta xJU8K+/QVcrIniRtpN04e2DmDBtIxveg57oouRcbxnrRy1ATUeCQspKrteb9OmPJ 6i24yJOk69yw+RdWl8m7G5xq0Iknyf/kIUZ+ymfvMYNNwnxDLmJiUvh7s115dw33 FGQ0o9eeiK5Qjvw5l/Do5B/ISV9YS2ksI2Nnoof2vw2WOgNaGZjk4s0D4JXkyF16 OH7uXj7WUDwO96Ywger38BM2RNYPrq9YSgV1Z0lGOv+PlhsiMAPOz6pGfzQXM2bD oPJ2zQ== Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4bvq8dmgy3-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 26 Jan 2026 12:26:49 +0000 (GMT) Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-34c704d5d15so8183110a91.1 for ; Mon, 26 Jan 2026 04:26:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1769430407; x=1770035207; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=pVCkh/W6bHIxppZtdEhqPaJQn9q3J1ln2hdlI6R74MI=; b=JzOsdHIDkHjBSkqyTpJCxUuvrM1um2b0DyP6i0Ok7fvr+9Kcm7Uw9Zbv5Vxtejdjzj AdTtRad5bvzmA5NnYFeX6sgN/psvnzxPfsS8C8hh+MVEvgFfzjZK3Z24oyOivdrjY63r 5eJZ1k7hzpMyzxCZL7ZupdU7WdbHCsf+kemj9CqWUx4Qltdlq7X/tMCLXinSBv8IP/kq FuvyZZjKP8WcHvKQ/fc8UxS5y4Br31YrCzN6PxEj9GALp4Jc3qfKo8Ecl+L9dr3GLOTQ FyCOeP7hdT21rjgqCs7KxlB1dB4MQdSVAoFc3Rq2hcHBTLLOm1tZXAtsu2b0SuyuPsbu XY7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769430407; x=1770035207; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=pVCkh/W6bHIxppZtdEhqPaJQn9q3J1ln2hdlI6R74MI=; b=c04+pFeoGhSlD/0M42tFzjgt7MVYDaH+HITptgupUVBGHKn7Ker5zjd950+5GpW6sA vTqEkkD11/+JsL8lQVUwJ7IaLw8kd2xDz2o4fS9JIcbyn8OjBlJ1TZXg3OZfpEQoD8Gc nAX5cQqJJJuFulhrOm+vEVOJYbRWV7TZxeBeynlX/GS1IlWv/R7O/UFn+IVxQzHwQQ7E NOBNge8fKwYUp+AsCaXRNoliEYcLgH4rQ/cwUzEny70Ig8RgT/SQro6ShmjVrSOHgFzU 5wsCUsgb33Iaf66eqa4JU70HTEy6RmyTouX7IeeV9dtAqQehrTtYndAgVDB7/6P9iAAc uH2g== X-Forwarded-Encrypted: i=1; AJvYcCXsuXOFWO4zmmKDac6GC8c+3VbiJlfH4guzj2tlMPHsNGu8vP+m+zhfT4qwqwkEqHcPKW5bqPyss+aIUEU=@vger.kernel.org X-Gm-Message-State: AOJu0YxF3GSJWNuu9WooY2qKeBxANCQRlVWIqZ7eWD6jg+d50cSU+qf3 7E646tDMSGk//hENppdxfued3rAJWOC+uHVCJaLNxN3viar2WNdFPXNlnHhYTb0MvB8VfG8kYzL G58jgaL3KH1qSoHoJ2UWNdj5tHc0DTxUCijEoPlvm9YuTbyr++B0icJ5/x0yNcF1ERJg= X-Gm-Gg: AZuq6aK/o2++Km0BhvrQTMv/5gA6LbNxCnqp7lDNJthYTv4KMkTfkmfTOJ1e8mTBcNp hpCyRQW8yY1JHqnoCSe/D1W1hG45RhL3JtKxBmEzLNTJGgVc9bWzkNByA6K9o5c5PQX+m5/Lw+6 CLZ5cElWTIfyUoFZkSvHyN8r2BglaZnlckaxd4zMIbPPActqIMrpkKt1a8K2oz6+C8kNC1GfQ2N O0BYUb8WW55qqohaPXazNZJ8o0mczCwZ1c/VvdNJRrbVNAOo3Jn46Y4rC/xTKhsrMXD6lMYdAiQ 0TYOhb5VYnLpThqrGPpHQYcAl4cepKyfPc0oKkIGcFllea0V+TMctDgLR0//A3UEocgw+kI8dac 7Wu1I3u+ukN8GGSpNAoBdQQb3alBB+4NR8CCYP4j75G1l X-Received: by 2002:a05:6a21:9082:b0:38b:e944:3e94 with SMTP id adf61e73a8af0-38e9f2853c7mr3680232637.39.1769430406954; Mon, 26 Jan 2026 04:26:46 -0800 (PST) X-Received: by 2002:a05:6a21:9082:b0:38b:e944:3e94 with SMTP id adf61e73a8af0-38e9f2853c7mr3680213637.39.1769430406447; Mon, 26 Jan 2026 04:26:46 -0800 (PST) Received: from hu-vgarodia-hyd.qualcomm.com ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c6366644379sm6076022a12.33.2026.01.26.04.26.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jan 2026 04:26:45 -0800 (PST) From: Vikash Garodia Date: Mon, 26 Jan 2026 17:55:46 +0530 Subject: [PATCH 3/7] of/iommu: add multi-map support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260126-kaanapali-iris-v1-3-e2646246bfc1@oss.qualcomm.com> References: <20260126-kaanapali-iris-v1-0-e2646246bfc1@oss.qualcomm.com> In-Reply-To: <20260126-kaanapali-iris-v1-0-e2646246bfc1@oss.qualcomm.com> To: Dikshita Agarwal , Abhinav Kumar , Bryan O'Donoghue , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Saravana Kannan , Joerg Roedel , Will Deacon , Robin Murphy , Stefan Schmidt , Hans Verkuil , Krzysztof Kozlowski , Vishnu Reddy , Hans Verkuil Cc: linux-arm-msm@vger.kernel.org, linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux.dev, Bryan O'Donoghue , Vikash Garodia , Charan Teja Kalla , Vijayanand Jitta X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1769430381; l=6265; i=vikash.garodia@oss.qualcomm.com; s=20241104; h=from:subject:message-id; bh=EUkaNWa1MVcCxEdOynQtZlG6RF2qb9JysfZNRjrcwmA=; b=hkULUopyIT1ZocwCpTifqAIj8RNy7i9ZYw7+k3+dPNzOWShp4cRUCIJ1vuWPWmD/tBaRW/bhO vogZYGvX3WIDylxFZDGanvOPh9o6JBGQqHrETtLMF1xhjZwksaFX4s8 X-Developer-Key: i=vikash.garodia@oss.qualcomm.com; a=ed25519; pk=LY9Eqp4KiHWxzGNKGHbwRFEJOfRCSzG/rxQNmvZvaKE= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMTI2MDEwNSBTYWx0ZWRfX/houlRrBMrcR BF6dmaylaqz5lPU0Ca+zHCva9tIY87zTHyu+HRSVfuJ1WHUJLDV0FbJ93RFwyI+qrGA1DUJIBPs TJs/FzBuAJyNEaHqk7ey2LAtwhwbf2v6YF72z073ISLm83UQYta7OzIIulamWJLhYGnLZR/Kv+n apyavAfv7dvvzl5l+FEC/WW21DzvqiR8C1YCXV1/jzGJQb/tA3rAFDuAEPT36dwzYHEAmW6uWdm 9m2ZrgrKX8vHF7ToQ0pOZkXrH+LqTAZIaSBNDFcW0cX7pokmMxo7ysXoarDN/P3YxscMPqNq2AM sU/QhRhwfKe8X/aCX4wm6TMXtSr2bTJvVFhXox3ZBM6Y4HzbFu1l8jZ7mSsItSCypOWc0F1MQ/Z RqHK/D26kDaN0vUi484AaCGxlqLYiYsi4hmWBhJ5GdtJmBXt5Yms6ujeXQxEJJ6pGG8PIVCaDfD a8S6LDOSXxkNYTiaEVg== X-Authority-Analysis: v=2.4 cv=RIq+3oi+ c=1 sm=1 tr=0 ts=69775d89 cx=c_pps a=UNFcQwm+pnOIJct1K4W+Mw==:117 a=ZePRamnt/+rB5gQjfz0u9A==:17 a=IkcTkHD0fZMA:10 a=vUbySO9Y5rIA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=VwQbUJbxAAAA:8 a=COk6AnOGAAAA:8 a=EUspDBNiAAAA:8 a=vJTt6mY4ybVYvk96TFUA:9 a=QEXdDO2ut3YA:10 a=uKXjsCUrEbL0IQVhDsJ9:22 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-ORIG-GUID: CI2yFnFRqVLPB2Tv4D6Z6IR4YmaaPZoW X-Proofpoint-GUID: CI2yFnFRqVLPB2Tv4D6Z6IR4YmaaPZoW X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.20,FMLib:17.12.100.49 definitions=2026-01-26_02,2026-01-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 adultscore=0 clxscore=1015 phishscore=0 impostorscore=0 lowpriorityscore=0 spamscore=0 suspectscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2601260105 From: Charan Teja Kalla When multiple mappings are present for an input id, linux matches just the first one. There is a usecase[1] where all the mappings are to be maintained in parallel for an iommu-map entry of a same input id. Whether multi-map is needed is reported by the callers through the callback function passed, which is called for every input id match. Since the requirement in the usecase[1] is for platform devices, not sure if it is really clean to maintain this decision on the bus type at the of_iommu layer or further to be from the respective iommu_driver->impl_ops(). [1] https://lore.kernel.org/all/20250627-video_cb-v3-0-51e18c0ffbce@quicinc= .com/ Signed-off-by: Charan Teja Kalla Signed-off-by: Vijayanand Jitta Signed-off-by: Vikash Garodia --- drivers/iommu/of_iommu.c | 36 ++++++++++++++++++++++++++++-------- drivers/of/base.c | 38 ++++++++++++++++++++++++++++---------- include/linux/of.h | 6 ++++++ 3 files changed, 62 insertions(+), 18 deletions(-) diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c index 768eaddf927b0700b2497b08ea21611b1a1b5688..067bb2298973671e1eaf01bb2ea= 52df3d2a52a44 100644 --- a/drivers/iommu/of_iommu.c +++ b/drivers/iommu/of_iommu.c @@ -16,6 +16,7 @@ #include #include #include +#include =20 #include "iommu-priv.h" =20 @@ -41,22 +42,41 @@ static int of_iommu_xlate(struct device *dev, return ret; } =20 +/* + * Callback to be called from of_map_id(), that tells if + * all the mappings for an input id to be maintained in + * parallel. Should this decission be from further layers, + * iommu_driver->impl_ops? + */ +static int of_iommu_configure_cb(struct of_map_id_arg *arg) +{ + struct of_phandle_args *iommu_spec =3D &arg->map_args; + struct device *dev =3D arg->dev; + int err; + + err =3D of_iommu_xlate(dev, iommu_spec); + of_node_put(iommu_spec->np); + + /* !iommu_spec->np may be from the bypassed translations */ + if (!err) + err =3D (!arg->multi_map || !iommu_spec->np) ? 0 : -EAGAIN; + + return err; +} + static int of_iommu_configure_dev_id(struct device_node *master_np, struct device *dev, const u32 *id) { struct of_map_id_arg arg =3D { .map_args =3D {}, + .cb =3D of_iommu_configure_cb, + .dev =3D dev, + /* Should this be pushed to iommu_driver->impl_ops? */ + .multi_map =3D dev_is_platform(dev), }; - int err; - - err =3D of_map_iommu_id(master_np, *id, &arg); - if (err) - return err; =20 - err =3D of_iommu_xlate(dev, &arg.map_args); - of_node_put(arg.map_args.np); - return err; + return of_map_iommu_id(master_np, *id, &arg); } =20 static int of_iommu_configure_dev(struct device_node *master_np, diff --git a/drivers/of/base.c b/drivers/of/base.c index 606bef4f90e7d13bae4f7b0c45acd1755ad89826..a1c3c5954ec7e8eb3753c8fd782= a1570f9eb9c17 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -2122,14 +2122,21 @@ static bool of_check_bad_map(const __be32 *map, int= len) return true; } =20 -static int of_map_id_fill_output(struct of_map_id_arg *arg, - struct device_node *phandle_node, u32 id_or_offset, - const __be32 *out_base, u32 cells, - bool bypass) +/* + * Fill the id_out and target for the of_map_id() caller. Also + * call the callback passed to the of_map_id() as part of the arg + * that decides if to continue further search. + */ +static int of_map_id_fill_arg(struct of_map_id_arg *arg, + struct device_node *phandle_node, u32 id_or_offset, + const __be32 *out_base, u32 cells, + bool bypass, bool *multi_id_map) { + int ret; + if (bypass) { arg->map_args.args[0] =3D id_or_offset; - return 0; + goto output; } =20 if (arg->map_args.np) @@ -2145,7 +2152,14 @@ static int of_map_id_fill_output(struct of_map_id_ar= g *arg, =20 arg->map_args.args_count =3D cells; =20 - return 0; +output: + /* pass the output for the callback, callers may further decide */ + ret =3D arg->cb ? arg->cb(arg) : 0; + + if (multi_id_map && ret =3D=3D -EAGAIN) + *multi_id_map =3D true; + + return ret; } =20 /** @@ -2179,6 +2193,7 @@ int of_map_id(const struct device_node *np, u32 id, c= onst char *map_name, int map_bytes, map_len, offset =3D 0; bool bad_map =3D false; const __be32 *map =3D NULL; + bool multi_id_map =3D false; =20 if (!np || !map_name || !arg) return -EINVAL; @@ -2264,23 +2279,26 @@ int of_map_id(const struct device_node *np, u32 id,= const char *map_name, if (masked_id < id_base || id_off >=3D id_len) continue; =20 - ret =3D of_map_id_fill_output(arg, phandle_node, id_off, out_base, cells= , false); + ret =3D of_map_id_fill_arg(arg, phandle_node, id_off, out_base, + cells, false, &multi_id_map); if (ret =3D=3D -EAGAIN) continue; =20 pr_debug("%pOF: %s, using mask %08x, id-base: %08x, out-base: %08x, leng= th: %08x, id: %08x -> %08x\n", np, map_name, map_mask, id_base, be32_to_cpup(out_base), id_len, id, id_off + be32_to_cpup(out_base)); - return 0; + return ret; } =20 + if (multi_id_map) + return 0; + pr_info("%pOF: no %s translation for id 0x%x on %pOF\n", np, map_name, id, arg->map_args.np ? arg->map_args.np : NULL); =20 bypass_translation: /* Bypasses translation */ - return of_map_id_fill_output(arg, NULL, id, 0, 0, true); - + return of_map_id_fill_arg(arg, NULL, id, 0, 0, true, NULL); err_map_len: pr_err("%pOF: Error: Bad %s length: %d\n", np, map_name, map_bytes); return -EINVAL; diff --git a/include/linux/of.h b/include/linux/of.h index 9efa6f93712c6024f05476f9fd39f3294f942ec1..abab73a76682351f5635c1127a6= c899917525050 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -25,6 +25,9 @@ typedef u32 phandle; typedef u32 ihandle; =20 +struct of_map_id_arg; +typedef int (*of_map_id_cb)(struct of_map_id_arg *arg); + struct property { char *name; int length; @@ -76,6 +79,9 @@ struct of_phandle_args { =20 struct of_map_id_arg { struct of_phandle_args map_args; + of_map_id_cb cb; + struct device *dev; + bool multi_map; }; =20 struct of_phandle_iterator { --=20 2.34.1