linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arch/powerpc: Use dma_zalloc_coherent
@ 2018-11-05  3:28 Sabyasachi Gupta
  2018-11-15 17:59 ` Sabyasachi Gupta
  2018-11-27  9:22 ` Michael Ellerman
  0 siblings, 2 replies; 11+ messages in thread
From: Sabyasachi Gupta @ 2018-11-05  3:28 UTC (permalink / raw)
  To: benh, paulus, mpe, joe, darren, christophe.leroy, geoff
  Cc: jrdr.linux, linuxppc-dev, linux-kernel

Replaced dma_alloc_coherent + memset with dma_zalloc_coherent

Signed-off-by: Sabyasachi Gupta <sabyasachi.linux@gmail.com>
---
 arch/powerpc/platforms/pasemi/dma_lib.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/powerpc/platforms/pasemi/dma_lib.c b/arch/powerpc/platforms/pasemi/dma_lib.c
index 53384eb..d18d164 100644
--- a/arch/powerpc/platforms/pasemi/dma_lib.c
+++ b/arch/powerpc/platforms/pasemi/dma_lib.c
@@ -255,15 +255,13 @@ int pasemi_dma_alloc_ring(struct pasemi_dmachan *chan, int ring_size)
 
 	chan->ring_size = ring_size;
 
-	chan->ring_virt = dma_alloc_coherent(&dma_pdev->dev,
+	chan->ring_virt = dma_zalloc_coherent(&dma_pdev->dev,
 					     ring_size * sizeof(u64),
 					     &chan->ring_dma, GFP_KERNEL);
 
 	if (!chan->ring_virt)
 		return -ENOMEM;
 
-	memset(chan->ring_virt, 0, ring_size * sizeof(u64));
-
 	return 0;
 }
 EXPORT_SYMBOL(pasemi_dma_alloc_ring);
-- 
2.7.4


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

* Re: [PATCH] arch/powerpc: Use dma_zalloc_coherent
  2018-11-05  3:28 [PATCH] arch/powerpc: Use dma_zalloc_coherent Sabyasachi Gupta
@ 2018-11-15 17:59 ` Sabyasachi Gupta
  2018-11-15 19:25   ` Joe Perches
  2018-11-16 10:06   ` Michael Ellerman
  2018-11-27  9:22 ` Michael Ellerman
  1 sibling, 2 replies; 11+ messages in thread
From: Sabyasachi Gupta @ 2018-11-15 17:59 UTC (permalink / raw)
  To: benh, paulus, mpe, joe, darren, christophe.leroy, geoff
  Cc: Souptick Joarder, linuxppc-dev, linux-kernel

On Mon, Nov 5, 2018 at 8:58 AM Sabyasachi Gupta
<sabyasachi.linux@gmail.com> wrote:
>
> Replaced dma_alloc_coherent + memset with dma_zalloc_coherent
>
> Signed-off-by: Sabyasachi Gupta <sabyasachi.linux@gmail.com>

Any comment on this patch?

> ---
>  arch/powerpc/platforms/pasemi/dma_lib.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/arch/powerpc/platforms/pasemi/dma_lib.c b/arch/powerpc/platforms/pasemi/dma_lib.c
> index 53384eb..d18d164 100644
> --- a/arch/powerpc/platforms/pasemi/dma_lib.c
> +++ b/arch/powerpc/platforms/pasemi/dma_lib.c
> @@ -255,15 +255,13 @@ int pasemi_dma_alloc_ring(struct pasemi_dmachan *chan, int ring_size)
>
>         chan->ring_size = ring_size;
>
> -       chan->ring_virt = dma_alloc_coherent(&dma_pdev->dev,
> +       chan->ring_virt = dma_zalloc_coherent(&dma_pdev->dev,
>                                              ring_size * sizeof(u64),
>                                              &chan->ring_dma, GFP_KERNEL);
>
>         if (!chan->ring_virt)
>                 return -ENOMEM;
>
> -       memset(chan->ring_virt, 0, ring_size * sizeof(u64));
> -
>         return 0;
>  }
>  EXPORT_SYMBOL(pasemi_dma_alloc_ring);
> --
> 2.7.4
>

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

