linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 0/2] i2c: imx: rework imx error handling.
@ 2019-01-09  5:56 Oleksij Rempel
  2019-01-09  5:56 ` [PATCH v5 1/2] i2c: imx: notify about real errors on dma i2c_imx_dma_request Oleksij Rempel
  2019-01-09  5:56 ` [PATCH v5 2/2] i2c: imx: improve the error handling in i2c_imx_dma_request() Oleksij Rempel
  0 siblings, 2 replies; 5+ messages in thread
From: Oleksij Rempel @ 2019-01-09  5:56 UTC (permalink / raw)
  To: Wolfram Sang, Shawn Guo, Sascha Hauer
  Cc: Oleksij Rempel, linux-i2c, Pengutronix Kernel Team,
	Fabio Estevam, linux-arm-kernel, NXP Linux Team

changes:
20190109 v5:
 - reword comments.
 - realign

20190107 v4:
 - split one patch to separate patches
 - revert back devm_free(), we need it for -ENODEV case.
 - reword comments.

20181130 v3:
 - reword commit message 
20181112 v2:
 - drop "[PATCH v1 2/3] i2c: imx: probe dma only only on i.MX50 and
   later" and rebase without this patch.
 - Set proper initial author

Oleksij Rempel (2):
  i2c: imx: notify about real errors on dma i2c_imx_dma_request
  i2c: imx: improve the error handling in i2c_imx_dma_request()

 drivers/i2c/busses/i2c-imx.c | 37 +++++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 15 deletions(-)

-- 
2.19.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v5 1/2] i2c: imx: notify about real errors on dma i2c_imx_dma_request
  2019-01-09  5:56 [PATCH v5 0/2] i2c: imx: rework imx error handling Oleksij Rempel
@ 2019-01-09  5:56 ` Oleksij Rempel
  2019-01-15 21:54   ` Wolfram Sang
  2019-01-09  5:56 ` [PATCH v5 2/2] i2c: imx: improve the error handling in i2c_imx_dma_request() Oleksij Rempel
  1 sibling, 1 reply; 5+ messages in thread
From: Oleksij Rempel @ 2019-01-09  5:56 UTC (permalink / raw)
  To: Wolfram Sang, Shawn Guo, Sascha Hauer
  Cc: Oleksij Rempel, linux-i2c, Pengutronix Kernel Team,
	Fabio Estevam, linux-arm-kernel, NXP Linux Team

At least on i.MX5x, the DMA events for I2C and SDHC use the same channel
and there can only be a single user. So in this case there should be no
message emitted that looks like an error if the I2C device doesn't have
an assigned DMA channel. In contrast real problems that were only
emitted at debug level before should be described at a higher level
to be better visible and so understandable.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/i2c/busses/i2c-imx.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index fa9ad53845d9..e28ef494dac8 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -285,9 +285,11 @@ static void i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx,
 	if (!dma)
 		return;
 
-	dma->chan_tx = dma_request_slave_channel(dev, "tx");
-	if (!dma->chan_tx) {
-		dev_dbg(dev, "can't request DMA tx channel\n");
+	dma->chan_tx = dma_request_chan(dev, "tx");
+	if (IS_ERR(dma->chan_tx)) {
+		ret = PTR_ERR(dma->chan_rx);
+		if (ret != -ENODEV && ret != -EPROBE_DEFER)
+			dev_err(dev, "can't request DMA tx channel (%d)\n", ret);
 		goto fail_al;
 	}
 
@@ -298,13 +300,15 @@ static void i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx,
 	dma_sconfig.direction = DMA_MEM_TO_DEV;
 	ret = dmaengine_slave_config(dma->chan_tx, &dma_sconfig);
 	if (ret < 0) {
-		dev_dbg(dev, "can't configure tx channel\n");
+		dev_err(dev, "can't configure tx channel (%d)\n", ret);
 		goto fail_tx;
 	}
 
-	dma->chan_rx = dma_request_slave_channel(dev, "rx");
-	if (!dma->chan_rx) {
-		dev_dbg(dev, "can't request DMA rx channel\n");
+	dma->chan_rx = dma_request_chan(dev, "rx");
+	if (IS_ERR(dma->chan_rx)) {
+		ret = PTR_ERR(dma->chan_rx);
+		if (ret != -ENODEV && ret != -EPROBE_DEFER)
+			dev_err(dev, "can't request DMA rx channel (%d)\n", ret);
 		goto fail_tx;
 	}
 
@@ -315,7 +319,7 @@ static void i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx,
 	dma_sconfig.direction = DMA_DEV_TO_MEM;
 	ret = dmaengine_slave_config(dma->chan_rx, &dma_sconfig);
 	if (ret < 0) {
-		dev_dbg(dev, "can't configure rx channel\n");
+		dev_err(dev, "can't configure rx channel (%d)\n", ret);
 		goto fail_rx;
 	}
 
@@ -332,7 +336,6 @@ static void i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx,
 	dma_release_channel(dma->chan_tx);
 fail_al:
 	devm_kfree(dev, dma);
-	dev_info(dev, "can't use DMA, using PIO instead.\n");
 }
 
 static void i2c_imx_dma_callback(void *arg)
-- 
2.19.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v5 2/2] i2c: imx: improve the error handling in i2c_imx_dma_request()
  2019-01-09  5:56 [PATCH v5 0/2] i2c: imx: rework imx error handling Oleksij Rempel
  2019-01-09  5:56 ` [PATCH v5 1/2] i2c: imx: notify about real errors on dma i2c_imx_dma_request Oleksij Rempel
@ 2019-01-09  5:56 ` Oleksij Rempel
  2019-01-15 21:54   ` Wolfram Sang
  1 sibling, 1 reply; 5+ messages in thread
