svn commit: r289716 - head/sys/mips/mips

Ian Lepore ian at FreeBSD.org
Wed Oct 21 19:24:22 UTC 2015


Author: ian
Date: Wed Oct 21 19:24:20 2015
New Revision: 289716
URL: https://svnweb.freebsd.org/changeset/base/289716

Log:
  Treat mbufs as cacheline-aligned.  Even when the transfer begins at an
  offset within the buffer to align the L3 headers we know the buffer itself
  was allocated and sized on cacheline boundaries and we don't need to
  preserve partitial cachelines at the start and end of the buffer when
  doing busdma sync operations.

Modified:
  head/sys/mips/mips/busdma_machdep.c

Modified: head/sys/mips/mips/busdma_machdep.c
==============================================================================
--- head/sys/mips/mips/busdma_machdep.c	Wed Oct 21 19:16:13 2015	(r289715)
+++ head/sys/mips/mips/busdma_machdep.c	Wed Oct 21 19:24:20 2015	(r289716)
@@ -951,6 +951,8 @@ _bus_dmamap_load_buffer(bus_dma_tag_t dm
 
 	if (segs == NULL)
 		segs = dmat->segments;
+	if ((flags & BUS_DMA_LOAD_MBUF) != 0)
+		map->flags |= DMAMAP_CACHE_ALIGNED;
 
 	if ((dmat->flags & BUS_DMA_COULD_BOUNCE) != 0) {
 		_bus_dmamap_count_pages(dmat, map, pmap, buf, buflen, flags);
@@ -1071,10 +1073,16 @@ bus_dmamap_sync_buf(vm_offset_t buf, int
 	 * prevent a data loss we save these chunks in temporary buffer
 	 * before invalidation and restore them afer it.
 	 *
-	 * If the aligned flag is set the buffer came from our allocator caches
-	 * which are always sized and aligned to cacheline boundaries, so we can
-	 * skip preserving nearby data if a transfer is unaligned (especially
-	 * it's likely to not end on a boundary).
+	 * If the aligned flag is set the buffer is either an mbuf or came from
+	 * our allocator caches.  In both cases they are always sized and
+	 * aligned to cacheline boundaries, so we can skip preserving nearby
+	 * data if a transfer appears to overlap cachelines.  An mbuf in
+	 * particular will usually appear to be overlapped because of offsetting
+	 * within the buffer to align the L3 headers, but we know that the bytes
+	 * preceeding that offset are part of the same mbuf memory and are not
+	 * unrelated adjacent data (and a rule of mbuf handling is that the cpu
+	 * is not allowed to touch the mbuf while dma is in progress, including
+	 * header fields).
 	 */
 	if (aligned) {
 		size_cl = 0;


More information about the svn-src-head mailing list