All of lore.kernel.org
 help / color / mirror / Atom feed
* dma: imx-sdma: pass ->dev to dma_alloc_coherent() API
@ 2019-01-11 14:29 ` Daniel Baluta
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Baluta @ 2019-01-11 14:29 UTC (permalink / raw)
  To: vkoul, dmaengine
  Cc: dl-linux-imx, kernel, dan.j.williams, linux-kernel, S.j. Wang,
	Andy Duan, Robin Gong, Daniel Baluta

From: Andy Duan <fugang.duan@nxp.com>

Pass ->dev to dma_alloc_coherent() API. We need this
becase dma_alloc_coherent() makes use of dev parameter
and receiving NULL will result in a crash.

Signed-off-by: Andy Duan <fugang.duan@nxp.com>
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
---
 drivers/dma/imx-sdma.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index a2b0a0e71168..26133b78ced8 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -677,7 +677,7 @@ static int sdma_load_script(struct sdma_engine *sdma, void *buf, int size,
 	int ret;
 	unsigned long flags;
 
-	buf_virt = dma_alloc_coherent(NULL, size, &buf_phys, GFP_KERNEL);
+	buf_virt = dma_alloc_coherent(sdma->dev, size, &buf_phys, GFP_KERNEL);
 	if (!buf_virt) {
 		return -ENOMEM;
 	}
@@ -696,7 +696,7 @@ static int sdma_load_script(struct sdma_engine *sdma, void *buf, int size,
 
 	spin_unlock_irqrestore(&sdma->channel_0_lock, flags);
 
-	dma_free_coherent(NULL, size, buf_virt, buf_phys);
+	dma_free_coherent(sdma->dev, size, buf_virt, buf_phys);
 
 	return ret;
 }
@@ -1182,7 +1182,7 @@ static int sdma_request_channel0(struct sdma_engine *sdma)
 {
 	int ret = -EBUSY;
 
-	sdma->bd0 = dma_zalloc_coherent(NULL, PAGE_SIZE, &sdma->bd0_phys,
+	sdma->bd0 = dma_zalloc_coherent(sdma->dev, PAGE_SIZE, &sdma->bd0_phys,
 					GFP_NOWAIT);
 	if (!sdma->bd0) {
 		ret = -ENOMEM;
@@ -1205,8 +1205,8 @@ static int sdma_alloc_bd(struct sdma_desc *desc)
 	u32 bd_size = desc->num_bd * sizeof(struct sdma_buffer_descriptor);
 	int ret = 0;
 
-	desc->bd = dma_zalloc_coherent(NULL, bd_size, &desc->bd_phys,
-					GFP_NOWAIT);
+	desc->bd = dma_zalloc_coherent(desc->sdmac->sdma->dev, bd_size,
+				       &desc->bd_phys, GFP_NOWAIT);
 	if (!desc->bd) {
 		ret = -ENOMEM;
 		goto out;
@@ -1219,7 +1219,8 @@ static void sdma_free_bd(struct sdma_desc *desc)
 {
 	u32 bd_size = desc->num_bd * sizeof(struct sdma_buffer_descriptor);
 
-	dma_free_coherent(NULL, bd_size, desc->bd, desc->bd_phys);
+	dma_free_coherent(desc->sdmac->sdma->dev, bd_size, desc->bd,
+			  desc->bd_phys);
 }
 
 static void sdma_desc_free(struct virt_dma_desc *vd)
@@ -1842,7 +1843,7 @@ static int sdma_init(struct sdma_engine *sdma)
 	/* Be sure SDMA has not started yet */
 	writel_relaxed(0, sdma->regs + SDMA_H_C0PTR);
 
-	sdma->channel_control = dma_alloc_coherent(NULL,
+	sdma->channel_control = dma_alloc_coherent(sdma->dev,
 			MAX_DMA_CHANNELS * sizeof (struct sdma_channel_control) +
 			sizeof(struct sdma_context_data),
 			&ccb_phys, GFP_KERNEL);

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

* [PATCH] dma: imx-sdma: pass ->dev to dma_alloc_coherent() API
@ 2019-01-11 14:29 ` Daniel Baluta
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Baluta @ 2019-01-11 14:29 UTC (permalink / raw)
  To: vkoul, dmaengine
  Cc: dl-linux-imx, kernel, dan.j.williams, linux-kernel, S.j. Wang,
	Andy Duan, Robin Gong, Daniel Baluta

