From patchwork Fri Aug 30 03:46:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyrone Ting X-Patchwork-Id: 824249 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 B7E751369AE; Fri, 30 Aug 2024 03:48:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724989737; cv=none; b=Mh6KXzN8cTp7rKcsTzMX0wF8IhaYJW9Q3nM+zyr91ef5pdTI+yLWIIXwwwLbULQ8xDb3UBBiArRWfFj971QvtsoIk3Ola5A8dT9hiK4bSFdx2VGPu1g5c3bYh1dSYuCQqhSHkDxkqs8QadiktNT3DJY+wnnSIyDzSDVAKlImncE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724989737; c=relaxed/simple; bh=/Hh9cHSOWQABreVbQ8MWvIlvXbfjoJgtyHNDAPmLs54=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=KGCUJgDSyPLI3ob8fYkLs3PmYTU/lqXq3ZYg3M3b10J50JtpIwcUUOOvfp8EUYgWHMntNLh2tJPQAlrLH3AYOCoSpzfeaZCgHZbu9HjbA+YOVKxkkugx1EhQbh1mq+tyRFzegAlTGnIfrb9EZr9Ip9pFKsdMKcZXoVm1bFZEA+M= 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=iZ+xp0Ec; arc=none smtp.client-ip=209.85.214.179 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="iZ+xp0Ec" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-20203988f37so13549695ad.1; Thu, 29 Aug 2024 20:48:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724989735; x=1725594535; 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=0Yuwb6+ZqfPT0JtISqh7yyK1d1c60sdj5zghOt5FrDU=; b=iZ+xp0Ec4pbvM4Z8Mw2lxhoRw5hTYNGklx9fg6NxlQ2RfC2NQLCP8Y9Y6SZ6GQHTlB lmbQy2PbQjaIXpV398eT4TT8ikfhawBF/IH77ff4gB1lSydsk8aS5KpV0TbSIVkkxGIi dVFWMQlePHvCbjrufYdzQNLTYZDnmlOJ0bvdJfJKtwGPUq6BGd8TmsUO5phLFPlyh2mb SSQbDAaOm95u5JsQ7I1alNE1Rk03nurRS/GO1m4xouCGcDiTnnqOgrSlnliu7BAl4ujW ZhVXQJvbtEuJkDW347ND12InmxlcpI/IXr1jR6Ey1rV8NNBtaSd9llhxyWFyIWvGtdBM fBIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724989735; x=1725594535; 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=0Yuwb6+ZqfPT0JtISqh7yyK1d1c60sdj5zghOt5FrDU=; b=t4r3vvCljDZ4Gpj4aiVXUZUluZrC0aqQIJ+IadHdoONHscWm2NJwgs14CVfA/ZPAMi Pxl0Zi8AbZ66xvkOAjr+UhpqkScr52P4Mjf096CSVx7urW+lgiKB+H5N1aGOjVGQc6hz Kcph3VptWv3mu6Qfhz/vvN9zAlV0Ggy9aqKrvcfUNVxk7QWti4Op7qf5tjn3Qt1o0tIl kB/2pPMTFli+w0gkfTFTu0YOO2gCuEHGZmW7nnLEwxeY8f/8MjGhbhxvcU5udoU0PDzY tu/uRNyeIe3SrSU8cCAQ+TI38WhdBHNkl/xzZ5Mp7Ke5+/g9Hl/1+mj+7fIyF4ZsJgp1 j1Lg== X-Forwarded-Encrypted: i=1; AJvYcCURpA9qjVUsI8ep75jpVTgPAl1hzEx5WgL0vYq+REZEMvm1Rcl4ehgcaMhTAYkWDhbyP2k9kbqUKHc=@vger.kernel.org, AJvYcCVodA05hjImQieHYamE+EW92tpo+1EJ0mj+3aVHpWlqJiKqKTCx+QmitHJtmlgMS5+ru3Qat960uIZMys/Z@vger.kernel.org X-Gm-Message-State: AOJu0YxSZ/wj/DUsp8IgBulFRD2UUZICgaIq221vTEBtjlNlq+KDi7yk VU5C/qa/bfT0YtL+jC/lTIiqx+0QtjEH7v5U3kOVk7I6aa3kSi8= X-Google-Smtp-Source: AGHT+IFQRsKAjsdhrL2+vAvZzE83PEnwKYSeTkwNNHy+5kcEHFwYymLvN94tr8b32+bjiWubAZNy8A== X-Received: by 2002:a17:902:c94c:b0:201:e646:4d8 with SMTP id d9443c01a7336-2050c3a7166mr62180945ad.26.1724989734783; Thu, 29 Aug 2024 20:48:54 -0700 (PDT) Received: from localhost (2001-b400-e338-dab5-746d-1a82-f21e-bb0a.emome-ip6.hinet.net. [2001:b400:e338:dab5:746d:1a82:f21e:bb0a]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-205152b1225sm18350175ad.22.2024.08.29.20.48.53 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 29 Aug 2024 20:48:54 -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 Subject: [PATCH v2 1/7] i2c: npcm: restore slave addresses array length Date: Fri, 30 Aug 2024 11:46:34 +0800 Message-Id: <20240830034640.7049-2-kfting@nuvoton.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240830034640.7049-1-kfting@nuvoton.com> References: <20240830034640.7049-1-kfting@nuvoton.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The smatch check warning is "buffer overflow 'npcm_i2caddr' 2 <= 9". The original design supports 10 slave addresses although only 2 addresses are required for current implementation. Restore the npcm_i2caddr array length to fix the smatch warning. Fixes: 47d506d1a28f ("i2c: npcm: Remove own slave addresses 2:10") Reported-by: Dan Carpenter Closes: https://lore.kernel.org/r/202408130818.FgDP5uNm-lkp@intel.com/ Signed-off-by: Tyrone Ting Reviewed-by: Andi Shyti --- drivers/i2c/busses/i2c-npcm7xx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c index 2fe68615942e..bbcb4d6668ce 100644 --- a/drivers/i2c/busses/i2c-npcm7xx.c +++ b/drivers/i2c/busses/i2c-npcm7xx.c @@ -136,11 +136,13 @@ enum i2c_addr { * Since the addr regs are sprinkled all over the address space, * use this array to get the address or each register. */ -#define I2C_NUM_OWN_ADDR 2 +#define I2C_NUM_OWN_ADDR 10 #define I2C_NUM_OWN_ADDR_SUPPORTED 2 static const int npcm_i2caddr[I2C_NUM_OWN_ADDR] = { - NPCM_I2CADDR1, NPCM_I2CADDR2, + NPCM_I2CADDR1, NPCM_I2CADDR2, NPCM_I2CADDR3, NPCM_I2CADDR4, + NPCM_I2CADDR5, NPCM_I2CADDR6, NPCM_I2CADDR7, NPCM_I2CADDR8, + NPCM_I2CADDR9, NPCM_I2CADDR10, }; #endif From patchwork Fri Aug 30 03:46:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyrone Ting X-Patchwork-Id: 824248 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (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 D370014C596; Fri, 30 Aug 2024 03:49:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724989744; cv=none; b=fKleN/9rl1yf+C5Uj+fDGE+ST+Ju0hdd8bnU/+yu2d7FYPZ6ERVpbPJAhVSzFlNm2YTWjqogahgdRTnZit6CVNPEKha92s6QlMuSBooo1YQ8iei2iJhYLju6fupK1jt621BQX4EWD9YAzYKLGCbTcXl2jg/hzv2/4j9I/vdC9gc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724989744; c=relaxed/simple; bh=2GfhZthxRo2cGnQkUAimOhU1adC//LwCOY7KJqz2Uig=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=QW+0lzmKdVmv0Fay5eLYbAE16fszYGomHPg1W3znvYNGklA2RPVSlaQfe4pBKvTr2w6fT5/zNIBMhYiP3PKzJUzzpiy/q0VT9fgOQMhFWv5zabpU8n5pKrk8GPCKOli/IxQ34EY30jqrVFO5wVhNhqgQUso3VrYFDbxPDF5q/6Y= 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=Ak8q4lzm; arc=none smtp.client-ip=209.85.210.172 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="Ak8q4lzm" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-714114be925so1126580b3a.2; Thu, 29 Aug 2024 20:49:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724989742; x=1725594542; 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=VnrTLojAZPBUqXV+IxATkeEOOYkS6IQOxRjyLV//KxQ=; b=Ak8q4lzmSa9gpxa2+zufIuyu/gQrLgZOe3Jpe90ouVH3XWqWMT3gw8tyMCMpZzz5av To8VCfSKHJbix5oGXBSy/8MYhat+humHEBrM6KCnT3+upZkfSsoc2P2N56ffAF1+sBeb 7Wq1DfpNkaVRPCA3k6qLiLHD6kr5+Lv/pAI4qBCxkmJNDYyGd7zgJLFxbiB5+7YFVhbN kWuw7E7LSNEI89HzuwvCazTDJL2i7x724JVR+gAkIGAUczKI5x86qR/uE9npw8DTkiJp p3jlusTzsiTBoiDSBlF47bK+M/sqg/C5oUqAV2tELU66z+J/PN2H6pdV/CfRfCMvz/FD BplA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724989742; x=1725594542; 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=VnrTLojAZPBUqXV+IxATkeEOOYkS6IQOxRjyLV//KxQ=; b=WmDGcEkbATUTjupKwONQoKFxVYetfmIH0cclfMOg9Zy4YOc1hBxr9PKPk+anUmmgKN hsrzwkqxMvCPglo3yFfJ2MZOjiphb3lX7I1oUTlARjNd6SS/9nzSQtN+kGFX7SgwOidK z8Qw1EtHofmAO185E4TUHg3/RHn9YknmIwKgcTW+9Bcn3+DI9PmrgV5NsXjRW8yhf/y/ /5+jQNgfT20PD96+mxL2OFFyz6P/mCQ/lE323PvXgClRz/x9oJLFLvO1o32h+PfrNH+c Zihw9H3cAWf8ZkDNK/GBDij8M2gKUYa2e07U+JNSGsNFhQhTtDTcwIosxTnFtsPcR3kt GsnQ== X-Forwarded-Encrypted: i=1; AJvYcCUNa5BfHCooanyLcOpqQDTGy3Ns06GdNWWQPuTmndvYVPQESC+BGXCSUv2uVIDPRqQX3+WakS6LmmE=@vger.kernel.org, AJvYcCWo/Bku/BwoU4RfG+hoV9v9Fv4JHMaPQcuXBWHctfci6GU/KM+8AdkT3Er5qoC3I3922/l4GsLq9DdXyc94@vger.kernel.org X-Gm-Message-State: AOJu0YwTsAwCpm8GkRtqnnWyVe++bxwuydzsDvJnZLIsuQdTqObs/EWr dzpMXfDCcuY1ciOomGi+36TYJyVvsaP2WazjtXd0FJYwXW2vIgg= X-Google-Smtp-Source: AGHT+IGG8X0DXHUFSFQGLI9Izd2j/MNhoYs9RHnKyE5Q3GWJUcqI+sbWLul0dVdBJ9mmrPY4THzgpw== X-Received: by 2002:a05:6a20:4f9a:b0:1cc:e4be:5fae with SMTP id adf61e73a8af0-1cce4be5fd5mr3165746637.7.1724989741837; Thu, 29 Aug 2024 20:49:01 -0700 (PDT) Received: from localhost (2001-b400-e338-dab5-746d-1a82-f21e-bb0a.emome-ip6.hinet.net. [2001:b400:e338:dab5:746d:1a82:f21e:bb0a]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-715e55b9cf0sm1907320b3a.96.2024.08.29.20.49.00 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 29 Aug 2024 20:49:01 -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 Subject: [PATCH v2 3/7] i2c: npcm: use a software flag to indicate a BER condition Date: Fri, 30 Aug 2024 11:46:36 +0800 Message-Id: <20240830034640.7049-4-kfting@nuvoton.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240830034640.7049-1-kfting@nuvoton.com> References: <20240830034640.7049-1-kfting@nuvoton.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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. Fixes: 48acf8292280 ("i2c: Remove redundant comparison in npcm_i2c_reg_slave") Signed-off-by: Tyrone Ting --- 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 Aug 30 03:46:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyrone Ting X-Patchwork-Id: 824247 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (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 978E814EC61; Fri, 30 Aug 2024 03:49:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724989750; cv=none; b=DfLYJuWBmrdeqg4Zrj6O3gIBytmAO06saEGZlyrJU1vmxcZ86qqly7Djgkb//chR4yd+YnIT+cdgiehpkHwL44uewVPu2u07W+WnRaCuh44zCYKKN7tZzz3uSpuqBMrNfe/HNXioxuPVJtCVjWCX5HiD1NflJWRrPVSj7J/54G4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724989750; c=relaxed/simple; bh=Y8tsQW95Kg/xpWjQGyQgQXGOZf2c0b712HbMcZ6a4Ok=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=BaMfH7KQcSALCtl0r0UIdzMHPN579zdRUJfyM3mmc93u/cXaE2kb18DquUISMiaWJDQMhUBMm44HiO/4bvtkil7j2JG0mX7yM234FdyKOazd4bX7WdJtvvkjxGx2kd5NZWQzBgws7ZhNhNqyjv7Qa1DBHNh59hXspZvztMlW1cg= 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=khQ8vmoI; arc=none smtp.client-ip=209.85.214.170 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="khQ8vmoI" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-2020ac89cabso14997345ad.1; Thu, 29 Aug 2024 20:49:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724989748; x=1725594548; 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=XqFq8EWoNEfLfpi6AmZzlGu/jzM8vHDtRNwp/7NnlVU=; b=khQ8vmoIq3jhb0lx1jc0446uD8Pl8eRcie7adSXNMPgsXgcsTEeVPoPKlZHBNWSDN8 sWWSVoh4H4RiI039tsBpN3yAtsil9dXWjbGkC4xx3TXnj7HMJMkfVJjnugOOMShI6Vmg oY7PKia2U7pUXvmM5bQcDTt5d9Rq8/HvbmZ9laowdXcRcQkKu+5WgIwdHqrz5JVxBtUu iSnM/vKTAjWizchcaeuac08YHlNi6IU0utP/oPURUfvzP8CAsIJCJ7LwFljNPzkutQfv eiXXuCRH/CGy7/WFUiUd0HWrpXUBcN1rrX/OpXbYbMJ5QCb7prkFWAt+kklFCuQrao5g FIcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724989748; x=1725594548; 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=XqFq8EWoNEfLfpi6AmZzlGu/jzM8vHDtRNwp/7NnlVU=; b=maQ1w5mWE2Eluqjs4AFw/0tzsF74U3EQaGB9kmy35PgeBf4keHdTtCGOp5GSh216hs X7XIy4LLP71ZkCrc4xelygM+ZWjuCIvF8F7HGI/9dhQ5gRS0c2Or+j0rLaKmijpNUbXF N+uKIlxICZVXMHMjGVBQ2g0KlKCF8k5c2PTwboAsbJHtK984VgaLPIwoygPufdzOfPh8 hwIe5hKSZgcvy5w5y6uuQD/bMwfhUPzBTK3ce5sybaxSX8HELk+y24U+hORFEvlIDsTn nCRzd8jZhbZwpUFMvoQ5Kh/6EXeao7pB4fOvvJWj+VTMLzmjIgtglmm3OtlZKQffA/Mk JD7g== X-Forwarded-Encrypted: i=1; AJvYcCXG6dQZgpAty3hO9UMYSFKu1C3N7qssmsBSAXnfIJfH3J8zBrLuBEQEwlD0z48EHIk08PnekdeqKZmqVvaV@vger.kernel.org, AJvYcCXXRPhR+hff/Z28ImPZYcs4bUB2vn/Q6O8C8NGcBWHxyTynUI2p+EojwnCRm1IFUmurPI7hojo7oeA=@vger.kernel.org X-Gm-Message-State: AOJu0YyLNPl4K8giNNoN0xbYXVJDLb/280EKqVaaviwkDaJPhyKNyTtj fGAysXMgG6QRv72rHlsGiDZoxsGZzy8flgfP+8ulz93pRQlhQ4c= X-Google-Smtp-Source: AGHT+IHizkeEALsJJzSovFZ2tihJcLdkSMPu2gI6fgOxc/IwZpNGYjr2kbuSimtekmZnUMXCtYDQ6g== X-Received: by 2002:a17:902:da8c:b0:1fb:8cab:ccc9 with SMTP id d9443c01a7336-2050c423fabmr63064475ad.45.1724989747578; Thu, 29 Aug 2024 20:49:07 -0700 (PDT) Received: from localhost (2001-b400-e338-dab5-746d-1a82-f21e-bb0a.emome-ip6.hinet.net. [2001:b400:e338:dab5:746d:1a82:f21e:bb0a]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20515545329sm18341245ad.215.2024.08.29.20.49.06 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 29 Aug 2024 20:49:07 -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 Subject: [PATCH v2 5/7] i2c: npcm: Modify the client address assignment Date: Fri, 30 Aug 2024 11:46:38 +0800 Message-Id: <20240830034640.7049-6-kfting@nuvoton.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240830034640.7049-1-kfting@nuvoton.com> References: <20240830034640.7049-1-kfting@nuvoton.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Store the client address earlier since it's used in the i2c_recover_bus logic flow. Fixes: 48acf8292280 ("i2c: Remove redundant comparison in npcm_i2c_reg_slave") Signed-off-by: Tyrone Ting --- drivers/i2c/busses/i2c-npcm7xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c index 68f3d47323ab..67d156ed29b9 100644 --- a/drivers/i2c/busses/i2c-npcm7xx.c +++ b/drivers/i2c/busses/i2c-npcm7xx.c @@ -2155,6 +2155,7 @@ static int npcm_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, } while (time_is_after_jiffies(time_left) && bus_busy); + 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 +2164,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 Aug 30 03:46:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyrone Ting X-Patchwork-Id: 824246 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 CE7351531C3; Fri, 30 Aug 2024 03:49:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724989756; cv=none; b=gjuyPlU1fNpsqoqgLIEXbuI2cOj+2lo35wWsl3mGS72apC6kZFjWE4Pbe0Y7V9/Kib5XiclChNKStGkmFOCmX21f1KzfyCKxfUcxOs7p1uhBd4yUl8Ho5vHQG7gHrjHZiG1D8VTCwR20tsllIoM2cH328zWD20HErSlNzAQ+WYc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724989756; c=relaxed/simple; bh=GyGJDuotmpT+T6oQysyKHcd2ws3AuvjX3ZNsznw/iEA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=FqpZTZyfnvwqhMrFwm3Fu0VsdjCkywwmIClqHCu0BS/BX2CKG8eaEl5gwtc7I8yTCZfv7vKLuFHLRPgJ/v7Ioxm1qiA5CZabTT1VaC/lfqBuDQATMkKtr2r8Ps9YIxmpdPGN88Ny+LlMSBcW/6zXHbVa/+X6jjqjkOi28lNPM+s= 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=P2adroIa; arc=none smtp.client-ip=209.85.214.172 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="P2adroIa" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-201f2b7fe0dso11574505ad.1; Thu, 29 Aug 2024 20:49:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724989754; x=1725594554; 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=R1w8U38LxbqsHMWFXxaIYW4AXwoQS5Rj9y5ARnmh8Yw=; b=P2adroIa6Wlj7GO38zejHgGu9nqgvPj54fWE5uhyCE8YRkH+Yij3VJTxRuk1vFZFqL +XoYwvkLf8w4JeLHVSIZJ07WsJ0I+GiR47/S3CXvq6cP8bYSbeLHMweELV5wTVNx9oOd ywgDwUrqxaUDobuvI+L9wmllmHgfTeczRBmHTrgRawI7hkfkwzdI4yqYyQbZPGWouL4k vUZZN7w3O2FvDcDTjq9lgWwWxOWrYxh/v8kaJ1Pj/3dpKF5tK/2uMqZrNZouP5nMgARr Wsz4+HOu76kLgQakniSYheSD3u12DVDKEAHtLXrheg5lzuWtTlbBLIArPi2qgScUbnrO rxvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724989754; x=1725594554; 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=R1w8U38LxbqsHMWFXxaIYW4AXwoQS5Rj9y5ARnmh8Yw=; b=K1tZR/yanZYF/q4ORBler49ayO0Y/gB6bvceTlsJ/cRw/6J6Fu5TWlYZPZvJgQ0jsZ nIKc6R2f1EOKNRjLhReegBZf1O1OTQjrwp3OKgRVPWgN03sVwoeAdR+tGOPDyjSfGJz7 fhpL216DpRhkdXf52iAaoPLJbYhljLrKQK4I91z93cqTnOorWiQCE1ni1nkhP5lu5jpq t8Pu409VyKDU3GCmUNWKYpGJIcyC80rEPXPYL7jZD/FHvnW/NDZrpskXQ1qrk9F5e0ox FSgXJjB8oTZV+H1nNPKoyZRJKnnfik1lCrUXalmTWIQ6y+1qTKBuRSnOfDekfsS18wWM 9C2w== X-Forwarded-Encrypted: i=1; AJvYcCWdcPHbfYjM/SIUaPfEiLGwNSPltd2WDxI6Qt8U/vYQ4GNH2p4jO9qzYsyi2EE6xjPrFTMa8hgrdRQ=@vger.kernel.org, AJvYcCXstXQ65bc1kTZ0hPqHoD7B0t9TbCC/F65dUafMCiFQtGcGFuddm8P37ugkS1CokXrQpxsBGla3ZDrdOV4T@vger.kernel.org X-Gm-Message-State: AOJu0YxCvQ+i71CsgC370yizP7EQB79ziTIUkSN53GCz2SiCmavkTxIX L9dPngCOTbyS8MzSbGgWePgIhcADXJI2b3mghsfWjRr79uzEOhw= X-Google-Smtp-Source: AGHT+IGrJD1LOrRYZRsGSK8KrWyqBhIIUuxqyDXZM8UZXfrS+XZ4T7TqZJ1nRpyYmsA8M78lXul8eg== X-Received: by 2002:a17:903:234c:b0:1fb:8419:8384 with SMTP id d9443c01a7336-2050c37255emr62935835ad.13.1724989754013; Thu, 29 Aug 2024 20:49:14 -0700 (PDT) Received: from localhost (2001-b400-e338-dab5-746d-1a82-f21e-bb0a.emome-ip6.hinet.net. [2001:b400:e338:dab5:746d:1a82:f21e:bb0a]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-205155452ecsm18259455ad.219.2024.08.29.20.49.13 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 29 Aug 2024 20:49:13 -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 v2 7/7] i2c: npcm: Enable slave in eob interrupt Date: Fri, 30 Aug 2024 11:46:40 +0800 Message-Id: <20240830034640.7049-8-kfting@nuvoton.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240830034640.7049-1-kfting@nuvoton.com> References: <20240830034640.7049-1-kfting@nuvoton.com> 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 cac4ea0b69b8..5bdc1b5895ac 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; }