* Re: [PATCH] arch/powerpc: Use dma_zalloc_coherent
  2018-11-15 17:59 ` Sabyasachi Gupta
@ 2018-11-15 19:25   ` Joe Perches
  2018-11-17  7:10     ` Souptick Joarder
  2018-11-16 10:06   ` Michael Ellerman
  1 sibling, 1 reply; 11+ messages in thread
From: Joe Perches @ 2018-11-15 19:25 UTC (permalink / raw)
  To: Sabyasachi Gupta, benh, paulus, mpe, darren, christophe.leroy, geoff
  Cc: Souptick Joarder, linuxppc-dev, linux-kernel

On Thu, 2018-11-15 at 23:29 +0530, Sabyasachi Gupta wrote:
> On Mon, Nov 5, 2018 at 8:58 AM Sabyasachi Gupta
> <sabyasachi.linux@gmail.com> wrote:
> > Replaced dma_alloc_coherent + memset with dma_zalloc_coherent
> > 
> > Signed-off-by: Sabyasachi Gupta <sabyasachi.linux@gmail.com>
> 
> Any comment on this patch?

It's obviously correct.

You might realign the arguments on the next lines
to the open parenthesis.

Perhaps there should be new function calls
added for symmetry to the other alloc functions
for multiplication overflow protection.

Perhaps:

void *dma_alloc_array_coherent()
void *dma_calloc_coherent()

Something like
---
 include/linux/dma-mapping.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 15bd41447025..95bebf8883b1 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -565,6 +565,25 @@ static inline void *dma_alloc_coherent(struct device *dev, size_t size,
 			(gfp & __GFP_NOWARN) ? DMA_ATTR_NO_WARN : 0);
 }
 
