PERFORCE change 183321 for review

Jakub Wojciech Klama jceel at FreeBSD.org
Fri Sep 3 21:51:10 UTC 2010


http://p4web.freebsd.org/@@183321?ac=10

Change 183321 by jceel at jceel on 2010/09/03 21:50:34

	Move syncing DMA maps and calling transfer callbacks from DMA engine
	driver to GPDMA framework.

Affected files ...

.. //depot/projects/soc2010/jceel_dma/sys/arm/davinci/davinci_edma.c#8 edit
.. //depot/projects/soc2010/jceel_dma/sys/dev/gpdma/gpdma.c#5 edit
.. //depot/projects/soc2010/jceel_dma/sys/dev/gpdma/gpdma.h#5 edit

Differences ...

==== //depot/projects/soc2010/jceel_dma/sys/arm/davinci/davinci_edma.c#8 (text+ko) ====

@@ -71,7 +71,7 @@
 #include "gpdma_if.h"
 
 #define	DEBUG
-#undef	DEBUG
+//#undef	DEBUG
 #ifdef	DEBUG
 #define	debugf(fmt, args...) do { \
 	            printf("edma: " fmt "\n", ##args); } while (0)
@@ -456,23 +456,8 @@
 
 			KASSERT(ch->dc_status != CHANNEL_IDLE, ("invalid channel state"));
 
-			if (xfer->dt_src.db_needsync) {
-				bus_dmamap_sync(xfer->dt_src.db_dmatag,
-				    xfer->dt_src.db_dmamap, 
-				    BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
-			}
+			gpdma_transfer_done(xfer, GPDMA_TRANSFER_COMPLETED);
 
-			if (xfer->dt_dst.db_needsync) {
-				bus_dmamap_sync(xfer->dt_dst.db_dmatag, 
-				    xfer->dt_dst.db_dmamap,
-				    BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTWRITE);
-			}
-
-			if (xfer->dt_callback != NULL) {
-				xfer->dt_callback(GPDMA_TRANSFER_COMPLETED,
-				    xfer->dt_callback_arg);
-			}
-		
 			if (chno > 32) 
 				davinci_write_edmacc_4(sc, DAVINCI_EDMACC_ICRH, (1 << (chno - 32)));
 			else
@@ -518,10 +503,7 @@
 
 		KASSERT(ch->dc_status != CHANNEL_IDLE, ("invalid channel state"));
 
-		if (xfer->dt_callback != NULL) {
-			xfer->dt_callback(GPDMA_TRANSFER_ERROR,
-			    xfer->dt_callback_arg);
-		}
+		gpdma_transfer_done(xfer, GPDMA_TRANSFER_ERROR);
 		
 		ch->dc_status = CHANNEL_IDLE;
 	
@@ -553,8 +535,6 @@
 static void
 davinci_edma_tcerr(struct davinci_edma_softc *sc, int tc)
 {
-//	struct davinci_edma_channel *ch;
-//	struct gpdma_transfer *xfer;
 	uint32_t errstat, errdet;
 	int chno;
 
@@ -575,9 +555,6 @@
 	device_printf(sc->ds_dev, "Transfer descriptor that has failed:\n");
 	davinci_edma_printdesc(sc, chno);
 
-//	ch = &sc->ds_channels[chno];
-//	xfer = ch->dc_xfer;
-
 	panic("DMA transfer controller error");
 }
 

==== //depot/projects/soc2010/jceel_dma/sys/dev/gpdma/gpdma.c#5 (text+ko) ====

@@ -46,7 +46,7 @@
 #include "gpdma_if.h"
 
 #define	DEBUG
-#undef	DEBUG
+//#undef	DEBUG
 #ifdef	DEBUG
 #define	debugf(fmt, args...) do { \
 	    printf("gpdma: " fmt "\n", ##args); } while (0)
@@ -356,6 +356,33 @@
 	free(xfer, M_GPDMA);
 }
 
+void
+gpdma_transfer_done(struct gpdma_transfer *xfer, int status)
+{
+	if (xfer->dt_src.db_needsync) {
+		bus_dmamap_sync(xfer->dt_src.db_dmatag,
+		    xfer->dt_src.db_dmamap, 
+		    BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
+		bus_dmamap_unload(xfer->dt_src.db_dmatag,
+		    xfer->dt_src.db_dmamap);
+		bus_dmamap_destroy(xfer->dt_src.db_dmatag,
+		    xfer->dt_src.db_dmamap);
+	}
+
+	if (xfer->dt_dst.db_needsync) {
+		bus_dmamap_sync(xfer->dt_dst.db_dmatag, 
+		    xfer->dt_dst.db_dmamap,
+		    BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTWRITE);
+		bus_dmamap_unload(xfer->dt_dst.db_dmatag,
+		    xfer->dt_src.db_dmamap);
+		bus_dmamap_destroy(xfer->dt_dst.db_dmatag,
+		    xfer->dt_dst.db_dmamap);
+	}
+
+	if (xfer->dt_callback != NULL)
+		xfer->dt_callback(status, xfer->dt_callback_arg);
+}
+
 int 
 gpdma_load_buffer_raw(struct gpdma_transfer *xfer, int buffer,
     bus_addr_t paddr, bus_size_t length)

==== //depot/projects/soc2010/jceel_dma/sys/dev/gpdma/gpdma.h#5 (text+ko) ====

@@ -161,6 +161,8 @@
 int gpdma_stop_transfer(void *);
 int gpdma_get_transfer_status(void *);
 
+void gpdma_transfer_done(struct gpdma_transfer *, int);
+
 int gpdma_load_buffer_raw(gpdma_transfer_t, int, bus_addr_t, bus_size_t);
 int gpdma_load_buffer_virt(gpdma_transfer_t, int, void *, size_t);
 int gpdma_load_buffer_uio(gpdma_transfer_t, int, struct uio *);


More information about the p4-projects mailing list