From: Andy Duan <fugang.duan@nxp.com>

Pass ->dev to dma_alloc_coherent() API. We need this
becase dma_alloc_coherent() makes use of dev parameter
and receiving NULL will result in a crash.

Signed-off-by: Andy Duan <fugang.duan@nxp.com>
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
---
 drivers/dma/imx-sdma.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index a2b0a0e71168..26133b78ced8 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -677,7 +677,7 @@ static int sdma_load_script(struct sdma_engine *sdma, void *buf, int size,
 	int ret;
 	unsigned long flags;
 
-	buf_virt = dma_alloc_coherent(NULL, size, &buf_phys, GFP_KERNEL);
+	buf_virt = dma_alloc_coherent(sdma->dev, size, &buf_phys, GFP_KERNEL);
 	if (!buf_virt) {
 		return -ENOMEM;
 	}
@@ -696,7 +696,7 @@ static int sdma_load_script(struct sdma_engine *sdma, void *buf, int size,
 
 	spin_unlock_irqrestore(&sdma->channel_0_lock, flags);
 
-	dma_free_coherent(NULL, size, buf_virt, buf_phys);
+	dma_free_coherent(sdma->dev, size, buf_virt, buf_phys);
 
 	return ret;
 }
@@ -1182,7 +1182,7 @@ static int sdma_request_channel0(struct sdma_engine *sdma)
 {
 	int ret = -EBUSY;
 
-	sdma->bd0 = dma_zalloc_coherent(NULL, PAGE_SIZE, &sdma->bd0_phys,
+	sdma->bd0 = dma_zalloc_coherent(sdma->dev, PAGE_SIZE, &sdma->bd0_phys,
 					GFP_NOWAIT);
 	if (!sdma->bd0) {
 		ret = -ENOMEM;
@@ -1205,8 +1205,8 @@ static int sdma_alloc_bd(struct sdma_desc *desc)
 	u32 bd_size = desc->num_bd * sizeof(struct sdma_buffer_descriptor);
 	int ret = 0;
 
-	desc->bd = dma_zalloc_coherent(NULL, bd_size, &desc->bd_phys,
-					GFP_NOWAIT);
+	desc->bd = dma_zalloc_coherent(desc->sdmac->sdma->dev, bd_size,
+				       &desc->bd_phys, GFP_NOWAIT);
 	if (!desc->bd) {
 		ret = -ENOMEM;
 		goto out;
@@ -1219,7 +1219,8 @@ static void sdma_free_bd(struct sdma_desc *desc)
 {
 	u32 bd_size = desc->num_bd * sizeof(struct sdma_buffer_descriptor);
 
-	dma_free_coherent(NULL, bd_size, desc->bd, desc->bd_phys);
+	dma_free_coherent(desc->sdmac->sdma->dev, bd_size, desc->bd,
+			  desc->bd_phys);
 }
 
 static void sdma_desc_free(struct virt_dma_desc *vd)
@@ -1842,7 +1843,7 @@ static int sdma_init(struct sdma_engine *sdma)
 	/* Be sure SDMA has not started yet */
 	writel_relaxed(0, sdma->regs + SDMA_H_C0PTR);
 
-	sdma->channel_control = dma_alloc_coherent(NULL,
+	sdma->channel_control = dma_alloc_coherent(sdma->dev,
 			MAX_DMA_CHANNELS * sizeof (struct sdma_channel_control) +
 			sizeof(struct sdma_context_data),
 			&ccb_phys, GFP_KERNEL);
-- 
2.17.1


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

* dma: imx-sdma: pass ->dev to dma_alloc_coherent() API
  2019-01-11 14:29 ` [PATCH] " Daniel Baluta
@ 2019-01-18  7:41 ` Robin Gong
  -1 siblings, 0 replies; 6+ messages in thread
From: Robin Gong @ 2019-01-18  7:41 UTC (permalink / raw)
  To: Daniel Baluta, vkoul, dmaengine
  Cc: dl-linux-imx, kernel, dan.j.williams, linux-kernel, S.j. Wang, Andy Duan

Reviewed-by: Robin Gong <yibin.gong@nxp.com>
> -----Original Message-----
> From: Daniel Baluta
> Sent: 2019年1月11日 22:30
> To: vkoul@kernel.org; dmaengine@vger.kernel.org
> Cc: dl-linux-imx <linux-imx@nxp.com>; kernel@pengutronix.de;
> dan.j.williams@intel.com; linux-kernel@vger.kernel.org; S.j. Wang
> <shengjiu.wang@nxp.com>; Andy Duan <fugang.duan@nxp.com>; Robin Gong
> <yibin.gong@nxp.com>; Daniel Baluta <daniel.baluta@nxp.com>
> Subject: [PATCH] dma: imx-sdma: pass ->dev to dma_alloc_coherent() API
> 
> From: Andy Duan <fugang.duan@nxp.com>
> 
> Pass ->dev to dma_alloc_coherent() API. We need this becase
> dma_alloc_coherent() makes use of dev parameter and receiving NULL will
> result in a crash.
> 
> Signed-off-by: Andy Duan <fugang.duan@nxp.com>
> Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
> ---
>  drivers/dma/imx-sdma.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index
> a2b0a0e71168..26133b78ced8 100644
> --- a/drivers/dma/imx-sdma.c
> +++ b/drivers/dma/imx-sdma.c
> @@ -677,7 +677,7 @@ static int sdma_load_script(struct sdma_engine
> *sdma, void *buf, int size,
>  	int ret;
>  	unsigned long flags;
> 
> -	buf_virt = dma_alloc_coherent(NULL, size, &buf_phys, GFP_KERNEL);
> +	buf_virt = dma_alloc_coherent(sdma->dev, size, &buf_phys,
> GFP_KERNEL);
>  	if (!buf_virt) {
>  		return -ENOMEM;
>  	}
> @@ -696,7 +696,7 @@ static int sdma_load_script(struct sdma_engine
> *sdma, void *buf, int size,
> 
>  	spin_unlock_irqrestore(&sdma->channel_0_lock, flags);
> 
> -	dma_free_coherent(NULL, size, buf_virt, buf_phys);
> +	dma_free_coherent(sdma->dev, size, buf_virt, buf_phys);
> 
>  	return ret;
>  }
> @@ -1182,7 +1182,7 @@ static int sdma_request_channel0(struct
> sdma_engine *sdma)  {
>  	int ret = -EBUSY;
> 
> -	sdma->bd0 = dma_zalloc_coherent(NULL, PAGE_SIZE, &sdma->bd0_phys,
> +	sdma->bd0 = dma_zalloc_coherent(sdma->dev, PAGE_SIZE,
> &sdma->bd0_phys,
>  					GFP_NOWAIT);
>  	if (!sdma->bd0) {
>  		ret = -ENOMEM;
> @@ -1205,8 +1205,8 @@ static int sdma_alloc_bd(struct sdma_desc *desc)
>  	u32 bd_size = desc->num_bd * sizeof(struct sdma_buffer_descriptor);
>  	int ret = 0;
> 
> -	desc->bd = dma_zalloc_coherent(NULL, bd_size, &desc->bd_phys,
> -					GFP_NOWAIT);
> +	desc->bd = dma_zalloc_coherent(desc->sdmac->sdma->dev, bd_size,
> +				       &desc->bd_phys, GFP_NOWAIT);
>  	if (!desc->bd) {
>  		ret = -ENOMEM;
>  		goto out;
> @@ -1219,7 +1219,8 @@ static void sdma_free_bd(struct sdma_desc *desc)
> {
>  	u32 bd_size = desc->num_bd * sizeof(struct sdma_buffer_descriptor);
> 
> -	dma_free_coherent(NULL, bd_size, desc->bd, desc->bd_phys);
> +	dma_free_coherent(desc->sdmac->sdma->dev, bd_size, desc->bd,
> +			  desc->bd_phys);
>  }
> 
>  static void sdma_desc_free(struct virt_dma_desc *vd) @@ -1842,7 +1843,7
> @@ static int sdma_init(struct sdma_engine *sdma)
>  	/* Be sure SDMA has not started yet */
>  	writel_relaxed(0, sdma->regs + SDMA_H_C0PTR);
> 
> -	sdma->channel_control = dma_alloc_coherent(NULL,
> +	sdma->channel_control = dma_alloc_coherent(sdma->dev,
>  			MAX_DMA_CHANNELS * sizeof (struct sdma_channel_control) +
>  			sizeof(struct sdma_context_data),
>  			&ccb_phys, GFP_KERNEL);
> --
> 2.17.1

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

* RE: [PATCH] dma: imx-sdma: pass ->dev to dma_alloc_coherent() API
@ 2019-01-18  7:41 ` Robin Gong
  0 siblings, 0 replies; 6+ messages in thread
From: Robin Gong @ 2019-01-18  7:41 UTC (permalink / raw)
  To: Daniel Baluta, vkoul, dmaengine
  Cc: dl-linux-imx, kernel, dan.j.williams, linux-kernel, S.j. Wang, Andy Duan

Reviewed-by: Robin Gong <yibin.gong@nxp.com>
> -----Original Message-----
> From: Daniel Baluta
> Sent: 2019年1月11日 22:30
> To: vkoul@kernel.org; dmaengine@vger.kernel.org
> Cc: dl-linux-imx <linux-imx@nxp.com>; kernel@pengutronix.de;
> dan.j.williams@intel.com; linux-kernel@vger.kernel.org; S.j. Wang
> <shengjiu.wang@nxp.com>; Andy Duan <fugang.duan@nxp.com>; Robin Gong
> <yibin.gong@nxp.com>; Daniel Baluta <daniel.baluta@nxp.com>
> Subject: [PATCH] dma: imx-sdma: pass ->dev to dma_alloc_coherent() API
> 
> From: Andy Duan <fugang.duan@nxp.com>
> 
> Pass ->dev to dma_alloc_coherent() API. We need this becase
> dma_alloc_coherent() makes use of dev parameter and receiving NULL will
> result in a crash.
> 
> Signed-off-by: Andy Duan <fugang.duan@nxp.com>
> Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
> ---
>  drivers/dma/imx-sdma.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index
> a2b0a0e71168..26133b78ced8 100644
> --- a/drivers/dma/imx-sdma.c
> +++ b/drivers/dma/imx-sdma.c
> @@ -677,7 +677,7 @@ static int sdma_load_script(struct sdma_engine
> *sdma, void *buf, int size,
>  	int ret;
>  	unsigned long flags;
> 
> -	buf_virt = dma_alloc_coherent(NULL, size, &buf_phys, GFP_KERNEL);
> +	buf_virt = dma_alloc_coherent(sdma->dev, size, &buf_phys,
> GFP_KERNEL);
>  	if (!buf_virt) {
>  		return -ENOMEM;
>  	}
> @@ -696,7 +696,7 @@ static int sdma_load_script(struct sdma_engine
> *sdma, void *buf, int size,
> 
>  	spin_unlock_irqrestore(&sdma->channel_0_lock, flags);
> 
> -	dma_free_coherent(NULL, size, buf_virt, buf_phys);
> +	dma_free_coherent(sdma->dev, size, buf_virt, buf_phys);
> 
>  	return ret;
>  }
> @@ -1182,7 +1182,7 @@ static int sdma_request_channel0(struct
> sdma_engine *sdma)  {
>  	int ret = -EBUSY;
> 
> -	sdma->bd0 = dma_zalloc_coherent(NULL, PAGE_SIZE, &sdma->bd0_phys,
> +	sdma->bd0 = dma_zalloc_coherent(sdma->dev, PAGE_SIZE,
> &sdma->bd0_phys,
>  					GFP_NOWAIT);
>  	if (!sdma->bd0) {
>  		ret = -ENOMEM;
> @@ -1205,8 +1205,8 @@ static int sdma_alloc_bd(struct sdma_desc *desc)
>  	u32 bd_size = desc->num_bd * sizeof(struct sdma_buffer_descriptor);
>  	int ret = 0;
> 
> -	desc->bd = dma_zalloc_coherent(NULL, bd_size, &desc->bd_phys,
> -					GFP_NOWAIT);
> +	desc->bd = dma_zalloc_coherent(desc->sdmac->sdma->dev, bd_size,
> +				       &desc->bd_phys, GFP_NOWAIT);
>  	if (!desc->bd) {
>  		ret = -ENOMEM;
>  		goto out;
> @@ -1219,7 +1219,8 @@ static void sdma_free_bd(struct sdma_desc *desc)
> {
>  	u32 bd_size = desc->num_bd * sizeof(struct sdma_buffer_descriptor);
> 
> -	dma_free_coherent(NULL, bd_size, desc->bd, desc->bd_phys);
> +	dma_free_coherent(desc->sdmac->sdma->dev, bd_size, desc->bd,
> +			  desc->bd_phys);
>  }
> 
>  static void sdma_desc_free(struct virt_dma_desc *vd) @@ -1842,7 +1843,7
> @@ static int sdma_init(struct sdma_engine *sdma)
>  	/* Be sure SDMA has not started yet */
>  	writel_relaxed(0, sdma->regs + SDMA_H_C0PTR);
> 
> -	sdma->channel_control = dma_alloc_coherent(NULL,
> +	sdma->channel_control = dma_alloc_coherent(sdma->dev,
>  			MAX_DMA_CHANNELS * sizeof (struct sdma_channel_control) +
>  			sizeof(struct sdma_context_data),
>  			&ccb_phys, GFP_KERNEL);
> --
> 2.17.1


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

* dma: imx-sdma: pass ->dev to dma_alloc_coherent() API
  2019-01-11 14:29 ` [PATCH] " Daniel Baluta
@ 2019-01-20 10:56 ` Vinod Koul
  -1 siblings, 0 replies; 6+ messages in thread
From: Vinod Koul @ 2019-01-20 10:56 UTC (permalink / raw)
  To: Daniel Baluta
  Cc: dmaengine, dl-linux-imx, kernel, dan.j.williams, linux-kernel,
	S.j. Wang, Andy Duan, Robin Gong

On 11-01-19, 14:29, Daniel Baluta wrote:
> From: Andy Duan <fugang.duan@nxp.com>
> 
> Pass ->dev to dma_alloc_coherent() API. We need this
> becase dma_alloc_coherent() makes use of dev parameter
  ^^^^^
Typo

> and receiving NULL will result in a crash.

Applied after fixing typo and subsystem name, thanks

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

* Re: [PATCH] dma: imx-sdma: pass ->dev to dma_alloc_coherent() API
@ 2019-01-20 10:56 ` Vinod Koul
  0 siblings, 0 replies; 6+ messages in thread
From: Vinod Koul @ 2019-01-20 10:56 UTC (permalink / raw)
  To: Daniel Baluta
  Cc: dmaengine, dl-linux-imx, kernel, dan.j.williams, linux-kernel,
	S.j. Wang, Andy Duan, Robin Gong

On 11-01-19, 14:29, Daniel Baluta wrote:
> From: Andy Duan <fugang.duan@nxp.com>
> 
> Pass ->dev to dma_alloc_coherent() API. We need this
> becase dma_alloc_coherent() makes use of dev parameter
  ^^^^^
Typo

> and receiving NULL will result in a crash.

Applied after fixing typo and subsystem name, thanks
-- 
~Vinod

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

end of thread, other threads:[~2019-01-20 10:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-20 10:56 dma: imx-sdma: pass ->dev to dma_alloc_coherent() API Vinod Koul
2019-01-20 10:56 ` [PATCH] " Vinod Koul
  -- strict thread matches above, loose matches on Subject: below --
2019-01-18  7:41 Robin Gong
2019-01-18  7:41 ` [PATCH] " Robin Gong
2019-01-11 14:29 Daniel Baluta
2019-01-11 14:29 ` [PATCH] " Daniel Baluta

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.