+static inline void *dma_alloc_array_coherent(struct device *dev,
+					     size_t n, size_t size,
+					     dma_addr_t *dma_handle, gfp_t gfp)
+{
+	size_t bytes;
+
+	if (unlikely(check_mul_overflow(n, size, &bytes)))
+		return NULL;
+	return dma_alloc_coherent(dev, bytes, dma_handle, gfp);
+}
+
+static inline void *dma_calloc_coherent(struct device *dev,
+					size_t n, size_t size,
+					dma_addr_t *dma_handle, gfp_t gfp)
+{
+	return dma_alloc_array_coherent(dev, n, size, dma_handle,
+					gfp | __GFP_ZERO);
+}
+
 static inline void dma_free_coherent(struct device *dev, size_t size,
 		void *cpu_addr, dma_addr_t dma_handle)
 {

---
> > diff --git a/arch/powerpc/platforms/pasemi/dma_lib.c b/arch/powerpc/platforms/pasemi/dma_lib.c
[]
> > @@ -255,15 +255,13 @@ int pasemi_dma_alloc_ring(struct pasemi_dmachan *chan, int ring_size)
> > 
> >         chan->ring_size = ring_size;
> > 
> > -       chan->ring_virt = dma_alloc_coherent(&dma_pdev->dev,
> > +       chan->ring_virt = dma_zalloc_coherent(&dma_pdev->dev,
> >                                              ring_size * sizeof(u64),
> >                                              &chan->ring_dma, GFP_KERNEL);
> >  en
> >         if (!chan->ring_virt)
> >                 return -ENOMEM;
> > 
> > -       memset(chan->ring_virt, 0, ring_size * sizeof(u64));
> > -
> >         return 0;
> >  }
> >  EXPORT_SYMBOL(pasemi_dma_alloc_ring);



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

* Re: [PATCH] arch/powerpc: Use dma_zalloc_coherent
  2018-11-15 17:59 ` Sabyasachi Gupta
  2018-11-15 19:25   ` Joe Perches
@ 2018-11-16 10:06   ` Michael Ellerman
  1 sibling, 0 replies; 11+ messages in thread
From: Michael Ellerman @ 2018-11-16 10:06 UTC (permalink / raw)
  To: Sabyasachi Gupta, benh, paulus, joe, darren, christophe.leroy, geoff
  Cc: Souptick Joarder, linuxppc-dev, linux-kernel

Sabyasachi Gupta <sabyasachi.linux@gmail.com> writes:

> On Mon, Nov 5, 2018 at 8:58 AM Sabyasachi Gupta
> <sabyasachi.linux@gmail.com> wrote:
>>
>> Replaced dma_alloc_coherent + memset with dma_zalloc_coherent
>>
>> Signed-off-by: Sabyasachi Gupta <sabyasachi.linux@gmail.com>
>
> Any comment on this patch?

Wait longer :)

I'm still chasing bugs in 4.20-rc2, I haven't started merging many
patches for 4.21 yet.

Your patches are tracked in patchwork here:
  https://patchwork.ozlabs.org/project/linuxppc-dev/list/?submitter=75253


If they're still in "new" state around rc5 then feel free to ping me
again.

cheers


>> diff --git a/arch/powerpc/platforms/pasemi/dma_lib.c b/arch/powerpc/platforms/pasemi/dma_lib.c
>> index 53384eb..d18d164 100644
>> --- a/arch/powerpc/platforms/pasemi/dma_lib.c
>> +++ b/arch/powerpc/platforms/pasemi/dma_lib.c
>> @@ -255,15 +255,13 @@ int pasemi_dma_alloc_ring(struct pasemi_dmachan *chan, int ring_size)
>>
>>         chan->ring_size = ring_size;
>>
>> -       chan->ring_virt = dma_alloc_coherent(&dma_pdev->dev,
>> +       chan->ring_virt = dma_zalloc_coherent(&dma_pdev->dev,
>>                                              ring_size * sizeof(u64),
>>                                              &chan->ring_dma, GFP_KERNEL);
>>
>>         if (!chan->ring_virt)
>>                 return -ENOMEM;
>>
>> -       memset(chan->ring_virt, 0, ring_size * sizeof(u64));
>> -
>>         return 0;
>>  }
>>  EXPORT_SYMBOL(pasemi_dma_alloc_ring);
>> --
>> 2.7.4
>>

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

* Re: [PATCH] arch/powerpc: Use dma_zalloc_coherent
  2018-11-15 19:25   ` Joe Perches
@ 2018-11-17  7:10     ` Souptick Joarder
  2018-11-17  8:24       ` Joe Perches
  0 siblings, 1 reply; 11+ messages in thread
From: Souptick Joarder @ 2018-11-17  7:10 UTC (permalink / raw)
  To: Joe Perches
  Cc: Sabyasachi Gupta, benh, paulus, mpe, darren, christophe.leroy,
	geoff, linuxppc-dev, linux-kernel

Hi Joe,

On Fri, Nov 16, 2018 at 12:55 AM Joe Perches <joe@perches.com> wrote:
>
> On Thu, 2018-11-15 at 23:29 +0530, Sabyasachi Gupta wrote:
> > On Mon, Nov 5, 2018 at 8:58 AM Sabyasachi Gupta
> > <sabyasachi.linux@gmail.com> wrote:
> > > Replaced dma_alloc_coherent + memset with dma_zalloc_coherent
> > >
> > > Signed-off-by: Sabyasachi Gupta <sabyasachi.linux@gmail.com>
> >
> > Any comment on this patch?
>
> It's obviously correct.
>
> You might realign the arguments on the next lines
> to the open parenthesis.
>
> Perhaps there should be new function calls
> added for symmetry to the other alloc functions
> for multiplication overflow protection.
>
> Perhaps:
>
> void *dma_alloc_array_coherent()
> void *dma_calloc_coherent()
>
> Something like
> ---
>  include/linux/dma-mapping.h | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
>
> diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
> index 15bd41447025..95bebf8883b1 100644
> --- a/include/linux/dma-mapping.h
> +++ b/include/linux/dma-mapping.h
> @@ -565,6 +565,25 @@ static inline void *dma_alloc_coherent(struct device *dev, size_t size,
>                         (gfp & __GFP_NOWARN) ? DMA_ATTR_NO_WARN : 0);
>  }
>
> +static inline void *dma_alloc_array_coherent(struct device *dev,
> +                                            size_t n, size_t size,
> +                                            dma_addr_t *dma_handle, gfp_t gfp)
> +{
> +       size_t bytes;
> +
> +       if (unlikely(check_mul_overflow(n, size, &bytes)))
> +               return NULL;
> +       return dma_alloc_coherent(dev, bytes, dma_handle, gfp);
> +}
> +
> +static inline void *dma_calloc_coherent(struct device *dev,
> +                                       size_t n, size_t size,
> +                                       dma_addr_t *dma_handle, gfp_t gfp)
> +{
> +       return dma_alloc_array_coherent(dev, n, size, dma_handle,
> +                                       gfp | __GFP_ZERO);
> +}
> +

