Author: mmel
Date: Sun Feb 10 14:25:29 2019
New Revision: 343962
URL: https://svnweb.freebsd.org/changeset/base/343962

Log:
  Properly handle alignment requests bigger that page size.
   - for now, alignments bigger that page size is allowed only for buffers
     allocated by bus_dmamem_alloc(), cover this fact by KASSERT.
   - never bounce buffers allocated by bus_dmamem_alloc(), these always comply
     with the required rules (alignment, boundary, address range).
  
  MFC after:    1 week
  Reviewed by:  jah
  PR:           235542

Modified:
  head/sys/arm/arm/busdma_machdep-v6.c

Modified: head/sys/arm/arm/busdma_machdep-v6.c
==============================================================================
--- head/sys/arm/arm/busdma_machdep-v6.c        Sun Feb 10 14:02:14 2019        
(r343961)
+++ head/sys/arm/arm/busdma_machdep-v6.c        Sun Feb 10 14:25:29 2019        
(r343962)
@@ -339,16 +339,27 @@ cacheline_bounce(bus_dmamap_t map, bus_addr_t addr, bu
  *
  * Note that the addr argument might be either virtual or physical.  It doesn't
  * matter because we only look at the low-order bits, which are the same in 
both
- * address spaces.
+ * address spaces and maximum alignment of generic buffer is limited up to page
+ * size.
+ * Bouncing of buffers allocated by bus_dmamem_alloc()is not necessary, these
+ * always comply with the required rules (alignment, boundary, and address
+ * range).
  */
 static __inline int
 might_bounce(bus_dma_tag_t dmat, bus_dmamap_t map, bus_addr_t addr,
     bus_size_t size)
 {
 
-       return ((dmat->flags & BUS_DMA_EXCL_BOUNCE) ||
+       KASSERT(dmat->flags & DMAMAP_DMAMEM_ALLOC ||
+           dmat->alignment <= PAGE_SIZE,
+           ("%s: unsupported alignment (0x%08lx) for buffer not "
+           "allocated by bus_dmamem_alloc()",
+           __func__, dmat->alignment));
+
+       return (!(dmat->flags & DMAMAP_DMAMEM_ALLOC) &&
+           ((dmat->flags & BUS_DMA_EXCL_BOUNCE) ||
            alignment_bounce(dmat, addr) ||
-           cacheline_bounce(map, addr, size));
+           cacheline_bounce(map, addr, size)));
 }
 
 /*
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to