All of lore.kernel.org
 help / color / mirror / Atom feed
* dmaengine: mv_xor: Use correct device for DMA API
@ 2019-02-18 18:27 ` Robin Murphy
  0 siblings, 0 replies; 6+ messages in thread
From: Robin Murphy @ 2019-02-18 18:27 UTC (permalink / raw)
  To: vkoul; +Cc: dmaengine, linux-arm-kernel, hch, John David Anglin

Using dma_dev->dev for mappings before it's assigned with the correct
device is unlikely to work as expected, and with future dma-direct
changes, passing a NULL device may end up crashing entirely. I don't
know enough about this hardware or the mv_xor_prep_dma_interrupt()
operation to implement the appropriate error-handling logic that would
have revealed those dma_map_single() calls failing on arm64 for as long
as the driver has been enabled there, but moving the assignment earlier
will at least make the current code operate as intended.

Fixes: 22843545b200 ("dma: mv_xor: Add support for DMA_INTERRUPT")
Reported-by: John David Anglin <dave.anglin@bell.net>
Tested-by: John David Anglin <dave.anglin@bell.net>
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
---
 drivers/dma/mv_xor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c
index 7f595355fb79..fe4a7c71fede 100644
--- a/drivers/dma/mv_xor.c
+++ b/drivers/dma/mv_xor.c
@@ -1059,6 +1059,7 @@ mv_xor_channel_add(struct mv_xor_device *xordev,
 		mv_chan->op_in_desc = XOR_MODE_IN_DESC;
 
 	dma_dev = &mv_chan->dmadev;
+	dma_dev->dev = &pdev->dev;
 	mv_chan->xordev = xordev;
 
 	/*
@@ -1091,7 +1092,6 @@ mv_xor_channel_add(struct mv_xor_device *xordev,
 	dma_dev->device_free_chan_resources = mv_xor_free_chan_resources;
 	dma_dev->device_tx_status = mv_xor_status;
 	dma_dev->device_issue_pending = mv_xor_issue_pending;
-	dma_dev->dev = &pdev->dev;
 
 	/* set prep routines based on capability */
 	if (dma_has_cap(DMA_INTERRUPT, dma_dev->cap_mask))

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

* [PATCH] dmaengine: mv_xor: Use correct device for DMA API
@ 2019-02-18 18:27 ` Robin Murphy
  0 siblings, 0 replies; 6+ messages in thread
From: Robin Murphy @ 2019-02-18 18:27 UTC (permalink / raw)
  To: vkoul; +Cc: dmaengine, John David Anglin, hch, linux-arm-kernel

Using dma_dev->dev for mappings before it's assigned with the correct
device is unlikely to work as expected, and with future dma-direct
changes, passing a NULL device may end up crashing entirely. I don't
know enough about this hardware or the mv_xor_prep_dma_interrupt()
operation to implement the appropriate error-handling logic that would
have revealed those dma_map_single() calls failing on arm64 for as long
as the driver has been enabled there, but moving the assignment earlier
will at least make the current code operate as intended.

Fixes: 22843545b200 ("dma: mv_xor: Add support for DMA_INTERRUPT")
Reported-by: John David Anglin <dave.anglin@bell.net>
Tested-by: John David Anglin <dave.anglin@bell.net>
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
---
 drivers/dma/mv_xor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c
index 7f595355fb79..fe4a7c71fede 100644
--- a/drivers/dma/mv_xor.c
+++ b/drivers/dma/mv_xor.c
@@ -1059,6 +1059,7 @@ mv_xor_channel_add(struct mv_xor_device *xordev,
 		mv_chan->op_in_desc = XOR_MODE_IN_DESC;
 
 	dma_dev = &mv_chan->dmadev;
+	dma_dev->dev = &pdev->dev;
 	mv_chan->xordev = xordev;
 
 	/*
@@ -1091,7 +1092,6 @@ mv_xor_channel_add(struct mv_xor_device *xordev,
 	dma_dev->device_free_chan_resources = mv_xor_free_chan_resources;
 	dma_dev->device_tx_status = mv_xor_status;
 	dma_dev->device_issue_pending = mv_xor_issue_pending;
-	dma_dev->dev = &pdev->dev;
 
 	/* set prep routines based on capability */
 	if (dma_has_cap(DMA_INTERRUPT, dma_dev->cap_mask))
-- 
2.20.1.dirty


_______________________________________________
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] 6+ messages in thread

* dmaengine: mv_xor: Use correct device for DMA API
  2019-02-18 18:27 ` [PATCH] " Robin Murphy
@ 2019-02-19 11:02 ` Thomas Petazzoni
  -1 siblings, 0 replies; 6+ messages in thread
From: Thomas Petazzoni @ 2019-02-19 11:02 UTC (permalink / raw)
  To: Robin Murphy; +Cc: vkoul, dmaengine, John David Anglin, hch, linux-arm-kernel