If I understood correctly, you are talking about adding these 2 new inline
functions. We can do that.

Can you please help to understand the consumers of these 2 new inline ?

>  static inline void dma_free_coherent(struct device *dev, size_t size,
>                 void *cpu_addr, dma_addr_t dma_handle)
>  {
>
> ---
> > > diff --git a/arch/powerpc/platforms/pasemi/dma_lib.c b/arch/powerpc/platforms/pasemi/dma_lib.c
> []
> > > @@ -255,15 +255,13 @@ int pasemi_dma_alloc_ring(struct pasemi_dmachan *chan, int ring_size)
> > >
> > >         chan->ring_size = ring_size;
> > >
> > > -       chan->ring_virt = dma_alloc_coherent(&dma_pdev->dev,
> > > +       chan->ring_virt = dma_zalloc_coherent(&dma_pdev->dev,
> > >                                              ring_size * sizeof(u64),
> > >                                              &chan->ring_dma, GFP_KERNEL);
> > >  en
> > >         if (!chan->ring_virt)
> > >                 return -ENOMEM;
> > >
> > > -       memset(chan->ring_virt, 0, ring_size * sizeof(u64));
> > > -
> > >         return 0;
> > >  }
> > >  EXPORT_SYMBOL(pasemi_dma_alloc_ring);
>
>

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

* Re: [PATCH] arch/powerpc: Use dma_zalloc_coherent
  2018-11-17  7:10     ` Souptick Joarder
@ 2018-11-17  8:24       ` Joe Perches
  0 siblings, 0 replies; 11+ messages in thread
From: Joe Perches @ 2018-11-17  8:24 UTC (permalink / raw)
  To: Souptick Joarder
  Cc: Sabyasachi Gupta, benh, paulus, mpe, darren, christophe.leroy,
	geoff, linuxppc-dev, linux-kernel

On Sat, 2018-11-17 at 12:40 +0530, Souptick Joarder wrote:
> Hi Joe,

Hi back.

> On Fri, Nov 16, 2018 at 12:55 AM Joe Perches <joe@perches.com> wrote:
> > On Thu, 2018-11-15 at 23:29 +0530, Sabyasachi Gupta wrote:
> > > On Mon, Nov 5, 2018 at 8:58 AM Sabyasachi Gupta
> > > <sabyasachi.linux@gmail.com> wrote:
> > > > Replaced dma_alloc_coherent + memset with dma_zalloc_coherent
> > > > 
> > > > Signed-off-by: Sabyasachi Gupta <sabyasachi.linux@gmail.com>
> > > 
> > > Any comment on this patch?
> > 
> > It's obviously correct.
> > 
> > You might realign the arguments on the next lines
> > to the open parenthesis.
> > 
> > Perhaps there should be new function calls
> > added for symmetry to the other alloc functions
> > for multiplication overflow protection.
> > 
> > Perhaps:
> > 
> > void *dma_alloc_array_coherent()
> > void *dma_calloc_coherent()
> > 
> > Something like
> > ---
> >  include/linux/dma-mapping.h | 19 +++++++++++++++++++
> >  1 file changed, 19 insertions(+)
> > 
> > diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
> > index 15bd41447025..95bebf8883b1 100644
> > --- a/include/linux/dma-mapping.h
> > +++ b/include/linux/dma-mapping.h
> > @@ -565,6 +565,25 @@ static inline void *dma_alloc_coherent(struct device *dev, size_t size,
> >                         (gfp & __GFP_NOWARN) ? DMA_ATTR_NO_WARN : 0);
> >  }
> > 
> > +static inline void *dma_alloc_array_coherent(struct device *dev,
> > +                                            size_t n, size_t size,
> > +                                            dma_addr_t *dma_handle, gfp_t gfp)
> > +{
> > +       size_t bytes;
> > +
> > +       if (unlikely(check_mul_overflow(n, size, &bytes)))
> > +               return NULL;
> > +       return dma_alloc_coherent(dev, bytes, dma_handle, gfp);
> > +}
> > +
> > +static inline void *dma_calloc_coherent(struct device *dev,
> > +                                       size_t n, size_t size,
> > +                                       dma_addr_t *dma_handle, gfp_t gfp)
> > +{
> > +       return dma_alloc_array_coherent(dev, n, size, dma_handle,
> > +                                       gfp | __GFP_ZERO);
> > +}
> > +
> 
> If I understood correctly, you are talking about adding these 2 new inline
> functions. We can do that.
> 
> Can you please help to understand the consumers of these 2 new inline ?

