From nobody Wed Oct 1 21:24:19 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 1996B1494C3; Sun, 28 Sep 2025 17:17:42 +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=1759079866; cv=none; b=HnRN5vq72E5M6zZ7YHEX1TB8c7wFskws05YWhnfaMcwx5QwTzayicxxSdL3ftCu3bJa2+hg/ZexytLlXMKiUfrcXRyg7riyGV2qJgIVFv4xD31G8bvb+t7Q9iGY3WfZJCvCtjlAo1Te9DPljqazK3OMzPoj204yJuuPxywb/Z9I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759079866; c=relaxed/simple; bh=RKt8X/sSTr+X/Cyf0/C/CjKHNv4US7rI7/NlClK1Gno=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rLtxu9dpK+A9mIk6X++WtAlXTXYqwjl40vGt+dp+ANyzwfEzE9+o3LVzMwZfK7ANSGmnsHsThJ8Kx232oz6fFIlLReZNCnDo45F3FvgCqNxo44zrO1wDpiOcyR3HXVoHvxEQK8aeBYxvkzECRYGxmgZ2gXMmcbQ5OOYs0kE4POA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=hb+yuxZx; 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=qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="hb+yuxZx" Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 58RNawg0008082; Sun, 28 Sep 2025 17:17:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=TFPCPT2+TyI J7MrYwRgn5gPa6YwlFTTqsD8arExCj+Q=; b=hb+yuxZxJTjTmC48FXh92vkaPh3 VNJjhALYP6XG1X4vT0UCkQJ+r0zxPHoFcSIFN3Tr2tY2lqOlcd4zfnY0MLzj4h6+ TU5/ABYEUUu6nn4IfOvZKE6rWYNlLmGZHv1YnLTRNHGMIUFdB8gnwWnyV6JaQLcz oxDK790qzIaRHXYpJfwuTzPTN7uX4l6rTpjAKbHgin64edTlbhTK6X3QjBJCZfit qIS3Q6edIg78peO0X+256hDGNw4jQUi6rLFWDOZDzte77duhJbDDazXaVJPbZINI /f2VAUxOThID8mWqChc9OBu+pLm6LwS7YLMQDYKjSnh1wNxpNI9JxNkNwPA== Received: from apblrppmta01.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 49e8a5u0d5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 28 Sep 2025 17:17:26 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTP id 58SHHMT0018673; Sun, 28 Sep 2025 17:17:22 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 49e90k74pb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 28 Sep 2025 17:17:22 +0000 Received: from APBLRPPMTA01.qualcomm.com (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 58SHHM1V018652; Sun, 28 Sep 2025 17:17:22 GMT Received: from hu-devc-hyd-u22-c.qualcomm.com (hu-charante-hyd.qualcomm.com [10.213.97.134]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 58SHHMuI018646 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 28 Sep 2025 17:17:22 +0000 Received: by hu-devc-hyd-u22-c.qualcomm.com (Postfix, from userid 389980) id 33AC955D; Sun, 28 Sep 2025 22:47:21 +0530 (+0530) From: Charan Teja Kalla To: joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, saravanak@google.com, conor+dt@kernel.org, robh@kernel.org, mchehab@kernel.org, bod@kernel.org, krzk+dt@kernel.org, abhinav.kumar@linux.dev, vikash.garodia@oss.qualcomm.com, dikshita.agarwal@oss.qualcomm.com Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux.dev, Charan Teja Kalla Subject: [RFC PATCH 1/3] dtbindings: add binding for iommu-map-masked property Date: Sun, 28 Sep 2025 22:47:16 +0530 Message-Id: <20250928171718.436440-2-charan.kalla@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250928171718.436440-1-charan.kalla@oss.qualcomm.com> References: <20250928171718.436440-1-charan.kalla@oss.qualcomm.com> 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-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Authority-Analysis: v=2.4 cv=RZKdyltv c=1 sm=1 tr=0 ts=68d96da6 cx=c_pps a=Ou0eQOY4+eZoSc0qltEV5Q==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17 a=yJojWOMRYYMA:10 a=NEAV23lmAAAA:8 a=EUspDBNiAAAA:8 a=xsS8FE68tDUPogoBysgA:9 a=cPQSjfK2_nFv0Q5t_7PE:22 X-Proofpoint-GUID: QEwDG_Z7gloP8JqZ8We2oFNxGWZGn16V X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwOTI3MDAzMyBTYWx0ZWRfX8mgnaNQSdOqk Bv20+LeFSB0AogyVrKK/fvI/9N+SKs3NBxkUGBikioBLTw/CkRnBjhteFwGo2He/uiIeOnB3Dyf wuxJ6amhIltxXI+he/zNjepcm2OAi8s0Fl/QPD/h483aYdtMdMQJaLAeX6+qfUC1ohBLR4bJf5Z 5NqSSLqzN/GpmijIfxJ7TTRoAdwmRhnrIoubcyP6+YT4gIb+u7KgFX1hBn2x9IMCxoOT0//O+Z2 zepdAmNuvwYN/Czf/AM+locg5AuYxzMrOgjF5MFERXtEYMhD7LJZNgm5y2Z1/mF8knA/3jG5zLf TqjJLd9UfneGAtYaxRpAGjfChKduh4l5gfoNRYesb/PnJ842GxYuWYSZwgESLK2/ltwUKeRBeQb kWphILk+2eLrHnhBn/2W+Ww/4UoGYg== X-Proofpoint-ORIG-GUID: QEwDG_Z7gloP8JqZ8We2oFNxGWZGn16V X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1117,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-09-28_07,2025-09-26_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 malwarescore=0 priorityscore=1501 adultscore=0 phishscore=0 impostorscore=0 spamscore=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2509150000 definitions=main-2509270033 Content-Type: text/plain; charset="utf-8" Add bindings for iommu-map-masked property, which is used to represent the IOMMU specifier pairs for each function of a multi-functional platform device, where each function can emit unique master id that can be associated with individual translation context. It contains syntax as below: iommu-map-masked =3D , ; The right place for this binding to go is [1], but posting it here as this is RFC. Please ignore the other concerns like ABI breakage, running dt schema e.t.c. [1] https://github.com/devicetree-org/dt-schema/blob/main/dtschema/schemas/= iommu/iommu.yaml Signed-off-by: Charan Teja Kalla --- .../bindings/media/qcom,sm8550-iris.yaml | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/media/qcom,sm8550-iris.yaml = b/Documentation/devicetree/bindings/media/qcom,sm8550-iris.yaml index 9c4b760508b5..9940a3d7b8f9 100644 --- a/Documentation/devicetree/bindings/media/qcom,sm8550-iris.yaml +++ b/Documentation/devicetree/bindings/media/qcom,sm8550-iris.yaml @@ -75,7 +75,7 @@ properties: - const: core =20 iommus: - maxItems: 2 + maxItems: 1 =20 dma-coherent: true =20 @@ -87,6 +87,20 @@ properties: opp-table: type: object =20 + iommu-map-masked: + $ref: /schemas/types.yaml#/definitions/uint32-array + description: + Maps function IDs to IOMMU specifiers for multi-functional devices, + and each function requires its own address space/translation context. + + Each entry contains:- + a) Function - ID Identifier for the device function. + b) IOMMU phandle - Identifier for iommu. + c) Arguments - arguments representing iommu handle. + + items: + maxItems: 4 + required: - compatible - power-domain-names @@ -96,6 +110,7 @@ required: - reset-names - iommus - dma-coherent + - iommu-map-masked =20 allOf: - if: @@ -116,6 +131,16 @@ allOf: reset-names: maxItems: 1 =20 + - if: + properties: + iommu-map-masked: true + then: + not: + anyOf: + - required: [iommu-map] + description: + iommu-map-masked is mutually exclusive with iommu-map property. + unevaluatedProperties: false =20 examples: @@ -156,8 +181,8 @@ examples: resets =3D <&gcc GCC_VIDEO_AXI0_CLK_ARES>; reset-names =3D "bus"; =20 - iommus =3D <&apps_smmu 0x1940 0x0000>, - <&apps_smmu 0x1947 0x0000>; + iommus =3D <&apps_smmu 0x1940 0x0000>; + iommu-map-masked =3D <0x0 &apps_smmu 0x1947 0x0000>; dma-coherent; =20 operating-points-v2 =3D <&iris_opp_table>; --=20 2.34.1 From nobody Wed Oct 1 21:24:19 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 B639C1494C3; Sun, 28 Sep 2025 17:17:52 +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=1759079874; cv=none; b=u3tSHZdZuP9awJE9E8yhvpKBKRSbb/Kr/4aTVzkKQDYZEYaWxXzykEFKc3nGrYhwFYr7f8qZja4xwsddX6mB3M+gS6vvcKqryHlxivo0xOkT1xvLpi19ZSAVF7FwV+kjBZgrpBRO8zeBvtNOUfaKK9s6gKuq3I73+p9pn1CQ1Z8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759079874; c=relaxed/simple; bh=5RBuK09EVOyYkXHD4zvVywFmut3grmLymlPS2wQ9/w4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NyHZ50OaBpaZnOeNApojBqwWlYS1cxlZFOanBN305o4dYXSIzFrlljn4+YjqBq90m2FHOWI9cHe/FMzzxs6mn5zCjoGHPvSi9JNwcKriXSzWzrwwMLChpAdFKR0DvapMo/5okmg3Ph5l4PDNcHzblAYCVSpFfA5vgC8Iq97NeIg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=C914esgf; 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=qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="C914esgf" Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 58SGrFB7024946; Sun, 28 Sep 2025 17:17:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=4IP0H+KM2Y8 li2p4r3BV6jUlQlBH4IbPQPuiqrFVGg0=; b=C914esgfNmzSqK6Uo+D9Cbk5zhn wOvYmNamRC6npqNRgkdUWUt9kjOCPTlX0nUy/nnwOkMCEhWMlCfGEkun91ZmPcSX yUVqSAE0LBY92rSlys44ir66wiAGQxsry+C3Z5dy1TtctMTAgRzki0uQHxDNCDu+ YNKDBIq1Yi6CO8WBYB/lKwDcvDlsbopKT/2E4fUQYy4J4MPe7CMgvzudkiwEEx4V uaCiTmuxTCGGlvoYWBLshKAUokOVcPhg7d1yYvuuDmPJjE6h61s5uLChyWIvGW20 lTvQJmA8tWY/a97EWRsIL5PLslP6RFVOVZNxwLd0whQLXwm4EmPZSrSPbcA== Received: from apblrppmta01.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 49e78fu30w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 28 Sep 2025 17:17:26 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTP id 58SHHM87018671; Sun, 28 Sep 2025 17:17:22 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 49e90k74pe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 28 Sep 2025 17:17:22 +0000 Received: from APBLRPPMTA01.qualcomm.com (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 58SHHMRw018653; Sun, 28 Sep 2025 17:17:22 GMT Received: from hu-devc-hyd-u22-c.qualcomm.com (hu-charante-hyd.qualcomm.com [10.213.97.134]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 58SHHMpL018647 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 28 Sep 2025 17:17:22 +0000 Received: by hu-devc-hyd-u22-c.qualcomm.com (Postfix, from userid 389980) id 379375F0; Sun, 28 Sep 2025 22:47:21 +0530 (+0530) From: Charan Teja Kalla To: joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, saravanak@google.com, conor+dt@kernel.org, robh@kernel.org, mchehab@kernel.org, bod@kernel.org, krzk+dt@kernel.org, abhinav.kumar@linux.dev, vikash.garodia@oss.qualcomm.com, dikshita.agarwal@oss.qualcomm.com Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux.dev, Charan Teja Kalla Subject: [RFC PATCH 2/3] of: create a wrapper for of_map_id() Date: Sun, 28 Sep 2025 22:47:17 +0530 Message-Id: <20250928171718.436440-3-charan.kalla@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250928171718.436440-1-charan.kalla@oss.qualcomm.com> References: <20250928171718.436440-1-charan.kalla@oss.qualcomm.com> 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-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Authority-Analysis: v=2.4 cv=DZAaa/tW c=1 sm=1 tr=0 ts=68d96da6 cx=c_pps a=Ou0eQOY4+eZoSc0qltEV5Q==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17 a=yJojWOMRYYMA:10 a=EUspDBNiAAAA:8 a=BA3SHdP6qxbv-UjKQhIA:9 a=cPQSjfK2_nFv0Q5t_7PE:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwOTI3MDAyMiBTYWx0ZWRfX5u4M687hG9T/ yY7+cQIj6Fx0AMqx3pUivoB6DT/uSxTaRIgqTL+C28RWvYmhZ21eRubOBfEiJ1Cs/R6nECYBkr/ jyI7Y+LTLNUZoqQqpuukR/1kJulPYoJl5vEF878wvvrDNQk+GUJ25tHQ4KbGAGurxvTCqIjZ9Mz 8YkZGDh2Z2ESXKLe280OUnbyB+CTNiNZUnaVd1+cCEJyuodLdELxNh99urfLtJicYr92GXqNICS 49p4jnUdF69iNYosjcvcNdYjXy8Qg/bVHz+b9mgs8rvfCoQe3gF40Bp+BPh4WFzU5ZcGTkU5HEj HoWKSGqKfEv1aOqA5YKyTiiMSQQ1f95LtrVgty8OP4Uhv9HdKVovVPGAtdZfmLAHNEeVOzXO928 S8S5mqv+++1fu5woVlVLbB87qR8PAg== X-Proofpoint-GUID: 1xP_p3OU49YfZH8-Cq8WZDCHk8vjTmWT X-Proofpoint-ORIG-GUID: 1xP_p3OU49YfZH8-Cq8WZDCHk8vjTmWT X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1117,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-09-28_07,2025-09-26_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 bulkscore=0 clxscore=1015 adultscore=0 impostorscore=0 priorityscore=1501 lowpriorityscore=0 suspectscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2509150000 definitions=main-2509270022 Content-Type: text/plain; charset="utf-8" Create a wrapper function for of_map_id(). This wrapper takes additional params in the subsequent patches. No functional changes. Signed-off-by: Charan Teja Kalla --- drivers/of/base.c | 36 ++++++++++++++++++++++++++++-------- include/linux/of.h | 11 +++++++++++ 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/drivers/of/base.c b/drivers/of/base.c index 7043acd971a0..ed2a924d1fab 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -2054,17 +2054,11 @@ int of_find_last_cache_level(unsigned int cpu) * @target: optional pointer to a target device node. * @id_out: optional pointer to receive the translated ID. * - * Given a device ID, look up the appropriate implementation-defined - * platform ID and/or the target device which receives transactions on that - * ID, as per the "iommu-map" and "msi-map" bindings. Either of @target or - * @id_out may be NULL if only the other is required. If @target points to - * a non-NULL device node pointer, only entries targeting that node will be - * matched; if it points to a NULL value, it will receive the device node = of - * the first matching target phandle, with a reference held. + * Look at the documentation of of_map_id(). * * Return: 0 on success or a standard error code on failure. */ -int of_map_id(const struct device_node *np, u32 id, +int of_map_id_and_mask(const struct device_node *np, u32 id, const char *map_name, const char *map_mask_name, struct device_node **target, u32 *id_out) { @@ -2149,4 +2143,30 @@ int of_map_id(const struct device_node *np, u32 id, *id_out =3D id; return 0; } + +/* of_map_id - Translate an ID through a downstream mapping. + * @np: root complex device node. + * @id: device ID to map. + * @map_name: property name of the map to use. + * @map_mask_name: optional property name of the mask to use. + * @target: optional pointer to a target device node. + * @id_out: optional pointer to receive the translated ID. + * + * Given a device ID, look up the appropriate implementation-defined + * platform ID and/or the target device which receives transactions on that + * ID, as per the "iommu-map" and "msi-map" bindings. Either of @target or + * @id_out may be NULL if only the other is required. If @target points to + * a non-NULL device node pointer, only entries targeting that node will be + * matched; if it points to a NULL value, it will receive the device node = of + * the first matching target phandle, with a reference held. + * + * Return: 0 on success or a standard error code on failure. + */ +int of_map_id(const struct device_node *np, u32 id, + const char *map_name, const char *map_mask_name, + struct device_node **target, u32 *id_out) +{ + return of_map_id_and_mask(np, id, map_name, map_mask_name, + target, id_out); +} EXPORT_SYMBOL_GPL(of_map_id); diff --git a/include/linux/of.h b/include/linux/of.h index a62154aeda1b..6fcc46e8b3da 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -460,6 +460,10 @@ int of_map_id(const struct device_node *np, u32 id, const char *map_name, const char *map_mask_name, struct device_node **target, u32 *id_out); =20 +int of_map_id_and_mask(const struct device_node *np, u32 id, + const char *map_name, const char *map_mask_name, + struct device_node **target, u32 *id_out); + phys_addr_t of_dma_get_max_cpu_address(struct device_node *np); =20 struct kimage; @@ -905,6 +909,13 @@ static inline int of_map_id(const struct device_node *= np, u32 id, return -EINVAL; } =20 +static inline int of_map_id_and_mask(const struct device_node *np, u32 id, + const char *map_name, const char *map_mask_name, + struct device_node **target, u32 *id_out) +{ + return -EINVAL; +} + static inline phys_addr_t of_dma_get_max_cpu_address(struct device_node *n= p) { return PHYS_ADDR_MAX; --=20 2.34.1 From nobody Wed Oct 1 21:24:19 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 199264A01; Sun, 28 Sep 2025 17:17:42 +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=1759079864; cv=none; b=td4lM8r7mX12O0zQ+7juT0ZNGMdQdqQhG4jC5+sOsdpGoclLP/S7sbca3w0l034iZF3JJ58cAjw2wU4NY4bMrwXgXkftpYaO+JckdXCk9UIVipRpeotLnNUgZUO81vDvm/elvGtsvcPEBnRXyXHmmSlQff7LCcYLNoK5vwitbuY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759079864; c=relaxed/simple; bh=SAD+C/FHTaWdTjV0x+/U7xwAZ028POddyaFiMCIPMrI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dCFNv4MkahiXzrEScaS5DhLsanwY8hV+wr+mSclPLVdtp6RepeqpCOzgeaoXu5QMVf6KG1fCQ1pY90SDaSSMnpuyHdQA3JPh7xEZzOwEO7NxinRuIxi1wBCnZE8Z/Ld5FJjCBqygr1dkA8va4mzZvR+tqtDHKjUADRqhIXF9EOE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=PR4EHcjl; 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=qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="PR4EHcjl" Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 58SGKR93014676; Sun, 28 Sep 2025 17:17:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=E8d0nBXLxTU O6aOWwxm8KO5YtTbkyjqmWh9yw06iQwA=; b=PR4EHcjlRHB++3SQ8sEKVvRoZHB 0BLuluKvG8JIZobt1Yh7aZrr4XfpmxGbqGTcCY1cPogd+aFISH/ZeL9U7p1Yfmj1 cR94JIDN9MQ5udipVc0sw14gk5cljNTlEBIPC0/PFKeZWXfX8irXEdmIb8EoEJUQ oQ69TNwmLDm+ZFf9bSn/oxDqsoj1Jq/1W4r/waHOb9WRgwNzVWbcvr0Dh/V9LH8S Rd5n4k5O2Npfft+Fqsb63vG2qv7lqkShkyzalK7WENxS03P+ZJZ94gcpB25t4rzQ sDM5b1MZkbQuXIaXh1nC1OyfjS/I1xcZXIOF3EqJWNGOFjE662oaEwqF9jQ== Received: from apblrppmta01.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 49e59muby2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 28 Sep 2025 17:17:26 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTP id 58SHHMT1018673; Sun, 28 Sep 2025 17:17:22 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 49e90k74pd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 28 Sep 2025 17:17:22 +0000 Received: from APBLRPPMTA01.qualcomm.com (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 58SHHM9Y018650; Sun, 28 Sep 2025 17:17:22 GMT Received: from hu-devc-hyd-u22-c.qualcomm.com (hu-charante-hyd.qualcomm.com [10.213.97.134]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 58SHHMk5018648 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 28 Sep 2025 17:17:22 +0000 Received: by hu-devc-hyd-u22-c.qualcomm.com (Postfix, from userid 389980) id 3BCE05F3; Sun, 28 Sep 2025 22:47:21 +0530 (+0530) From: Charan Teja Kalla To: joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, saravanak@google.com, conor+dt@kernel.org, robh@kernel.org, mchehab@kernel.org, bod@kernel.org, krzk+dt@kernel.org, abhinav.kumar@linux.dev, vikash.garodia@oss.qualcomm.com, dikshita.agarwal@oss.qualcomm.com Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux.dev, Charan Teja Kalla Subject: [RFC PATCH 3/3] of: implment the 'iommu-map-masked' to represent multi-functional devices Date: Sun, 28 Sep 2025 22:47:18 +0530 Message-Id: <20250928171718.436440-4-charan.kalla@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250928171718.436440-1-charan.kalla@oss.qualcomm.com> References: <20250928171718.436440-1-charan.kalla@oss.qualcomm.com> 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-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: t4Z5s7goqR9F1ZlIx4v1fVVg6RWhFSDd X-Authority-Analysis: v=2.4 cv=O4g0fR9W c=1 sm=1 tr=0 ts=68d96da6 cx=c_pps a=Ou0eQOY4+eZoSc0qltEV5Q==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17 a=yJojWOMRYYMA:10 a=EUspDBNiAAAA:8 a=tZiW2AOmwnKfT6Y2LrUA:9 a=cPQSjfK2_nFv0Q5t_7PE:22 X-Proofpoint-ORIG-GUID: t4Z5s7goqR9F1ZlIx4v1fVVg6RWhFSDd X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwOTI3MDAwMSBTYWx0ZWRfX21R5/00zIgDa OhT6V7OgIMp5/aarF1tAYr7YqkAx8JTXP9VtamDDywyCUuHNrT9f+2BQyi6KM7bqZoiiI00Xik2 Qx8o62Y8Z0qIkHN8kyeVCVASPmcPMbCrUWkxFWXPsT78UI9vp+JHmkKWabLLVCo758b1O720WoU ek056dvRncoueVmhFGvpCOTS+Fhz+/CU899hf5E3ombwoee7UwySPbefN/gjbDmH57os4X957VJ 8lle7Cb2zkAIEWz4jl9axN8DtJNiyIZCfInVZXsRWtSo+CY+HZCAsbuSAmmxBHnlxsjHwrbIKz3 vC+m7TeBRkC7cnl96Utlv2OovE+71ZEofbLETpgx6aptKGjDQ1Qys7RgH1uE5JdN1CaYAyfw0Bx Wpt+p34h4TGF8ufGAtlQm+kEVT+N8w== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1117,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-09-28_07,2025-09-26_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 phishscore=0 clxscore=1011 priorityscore=1501 lowpriorityscore=0 spamscore=0 impostorscore=0 bulkscore=0 suspectscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2509150000 definitions=main-2509270001 Content-Type: text/plain; charset="utf-8" The classical representation used by the platform device to represent the IOMMU specifier pairs is through 'iommus =3D'. All the IOMMU specifier pairs represented will be marked to use the single translation context, at least is the case for ARM IOMMU. When each functionality of a multi-functional device required to use individual address spaces, for arm architecture, it need to be mentioned as multiple sub-device nodes in the device tree. But since the device tree is used to just pass on the soc layout to the linux kernel, it doesn't truly fit. Introduce the iommu-map-masked property(taking cue from iommu-map for pci devices) where each functionality is represented(in arm64 architecture language) as: iommu-map-masked =3D , ; Iommu client drivers can dynamically create the child devices for each of these function ID's and call of_dma_configure_id() on these child devices which sets up the IOMMU configuration. Signed-off-by: Charan Teja Kalla --- drivers/iommu/of_iommu.c | 44 ++++++++++++++++++++++++++++++++++++++++ drivers/of/base.c | 21 +++++++++++++++++-- include/linux/of.h | 8 ++++++-- 3 files changed, 69 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c index 6b989a62def2..2363de8f2fd6 100644 --- a/drivers/iommu/of_iommu.c +++ b/drivers/iommu/of_iommu.c @@ -41,12 +41,56 @@ static int of_iommu_xlate(struct device *dev, return ret; } =20 +static int of_iommu_map_id(const __be32 *map, u32 id, + struct device *dev, void *data) +{ + struct device_node *phandle_node; + struct of_phandle_args *iommu_spec =3D data; + u32 id_base =3D be32_to_cpup(map + 0); + u32 phandle =3D be32_to_cpup(map + 1); + u32 master_id0 =3D be32_to_cpup(map + 2); + u32 master_id1 =3D be32_to_cpup(map + 3); + int err; + + phandle_node =3D of_find_node_by_phandle(phandle); + if (!phandle_node) + return -ENODEV; + + if (id !=3D id_base) + return -EAGAIN; + + iommu_spec->np =3D phandle_node; + iommu_spec->args[0] =3D master_id0; + iommu_spec->args[1] =3D master_id1; + + err =3D of_iommu_xlate(dev, iommu_spec); + of_node_put(iommu_spec->np); + + return err; +} + +static int of_iommu_configure_map_id_and_mask(struct device_node *master_n= p, + struct device *dev, + const u32 *id) +{ + struct of_phandle_args iommu_spec =3D { .args_count =3D 2 }; + + return of_map_id_and_mask(master_np, *id, + "iommu-map-masked", NULL, + &iommu_spec.np, NULL, + dev, (void *)&iommu_spec, of_iommu_map_id); +} + static int of_iommu_configure_dev_id(struct device_node *master_np, struct device *dev, const u32 *id) { struct of_phandle_args iommu_spec =3D { .args_count =3D 1 }; int err; + bool iommu_map_masked =3D !!of_find_property(master_np, "iommu-map-masked= ", NULL); + + if (iommu_map_masked) + return of_iommu_configure_map_id_and_mask(master_np, dev, id); =20 err =3D of_map_id(master_np, *id, "iommu-map", "iommu-map-mask", &iommu_spec.np, diff --git a/drivers/of/base.c b/drivers/of/base.c index ed2a924d1fab..bb11125e9624 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -2053,6 +2053,9 @@ int of_find_last_cache_level(unsigned int cpu) * @map_mask_name: optional property name of the mask to use. * @target: optional pointer to a target device node. * @id_out: optional pointer to receive the translated ID. + * @dev: TODO + * @data: optional param that to be passed to fn. + * @fn: custom function to get implementation defined platform/device id. * * Look at the documentation of of_map_id(). * @@ -2060,10 +2063,13 @@ int of_find_last_cache_level(unsigned int cpu) */ int of_map_id_and_mask(const struct device_node *np, u32 id, const char *map_name, const char *map_mask_name, - struct device_node **target, u32 *id_out) + struct device_node **target, u32 *id_out, + struct device *dev, void *data, + int (*fn)(const __be32 *map, u32 id, struct device *dev, void *dat= a)) { u32 map_mask, masked_id; int map_len; + int ret; const __be32 *map =3D NULL; =20 if (!np || !map_name || (!target && !id_out)) @@ -2109,6 +2115,13 @@ int of_map_id_and_mask(const struct device_node *np,= u32 id, return -EFAULT; } =20 + if (fn) { + ret =3D fn(map, id, dev, data); + if (ret !=3D -EAGAIN) + break; + continue; + } + if (masked_id < id_base || masked_id >=3D id_base + id_len) continue; =20 @@ -2135,12 +2148,16 @@ int of_map_id_and_mask(const struct device_node *np= , u32 id, return 0; } =20 + if (fn) + return ret; + pr_info("%pOF: no %s translation for id 0x%x on %pOF\n", np, map_name, id, target && *target ? *target : NULL); =20 /* Bypasses translation */ if (id_out) *id_out =3D id; + return 0; } =20 @@ -2167,6 +2184,6 @@ int of_map_id(const struct device_node *np, u32 id, struct device_node **target, u32 *id_out) { return of_map_id_and_mask(np, id, map_name, map_mask_name, - target, id_out); + target, id_out, NULL, NULL, NULL); } EXPORT_SYMBOL_GPL(of_map_id); diff --git a/include/linux/of.h b/include/linux/of.h index 6fcc46e8b3da..7f3890ab26d5 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -462,7 +462,9 @@ int of_map_id(const struct device_node *np, u32 id, =20 int of_map_id_and_mask(const struct device_node *np, u32 id, const char *map_name, const char *map_mask_name, - struct device_node **target, u32 *id_out); + struct device_node **target, u32 *id_out, + struct device *dev, void *data, + int (*fn)(const __be32 *map, u32 id, struct device *dev, void *data)); =20 phys_addr_t of_dma_get_max_cpu_address(struct device_node *np); =20 @@ -911,7 +913,9 @@ static inline int of_map_id(const struct device_node *n= p, u32 id, =20 static inline int of_map_id_and_mask(const struct device_node *np, u32 id, const char *map_name, const char *map_mask_name, - struct device_node **target, u32 *id_out) + struct device_node **target, u32 *id_out, + struct device *dev, void *data, + int (*fn)(const __be32 *map, u32 id, void *data)) { return -EINVAL; } --=20 2.34.1