diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2014-07-06 14:32:31 -0400 |
---|---|---|
committer | Vinod Koul <vinod.koul@intel.com> | 2014-07-15 12:31:04 -0400 |
commit | 8ed30a14265fc2ebace02ea321c463facedfac17 (patch) | |
tree | 1b232a7fd73785cbc172e832776559822c6a9d2f /drivers/dma/pl330.c | |
parent | 9dc5a315fe515e92f40c387ae15f8b760568834e (diff) |
dmaengine: pl330: Simplify marking a request as unused
Instead of storing a special instruction in the command buffer to mark a request
as currently unused just set the descriptor field to NULL.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Diffstat (limited to 'drivers/dma/pl330.c')
-rw-r--r-- | drivers/dma/pl330.c | 51 |
1 files changed, 13 insertions, 38 deletions
diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index b31c6c380158..105e33e3bb33 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c | |||
@@ -245,9 +245,6 @@ enum pl330_byteswap { | |||
245 | */ | 245 | */ |
246 | #define MCODE_BUFF_PER_REQ 256 | 246 | #define MCODE_BUFF_PER_REQ 256 |
247 | 247 | ||
248 | /* If the _pl330_req is available to the client */ | ||
249 | #define IS_FREE(req) (*((u8 *)((req)->mc_cpu)) == CMD_DMAEND) | ||
250 | |||
251 | /* Use this _only_ to wait on transient states */ | 248 | /* Use this _only_ to wait on transient states */ |
252 | #define UNTIL(t, s) while (!(_state(t) & (s))) cpu_relax(); | 249 | #define UNTIL(t, s) while (!(_state(t) & (s))) cpu_relax(); |
253 | 250 | ||
@@ -529,14 +526,12 @@ struct _xfer_spec { | |||
529 | 526 | ||
530 | static inline bool _queue_empty(struct pl330_thread *thrd) | 527 | static inline bool _queue_empty(struct pl330_thread *thrd) |
531 | { | 528 | { |
532 | return (IS_FREE(&thrd->req[0]) && IS_FREE(&thrd->req[1])) | 529 | return thrd->req[0].desc == NULL && thrd->req[1].desc == NULL; |
533 | ? true : false; | ||
534 | } | 530 | } |
535 | 531 | ||
536 | static inline bool _queue_full(struct pl330_thread *thrd) | 532 | static inline bool _queue_full(struct pl330_thread *thrd) |
537 | { | 533 | { |
538 | return (IS_FREE(&thrd->req[0]) || IS_FREE(&thrd->req[1])) | 534 | return thrd->req[0].desc != NULL && thrd->req[1].desc != NULL; |
539 | ? false : true; | ||
540 | } | 535 | } |
541 | 536 | ||
542 | static inline bool is_manager(struct pl330_thread *thrd) | 537 | static inline bool is_manager(struct pl330_thread *thrd) |
@@ -948,21 +943,6 @@ static inline void _execute_DBGINSN(struct pl330_thread *thrd, | |||
948 | writel(0, regs + DBGCMD); | 943 | writel(0, regs + DBGCMD); |
949 | } | 944 | } |
950 | 945 | ||
951 | /* | ||
952 | * Mark a _pl330_req as free. | ||
953 | * We do it by writing DMAEND as the first instruction | ||
954 | * because no valid request is going to have DMAEND as | ||
955 | * its first instruction to execute. | ||
956 | */ | ||
957 | static void mark_free(struct pl330_thread *thrd, int idx) | ||
958 | { | ||
959 | struct _pl330_req *req = &thrd->req[idx]; | ||
960 | |||
961 | _emit_END(0, req->mc_cpu); | ||
962 | |||
963 | thrd->req_running = -1; | ||
964 | } | ||
965 | |||
966 | static inline u32 _state(struct pl330_thread *thrd) | 946 | static inline u32 _state(struct pl330_thread *thrd) |
967 | { | 947 | { |
968 | void __iomem *regs = thrd->dmac->base; | 948 | void __iomem *regs = thrd->dmac->base; |
@@ -1059,18 +1039,18 @@ static bool _trigger(struct pl330_thread *thrd) | |||
1059 | return true; | 1039 | return true; |
1060 | 1040 | ||
1061 | idx = 1 - thrd->lstenq; | 1041 | idx = 1 - thrd->lstenq; |
1062 | if (!IS_FREE(&thrd->req[idx])) | 1042 | if (thrd->req[idx].desc != NULL) { |
1063 | req = &thrd->req[idx]; | 1043 | req = &thrd->req[idx]; |
1064 | else { | 1044 | } else { |
1065 | idx = thrd->lstenq; | 1045 | idx = thrd->lstenq; |
1066 | if (!IS_FREE(&thrd->req[idx])) | 1046 | if (thrd->req[idx].desc != NULL) |
1067 | req = &thrd->req[idx]; | 1047 | req = &thrd->req[idx]; |
1068 | else | 1048 | else |
1069 | req = NULL; | 1049 | req = NULL; |
1070 | } | 1050 | } |
1071 | 1051 | ||
1072 | /* Return if no request */ | 1052 | /* Return if no request */ |
1073 | if (!req || !req->desc) | 1053 | if (!req) |
1074 | return true; | 1054 | return true; |
1075 | 1055 | ||
1076 | desc = req->desc; | 1056 | desc = req->desc; |
@@ -1438,7 +1418,7 @@ static int pl330_submit_req(struct pl330_thread *thrd, | |||
1438 | 1418 | ||
1439 | ccr = _prepare_ccr(&desc->rqcfg); | 1419 | ccr = _prepare_ccr(&desc->rqcfg); |
1440 | 1420 | ||
1441 | idx = IS_FREE(&thrd->req[0]) ? 0 : 1; | 1421 | idx = thrd->req[0].desc == NULL ? 0 : 1; |
1442 | 1422 | ||
1443 | xs.ccr = ccr; | 1423 | xs.ccr = ccr; |
1444 | xs.desc = desc; | 1424 | xs.desc = desc; |
@@ -1532,8 +1512,7 @@ static void pl330_dotask(unsigned long data) | |||
1532 | 1512 | ||
1533 | thrd->req[0].desc = NULL; | 1513 | thrd->req[0].desc = NULL; |
1534 | thrd->req[1].desc = NULL; | 1514 | thrd->req[1].desc = NULL; |
1535 | mark_free(thrd, 0); | 1515 | thrd->req_running = -1; |
1536 | mark_free(thrd, 1); | ||
1537 | 1516 | ||
1538 | /* Clear the reset flag */ | 1517 | /* Clear the reset flag */ |
1539 | pl330->dmac_tbd.reset_chan &= ~(1 << i); | 1518 | pl330->dmac_tbd.reset_chan &= ~(1 << i); |
@@ -1615,8 +1594,6 @@ static int pl330_update(struct pl330_dmac *pl330) | |||
1615 | descdone = thrd->req[active].desc; | 1594 | descdone = thrd->req[active].desc; |
1616 | thrd->req[active].desc = NULL; | 1595 | thrd->req[active].desc = NULL; |
1617 | 1596 | ||
1618 | mark_free(thrd, active); | ||
1619 | |||
1620 | /* Get going again ASAP */ | 1597 | /* Get going again ASAP */ |
1621 | _start(thrd); | 1598 | _start(thrd); |
1622 | 1599 | ||
@@ -1667,8 +1644,7 @@ static int pl330_chan_ctrl(struct pl330_thread *thrd, enum pl330_chan_op op) | |||
1667 | 1644 | ||
1668 | thrd->req[0].desc = NULL; | 1645 | thrd->req[0].desc = NULL; |
1669 | thrd->req[1].desc = NULL; | 1646 | thrd->req[1].desc = NULL; |
1670 | mark_free(thrd, 0); | 1647 | thrd->req_running = -1; |
1671 | mark_free(thrd, 1); | ||
1672 | break; | 1648 | break; |
1673 | 1649 | ||
1674 | case PL330_OP_ABORT: | 1650 | case PL330_OP_ABORT: |
@@ -1680,7 +1656,7 @@ static int pl330_chan_ctrl(struct pl330_thread *thrd, enum pl330_chan_op op) | |||
1680 | break; | 1656 | break; |
1681 | 1657 | ||
1682 | thrd->req[active].desc = NULL; | 1658 | thrd->req[active].desc = NULL; |
1683 | mark_free(thrd, active); | 1659 | thrd->req_running = -1; |
1684 | 1660 | ||
1685 | /* Start the next */ | 1661 | /* Start the next */ |
1686 | case PL330_OP_START: | 1662 | case PL330_OP_START: |
@@ -1741,9 +1717,8 @@ static struct pl330_thread *pl330_request_channel(struct pl330_dmac *pl330) | |||
1741 | thrd->free = false; | 1717 | thrd->free = false; |
1742 | thrd->lstenq = 1; | 1718 | thrd->lstenq = 1; |
1743 | thrd->req[0].desc = NULL; | 1719 | thrd->req[0].desc = NULL; |
1744 | mark_free(thrd, 0); | ||
1745 | thrd->req[1].desc = NULL; | 1720 | thrd->req[1].desc = NULL; |
1746 | mark_free(thrd, 1); | 1721 | thrd->req_running = -1; |
1747 | break; | 1722 | break; |
1748 | } | 1723 | } |
1749 | } | 1724 | } |
@@ -1841,14 +1816,14 @@ static inline void _reset_thread(struct pl330_thread *thrd) | |||
1841 | thrd->req[0].mc_bus = pl330->mcode_bus | 1816 | thrd->req[0].mc_bus = pl330->mcode_bus |
1842 | + (thrd->id * pl330->mcbufsz); | 1817 | + (thrd->id * pl330->mcbufsz); |
1843 | thrd->req[0].desc = NULL; | 1818 | thrd->req[0].desc = NULL; |
1844 | mark_free(thrd, 0); | ||
1845 | 1819 | ||
1846 | thrd->req[1].mc_cpu = thrd->req[0].mc_cpu | 1820 | thrd->req[1].mc_cpu = thrd->req[0].mc_cpu |
1847 | + pl330->mcbufsz / 2; | 1821 | + pl330->mcbufsz / 2; |
1848 | thrd->req[1].mc_bus = thrd->req[0].mc_bus | 1822 | thrd->req[1].mc_bus = thrd->req[0].mc_bus |
1849 | + pl330->mcbufsz / 2; | 1823 | + pl330->mcbufsz / 2; |
1850 | thrd->req[1].desc = NULL; | 1824 | thrd->req[1].desc = NULL; |
1851 | mark_free(thrd, 1); | 1825 | |
1826 | thrd->req_running = -1; | ||
1852 | } | 1827 | } |
1853 | 1828 | ||
1854 | static int dmac_alloc_threads(struct pl330_dmac *pl330) | 1829 | static int dmac_alloc_threads(struct pl330_dmac *pl330) |