From nobody Thu Dec 18 08:10:12 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A57DC4167D for ; Tue, 14 Nov 2023 08:56:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232292AbjKNI4X convert rfc822-to-8bit (ORCPT ); Tue, 14 Nov 2023 03:56:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232397AbjKNI4U (ORCPT ); Tue, 14 Nov 2023 03:56:20 -0500 Received: from fd01.gateway.ufhost.com (fd01.gateway.ufhost.com [61.152.239.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30B2F198 for ; Tue, 14 Nov 2023 00:56:16 -0800 (PST) Received: from EXMBX166.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX166", Issuer "EXMBX166" (not verified)) by fd01.gateway.ufhost.com (Postfix) with ESMTP id D2F628143; Tue, 14 Nov 2023 16:56:14 +0800 (CST) Received: from EXMBX066.cuchost.com (172.16.7.66) by EXMBX166.cuchost.com (172.16.6.76) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Tue, 14 Nov 2023 16:56:14 +0800 Received: from localhost.localdomain (161.142.156.149) by EXMBX066.cuchost.com (172.16.6.66) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Tue, 14 Nov 2023 16:56:11 +0800 From: Joshua Yeong To: , CC: , , "Joshua Yeong" Subject: [PATCH v3 1/1] i3c: Add fallback method for GETMXDS CCC Date: Tue, 14 Nov 2023 16:55:25 +0800 Message-ID: <20231114085525.6271-2-joshua.yeong@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231114085525.6271-1-joshua.yeong@starfivetech.com> References: <20231114085525.6271-1-joshua.yeong@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [161.142.156.149] X-ClientProxiedBy: EXCAS062.cuchost.com (172.16.6.22) To EXMBX066.cuchost.com (172.16.6.66) X-YovoleRuleAgent: yovoleflag Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Some I3C hardware will report error when an incorrect length is received fr= om device. GETMXDS CCC are available in 2 formats: without turnaround time (fo= rmat 1) and with turnaround time (format 2). There is no mechanics to determine = which format is supported by device. So in case sending GETMXDS CCC format 2 resu= lted in a failure, try sending GETMXDS CCC format 1 instead. Signed-off-by: Joshua Yeong Reviewed-by: Miquel Raynal --- drivers/i3c/master.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index 95caa162706f..718b643cb54d 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -1130,8 +1130,16 @@ static int i3c_master_getmxds_locked(struct i3c_mast= er_controller *master, =20 i3c_ccc_cmd_init(&cmd, true, I3C_CCC_GETMXDS, &dest, 1); ret =3D i3c_master_send_ccc_cmd_locked(master, &cmd); - if (ret) - goto out; + if (ret) { + /* + * Retry when the device does not support max read turnaround + * while expecting shorter length from this CCC command. + */ + dest->payload.len -=3D 3; + ret =3D i3c_master_send_ccc_cmd_locked(master, &cmd); + if (ret) + goto out; + } =20 if (dest.payload.len !=3D 2 && dest.payload.len !=3D 5) { ret =3D -EIO; --=20 2.25.1