Any call to dma_alloc_coherent with a multiply
_might_overflow the multiplication.  The
check_mul_overflow simply avoids the overflow.



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

* Re: arch/powerpc: Use dma_zalloc_coherent
  2018-11-05  3:28 [PATCH] arch/powerpc: Use dma_zalloc_coherent Sabyasachi Gupta
  2018-11-15 17:59 ` Sabyasachi Gupta
@ 2018-11-27  9:22 ` Michael Ellerman
  1 sibling, 0 replies; 11+ messages in thread
From: Michael Ellerman @ 2018-11-27  9:22 UTC (permalink / raw)
  To: Sabyasachi Gupta, benh, paulus, joe, darren, christophe.leroy, geoff
  Cc: linuxppc-dev, jrdr.linux, linux-kernel

On Mon, 2018-11-05 at 03:28:23 UTC, Sabyasachi Gupta wrote:
> Replaced dma_alloc_coherent + memset with dma_zalloc_coherent
> 
> Signed-off-by: Sabyasachi Gupta <sabyasachi.linux@gmail.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/c3d6a64bd1e82ea486bff46b17d540

cheers

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

* Re: [PATCH] arch/powerpc: Use dma_zalloc_coherent
  2018-11-15 17:56 ` Sabyasachi Gupta
@ 2018-12-22  1:56   ` Scott Wood
  0 siblings, 0 replies; 11+ messages in thread
From: Scott Wood @ 2018-12-22  1:56 UTC (permalink / raw)
  To: Sabyasachi Gupta, benh, paulus, mpe
  Cc: Brajeswar Ghosh, linuxppc-dev, Souptick Joarder, linux-kernel

On Thu, 2018-11-15 at 23:26 +0530, Sabyasachi Gupta wrote:
> On Mon, Nov 5, 2018 at 7:52 AM Sabyasachi Gupta
> <sabyasachi.linux@gmail.com> wrote:
> > 
> > Replaced dma_alloc_coherent + memset with dma_zalloc_coherent
> > 
> > Signed-off-by: Sabyasachi Gupta <sabyasachi.linux@gmail.com>
> 
> Any comment on this patch?

