History log of /haiku/src/libs/compat/freebsd_network/bus_dma.cpp
Revision Date Author Comments
# 231f740c 27-Jan-2023 Augustin Cavalier <waddlesplash@gmail.com>

openbsd_network & drivers: Implement the real bus_dmamem functions.

This required the addition of some slight modifications to the main
(FreeBSD compat) bus_dma implementation.

Allows some #ifdefs from iaxwifi/idualwifi to be dropped, and will
ease the porting of some future drivers.

Tested with idualwifi7260, seems to work as before.


# b12b802c 01-Jul-2022 Augustin Cavalier <waddlesplash@gmail.com>

freebsd_network: Add an extended bus_dmamap_sync API for partial syncs.

To preserve proper semantics with the OpenBSD layer, this is needed.


# c27c9870 20-Jun-2022 Augustin Cavalier <waddlesplash@gmail.com>

freebsd_network: Fix address restriction computation in bus_dma.

The min/max usage was reversd from what it should be. This
would have led to the least restrictive restrictions being the
ones that were checked, instead of the most restrictive.


# 2c81f880 20-Jun-2022 Augustin Cavalier <waddlesplash@gmail.com>

freebsd_network: Clean up bus_dma restrictions implementation.

* Remove support for filters (again): they are deprecated in FreeBSD
and no driver we have uses them. This allows the loop in the
_validate_address function to be dropped entirely.

* Clean up parent tag handling logic.


# c6c03b01 13-Jun-2022 Augustin Cavalier <waddlesplash@gmail.com>

freebsd_network: Validate ranges but not alignment when coalescing in bus_dma.


# 7de24641 13-Jun-2022 Augustin Cavalier <waddlesplash@gmail.com>

freebsd_network: Adjust address validation in bus_dma code.

We need not (in fact, must not) revalidate addresses if we are just
going to coalesce with the previous segment; otherwise, we will incorrectly
reject buffers that are more than page-aligned.

Should fix #17798 and the new KDL in #14260.


# 73603a51 13-Jun-2022 Augustin Cavalier <waddlesplash@gmail.com>

freebsd_network: Clean up bus_dma code.

* Turn lastaddrp into a reference instead of a pointer.
* Use PAGESIZE instead of B_PAGE_SIZE for consistency.
* Rename "nsegs" variables to "seg" as it is an offset and not a count.

No functional change intended.


# 802e16c5 10-Jun-2022 Augustin Cavalier <waddlesplash@gmail.com>

freebsd_network: Add missing store of the passed buffer length.

This broke bouncing of anything not an mbuf.
Confirmed to fix #17778, and may fix other problems too.


# 3e9b8421 03-Jun-2022 Augustin Cavalier <waddlesplash@gmail.com>

freebsd_network: bus_dmamap_load_mbuf_sg is always NOWAIT.

This matches FreeBSD.


# 04d2f987 03-Jun-2022 Augustin Cavalier <waddlesplash@gmail.com>

freebsd_network: Put extern "C" in front of all public busdma functions.

Should catch the problem the previous commit fixed earlier.


# 92d0fd61 03-Jun-2022 Augustin Cavalier <waddlesplash@gmail.com>

freebsd_network: Fix definition of bus_dma_tag_create.

Fixes the build under 32-bit.


# 15253c90 03-Jun-2022 Augustin Cavalier <waddlesplash@gmail.com>

freebsd_network: Retry dmamap loads with a bounce buffer in more cases.

Instead of just on ERANGE, also do it for EFBIG and other such errors.

Related to #17763 and #17766.


# 4eac62eb 03-Jun-2022 Augustin Cavalier <waddlesplash@gmail.com>

freebsd_network: Allow destruction of dmamaps with BUFFER_PROHIBITED.


# cb7e50e0 02-Jun-2022 Augustin Cavalier <waddlesplash@gmail.com>

freebsd_network: Propagate alignment restrictions from parent dma_tags.

FreeBSD does the same.


