Date: Wed, 27 May 2015 23:58:59 GMT From: pratiksinghal@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286264 - soc2015/pratiksinghal/cubie-head/sys/arm/allwinner Message-ID: <201505272358.t4RNwx7R081319@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pratiksinghal Date: Wed May 27 23:58:59 2015 New Revision: 286264 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286264 Log: Added locks in a10_dma for controller Modified: soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_dma.c soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_dma.h soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c Modified: soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_dma.c ============================================================================== --- soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_dma.c Wed May 27 22:30:21 2015 (r286263) +++ soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_dma.c Wed May 27 23:58:59 2015 (r286264) @@ -47,6 +47,7 @@ } ; struct a10_dma_controller { + struct mtx a10_controller_mtx ; struct a10_dma_softc* sc ; struct a10_dma_channel ddma_channels[NDDMA] ; struct a10_dma_channel ndma_channels[NNDMA] ; @@ -86,7 +87,7 @@ sc->a10_dma_dev = dev ; mtx_init(&sc->a10_dma_mtx, device_get_nameunit(sc->a10_dma_dev),"a10_dma", MTX_DEF) ; - + mtx_init(&a10_dma_cnt->a10_controller_mtx, "A10 DMA controller", "a10_dma_controller", MTX_DEF) ; sc->a10_dma_mem_resource = bus_alloc_resource_any(sc->a10_dma_dev, SYS_RES_MEMORY, &sc->a10_dma_mem_rid, RF_ACTIVE) ; if(sc->a10_dma_mem_resource == NULL) { @@ -163,7 +164,6 @@ a10_get_ddma_channel() { uint8_t pos = NDDMA + 1 ; - if(a10_dma_cnt->nddma_channels_in_use >= NDDMA) return (pos) ; @@ -176,10 +176,11 @@ if(pos > NDDMA) return (pos) ; - + a10_controller_lock(a10_dma_cnt) ; a10_dma_cnt->ddma_channels[pos].in_use = 1 ; a10_dma_cnt->nddma_channels_in_use++ ; - a10_dma_cnt->ddma_channels[pos].a10_dma_channel_type = DDMA ; + a10_dma_cnt->ddma_channels[pos].a10_dma_channel_type = DDMA ; + a10_controller_unlock(a10_dma_cnt) ; return pos ; } @@ -190,8 +191,10 @@ device_printf(a10_dma_cnt->sc->a10_dma_dev, "Invalid position %u while freeing dma channel!\n",pos) ; return ; } + a10_controller_lock(a10_dma_cnt) ; a10_dma_cnt->ddma_channels[pos].in_use = 0 ; a10_dma_cnt->nddma_channels_in_use-- ; + a10_controller_unlock(a10_dma_cnt) ; device_printf(a10_dma_cnt->sc->a10_dma_dev, "Freed DDMA Channel no %u\n", pos) ; } Modified: soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_dma.h ============================================================================== --- soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_dma.h Wed May 27 22:30:21 2015 (r286263) +++ soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_dma.h Wed May 27 23:58:59 2015 (r286264) @@ -51,6 +51,9 @@ #define a10_dma_lock(_sc) mtx_lock(&(_sc)->a10_dma_mtx) #define a10_dma_unlock(_sc) mtx_unlock(&(_sc)->a10_dma_mtx) +#define a10_controller_lock(_sc) mtx_lock(&(_sc)->a10_controller_mtx) +#define a10_controller_unlock(_sc) mtx_unlock(&(_sc)->a10_controller_mtx) + /* Helper Macros */ #define SET_BIT(n) (1 << (n)) Modified: soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c ============================================================================== --- soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c Wed May 27 22:30:21 2015 (r286263) +++ soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c Wed May 27 23:58:59 2015 (r286264) @@ -62,6 +62,7 @@ struct a10_mmc_softc { bus_space_handle_t a10_bsh; bus_space_tag_t a10_bst; + //bus_dma_tag_t a10_dmat ; device_t a10_dev; int a10_bus_busy; int a10_id; @@ -190,7 +191,17 @@ goto fail; } sc->ddma_channel = NDDMA + 1 ; - sc->use_dma = 0 ; + sc->use_dma = 0 ; + + // /* Setup DMA */ + // uint32_t err = bus_dma_tag_create(bus_get_dma_tag(dev), 4096,0, + // BUS_SPACE_MAXADDR,BUS_SPACE_MAXADDR,NULL,NULL, + // BUS_SPACE_UNRESTRICTED,1,PAGE_SIZE,0, + // busdma_lock_mutex,&sc->sc_mtx,&sc->a10_dmat) ; + // if(err) { + // device_printf(dev, "Could not create dma tag.\n"); + // goto fail ; + // } return (0); fail: @@ -691,7 +702,7 @@ static void a10_mmc_init_dma(device_t parent) { /* Identify the parent tag. */ - bus_dma_tag_t parent_tag = bus_get_dma_tag(parent) ; + //bus_dma_tag_t parent_tag = bus_get_dma_tag(parent) ; /*TODO :- Create children dma tags and maps and initiate the dma transfer. */ }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201505272358.t4RNwx7R081319>