Hello Robin,

Thanks a lot for fixing this!

On Mon, 18 Feb 2019 18:27:06 +0000
Robin Murphy <robin.murphy@arm.com> wrote:

> Using dma_dev->dev for mappings before it's assigned with the correct
> device is unlikely to work as expected, and with future dma-direct
> changes, passing a NULL device may end up crashing entirely. I don't
> know enough about this hardware or the mv_xor_prep_dma_interrupt()
> operation to implement the appropriate error-handling logic that would
> have revealed those dma_map_single() calls failing on arm64 for as long
> as the driver has been enabled there, but moving the assignment earlier
> will at least make the current code operate as intended.
> 
> Fixes: 22843545b200 ("dma: mv_xor: Add support for DMA_INTERRUPT")
> Reported-by: John David Anglin <dave.anglin@bell.net>
> Tested-by: John David Anglin <dave.anglin@bell.net>
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>

Acked-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>

Best regards,

Thomas

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

* Re: [PATCH] dmaengine: mv_xor: Use correct device for DMA API
@ 2019-02-19 11:02 ` Thomas Petazzoni
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Petazzoni @ 2019-02-19 11:02 UTC (permalink / raw)
  To: Robin Murphy; +Cc: dmaengine, vkoul, John David Anglin, hch, linux-arm-kernel

Hello Robin,

Thanks a lot for fixing this!

On Mon, 18 Feb 2019 18:27:06 +0000
Robin Murphy <robin.murphy@arm.com> wrote:

> Using dma_dev->dev for mappings before it's assigned with the correct
> device is unlikely to work as expected, and with future dma-direct
> changes, passing a NULL device may end up crashing entirely. I don't
> know enough about this hardware or the mv_xor_prep_dma_interrupt()
> operation to implement the appropriate error-handling logic that would
> have revealed those dma_map_single() calls failing on arm64 for as long
> as the driver has been enabled there, but moving the assignment earlier
> will at least make the current code operate as intended.
> 
> Fixes: 22843545b200 ("dma: mv_xor: Add support for DMA_INTERRUPT")
> Reported-by: John David Anglin <dave.anglin@bell.net>
> Tested-by: John David Anglin <dave.anglin@bell.net>
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>

Acked-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

_______________________________________________
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] 6+ messages in thread

* dmaengine: mv_xor: Use correct device for DMA API
  2019-02-18 18:27 ` [PATCH] " Robin Murphy
@ 2019-02-19 12:10 ` Vinod Koul
  -1 siblings, 0 replies; 6+ messages in thread
From: Vinod Koul @ 2019-02-19 12:10 UTC (permalink / raw)
  To: Robin Murphy; +Cc: dmaengine, linux-arm-kernel, hch, John David Anglin

On 18-02-19, 18:27, Robin Murphy wrote:
> Using dma_dev->dev for mappings before it's assigned with the correct
> device is unlikely to work as expected, and with future dma-direct
> changes, passing a NULL device may end up crashing entirely. I don't
> know enough about this hardware or the mv_xor_prep_dma_interrupt()
> operation to implement the appropriate error-handling logic that would
> have revealed those dma_map_single() calls failing on arm64 for as long
> as the driver has been enabled there, but moving the assignment earlier
> will at least make the current code operate as intended.

Applied, thanks

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

* Re: [PATCH] dmaengine: mv_xor: Use correct device for DMA API
@ 2019-02-19 12:10 ` Vinod Koul
  0 siblings, 0 replies; 6+ messages in thread
From: Vinod Koul @ 2019-02-19 12:10 UTC (permalink / raw)
  To: Robin Murphy; +Cc: dmaengine, John David Anglin, hch, linux-arm-kernel

On 18-02-19, 18:27, Robin Murphy wrote:
> Using dma_dev->dev for mappings before it's assigned with the correct
> device is unlikely to work as expected, and with future dma-direct
> changes, passing a NULL device may end up crashing entirely. I don't
> know enough about this hardware or the mv_xor_prep_dma_interrupt()
> operation to implement the appropriate error-handling logic that would
> have revealed those dma_map_single() calls failing on arm64 for as long
> as the driver has been enabled there, but moving the assignment earlier
> will at least make the current code operate as intended.

Applied, thanks

-- 
~Vinod

_______________________________________________
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] 6+ messages in thread

end of thread, other threads:[~2019-02-19 12:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-18 18:27 dmaengine: mv_xor: Use correct device for DMA API Robin Murphy
2019-02-18 18:27 ` [PATCH] " Robin Murphy
2019-02-19 11:02 Thomas Petazzoni
2019-02-19 11:02 ` [PATCH] " Thomas Petazzoni
2019-02-19 12:10 Vinod Koul
2019-02-19 12:10 ` [PATCH] " Vinod Koul

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.