From: Oleksij Rempel @ 2019-01-09  5:56 UTC (permalink / raw)
  To: Wolfram Sang, Shawn Guo, Sascha Hauer
  Cc: Oleksij Rempel, linux-i2c, Pengutronix Kernel Team,
	Fabio Estevam, linux-arm-kernel, NXP Linux Team

Improve the error handling in i2c_imx_dma_request() and let it return an error
indication that the caller then can handle accordingly.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/i2c/busses/i2c-imx.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index e28ef494dac8..09b124547669 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -273,8 +273,8 @@ static inline unsigned char imx_i2c_read_reg(struct imx_i2c_struct *i2c_imx,
 }
 
 /* Functions for DMA support */
-static void i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx,
-						dma_addr_t phy_addr)
+static int i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx,
+			       dma_addr_t phy_addr)
 {
 	struct imx_i2c_dma *dma;
 	struct dma_slave_config dma_sconfig;
@@ -283,7 +283,7 @@ static void i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx,
 
 	dma = devm_kzalloc(dev, sizeof(*dma), GFP_KERNEL);
 	if (!dma)
-		return;
+		return -ENOMEM;
 
 	dma->chan_tx = dma_request_chan(dev, "tx");
 	if (IS_ERR(dma->chan_tx)) {
@@ -328,7 +328,7 @@ static void i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx,
 	dev_info(dev, "using %s (tx) and %s (rx) for DMA transfers\n",
 		dma_chan_name(dma->chan_tx), dma_chan_name(dma->chan_rx));
 
-	return;
+	return 0;
 
 fail_rx:
 	dma_release_channel(dma->chan_rx);
@@ -336,6 +336,8 @@ static void i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx,
 	dma_release_channel(dma->chan_tx);
 fail_al:
 	devm_kfree(dev, dma);
+	/* return successfully if there is no dma support */
+	return ret == -ENODEV ? 0 : ret;
 }
 
 static void i2c_imx_dma_callback(void *arg)
@@ -1163,11 +1165,13 @@ static int i2c_imx_probe(struct platform_device *pdev)
 	dev_dbg(&i2c_imx->adapter.dev, "device resources: %pR\n", res);
 	dev_dbg(&i2c_imx->adapter.dev, "adapter name: \"%s\"\n",
 		i2c_imx->adapter.name);
-	dev_info(&i2c_imx->adapter.dev, "IMX I2C adapter registered\n");
 
 	/* Init DMA config if supported */
-	i2c_imx_dma_request(i2c_imx, phy_addr);
+	ret = i2c_imx_dma_request(i2c_imx, phy_addr);
+	if (ret < 0)
+		goto clk_notifier_unregister;
 
+	dev_info(&i2c_imx->adapter.dev, "IMX I2C adapter registered\n");
 	return 0;   /* Return OK */
 
 clk_notifier_unregister:
-- 
2.19.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v5 1/2] i2c: imx: notify about real errors on dma i2c_imx_dma_request
  2019-01-09  5:56 ` [PATCH v5 1/2] i2c: imx: notify about real errors on dma i2c_imx_dma_request Oleksij Rempel
@ 2019-01-15 21:54   ` Wolfram Sang
  0 siblings, 0 replies; 5+ messages in thread
From: Wolfram Sang @ 2019-01-15 21:54 UTC (permalink / raw)
  To: Oleksij Rempel
  Cc: Sascha Hauer, linux-i2c, Pengutronix Kernel Team, Fabio Estevam,
	Shawn Guo, linux-arm-kernel, NXP Linux Team


[-- Attachment #1.1: Type: text/plain, Size: 639 bytes --]

On Wed, Jan 09, 2019 at 06:56:49AM +0100, Oleksij Rempel wrote:
> At least on i.MX5x, the DMA events for I2C and SDHC use the same channel
> and there can only be a single user. So in this case there should be no
> message emitted that looks like an error if the I2C device doesn't have
> an assigned DMA channel. In contrast real problems that were only
> emitted at debug level before should be described at a higher level
> to be better visible and so understandable.
> 
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Applied to for-next, thanks!


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

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v5 2/2] i2c: imx: improve the error handling in i2c_imx_dma_request()
  2019-01-09  5:56 ` [PATCH v5 2/2] i2c: imx: improve the error handling in i2c_imx_dma_request() Oleksij Rempel
@ 2019-01-15 21:54   ` Wolfram Sang
  0 siblings, 0 replies; 5+ messages in thread
From: Wolfram Sang @ 2019-01-15 21:54 UTC (permalink / raw)
  To: Oleksij Rempel
  Cc: Sascha Hauer, linux-i2c, Pengutronix Kernel Team, Fabio Estevam,
	Shawn Guo, linux-arm-kernel, NXP Linux Team


[-- Attachment #1.1: Type: text/plain, Size: 367 bytes --]

On Wed, Jan 09, 2019 at 06:56:50AM +0100, Oleksij Rempel wrote:
> Improve the error handling in i2c_imx_dma_request() and let it return an error
> indication that the caller then can handle accordingly.
> 
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Applied to for-next, thanks!


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

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2019-01-15 21:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-09  5:56 [PATCH v5 0/2] i2c: imx: rework imx error handling Oleksij Rempel
2019-01-09  5:56 ` [PATCH v5 1/2] i2c: imx: notify about real errors on dma i2c_imx_dma_request Oleksij Rempel
2019-01-15 21:54   ` Wolfram Sang
2019-01-09  5:56 ` [PATCH v5 2/2] i2c: imx: improve the error handling in i2c_imx_dma_request() Oleksij Rempel
2019-01-15 21:54   ` Wolfram Sang

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).