Subject: Re: Mem-2-Mem DMA - Generalized API

From: Arnd Bergmann <[email-masked]>
Date: Sat, 7 Jul 2007 15:28:00 +0200

On Saturday 07 July 2007, Clifford Wolf wrote:
> > > +=A0=A0=A0// make sure all pending requests have finished before retu=
rning
> > > +=A0=A0=A0down_write(&backend->unreg_sem);
> > > +=A0=A0=A0up_write(&backend->unreg_sem);
> > > +}
> >=20
> > This usage of rw semaphores looks fishy.=20
>=20
> yep. do you have a better idea how to implement this easily?
>=20

I'd guess what you really want is reference counting. Every request
that gets assigned to a backend should get a kref on that backend
and give that up once it gets released itself.

I guess you can then have one more reference that you get in
dmatransfer_register_backend and release in dmatransfer_unregister_backend.
When you release the last reference, you call complete(),
and dmatransfer_unregister_backend() ends with a wait_for_completion().

	Arnd <><