Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3206238rdb; Wed, 13 Sep 2023 05:36:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHsNosDpuOLfyYcdz4F9pjZr+RPr1FZO/GfpG8wrNCYbh1dUYxKk5mP+CYpQi5+q4d96NhY X-Received: by 2002:a05:6358:928:b0:139:bbae:1f3 with SMTP id r40-20020a056358092800b00139bbae01f3mr3252947rwi.3.1694608564093; Wed, 13 Sep 2023 05:36:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694608564; cv=none; d=google.com; s=arc-20160816; b=qXeaEwjnRELh6Gm8WF41EWjMJaTYfaVLS954fVevpGu5pf6d3Twd0BFmLlh2jMD1B6 iAZ+Dwp2FkWGfsAWA7J9EoA0qim3g/ic7jUMMmngAqDrzbJziFB7UAr3C/7UCDwMrB49 aFftI4HYHTxqIajn8t4pNCkHm76pWbdh0BoGWDVcs1/NQkl7aL2IWdJieI2YZly1qTF0 xUR7PaW0IyUPonuRX6ScJgD9ewHqlm6NlpQyVmGle7qO1ZJ/lTI3OkT2RxOXjg37RWAb tgu6jnAfVSm1aFiVf2gmH9MDiQXCqX2KOeTyx16SPguxqSF7/5+VhAqHiDCJAKJ8xCRM ZGkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=hsxchjZb9NNdx19raBfkRm04KA1FW7IMdO9X4io4lsQ=; fh=9Otq0vJ9DEcx/JIUc52u50yzlhChaYsm24kJ5qa8wbQ=; b=Xd7JLigug9moqJYntYSKf4O4NMoZib5ALBM+PD1pAM6lIe1bSfkJqBofWsZ2xdzUuA TCXfqh5uHgi7qAKjMFbRUvZHVD1orlgLRCcgV2bLXYNUmYHAlx3ia43iFjDppd9qYOtY dBjuX2dk6xkDA/7KLzepfcV1mnLIJyG5zo+CCT5uZieMDx5+QQo4O8iL3DsIY3BrA9/7 ELFVKHFNkIVJ485ECCnPsF/RO1Hkxw0VuwCFG8nEQ6g1nFXKFsMP875T8ZfTNWZpZcON z2+kYWutvmNGw7zzzWbWoECrSKUmVz6t5slBNyQi+LJ8RD5D15mYp5RgugbIy/Lhm6Di KpUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=c0YyYKWt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id l191-20020a6388c8000000b00537c6c285a0si7284773pgd.167.2023.09.13.05.35.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 05:36:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=c0YyYKWt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 3BE08801F893; Wed, 13 Sep 2023 05:28:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240320AbjIMM22 (ORCPT + 99 others); Wed, 13 Sep 2023 08:28:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236105AbjIMM20 (ORCPT ); Wed, 13 Sep 2023 08:28:26 -0400 Received: from mail-yw1-x1143.google.com (mail-yw1-x1143.google.com [IPv6:2607:f8b0:4864:20::1143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C38EC19A8; Wed, 13 Sep 2023 05:28:22 -0700 (PDT) Received: by mail-yw1-x1143.google.com with SMTP id 00721157ae682-59b8f5b6c0aso30735007b3.0; Wed, 13 Sep 2023 05:28:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694608102; x=1695212902; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=hsxchjZb9NNdx19raBfkRm04KA1FW7IMdO9X4io4lsQ=; b=c0YyYKWt49IFIBKetzSZ2+ouiBufu/NbEwZoQqvqT6rBoONHJxcuI6HBEKAQah2kpX 6doSzw0ia9i5YorIGqsv3PgNKD8oXis203Qve9Fpnyg4RvG286GKYvcgKhj6vd4H7cim URq0D1ixVqeD6RV5qi+R+vVrJFxbrv0XuKeSD0PBtAsvPgEOKopzO0ix2F9oFbiZ+Pby JwzriuKyQRaO2GktJoqHR8TOf6wUDJKBuTdFDzUVmDVVJLoRz35agZO5trVNdazhpqwd sF/rx0e9bPPzrfBWh8+XVKhlVT3fR6kjsJsHkTYIlNz3U7AHlMo4FfNP4GRyXe5oK5/2 2aKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694608102; x=1695212902; h=content-transfer-encoding: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=hsxchjZb9NNdx19raBfkRm04KA1FW7IMdO9X4io4lsQ=; b=l+tziPMb1tK2+NR6BkP/k35imBVFrkTQ4PBYuixFZR/O8U9qi4+kSLbk2IsXXEhqX4 IrBFm8mX3PUlzin2IWNBdJ+opU33r9Rh2rYj7WH+12JhkWMoppV7AnIsqkNYaoAJ/fnL 78t68osvHr3JviweazRmuBY4NVMBNv31wCqQ05JpwbWw7zTqb/bnQdR1uOPrZBxt5qxQ a90wLSHFV01vGBOn//17NdpWEomAH+P1hDtai1LeYt6pBM3MbX2/kwSHqP69Kdx1YP1V u72I2+2STOVJwTMwJ9i3z3zmRNDlhPsORyzXyhStxv2q3yHYORAZE/reuaCAa65aNsib uxZw== X-Gm-Message-State: AOJu0YxA7jvMXUohEWyWTVve/2Nlhy/vZMfihWC9sdYR6fTVYxNYTZWg oC9SVzSK+Pc/r9g7G8VxwM+cI4jyumeyF7Ke6N7trKDgxBg5qw== X-Received: by 2002:a0d:ca97:0:b0:59b:d351:60cd with SMTP id m145-20020a0dca97000000b0059bd35160cdmr1087422ywd.38.1694608101993; Wed, 13 Sep 2023 05:28:21 -0700 (PDT) MIME-Version: 1.0 References: <20230817094520.21286-1-Huangzheng.Lai@unisoc.com> <20230817094520.21286-4-Huangzheng.Lai@unisoc.com> <20230902210513.3xelrcdtynz45p4o@zenone.zhora.eu> In-Reply-To: <20230902210513.3xelrcdtynz45p4o@zenone.zhora.eu> From: huangzheng lai Date: Wed, 13 Sep 2023 20:28:11 +0800 Message-ID: Subject: Re: [PATCH 3/8] i2c: sprd: Use global variables to record IIC ack/nack status instead of local variables To: Andi Shyti Cc: Huangzheng Lai , Orson Zhai , Baolin Wang , Chunyan Zhang , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Xiongpeng Wu Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 (morse.vger.email [0.0.0.0]); Wed, 13 Sep 2023 05:28:29 -0700 (PDT) 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Hi Andi, On Sun, Sep 3, 2023 at 5:05=E2=80=AFAM Andi Shyti w= rote: > > Hi Huangzheng, > > On Thu, Aug 17, 2023 at 05:45:15PM +0800, Huangzheng Lai wrote: > > We found that when the interrupt bit of the IIC controller is cleared, > > the ack/nack bit is also cleared at the same time. After clearing the > > interrupt bit in sprd_i2c_isr(), incorrect ack/nack information will be > > obtained in sprd_i2c_isr_thread(), resulting in incorrect communication > > when nack cannot be recognized. To solve this problem, we used a global > > variable to record ack/nack information before clearing the interrupt > > bit instead of a local variable. > > > > Signed-off-by: Huangzheng Lai > > Is this a fix? Then please consider adding > > Fixes: 8b9ec0719834 ("i2c: Add Spreadtrum I2C controller driver") > Cc: # v4.14+ Thank you for your prompt. In the next version of the patch, I will add the fixes tag. > > > --- > > drivers/i2c/busses/i2c-sprd.c | 10 +++++----- > > 1 file changed, 5 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/i2c/busses/i2c-sprd.c b/drivers/i2c/busses/i2c-spr= d.c > > index 066b3a9c30c8..549b60dd3273 100644 > > --- a/drivers/i2c/busses/i2c-sprd.c > > +++ b/drivers/i2c/busses/i2c-sprd.c > > @@ -85,6 +85,7 @@ struct sprd_i2c { > > struct clk *clk; > > u32 src_clk; > > u32 bus_freq; > > + bool ack_flag; > > smells a bit racy... however we are in the same interrupt cycle. > > Do you think we might need a spinlock around here? The fifo empty and full interrupt enable will be turned off in sprd_i2c_isr(), and will not be reset until sprd_i2c_isr_thread() finishes processing, depending on the situation. Apart from these two interrupt types, there are only two types left: transmission completion and transmission failure. Both interrupts need to be re initiated for transmission to occur, and transmission will not be re initiated until the current data processing is completed. Thanks, Huangzheng