Date: Sat, 20 Jun 2015 12:47:38 GMT From: pratiksinghal@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r287378 - soc2015/pratiksinghal/cubie-head/sys/arm/allwinner Message-ID: <201506201247.t5KClc3E023586@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pratiksinghal Date: Sat Jun 20 12:47:38 2015 New Revision: 287378 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=287378 Log: 1) Cleaned up unused variables from softc 2) Corrected the handling of length in prepare function 3) Corrected the post i/o sync operations. Modified: soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c Modified: soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c ============================================================================== --- soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c Sat Jun 20 12:15:08 2015 (r287377) +++ soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c Sat Jun 20 12:47:38 2015 (r287378) @@ -85,19 +85,16 @@ int a10_use_dma ; /* Fields required for DMA access */ - uint32_t a10_dma_xfer_len ; - bus_dma_segment_t* a10_dma_segs ; - int a10_dma_nsegs ; - bus_size_t a10_dma_size ; struct a10_mmc_cb a10_dma_cb_arg ; bus_dmamap_t a10_dma_map ; bus_dma_tag_t a10_dma_tag ; - int a10_dma_ndesc; void* a10_dma_desc ; int a10_dma_ops ; bus_dma_tag_t a10_dma_buff_tag ; bus_dmamap_t a10_dma_buff_map ; bus_addr_t a10_dma_buff_addrs[A10_DMA_NSEGS] ; + bus_size_t a10_dma_buff_sizes[A10_DMA_NSEGS] ; + uint32_t a10_dma_nsegs ; }; @@ -230,7 +227,7 @@ sc->a10_use_dma = 0 ; } } - sc->a10_dma_buff_addrs[0] = 0; + sc->a10_dma_nsegs = 0 ; #ifdef DEBUG device_printf(sc->a10_dev, "DMA status %d\n", sc->a10_use_dma) ; #endif @@ -248,15 +245,13 @@ static int a10_mmc_setup_dma(struct a10_mmc_softc* sc, device_t dev) { - sc->a10_dma_xfer_len = 0x2000 ; - sc->a10_dma_ndesc = A10_MMC_NDESC ; - sc->a10_dma_size = sizeof(struct a10_mmc_dma_desc)*(sc->a10_dma_ndesc) ; + uint32_t a10_dma_size = sizeof(struct a10_mmc_dma_desc)*(A10_MMC_NDESC); uint32_t error ; error = bus_dma_tag_create(bus_get_dma_tag(dev),1, - sc->a10_dma_size,BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, - NULL,NULL,sc->a10_dma_size, - 1,sc->a10_dma_size,0, + a10_dma_size,BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, + NULL,NULL,a10_dma_size, + 1,a10_dma_size,0, NULL,NULL,&sc->a10_dma_tag) ; if (error) return (error) ; @@ -264,7 +259,7 @@ if (error) return (error) ; - error = bus_dmamap_load(sc->a10_dma_tag, sc->a10_dma_map,sc->a10_dma_desc,sc->a10_dma_size,a10_dma_cb, &sc->a10_dma_cb_arg,0) ; + error = bus_dmamap_load(sc->a10_dma_tag, sc->a10_dma_map,sc->a10_dma_desc,a10_dma_size,a10_dma_cb, &sc->a10_dma_cb_arg,0) ; if ((error != 0)&&(error != EINPROGRESS)) return (error) ; @@ -300,9 +295,9 @@ rem = min(len,cmd->data->len) ; uint32_t error = bus_dmamap_load(sc->a10_dma_buff_tag, sc->a10_dma_buff_map, cmd->data->data,rem,a10_dma_buff_cb, - sc->a10_dma_buff_addrs,0) ; + &sc->a10_dma_nsegs,0) ; if (error == EINPROGRESS) { - for( ; sc->a10_dma_buff_addrs[0] == 0 ; ) { } + for( ; sc->a10_dma_nsegs == 0 ; ) { } } else if (error != 0) { device_printf(sc->a10_dev, "DMA transaction failed due to insufficient resources\n") ; @@ -310,11 +305,10 @@ } while (rem > 0) { - if (desc == sc->a10_dma_ndesc) + if (desc == A10_MMC_NDESC) break ; - len = min(sc->a10_dma_xfer_len, rem) ; + len = min(sc->a10_dma_buff_sizes[desc], rem) ; dma[desc].buff_size = htole32(len) ; - device_printf(sc->a10_dev, "The address is %lu\n", sc->a10_dma_buff_addrs[desc]) ; dma[desc].buff_addr = htole32(sc->a10_dma_buff_addrs[desc]) ; dma[desc].config = htole32(A10_MMC_DMA_CONFIG_CH|A10_MMC_DMA_CONFIG_OWN) ; @@ -336,8 +330,8 @@ desc++ ; } - if ((desc == sc->a10_dma_ndesc) && (rem > 0)) { - device_printf(sc->a10_dev, "Couldn't find enough descriptors for DMA transfer! desc = %d,sc->a10_dma_ndesc = %d\n",desc, sc->a10_dma_ndesc) ; + if ((desc == A10_MMC_NDESC) && (rem > 0)) { + device_printf(sc->a10_dev, "Couldn't find enough descriptors for DMA transfer! desc = %d,A10_MMC_NDESC = %d\n",desc, A10_MMC_NDESC) ; return EIO ; } @@ -374,7 +368,8 @@ static int a10_mmc_can_do_dma(struct mmc_request* req) { - if ((req->cmd->data->len > A10_MMC_DMA_MAXLEN) || (req->cmd->data->len <= A10_MMC_DMA_MINLEN)) + if (req->cmd->data->len > A10_MMC_DMA_MAXLEN) + //if ((req->cmd->data->len > A10_MMC_DMA_MAXLEN) || (req->cmd->data->len <= A10_MMC_DMA_MINLEN)) return (0) ; else return (1) ; @@ -398,10 +393,12 @@ printf("a10_mmc: Error in a10_dma_buff_callback function, code = %d\n", error) ; return ; } - bus_addr_t* ptr = (bus_addr_t*) arg ; - int i = 0; - for(i=0; i<nsegs; i++) - ptr[i] = segs[i].ds_addr ; + int i ; + *(uint32_t*)arg = nsegs ; + for(i=0; i<nsegs; i++) { + sc->a10_dma_buff_addrs[i] = segs[i].ds_addr ; + sc->a10_dma_buff_sizes[i] = segs[i].ds_len ; + } } static int @@ -465,7 +462,7 @@ sc->a10_resid = 0; sc->a10_idst = 0 ; sc->a10_intr_wait = 0; - sc->a10_dma_buff_addrs[0] = 0 ; + sc->a10_dma_nsegs = 0 ; req->done(req); } @@ -594,9 +591,9 @@ if ((idst & A10_MMC_IDMAC_COMPLETE) && ((sc->a10_intr & sc->a10_intr_wait) == sc->a10_intr_wait)) { if (sc->a10_dma_ops == 0) - bus_dmamap_sync(sc->a10_dma_tag, sc->a10_dma_map, BUS_DMASYNC_POSTREAD) ; + bus_dmamap_sync(sc->a10_dma_buff_tag, sc->a10_dma_buff_map, BUS_DMASYNC_POSTREAD) ; else if (sc->a10_dma_ops == 1) - bus_dmamap_sync(sc->a10_dma_tag, sc->a10_dma_map, BUS_DMASYNC_POSTWRITE) ; + bus_dmamap_sync(sc->a10_dma_buff_tag, sc->a10_dma_buff_map, BUS_DMASYNC_POSTWRITE) ; else device_printf(sc->a10_dev, "Invalid operations request!\n") ; bus_dmamap_unload(sc->a10_dma_buff_tag, sc->a10_dma_buff_map) ;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201506201247.t5KClc3E023586>