From nobody Wed Oct 8 21:36:50 2025 Received: from mx0a-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) (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 CE37927A917 for ; Tue, 24 Jun 2025 09:07:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.135.77 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750756056; cv=none; b=Y102PkEdLaPy/FLnkFIWoeNIAiHyLI4KpsvZ4gvhkslgZoZzkNhrOxx/y0KncUbX8G1ibvzo0o0CLd/+uatjw+L+iuN6P+WQZB3d4P0UncA5dPpl5O2Bcu0fMcDl9ASupEPVvDTkpwQIggSz6uOVPWwwJZBVlKefUZiDXpiDL3g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750756056; c=relaxed/simple; bh=HfDaL1+3ZZH7qU0UrdVmwCMTo/BAN5wJ95E8N0SQOVA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=D8Sgykjr8PmP0n29k0fHqxeAIrZtTAtDY2z6rqewQIoES861pL/gYlyxO59Zwm5LI4PgX95QpPOPyA/CM/iS8pNQCJoxNE7ReNvgaTsTZOzQ0qrSi1euAuzJkD3aErxPCdjDlom8+riiagcJH9vSB84ozOvjldL1p7/mmHadXdk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=analog.com; spf=pass smtp.mailfrom=analog.com; dkim=pass (2048-bit key) header.d=analog.com header.i=@analog.com header.b=dED7wLVU; arc=none smtp.client-ip=148.163.135.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=analog.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=analog.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=analog.com header.i=@analog.com header.b="dED7wLVU" Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 55O6vAGN016424; Tue, 24 Jun 2025 05:07:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=ZFVYa UcJ8QJdBtj22eJipmqjgLTId7OEXFrgqfcYbfw=; b=dED7wLVUO9R3U4UOjXJRz oSMQ0QbDCEH7TNrWp+Kirdhp65lEGNMV7m2jeBhR2x+u6E098dRz0bo/KAka/2tM Goibl5y8oR42u/Ax7DxTBScLU2WY+0d0zlR+ZArObLwPzCcqpZHoB/mya+aT1tdU VeBbXk1NyOKSmKYkXoeu92wm1squsiG/ATKsiFYnmDTOPz3ks1OwcBz91kOMwePn ncYMJ5iH6QYLy4qoKxMzf0gm84BzHLHSkhRY+At6G/lmIaOHldmVEQCIAZU8AHEC csk9ihs2/BlKWeo5N7xPGH3tfWlFmrHvPUu6Y34sP8TbB/EQs/o8clk4FDEStBin g== Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 47dpk9enxv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 24 Jun 2025 05:07:17 -0400 (EDT) Received: from ASHBMBX8.ad.analog.com (ASHBMBX8.ad.analog.com [10.64.17.5]) by nwd2mta3.analog.com (8.14.7/8.14.7) with ESMTP id 55O97F1A012602 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 24 Jun 2025 05:07:15 -0400 Received: from ASHBCASHYB5.ad.analog.com (10.64.17.133) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Tue, 24 Jun 2025 05:07:15 -0400 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBCASHYB5.ad.analog.com (10.64.17.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Tue, 24 Jun 2025 05:07:15 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.1748.10 via Frontend Transport; Tue, 24 Jun 2025 05:07:15 -0400 Received: from HYB-DlYm71t3hSl.ad.analog.com (HYB-DlYm71t3hSl.ad.analog.com [10.44.3.55] (may be forged)) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 55O973ao007498; Tue, 24 Jun 2025 05:07:10 -0400 From: Jorge Marques Date: Tue, 24 Jun 2025 11:06:04 +0200 Subject: [PATCH v3 1/3] i3c: master: Add inline i3c_readl_fifo() and i3c_writel_fifo() 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: <20250624-i3c-writesl-readsl-v3-1-63ccf0870f01@analog.com> References: <20250624-i3c-writesl-readsl-v3-0-63ccf0870f01@analog.com> In-Reply-To: <20250624-i3c-writesl-readsl-v3-0-63ccf0870f01@analog.com> To: Alexandre Belloni , Frank Li , =?utf-8?q?Przemys=C5=82aw_Gaj?= CC: , , "Jorge Marques" X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1750756023; l=1856; i=jorge.marques@analog.com; s=20250303; h=from:subject:message-id; bh=HfDaL1+3ZZH7qU0UrdVmwCMTo/BAN5wJ95E8N0SQOVA=; b=MX2OdZVXP3WUYbaV5W5gev/9zEQjAMYLZ3UF5hGa4mUxtsD3MgrB503Q0kAKF5tRTYfH7ewjJ TA6L7J9BPt4DXftOK6eKiG6WqLplJn6XW0SXH5EoCYmvRXjljxwt5Tx X-Developer-Key: i=jorge.marques@analog.com; a=ed25519; pk=NUR1IZZMH0Da3QbJ2tBSznSPVfRpuoWdhBzKGSpAdbg= X-ADIRuleOP-NewSCL: Rule Triggered X-Authority-Analysis: v=2.4 cv=aclhnQot c=1 sm=1 tr=0 ts=685a6ac5 cx=c_pps a=PpDZqlmH/M8setHirZLBMw==:117 a=PpDZqlmH/M8setHirZLBMw==:17 a=IkcTkHD0fZMA:10 a=6IFa9wvqVegA:10 a=gAnH3GRIAAAA:8 a=Xws4TFRhkSG2vrPBptAA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNjI0MDA3NyBTYWx0ZWRfX92rQiST2s3fr J+Itrn3Sk1MTEo+cxLmt10G+7KWyKJN6YlCeIDP23+zQznAtzK/+pVwQZ6MLobK/RViZZiHOJ2r qih223Uy79PV8qZm/bqKReTTpbdWao4sQs5/tPKSvH8vaeYHX2b5aTzOImIu/5Nj+SEH/64V/Xi xOgJr0CCIBPgIZmKS/U2gNw59Kqq6S78gNCq5sc+8OGDe2yVd0UnfTIDA44motWlu5LyCovSXwP j3cC19ppxsuXqhptu88DSl5StUeusNeB56poySrn4lnnHTnQjvB7qVpAk/NaQZUFB1627PVCLGS KSf6JN9BoT1PJc/yVnBMBve7dHzYsy6DZBza2xusY1bszCq2OJUiJIGb6zBGz3zB22beo8lp2Z5 wumZrmDPhJDW71D/EWrJHLT/2JcA8N8IpiTNqe0w0bu6r0mUpAqTVOZLCJGyAzlnbkN0OAwp X-Proofpoint-ORIG-GUID: zxH2MtxFqNAamX6WOWD3AzazaBD3zz7Y X-Proofpoint-GUID: zxH2MtxFqNAamX6WOWD3AzazaBD3zz7Y X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-06-24_03,2025-06-23_07,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 spamscore=0 malwarescore=0 bulkscore=0 clxscore=1015 lowpriorityscore=0 suspectscore=0 mlxlogscore=824 phishscore=0 adultscore=0 mlxscore=0 priorityscore=1501 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2506240077 The I3C abstraction expects u8 buffers, but some controllers operate with a 32-bit bus width FIFO and cannot flag valid bytes individually. To avoid reading or writing outside the buffer bounds, use 32-bit accesses where possible and apply memcpy for any remaining bytes Signed-off-by: Jorge Marques Reviewed-by: Frank Li Reviewed-by: Wolfram Sang Suggested-by: Wolfram Sang Tested-by: Wolfram Sang --- drivers/i3c/internals.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/i3c/internals.h b/drivers/i3c/internals.h index 433f6088b7cec8c77288ee24dbee8b18338aa1eb..6a11437fee47bd1d19354e983d4= a561a4356b08d 100644 --- a/drivers/i3c/internals.h +++ b/drivers/i3c/internals.h @@ -22,4 +22,41 @@ int i3c_dev_enable_ibi_locked(struct i3c_dev_desc *dev); int i3c_dev_request_ibi_locked(struct i3c_dev_desc *dev, const struct i3c_ibi_setup *req); void i3c_dev_free_ibi_locked(struct i3c_dev_desc *dev); + +/** + * i3c_writel_fifo - Write data buffer to 32bit FIFO + * @addr: FIFO Address to write to + * @buf: Pointer to the data bytes to write + * @nbytes: Number of bytes to write + */ +static inline void i3c_writel_fifo(void __iomem *addr, const void *buf, + int nbytes) +{ + writesl(addr, buf, nbytes / 4); + if (nbytes & 3) { + u32 tmp =3D 0; + + memcpy(&tmp, buf + (nbytes & ~3), nbytes & 3); + writel(tmp, addr); + } +} + +/** + * i3c_readl_fifo - Read data buffer from 32bit FIFO + * @addr: FIFO Address to read from + * @buf: Pointer to the buffer to store read bytes + * @nbytes: Number of bytes to read + */ +static inline void i3c_readl_fifo(const void __iomem *addr, void *buf, + int nbytes) +{ + readsl(addr, buf, nbytes / 4); + if (nbytes & 3) { + u32 tmp; + + tmp =3D readl(addr); + memcpy(buf + (nbytes & ~3), &tmp, nbytes & 3); + } +} + #endif /* I3C_INTERNAL_H */ --=20 2.49.0 From nobody Wed Oct 8 21:36:50 2025 Received: from mx0a-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) (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 93376251792 for ; Tue, 24 Jun 2025 09:07:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.135.77 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750756054; cv=none; b=K8cJHU0lGhLyAUb8Lk7LmgYTx2Q95/IdC/Dfs7YUAqKRv6YG+PQs9Sy//q1fRMInrjvV3gE5xDQ0EQQ7xHYB3B9ShTtFHfdljaZYN3ArxkPq1dAA1Zy5IOHTeIUFO/hZOJF5QwThONt8ZZHVZHGP+fnAIjCS+wxXewsnOGGC8bA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750756054; c=relaxed/simple; bh=0h1B/EXtyfjip0W6o3w7xdrYftaObTtcOMMwc/DNLCM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=YQ0LGEy41YLAvXtmnl7BL/P2WKBAPnB9RLIU5gHwlog4kYNxr7kQUGB+UnHCRzGsFu95mad2b94Gko5kS3Ca8t2x923DeiM2L21802tGlYbUJ4NN1IGrlZXtfL8+HDexMN1N+U+6e1phmwq/h1REgyoHeahydQyKesIo31bVByU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=analog.com; spf=pass smtp.mailfrom=analog.com; dkim=pass (2048-bit key) header.d=analog.com header.i=@analog.com header.b=vtvJ78HK; arc=none smtp.client-ip=148.163.135.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=analog.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=analog.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=analog.com header.i=@analog.com header.b="vtvJ78HK" Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 55O6i84M016383; Tue, 24 Jun 2025 05:07:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=i4IeI J8yn+pHeHifgHBvLNv1j95vL/lajmEMjYmg9Fw=; b=vtvJ78HKc3gYphvn3frE3 vvlGXlOtzg54eWA5fpkkihZ1Xo5fb0MfSvK/BLC9CQCYawqqkCo625FoLwKOZNvy 6w6dJcugGppFUJIbgvWuwdYYGcF9qPKLYGybcIiT+KiiEJKFYBTEKEBWSIxK3NHl bfoJr0xt1I2CLnsmLLm6h3cLWnnbDKgnZHDhMoufTFECopdWJ/afairZDmn8YRD3 oWvmObnOe1qP/lWWIOYx4Cr7tqD0U9ljncsadNf3ancAV4N5mN5+kzZLUXfPGqg9 75HNtypUyLESwGSbmdh/OOwKvviW57F445b2f+UlchiM8oCmxBhFyYuj3tw1jWii g== Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 47dpk9eny2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 24 Jun 2025 05:07:18 -0400 (EDT) Received: from ASHBMBX9.ad.analog.com (ASHBMBX9.ad.analog.com [10.64.17.10]) by nwd2mta3.analog.com (8.14.7/8.14.7) with ESMTP id 55O97H4T012615 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 24 Jun 2025 05:07:17 -0400 Received: from ASHBCASHYB5.ad.analog.com (10.64.17.133) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Tue, 24 Jun 2025 05:07:17 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) by ASHBCASHYB5.ad.analog.com (10.64.17.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Tue, 24 Jun 2025 05:07:17 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server id 15.2.1748.10 via Frontend Transport; Tue, 24 Jun 2025 05:07:17 -0400 Received: from HYB-DlYm71t3hSl.ad.analog.com (HYB-DlYm71t3hSl.ad.analog.com [10.44.3.55] (may be forged)) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 55O973ap007498; Tue, 24 Jun 2025 05:07:11 -0400 From: Jorge Marques Date: Tue, 24 Jun 2025 11:06:05 +0200 Subject: [PATCH v3 2/3] i3c: master: cdns: Use i3c_writel_fifo() and i3c_readl_fifo() 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: <20250624-i3c-writesl-readsl-v3-2-63ccf0870f01@analog.com> References: <20250624-i3c-writesl-readsl-v3-0-63ccf0870f01@analog.com> In-Reply-To: <20250624-i3c-writesl-readsl-v3-0-63ccf0870f01@analog.com> To: Alexandre Belloni , Frank Li , =?utf-8?q?Przemys=C5=82aw_Gaj?= CC: , , "Jorge Marques" X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1750756023; l=2207; i=jorge.marques@analog.com; s=20250303; h=from:subject:message-id; bh=0h1B/EXtyfjip0W6o3w7xdrYftaObTtcOMMwc/DNLCM=; b=F1IjRYp3Q0ELCStfPrS7g51UhC7/jgUgw14x+qaqyVvt6dWadVRF6/X7P3mUpWb2BCoV18AL6 40bLuzCmPHEBbRr1ooWDw3Z601MzklzOty9xBgsHYFl0zbpvSN4OyUI X-Developer-Key: i=jorge.marques@analog.com; a=ed25519; pk=NUR1IZZMH0Da3QbJ2tBSznSPVfRpuoWdhBzKGSpAdbg= X-ADIRuleOP-NewSCL: Rule Triggered X-Authority-Analysis: v=2.4 cv=aclhnQot c=1 sm=1 tr=0 ts=685a6ac6 cx=c_pps a=PpDZqlmH/M8setHirZLBMw==:117 a=PpDZqlmH/M8setHirZLBMw==:17 a=IkcTkHD0fZMA:10 a=6IFa9wvqVegA:10 a=gAnH3GRIAAAA:8 a=HIdXEUdWjxm5DSZX9lgA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNjI0MDA3NyBTYWx0ZWRfX7beYt5zqI7jB djo/m4mL2oY/hy7/JKN/r0TcwcPK9bHUUAb7WH8TOZd/FZ8z1eToqB8bHxSEhqHSMBDxWg/L0Kk qJbZbf4sZYB/z/nFjh1+/1PGdZJo47YostQEGqEtgcrxoZBwtSPegYstTyf1pE22sz+uPFg2Vt0 /0KaxG+ma5PJX2hMQdUU09iZeXFsFNyZVOXVqsapOg2JJUAZ1l75L/ufJF/Qq1akGMtuNiBvcIV cxf5NNUOuPnhC5rjDOfGdeq7vVqzsB2sdqL9LceweuHonmY5Q+2CG01ty4ww5e9cm29e1FWQaEP DVBeg0n3KqhrhoA8jvOYylFIYB7O4hZXx7o1xgGkpmrO8zTpVBjWJ4C1AdmGVz29UpQbPZ5jdcP Hz7QXhcrB5DteaUvWgqzdhZ5sZ/7VzHVzrLFywAQlQz2h0RqQr1RdajsgzNc8M/+09uHPL+k X-Proofpoint-ORIG-GUID: G789YaPys_ZBzYqe3cU5W8fn3Eo0Z0Au X-Proofpoint-GUID: G789YaPys_ZBzYqe3cU5W8fn3Eo0Z0Au X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-06-24_03,2025-06-23_07,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 spamscore=0 malwarescore=0 bulkscore=0 clxscore=1015 lowpriorityscore=0 suspectscore=0 mlxlogscore=807 phishscore=0 adultscore=0 mlxscore=0 priorityscore=1501 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2506240077 Use common inline i3c_writel_fifo()/i3c_readl_fifo() methods to simplify code since the FIFO of controller is a 32bit width. Signed-off-by: Jorge Marques Reviewed-by: Frank Li --- drivers/i3c/master/i3c-master-cdns.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/drivers/i3c/master/i3c-master-cdns.c b/drivers/i3c/master/i3c-= master-cdns.c index fd3752cea654954ed1e37337754e45fddbbbf68e..321c04d2109ec1951f2b07a9d1b= 88c6aaf055c95 100644 --- a/drivers/i3c/master/i3c-master-cdns.c +++ b/drivers/i3c/master/i3c-master-cdns.c @@ -23,6 +23,8 @@ #include #include =20 +#include "../internals.h" + #define DEV_ID 0x0 #define DEV_ID_I3C_MASTER 0x5034 =20 @@ -427,25 +429,13 @@ to_cdns_i3c_master(struct i3c_master_controller *mast= er) static void cdns_i3c_master_wr_to_tx_fifo(struct cdns_i3c_master *master, const u8 *bytes, int nbytes) { - writesl(master->regs + TX_FIFO, bytes, nbytes / 4); - if (nbytes & 3) { - u32 tmp =3D 0; - - memcpy(&tmp, bytes + (nbytes & ~3), nbytes & 3); - writesl(master->regs + TX_FIFO, &tmp, 1); - } + i3c_writel_fifo(master->regs + TX_FIFO, bytes, nbytes); } =20 static void cdns_i3c_master_rd_from_rx_fifo(struct cdns_i3c_master *master, u8 *bytes, int nbytes) { - readsl(master->regs + RX_FIFO, bytes, nbytes / 4); - if (nbytes & 3) { - u32 tmp; - - readsl(master->regs + RX_FIFO, &tmp, 1); - memcpy(bytes + (nbytes & ~3), &tmp, nbytes & 3); - } + i3c_readl_fifo(master->regs + RX_FIFO, bytes, nbytes); } =20 static bool cdns_i3c_master_supports_ccc_cmd(struct i3c_master_controller = *m, @@ -1330,12 +1320,7 @@ static void cdns_i3c_master_handle_ibi(struct cdns_i= 3c_master *master, buf =3D slot->data; =20 nbytes =3D IBIR_XFER_BYTES(ibir); - readsl(master->regs + IBI_DATA_FIFO, buf, nbytes / 4); - if (nbytes % 3) { - u32 tmp =3D __raw_readl(master->regs + IBI_DATA_FIFO); - - memcpy(buf + (nbytes & ~3), &tmp, nbytes & 3); - } + i3c_readl_fifo(master->regs + IBI_DATA_FIFO, buf, nbytes); =20 slot->len =3D min_t(unsigned int, IBIR_XFER_BYTES(ibir), dev->ibi->max_payload_len); --=20 2.49.0 From nobody Wed Oct 8 21:36:50 2025 Received: from mx0a-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) (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 81BB727AC57 for ; Tue, 24 Jun 2025 09:07:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.135.77 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750756057; cv=none; b=jj3gpti9nm91GWcP1JWHBaAyE65gC9eXvFVQCUWaUobTA9lYXDoMRQJAztM8e31E6eIQR+qH+BYw2DQ+ttQVIfyb397xhEf8kxk2Ott/zfvDNkyZ2Xg63R9zqx/yZ3oth1/Hg8HKxn7/jx8TcWR9roAD7R2T/UocCxN8GaDGG4I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750756057; c=relaxed/simple; bh=wCs4i87jJYOsPZ2Vm1E8RoZR7ejFzjqL1pmElM07eyQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=S7bJ3Jbh9Drg08u+/xWs3UFJpgvHX663m1ebpDen6d8eWOHbGX2rH8K7fHZO66AESwhNzt4uxM7lsXpFAsGqp9IKk57V6iZfYy8xC8wDMC12BG57UtbT24AsIxBmcxwwWVFt6yKwyyj/5+wrA90ng3G0VBrzAymcmZCXMc/7HG8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=analog.com; spf=pass smtp.mailfrom=analog.com; dkim=pass (2048-bit key) header.d=analog.com header.i=@analog.com header.b=O1wdHTTg; arc=none smtp.client-ip=148.163.135.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=analog.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=analog.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=analog.com header.i=@analog.com header.b="O1wdHTTg" Received: from pps.filterd (m0167089.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 55O78SQJ017397; Tue, 24 Jun 2025 05:07:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=1t/j9 5uo+rfdf+7ItOaKA2g2tv6TYJM7N8IK0++IJpY=; b=O1wdHTTg48sIy+J8ZwHu2 ZTibfzR53HIQEpg/Pfhh9A907UJyObV5h38KBeCElyYbJDPycTxdpcidKIan0vaV dnAgsbogHoHmuch21xfQ6cnDcZUTUEymt3556aHUuG30rB7ArwLC2OaHDkf3FSlp waJrs/QNFC/KktcmKhEVhLK8PzfjvVNXJeilZu3Rwp9wN0RJzl2qoPQVNRJKcKYd 0BsvixWDEKC/fUVCIIbgzs4NBkLfU2WKsBdk3LUNh8FollFyJuiB3R0zcS9bqMPG /pzI8yKdV9r5csuZXYpEr8GcGjjPqiGVXwK5jgaRp49RnzWyu5bwvTd9KlT7Tqcr w== Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 47f43a6g06-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 24 Jun 2025 05:07:21 -0400 (EDT) Received: from ASHBMBX8.ad.analog.com (ASHBMBX8.ad.analog.com [10.64.17.5]) by nwd2mta3.analog.com (8.14.7/8.14.7) with ESMTP id 55O97IBc012640 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 24 Jun 2025 05:07:18 -0400 Received: from ASHBCASHYB4.ad.analog.com (10.64.17.132) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Tue, 24 Jun 2025 05:07:18 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) by ASHBCASHYB4.ad.analog.com (10.64.17.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Tue, 24 Jun 2025 05:07:18 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server id 15.2.1748.10 via Frontend Transport; Tue, 24 Jun 2025 05:07:18 -0400 Received: from HYB-DlYm71t3hSl.ad.analog.com (HYB-DlYm71t3hSl.ad.analog.com [10.44.3.55] (may be forged)) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 55O973aq007498; Tue, 24 Jun 2025 05:07:13 -0400 From: Jorge Marques Date: Tue, 24 Jun 2025 11:06:06 +0200 Subject: [PATCH v3 3/3] i3c: master: dw: Use i3c_writel_fifo() and i3c_readl_fifo() 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: <20250624-i3c-writesl-readsl-v3-3-63ccf0870f01@analog.com> References: <20250624-i3c-writesl-readsl-v3-0-63ccf0870f01@analog.com> In-Reply-To: <20250624-i3c-writesl-readsl-v3-0-63ccf0870f01@analog.com> To: Alexandre Belloni , Frank Li , =?utf-8?q?Przemys=C5=82aw_Gaj?= CC: , , "Jorge Marques" X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1750756023; l=2104; i=jorge.marques@analog.com; s=20250303; h=from:subject:message-id; bh=wCs4i87jJYOsPZ2Vm1E8RoZR7ejFzjqL1pmElM07eyQ=; b=KsrDy+vX0StOQy9eXsmLzz2Qtjbs+wEjPnKUNxUGhNF9SYiReu1JSoUwdha9exn85ufrhQvOx IgGd54NbjntDJ8lSC0+lFW2dpK0YTufxla98reI3+FwrucIwUI7ABwJ X-Developer-Key: i=jorge.marques@analog.com; a=ed25519; pk=NUR1IZZMH0Da3QbJ2tBSznSPVfRpuoWdhBzKGSpAdbg= X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNjI0MDA3NyBTYWx0ZWRfX4szgUOkXI/D+ SEYNQvAr6OucyRV5x0RemVaNzpNnhQ0k5bkJxMDRm7PhDax3zT+Elro0UlJv8MiZzqyhZR9cv3Q AzCQlJop3ZL4Zu2v2JmMBZXWWMztFPqesMZW2YSHuMjxYxy1z7BUGhTXB/TJ9bRpgwA0fbixZPd 1aZeAhnciIskKIOPD6jbJoLrnZyn/ZlKieTimAAOE4OmlLZNQKYQDIntcCG6Go6/iDM82AVmGpR J2Qus2ts5QtPRDGtM0blAvRwSb+jjw+nbgF9RSFq6X75s6e1h+RO5JDLiSR9bwQAobxSm4pb4hi r/SHyHourQVB1crxuScUckmOalNWgp2yAgongmq2C2XDCbqeJB3e6x8Q8qeFVTRRO5ThYsJfqNJ ZCd10bzApq+TtmxSHxOILuWnDcA+hjOD0clKuPAgjS/I4fjHsb6qHNVs4Zl2DIT+W5m8oiWP X-Authority-Analysis: v=2.4 cv=PuGTbxM3 c=1 sm=1 tr=0 ts=685a6ac9 cx=c_pps a=PpDZqlmH/M8setHirZLBMw==:117 a=PpDZqlmH/M8setHirZLBMw==:17 a=IkcTkHD0fZMA:10 a=6IFa9wvqVegA:10 a=gAnH3GRIAAAA:8 a=HIdXEUdWjxm5DSZX9lgA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-ORIG-GUID: Tw9L9c6SN7TFMlD-MWZHESK-5RmbKTot X-Proofpoint-GUID: Tw9L9c6SN7TFMlD-MWZHESK-5RmbKTot X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-06-24_03,2025-06-23_07,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 priorityscore=1501 phishscore=0 mlxscore=0 mlxlogscore=808 malwarescore=0 adultscore=0 spamscore=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 impostorscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2506240077 Use common inline i3c_writel_fifo()/i3c_readl_fifo() methods to simplify code since the FIFO of controller is a 32bit width. Signed-off-by: Jorge Marques Reviewed-by: Frank Li --- drivers/i3c/master/dw-i3c-master.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c= -master.c index 611c22b72c1572ddf717c8ad473e44a3b8fcceaf..886f8b74defda31ae93248467d1= 44f9c8c561581 100644 --- a/drivers/i3c/master/dw-i3c-master.c +++ b/drivers/i3c/master/dw-i3c-master.c @@ -23,6 +23,7 @@ #include #include =20 +#include "../internals.h" #include "dw-i3c-master.h" =20 #define DEVICE_CTRL 0x0 @@ -336,37 +337,19 @@ static int dw_i3c_master_get_free_pos(struct dw_i3c_m= aster *master) static void dw_i3c_master_wr_tx_fifo(struct dw_i3c_master *master, const u8 *bytes, int nbytes) { - writesl(master->regs + RX_TX_DATA_PORT, bytes, nbytes / 4); - if (nbytes & 3) { - u32 tmp =3D 0; - - memcpy(&tmp, bytes + (nbytes & ~3), nbytes & 3); - writesl(master->regs + RX_TX_DATA_PORT, &tmp, 1); - } -} - -static void dw_i3c_master_read_fifo(struct dw_i3c_master *master, - int reg, u8 *bytes, int nbytes) -{ - readsl(master->regs + reg, bytes, nbytes / 4); - if (nbytes & 3) { - u32 tmp; - - readsl(master->regs + reg, &tmp, 1); - memcpy(bytes + (nbytes & ~3), &tmp, nbytes & 3); - } + i3c_writel_fifo(master->regs + RX_TX_DATA_PORT, bytes, nbytes); } =20 static void dw_i3c_master_read_rx_fifo(struct dw_i3c_master *master, u8 *bytes, int nbytes) { - return dw_i3c_master_read_fifo(master, RX_TX_DATA_PORT, bytes, nbytes); + i3c_readl_fifo(master->regs + RX_TX_DATA_PORT, bytes, nbytes); } =20 static void dw_i3c_master_read_ibi_fifo(struct dw_i3c_master *master, u8 *bytes, int nbytes) { - return dw_i3c_master_read_fifo(master, IBI_QUEUE_STATUS, bytes, nbytes); + i3c_readl_fifo(master->regs + IBI_QUEUE_STATUS, bytes, nbytes); } =20 static struct dw_i3c_xfer * --=20 2.49.0