Just that FSL patches should be CCed to me, and the subject line is too broad
(and duplicates another patch posted around the same time).

I'm applying with the subject changed to
"arch/powerpc/fsl_rmu: Use dma_zalloc_coherent".

-Scott



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

* Re: [PATCH] arch/powerpc: Use dma_zalloc_coherent
  2018-11-05  2:22 [PATCH] " Sabyasachi Gupta
  2018-11-15 17:56 ` Sabyasachi Gupta
@ 2018-12-05  4:41 ` Sabyasachi Gupta
  1 sibling, 0 replies; 11+ messages in thread
From: Sabyasachi Gupta @ 2018-12-05  4:41 UTC (permalink / raw)
  To: benh, paulus, mpe
  Cc: Souptick Joarder, linuxppc-dev, linux-kernel, Brajeswar Ghosh

On Mon, Nov 5, 2018 at 7:52 AM Sabyasachi Gupta
<sabyasachi.linux@gmail.com> wrote:
>
> Replaced dma_alloc_coherent + memset with dma_zalloc_coherent
>
> Signed-off-by: Sabyasachi Gupta <sabyasachi.linux@gmail.com>

Any comment on this patch?

> ---
>  arch/powerpc/sysdev/fsl_rmu.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/arch/powerpc/sysdev/fsl_rmu.c b/arch/powerpc/sysdev/fsl_rmu.c
> index 88b35a3d..8b0ebf3 100644
> --- a/arch/powerpc/sysdev/fsl_rmu.c
> +++ b/arch/powerpc/sysdev/fsl_rmu.c
> @@ -756,15 +756,13 @@ fsl_open_outb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entries)
>         }
>
>         /* Initialize outbound message descriptor ring */
> -       rmu->msg_tx_ring.virt = dma_alloc_coherent(priv->dev,
> +       rmu->msg_tx_ring.virt = dma_zalloc_coherent(priv->dev,
>                                 rmu->msg_tx_ring.size * RIO_MSG_DESC_SIZE,
>                                 &rmu->msg_tx_ring.phys, GFP_KERNEL);
>         if (!rmu->msg_tx_ring.virt) {
>                 rc = -ENOMEM;
>                 goto out_dma;
>         }
> -       memset(rmu->msg_tx_ring.virt, 0,
> -                       rmu->msg_tx_ring.size * RIO_MSG_DESC_SIZE);
>         rmu->msg_tx_ring.tx_slot = 0;
>
>         /* Point dequeue/enqueue pointers at first entry in ring */
> --
> 2.7.4
>

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

* Re: [PATCH] arch/powerpc: Use dma_zalloc_coherent
  2018-11-05  2:22 [PATCH] " Sabyasachi Gupta
@ 2018-11-15 17:56 ` Sabyasachi Gupta
  2018-12-22  1:56   ` Scott Wood
  2018-12-05  4:41 ` Sabyasachi Gupta
  1 sibling, 1 reply; 11+ messages in thread
From: Sabyasachi Gupta @ 2018-11-15 17:56 UTC (permalink / raw)
  To: benh, paulus, mpe
  Cc: Souptick Joarder, linuxppc-dev, linux-kernel, Brajeswar Ghosh

On Mon, Nov 5, 2018 at 7:52 AM Sabyasachi Gupta
<sabyasachi.linux@gmail.com> wrote:
>
> Replaced dma_alloc_coherent + memset with dma_zalloc_coherent
>
> Signed-off-by: Sabyasachi Gupta <sabyasachi.linux@gmail.com>

Any comment on this patch?

> ---
>  arch/powerpc/sysdev/fsl_rmu.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/arch/powerpc/sysdev/fsl_rmu.c b/arch/powerpc/sysdev/fsl_rmu.c
> index 88b35a3d..8b0ebf3 100644
> --- a/arch/powerpc/sysdev/fsl_rmu.c
> +++ b/arch/powerpc/sysdev/fsl_rmu.c
> @@ -756,15 +756,13 @@ fsl_open_outb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entries)
>         }
>
>         /* Initialize outbound message descriptor ring */
> -       rmu->msg_tx_ring.virt = dma_alloc_coherent(priv->dev,
> +       rmu->msg_tx_ring.virt = dma_zalloc_coherent(priv->dev,
>                                 rmu->msg_tx_ring.size * RIO_MSG_DESC_SIZE,
>                                 &rmu->msg_tx_ring.phys, GFP_KERNEL);
>         if (!rmu->msg_tx_ring.virt) {
>                 rc = -ENOMEM;
>                 goto out_dma;
>         }
> -       memset(rmu->msg_tx_ring.virt, 0,
> -                       rmu->msg_tx_ring.size * RIO_MSG_DESC_SIZE);
>         rmu->msg_tx_ring.tx_slot = 0;
>
>         /* Point dequeue/enqueue pointers at first entry in ring */
> --
> 2.7.4
>

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

* [PATCH] arch/powerpc: Use dma_zalloc_coherent
@ 2018-11-05  2:22 Sabyasachi Gupta
  2018-11-15 17:56 ` Sabyasachi Gupta
  2018-12-05  4:41 ` Sabyasachi Gupta
  0 siblings, 2 replies; 11+ messages in thread
From: Sabyasachi Gupta @ 2018-11-05  2:22 UTC (permalink / raw)
  To: benh, paulus, mpe; +Cc: jrdr.linux, linuxppc-dev, linux-kernel, brajeswar.linux

Replaced dma_alloc_coherent + memset with dma_zalloc_coherent

Signed-off-by: Sabyasachi Gupta <sabyasachi.linux@gmail.com>
---
 arch/powerpc/sysdev/fsl_rmu.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/powerpc/sysdev/fsl_rmu.c b/arch/powerpc/sysdev/fsl_rmu.c
index 88b35a3d..8b0ebf3 100644
--- a/arch/powerpc/sysdev/fsl_rmu.c
+++ b/arch/powerpc/sysdev/fsl_rmu.c
@@ -756,15 +756,13 @@ fsl_open_outb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entries)
 	}
 
 	/* Initialize outbound message descriptor ring */
-	rmu->msg_tx_ring.virt = dma_alloc_coherent(priv->dev,
+	rmu->msg_tx_ring.virt = dma_zalloc_coherent(priv->dev,
 				rmu->msg_tx_ring.size * RIO_MSG_DESC_SIZE,
 				&rmu->msg_tx_ring.phys, GFP_KERNEL);
 	if (!rmu->msg_tx_ring.virt) {
 		rc = -ENOMEM;
 		goto out_dma;
 	}
-	memset(rmu->msg_tx_ring.virt, 0,
-			rmu->msg_tx_ring.size * RIO_MSG_DESC_SIZE);
 	rmu->msg_tx_ring.tx_slot = 0;
 
 	/* Point dequeue/enqueue pointers at first entry in ring */
-- 
2.7.4


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

end of thread, other threads:[~2018-12-22  2:00 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-05  3:28 [PATCH] arch/powerpc: Use dma_zalloc_coherent Sabyasachi Gupta
2018-11-15 17:59 ` Sabyasachi Gupta
2018-11-15 19:25   ` Joe Perches
2018-11-17  7:10     ` Souptick Joarder
2018-11-17  8:24       ` Joe Perches
2018-11-16 10:06   ` Michael Ellerman
2018-11-27  9:22 ` Michael Ellerman
  -- strict thread matches above, loose matches on Subject: below --
2018-11-05  2:22 [PATCH] " Sabyasachi Gupta
2018-11-15 17:56 ` Sabyasachi Gupta
2018-12-22  1:56   ` Scott Wood
2018-12-05  4:41 ` Sabyasachi Gupta

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