linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 5.6 28/38] i2c: remove i2c_new_probed_device API
       [not found] <20200424122237.9831-1-sashal@kernel.org>
@ 2020-04-24 12:22 ` Sasha Levin
  2020-04-24 13:36   ` Wolfram Sang
  2020-04-24 12:22 ` [PATCH AUTOSEL 5.6 30/38] i2c: tegra: Better handle case where CPU0 is busy for a long time Sasha Levin
  2020-04-24 12:22 ` [PATCH AUTOSEL 5.6 31/38] i2c: tegra: Synchronize DMA before termination Sasha Levin
  2 siblings, 1 reply; 7+ messages in thread
From: Sasha Levin @ 2020-04-24 12:22 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Wolfram Sang, Wolfram Sang, Sasha Levin, linux-i2c

From: Wolfram Sang <wsa+renesas@sang-engineering.com>

[ Upstream commit 3c1d1613be80c2e17f1ddf672df1d8a8caebfd0d ]

All in-tree users have been converted to the new i2c_new_scanned_device
function, so remove this deprecated one.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/i2c/i2c-core-base.c | 13 -------------
 include/linux/i2c.h         |  6 ------
 2 files changed, 19 deletions(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index cefad08819420..4bfb15ac71f1c 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -2269,19 +2269,6 @@ i2c_new_scanned_device(struct i2c_adapter *adap,
 }
 EXPORT_SYMBOL_GPL(i2c_new_scanned_device);
 
-struct i2c_client *
-i2c_new_probed_device(struct i2c_adapter *adap,
-		      struct i2c_board_info *info,
-		      unsigned short const *addr_list,
-		      int (*probe)(struct i2c_adapter *adap, unsigned short addr))
-{
-	struct i2c_client *client;
-
-	client = i2c_new_scanned_device(adap, info, addr_list, probe);
-	return IS_ERR(client) ? NULL : client;
-}
-EXPORT_SYMBOL_GPL(i2c_new_probed_device);
-
 struct i2c_adapter *i2c_get_adapter(int nr)
 {
 	struct i2c_adapter *adapter;
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index f6b942150631b..a32f3297d4226 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -453,12 +453,6 @@ i2c_new_scanned_device(struct i2c_adapter *adap,
 		       unsigned short const *addr_list,
 		       int (*probe)(struct i2c_adapter *adap, unsigned short addr));
 
-struct i2c_client *
-i2c_new_probed_device(struct i2c_adapter *adap,
-		       struct i2c_board_info *info,
-		       unsigned short const *addr_list,
-		       int (*probe)(struct i2c_adapter *adap, unsigned short addr));
-
 /* Common custom probe functions */
 int i2c_probe_func_quick_read(struct i2c_adapter *adap, unsigned short addr);
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH AUTOSEL 5.6 30/38] i2c: tegra: Better handle case where CPU0 is busy for a long time
       [not found] <20200424122237.9831-1-sashal@kernel.org>
  2020-04-24 12:22 ` [PATCH AUTOSEL 5.6 28/38] i2c: remove i2c_new_probed_device API Sasha Levin
@ 2020-04-24 12:22 ` Sasha Levin
  2020-04-27  7:22   ` Thierry Reding
  2020-04-24 12:22 ` [PATCH AUTOSEL 5.6 31/38] i2c: tegra: Synchronize DMA before termination Sasha Levin
  2 siblings, 1 reply; 7+ messages in thread
From: Sasha Levin @ 2020-04-24 12:22 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Dmitry Osipenko, Wolfram Sang, Sasha Levin, linux-i2c, linux-tegra

From: Dmitry Osipenko <digetx@gmail.com>

[ Upstream commit a900aeac253729411cf33c6cb598c152e9e4137f ]

Boot CPU0 always handle I2C interrupt and under some rare circumstances
(like running KASAN + NFS root) it may stuck in uninterruptible state for
a significant time. In this case we will get timeout if I2C transfer is
running on a sibling CPU, despite of IRQ being raised. In order to handle
this rare condition, the IRQ status needs to be checked after completion
timeout.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/i2c/busses/i2c-tegra.c | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index cbc2ad49043e4..0daa863fb26f2 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -1000,14 +1000,13 @@ tegra_i2c_poll_completion_timeout(struct tegra_i2c_dev *i2c_dev,
 	do {
 		u32 status = i2c_readl(i2c_dev, I2C_INT_STATUS);
 
-		if (status) {
+		if (status)
 			tegra_i2c_isr(i2c_dev->irq, i2c_dev);
 
-			if (completion_done(complete)) {
-				s64 delta = ktime_ms_delta(ktimeout, ktime);
+		if (completion_done(complete)) {
+			s64 delta = ktime_ms_delta(ktimeout, ktime);
 
-				return msecs_to_jiffies(delta) ?: 1;
-			}
+			return msecs_to_jiffies(delta) ?: 1;
 		}
 
 		ktime = ktime_get();
@@ -1034,14 +1033,18 @@ tegra_i2c_wait_completion_timeout(struct tegra_i2c_dev *i2c_dev,
 		disable_irq(i2c_dev->irq);
 
 		/*
-		 * There is a chance that completion may happen after IRQ
-		 * synchronization, which is done by disable_irq().
+		 * Under some rare circumstances (like running KASAN +
+		 * NFS root) CPU, which handles interrupt, may stuck in
+		 * uninterruptible state for a significant time.  In this
+		 * case we will get timeout if I2C transfer is running on
+		 * a sibling CPU, despite of IRQ being raised.
+		 *
+		 * In order to handle this rare condition, the IRQ status
+		 * needs to be checked after timeout.
 		 */
-		if (ret == 0 && completion_done(complete)) {
-			dev_warn(i2c_dev->dev,
-				 "completion done after timeout\n");
-			ret = 1;
-		}
+		if (ret == 0)
+			ret = tegra_i2c_poll_completion_timeout(i2c_dev,
+								complete, 0);
 	}
 
 	return ret;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH AUTOSEL 5.6 31/38] i2c: tegra: Synchronize DMA before termination
       [not found] <20200424122237.9831-1-sashal@kernel.org>
  2020-04-24 12:22 ` [PATCH AUTOSEL 5.6 28/38] i2c: remove i2c_new_probed_device API Sasha Levin
  2020-04-24 12:22 ` [PATCH AUTOSEL 5.6 30/38] i2c: tegra: Better handle case where CPU0 is busy for a long time Sasha Levin
@ 2020-04-24 12:22 ` Sasha Levin
  2 siblings, 0 replies; 7+ messages in thread
From: Sasha Levin @ 2020-04-24 12:22 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Dmitry Osipenko, Wolfram Sang, Sasha Levin, linux-i2c, linux-tegra

From: Dmitry Osipenko <digetx@gmail.com>

[ Upstream commit 8814044fe0fa182abc9ff818d3da562de98bc9a7 ]

DMA transfer could be completed, but CPU (which handles DMA interrupt)
may get too busy and can't handle the interrupt in a timely manner,
despite of DMA IRQ being raised. In this case the DMA state needs to
synchronized before terminating DMA transfer in order not to miss the
DMA transfer completion.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/i2c/busses/i2c-tegra.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index 0daa863fb26f2..0c6dac770fc3a 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -1223,6 +1223,15 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
 		time_left = tegra_i2c_wait_completion_timeout(
 				i2c_dev, &i2c_dev->dma_complete, xfer_time);
 
+		/*
+		 * Synchronize DMA first, since dmaengine_terminate_sync()
+		 * performs synchronization after the transfer's termination
+		 * and we want to get a completion if transfer succeeded.
+		 */
+		dmaengine_synchronize(i2c_dev->msg_read ?
+				      i2c_dev->rx_dma_chan :
+				      i2c_dev->tx_dma_chan);
+
 		dmaengine_terminate_sync(i2c_dev->msg_read ?
 					 i2c_dev->rx_dma_chan :
 					 i2c_dev->tx_dma_chan);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH AUTOSEL 5.6 28/38] i2c: remove i2c_new_probed_device API
  2020-04-24 12:22 ` [PATCH AUTOSEL 5.6 28/38] i2c: remove i2c_new_probed_device API Sasha Levin
@ 2020-04-24 13:36   ` Wolfram Sang
  2020-04-25  1:51     ` Sasha Levin
  0 siblings, 1 reply; 7+ messages in thread
From: Wolfram Sang @ 2020-04-24 13:36 UTC (permalink / raw)
  To: Sasha Levin; +Cc: linux-kernel, stable, Wolfram Sang, linux-i2c

[-- Attachment #1: Type: text/plain, Size: 591 bytes --]

On Fri, Apr 24, 2020 at 08:22:26AM -0400, Sasha Levin wrote:
> From: Wolfram Sang <wsa+renesas@sang-engineering.com>
> 
> [ Upstream commit 3c1d1613be80c2e17f1ddf672df1d8a8caebfd0d ]
> 
> All in-tree users have been converted to the new i2c_new_scanned_device
> function, so remove this deprecated one.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
> Signed-off-by: Sasha Levin <sashal@kernel.org>

This should not be backported. It is only since this merge window that
all in-tree users are converted!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH AUTOSEL 5.6 28/38] i2c: remove i2c_new_probed_device API
  2020-04-24 13:36   ` Wolfram Sang
@ 2020-04-25  1:51     ` Sasha Levin
  0 siblings, 0 replies; 7+ messages in thread
From: Sasha Levin @ 2020-04-25  1:51 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-kernel, stable, Wolfram Sang, linux-i2c

On Fri, Apr 24, 2020 at 03:36:35PM +0200, Wolfram Sang wrote:
>On Fri, Apr 24, 2020 at 08:22:26AM -0400, Sasha Levin wrote:
>> From: Wolfram Sang <wsa+renesas@sang-engineering.com>
>>
>> [ Upstream commit 3c1d1613be80c2e17f1ddf672df1d8a8caebfd0d ]
>>
>> All in-tree users have been converted to the new i2c_new_scanned_device
>> function, so remove this deprecated one.
>>
>> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
>> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
>> Signed-off-by: Sasha Levin <sashal@kernel.org>
>
>This should not be backported. It is only since this merge window that
>all in-tree users are converted!

Uh, I'm not sure how this snuck through. I've droped it, sorry!

-- 
Thanks,
Sasha

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH AUTOSEL 5.6 30/38] i2c: tegra: Better handle case where CPU0 is busy for a long time
  2020-04-24 12:22 ` [PATCH AUTOSEL 5.6 30/38] i2c: tegra: Better handle case where CPU0 is busy for a long time Sasha Levin
@ 2020-04-27  7:22   ` Thierry Reding
  2020-05-01  0:59     ` Sasha Levin
  0 siblings, 1 reply; 7+ messages in thread
From: Thierry Reding @ 2020-04-27  7:22 UTC (permalink / raw)
  To: Sasha Levin
  Cc: Jon Hunter, linux-kernel, stable, Dmitry Osipenko, Wolfram Sang,
	linux-i2c, linux-tegra

[-- Attachment #1: Type: text/plain, Size: 1259 bytes --]

On Fri, Apr 24, 2020 at 08:22:28AM -0400, Sasha Levin wrote:
> From: Dmitry Osipenko <digetx@gmail.com>
> 
> [ Upstream commit a900aeac253729411cf33c6cb598c152e9e4137f ]
> 
> Boot CPU0 always handle I2C interrupt and under some rare circumstances
> (like running KASAN + NFS root) it may stuck in uninterruptible state for
> a significant time. In this case we will get timeout if I2C transfer is
> running on a sibling CPU, despite of IRQ being raised. In order to handle
> this rare condition, the IRQ status needs to be checked after completion
> timeout.
> 
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
>  drivers/i2c/busses/i2c-tegra.c | 27 +++++++++++++++------------
>  1 file changed, 15 insertions(+), 12 deletions(-)

Hi Sasha,

can you drop this from the v5.6 stable queue please? Jon discovered that
this patch introduces a regression in v5.7, and since we don't have a
good understanding of why this is breaking things I think it'd be best
if we reverted it for v5.7 until we come up with a good fix.

I think the same applies for the other i2c/tegra patch that's 31/38 of
this series.

Thanks,
Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH AUTOSEL 5.6 30/38] i2c: tegra: Better handle case where CPU0 is busy for a long time
  2020-04-27  7:22   ` Thierry Reding
@ 2020-05-01  0:59     ` Sasha Levin
  0 siblings, 0 replies; 7+ messages in thread
From: Sasha Levin @ 2020-05-01  0:59 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Jon Hunter, linux-kernel, stable, Dmitry Osipenko, Wolfram Sang,
	linux-i2c, linux-tegra

On Mon, Apr 27, 2020 at 09:22:33AM +0200, Thierry Reding wrote:
>On Fri, Apr 24, 2020 at 08:22:28AM -0400, Sasha Levin wrote:
>> From: Dmitry Osipenko <digetx@gmail.com>
>>
>> [ Upstream commit a900aeac253729411cf33c6cb598c152e9e4137f ]
>>
>> Boot CPU0 always handle I2C interrupt and under some rare circumstances
>> (like running KASAN + NFS root) it may stuck in uninterruptible state for
>> a significant time. In this case we will get timeout if I2C transfer is
>> running on a sibling CPU, despite of IRQ being raised. In order to handle
>> this rare condition, the IRQ status needs to be checked after completion
>> timeout.
>>
>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
>> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
>> Signed-off-by: Sasha Levin <sashal@kernel.org>
>> ---
>>  drivers/i2c/busses/i2c-tegra.c | 27 +++++++++++++++------------
>>  1 file changed, 15 insertions(+), 12 deletions(-)
>
>Hi Sasha,
>
>can you drop this from the v5.6 stable queue please? Jon discovered that
>this patch introduces a regression in v5.7, and since we don't have a
>good understanding of why this is breaking things I think it'd be best
>if we reverted it for v5.7 until we come up with a good fix.
>
>I think the same applies for the other i2c/tegra patch that's 31/38 of
>this series.

I've dropped both of these, thanks!

-- 
Thanks,
Sasha

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-05-01  0:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20200424122237.9831-1-sashal@kernel.org>
2020-04-24 12:22 ` [PATCH AUTOSEL 5.6 28/38] i2c: remove i2c_new_probed_device API Sasha Levin
2020-04-24 13:36   ` Wolfram Sang
2020-04-25  1:51     ` Sasha Levin
2020-04-24 12:22 ` [PATCH AUTOSEL 5.6 30/38] i2c: tegra: Better handle case where CPU0 is busy for a long time Sasha Levin
2020-04-27  7:22   ` Thierry Reding
2020-05-01  0:59     ` Sasha Levin
2020-04-24 12:22 ` [PATCH AUTOSEL 5.6 31/38] i2c: tegra: Synchronize DMA before termination Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).