From mboxrd@z Thu Jan 1 00:00:00 1970 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=bpAAf7B9vF/FKTRIj5ajqz+gPdeLjFI2iDpXI4PSjO+FSRjvbbbW0oaDQf6NmZCvDVPA jNcEvKk71Dd3WnUO22QelHkMBoXaNXhrObU6m7eRKWRVjienC4syXwuJsnGD//ItZf+bH Ah3lDFkGZUI61JPPTzgavz0K4ErfGVuuik3Be2udnYGt7rW9Ww1oY9AhE2s2LdFIZvg/h hXfJFxkSsKJ1X83wOKoa4j4bA/xQycqirtiu7Bp3BN6HyeSr2EDD9EikY6ZPFmhemrshT 87s2dhRxkcMAJIpCRh1u98ghO88zDI55/14oFZSFZtzk0N+sEFiwaR4W7tepUOG2S4g== 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-Authority-Analysis:X-Proofpoint-Spam-Info: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-GUID: X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details; bh=z33a8ywlWjMgM7wbnvJxTRt4ji4wl9cy6bBXMhjrrNI=; b=JKuDjWaJ9ndawNI0Q/uCTm/0H4yMuZRU/plpauB9wTm2hAcXBhTuqWecMjxG/kcO2gyR wEAW2s3nl1zIqd7B0dT2OJ4NRXdEJHaKJgvAr09gk3Ue3qhQOOOlJiiP9paoby9cQ5AgA er2sUe9DJKgEQmbcJXVWS/vdLuonecUDRIE/3/mdE6/vrvU5sueWS/4SnBQ1UH3XpTazz MOT5ca1fUoO68WFyyydHqiuq+tSO2cx1mKRZnZwxcjE7J7bpq+caZ9tMnluC7fBlvTiD6 9GheAX1C4VsJ0OvBV71lWDn/2CyooMAoaFZTlmjfntA3FQmmtS4hhMAU1joKsv/CYaQ== 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 E0344606A692 for ; Mon, 30 Nov 2026 10:37:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E0344606A692 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 (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AU9VAnR3018185 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-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j92qph7p6-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-f198.google.com with SMTP id af79cd13be357-93f37c94ceeso1757211385a.1 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=LIiKzDzzTTbIgWpsB37RIt6dQ8low9DFMZS4qJAztx8gmnlgld8WUJYTBwq1p4S3FZ omBb4dv06MTVswZrbN6MOXVxjenfDAx/pBpJIVAy7A+EjkfRmg0VUlVqJK5EMQVeDUV3 N9gKnM5p+mfkiuFHEK7BnFrTHuJ+Yhv4o1JFXJGws+UySUPZ6uSQEhSfDNB76bv4pKmE AB6xqkOZQvM/nBTIEaucV9QdFdEeMj221dWWvRu1elu2+ktQD4eO0Mu3Z8fWf6JumUg2 djBCZUrCAncEfiEN4hbcgeotB19ypGpPrgKtrZMoJ/2ImqIldAuUrikGHjasmzhcM6E8 AThA== X-Forwarded-Encrypted: i=1; AL+hErEaXvVKMClLuJGQXC5X8qU9CFM4bBnOKhFIJz1Xn6L7750lv90JLTxc6V68pVWnPod7SEA937tyZRNNzg0=@vger.kernel.org X-Gm-Message-State: APuU4Z9CpmJ1+r7QQHyxmXCl4lONNk4fq3fkXzq65bNgct7zHfxs/TZG 2wy7Z46lvAhauEJU2Je/X+8iCApylxkMUuUZopAjmPc//r32ERlGrSZqvkbhg49YIOW1BYUyLvO K36jzeJKV+OrAR5sbUx4HhCLMpWZXO/vlt+o5v1PG+x/V/9KI8wugR4FaHphjbugJLFc= X-Gm-Gg: AZFdTZfrge1CBWw/CvnkLVl6IJAWnLYGkMUslQgRX0ayNf3IxOhz4dZIqAI8W1Fafjm 0u3F63q46Zn4xwzIIiygng8gGMpQ4bgkrjNJNFhuhUquEa6106+/zyXV6CTJNcaGqwtljTH+aGt d6PUTAhngAKAsz+8hXRu1ScdnDj4tLZzX6OsG+GuJXHLjyxfsxLLxbuMjW7En3g+uL0RI+4oIRk uLr62HsZQnQCrp6wiQE6HLeVgEfIS9/TrQZJw0YHRmVoYZnM7ZjrvrmM6pNNeKfo4Ya/hEaQqy3 l5z7xqRDa9E661q0aK3EoHjKqmHuSv03GNpulBBVGnbaVSqY6ns16Mnxdg7tjQJAfrXrIpR/zaB pGbiIOIpnOjhfTVlUOgzc1AcTy3BfiFNH5A+0L+bBCvwncvjHfk9Cek3r6cUVSEz/Z4mO0r+3/2 m7ef2ynYLnmmNNwEkrnzBt5ZDcrR5L9EfmccTluf29KEdrsynhHeffmNsqB7mGksOuMvEze6hBC XTju4fSHsa/k3Uaf3kLZrT/5/z0 X-Received: by 2002:a05:620a:2986:b0:949:aceb:b799 with SMTP id af79cd13be357-949b357272amr5979330885a.13.1796035042213; 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-kernel@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: h8sChJB-pNp5ocvXjVRYw0tw_9z0WRYW X-Authority-Analysis: v=2.4 cv=YMQKWhGx c=1 sm=1 tr=0 ts=6b0d51e2 cx=c_pps a=qKBjSQ1v91RyAK45QCPf5w==:117 a=xqWC_Br6kY4A:10 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=EUspDBNiAAAA:8 a=Q-BVT9UuQ3EDAlpGIL8A:9 a=QEXdDO2ut3YA:10 a=NFOGd7dJGGMPyQGDc5-O:22 X-Proofpoint-Spam-Info: AW1haW4tMjYxMTMwMDA0MiBTYWx0ZWRfX+bWotkXrJbti 1fsrbvbm934LCL5caoEaiEf4LHYge5iqfkXHHxEDnk2PF1O6mMlJFfkSyfAto7XRTWaWtfXHeJv no28UOieiItO1GKM8/I6SRXlntatM5Q= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTMwMDA0MiBTYWx0ZWRfX+82/DoXusIOs Bdl1iffzH5zUMGon/S6tkruqf3grCOvB3rgWrNGrnao3rQCOy5KYIi1BctUS5OsBvTGUI0ftXYr Fk/NH8y8OPE1VwVHCbT61QFShQy7BNi9yRZvOFDeLVT6728l87iI5VaHuuKFQXMUCOz0E1LD84K UhcMsAapD0pQzzujxuXE3zJ+JF147YSku03mgQZ/wemI6UA13idX9RKReauWIPGyrqwOQTMUuSH 91igX84snOMbRKXWpoN5J41BtUgYssakqhlwtsmtGbXClzpxSrFAwJg01pbhq/hjaUMTltXLFij UUvnzw3ojWwPqnnYIn6Y+LeV8dbIL8ci9ynXLYv56DxLYu6Y6keQqR51Pv7z0Gu9NgYnI/r1jId CUq4zLiv81criSLUP0zED6fYTWjv39Nv5mpW2CpqBLN/CFieTgq8vNwFg26jpidLMOlf8Ap04C4 nl78dRql2mhl/PUEZ5Q== X-Proofpoint-GUID: h8sChJB-pNp5ocvXjVRYw0tw_9z0WRYW 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 adultscore=0 suspectscore=0 priorityscore=1501 clxscore=1015 impostorscore=0 bulkscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 spamscore=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