Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.180.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796035044; b=0T4Mf57ccg52KIS4tPAFmeh5Hnkjq3gq14yT2pn89tNw+aARhhY/hebIUNzu7oAfsNZM DRhAWY8AlLgiff/8zu36yYHVl2fkaYqRGWs6XpXsxx+AmAgGLSsnVJ5azaM9RSnjvvQIc S1+UdUC3TzBE+EapKaR8bWOF96ep/jmDR69cYNc/o8oNBulWQSa26t/CEyRqsqaFnhX0u DOPK9Kd0h6lUF9+tW+a5PnQED+pYwX2ewTmmCLrfJa08GmSCukhrPdd9gLTJ5s+q7b5/O P30Gy8HaAwu+B2JhQflqHCOtxRx9hgqz7XdL5VoSCypNoxAWHMOlyqZuKd74gFYgVLA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796035044; h=DMARC-Filter:Received:DKIM-Signature:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:X-Received:Received:From:Date: Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Proofpoint-ORIG-GUID:X-Proofpoint-Spam-Info:X-Proofpoint-GUID: X-Authority-Analysis:X-Proofpoint-Spam-Details-Enc: X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details; bh=z33a8ywlWjMgM7wbnvJxTRt4ji4wl9cy6bBXMhjrrNI=; b=SHi7ppocE+gEaLN5Wge+53SmiBzKEaEGlY2f+vCmPDYhWyBHJeMlX/u9pUsemfa98rF+ 66j3F4CKe0wzT4wZ9a65WrUI39eJ9z9k3dxGu1dySeKh2SkY+nXSq7p9cwe+BjEMdiRhG 1ERaIHx9D6/T5ax343tk43LU0s7Ikf4X8McyCiIXanGLBNLpA0s4GCwm1JIabUVK3SfQN q7zRxwmfEG/Q4Hhycl88zFfTpNxlEhwCRxjMlaJg022arc0azwe337YOhdhDdrQib/+Ba Uvxnh2R7baLGnoAdaid/oHvBtGf9DoQ4DAbzd5BpUKaaZEvORNIvLQGvVRuQRPoT50Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=Rm85dVeT; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=FlrQimYf; arc=none smtp.remote-ip=205.220.180.131 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CFF38606A33C for ; Mon, 30 Nov 2026 10:37:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CFF38606A33C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=Rm85dVeT; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=FlrQimYf Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AU9V4JW2004181 for ; Mon, 30 Nov 2026 10:37:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= z33a8ywlWjMgM7wbnvJxTRt4ji4wl9cy6bBXMhjrrNI=; b=Rm85dVeTRJtjomFI iIgq4Qk4RPIt77B7HYCnwLwccXzUMBB+LkVEf97ZU+QWGSZOQx59/e+Pntg3hfPi LyubA0PvYruwVsFpYW3hNY0O/+YqYYxfUb5oLjIwXQU4E+x2CFLLnnuoSz13O4Re Q8/VrFoXdHtbVvGe88GLlKm/3GnyqKledl4IaoZ8KuHfZwjuDkp3AvsL2xJ8KatT W+lCl6ip+5r41jx1O6IKXOEZOtykKP8sAsUnUD2Db5hWuxEBOct1ACQpg9b+20N2 bHpmD0drq+2tqg44f9t0vFEn1PHE4peS8s/0QP8cXqPdj7cPyvukLA7kQPi8/02n 1jiQ5A== Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j9477gw3r-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 30 Nov 2026 10:37:22 +0000 (GMT) Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-94975041698so2256002185a.0 for ; Mon, 30 Nov 2026 02:37:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1796035042; x=1796639842; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=z33a8ywlWjMgM7wbnvJxTRt4ji4wl9cy6bBXMhjrrNI=; b=FlrQimYf+jSog/njTDoYv12b9U6bJGgMCCc40jsExaFj1/GWfFUEqHf/glENA82Kr9 pvDbh7ZDUV419AM60YUbiIX4zeYU7atoIVBKyAM9vnbrraxDpHuWUgd5+Ufm2FNzXy91 N0uI9x6LNO3PTPnnv6N6AK6caNjITNQxjhRzPW08mPkuqiMWtg2uardoWnKp4zhu2KyG tvrcc9nbug4cw3fvDBe9ZhSxIziO6osiZd9dp2fxf4bf0J29Ome8qE3/M8T8FzU/QmSo SfTyIlctitCPEmwPQbc9enrEZA6p/Iv4ODg1yn80nn0s1GIozu7rHCdtMgcwey4hDzOM PqRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796035042; x=1796639842; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=z33a8ywlWjMgM7wbnvJxTRt4ji4wl9cy6bBXMhjrrNI=; b=AlA4QW/3BuTlwOwM/MPoM2FLqYorjJH7HZ0G5xR6R6ZYmbdMIDAdhu+1CwjGMrFM5C MP4Y18DqnAB5SStnEwHqCOtt7VLIB6u2jwFeGuyg/XB0YxiAlap6Ihw1zcbS4grmcG0Q HN0jZinpWcnl5JH59yVEsJ7rTOCplODIbXpIO18k5TgvKXHo6d07yPUy+SKKMliZUeaY FAQ7vhUxiHvlwq79XzobjlXYh1uQ0JqnAeVoGbMFKWc1h3q8eL8YnrPr6smY3y0MLWp3 ix+stXvhHd2neQg0pR3EQvqL101SUbJ/Ryfx9s8V8h+tJvsUfuYlCd+zkR22f5wj3y3S cOiA== X-Forwarded-Encrypted: i=1; AL+hErHUVzbEx6b65t3XX960I/2Lm+ZQ7h5SXb4DUzBlFWwDe1crjHjA3dWDHq1gd6LHbSfRVySUWzT/tYpqQrFt@vger.kernel.org X-Gm-Message-State: APuU4Z/I89IaPrEXbuAx2RE8IyfSYelHIASXTjzA3nLpjY7P0YqmTSFx xHWxaPhdmesx26AzctGmvwx+oYQVFc3L6e5/AvIpY4xZ1BWluX5K4wD57k37nsF2KXAAWgPiz9f 7n8JRxw31YsLRepZX9jy7DU3LDuYmS2QmsLNQIBsScfHZmRsMDgUO67Kk9ytJqb6rJBGryM5wtf 9hnlY= X-Gm-Gg: AZFdTZeifabSwImMFBdtqvG6uLWa7cu1/L2UftgoSg0YNnavMeR7vuKz3V2Qq8o2jMb A2kTwiBQnzQUlg2uh6slN7NKbcQAeerUGYnA1O4hFZyPSRecl8m2ghHNNCkvttTjgnLHH9dkodF 38dVEa30iDkXktd5ANYF5kxBZ35hYprACeqf/lu+7mO+goO5eIVfAJFLZuEpr1uMRAyJebqZavX lKRql4hjOnesQLOPB1h8XcnZyayIrxyfwgFOWPNykPSF8Husbty2N73OAUjSPGaWyPK8HuDxB57 iRH3IfluZyWyXBXkAVUB1KIQ4Wmp81gK5ePbtaLP1H0ftJx2SAWPd0UefMSyxUQFbQlFS+XNSHx H11fUt+iit2QmNxLhcGHyLWkQbLfuVEi0lhdxih5KYuvAmMonO682cb3pHxcRomlLGMv3MEgP8e UQa9jaqNhcFmv+1U6RbPz0/0P4GhvI4RqWPqt6PCXITSHHPRDNToAbUq1jWFKHn7ofYc8PQRlq3 LpNazVmeuJ3g862TUWQeOibQYEz X-Received: by 2002:a05:620a:2986:b0:949:aceb:b799 with SMTP id af79cd13be357-949b357272amr5979331185a.13.1796035042240; Mon, 30 Nov 2026 02:37:22 -0800 (PST) X-Received: by 2002:a05:620a:2986:b0:949:aceb:b799 with SMTP id af79cd13be357-949b357272amr5979328185a.13.1796035041724; Mon, 30 Nov 2026 02:37:21 -0800 (PST) Received: from QCOM-eG0v1AUPpu.na.qualcomm.com ([2a01:e0a:830:450:6046:9c83:ea4b:ae9c]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbab390cf5sm486441005e9.7.2026.11.30.02.37.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 02:37:20 -0800 (PST) From: Loic Poulain Date: Mon, 30 Nov 2026 11:37:01 +0100 Subject: [PATCH v5 5/7] i2c: qcom-cci: Extend i2c read limits based on CCI revision X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261130-cci-imp-v5-5-d2ac891f2bc6@oss.qualcomm.com> References: <20261130-cci-imp-v5-0-d2ac891f2bc6@oss.qualcomm.com> In-Reply-To: <20261130-cci-imp-v5-0-d2ac891f2bc6@oss.qualcomm.com> To: Robert Foss , Andi Shyti , Konrad Dybcio Cc: linux-i2c@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Loic Poulain X-Mailer: b4 0.14.2 X-Proofpoint-ORIG-GUID: AsN4Pns1hD0e_MIKNtyGDEqRSBSI3FzO X-Proofpoint-Spam-Info: AW1haW4tMjYxMTMwMDA0MiBTYWx0ZWRfX9iVDl17PlWd6 BbDL341f29D4kE62IV3mmMHK+JOENXanRO7JiepuTTqZ1mySg2ibDzXvFdrdq4vyf3hqzHRlE3h sJfM46zAuzFVb0aW/inU7n5ZcMVNMP8= X-Proofpoint-GUID: AsN4Pns1hD0e_MIKNtyGDEqRSBSI3FzO X-Authority-Analysis: v=2.4 cv=CN6/zhrD c=1 sm=1 tr=0 ts=6b0d51e2 cx=c_pps a=hnmNkyzTK/kJ09Xio7VxxA==:117 a=xqWC_Br6kY4A:10 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=ZpdpYltYx_vBUK5n70dp:22 a=EUspDBNiAAAA:8 a=Q-BVT9UuQ3EDAlpGIL8A:9 a=QEXdDO2ut3YA:10 a=PEH46H7Ffwr30OY-TuGO:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTMwMDA0MiBTYWx0ZWRfX553hobVjo6NN xHJiu6/7Yjxxto7/V2q25FnhvbSUISPFLA9ihXNQdWOb0fIk72SS3Y5mPIVRysS4Wrot08CG5I/ VHJMUkLXE6MhDTBl5pz3i/QQCP9rpIvuD1qZfja+qBjEB8zZOTchxacBdCEGaACBwBRNzkhFSxj u72t55kJ4nci9s5OT4tHvmgGurq6weibxoriGTzM7IUwP3qfYbAVoC67AexvJmUnd58/DIOlcPF f2NpglKwesnPTGwM40U2ae6Qqzq95T34+E2sqoW5WcFV/+UgSiB9JDt0UjiU+d1MFsAK0pr7els 2PErF3wiA+0O4DugYjQz8+wfewrE5T8GqYHpSzDGDKl9u6ILke8PRihwSGR765hKhzqNgjPi6Z0 i2DJ3zFh3VFwgkk+Odr3+M3oaNQNaB4m9Z9A4hfYw9Eu+8kH3ZcfBiswo0ZyOfBvGsqBzCTSNm1 /jaxA5KD07I6ozG2OUQ== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-30_03,2026-11-27_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 impostorscore=0 priorityscore=1501 spamscore=0 malwarescore=0 clxscore=1015 suspectscore=0 phishscore=0 adultscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611300042 max_read_len was hardcoded to 12 bytes for all CCI revisions, but this does not reflect the actual hardware limits. Depending on the CCI version, the maximum read size is either 14 bytes (16 - 2) or 254 bytes (256 - 2), corresponding to FIFO_SIZE - 2. Two FIFO bytes are reserved by the hardware, with the first and last bytes used for metadata such as slave ID/address reporting. Add CCI_I2C_READ_MAX_LEN macro to derive max_read_len from each revision's FIFO size instead of hardcoding it and adjust the values according the hardware revisions. Improve the FIFO read procedure, read the first word, discard its ID-echo byte, then drain the remaining words in a plain loop. Switch to readl_relaxed() for the FIFO reads, since the preceding wait_for_completion_timeout() already orders them against the hardware's completion interrupt. Reviewed-by: Konrad Dybcio Signed-off-by: Loic Poulain --- drivers/i2c/busses/i2c-qcom-cci.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/drivers/i2c/busses/i2c-qcom-cci.c b/drivers/i2c/busses/i2c-qcom-cci.c index 5bb39534578e8887a7bf54e9fe219a58433c91cc..1bbaf628bea97273a97c263f67ead3ffc86f6148 100644 --- a/drivers/i2c/busses/i2c-qcom-cci.c +++ b/drivers/i2c/busses/i2c-qcom-cci.c @@ -108,6 +108,9 @@ (((qsize) - CCI_I2C_BURST_OVERHEAD) / CCI_I2C_WRITE_WC * \ CCI_I2C_WRITE_MAX_LEN) +/* The first and last bytes are reserved - not payload */ +#define CCI_I2C_READ_MAX_LEN(fsize) ((fsize) - 2) + enum { I2C_MODE_STANDARD, I2C_MODE_FAST, @@ -481,7 +484,6 @@ static int cci_i2c_read(struct cci *cci, u16 master, u32 val, words_read, words_exp; u8 queue = QUEUE_1; int i, index = 0, ret; - bool first = true; /* * Call validate queue to make sure queue is empty before starting. @@ -509,21 +511,16 @@ static int cci_i2c_read(struct cci *cci, u16 master, return -EIO; } - do { - val = readl(cci->base + CCI_I2C_Mm_READ_DATA(master)); - - for (i = 0; i < 4 && index < len; i++) { - if (first) { - /* The LS byte of this register represents the - * first byte read from the slave during a read - * access. - */ - first = false; - continue; - } + /* The first byte of the read is the slave ID echo, not payload */ + val = readl_relaxed(cci->base + CCI_I2C_Mm_READ_DATA(master)); + for (i = 1; i < 4 && index < len; i++) + buf[index++] = (val >> (i * 8)) & 0xff; + + while (--words_read) { + val = readl_relaxed(cci->base + CCI_I2C_Mm_READ_DATA(master)); + for (i = 0; i < 4 && index < len; i++) buf[index++] = (val >> (i * 8)) & 0xff; - } - } while (--words_read); + } return 0; } @@ -736,7 +733,7 @@ static const struct cci_data cci_hw_catalog[] = { .queue_size = { 64, 16 }, .quirks = { .max_write_len = 10, - .max_read_len = 12, + .max_read_len = CCI_I2C_READ_MAX_LEN(16), }, }, { @@ -745,7 +742,7 @@ static const struct cci_data cci_hw_catalog[] = { .queue_size = { 64, 16 }, .quirks = { .max_write_len = CCI_I2C_BURST_MAX_LEN(64), - .max_read_len = 12, + .max_read_len = CCI_I2C_READ_MAX_LEN(16), }, }, { @@ -754,7 +751,7 @@ static const struct cci_data cci_hw_catalog[] = { .queue_size = { 128, 32 }, .quirks = { .max_write_len = CCI_I2C_BURST_MAX_LEN(128), - .max_read_len = 12, + .max_read_len = CCI_I2C_READ_MAX_LEN(16), }, }, { @@ -763,7 +760,7 @@ static const struct cci_data cci_hw_catalog[] = { .queue_size = { 128, 32 }, .quirks = { .max_write_len = CCI_I2C_BURST_MAX_LEN(128), - .max_read_len = 12, + .max_read_len = CCI_I2C_READ_MAX_LEN(256), }, }, { @@ -772,7 +769,7 @@ static const struct cci_data cci_hw_catalog[] = { .queue_size = { 1024, 32 }, .quirks = { .max_write_len = CCI_I2C_BURST_MAX_LEN(1024), - .max_read_len = 12, + .max_read_len = CCI_I2C_READ_MAX_LEN(256), }, }, }; -- 2.34.1