# 654b4f97 02-Jun-2022 Augustin Cavalier <waddlesplash@gmail.com>

freebsd_network: Ensure BUFFER_PROHIBITED status is "sticky."

That is, do not reset it on bus_dmamap_unload.


# d66ceb73 02-Jun-2022 Augustin Cavalier <waddlesplash@gmail.com>

freebsd_network: Implement bouncing and address validation in bus_dma.

This has been missing since the rewrite in 26b95c15f255904694ce8224b6f21f0b931a9cff.

Until now it seems to not have been a problem since buffer sizes
were generally small enough and did not cross page boundaries due
to alignment guarantees. However, now that we have enabled jumbo
frames by default, some drivers do hit DMA limits without bouncing,
as these frames cross pages.

So, now we implement a basic bouncing system. Unlike FreeBSD which
maintains a global "bounce pages" cache that it pulls from,
we use per-dmamap bounce buffers, lazily allocated only if needed.
I tested this by forcing all non-"prohibited" dmamaps to bounce all
transactions, and the rtl81xx driver still worked that way (though
not all drivers may as they have expectations about contiguously
allocated memory never getting bounced.)

This should fix #17763. Hopefully it will also fix #17766 as well.


# 26f69176 29-May-2022 Augustin Cavalier <waddlesplash@gmail.com>

freebsd_network: Add missing segment size check to bus_dma logic.


# caef66c2 03-Dec-2019 Augustin Cavalier <waddlesplash@gmail.com>

freebsd_network: Return to allocating the segments in dmamap_load.

It seems some drivers do not create dmamaps for all their bustags,
so we can't allocate the segments there. And of course, some also
do not go through dmamem_alloc, so the only option then is to revert
to where FreeBSD allocates them, inside dmamap_load.


# 7100b1e1 02-Dec-2019 waddlesplash <waddlesplash@gmail.com>

freebsd_network: Move segment array allocation in bus_dma to dmamap_create().

It seems that some drivers (e.g. broadcom43xx) create a parent DMA tag
with nsegments set to BUS_SPACE_UNRESTRICTED, i.e. MAX_INT, which of
course fails allocation, expecting to never allocate memory for this
tag, only for child tags. So in order to handle this, we have to
delay allocating the segment array until we are certain that the nsegments
value is the "real deal".

Doing it in dmamap_load would be fine, but as there is more than one
entry point to that, we would have to allocate this in multiple places.
dmamap_create() must be called and there is only one way through it,
so put the allocation there.

Fixes #15500 (i.e. both the KDL and the underlying problem that
led to it; it only crashed because the wrong pointer was passed
to kernel_free, whoops.)


# 26b95c15 22-Nov-2019 Augustin Cavalier <waddlesplash@gmail.com>

freebsd_network: Completely overhaul bus_dma implementation.

The old implementation was based on an ancient copy of the FreeBSD
busdma code for x86, and did not make a bunch of assumptions that
we make basically everywhere else (for instance, that we can request
arbitrarily-aligned contiguous physical memory from the VM.)

As a consequence, it had a significant amount of code devoted to
bounce pages, which are just a waste of resources on x86, and
for that matter, probably any other architecture Haiku will ever
be ported to. (Even if we do need to run on some system where
only a small portion of system memory can be accessed by devices,
likely we would reserve that memory for just this occasion anyway.)

I was initially under the impression that the bounce-pages code
never turned on, but apparently due to the "alignment" check
(and also the "Maxmem" check, which was to defined to 32KB...?!)
it does indeed activate on a variety of systems, and maybe
(in the case of drivers that do not call sync() properly) even
is the cause of some of our ported driver breakage.

The new implementation is pretty much optimized for Haiku,
and shares almost no code or structure with the old one (save
for a few functions that really only have one proper implementation.)

Tested with ipro1000 and rtl81xx. Regressions are more than possible,
so please don't hesitate to file bugs if your network driver now
fails to come up (or you get KDLs.)