[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: proposal for bus_dma(9) change
> The driver's attaching function knows something failed and calls the
> function which free's the dma memory (actually, some drivers
> don't do even that!). This free function just gets a softc argument,
> so the error code is unknown. The free routine doesn't even
> know if something failed. All what it can do is that it checks
> the dmamap pointer against NULL. If it isn't NULL, it calls
> bus_dmamap_destroy() => BOOM
Ah, are you saying about _bus_dma_alloc_bouncebuf() failure
in x86/bus_dma.c:_bus_dmamap_create() for example?
> 2) My proposal to change the behaviour of bus_dmamap_create():
> In case of error, the dmamap is NULL (instead of undefined).
> Effect: This makes the dmamap pointer check against NULL as
> described above correct and bus_dmamap_destroy() isn't called.
> Required effort: Find all implementations of bus_dmamap_create()
> and adjust the implementation.
It's unaccectable to change only bus_dmamap_create(9)
because all APIs should have consistent meaning of dmamap.
In -current API definition, returned dmamap is undefined
in error case, so driver can't assume dmamap is valid
if it isn't NULL and driver should have resonsibility
to keep invalid dmamap NULL in failure path and destroying path.
If the definition is changed as NULL dmamap means invalid dmamap,
bus_dmamap_destroy(9) should also be changed to make passed dmamap NULL,
and bus_dmamap_create(9) should reject non-NULL dmamap,
otherwise inconsistent semantics could confuse driver writers
and they will create more other bugs.
> Benefit (you asked for): Once this is done,
Does it require less effort to fix all bus_dmamap_create()
than fixing each driver?
> we don't need to worry
> about exact *this* problem in the drivers anymore. This also
> makes the use of bus_dmamap_create() more intuitively usable.
But you also have to worry about the problem when
new MD bus_dmamap_create() implementations are added.
Once all drivers are fixed, we don't have to worry about
MD bus_dmamap_create(9) implementation.
MI API with MD implementation should be designed carefully
because maintainance cost is more expensive than independent drivers.
Main Index |
Thread Index |