The branch stable/13 has been updated by andrew:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=6f86f758d251a34281c12f0195cfe662d684b4d2

commit 6f86f758d251a34281c12f0195cfe662d684b4d2
Author:     Andrew Turner <[email protected]>
AuthorDate: 2022-04-04 09:28:59 +0000
Commit:     Andrew Turner <[email protected]>
CommitDate: 2022-05-03 14:04:04 +0000

    Fix a coherent bus check in the arm64 busdma
    
    In the arm64 busdma we have an internal flag to signal when a tag is
    for a cache-coherent device. In this case we don't need to adjust the
    size and alignment of allocated buffers to be within a cache line.
    
    The cache line adjustment was incorrectly using the coherent flag
    passed in to bus_dma_tag_create and not the internal flag. Fix it to
    use the latter to reduce the memory usage slightly.
    
    Reviewed by:    bz
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D34763
    
    (cherry picked from commit 3532bcd282b3ba508f0b39560626983463512813)
---
 sys/arm64/arm64/busdma_bounce.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/sys/arm64/arm64/busdma_bounce.c b/sys/arm64/arm64/busdma_bounce.c
index 2173273bf496..9e36dda3a90a 100644
--- a/sys/arm64/arm64/busdma_bounce.c
+++ b/sys/arm64/arm64/busdma_bounce.c
@@ -266,6 +266,18 @@ bounce_bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t 
alignment,
 
        if ((flags & BUS_DMA_COHERENT) != 0) {
                newtag->bounce_flags |= BF_COHERENT;
+       }
+
+       if (parent != NULL) {
+               if ((newtag->common.filter != NULL ||
+                   (parent->bounce_flags & BF_COULD_BOUNCE) != 0))
+                       newtag->bounce_flags |= BF_COULD_BOUNCE;
+
+               /* Copy some flags from the parent */
+               newtag->bounce_flags |= parent->bounce_flags & BF_COHERENT;
+       }
+
+       if ((newtag->bounce_flags & BF_COHERENT) != 0) {
                newtag->alloc_alignment = newtag->common.alignment;
                newtag->alloc_size = newtag->common.maxsize;
        } else {
@@ -281,15 +293,6 @@ bounce_bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t 
alignment,
                    dcache_line_size);
        }
 
-       if (parent != NULL) {
-               if ((newtag->common.filter != NULL ||
-                   (parent->bounce_flags & BF_COULD_BOUNCE) != 0))
-                       newtag->bounce_flags |= BF_COULD_BOUNCE;
-
-               /* Copy some flags from the parent */
-               newtag->bounce_flags |= parent->bounce_flags & BF_COHERENT;
-       }
-
        if (newtag->common.lowaddr < ptoa((vm_paddr_t)Maxmem) ||
            newtag->common.alignment > 1)
                newtag->bounce_flags |= BF_COULD_BOUNCE;

Reply via email to