Received: by 2002:a05:7412:8598:b0:f9:33c2:5753 with SMTP id n24csp157454rdh; Mon, 18 Dec 2023 15:03:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IHIDUY3DxNjVPNPb0gv0wLx7P9BVvHwzwsP2j4wrSfchTQHufIqB93AuxzOKFZyd2wB4UTR X-Received: by 2002:a17:90b:168e:b0:28b:3d31:b0a with SMTP id kv14-20020a17090b168e00b0028b3d310b0amr2141953pjb.92.1702940591880; Mon, 18 Dec 2023 15:03:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702940591; cv=none; d=google.com; s=arc-20160816; b=HKD3HDhIjqCP4K6cRAGAqQm9ufcna5oBEuw2NLbFFOF2sGgzqQkyCJIKyXKroIJMug 7T+iOYtcUhw8zwDLUikaLnRZHy9L318HwXlVAbNxHCm/hdrnjjsW28ajqKLUCl+ic2h0 xaZqqQHkL42iuPR8TLUIZ/CWbVvo5LRcgd9ZJLdr8JUPXZhyNjnlB6R4xxcjSlAIJJKV TE8vsoKIde+dU2jM1XZDjv5qMPnXAm3kgHY8PZA/cnIY4IYofZcuV8u5N1HlGOAj7lvx vZzENfGP1ZbLc+7iMyiTKwsgrvDz50eVdT/CE9gwCgEZV+zgc+kohmUmZMrzsnDqeojE mI7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id:dkim-signature; bh=YJxqecOL6R6o6l2AGHwi7QgNX0u29B+GDnVZRFgkI+k=; fh=yDkQzEl6IxZLQSJVtYl4ZVgHjrQZ2Js7dKd11NaUo5c=; b=hmgZD0iggs6e526XvdTiBEwiqPNnJhuPsKTCDq/uivMmSMvysmFIWygI0CHIx0P4fS 1wzh93szyLdzkZ7/75YcF678j0X49wmYHIeG9shycRjklmbRsL4aLs+nuBTgMXVSLDAD /TFKNIwc1KLj9GGLibZkfFBhF/B+fe2DO4jm9eRfhZYBqMJ9n7t7G2a8WRyyLOuobL9/ fmrmJRRbP5JKDZjTQeTcaQ67HjrY0zKXT6vqPOpnE+Tfi8b4yM9SStDYQrwP+VyfryDW z11VWClcMSGIuVaLLm9CDDZitq1+NsVlbJdDtc91FbwpN6lSjTcVHWWFayP8XK8jneMR lMXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeconstruct.com.au header.s=2022a header.b=WPpwQ9xu; spf=pass (google.com: domain of linux-kernel+bounces-4461-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4461-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codeconstruct.com.au Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id g8-20020a17090a300800b0028b18caf8c6si85275pjb.106.2023.12.18.15.03.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 15:03:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4461-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@codeconstruct.com.au header.s=2022a header.b=WPpwQ9xu; spf=pass (google.com: domain of linux-kernel+bounces-4461-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4461-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codeconstruct.com.au Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6B877286277 for ; Mon, 18 Dec 2023 23:03:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BDF01760A7; Mon, 18 Dec 2023 23:03:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=codeconstruct.com.au header.i=@codeconstruct.com.au header.b="WPpwQ9xu" X-Original-To: linux-kernel@vger.kernel.org Received: from codeconstruct.com.au (pi.codeconstruct.com.au [203.29.241.158]) (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 3B0145A867; Mon, 18 Dec 2023 23:03:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=codeconstruct.com.au Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=codeconstruct.com.au Received: from [192.168.68.112] (ppp118-210-80-147.adl-adc-lon-bras32.tpg.internode.on.net [118.210.80.147]) by mail.codeconstruct.com.au (Postfix) with ESMTPSA id 0D8F72014F; Tue, 19 Dec 2023 07:02:47 +0800 (AWST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codeconstruct.com.au; s=2022a; t=1702940572; bh=YJxqecOL6R6o6l2AGHwi7QgNX0u29B+GDnVZRFgkI+k=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=WPpwQ9xuCxjzJXTUKiuwMsoVkjUOhqrT6gnnb+LZcvdi72ZyLxsdejy13T3hs6sJn jec0d5Yk7/2oi6H9++Tf2QiyR2h/vHmi1wIH91bYIFfcc9CVWxGyIlJswVcVgmvrdG aQHnrOaw1d9VThcRuYhLTvTqr1q2qch4DLthL4XtR1PqjhgVw5TWULqAKdTkUc14mg vJjWfXN1VFaLe6mLftYRcg2sz8Kpue0Z4pU6DtLCkYRXKq9Yc8hBsQaWwQXfZzUlae Zz9md12KBZIi1UpqHb7lMHQA9Zl/6UKbC2FOyGuxuWTZjkk1LkZ/Nyx9j70mgR/Bgk htzkxxHW79TMQ== Message-ID: <477f1e8fbed91cc1160086af1f20030e7a6d853b.camel@codeconstruct.com.au> Subject: Re: [PATCH v4 2/2] i2c: aspeed: Acknowledge Tx done with and without ACK irq late From: Andrew Jeffery To: Quan Nguyen , Brendan Higgins , Benjamin Herrenschmidt , Joel Stanley , Andi Shyti , Wolfram Sang , Jae Hyun Yoo , Guenter Roeck , linux-i2c@vger.kernel.org, openbmc@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org Cc: Cosmo Chou , Open Source Submission , Phong Vo , "Thang Q . Nguyen" Date: Tue, 19 Dec 2023 09:32:45 +1030 In-Reply-To: <7dfc99e5-4c76-413b-aabc-81b26e26249e@os.amperecomputing.com> References: <20231211102217.2436294-1-quan@os.amperecomputing.com> <20231211102217.2436294-3-quan@os.amperecomputing.com> <2eab42cde34723a195e7a0287db08b25f8388a3b.camel@codeconstruct.com.au> <54cba87a0df233b8762e43b742afe8e44a77a60c.camel@codeconstruct.com.au> <7dfc99e5-4c76-413b-aabc-81b26e26249e@os.amperecomputing.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4-2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Mon, 2023-12-18 at 15:45 +0700, Quan Nguyen wrote: >=20 > On 15/12/2023 05:21, Andrew Jeffery wrote: > >=20 > > ``` > > $ qemu-system-arm \ > > -M ast2600-evb \ > > -kernel build.aspeed_g5/arch/arm/boot/zImage \ > > -dtb build.aspeed_g5/arch/arm/boot/dts/aspeed/aspeed-ast2600-evb.dtb \ > > -initrd ~/src/buildroot.org/buildroot/output/images/rootfs.cpio.xz \ > > -nographic 2>&1 \ > > | ts -s > > ... > > 00:00:03 [ 1.089187] Freeing initrd memory: 3308K > > 00:00:05 smbus: error: Unexpected send start condition in state 1 > > 00:00:05 smbus: error: Unexpected write in state -1 > > 00:00:06 [ 3.685731] aspeed-i2c-bus 1e78a400.i2c-bus: i2c bus 7 regi= stered, irq 48 > > 00:00:06 [ 3.688918] aspeed-i2c-bus 1e78a480.i2c-bus: i2c bus 8 regi= stered, irq 49 > > 00:00:06 [ 3.692326] aspeed-i2c-bus 1e78a500.i2c-bus: i2c bus 9 regi= stered, irq 50 > > 00:00:06 [ 3.693757] aspeed-i2c-bus 1e78a680.i2c-bus: i2c bus 12 reg= istered, irq 51 > > 00:00:06 [ 3.695070] aspeed-i2c-bus 1e78a700.i2c-bus: i2c bus 13 reg= istered, irq 52 > > 00:00:06 [ 3.696184] aspeed-i2c-bus 1e78a780.i2c-bus: i2c bus 14 reg= istered, irq 53 > > 00:00:06 [ 3.697144] aspeed-i2c-bus 1e78a800.i2c-bus: i2c bus 15 reg= istered, irq 54 > > 00:00:06 [ 3.699061] aspeed-video 1e700000.video: irq 55 > > 00:00:06 [ 3.699254] aspeed-video 1e700000.video: assigned reserved = memory node video > > 00:00:06 [ 3.702755] aspeed-video 1e700000.video: alloc mem size(245= 76) at 0xbc000000 for jpeg header > > 00:00:06 [ 3.706139] Driver for 1-wire Dallas network protocol. > > 00:00:07 smbus: error: Unexpected send start condition in state -1 > > 00:00:07 smbus: error: Unexpected write in state -1 > > 00:00:10 smbus: error: Unexpected send start condition in state -1 > > 00:00:10 smbus: error: Unexpected write in state -1 > > 00:00:12 smbus: error: Unexpected send start condition in state -1 > > 00:00:12 smbus: error: Unexpected write in state -1 > > 00:00:14 smbus: error: Unexpected send start condition in state -1 > > 00:00:14 smbus: error: Unexpected write in state -1 > > 00:00:17 smbus: error: Unexpected send start condition in state -1 > > 00:00:17 smbus: error: Unexpected write in state -1 > > 00:00:18 [ 14.080141] adt7475 7-002e: Error configuring attenuator by= pass > > 00:00:19 smbus: error: Unexpected send start condition in state -1 > > 00:00:19 smbus: error: Unexpected write in state -1 > > 00:00:21 smbus: error: Unexpected send start condition in state -1 > > 00:00:21 smbus: error: Unexpected write in state -1 > > 00:00:24 smbus: error: Unexpected send start condition in state -1 > > 00:00:24 smbus: error: Unexpected write in state -1 > > ``` > >=20 > > The smbus errors do not occur if I revert this patch. > >=20 > > Can you look into qemu to see if it's a bug in the aspeed i2c > > controller model's state machine? > >=20 >=20 > Thanks, Andrew, for testing these patches on qemu. >=20 > I'll try to look into it to see if anything can be improved, but I have= =20 > to admit that I'm not so familiar with it. This is my first time trying= =20 > it on qemu. Just did these tests on real HW with waveform captured=20 > sometimes. >=20 > So far I could be able to reproduce the issue and start playing around= =20 > trying to understand the model. >=20 So `$ git grep -lF 'Unexpected write in state'` leads us to hw/i2c/smbus_slave.c:193. From the switch statement there and the log output above dev->mode must be SMBUS_CONFUSED: https://gitlab.com/qemu-project/qemu/-/blob/039afc5ef7367fbc8fb475580c291c2= 655e856cb/hw/i2c/smbus_slave.c#L35-L41 The prior log message was: ``` 00:00:05 smbus: error: Unexpected send start condition in state 1 ``` So we entered SMBUS_CONFUSED from SMBUS_WRITE_DATA. Given the log output above it suggests the master model is failing to send an I2C_FINISH prior to I2C_START_SEND, as that log message is emitted from `dev->mode !=3D SMBUS_IDLE` when the slave sees an `I2C_START_SEND`. Perhaps the M_STOP_CMD handling needs to go above the M_START_CMD handling in aspeed_i2c_bus_handle_cmd()? https://gitlab.com/qemu-project/qemu/-/blob/039afc5ef7367fbc8fb475580c291c2= 655e856cb/hw/i2c/aspeed_i2c.c#L450 Andrew