Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp2835736rdh; Sun, 26 Nov 2023 23:05:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IF/KGqUUQfnhaLk8QSjOQr2uhYDdsQn/lAP9W3YaZBTSdzUwLwyqgL5SVWxyz/BN/bSxgsj X-Received: by 2002:a17:903:246:b0:1cc:5a65:c535 with SMTP id j6-20020a170903024600b001cc5a65c535mr13062862plh.6.1701068750742; Sun, 26 Nov 2023 23:05:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701068750; cv=none; d=google.com; s=arc-20160816; b=jivMkHf34JEL47GfVPgwF6qsrpcwqkzJjX6TLbr3DdSx9mYx7Nd/m/KcHjsed4T5je u1nP7OztNU8bMpyMZjRfvmrtK6gVxGI8vayQro0nZpLyLLjUbt1NSV85GIVW2+v1E7L1 ZC4orEleoR1dKdZS7LOGCQdkLBEZsbJ0iJMMqqc0VLwZ7ZNA0lyi1BQf6iNGv7tcnc3b reIqaWJkxBndi88AxGVgMjMaxOUq6sEl0b7l/N7SHmIf+M4sBHSa/7pp9+3YWOFsF+iu AMA7wj8+HdIvKKhF6YMGDZ1JoHZhYeHNjNznTz5/1BxPCK7gBmZvIBS/rTvKLsLUSSAy FD5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=njKIqe2mNiRdX5LaAFqRQiCwPnpSDRZxDJdhCHqWXjY=; fh=rrziHh00Oo9vK/Uwn3xLnRYUOFRNW4JlL2fSGM6Shmc=; b=A4vPVmHImzIyace1wg1TU5+51e13uMRLgiXPRNsFKiZV90IySZw3IYmBbASx2BdTBg Ur/NKCeS5dBUedNvJ2JfK5Jh5mOYLGsYXYfU/KNrD++rbjpp+nnDo76R4RORi2ecMLf9 FYPQ+4WpOOR2akcCKW02bQLAKoyuNpIa3IrTte1RAyW7bte2+MHUqMvtsJ9zSeVoJaQy AYptT1+AhXjbpfiHxyBfZGYlCfx3nP+1X/TH3KTyAjwQvDpQvl9H3v6zAdD27blSApCz 3d6WhyV+GFCKbzn1y6fB5eUHJLN0hfyp3C5z4UVkoq7uFrHlY58OlpJj7Y2mWkt7+dmt OIeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="KFm27/He"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id g3-20020a170902934300b001ca7a4c8360si7472234plp.31.2023.11.26.23.05.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Nov 2023 23:05:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="KFm27/He"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id D5E33807C749; Sun, 26 Nov 2023 23:05:20 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229527AbjK0HE7 (ORCPT + 99 others); Mon, 27 Nov 2023 02:04:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjK0HE6 (ORCPT ); Mon, 27 Nov 2023 02:04:58 -0500 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6358812F; Sun, 26 Nov 2023 23:05:04 -0800 (PST) Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a02d12a2444so555255766b.3; Sun, 26 Nov 2023 23:05:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701068703; x=1701673503; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=njKIqe2mNiRdX5LaAFqRQiCwPnpSDRZxDJdhCHqWXjY=; b=KFm27/HeZ/b7wqKHOFGTBZ8e7iHDHwJM9rf0n/IHFED/1pbnD0apQfIq1rAVm6tMtS fnXvbuS+7iCFXDy4vSZ85Hv7bN3B8y+OYDWUcnQ4aqoRQLBo3a7wTscQGDcXg8qHqovs IvadzjxQZu0S6qYMlZJ2flUrVrK0Az8RueP33cO73T1CkXkqeSet082MmEJqAgmXKHPk FSyCN5Jhk5DBnWF61Uydy5Ffv+VzrppzrxswLBaA/ajv4ndvKVTd2YS1KMkPP/Ga/Nld THZO+I0kHe1Kk2xT5z4QRsaSkvfZUJC4K1sraxwOpl7PELM3zaFVZloZCLdFHwmzY9T2 RkIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701068703; x=1701673503; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=njKIqe2mNiRdX5LaAFqRQiCwPnpSDRZxDJdhCHqWXjY=; b=ScOBy78w60cN6anybmCgct1ktnNLfI+9k5mLSyqKxqgEddBzqmqtHdwXafs/xUW1iM SSJqaMg5tjyEV4xRi7urzpgdrvuTgl0jG4AMmf49ZB+AHZnjFJt6nyHiKlhVFsoTceuj VAe0XPoVDAUohd65qimIcaQgaajL/hSA0ETfq03CDX+nC8IPbmjN5QcJcq/rF7e2Y8Iu 5kYmcx3UmXYBboPSgZ2H57XTP42DL8akgEgr4KSGZSB3pR4YInZzEcOZvy2sqXTVT5aD Suo5syVvuiql6SufcsBZOB4i9b7eXP1VwvQ8YY/gXJRep7PImJhRP1oD3H09DXGI8stS 94Sw== X-Gm-Message-State: AOJu0YxxdmLbsjvBAc0JhcJC7CcjhW4vsjgylzihYeV50Qi+Sawi4Nlx qQGDnL01HU5YjI1qlJsjhpTHN1yllw+rTlcn6W/QO7CyptTdNg== X-Received: by 2002:a17:906:66c1:b0:9ff:77c2:e67f with SMTP id k1-20020a17090666c100b009ff77c2e67fmr7216953ejp.33.1701068702634; Sun, 26 Nov 2023 23:05:02 -0800 (PST) MIME-Version: 1.0 References: <20231120091746.2866232-1-chou.cosmo@gmail.com> In-Reply-To: From: Cosmo Chou Date: Mon, 27 Nov 2023 15:04:51 +0800 Message-ID: Subject: Re: [PATCH] i2c: aspeed: Acknowledge Tx ack late when in SLAVE_READ_PROCESSED To: Andrew Jeffery Cc: brendan.higgins@linux.dev, benh@kernel.crashing.org, joel@jms.id.au, andi.shyti@kernel.org, linux@roeck-us.net, wsa@kernel.org, jae.hyun.yoo@linux.intel.com, 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, cosmo.chou@quantatw.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sun, 26 Nov 2023 23:05:21 -0800 (PST) Andrew Jeffery wrote on Mon, 2023-11-27 at 11:23 AM: > > On Mon, 2023-11-20 at 17:17 +0800, Cosmo Chou wrote: > > commit 2be6b47211e1 ("i2c: aspeed: Acknowledge most interrupts early > > in interrupt handler") moved most interrupt acknowledgments to the > > start of the interrupt handler to avoid race conditions. However, > > slave Tx ack status shouldn't be cleared before SLAVE_READ_PROCESSED > > is handled. > > > > Acknowledge Tx ack status after handling SLAVE_READ_PROCESSED to fix > > the problem that the next byte is not sent correctly. > > What does this mean in practice? Can you provide more details? It > sounds like you've seen concrete problems and it would be nice to > capture what it was that occurred. > > Andrew For a normal slave transaction, a master attempts to read out N bytes from BMC: (BMC addr: 0x20) [S] [21] [A] [1st_B] [1_ack] [2nd_B] [2_ack] ... [Nth_B] [N] [P] T1: when [21] [A]: Both INTR_SLAVE_MATCH and INTR_RX_DONE rise, INTR_RX_DONE is not cleared until BMC is ready to send the 1st_B: https://github.com/torvalds/linux/blob/master/drivers/i2c/busses/i2c-aspeed.c#L294 That is, BMC stretches the SCL until ready to send the 1st_B. T2: when [1_ack]: INTR_TX_ACK rises, but it's cleared at the start of the ISR, so that BMC does not stretch the SCL, the master continues to read 2nd_B before BMC is ready to send the 2nd_B. To fix this, do not clear INTR_TX_ACK until BMC is ready to send data: https://github.com/torvalds/linux/blob/master/drivers/i2c/busses/i2c-aspeed.c#L302 Cosmo