svn commit: r330191 - stable/11/sys/dev/iwm

Eitan Adler eadler at FreeBSD.org
Thu Mar 1 06:20:18 UTC 2018


Author: eadler
Date: Thu Mar  1 06:20:16 2018
New Revision: 330191
URL: https://svnweb.freebsd.org/changeset/base/330191

Log:
  MFC r314082:
  
  [iwm] Move iwm_dma_contig_alloc/_free functions to if_iwm_util.c.

Modified:
  stable/11/sys/dev/iwm/if_iwm.c
  stable/11/sys/dev/iwm/if_iwm_util.c
  stable/11/sys/dev/iwm/if_iwm_util.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/iwm/if_iwm.c
==============================================================================
--- stable/11/sys/dev/iwm/if_iwm.c	Thu Mar  1 06:19:53 2018	(r330190)
+++ stable/11/sys/dev/iwm/if_iwm.c	Thu Mar  1 06:20:16 2018	(r330191)
@@ -239,10 +239,6 @@ static int	iwm_firmware_store_section(struct iwm_softc
 static int	iwm_set_default_calib(struct iwm_softc *, const void *);
 static void	iwm_fw_info_free(struct iwm_fw_info *);
 static int	iwm_read_firmware(struct iwm_softc *, enum iwm_ucode_type);
-static void	iwm_dma_map_addr(void *, bus_dma_segment_t *, int, int);
-static int	iwm_dma_contig_alloc(bus_dma_tag_t, struct iwm_dma_info *,
-                                     bus_size_t, bus_size_t);
-static void	iwm_dma_contig_free(struct iwm_dma_info *);
 static int	iwm_alloc_fwmem(struct iwm_softc *);
 static int	iwm_alloc_sched(struct iwm_softc *);
 static int	iwm_alloc_kw(struct iwm_softc *);
@@ -892,71 +888,6 @@ iwm_read_firmware(struct iwm_softc *sc, enum iwm_ucode
 /*
  * DMA resource routines
  */
-
-static void
-iwm_dma_map_addr(void *arg, bus_dma_segment_t *segs, int nsegs, int error)
-{
-        if (error != 0)
-                return;
-	KASSERT(nsegs == 1, ("too many DMA segments, %d should be 1", nsegs));
-	*(bus_addr_t *)arg = segs[0].ds_addr;
-}
-
-static int
-iwm_dma_contig_alloc(bus_dma_tag_t tag, struct iwm_dma_info *dma,
-    bus_size_t size, bus_size_t alignment)
-{
-	int error;
-
-	dma->tag = NULL;
-	dma->map = NULL;
-	dma->size = size;
-	dma->vaddr = NULL;
-
-	error = bus_dma_tag_create(tag, alignment,
-            0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, size,
-            1, size, 0, NULL, NULL, &dma->tag);
-        if (error != 0)
-                goto fail;
-
-        error = bus_dmamem_alloc(dma->tag, (void **)&dma->vaddr,
-            BUS_DMA_NOWAIT | BUS_DMA_ZERO | BUS_DMA_COHERENT, &dma->map);
-        if (error != 0)
-                goto fail;
-
-        error = bus_dmamap_load(dma->tag, dma->map, dma->vaddr, size,
-            iwm_dma_map_addr, &dma->paddr, BUS_DMA_NOWAIT);
-        if (error != 0) {
-		bus_dmamem_free(dma->tag, dma->vaddr, dma->map);
-		dma->vaddr = NULL;
-		goto fail;
-	}
-
-	bus_dmamap_sync(dma->tag, dma->map, BUS_DMASYNC_PREWRITE);
-
-	return 0;
-
-fail:
-	iwm_dma_contig_free(dma);
-
-	return error;
-}
-
-static void
-iwm_dma_contig_free(struct iwm_dma_info *dma)
-{
-	if (dma->vaddr != NULL) {
-		bus_dmamap_sync(dma->tag, dma->map,
-		    BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
-		bus_dmamap_unload(dma->tag, dma->map);
-		bus_dmamem_free(dma->tag, dma->vaddr, dma->map);
-		dma->vaddr = NULL;
-	}
-	if (dma->tag != NULL) {
-		bus_dma_tag_destroy(dma->tag);
-		dma->tag = NULL;
-	}
-}
 
 /* fwmem is used to load firmware onto the card */
 static int

Modified: stable/11/sys/dev/iwm/if_iwm_util.c
==============================================================================
--- stable/11/sys/dev/iwm/if_iwm_util.c	Thu Mar  1 06:19:53 2018	(r330190)
+++ stable/11/sys/dev/iwm/if_iwm_util.c	Thu Mar  1 06:20:16 2018	(r330191)
@@ -421,3 +421,68 @@ iwm_free_resp(struct iwm_softc *sc, struct iwm_host_cm
 	sc->sc_wantresp = -1;
 	wakeup(&sc->sc_wantresp);
 }
+
+static void
+iwm_dma_map_addr(void *arg, bus_dma_segment_t *segs, int nsegs, int error)
+{
+        if (error != 0)
+                return;
+	KASSERT(nsegs == 1, ("too many DMA segments, %d should be 1", nsegs));
+	*(bus_addr_t *)arg = segs[0].ds_addr;
+}
+
+int
+iwm_dma_contig_alloc(bus_dma_tag_t tag, struct iwm_dma_info *dma,
+    bus_size_t size, bus_size_t alignment)
+{
+	int error;
+
+	dma->tag = NULL;
+	dma->map = NULL;
+	dma->size = size;
+	dma->vaddr = NULL;
+
+	error = bus_dma_tag_create(tag, alignment,
+            0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, size,
+            1, size, 0, NULL, NULL, &dma->tag);
+        if (error != 0)
+                goto fail;
+
+        error = bus_dmamem_alloc(dma->tag, (void **)&dma->vaddr,
+            BUS_DMA_NOWAIT | BUS_DMA_ZERO | BUS_DMA_COHERENT, &dma->map);
+        if (error != 0)
+                goto fail;
+
+        error = bus_dmamap_load(dma->tag, dma->map, dma->vaddr, size,
+            iwm_dma_map_addr, &dma->paddr, BUS_DMA_NOWAIT);
+        if (error != 0) {
+		bus_dmamem_free(dma->tag, dma->vaddr, dma->map);
+		dma->vaddr = NULL;
+		goto fail;
+	}
+
+	bus_dmamap_sync(dma->tag, dma->map, BUS_DMASYNC_PREWRITE);
+
+	return 0;
+
+fail:
+	iwm_dma_contig_free(dma);
+
+	return error;
+}
+
+void
+iwm_dma_contig_free(struct iwm_dma_info *dma)
+{
+	if (dma->vaddr != NULL) {
+		bus_dmamap_sync(dma->tag, dma->map,
+		    BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
+		bus_dmamap_unload(dma->tag, dma->map);
+		bus_dmamem_free(dma->tag, dma->vaddr, dma->map);
+		dma->vaddr = NULL;
+	}
+	if (dma->tag != NULL) {
+		bus_dma_tag_destroy(dma->tag);
+		dma->tag = NULL;
+	}
+}

Modified: stable/11/sys/dev/iwm/if_iwm_util.h
==============================================================================
--- stable/11/sys/dev/iwm/if_iwm_util.h	Thu Mar  1 06:19:53 2018	(r330190)
+++ stable/11/sys/dev/iwm/if_iwm_util.h	Thu Mar  1 06:20:16 2018	(r330191)
@@ -116,6 +116,10 @@ extern	int iwm_mvm_send_cmd_pdu_status(struct iwm_soft
 	uint16_t len, const void *data, uint32_t *status);
 extern	void iwm_free_resp(struct iwm_softc *sc, struct iwm_host_cmd *hcmd);
 
+extern	int iwm_dma_contig_alloc(bus_dma_tag_t tag, struct iwm_dma_info *dma,
+				 bus_size_t size, bus_size_t alignment);
+extern	void iwm_dma_contig_free(struct iwm_dma_info *);
+
 static inline uint8_t
 iwm_mvm_get_valid_tx_ant(struct iwm_softc *sc)
 {


More information about the svn-src-all mailing list