From nobody Thu Oct 9 01:09:50 2025 Received: from mx0b-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 BDE2019309C for ; Sun, 22 Jun 2025 09:21:43 +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=1750584105; cv=none; b=jEWDpTqiH0Tv9cO46DfRLVEB+hkrK73cc+q9ZhN50cLi6YpNo4ZaecYPfrmAwyL59T4hKqWHk0saBQsuCp6tDzOiN/KD5dADrwy6u+A+SuglqSoQ1mc5Dl+9uDVSSE/GxG2kWqa3JwZskWXNhqnKyXwThoLXhMKd0woujklXres= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750584105; c=relaxed/simple; bh=Dva/GbAbWuDLMMK+tDe/4bHG1TBRDryfMCpLVW9ikz0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=BYC0IoVUtyuGubJwKQiT4bL3a5inpzIgqnUDS5wos7nJ5WtnJ1nzt89KkSiZN+XAGFj9YpDURRAU53oiliQUN9E2AEG963cUHulsiwxwGC2KuJaeW9F1ncrAyZAZcakNtkDG852rjbNnMapV8ccOaH6JJiUJXXunbbbQQXGuweM= 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=medRs/qL; 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="medRs/qL" Received: from pps.filterd (m0375855.ppops.net [127.0.0.1]) by mx0b-00128a01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 55M73Dsj024613; Sun, 22 Jun 2025 05:21:34 -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=11/PY CO3hBt0DXZSESexUszH2l715ialGwaHJ+BPMeg=; b=medRs/qLuL+LV5bwrEHPr RjuF+JNp4vxjN3p8DlK7kxvXCalYWWzTflSnhjkU7qun+AUAv1/nU/JL19z65wZK 5SeSqxTEjvQRGB1R9IFcmaTel89afSxFyZGbbZYB2RK4GoTf7UXg+42E2d3cQ0p5 UZ1uE6ee39IEAJSqkoeWfF5p5eOJcelw+me61aV70yzz78xMdEXM2+jNajUauDEL FjVXLa7RYf97OOwWDnPXZlaChJBfMKiG6Ej4pxgNK1foDc6yNRTv9Bch5FPAOzVP n/B1oPpu6BQO9Px5Gq2Te0rByEA63XAmh3V7iU1BL2K0mdPAd+NlGSeSFG7Zlhoj w== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 47ed3qga57-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 22 Jun 2025 05:21:34 -0400 (EDT) Received: from ASHBMBX8.ad.analog.com (ASHBMBX8.ad.analog.com [10.64.17.5]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 55M9LXGF058699 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 22 Jun 2025 05:21:33 -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; Sun, 22 Jun 2025 05:21:33 -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; Sun, 22 Jun 2025 05:21:33 -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; Sun, 22 Jun 2025 05:21:33 -0400 Received: from HYB-DlYm71t3hSl.ad.analog.com (HYB-DlYm71t3hSl.ad.analog.com [10.32.14.29]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 55M9LHqS002302; Sun, 22 Jun 2025 05:21:21 -0400 From: Jorge Marques Date: Sun, 22 Jun 2025 11:18:58 +0200 Subject: [PATCH v2 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: <20250622-i3c-writesl-readsl-v2-1-2afd34ec6306@analog.com> References: <20250622-i3c-writesl-readsl-v2-0-2afd34ec6306@analog.com> In-Reply-To: <20250622-i3c-writesl-readsl-v2-0-2afd34ec6306@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=1750583937; l=1919; i=jorge.marques@analog.com; s=20250303; h=from:subject:message-id; bh=Dva/GbAbWuDLMMK+tDe/4bHG1TBRDryfMCpLVW9ikz0=; b=Zu7VYTthOqrCyBGQSr6n7eFUw1aIAaTBS+zk7LcsICJ/94C/Kmd2aBuZbto2yLXWxRhr/IXn1 NV+x92LgwP/B4Fnuz8Bq8l9nWehnQiHSZoFckMHNpfwJiSyvTPB/VPs X-Developer-Key: i=jorge.marques@analog.com; a=ed25519; pk=NUR1IZZMH0Da3QbJ2tBSznSPVfRpuoWdhBzKGSpAdbg= X-ADIRuleOP-NewSCL: Rule Triggered X-Authority-Analysis: v=2.4 cv=HZYUTjE8 c=1 sm=1 tr=0 ts=6857cb1e cx=c_pps a=3WNzaoukacrqR9RwcOSAdA==:117 a=3WNzaoukacrqR9RwcOSAdA==:17 a=IkcTkHD0fZMA:10 a=6IFa9wvqVegA:10 a=gAnH3GRIAAAA:8 a=QMVJh2PuZ69kPaAn0y8A:9 a=QEXdDO2ut3YA:10 X-Proofpoint-GUID: gSUpFxPmM7AQcT5HLhgxOrUAXQFYQg7I X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNjIyMDA1NSBTYWx0ZWRfXyrKTB3LrpQHA tsCTERBYcOmqqzrOBtSyROZdnTO4EDWiVlotdLH4sG8g8e0XihVcK4L0rRInMlIDV/B6dHIKZy6 iygj47hp/3brmm86HFGOZZ3EzFOahl3mxDCzjYvVQDo/3RE30nDZLSWCbQ1ryoC2S4ZerR+sd0C VNSHMLvfSj63HDTe4Mj4wk0lIbBoPjjKiKt7h2uy296RHSqW82tiQqpILwdEGqSmSFg5Nj3FygA r/KhK6/nzo8BQ3pEv9nh9L0vScAllSvZvAV4a/Ipmr/+Woo9UQfrpctmdwRzKK+g5G060cSiOIe bzuy6sI3E6//o0uKV7uxWt4lNgOtx3kR4vQDf4485ayrdNpXHB4FAPmvT9OrI4T680OyTnsi/vN gGuhNDfZ413aNFJ41BwWp6JBP6++HpdGMjaXqTRQo5aJAqTcDUX0djRbOjyXZTd35IJhou+Q X-Proofpoint-ORIG-GUID: gSUpFxPmM7AQcT5HLhgxOrUAXQFYQg7I X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-06-22_03,2025-06-20_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=741 bulkscore=0 malwarescore=0 spamscore=0 priorityscore=1501 mlxscore=0 impostorscore=0 adultscore=0 clxscore=1015 suspectscore=0 phishscore=0 lowpriorityscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2506220055 The i3c abstraction excepts u8 buffers, but some controllers have a bus width of 32-bits and don't support flagging valid bytes, so it is required to read/write long words and to use memcpy on the remainder of the number of bytes by 32-bits to not write/read outside the buffer bounds. Signed-off-by: Jorge Marques 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..88887b12122efafac81bcfdd093= d943259e13a08 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_master_writesl- Write bytes to long memory region from byte array + * @addr: Register to write to + * @bytes: Pointer to the data bytes to write + * @nbytes: Number of bytes to write + */ +static inline void i3c_writel_fifo(void __iomem *addr, const void *bytes, + int nbytes) +{ + writesl(addr, bytes, nbytes / 4); + if (nbytes & 3) { + u32 tmp =3D 0; + + memcpy(&tmp, bytes + (nbytes & ~3), nbytes & 3); + writel(tmp, addr); + } +} + +/** + * i3c_master_readsl - Read bytes from long memory region to byte array + * @addr: Register to read from + * @bytes: 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 *bytes, + int nbytes) +{ + readsl(addr, bytes, nbytes / 4); + if (nbytes & 3) { + u32 tmp; + + tmp =3D readl(addr); + memcpy(bytes + (nbytes & ~3), &tmp, nbytes & 3); + } +} + #endif /* I3C_INTERNAL_H */ --=20 2.49.0 From nobody Thu Oct 9 01:09: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 B48B519995E for ; Sun, 22 Jun 2025 09:22:11 +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=1750584133; cv=none; b=VXB7EjQECnMGiKaAu8DDeaPGtlhNqSffbqxjIVgesyPcw10hDFp+4Gzb6Hyon5faxEdv9LtKogysNstHXL2snlzBdi8hRdzRo2hH6JzUFBD8QctbF9ytZepkrvRw/BQ6igpqhCbZUuyVXVmiacqoy27ScVkPOz1NM3GC4/+KP7A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750584133; c=relaxed/simple; bh=G2ndV+MQ36l3fmzDtWBM3JUhQ84vhzEGz9R9pdPXqtA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=jbwV2AnbYtOQgZDcslIj866k/XvIgjJJYpAodSBBbzGaA9Rh1vJ8PVGC1Sgg8OTCZLZ43iGkXwHYWqOkzgpijRE0fuQuXNw+oiyF221Ok2ccjdaaWK2aE/kBL3r5JMZ4+J7RzbtakWUdCNHpUSrUK71v57t2JXYG303ZyTlB6pQ= 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=Q0+59x/c; 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="Q0+59x/c" 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 55M528BI012266; Sun, 22 Jun 2025 05:22:03 -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=HNtXL lkrbNK2ae+OChWznVZiy3xck+hIBQLK1M8aHhY=; b=Q0+59x/c8npg74NeDQWVK miUor0Gq+GhWu1Bp/CwchAsVBEbZWe6pRd12IPW7Lm3ydsBss0PZtuUBMf5YVwtl nqYT9hPensH1skZM/FqXXsUAEcSgMdZhWwu2wvHiZ31ge8hf110zbYa+4MNHj3fa 67ft6zSNvjgqjTK3tUOt+lVKh/C6jf3SjR09ioYMX4lVuDIATcw3bSAgg+4jIimI yjZpPMTMwa5oDplxufth4x1fPqhVxYv8StMUfSYuqZuQV1IAVP4YTpBk/5vQdKzS fQQdPMyrZYsY4Be9QwpIAMz9Gd911nWW5xxgk2iNGAWvWRaJcXuerziH1KITqU4U A== Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 47dsn7bkpv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 22 Jun 2025 05:22:02 -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 55M9Lkgp063097 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 22 Jun 2025 05:21:46 -0400 Received: from ASHBCASHYB4.ad.analog.com (10.64.17.132) 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; Sun, 22 Jun 2025 05:21:46 -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; Sun, 22 Jun 2025 05:21:46 -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; Sun, 22 Jun 2025 05:21:46 -0400 Received: from HYB-DlYm71t3hSl.ad.analog.com (HYB-DlYm71t3hSl.ad.analog.com [10.32.14.29]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 55M9LVbB002307; Sun, 22 Jun 2025 05:21:35 -0400 From: Jorge Marques Date: Sun, 22 Jun 2025 11:18:59 +0200 Subject: [PATCH v2 2/3] i3c: master: cdns: Use i3c_master_writesl() and i3c_master_readsl() 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: <20250622-i3c-writesl-readsl-v2-2-2afd34ec6306@analog.com> References: <20250622-i3c-writesl-readsl-v2-0-2afd34ec6306@analog.com> In-Reply-To: <20250622-i3c-writesl-readsl-v2-0-2afd34ec6306@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=1750583937; l=2213; i=jorge.marques@analog.com; s=20250303; h=from:subject:message-id; bh=G2ndV+MQ36l3fmzDtWBM3JUhQ84vhzEGz9R9pdPXqtA=; b=6UjcbzqVvZ0MDA4cGh0jcPXQMkgtWJsMgUAp+JZv9v77SFFVIcm377k5eSTqzJOERSVd3mqPh QfLJjktqYIuDRaZjM1SiujngWWbxWnDNvjmrFPUv9Alq74lV35J+yWW X-Developer-Key: i=jorge.marques@analog.com; a=ed25519; pk=NUR1IZZMH0Da3QbJ2tBSznSPVfRpuoWdhBzKGSpAdbg= X-ADIRuleOP-NewSCL: Rule Triggered X-Authority-Analysis: v=2.4 cv=GLsIEvNK c=1 sm=1 tr=0 ts=6857cb3a cx=c_pps a=PpDZqlmH/M8setHirZLBMw==:117 a=PpDZqlmH/M8setHirZLBMw==:17 a=IkcTkHD0fZMA:10 a=6IFa9wvqVegA:10 a=gAnH3GRIAAAA:8 a=wBeUhC9FeeX9q1_Bn2kA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNjIyMDA1NiBTYWx0ZWRfX5Kb3dTJYyylB iaWUEXH7Le0RO5rSgHaP3WA2wQPG96CEkE34ApdRht4SfoyvtFBjBkKM8qZMCqNOQ7f6UB/9a6l rIucK4pW6yPqDhREQyJqKcwr/dDSjlwNzcLBDiI70b+LMNIbQScenIkH1CebS3unxMyrJ4YZKYO 6OhrbbRfEHIrKFw005bvZErgXppThkLhTUtoNr+ztvepVQ6+zQgGDyG9mdNp7orOWc3ymISo+v0 /2WvzZYXE2zbDka0iRPMVWaYcAKhpTYJbpahm3rAWU8Fr7jowcVDcvaLUpjddXw4rLxw0l0047l DDMAFtx2zKLDQrn+xQ/AKOhrXUJxSN4odRI0Wts0HZMmEcIgDLfs71Et9MnUdjmx1HAdeuBNTop PMZBMCVFQ8AGIH4nXh/tpIUJKpvCRrZWJgSOAIEFIifYMBC3UTzaD9+y9ONairin/uqFn9fM X-Proofpoint-GUID: MJ-2Q7Sa5SSomXW1FOY3EPwni_BTskM0 X-Proofpoint-ORIG-GUID: MJ-2Q7Sa5SSomXW1FOY3EPwni_BTskM0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-06-22_03,2025-06-20_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxscore=0 malwarescore=0 mlxlogscore=807 lowpriorityscore=0 priorityscore=1501 phishscore=0 clxscore=1015 bulkscore=0 suspectscore=0 adultscore=0 spamscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2506220056 Use common inline i3c_master_writesl()/i3c_master_readsl() methods to simplify code since the FIFO of controller is a 32bit width. Signed-off-by: Jorge Marques --- 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 Thu Oct 9 01:09:50 2025 Received: from mx0b-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 572F9165F16 for ; Sun, 22 Jun 2025 09:22:09 +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=1750584131; cv=none; b=MoobGYTai9k5RuJQc61L5yoNDUus66+ovNsXBpeUcZ7KEhxXbwxvRBNSEq3NF/nfmioKMUkeSJ5Z+1RGUmhwtyeKqFdxeTpgeKGy4WDA5AlCS2gf/n7VE903o6wrmuFTb7I11afBgetrqIac0Dx941chSuu7BAdEJgmbapt6wrk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750584131; c=relaxed/simple; bh=EVtmVW1IwOASaN6R3rocsgTFp0b6Lx3rU+vedxS57Gk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=GOhq561e2Nke9TMgkI2t6Br9sJxrCVluqNjiygjtWRX5uUqXkcLHz3dqqzpNmXYZDe0ywh/qpwRk27iYtkR2H+m1+e790ohz7BUk2/m7CBroMdCx8tNj3369x4LIf+ihNk4JHXldJisLIu6KOgussRKER7qE0WuiDfcIYMq3I90= 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=m8OxWh3r; 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="m8OxWh3r" Received: from pps.filterd (m0375855.ppops.net [127.0.0.1]) by mx0b-00128a01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 55M73COc024600; Sun, 22 Jun 2025 05:22:01 -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=OrLzQ 8IA6w4hYwzQtNtB4fAW5I0GOz7zTw3X11/xH5E=; b=m8OxWh3rdbUK9TeCybMvs TNu85yv3KXhN53TcN+Ldvg5b4+wpEmlUW0C2UqS/HsH7Te5EGUzDYfwWW2KmrjfJ qUKEznTgttn4C78SKSMmnUN8UThKDZvKpW6e3aHV/3v7sK+Ss9Xc5Fqr/uVXLPlp CCSR6L4R7xviOJc4wf7A86HeXWYNCubIIiprvL+sGdamXoX+hV4D6IsErCjwV1yr WKChjMMS//5q2nsW9rTje5ESHerKzodr78JfsLomx9BkPlRTzARPVJ+7SN3YnjGN k+vLMGC5TpApUC37FK1HU0Fc+KtqGGqGR9gVOVlEJtc1LuWo7NWoypquMo7psPlV w== Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 47ed3qga62-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 22 Jun 2025 05:22:01 -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 55M9M0vk063117 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 22 Jun 2025 05:22:00 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) 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; Sun, 22 Jun 2025 05:22:00 -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; Sun, 22 Jun 2025 05:22:00 -0400 Received: from HYB-DlYm71t3hSl.ad.analog.com (HYB-DlYm71t3hSl.ad.analog.com [10.32.14.29]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 55M9LkIi002322; Sun, 22 Jun 2025 05:21:50 -0400 From: Jorge Marques Date: Sun, 22 Jun 2025 11:19:00 +0200 Subject: [PATCH v2 3/3] i3c: master: dw: Use i3c_master_writesl() and i3c_master_readsl() 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: <20250622-i3c-writesl-readsl-v2-3-2afd34ec6306@analog.com> References: <20250622-i3c-writesl-readsl-v2-0-2afd34ec6306@analog.com> In-Reply-To: <20250622-i3c-writesl-readsl-v2-0-2afd34ec6306@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=1750583937; l=2110; i=jorge.marques@analog.com; s=20250303; h=from:subject:message-id; bh=EVtmVW1IwOASaN6R3rocsgTFp0b6Lx3rU+vedxS57Gk=; b=btZUFab5KJHmhyTgU85BexIUN9q4XouW5kMnFxP6SZLHuvySJ3Rzb47Va48UT7atnYx6STv8H 8ogEvZYDIGIDZ5Io+1Rd3jlHFIdbAuQ8wWQpNJfMcGH6CEdVMSFKX2/ X-Developer-Key: i=jorge.marques@analog.com; a=ed25519; pk=NUR1IZZMH0Da3QbJ2tBSznSPVfRpuoWdhBzKGSpAdbg= X-ADIRuleOP-NewSCL: Rule Triggered X-Authority-Analysis: v=2.4 cv=HZYUTjE8 c=1 sm=1 tr=0 ts=6857cb39 cx=c_pps a=PpDZqlmH/M8setHirZLBMw==:117 a=PpDZqlmH/M8setHirZLBMw==:17 a=IkcTkHD0fZMA:10 a=6IFa9wvqVegA:10 a=gAnH3GRIAAAA:8 a=5rRNbQybwip5eFZw3WsA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-GUID: utokvlCfw76XicjdkaGxMEiHfsp9gqss X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNjIyMDA1NSBTYWx0ZWRfXz3ITp/BEjrCV GIZdLHY2uYjMUUdrLe0xwji9QcSPPN4BCI5vajsoVtbiDUiweLIYBLg1ltzwZLrWi7U3BRLMYxo 2qctIdF33vMMk9FSAzM/mbm47xo+NVCIkaqOzM5PwlWa4IODHJCprMR2/TO6Vp+1pbFITy84HgT UqTQobvv6tK7riOyJv7i6eSYAXq7iBpFLZ8wZZSWFlbcCSYvOP08t6VVUnyutvIYONzUe8TesVt 0BqNcfRYgALc7jtGK9ydg1GgYHPke9DfFitwnqXAJcnmpvbdBlvBES79FobfiMZJt+6sAmrOfoz WJWArgDO1wyUEi6Ql4lEowU2JdjVWEamKkxFwu0i0lR7ft3XwYM7V7hiKWtqQtZwBfZGfbZn0KH 5KqgvA5gPOTz6vIdq+O2og49IcDugjOneLBmh0hwvxpHGwPjzqODZxafNHSGQ5VNjSOC5pWW X-Proofpoint-ORIG-GUID: utokvlCfw76XicjdkaGxMEiHfsp9gqss X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-06-22_03,2025-06-20_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=821 bulkscore=0 malwarescore=0 spamscore=0 priorityscore=1501 mlxscore=0 impostorscore=0 adultscore=0 clxscore=1015 suspectscore=0 phishscore=0 lowpriorityscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2506220055 Use common inline i3c_master_writesl()/i3c_master_readsl() methods to simplify code since the FIFO of controller is a 32bit width. Signed-off-by: Jorge Marques --- 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