Re: [PATCH v5 05/14] crypto: marvell/CESA: add TDMA support

2015-06-17 Thread Boris Brezillon
On Wed, 17 Jun 2015 15:18:29 +0800
Herbert Xu  wrote:

> On Wed, Jun 17, 2015 at 09:15:03AM +0200, Boris Brezillon wrote:
> >
> > Anyway, now I'm doing the following test:
> > 
> > if (creq->src_nents && !ret)
> > return -ENOMEM;
> 
> Best not call dma_map_sg at all in the !src_nents case as I think
> some architectures will WARN or BUG if you give it a zero-length
> list.

Okay, I've changed it to test for the !src_nents before calling
dma_map_sg.

Thanks,

Boris


-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 05/14] crypto: marvell/CESA: add TDMA support

2015-06-17 Thread Herbert Xu
On Wed, Jun 17, 2015 at 09:15:03AM +0200, Boris Brezillon wrote:
>
> Anyway, now I'm doing the following test:
> 
> if (creq->src_nents && !ret)
>   return -ENOMEM;

Best not call dma_map_sg at all in the !src_nents case as I think
some architectures will WARN or BUG if you give it a zero-length
list.

Cheers,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 05/14] crypto: marvell/CESA: add TDMA support

2015-06-17 Thread Boris Brezillon
On Wed, 17 Jun 2015 13:56:33 +0800
Herbert Xu  wrote:

> On Wed, Jun 17, 2015 at 01:05:27PM +0800, Herbert Xu wrote:
> > On Tue, Jun 16, 2015 at 11:58:59AM +0200, Boris Brezillon wrote:
> > >
> > > + ret = dma_map_sg(cesa_dev->dev, req->src, creq->src_nents,
> > > +  DMA_TO_DEVICE);
> > > + if (ret != creq->src_nents)
> > > + return -ENOMEM;
> > 
> > Hmm it doesn't quite work like that.  It returns zero on error,
> > otherwise it returns the number (n) of mapped entries which may be
> > less than what you gave it due to merging.  You're then supposed
> > to use only the first n entries which should contain everything.
> 
> Please take a look at Documentation/DMA-API-HOWTO.txt, it has
> everything you need to know about the dma_map_sg interface.

Yep, I read it, but apparently not carefully enough ;-).
I'll fix that.

Note that I did not ignore your previous comment on purpose (checking
for !ret to verify if the sg entries were successfully mapped), but I
have a specific case in the hash code where the requested len is 0
(final request) and thus the src_nents is 0 too. Which means I'm
expecting the dma_sg_map to return 0.

Anyway, now I'm doing the following test:

if (creq->src_nents && !ret)
return -ENOMEM;

Best Regards,

Boris

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 05/14] crypto: marvell/CESA: add TDMA support

2015-06-16 Thread Herbert Xu
On Wed, Jun 17, 2015 at 01:05:27PM +0800, Herbert Xu wrote:
> On Tue, Jun 16, 2015 at 11:58:59AM +0200, Boris Brezillon wrote:
> >
> > +   ret = dma_map_sg(cesa_dev->dev, req->src, creq->src_nents,
> > +DMA_TO_DEVICE);
> > +   if (ret != creq->src_nents)
> > +   return -ENOMEM;
> 
> Hmm it doesn't quite work like that.  It returns zero on error,
> otherwise it returns the number (n) of mapped entries which may be
> less than what you gave it due to merging.  You're then supposed
> to use only the first n entries which should contain everything.

Please take a look at Documentation/DMA-API-HOWTO.txt, it has
everything you need to know about the dma_map_sg interface.

Cheers,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 05/14] crypto: marvell/CESA: add TDMA support

2015-06-16 Thread Herbert Xu
On Tue, Jun 16, 2015 at 11:58:59AM +0200, Boris Brezillon wrote:
>
> + ret = dma_map_sg(cesa_dev->dev, req->src, creq->src_nents,
> +  DMA_TO_DEVICE);
> + if (ret != creq->src_nents)
> + return -ENOMEM;

Hmm it doesn't quite work like that.  It returns zero on error,
otherwise it returns the number (n) of mapped entries which may be
less than what you gave it due to merging.  You're then supposed
to use only the first n entries which should contain everything.

Cheers,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html