2010-01-13 06:29:50

by Dmitry Kasatkin

[permalink] [raw]
Subject: Crypto API

Hi,

I develop some drivers for crypto HW and met some difficulties.
Some algorithm functions are called behind crypto_kmap()

data = crypto_kmap(sg_page(sg), 0);

It will do inc_preempt_count();

I try to use DMA controller to perform memory transfers and try to use
wait_for_completion()

But of course it gives

BUG: sleeping function called from invalid context at kernel/sched.c:5786

What is the best way to handle such case?

Thanks,
Dmitry




2010-01-14 00:40:14

by Herbert Xu

[permalink] [raw]
Subject: Re: Crypto API

Dmitry Kasatkin <[email protected]> wrote:
>
> I develop some drivers for crypto HW and met some difficulties.
> Some algorithm functions are called behind crypto_kmap()
>
> data = crypto_kmap(sg_page(sg), 0);
>
> It will do inc_preempt_count();
>
> I try to use DMA controller to perform memory transfers and try to use
> wait_for_completion()

crypto_kmap is for software crypto. If you're doing DMA, you
shouldn't use it.

Please take a look at other crypto drivers under drivers/crypto
as to how DMA should be implemented.

Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt