From patchwork Fri Sep 13 10:14:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyrone Ting X-Patchwork-Id: 828392 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 089511C2DAA; Fri, 13 Sep 2024 10:15:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726222504; cv=none; b=V4HZyI9GYSZxpF99coRv9Y3VeDG4z/7fGkvIiMiua68tEN9ACaZxb8REYEzijF6o0OxBf/OkvpiZPJLy35seVmwJjhvQ+afk4XjcIZF1qPeA3lSxunVhaJS+RxCMDMxsPOyfvEtO7dlqAqqlxwbb/aSJM63Nv9wTQtr14T55yZY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726222504; c=relaxed/simple; bh=UaVhrWPRrj8URDfaChzsHRZwdGfSRxrk64dkcS/Mepw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=YV+4NrHzgKZEkUNTLlMTbH9Q5B1G5LH8mS88SoqFnKQDtnUWxNRgqeprQ+VaSDanEvJ3XLaKRf0MBxPM2E8fesk5kUmmrB2fSpx41ob2lYyMSOIEAVU+OnXZInTDS9wlEiFxyX/EZqzAfM3a3vWeWBlKAmfrTb46P6eH15bDwWI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jCrGW4G/; arc=none smtp.client-ip=209.85.210.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jCrGW4G/" Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-718f4fd89e5so1805066b3a.0; Fri, 13 Sep 2024 03:15:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726222502; x=1726827302; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=1BGcthvFE7iZ7GLQ5GBYdiVKahiHTHcdNQMsIVlcYPg=; b=jCrGW4G/isNgGsERH1nGO+HQuDYZBziegOT29imFeyP+l7GfLy3Df04rrZmxC4yiIo Vh4yOhT/iKYQuiWjuSmKn6xz1zXqGXKy4VTwqUf8FKqARsJgst6R8j8cvsrGs8uvYRhb CqZOrrTfM/ZI1Exuh9dFQlM4znuvsOQbsyoTLFIvcdl5bQg8rnCHxjigG39EMYYlY10o hnQwaSfRbyFlDCktscHrhqK7Eb5S5paH2jTE0F1FHz4yXkwCkrwFvDCxFSvlbI9XqHOq pgGjvi0AToFfYxv5qKhTHomr+sb1ZCabEtQMPC8CehQGs+O3UwwlWtZSVRK7XyxtzhUm aXJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726222502; x=1726827302; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1BGcthvFE7iZ7GLQ5GBYdiVKahiHTHcdNQMsIVlcYPg=; b=Bbm6YRlqx345+CqK9IG87FPSfoW8FQUWemJ1GITeekrd1xAOy0suaoTmLb9NdKFdo4 h9n29P1+RGhC4NKYUog/9xdVEiZsxi+372gQCCRafjXjSpTy7tZAJTu++u2i59xd728g qSLD+hln8X4H/ClHzQ/jeX3UQjfBpzXKG7rf8TA0A3G7T10cz9rSVyJsHis3Vc5WvvWg KbC68+hj31En3l+bOArWCEdAR2oiw316exGcAth+Z+xsKMSQz7FqkTO3n+iZgLCoZ4JY Z7LM1lOnqK+2k87Qux2kb9/XbHqNyaGCi6lsAyEdffnBKx+pBhEZP0QDB5V2e+PtHL2U V10A== X-Forwarded-Encrypted: i=1; AJvYcCVbw1H+uORX32tezruZiczN7RnsGEOv7fLwivvHPWwXfvDCnHNdW0dlO0SUq20eU2yLqKNOE9yt3wFmF9As@vger.kernel.org, AJvYcCXQxJMmuD9ij5FGXBYb1fxgACpU0DkQEuYXsKsqHVRP0UDEoXjEk7JYBCv5TjwXLZsEgGOz713F9oY=@vger.kernel.org X-Gm-Message-State: AOJu0YwpsryTWdfJ49xvrctPiRSLNpI0NMEnUH9oEWLjD1u74nJagnPy +lcLRjJ20wxFPIyDB1zIcKaUMX718z3E9x1lZcBcRbkXyf0cwGk= X-Google-Smtp-Source: AGHT+IFN/+8+evtZLjVKFw6cYdVaoUYs3aUOmN15pQaGNz/9tKq8F0s/IxmSII3BTDfiXTypDRemBA== X-Received: by 2002:a05:6a21:58b:b0:1cf:6953:2872 with SMTP id adf61e73a8af0-1cf764c27f2mr7849092637.48.1726222502190; Fri, 13 Sep 2024 03:15:02 -0700 (PDT) Received: from localhost (2001-b400-e334-c33a-b4cd-4a8f-209a-cf54.emome-ip6.hinet.net. [2001:b400:e334:c33a:b4cd:4a8f:209a:cf54]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7190909256csm5804618b3a.125.2024.09.13.03.15.01 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Sep 2024 03:15:01 -0700 (PDT) From: warp5tw@gmail.com X-Google-Original-From: kfting@nuvoton.com To: avifishman70@gmail.com, tmaimon77@gmail.com, tali.perry1@gmail.com, venture@google.com, yuenn@google.com, benjaminfair@google.com, andi.shyti@kernel.org, andriy.shevchenko@linux.intel.com, wsa@kernel.org, rand.sec96@gmail.com, wsa+renesas@sang-engineering.com, warp5tw@gmail.com, tali.perry@nuvoton.com, Avi.Fishman@nuvoton.com, tomer.maimon@nuvoton.com, KWLIU@nuvoton.com, JJLIU0@nuvoton.com, kfting@nuvoton.com Cc: openbmc@lists.ozlabs.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/6] i2c: npcm: use a software flag to indicate a BER condition Date: Fri, 13 Sep 2024 18:14:42 +0800 Message-Id: <20240913101445.16513-3-kfting@nuvoton.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240913101445.16513-1-kfting@nuvoton.com> References: <20240913101445.16513-1-kfting@nuvoton.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: From: Tyrone Ting If not clearing the BB (bus busy) condition in the BER (bus error) interrupt, the driver causes a timeout and hence the i2c core doesn't do the i2c transfer retry but returns the driver's return value to the upper layer instead. Clear the BB condition in the BER interrupt and a software flag is used. The driver does an i2c recovery without causing the timeout if the flag is set. Signed-off-by: Tyrone Ting Reviewed-by: Tali Perry --- drivers/i2c/busses/i2c-npcm7xx.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c index 2b76dbfba438..2d034503d8bc 100644 --- a/drivers/i2c/busses/i2c-npcm7xx.c +++ b/drivers/i2c/busses/i2c-npcm7xx.c @@ -334,6 +334,7 @@ struct npcm_i2c { u64 nack_cnt; u64 timeout_cnt; u64 tx_complete_cnt; + bool ber_state; }; static inline void npcm_i2c_select_bank(struct npcm_i2c *bus, @@ -1521,6 +1522,7 @@ static void npcm_i2c_irq_handle_ber(struct npcm_i2c *bus) if (npcm_i2c_is_master(bus)) { npcm_i2c_master_abort(bus); } else { + bus->ber_state = true; npcm_i2c_clear_master_status(bus); /* Clear BB (BUS BUSY) bit */ @@ -1699,6 +1701,7 @@ static int npcm_i2c_recovery_tgclk(struct i2c_adapter *_adap) dev_dbg(bus->dev, "bus%d-0x%x recovery skipped, bus not stuck", bus->num, bus->dest_addr); npcm_i2c_reset(bus); + bus->ber_state = false; return 0; } @@ -1763,6 +1766,7 @@ static int npcm_i2c_recovery_tgclk(struct i2c_adapter *_adap) if (bus->rec_succ_cnt < ULLONG_MAX) bus->rec_succ_cnt++; } + bus->ber_state = false; return status; } @@ -2158,7 +2162,7 @@ static int npcm_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, } while (time_is_after_jiffies(time_left) && bus_busy); - if (bus_busy) { + if (bus_busy || bus->ber_state) { iowrite8(NPCM_I2CCST_BB, bus->reg + NPCM_I2CCST); npcm_i2c_reset(bus); i2c_recover_bus(adap); From patchwork Fri Sep 13 10:14:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyrone Ting X-Patchwork-Id: 828391 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24EF819F401; Fri, 13 Sep 2024 10:15:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726222512; cv=none; b=G0aJTd2OeGr9MlAiLEH+eWRH9IYZwahg/dbjCl3RPTQGFkgi4wetjJb3Lqm4GuVlgWfX0GndA+wqCtHglwwtjh9K+vtTjAzXWwJl/vvig8Z/LDyeMDvK//wkx4b3oRNbA0SOYfiMXc+ZoIg+DtIt22mfTab2sYwcopfhbZLDP9M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726222512; c=relaxed/simple; bh=eYqdFGeeI6JMSXzz1AebDd2mo26GrYd8KbFl6H6hD3o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=JnUOyWfyw10lvXA1z5DusJ9rAPi4VaRJf3WoY40BtLY/OVqrspwlJHv2POfGRr3/0Woz3kh71kqzVCgU18R2eEsIUFCq6ZDECtTOioIWBGAFOaRqli31CSLUfR4SunWFpIOQBJJKvcIhamh0OZeeYu/EZkCNIZl924Bll6bbh7A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FHR59Bu+; arc=none smtp.client-ip=209.85.210.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FHR59Bu+" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-718e9c8bd83so2232875b3a.1; Fri, 13 Sep 2024 03:15:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726222510; x=1726827310; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=Ld5dlQNPUQTUFF/Ssx2WQipHo3yFKCbKn/t6dhaVrDQ=; b=FHR59Bu+2UFB4IA24EELVZXmPkxb6QQho6gCgnROVAImtSN6HvA59GHI1/9IH4Jq9o C/eKojzMKmGJMZKUhnC14yLD04orRJqvIi0ji3Eg1fdFnZhRhGhiqC5WmYXw0DVb73Rv ss7yh5bXdPukLh9mJIHt9cXD7/sIu8LZ+aosej469zeFChm05zdMHgunXI00lDh06ORh DrKd4hw3nDGb+VTpjyu1MQHbr3Gym6yFFpiA37Hia5l/8r4kw6Uwv4WdPT03KhI6eIpl Fe3w0kSWwiFKfhTC6rhqeEIiBw7aSOdetDYKD5CdElwr3ZFjGS6alTb7kkH/KmjsGbce sFSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726222510; x=1726827310; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Ld5dlQNPUQTUFF/Ssx2WQipHo3yFKCbKn/t6dhaVrDQ=; b=MqCHIzR7KqDVQYyF5cThBajnSvIk5JGdIgvkZMd7AepsboZRwF7/tj0/ynYiRYQFdU 0CQ+WVLxwBovCSbw8/2hEH70RJo7gC7Gdu+90lNXd5WIUtP/hoHaqT463NkQQx1hrwR5 t4b1we71PNEkd92sVIDK/7RVeS8JvHNj9Ft5i3YeuiIW4dVB3BJC0lDgddmtQ+a4a0Aj IvqFp4ZywFU+NpnbqA/9GVNAwLPTyDzN70z3YtzgMjLcOsWdk1p0z8JbYicnOqM75sE4 mWUNN0pqHu6ACqDLFSDVnXi1hIqQdAK4dYPKzBH59ANgZNoVMRcrbe4Qmyb7+o0C47b3 aqFw== X-Forwarded-Encrypted: i=1; AJvYcCUqye8BB+RBqZap6hxMOcW5DjRhdPUw1T8FKhCx3Z5n10o6TTJ5GXaoT3u2uDDqPR5U2Q+O9R/Xt4BXOmqv@vger.kernel.org, AJvYcCVUsayIK+MwpDozGvLodcMwViQncTVuOvr7sJ4+V9gHMzW5k0qf9N+lqP/+KIgTpjNqeeYLvsaGG2k=@vger.kernel.org X-Gm-Message-State: AOJu0Yy5GOG8Gya/u/Y84EvcXzYyB/RoUBZLhQmh7hu8/aW6ujAF1f8a k1+sk0FFMjdH6qwufmv4hoL1b4MITf4bbg0iwpgjZO2UQkuOgbI= X-Google-Smtp-Source: AGHT+IGt26oOAshFJlW/po5/WtDlvLOL1IGJhw4CdzWN+MaBv+2N3YYu0lqY/H1NjONEpq76mTw+/w== X-Received: by 2002:a05:6a00:6f18:b0:717:98e7:3d0 with SMTP id d2e1a72fcca58-71907ba053fmr23661051b3a.0.1726222510134; Fri, 13 Sep 2024 03:15:10 -0700 (PDT) Received: from localhost (2001-b400-e334-c33a-b4cd-4a8f-209a-cf54.emome-ip6.hinet.net. [2001:b400:e334:c33a:b4cd:4a8f:209a:cf54]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71909003c57sm5813143b3a.89.2024.09.13.03.15.09 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Sep 2024 03:15:09 -0700 (PDT) From: warp5tw@gmail.com X-Google-Original-From: kfting@nuvoton.com To: avifishman70@gmail.com, tmaimon77@gmail.com, tali.perry1@gmail.com, venture@google.com, yuenn@google.com, benjaminfair@google.com, andi.shyti@kernel.org, andriy.shevchenko@linux.intel.com, wsa@kernel.org, rand.sec96@gmail.com, wsa+renesas@sang-engineering.com, warp5tw@gmail.com, tali.perry@nuvoton.com, Avi.Fishman@nuvoton.com, tomer.maimon@nuvoton.com, KWLIU@nuvoton.com, JJLIU0@nuvoton.com, kfting@nuvoton.com Cc: openbmc@lists.ozlabs.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 4/6] i2c: npcm: Modify the client address assignment Date: Fri, 13 Sep 2024 18:14:44 +0800 Message-Id: <20240913101445.16513-5-kfting@nuvoton.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240913101445.16513-1-kfting@nuvoton.com> References: <20240913101445.16513-1-kfting@nuvoton.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: From: Tyrone Ting Store the client address earlier since it might get called in the i2c_recover_bus logic flow at the early stage of the function npcm_i2c_master_xfer. Signed-off-by: Tyrone Ting Reviewed-by: Tali Perry --- drivers/i2c/busses/i2c-npcm7xx.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c index 68f3d47323ab..e52e65e63600 100644 --- a/drivers/i2c/busses/i2c-npcm7xx.c +++ b/drivers/i2c/busses/i2c-npcm7xx.c @@ -2155,6 +2155,18 @@ static int npcm_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, } while (time_is_after_jiffies(time_left) && bus_busy); + /* + * Previously, the address was stored w/o left-shift by one bit and + * with that shift in the following call to npcm_i2c_master_start_xmit. + * + * Since there are cases that the i2c_recover_bus gets called at the + * early stage of the function npcm_i2c_master_xfer, the address is + * stored with the shift and used in the i2c_recover_bus call. + * + * The address is stored from bit 1 to bit 7 in the register for + * sending the i2c address later so it's left-shifted by 1 bit. + */ + bus->dest_addr = slave_addr << 1; if (bus_busy || bus->ber_state) { iowrite8(NPCM_I2CCST_BB, bus->reg + NPCM_I2CCST); npcm_i2c_reset(bus); @@ -2163,7 +2175,6 @@ static int npcm_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, } npcm_i2c_init_params(bus); - bus->dest_addr = slave_addr; bus->msgs = msgs; bus->msgs_num = num; bus->cmd_err = 0; From patchwork Fri Sep 13 10:15:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyrone Ting X-Patchwork-Id: 828390 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B45B91C174C; Fri, 13 Sep 2024 10:15:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726222539; cv=none; b=EHDDn5qDTwD+XmaJ5te3Hay7gFcz4D5LgG7h0Df3wKi+E91umOR83ioGmBmmBTDIg8CqvxspV4yiuIiwculjJRVrim5pkdH1dIHYJknmKZVgj6yEFiYiMaAZmsLto2YU1tXWhRdW2LyB10r3vuYHVGp76iuxREq5KVhPIXhK4SI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726222539; c=relaxed/simple; bh=OgAa7aTq2lPu3Ae+dtZHVJsh3t4kxm7ZckQl6MuZ9uU=; h=From:To:Cc:Subject:Date:Message-Id; b=CWgcJcEBtczxAzFxY++K+1Yqodbjb9uCeI+3mzUdWcst4yNSiEaUxOAsrVOnMn29ZycCC1TSBGn0AFxegL8z7ec+GhZ64rm5w3Vu3t/HC5IT09XiRNu5ZBT5EfoTkkwcBlGlhW35z/wHQe/JCGvLjKb37VoJ8Zp9v08EAcN/9I8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HdbhNtJK; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HdbhNtJK" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-20688fbaeafso8657235ad.0; Fri, 13 Sep 2024 03:15:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726222537; x=1726827337; darn=vger.kernel.org; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jVTHLdi2Mm542zmwkkAlJabphNlWmnDQC/mhVmCZ97o=; b=HdbhNtJKHVHhbbsJO+cWxokB2bWPnz+AEzkslOqS2Cy3lrAoruhiD47QMghRk+OG2P mhUxAStFMjQkQbWrsben/WsHbOpnh9VuEyN6O24d7E1CtxNA7Eog0/CPzWYw7FqKujRd Uf5so+YsbNMkvrQAeX1YdTlFomWhvYfIH9Udi68FBbmRuA53yKKhGPJ3eO1SWttu9ZJ5 d2C4r6IYxw97TNpbzuLSd8AcUjMvMGYv0G3guntaUrDtFBBgmS9OB+Y+y7cWgDUgL+7j 70pYmV/QH47gLtnjwhyZjyg/7MmM1y0EnPd9T2rxqumHk9beUoxuQIlQ0cLHOoh91nJr 297w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726222537; x=1726827337; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jVTHLdi2Mm542zmwkkAlJabphNlWmnDQC/mhVmCZ97o=; b=v/7BVrwCtomD2TpR6jUZkErE9qyz9pRTut2nRe1THgGCDXaJEFhrYKTrGg3P7yhkBB z2oi1LIHdkvkyvBt1KmT6LOomM1H2e62dQVfb2gMSbIqCKmxxtqIiK8Rqsl5p7e8R2V8 ZDsxip8/rAUwFB6t3mYUHUL+JBS6mKd/dW9Pqnii6d966HLie3DP8mjIr0HcSEolfd/S xZstGpFmOd4OrRd3Bm+uVz0M0O0ORpY58L3WLmBCC7cWlZ/9J2QAKHbqNRpoE+nxx076 x9TXSSWq3WHbZqPm9epBgmQvbGmnyd9ho8pd5b1JjFf+nrN7R/GxOhAKSHfHkSAW+wVh ixvw== X-Forwarded-Encrypted: i=1; AJvYcCVS9ow1IBHw2E5MB/NorgT92k5DuO5UO5Ouh7XY/8ggtVngGfjfiWMkm3gpOWFKocF1QJZwZ62Cbk0=@vger.kernel.org, AJvYcCXw4n5GQP90UGraHQ9JfwbX89aMBP7NKkkHKXRs3uFb69dARUN1gLFkL2Hc/85IY8fjUDAG1l1AJGxXk9JW@vger.kernel.org X-Gm-Message-State: AOJu0YxiCGA3CBHu5MJh3tmhWSkN/Y2ShiwGVENbqZm8j859fMZdgHiG BftfH8rMCkBKPdLAwmEXhtY3VvMzp0FslFPghQICMDWnhzsIpDU= X-Google-Smtp-Source: AGHT+IEqBgm2LjVIYJxzm7H8JtO4VCPi7B8otV/hieFQza1fVLggbc0vnIC/IgXxwUmecHv9UgzFEQ== X-Received: by 2002:a17:902:e54e:b0:1fd:791d:1437 with SMTP id d9443c01a7336-20781b476efmr34377225ad.6.1726222536829; Fri, 13 Sep 2024 03:15:36 -0700 (PDT) Received: from localhost (2001-b400-e334-c33a-b4cd-4a8f-209a-cf54.emome-ip6.hinet.net. [2001:b400:e334:c33a:b4cd:4a8f:209a:cf54]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2076afdd48esm25709495ad.178.2024.09.13.03.15.35 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Sep 2024 03:15:35 -0700 (PDT) From: Tyrone Ting X-Google-Original-From: Tyrone Ting To: avifishman70@gmail.com, tmaimon77@gmail.com, tali.perry1@gmail.com, venture@google.com, yuenn@google.com, benjaminfair@google.com, andi.shyti@kernel.org, andriy.shevchenko@linux.intel.com, wsa@kernel.org, rand.sec96@gmail.com, wsa+renesas@sang-engineering.com, warp5tw@gmail.com, tali.perry@nuvoton.com, Avi.Fishman@nuvoton.com, tomer.maimon@nuvoton.com, KWLIU@nuvoton.com, JJLIU0@nuvoton.com, kfting@nuvoton.com Cc: openbmc@lists.ozlabs.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Charles Boyer , Vivekanand Veeracholan Subject: [PATCH v3 6/6] i2c: npcm: Enable slave in eob interrupt Date: Fri, 13 Sep 2024 18:15:32 +0800 Message-Id: <20240913101532.16571-1-kfting@nuvoton.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: From: Charles Boyer Nuvoton slave enable was in user space API call master_xfer, so it is subject to delays from the OS scheduler. If the BMC is not enabled for slave mode in time for master to send response, then it will NAK the address match. Then the PLDM request timeout occurs. If the slave enable is moved to the EOB interrupt service routine, then the BMC can be ready in slave mode by the time it needs to receive a response. Signed-off-by: Charles Boyer Signed-off-by: Vivekanand Veeracholan Signed-off-by: Tyrone Ting Reviewed-by: Tali Perry --- drivers/i2c/busses/i2c-npcm7xx.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c index 03de1353ad6e..bb4586563c0c 100644 --- a/drivers/i2c/busses/i2c-npcm7xx.c +++ b/drivers/i2c/busses/i2c-npcm7xx.c @@ -1781,6 +1781,12 @@ static int npcm_i2c_int_master_handler(struct npcm_i2c *bus) (FIELD_GET(NPCM_I2CCST3_EO_BUSY, ioread8(bus->reg + NPCM_I2CCST3)))) { npcm_i2c_irq_handle_eob(bus); +#if IS_ENABLED(CONFIG_I2C_SLAVE) + /* reenable slave if it was enabled */ + if (bus->slave) + iowrite8((bus->slave->addr & 0x7F) | NPCM_I2CADDR_SAEN, + bus->reg + NPCM_I2CADDR1); +#endif return 0; }