From nobody Wed Nov 27 00:35:37 2024 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 DFF021E6339; Tue, 15 Oct 2024 12:08:23 +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=1728994105; cv=none; b=HAHP1FkjrDa20UBNi9eLtN5K2WO73ntD2xFwP9Ia8k8nC1VMHx/D0uHhjxFquKZO5GSPUByBKzhLb+yF+W9y0XhqnpFjg7vP3rhJ9tsLORplKkA1jL8s22w/9TI02CCCyzEabRlN10HEoSL/tffWfST5Jo8o7Lur3t3ipKMfBg0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728994105; c=relaxed/simple; bh=Mi7GP4jSbdCnXMDarurINP3O08gFDwlMkIy2JUMz6iY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Pj2KbaLtwaQlWlrQ05lGPDwrxAmiteubSAdIwgFVDY+ZKDdQb/xd0C1ZygHe3/UbijzTfYCxKF1KXK6DhmeQheHz8SjD2mD+1cC0mkCqx7LSJXN7nX7Zw88Fm8TnI3OihQo/ulH2PhrGZiywTZ8Izpl2vjeMxlH6qwDKsqTmzuc= 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=n9abmTqR; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="n9abmTqR" 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 49F85HPv030714; Tue, 15 Oct 2024 12:08:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to; s=qcppdkim1; bh=uV1QMerX2E3bCzJ5ReeeBm9c ZKO+uAJ0gF+pFA4KQZ8=; b=n9abmTqRZX9WhUZrPeQatHK7m5JcRVfwb5NzUX/V Rw0wqZnkG6CZfumqvMCHGtxWQHPiwjattHVvf8se2mPy9mgql8JIi2DtGMkhgYKQ NPPhCCCGK4kXQm9t5/m87/2SxxIsZj+9l/O2f2AkSsvOYha2j2H3Ys6xmA1CG5II kTcdHDwXZClw6Hpn8VMC9W//+QDWTzA8SG7uswhDf+F4PilJTSc1ujYIMd5IJ2NG dxjsPXsBntgCW5chcAOm1ZgdVAWepf3XCQVoikfjLCKSghfehzpN3tyLkCfo0YDA VIwLvXWX/ozA3WkQbEg1He/kJam7UPUn893I5FjozYrYIw== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 429mjy0kqq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 12:08:17 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA01.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 49FC8GTV026942 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 12:08:16 GMT Received: from hu-jseerapu-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Tue, 15 Oct 2024 05:08:10 -0700 From: Jyothi Kumar Seerapu To: Vinod Koul , Rob Herring , "Krzysztof Kozlowski" , Conor Dooley , "Bjorn Andersson" , Konrad Dybcio , Andi Shyti , Sumit Semwal , =?UTF-8?q?Christian=20K=C3=B6nig?= CC: , , , , , , , , , , Subject: [PATCH v1 1/5] dt-bindings: dmaengine: qcom: gpi: Add additional arg to dma-cell property Date: Tue, 15 Oct 2024 17:37:46 +0530 Message-ID: <20241015120750.21217-2-quic_jseerapu@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241015120750.21217-1-quic_jseerapu@quicinc.com> References: <20241015120750.21217-1-quic_jseerapu@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: EKxx1K3wr0jgmfX0Zx7xxh6X_XklAu7h X-Proofpoint-ORIG-GUID: EKxx1K3wr0jgmfX0Zx7xxh6X_XklAu7h X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 phishscore=0 mlxscore=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 impostorscore=0 clxscore=1015 spamscore=0 suspectscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410150083 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When high performance with multiple i2c messages in a single transfer is required, employ Block Event Interrupt (BEI) to trigger interrupts after specific messages transfer and the last message transfer, thereby reducing interrupts. For each i2c message transfer, a series of Transfer Request Elements(TREs) must be programmed, including config tre for frequency configuration, go tre for holding i2c address and dma tre for holding dma buffer address, length as per the hardware programming guide. For transfer using BEI, multiple I2C messages may necessitate the preparation of config, go, and tx DMA TREs. However, a channel TRE size of 64 is often insufficient, potentially leading to failures due to inadequate memory space. Add additional argument to dma-cell property for channel TRE size. With this, adjust the channel TRE size via the device tree. The default size is 64, but clients can modify this value based on their specific requirements. Signed-off-by: Jyothi Kumar Seerapu --- Documentation/devicetree/bindings/dma/qcom,gpi.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/dma/qcom,gpi.yaml b/Document= ation/devicetree/bindings/dma/qcom,gpi.yaml index 4df4e61895d2..002495921643 100644 --- a/Documentation/devicetree/bindings/dma/qcom,gpi.yaml +++ b/Documentation/devicetree/bindings/dma/qcom,gpi.yaml @@ -54,14 +54,16 @@ properties: maxItems: 13 =20 "#dma-cells": - const: 3 + minItems: 3 + maxItems: 4 description: > DMA clients must use the format described in dma.txt, giving a phand= le - to the DMA controller plus the following 3 integer cells: + to the DMA controller plus the following 4 integer cells: - channel: if set to 0xffffffff, any available channel will be alloc= ated for the client. Otherwise, the exact channel specified will be use= d. - seid: serial id of the client as defined in the SoC documentation. - client: type of the client as defined in dt-bindings/dma/qcom-gpi.h + - channel-tre-size: size of the channel TRE (transfer ring element) =20 iommus: maxItems: 1 --=20 2.17.1 From nobody Wed Nov 27 00:35:37 2024 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 03C861EC00A; Tue, 15 Oct 2024 12:08:31 +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=1728994113; cv=none; b=LtWnzVFtw5Ev5VvWPh8J69oHs9dHrtC8O/tWU3uUftdjbdOXPdaZ4UYWEhD4tSmMF1TUZaZKBcZ60Mcyiuzft5hnIT3yk5lJXZxCkDzT6Eo0p7nmhCSJ7HWugVQbW3uRHVnD7N5ZXuV1HFhIsbT8KJmjo4+Lv+vTBOuUh+WCXqU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728994113; c=relaxed/simple; bh=sixd0htXLi4lq/+g5Wakv0O4vqNjU4vtXkII29g7DXM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=N9UvfeZP40wK8ydLc2nKmehKJaLgs36ZVqmCdloEvED6qnd+H4PfjFaVPpm0C16XNZLN2sZTOWEF0CH768P3VOpQMMwnefC/uHgLOHzyKJGT+iPGULiFbUdKuqiNMwbQMlSFTE4jaWiorPZwqAmZWFsO23iglTFWTsFDRswopro= 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=JA9dPEho; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="JA9dPEho" Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49FAjba0022751; Tue, 15 Oct 2024 12:08:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to; s=qcppdkim1; bh=zr0xCzl94Flfb4GNKrmacllY 32cztycHSo5tJP0qt2Q=; b=JA9dPEhodvGEM56P/aMR2JS2WygD2LgZ5N+ABjNF bFWUY1OjIBUjjCl/aK6cjGyjKYNLQfwxNdEoF8lnoCIneYsJnl/DkVYNZKlETuHp 5Z1/8tj8S734LMYvnlxAzcol7NAEdz5GzvDduTMPhGO4GuJqtzy+2hgEVb7jmc3N 7lzrNUCNQHmLtYUIxdHe8KksQENQecBXcQ7fhHPJLVQQh/t8AJlgbJnk/nAoMqb2 v54bXARoTuw+XC0DqJgmdBbD5a/ycibkKjuQUhLDWngCi4iUs12wPQbDlLHErMlB wxH2kf/K0kHItkdwZnHbkAyR80zd94uauKGpuE1cHRkkBA== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 427g2rqg2e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 12:08:22 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA02.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 49FC8LOB002234 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 12:08:21 GMT Received: from hu-jseerapu-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Tue, 15 Oct 2024 05:08:16 -0700 From: Jyothi Kumar Seerapu To: Vinod Koul , Rob Herring , "Krzysztof Kozlowski" , Conor Dooley , "Bjorn Andersson" , Konrad Dybcio , Andi Shyti , Sumit Semwal , =?UTF-8?q?Christian=20K=C3=B6nig?= CC: , , , , , , , , , , Subject: [PATCH v1 2/5] arm64: dts: qcom: Add support for configuring channel TRE size Date: Tue, 15 Oct 2024 17:37:47 +0530 Message-ID: <20241015120750.21217-3-quic_jseerapu@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241015120750.21217-1-quic_jseerapu@quicinc.com> References: <20241015120750.21217-1-quic_jseerapu@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: X6G_FitGyw9X2VxUdzoYGsYIxqQ7wTX0 X-Proofpoint-GUID: X6G_FitGyw9X2VxUdzoYGsYIxqQ7wTX0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 suspectscore=0 phishscore=0 malwarescore=0 clxscore=1015 spamscore=0 adultscore=0 mlxlogscore=999 impostorscore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410150082 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When high performance with multiple i2c messages in a single transfer is required, employ Block Event Interrupt (BEI) to trigger interrupts after specific messages transfer and the last message transfer, thereby reducing interrupts. For each i2c message transfer, a series of Transfer Request Elements(TREs) must be programmed, including config tre for frequency configuration, go tre for holding i2c address and dma tre for holding dma buffer address, length as per the hardware programming guide. For transfer using BEI, multiple I2C messages may necessitate the preparation of config, go, and tx DMA TREs. However, a channel TRE size of 64 is often insufficient, potentially leading to failures due to inadequate memory space. Adjust the channel TRE size through the device tree. The default size is 64, but clients can modify this value based on their heigher channel TRE size requirements. Signed-off-by: Jyothi Kumar Seerapu --- arch/arm64/boot/dts/qcom/sc7280.dtsi | 132 +++++++++++++-------------- 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/arch/arm64/boot/dts/qcom/sc7280.dtsi b/arch/arm64/boot/dts/qco= m/sc7280.dtsi index 3d8410683402..c7c0e15ff9d3 100644 --- a/arch/arm64/boot/dts/qcom/sc7280.dtsi +++ b/arch/arm64/boot/dts/qcom/sc7280.dtsi @@ -1064,7 +1064,7 @@ }; =20 gpi_dma0: dma-controller@900000 { - #dma-cells =3D <3>; + #dma-cells =3D <4>; compatible =3D "qcom,sc7280-gpi-dma", "qcom,sm6350-gpi-dma"; reg =3D <0 0x00900000 0 0x60000>; interrupts =3D , @@ -1114,8 +1114,8 @@ "qup-memory"; power-domains =3D <&rpmhpd SC7280_CX>; required-opps =3D <&rpmhpd_opp_low_svs>; - dmas =3D <&gpi_dma0 0 0 QCOM_GPI_I2C>, - <&gpi_dma0 1 0 QCOM_GPI_I2C>; + dmas =3D <&gpi_dma0 0 0 QCOM_GPI_I2C 64>, + <&gpi_dma0 1 0 QCOM_GPI_I2C 64>; dma-names =3D "tx", "rx"; status =3D "disabled"; }; @@ -1135,8 +1135,8 @@ interconnects =3D <&clk_virt MASTER_QUP_CORE_0 0 &clk_virt SLAVE_QUP_C= ORE_0 0>, <&gem_noc MASTER_APPSS_PROC 0 &cnoc2 SLAVE_QUP_0 0>; interconnect-names =3D "qup-core", "qup-config"; - dmas =3D <&gpi_dma0 0 0 QCOM_GPI_SPI>, - <&gpi_dma0 1 0 QCOM_GPI_SPI>; + dmas =3D <&gpi_dma0 0 0 QCOM_GPI_SPI 64>, + <&gpi_dma0 1 0 QCOM_GPI_SPI 64>; dma-names =3D "tx", "rx"; status =3D "disabled"; }; @@ -1174,8 +1174,8 @@ "qup-memory"; power-domains =3D <&rpmhpd SC7280_CX>; required-opps =3D <&rpmhpd_opp_low_svs>; - dmas =3D <&gpi_dma0 0 1 QCOM_GPI_I2C>, - <&gpi_dma0 1 1 QCOM_GPI_I2C>; + dmas =3D <&gpi_dma0 0 1 QCOM_GPI_I2C 64>, + <&gpi_dma0 1 1 QCOM_GPI_I2C 64>; dma-names =3D "tx", "rx"; status =3D "disabled"; }; @@ -1195,8 +1195,8 @@ interconnects =3D <&clk_virt MASTER_QUP_CORE_0 0 &clk_virt SLAVE_QUP_C= ORE_0 0>, <&gem_noc MASTER_APPSS_PROC 0 &cnoc2 SLAVE_QUP_0 0>; interconnect-names =3D "qup-core", "qup-config"; - dmas =3D <&gpi_dma0 0 1 QCOM_GPI_SPI>, - <&gpi_dma0 1 1 QCOM_GPI_SPI>; + dmas =3D <&gpi_dma0 0 1 QCOM_GPI_SPI 64>, + <&gpi_dma0 1 1 QCOM_GPI_SPI 64>; dma-names =3D "tx", "rx"; status =3D "disabled"; }; @@ -1234,8 +1234,8 @@ "qup-memory"; power-domains =3D <&rpmhpd SC7280_CX>; required-opps =3D <&rpmhpd_opp_low_svs>; - dmas =3D <&gpi_dma0 0 2 QCOM_GPI_I2C>, - <&gpi_dma0 1 2 QCOM_GPI_I2C>; + dmas =3D <&gpi_dma0 0 2 QCOM_GPI_I2C 64>, + <&gpi_dma0 1 2 QCOM_GPI_I2C 64>; dma-names =3D "tx", "rx"; status =3D "disabled"; }; @@ -1255,8 +1255,8 @@ interconnects =3D <&clk_virt MASTER_QUP_CORE_0 0 &clk_virt SLAVE_QUP_C= ORE_0 0>, <&gem_noc MASTER_APPSS_PROC 0 &cnoc2 SLAVE_QUP_0 0>; interconnect-names =3D "qup-core", "qup-config"; - dmas =3D <&gpi_dma0 0 2 QCOM_GPI_SPI>, - <&gpi_dma0 1 2 QCOM_GPI_SPI>; + dmas =3D <&gpi_dma0 0 2 QCOM_GPI_SPI 64>, + <&gpi_dma0 1 2 QCOM_GPI_SPI 64>; dma-names =3D "tx", "rx"; status =3D "disabled"; }; @@ -1294,8 +1294,8 @@ "qup-memory"; power-domains =3D <&rpmhpd SC7280_CX>; required-opps =3D <&rpmhpd_opp_low_svs>; - dmas =3D <&gpi_dma0 0 3 QCOM_GPI_I2C>, - <&gpi_dma0 1 3 QCOM_GPI_I2C>; + dmas =3D <&gpi_dma0 0 3 QCOM_GPI_I2C 64>, + <&gpi_dma0 1 3 QCOM_GPI_I2C 64>; dma-names =3D "tx", "rx"; status =3D "disabled"; }; @@ -1315,8 +1315,8 @@ interconnects =3D <&clk_virt MASTER_QUP_CORE_0 0 &clk_virt SLAVE_QUP_C= ORE_0 0>, <&gem_noc MASTER_APPSS_PROC 0 &cnoc2 SLAVE_QUP_0 0>; interconnect-names =3D "qup-core", "qup-config"; - dmas =3D <&gpi_dma0 0 3 QCOM_GPI_SPI>, - <&gpi_dma0 1 3 QCOM_GPI_SPI>; + dmas =3D <&gpi_dma0 0 3 QCOM_GPI_SPI 64>, + <&gpi_dma0 1 3 QCOM_GPI_SPI 64>; dma-names =3D "tx", "rx"; status =3D "disabled"; }; @@ -1354,8 +1354,8 @@ "qup-memory"; power-domains =3D <&rpmhpd SC7280_CX>; required-opps =3D <&rpmhpd_opp_low_svs>; - dmas =3D <&gpi_dma0 0 4 QCOM_GPI_I2C>, - <&gpi_dma0 1 4 QCOM_GPI_I2C>; + dmas =3D <&gpi_dma0 0 4 QCOM_GPI_I2C 64>, + <&gpi_dma0 1 4 QCOM_GPI_I2C 64>; dma-names =3D "tx", "rx"; status =3D "disabled"; }; @@ -1375,8 +1375,8 @@ interconnects =3D <&clk_virt MASTER_QUP_CORE_0 0 &clk_virt SLAVE_QUP_C= ORE_0 0>, <&gem_noc MASTER_APPSS_PROC 0 &cnoc2 SLAVE_QUP_0 0>; interconnect-names =3D "qup-core", "qup-config"; - dmas =3D <&gpi_dma0 0 4 QCOM_GPI_SPI>, - <&gpi_dma0 1 4 QCOM_GPI_SPI>; + dmas =3D <&gpi_dma0 0 4 QCOM_GPI_SPI 64>, + <&gpi_dma0 1 4 QCOM_GPI_SPI 64>; dma-names =3D "tx", "rx"; status =3D "disabled"; }; @@ -1414,8 +1414,8 @@ "qup-memory"; power-domains =3D <&rpmhpd SC7280_CX>; required-opps =3D <&rpmhpd_opp_low_svs>; - dmas =3D <&gpi_dma0 0 5 QCOM_GPI_I2C>, - <&gpi_dma0 1 5 QCOM_GPI_I2C>; + dmas =3D <&gpi_dma0 0 5 QCOM_GPI_I2C 64>, + <&gpi_dma0 1 5 QCOM_GPI_I2C 64>; dma-names =3D "tx", "rx"; status =3D "disabled"; }; @@ -1435,8 +1435,8 @@ interconnects =3D <&clk_virt MASTER_QUP_CORE_0 0 &clk_virt SLAVE_QUP_C= ORE_0 0>, <&gem_noc MASTER_APPSS_PROC 0 &cnoc2 SLAVE_QUP_0 0>; interconnect-names =3D "qup-core", "qup-config"; - dmas =3D <&gpi_dma0 0 5 QCOM_GPI_SPI>, - <&gpi_dma0 1 5 QCOM_GPI_SPI>; + dmas =3D <&gpi_dma0 0 5 QCOM_GPI_SPI 64>, + <&gpi_dma0 1 5 QCOM_GPI_SPI 64>; dma-names =3D "tx", "rx"; status =3D "disabled"; }; @@ -1474,8 +1474,8 @@ "qup-memory"; power-domains =3D <&rpmhpd SC7280_CX>; required-opps =3D <&rpmhpd_opp_low_svs>; - dmas =3D <&gpi_dma0 0 6 QCOM_GPI_I2C>, - <&gpi_dma0 1 6 QCOM_GPI_I2C>; + dmas =3D <&gpi_dma0 0 6 QCOM_GPI_I2C 64>, + <&gpi_dma0 1 6 QCOM_GPI_I2C 64>; dma-names =3D "tx", "rx"; status =3D "disabled"; }; @@ -1495,8 +1495,8 @@ interconnects =3D <&clk_virt MASTER_QUP_CORE_0 0 &clk_virt SLAVE_QUP_C= ORE_0 0>, <&gem_noc MASTER_APPSS_PROC 0 &cnoc2 SLAVE_QUP_0 0>; interconnect-names =3D "qup-core", "qup-config"; - dmas =3D <&gpi_dma0 0 6 QCOM_GPI_SPI>, - <&gpi_dma0 1 6 QCOM_GPI_SPI>; + dmas =3D <&gpi_dma0 0 6 QCOM_GPI_SPI 64>, + <&gpi_dma0 1 6 QCOM_GPI_SPI 64>; dma-names =3D "tx", "rx"; status =3D "disabled"; }; @@ -1534,8 +1534,8 @@ "qup-memory"; power-domains =3D <&rpmhpd SC7280_CX>; required-opps =3D <&rpmhpd_opp_low_svs>; - dmas =3D <&gpi_dma0 0 7 QCOM_GPI_I2C>, - <&gpi_dma0 1 7 QCOM_GPI_I2C>; + dmas =3D <&gpi_dma0 0 7 QCOM_GPI_I2C 64>, + <&gpi_dma0 1 7 QCOM_GPI_I2C 64>; dma-names =3D "tx", "rx"; status =3D "disabled"; }; @@ -1555,8 +1555,8 @@ interconnects =3D <&clk_virt MASTER_QUP_CORE_0 0 &clk_virt SLAVE_QUP_C= ORE_0 0>, <&gem_noc MASTER_APPSS_PROC 0 &cnoc2 SLAVE_QUP_0 0>; interconnect-names =3D "qup-core", "qup-config"; - dmas =3D <&gpi_dma0 0 7 QCOM_GPI_SPI>, - <&gpi_dma0 1 7 QCOM_GPI_SPI>; + dmas =3D <&gpi_dma0 0 7 QCOM_GPI_SPI 64>, + <&gpi_dma0 1 7 QCOM_GPI_SPI 64>; dma-names =3D "tx", "rx"; status =3D "disabled"; }; @@ -1579,7 +1579,7 @@ }; =20 gpi_dma1: dma-controller@a00000 { - #dma-cells =3D <3>; + #dma-cells =3D <4>; compatible =3D "qcom,sc7280-gpi-dma", "qcom,sm6350-gpi-dma"; reg =3D <0 0x00a00000 0 0x60000>; interrupts =3D , @@ -1629,8 +1629,8 @@ "qup-memory"; power-domains =3D <&rpmhpd SC7280_CX>; required-opps =3D <&rpmhpd_opp_low_svs>; - dmas =3D <&gpi_dma1 0 0 QCOM_GPI_I2C>, - <&gpi_dma1 1 0 QCOM_GPI_I2C>; + dmas =3D <&gpi_dma1 0 0 QCOM_GPI_I2C 64>, + <&gpi_dma1 1 0 QCOM_GPI_I2C 64>; dma-names =3D "tx", "rx"; status =3D "disabled"; }; @@ -1650,8 +1650,8 @@ interconnects =3D <&clk_virt MASTER_QUP_CORE_1 0 &clk_virt SLAVE_QUP_C= ORE_1 0>, <&gem_noc MASTER_APPSS_PROC 0 &cnoc2 SLAVE_QUP_1 0>; interconnect-names =3D "qup-core", "qup-config"; - dmas =3D <&gpi_dma1 0 0 QCOM_GPI_SPI>, - <&gpi_dma1 1 0 QCOM_GPI_SPI>; + dmas =3D <&gpi_dma1 0 0 QCOM_GPI_SPI 64>, + <&gpi_dma1 1 0 QCOM_GPI_SPI 64>; dma-names =3D "tx", "rx"; status =3D "disabled"; }; @@ -1689,8 +1689,8 @@ "qup-memory"; power-domains =3D <&rpmhpd SC7280_CX>; required-opps =3D <&rpmhpd_opp_low_svs>; - dmas =3D <&gpi_dma1 0 1 QCOM_GPI_I2C>, - <&gpi_dma1 1 1 QCOM_GPI_I2C>; + dmas =3D <&gpi_dma1 0 1 QCOM_GPI_I2C 64>, + <&gpi_dma1 1 1 QCOM_GPI_I2C 64>; dma-names =3D "tx", "rx"; status =3D "disabled"; }; @@ -1710,8 +1710,8 @@ interconnects =3D <&clk_virt MASTER_QUP_CORE_1 0 &clk_virt SLAVE_QUP_C= ORE_1 0>, <&gem_noc MASTER_APPSS_PROC 0 &cnoc2 SLAVE_QUP_1 0>; interconnect-names =3D "qup-core", "qup-config"; - dmas =3D <&gpi_dma1 0 1 QCOM_GPI_SPI>, - <&gpi_dma1 1 1 QCOM_GPI_SPI>; + dmas =3D <&gpi_dma1 0 1 QCOM_GPI_SPI 64>, + <&gpi_dma1 1 1 QCOM_GPI_SPI 64>; dma-names =3D "tx", "rx"; status =3D "disabled"; }; @@ -1749,8 +1749,8 @@ "qup-memory"; power-domains =3D <&rpmhpd SC7280_CX>; required-opps =3D <&rpmhpd_opp_low_svs>; - dmas =3D <&gpi_dma1 0 2 QCOM_GPI_I2C>, - <&gpi_dma1 1 2 QCOM_GPI_I2C>; + dmas =3D <&gpi_dma1 0 2 QCOM_GPI_I2C 64>, + <&gpi_dma1 1 2 QCOM_GPI_I2C 64>; dma-names =3D "tx", "rx"; status =3D "disabled"; }; @@ -1770,8 +1770,8 @@ interconnects =3D <&clk_virt MASTER_QUP_CORE_1 0 &clk_virt SLAVE_QUP_C= ORE_1 0>, <&gem_noc MASTER_APPSS_PROC 0 &cnoc2 SLAVE_QUP_1 0>; interconnect-names =3D "qup-core", "qup-config"; - dmas =3D <&gpi_dma1 0 2 QCOM_GPI_SPI>, - <&gpi_dma1 1 2 QCOM_GPI_SPI>; + dmas =3D <&gpi_dma1 0 2 QCOM_GPI_SPI 64>, + <&gpi_dma1 1 2 QCOM_GPI_SPI 64>; dma-names =3D "tx", "rx"; status =3D "disabled"; }; @@ -1809,8 +1809,8 @@ "qup-memory"; power-domains =3D <&rpmhpd SC7280_CX>; required-opps =3D <&rpmhpd_opp_low_svs>; - dmas =3D <&gpi_dma1 0 3 QCOM_GPI_I2C>, - <&gpi_dma1 1 3 QCOM_GPI_I2C>; + dmas =3D <&gpi_dma1 0 3 QCOM_GPI_I2C 64>, + <&gpi_dma1 1 3 QCOM_GPI_I2C 64>; dma-names =3D "tx", "rx"; status =3D "disabled"; }; @@ -1830,8 +1830,8 @@ interconnects =3D <&clk_virt MASTER_QUP_CORE_1 0 &clk_virt SLAVE_QUP_C= ORE_1 0>, <&gem_noc MASTER_APPSS_PROC 0 &cnoc2 SLAVE_QUP_1 0>; interconnect-names =3D "qup-core", "qup-config"; - dmas =3D <&gpi_dma1 0 3 QCOM_GPI_SPI>, - <&gpi_dma1 1 3 QCOM_GPI_SPI>; + dmas =3D <&gpi_dma1 0 3 QCOM_GPI_SPI 64>, + <&gpi_dma1 1 3 QCOM_GPI_SPI 64>; dma-names =3D "tx", "rx"; status =3D "disabled"; }; @@ -1869,8 +1869,8 @@ "qup-memory"; power-domains =3D <&rpmhpd SC7280_CX>; required-opps =3D <&rpmhpd_opp_low_svs>; - dmas =3D <&gpi_dma1 0 4 QCOM_GPI_I2C>, - <&gpi_dma1 1 4 QCOM_GPI_I2C>; + dmas =3D <&gpi_dma1 0 4 QCOM_GPI_I2C 64>, + <&gpi_dma1 1 4 QCOM_GPI_I2C 64>; dma-names =3D "tx", "rx"; status =3D "disabled"; }; @@ -1890,8 +1890,8 @@ interconnects =3D <&clk_virt MASTER_QUP_CORE_1 0 &clk_virt SLAVE_QUP_C= ORE_1 0>, <&gem_noc MASTER_APPSS_PROC 0 &cnoc2 SLAVE_QUP_1 0>; interconnect-names =3D "qup-core", "qup-config"; - dmas =3D <&gpi_dma1 0 4 QCOM_GPI_SPI>, - <&gpi_dma1 1 4 QCOM_GPI_SPI>; + dmas =3D <&gpi_dma1 0 4 QCOM_GPI_SPI 64>, + <&gpi_dma1 1 4 QCOM_GPI_SPI 64>; dma-names =3D "tx", "rx"; status =3D "disabled"; }; @@ -1929,8 +1929,8 @@ "qup-memory"; power-domains =3D <&rpmhpd SC7280_CX>; required-opps =3D <&rpmhpd_opp_low_svs>; - dmas =3D <&gpi_dma1 0 5 QCOM_GPI_I2C>, - <&gpi_dma1 1 5 QCOM_GPI_I2C>; + dmas =3D <&gpi_dma1 0 5 QCOM_GPI_I2C 64>, + <&gpi_dma1 1 5 QCOM_GPI_I2C 64>; dma-names =3D "tx", "rx"; status =3D "disabled"; }; @@ -1950,8 +1950,8 @@ interconnects =3D <&clk_virt MASTER_QUP_CORE_1 0 &clk_virt SLAVE_QUP_C= ORE_1 0>, <&gem_noc MASTER_APPSS_PROC 0 &cnoc2 SLAVE_QUP_1 0>; interconnect-names =3D "qup-core", "qup-config"; - dmas =3D <&gpi_dma1 0 5 QCOM_GPI_SPI>, - <&gpi_dma1 1 5 QCOM_GPI_SPI>; + dmas =3D <&gpi_dma1 0 5 QCOM_GPI_SPI 64>, + <&gpi_dma1 1 5 QCOM_GPI_SPI 64>; dma-names =3D "tx", "rx"; status =3D "disabled"; }; @@ -1989,8 +1989,8 @@ "qup-memory"; power-domains =3D <&rpmhpd SC7280_CX>; required-opps =3D <&rpmhpd_opp_low_svs>; - dmas =3D <&gpi_dma1 0 6 QCOM_GPI_I2C>, - <&gpi_dma1 1 6 QCOM_GPI_I2C>; + dmas =3D <&gpi_dma1 0 6 QCOM_GPI_I2C 64>, + <&gpi_dma1 1 6 QCOM_GPI_I2C 64>; dma-names =3D "tx", "rx"; status =3D "disabled"; }; @@ -2010,8 +2010,8 @@ interconnects =3D <&clk_virt MASTER_QUP_CORE_1 0 &clk_virt SLAVE_QUP_C= ORE_1 0>, <&gem_noc MASTER_APPSS_PROC 0 &cnoc2 SLAVE_QUP_1 0>; interconnect-names =3D "qup-core", "qup-config"; - dmas =3D <&gpi_dma1 0 6 QCOM_GPI_SPI>, - <&gpi_dma1 1 6 QCOM_GPI_SPI>; + dmas =3D <&gpi_dma1 0 6 QCOM_GPI_SPI 64>, + <&gpi_dma1 1 6 QCOM_GPI_SPI 64>; dma-names =3D "tx", "rx"; status =3D "disabled"; }; @@ -2049,8 +2049,8 @@ "qup-memory"; power-domains =3D <&rpmhpd SC7280_CX>; required-opps =3D <&rpmhpd_opp_low_svs>; - dmas =3D <&gpi_dma1 0 7 QCOM_GPI_I2C>, - <&gpi_dma1 1 7 QCOM_GPI_I2C>; + dmas =3D <&gpi_dma1 0 7 QCOM_GPI_I2C 64>, + <&gpi_dma1 1 7 QCOM_GPI_I2C 64>; dma-names =3D "tx", "rx"; status =3D "disabled"; }; @@ -2070,8 +2070,8 @@ interconnects =3D <&clk_virt MASTER_QUP_CORE_1 0 &clk_virt SLAVE_QUP_C= ORE_1 0>, <&gem_noc MASTER_APPSS_PROC 0 &cnoc2 SLAVE_QUP_1 0>; interconnect-names =3D "qup-core", "qup-config"; - dmas =3D <&gpi_dma1 0 7 QCOM_GPI_SPI>, - <&gpi_dma1 1 7 QCOM_GPI_SPI>; + dmas =3D <&gpi_dma1 0 7 QCOM_GPI_SPI 64>, + <&gpi_dma1 1 7 QCOM_GPI_SPI 64>; dma-names =3D "tx", "rx"; status =3D "disabled"; }; --=20 2.17.1 From nobody Wed Nov 27 00:35:37 2024 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 27E191EBA0B; Tue, 15 Oct 2024 12:08:35 +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=1728994117; cv=none; b=Lmu+O9ZOu/cK4gJBEFQuci47lzxSGdcYXuWHhs6rRuZOho5nmrtDJ1x45k/yZO+ne57PqjLauMQSSJsdmAJogUy7P0HYz5YnFW/YHjyElB8HirDklJjLzJ3Aqby9mvJale1Z2FGazolQ+30H+03LmHwsou+sfCcAdH8h+0Z49HA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728994117; c=relaxed/simple; bh=CwV2sK0pp1WyVLDW1vlXY12XTJ2+Xbe7ibdwMmAHJ68=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pc3XW+E1ueugp+UuxeGJ4xgvA3Eo8N9kI225Umw2qu6jC+UD4gdBKd4xIN0K/RvhXUFLHKfAfp2yUbLSV5VxOrM9T79V1xYwK6SROAlkaDlKxFbxt1UHrfwoLaErsp1L19gf2Qlv8Uh+qhel4aA7do+d/x/a2Ro38TJGrGQPVS4= 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=AK3zCtGx; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="AK3zCtGx" 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 49F81YGZ007476; Tue, 15 Oct 2024 12:08:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to; s=qcppdkim1; bh=cm3GaeCM1QlNiivJ92AjVRJE WR8TMLzyrFLl8F5Vwi0=; b=AK3zCtGxZDuOsfiDxmFIiq4HTRZ5XNdy1b+9sHh7 cMQOf46waZop2PkeM2XT/H1Ye9G8Uo2zYIGUT2xIX+pn8p3LWOw8W7JP844nJgyH xcf38hDQhocrPl2yDQm14VJ1PMXTX0tJXMMcQWyeGUSJba3iwZv57lmp9VzT53N3 HqzZwImiDYGHx1YbB7YrL7Ei0S8Y47rcd0aDr65d5u91zwu0DWhTp/RX65ZXd9jZ Gva32B8TMF6VBWNvc6VLbyBukuiEakNJ6OJB5Oqips2bBJEQaf8oWOyaMC82LaGY jcoCC4hA55/hMdGNYr6+PQtGi6aIV0bn8SfloQjhGpe21Q== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 429mh50m13-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 12:08:28 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA04.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 49FC8Rbi025944 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 12:08:27 GMT Received: from hu-jseerapu-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Tue, 15 Oct 2024 05:08:21 -0700 From: Jyothi Kumar Seerapu To: Vinod Koul , Rob Herring , "Krzysztof Kozlowski" , Conor Dooley , "Bjorn Andersson" , Konrad Dybcio , Andi Shyti , Sumit Semwal , =?UTF-8?q?Christian=20K=C3=B6nig?= CC: , , , , , , , , , , Subject: [PATCH v1 3/5] dmaengine: qcom: gpi: Add provision to support TRE size as the fourth argument of dma-cells property Date: Tue, 15 Oct 2024 17:37:48 +0530 Message-ID: <20241015120750.21217-4-quic_jseerapu@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241015120750.21217-1-quic_jseerapu@quicinc.com> References: <20241015120750.21217-1-quic_jseerapu@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: F8Yq6o2FdINgvP5nTWcx35aTMAssJSks X-Proofpoint-ORIG-GUID: F8Yq6o2FdINgvP5nTWcx35aTMAssJSks X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 spamscore=0 priorityscore=1501 adultscore=0 mlxlogscore=999 lowpriorityscore=0 mlxscore=0 phishscore=0 malwarescore=0 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410150083 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The current GPI driver hardcodes the channel TRE (Transfer Ring Element) size to 64. For scenarios requiring high performance with multiple messages in a transfer, use Block Event Interrupt (BEI). This method triggers interrupt after specific message transfers and the last message transfer, effectively reducing the number of interrupts. For multiple transfers utilizing BEI, a channel TRE size of 64 is insufficient and may lead to transfer failures, indicated by errors related to unavailable memory space. Added provision to modify the channel TRE size via the device tree. The Default channel TRE size is set to 64, but this value can update in the device tree which will then be parsed by the GPI driver. Signed-off-by: Jyothi Kumar Seerapu --- drivers/dma/qcom/gpi.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/drivers/dma/qcom/gpi.c b/drivers/dma/qcom/gpi.c index 52a7c8f2498f..3c89b4a88ac1 100644 --- a/drivers/dma/qcom/gpi.c +++ b/drivers/dma/qcom/gpi.c @@ -234,7 +234,7 @@ enum msm_gpi_tce_code { #define GPI_RX_CHAN (1) #define STATE_IGNORE (U32_MAX) #define EV_FACTOR (2) -#define REQ_OF_DMA_ARGS (5) /* # of arguments required from client */ +#define REQ_OF_DMA_ARGS (3) /* # of arguments required from client */ #define CHAN_TRES 64 =20 struct __packed xfer_compl_event { @@ -481,6 +481,7 @@ struct gchan { u32 chid; u32 seid; u32 protocol; + u32 num_chan_tres; struct gpii *gpii; enum gpi_ch_state ch_state; enum gpi_pm_state pm_state; @@ -1903,8 +1904,8 @@ static int gpi_ch_init(struct gchan *gchan) } =20 /* allocate memory for event ring */ - elements =3D CHAN_TRES << ev_factor; - ret =3D gpi_alloc_ring(&gpii->ev_ring, elements, + elements =3D max(gpii->gchan[0].num_chan_tres, gpii->gchan[1].num_chan_tr= es); + ret =3D gpi_alloc_ring(&gpii->ev_ring, elements << ev_factor, sizeof(union gpi_event), gpii); if (ret) goto exit_gpi_init; @@ -2042,7 +2043,7 @@ static int gpi_alloc_chan_resources(struct dma_chan *= chan) mutex_lock(&gpii->ctrl_lock); =20 /* allocate memory for transfer ring */ - ret =3D gpi_alloc_ring(&gchan->ch_ring, CHAN_TRES, + ret =3D gpi_alloc_ring(&gchan->ch_ring, gchan->num_chan_tres, sizeof(struct gpi_tre), gpii); if (ret) goto xfer_alloc_err; @@ -2107,9 +2108,9 @@ static struct dma_chan *gpi_of_dma_xlate(struct of_ph= andle_args *args, int gpii; struct gchan *gchan; =20 - if (args->args_count < 3) { - dev_err(gpi_dev->dev, "gpii require minimum 2 args, client passed:%d arg= s\n", - args->args_count); + if (args->args_count < REQ_OF_DMA_ARGS) { + dev_err(gpi_dev->dev, "gpii require minimum %d args, client passed:%d ar= gs\n", + REQ_OF_DMA_ARGS, args->args_count); return NULL; } =20 @@ -2138,6 +2139,16 @@ static struct dma_chan *gpi_of_dma_xlate(struct of_p= handle_args *args, gchan->seid =3D seid; gchan->protocol =3D args->args[2]; =20 + /* + * If the channel tre size entry is present in device tree and + * channel tre size is greater than 64 then parse the value from + * the device tree, otherwise use the default value, which is 64. + */ + if (args->args_count > REQ_OF_DMA_ARGS && args->args[3] > CHAN_TRES) + gchan->num_chan_tres =3D args->args[3]; + else + gchan->num_chan_tres =3D CHAN_TRES; + return dma_get_slave_channel(&gchan->vc.chan); } =20 --=20 2.17.1 From nobody Wed Nov 27 00:35:37 2024 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 792CB1F890F; Tue, 15 Oct 2024 12:08:42 +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=1728994125; cv=none; b=EK3dg3wBJHBXbYIhsf0GdoADcfz80XzWA8DqMhBfhbTDeHmjFrgdtkTYoEJcZz+d1O+vNL8gwum8v1qBN/478V7me5oC44NfSgkIOuojruPKURVFvU86z2mz9uLacJclQywnOmN7s+uD2WnM19ED0vI8OZDNU9nBySbpUxyJ2cQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728994125; c=relaxed/simple; bh=mj5RauSO/liewGiosP+B7urk0xGqdqBiGXVhuvMwJc8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YOe1l686uRcHVqR3co6tJ/4tcZC1VJi1BeKSbLzD5H+UvX5jxVKSHWyniVzbHAP8reEFmVZkm2eduq9l76Gpa1wJrApx/cOaFMzugKIpc6iGNUHNTWsAXPbF6kSLZOr2pT3DCWK+Q9NQv0ztDu5IX//DqH8EVBIjVw9HrODV1TY= 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=CSG9FKuk; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="CSG9FKuk" Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49FC5BoS023375; Tue, 15 Oct 2024 12:08:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to; s=qcppdkim1; bh=P+4ofdEIAV7EXx+X3B4PmdFg yiGukoosZaG+P3Ti4U0=; b=CSG9FKukdA2oyjk/zgmW8yIFMDhkCKUgDXQ8X/jb FvEI1zjmP2nOrkmfFpNNuJRyIqp6IzBNehUCtXjjPzASgpqzr1NacqIAqIGNpTlk 2/B09j4pzeNftVgiyCEH+G79KYKvbI5z0ykS8X+HnBxXAYMFz2oF8TsaFv+yREGW zbw2XUW7RaqenY/mGZeUY4KRcv9wZLaV1kvKTPyophd2ppibLeOZu2oYzzVAYOG5 k36n2L5YDKb4G9IqNKvPwfrFYsnc0mFaaQNrxCuQDnXpFJ0m1i9nxR0AOLbZbHyc XLr5bVTnTM3IBS5i9qdnk4y5tI42S/I+cSMxnfkKE9LjMg== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 429r3b809j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 12:08:33 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA03.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 49FC8XRY027419 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 12:08:33 GMT Received: from hu-jseerapu-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Tue, 15 Oct 2024 05:08:27 -0700 From: Jyothi Kumar Seerapu To: Vinod Koul , Rob Herring , "Krzysztof Kozlowski" , Conor Dooley , "Bjorn Andersson" , Konrad Dybcio , Andi Shyti , Sumit Semwal , =?UTF-8?q?Christian=20K=C3=B6nig?= CC: , , , , , , , , , , Subject: [PATCH v1 4/5] dmaengine: qcom: gpi: Add GPI Block event interrupt support Date: Tue, 15 Oct 2024 17:37:49 +0530 Message-ID: <20241015120750.21217-5-quic_jseerapu@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241015120750.21217-1-quic_jseerapu@quicinc.com> References: <20241015120750.21217-1-quic_jseerapu@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: aEFO6pLAIX0YeBZ9ROqnvKFdp91C0S1f X-Proofpoint-GUID: aEFO6pLAIX0YeBZ9ROqnvKFdp91C0S1f X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 mlxscore=0 priorityscore=1501 clxscore=1015 adultscore=0 lowpriorityscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 suspectscore=0 spamscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410150083 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" GSI hardware generates an interrupt for each transfer completion. For multiple messages within a single transfer, this results in receiving N interrupts for N messages, which can introduce significant software interrupt latency. To mitigate this latency, utilize Block Event Interrupt (BEI) only when an interrupt is necessary. When using BEI, consider splitting a single multi-message transfer into chunks of 64. This approach can enhance overall transfer time and efficiency. Signed-off-by: Jyothi Kumar Seerapu --- drivers/dma/qcom/gpi.c | 49 ++++++++++++++++++++++++++++++++ include/linux/dma/qcom-gpi-dma.h | 37 ++++++++++++++++++++++++ 2 files changed, 86 insertions(+) diff --git a/drivers/dma/qcom/gpi.c b/drivers/dma/qcom/gpi.c index 3c89b4a88ac1..b8ca119114d2 100644 --- a/drivers/dma/qcom/gpi.c +++ b/drivers/dma/qcom/gpi.c @@ -1694,6 +1694,9 @@ static int gpi_create_i2c_tre(struct gchan *chan, str= uct gpi_desc *desc, =20 tre->dword[3] =3D u32_encode_bits(TRE_TYPE_DMA, TRE_FLAGS_TYPE); tre->dword[3] |=3D u32_encode_bits(1, TRE_FLAGS_IEOT); + + if (i2c->flags & QCOM_GPI_BLOCK_EVENT_IRQ) + tre->dword[3] |=3D u32_encode_bits(1, TRE_FLAGS_BEI); } =20 for (i =3D 0; i < tre_idx; i++) @@ -2099,6 +2102,52 @@ static int gpi_find_avail_gpii(struct gpi_dev *gpi_d= ev, u32 seid) return -EIO; } =20 +/** + * gpi_multi_desc_process() - Process received transfers from GSI HW + * @dev: pointer to the corresponding dev node + * @multi_xfer: pointer to the gpi_multi_xfer + * @num_xfers: total number of transfers + * @transfer_timeout_msecs: transfer timeout value + * @transfer_comp: completion object of the transfer + * + * This function is used to process the received transfers based on the + * completion events + * + * Return: On success returns 0, otherwise return error code + */ +int gpi_multi_desc_process(struct device *dev, struct gpi_multi_xfer *mult= i_xfer, + u32 num_xfers, u32 transfer_timeout_msecs, + struct completion *transfer_comp) +{ + int i; + u32 max_irq_cnt, time_left; + + max_irq_cnt =3D num_xfers / NUM_MSGS_PER_IRQ; + if (num_xfers % NUM_MSGS_PER_IRQ) + max_irq_cnt++; + + /* + * Wait for the interrupts of the processed transfers in multiple + * of 64 and for the last transfer. If the hardware is fast and + * already processed all the transfers then no need to wait. + */ + for (i =3D 0; i < max_irq_cnt; i++) { + reinit_completion(transfer_comp); + if (max_irq_cnt !=3D multi_xfer->irq_cnt) { + time_left =3D wait_for_completion_timeout(transfer_comp, + transfer_timeout_msecs); + if (!time_left) { + dev_err(dev, "%s: Transfer timeout\n", __func__); + return -ETIMEDOUT; + } + } + if (num_xfers > multi_xfer->msg_idx_cnt) + return 0; + } + return 0; +} +EXPORT_SYMBOL_GPL(gpi_multi_desc_process); + /* gpi_of_dma_xlate: open client requested channel */ static struct dma_chan *gpi_of_dma_xlate(struct of_phandle_args *args, struct of_dma *of_dma) diff --git a/include/linux/dma/qcom-gpi-dma.h b/include/linux/dma/qcom-gpi-= dma.h index 6680dd1a43c6..ca0465627a21 100644 --- a/include/linux/dma/qcom-gpi-dma.h +++ b/include/linux/dma/qcom-gpi-dma.h @@ -15,6 +15,12 @@ enum spi_transfer_cmd { SPI_DUPLEX, }; =20 +#define QCOM_GPI_BLOCK_EVENT_IRQ BIT(0) + +#define QCOM_GPI_MAX_NUM_MSGS 200 +#define NUM_MSGS_PER_IRQ 64 +#define MIN_NUM_OF_MSGS_MULTI_DESC 4 + /** * struct gpi_spi_config - spi config for peripheral * @@ -51,6 +57,29 @@ enum i2c_op { I2C_READ, }; =20 +/** + * struct gpi_multi_xfer - Used for multi transfer support + * + * @msg_idx_cnt: message index for the transfer + * @buf_idx: dma buffer index + * @unmap_msg_cnt: unampped transfer index + * @freed_msg_cnt: freed transfer index + * @irq_cnt: received interrupt count + * @irq_msg_cnt: transfer message count for the received irqs + * @dma_buf: virtual address of the buffer + * @dma_addr: dma address of the buffer + */ +struct gpi_multi_xfer { + u32 msg_idx_cnt; + u32 buf_idx; + u32 unmap_msg_cnt; + u32 freed_msg_cnt; + u32 irq_cnt; + u32 irq_msg_cnt; + void *dma_buf[QCOM_GPI_MAX_NUM_MSGS]; + dma_addr_t *dma_addr[QCOM_GPI_MAX_NUM_MSGS]; +}; + /** * struct gpi_i2c_config - i2c config for peripheral * @@ -65,6 +94,8 @@ enum i2c_op { * @rx_len: receive length for buffer * @op: i2c cmd * @muli-msg: is part of multi i2c r-w msgs + * @flags: true for block event interrupt support + * @multi_xfer: indicates transfer has multi messages */ struct gpi_i2c_config { u8 set_config; @@ -78,6 +109,12 @@ struct gpi_i2c_config { u32 rx_len; enum i2c_op op; bool multi_msg; + u8 flags; + struct gpi_multi_xfer multi_xfer; }; =20 +int gpi_multi_desc_process(struct device *dev, struct gpi_multi_xfer *mult= i_xfer, + u32 num_xfers, u32 tranfer_timeout_msecs, + struct completion *transfer_comp); + #endif /* QCOM_GPI_DMA_H */ --=20 2.17.1 From nobody Wed Nov 27 00:35:37 2024 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 BFE941F8EE0; Tue, 15 Oct 2024 12:08:48 +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=1728994130; cv=none; b=KGpRAwNFdG7Ni28brTjRGGJNZHkBgXwSZALwgD/rr3KwtSsiv8cd1cG+vZ02qtR51FK/f+oCVdzwqpBcYR+OfMiTy0lV/Aecg9v7nOATgMTtx4nSNNLabejhgWNLnq3a5fe+7uvwh25qPkBHRwLqKe24I+bKVY4jPJ6m073HqW0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728994130; c=relaxed/simple; bh=PB7ITYqeJHSWN7dDeshEQNuJtkk65I1VUnMHSCBdzG0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dwCD9EGpHzCjBdMlEqrLxXBnu+7er217YEdXnY6FMGCCUJ5+7TV9FciXoI3cFTD+k6O7e6TcN8ldda9lwZ7IvCFqw28amXDCXPGHWF3gwizuNFyQ1/RVjQt5Q2zKE95WXZdx8sjdq1GERCHm7Uf3H3+cRwJsP1Sv2AYK/qstkEY= 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=UQ8nc6OV; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="UQ8nc6OV" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49FBVKeL028539; Tue, 15 Oct 2024 12:08:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to; s=qcppdkim1; bh=0o+CFFxLvBXPtKGJfpW0Lc+u 4Hdpi4klAbpdj7dOxbo=; b=UQ8nc6OVoj2T1cUFmbiFhoDzX1VPgK2JurHgv3CV 2xWxpnx7o3xe7q7gMEXPWTb51sCwhJOog74LEaE6w0C6x/myR6wWkvmgkSV8l0UW 9wrhgn9culQTSVYb89NVrDnkN/Y45fE0G2Z7FCgIPZErAXhV8kyWCoyPrxnAR87c 4e2KjBY5IlegTpkQ1b0y7jRYDy9lqot7t5asdpzuPUdrZusbiTUOtMgxTr+nVrsd INGt1FFpqOsghmUtTTms3zrzhEtBAQD5PsVm83/c3fxJs8yjSC5NRton/W/holIl YNh0K5yeiTfzr0zuANdfJE9ubzh2bobm1hE/WDP8EcALyg== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4292evk69c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 12:08:39 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA05.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 49FC8c79011440 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 12:08:38 GMT Received: from hu-jseerapu-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Tue, 15 Oct 2024 05:08:33 -0700 From: Jyothi Kumar Seerapu To: Vinod Koul , Rob Herring , "Krzysztof Kozlowski" , Conor Dooley , "Bjorn Andersson" , Konrad Dybcio , Andi Shyti , Sumit Semwal , =?UTF-8?q?Christian=20K=C3=B6nig?= CC: , , , , , , , , , , Subject: [PATCH v1 5/5] i2c: i2c-qcom-geni: Add Block event interrupt support Date: Tue, 15 Oct 2024 17:37:50 +0530 Message-ID: <20241015120750.21217-6-quic_jseerapu@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241015120750.21217-1-quic_jseerapu@quicinc.com> References: <20241015120750.21217-1-quic_jseerapu@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: igqfXn0az7sxVPtrNFgXme81UVCGm5Qq X-Proofpoint-ORIG-GUID: igqfXn0az7sxVPtrNFgXme81UVCGm5Qq X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 priorityscore=1501 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 phishscore=0 adultscore=0 bulkscore=0 mlxscore=0 impostorscore=0 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410150083 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The I2C driver gets an interrupt upon transfer completion. For multiple messages in a single transfer, N interrupts will be received for N messages, leading to significant software interrupt latency. To mitigate this latency, utilize Block Event Interrupt (BEI) only when an interrupt is necessary. This means large transfers can be split into multiple chunks of 64 messages internally, without expecting interrupts for the first 63 transfers, only the last one will trigger an interrupt indicating 64 transfers completed. By implementing BEI, multi-message transfers can be divided into chunks of 64 messages, improving overall transfer time. This optimization reduces transfer time from 168 ms to 48 ms for a series of 200 I2C write messages in a single transfer, with a clock frequency support of 100 kHz. BEI optimizations are currently implemented for I2C write transfers only, as there is no use case for multiple I2C read messages in a single transfer at this time. Signed-off-by: Jyothi Kumar Seerapu --- drivers/i2c/busses/i2c-qcom-geni.c | 205 +++++++++++++++++++++++++---- 1 file changed, 181 insertions(+), 24 deletions(-) diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qc= om-geni.c index 212336f724a6..a73dc1738a62 100644 --- a/drivers/i2c/busses/i2c-qcom-geni.c +++ b/drivers/i2c/busses/i2c-qcom-geni.c @@ -99,6 +99,10 @@ struct geni_i2c_dev { struct dma_chan *rx_c; bool gpi_mode; bool abort_done; + bool is_tx_multi_xfer; + u32 num_msgs; + u32 tx_irq_cnt; + struct gpi_i2c_config *gpi_config; }; =20 struct geni_i2c_desc { @@ -485,6 +489,7 @@ static int geni_i2c_tx_one_msg(struct geni_i2c_dev *gi2= c, struct i2c_msg *msg, static void i2c_gpi_cb_result(void *cb, const struct dmaengine_result *res= ult) { struct geni_i2c_dev *gi2c =3D cb; + struct gpi_multi_xfer *tx_multi_xfer; =20 if (result->result !=3D DMA_TRANS_NOERROR) { dev_err(gi2c->se.dev, "DMA txn failed:%d\n", result->result); @@ -493,7 +498,21 @@ static void i2c_gpi_cb_result(void *cb, const struct d= maengine_result *result) dev_dbg(gi2c->se.dev, "DMA xfer has pending: %d\n", result->residue); } =20 - complete(&gi2c->done); + if (gi2c->is_tx_multi_xfer) { + tx_multi_xfer =3D &gi2c->gpi_config->multi_xfer; + + /* + * Send Completion for last message or multiple of NUM_MSGS_PER_IRQ. + */ + if ((tx_multi_xfer->irq_msg_cnt =3D=3D gi2c->num_msgs - 1) || + (!((tx_multi_xfer->irq_msg_cnt + 1) % NUM_MSGS_PER_IRQ))) { + tx_multi_xfer->irq_cnt++; + complete(&gi2c->done); + } + tx_multi_xfer->irq_msg_cnt++; + } else { + complete(&gi2c->done); + } } =20 static void geni_i2c_gpi_unmap(struct geni_i2c_dev *gi2c, struct i2c_msg *= msg, @@ -511,7 +530,41 @@ static void geni_i2c_gpi_unmap(struct geni_i2c_dev *gi= 2c, struct i2c_msg *msg, } } =20 -static int geni_i2c_gpi(struct geni_i2c_dev *gi2c, struct i2c_msg *msg, +/** + * gpi_i2c_multi_desc_unmap() - unmaps the buffers post multi message TX t= ransfers + * @dev: pointer to the corresponding dev node + * @gi2c: i2c dev handle + * @msgs: i2c messages array + * @peripheral: pointer to the gpi_i2c_config + */ +static void gpi_i2c_multi_desc_unmap(struct geni_i2c_dev *gi2c, struct i2c= _msg msgs[], + struct gpi_i2c_config *peripheral) +{ + u32 msg_xfer_cnt, wr_idx =3D 0; + struct gpi_multi_xfer *tx_multi_xfer =3D &peripheral->multi_xfer; + + /* + * In error case, need to unmap all messages based on the msg_idx_cnt. + * Non-error case unmap all the processed messages. + */ + if (gi2c->err) + msg_xfer_cnt =3D tx_multi_xfer->msg_idx_cnt; + else + msg_xfer_cnt =3D tx_multi_xfer->irq_cnt * NUM_MSGS_PER_IRQ; + + /* Unmap the processed DMA buffers based on the received interrupt count = */ + for (; tx_multi_xfer->unmap_msg_cnt < msg_xfer_cnt; tx_multi_xfer->unmap_= msg_cnt++) { + if (tx_multi_xfer->unmap_msg_cnt =3D=3D gi2c->num_msgs) + break; + wr_idx =3D tx_multi_xfer->unmap_msg_cnt % QCOM_GPI_MAX_NUM_MSGS; + geni_i2c_gpi_unmap(gi2c, &msgs[tx_multi_xfer->unmap_msg_cnt], + tx_multi_xfer->dma_buf[wr_idx], + tx_multi_xfer->dma_addr[wr_idx], NULL, NULL); + tx_multi_xfer->freed_msg_cnt++; + } +} + +static int geni_i2c_gpi(struct geni_i2c_dev *gi2c, struct i2c_msg msgs[], = int cur_msg_idx, struct dma_slave_config *config, dma_addr_t *dma_addr_p, void **buf, unsigned int op, struct dma_chan *dma_chan) { @@ -523,26 +576,49 @@ static int geni_i2c_gpi(struct geni_i2c_dev *gi2c, st= ruct i2c_msg *msg, enum dma_transfer_direction dma_dirn; struct dma_async_tx_descriptor *desc; int ret; + struct gpi_multi_xfer *gi2c_gpi_xfer; + dma_cookie_t cookie; =20 peripheral =3D config->peripheral_config; - - dma_buf =3D i2c_get_dma_safe_msg_buf(msg, 1); - if (!dma_buf) + gi2c_gpi_xfer =3D &peripheral->multi_xfer; + gi2c_gpi_xfer->msg_idx_cnt =3D cur_msg_idx; + dma_buf =3D gi2c_gpi_xfer->dma_buf[gi2c_gpi_xfer->buf_idx]; + addr =3D gi2c_gpi_xfer->dma_addr[gi2c_gpi_xfer->buf_idx]; + + dma_buf =3D i2c_get_dma_safe_msg_buf(&msgs[gi2c_gpi_xfer->msg_idx_cnt], 1= ); + if (!dma_buf) { + gi2c->err =3D -ENOMEM; return -ENOMEM; + } =20 if (op =3D=3D I2C_WRITE) map_dirn =3D DMA_TO_DEVICE; else map_dirn =3D DMA_FROM_DEVICE; =20 - addr =3D dma_map_single(gi2c->se.dev->parent, dma_buf, msg->len, map_dirn= ); + addr =3D dma_map_single(gi2c->se.dev->parent, + dma_buf, msgs[gi2c_gpi_xfer->msg_idx_cnt].len, + map_dirn); if (dma_mapping_error(gi2c->se.dev->parent, addr)) { - i2c_put_dma_safe_msg_buf(dma_buf, msg, false); + i2c_put_dma_safe_msg_buf(dma_buf, &msgs[gi2c_gpi_xfer->msg_idx_cnt], + false); + gi2c->err =3D -ENOMEM; return -ENOMEM; } =20 + if (gi2c->is_tx_multi_xfer) { + if (((gi2c_gpi_xfer->msg_idx_cnt + 1) % NUM_MSGS_PER_IRQ)) + peripheral->flags |=3D QCOM_GPI_BLOCK_EVENT_IRQ; + else + peripheral->flags &=3D ~QCOM_GPI_BLOCK_EVENT_IRQ; + + /* BEI bit to be cleared for last TRE */ + if (gi2c_gpi_xfer->msg_idx_cnt =3D=3D gi2c->num_msgs - 1) + peripheral->flags &=3D ~QCOM_GPI_BLOCK_EVENT_IRQ; + } + /* set the length as message for rx txn */ - peripheral->rx_len =3D msg->len; + peripheral->rx_len =3D msgs[gi2c_gpi_xfer->msg_idx_cnt].len; peripheral->op =3D op; =20 ret =3D dmaengine_slave_config(dma_chan, config); @@ -560,25 +636,56 @@ static int geni_i2c_gpi(struct geni_i2c_dev *gi2c, st= ruct i2c_msg *msg, else dma_dirn =3D DMA_DEV_TO_MEM; =20 - desc =3D dmaengine_prep_slave_single(dma_chan, addr, msg->len, dma_dirn, = flags); + desc =3D dmaengine_prep_slave_single(dma_chan, addr, + msgs[gi2c_gpi_xfer->msg_idx_cnt].len, + dma_dirn, flags); if (!desc) { dev_err(gi2c->se.dev, "prep_slave_sg failed\n"); - ret =3D -EIO; + gi2c->err =3D -EIO; goto err_config; } =20 desc->callback_result =3D i2c_gpi_cb_result; desc->callback_param =3D gi2c; =20 - dmaengine_submit(desc); - *buf =3D dma_buf; - *dma_addr_p =3D addr; + if (!((msgs[cur_msg_idx].flags & I2C_M_RD) && op =3D=3D I2C_WRITE)) { + gi2c_gpi_xfer->msg_idx_cnt++; + gi2c_gpi_xfer->buf_idx =3D (cur_msg_idx + 1) % QCOM_GPI_MAX_NUM_MSGS; + } + cookie =3D dmaengine_submit(desc); + if (dma_submit_error(cookie)) { + dev_err(gi2c->se.dev, + "%s: dmaengine_submit failed (%d)\n", __func__, cookie); + return -EINVAL; + } =20 + if (gi2c->is_tx_multi_xfer) { + dma_async_issue_pending(gi2c->tx_c); + if ((cur_msg_idx =3D=3D (gi2c->num_msgs - 1)) || + (gi2c_gpi_xfer->msg_idx_cnt >=3D + QCOM_GPI_MAX_NUM_MSGS + gi2c_gpi_xfer->freed_msg_cnt)) { + ret =3D gpi_multi_desc_process(gi2c->se.dev, gi2c_gpi_xfer, + gi2c->num_msgs, XFER_TIMEOUT, + &gi2c->done); + if (ret) { + dev_dbg(gi2c->se.dev, + "I2C multi write msg transfer timeout: %d\n", + ret); + gi2c->err =3D -ETIMEDOUT; + goto err_config; + } + } + } else { + /* Non multi descriptor message transfer */ + *buf =3D dma_buf; + *dma_addr_p =3D addr; + } return 0; =20 err_config: - dma_unmap_single(gi2c->se.dev->parent, addr, msg->len, map_dirn); - i2c_put_dma_safe_msg_buf(dma_buf, msg, false); + dma_unmap_single(gi2c->se.dev->parent, addr, + msgs[cur_msg_idx].len, map_dirn); + i2c_put_dma_safe_msg_buf(dma_buf, &msgs[cur_msg_idx], false); return ret; } =20 @@ -590,6 +697,7 @@ static int geni_i2c_gpi_xfer(struct geni_i2c_dev *gi2c,= struct i2c_msg msgs[], i unsigned long time_left; dma_addr_t tx_addr, rx_addr; void *tx_buf =3D NULL, *rx_buf =3D NULL; + struct gpi_multi_xfer *tx_multi_xfer; const struct geni_i2c_clk_fld *itr =3D gi2c->clk_fld; =20 config.peripheral_config =3D &peripheral; @@ -603,6 +711,39 @@ static int geni_i2c_gpi_xfer(struct geni_i2c_dev *gi2c= , struct i2c_msg msgs[], i peripheral.set_config =3D 1; peripheral.multi_msg =3D false; =20 + gi2c->gpi_config =3D &peripheral; + gi2c->num_msgs =3D num; + gi2c->is_tx_multi_xfer =3D false; + gi2c->tx_irq_cnt =3D 0; + + tx_multi_xfer =3D &peripheral.multi_xfer; + tx_multi_xfer->msg_idx_cnt =3D 0; + tx_multi_xfer->buf_idx =3D 0; + tx_multi_xfer->unmap_msg_cnt =3D 0; + tx_multi_xfer->freed_msg_cnt =3D 0; + tx_multi_xfer->irq_msg_cnt =3D 0; + tx_multi_xfer->irq_cnt =3D 0; + + /* + * If number of write messages are four and higher then + * configure hardware for multi descriptor transfers with BEI. + */ + if (num >=3D MIN_NUM_OF_MSGS_MULTI_DESC) { + gi2c->is_tx_multi_xfer =3D true; + for (i =3D 0; i < num; i++) { + if (msgs[i].flags & I2C_M_RD) { + /* + * Multi descriptor transfer with BEI + * support is enabled for write transfers. + * Add BEI optimization support for read + * transfers later. + */ + gi2c->is_tx_multi_xfer =3D false; + break; + } + } + } + for (i =3D 0; i < num; i++) { gi2c->cur =3D &msgs[i]; gi2c->err =3D 0; @@ -613,14 +754,16 @@ static int geni_i2c_gpi_xfer(struct geni_i2c_dev *gi2= c, struct i2c_msg msgs[], i peripheral.stretch =3D 1; =20 peripheral.addr =3D msgs[i].addr; + if (i > 0 && (!(msgs[i].flags & I2C_M_RD))) + peripheral.multi_msg =3D false; =20 - ret =3D geni_i2c_gpi(gi2c, &msgs[i], &config, + ret =3D geni_i2c_gpi(gi2c, msgs, i, &config, &tx_addr, &tx_buf, I2C_WRITE, gi2c->tx_c); if (ret) goto err; =20 if (msgs[i].flags & I2C_M_RD) { - ret =3D geni_i2c_gpi(gi2c, &msgs[i], &config, + ret =3D geni_i2c_gpi(gi2c, msgs, i, &config, &rx_addr, &rx_buf, I2C_READ, gi2c->rx_c); if (ret) goto err; @@ -628,18 +771,28 @@ static int geni_i2c_gpi_xfer(struct geni_i2c_dev *gi2= c, struct i2c_msg msgs[], i dma_async_issue_pending(gi2c->rx_c); } =20 - dma_async_issue_pending(gi2c->tx_c); - - time_left =3D wait_for_completion_timeout(&gi2c->done, XFER_TIMEOUT); - if (!time_left) - gi2c->err =3D -ETIMEDOUT; + if (!gi2c->is_tx_multi_xfer) { + dma_async_issue_pending(gi2c->tx_c); + time_left =3D wait_for_completion_timeout(&gi2c->done, XFER_TIMEOUT); + if (!time_left) { + dev_err(gi2c->se.dev, "%s:I2C timeout\n", __func__); + gi2c->err =3D -ETIMEDOUT; + } + } =20 if (gi2c->err) { ret =3D gi2c->err; goto err; } =20 - geni_i2c_gpi_unmap(gi2c, &msgs[i], tx_buf, tx_addr, rx_buf, rx_addr); + if (!gi2c->is_tx_multi_xfer) { + geni_i2c_gpi_unmap(gi2c, &msgs[i], tx_buf, tx_addr, rx_buf, rx_addr); + } else { + if (gi2c->tx_irq_cnt !=3D tx_multi_xfer->irq_cnt) { + gi2c->tx_irq_cnt =3D tx_multi_xfer->irq_cnt; + gpi_i2c_multi_desc_unmap(gi2c, msgs, &peripheral); + } + } } =20 return num; @@ -648,7 +801,11 @@ static int geni_i2c_gpi_xfer(struct geni_i2c_dev *gi2c= , struct i2c_msg msgs[], i dev_err(gi2c->se.dev, "GPI transfer failed: %d\n", ret); dmaengine_terminate_sync(gi2c->rx_c); dmaengine_terminate_sync(gi2c->tx_c); - geni_i2c_gpi_unmap(gi2c, &msgs[i], tx_buf, tx_addr, rx_buf, rx_addr); + if (gi2c->is_tx_multi_xfer) + gpi_i2c_multi_desc_unmap(gi2c, msgs, &peripheral); + else + geni_i2c_gpi_unmap(gi2c, &msgs[i], tx_buf, tx_addr, rx_buf, rx_addr); + return ret; } =20 --=20 2.17.1