aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/dma/dmaengine.c
diff options
context:
space:
mode:
authorChristoph Lameter <cl@linux-foundation.org>2009-10-03 06:48:23 -0400
committerTejun Heo <tj@kernel.org>2009-10-03 06:48:23 -0400
commite7dcaa4755e35d7540bf19f316f8798357c53fa0 (patch)
tree69c41151378213382199b577f2bc7b0d8bd1cc22 /drivers/dma/dmaengine.c
parentca0c9584b1f16bd5911893647cb7f1be82e60554 (diff)
this_cpu: Eliminate get/put_cpu
There are cases where we can use this_cpu_ptr and as the result of using this_cpu_ptr() we no longer need to determine the currently executing cpu. In those places no get/put_cpu combination is needed anymore. The local cpu variable can be eliminated. Preemption still needs to be disabled and enabled since the modifications of the per cpu variables is not atomic. There may be multiple per cpu variables modified and those must all be from the same processor. Acked-by: Maciej Sosnowski <maciej.sosnowski@intel.com> Acked-by: Dan Williams <dan.j.williams@intel.com> Acked-by: Tejun Heo <tj@kernel.org> cc: Eric Biederman <ebiederm@aristanetworks.com> cc: Stephen Hemminger <shemminger@vyatta.com> cc: David L Stevens <dlstevens@us.ibm.com> Signed-off-by: Christoph Lameter <cl@linux-foundation.org> Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'drivers/dma/dmaengine.c')
-rw-r--r--drivers/dma/dmaengine.c36
1 files changed, 13 insertions, 23 deletions
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index bd0b248de2cf..51d7480d3a92 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -326,14 +326,7 @@ arch_initcall(dma_channel_table_init);
326 */ 326 */
327struct dma_chan *dma_find_channel(enum dma_transaction_type tx_type) 327struct dma_chan *dma_find_channel(enum dma_transaction_type tx_type)
328{ 328{
329 struct dma_chan *chan; 329 return this_cpu_read(channel_table[tx_type]->chan);
330 int cpu;
331
332 cpu = get_cpu();
333 chan = per_cpu_ptr(channel_table[tx_type], cpu)->chan;
334 put_cpu();
335
336 return chan;
337} 330}
338EXPORT_SYMBOL(dma_find_channel); 331EXPORT_SYMBOL(dma_find_channel);
339 332
@@ -847,7 +840,6 @@ dma_async_memcpy_buf_to_buf(struct dma_chan *chan, void *dest,
847 struct dma_async_tx_descriptor *tx; 840 struct dma_async_tx_descriptor *tx;
848 dma_addr_t dma_dest, dma_src; 841 dma_addr_t dma_dest, dma_src;
849 dma_cookie_t cookie; 842 dma_cookie_t cookie;
850 int cpu;
851 unsigned long flags; 843 unsigned long flags;
852 844
853 dma_src = dma_map_single(dev->dev, src, len, DMA_TO_DEVICE); 845 dma_src = dma_map_single(dev->dev, src, len, DMA_TO_DEVICE);
@@ -866,10 +858,10 @@ dma_async_memcpy_buf_to_buf(struct dma_chan *chan, void *dest,
866 tx->callback = NULL; 858 tx->callback = NULL;
867 cookie = tx->tx_submit(tx); 859 cookie = tx->tx_submit(tx);
868 860
869 cpu = get_cpu(); 861 preempt_disable();
870 per_cpu_ptr(chan->local, cpu)->bytes_transferred += len; 862 __this_cpu_add(chan->local->bytes_transferred, len);
871 per_cpu_ptr(chan->local, cpu)->memcpy_count++; 863 __this_cpu_inc(chan->local->memcpy_count);
872 put_cpu(); 864 preempt_enable();
873 865
874 return cookie; 866 return cookie;
875} 867}
@@ -896,7 +888,6 @@ dma_async_memcpy_buf_to_pg(struct dma_chan *chan, struct page *page,
896 struct dma_async_tx_descriptor *tx; 888 struct dma_async_tx_descriptor *tx;
897 dma_addr_t dma_dest, dma_src; 889 dma_addr_t dma_dest, dma_src;
898 dma_cookie_t cookie; 890 dma_cookie_t cookie;
899 int cpu;
900 unsigned long flags; 891 unsigned long flags;
901 892
902 dma_src = dma_map_single(dev->dev, kdata, len, DMA_TO_DEVICE); 893 dma_src = dma_map_single(dev->dev, kdata, len, DMA_TO_DEVICE);
@@ -913,10 +904,10 @@ dma_async_memcpy_buf_to_pg(struct dma_chan *chan, struct page *page,
913 tx->callback = NULL; 904 tx->callback = NULL;
914 cookie = tx->tx_submit(tx); 905 cookie = tx->tx_submit(tx);
915 906
916 cpu = get_cpu(); 907 preempt_disable();
917 per_cpu_ptr(chan->local, cpu)->bytes_transferred += len; 908 __this_cpu_add(chan->local->bytes_transferred, len);
918 per_cpu_ptr(chan->local, cpu)->memcpy_count++; 909 __this_cpu_inc(chan->local->memcpy_count);
919 put_cpu(); 910 preempt_enable();
920 911
921 return cookie; 912 return cookie;
922} 913}
@@ -945,7 +936,6 @@ dma_async_memcpy_pg_to_pg(struct dma_chan *chan, struct page *dest_pg,
945 struct dma_async_tx_descriptor *tx; 936 struct dma_async_tx_descriptor *tx;
946 dma_addr_t dma_dest, dma_src; 937 dma_addr_t dma_dest, dma_src;
947 dma_cookie_t cookie; 938 dma_cookie_t cookie;
948 int cpu;
949 unsigned long flags; 939 unsigned long flags;
950 940
951 dma_src = dma_map_page(dev->dev, src_pg, src_off, len, DMA_TO_DEVICE); 941 dma_src = dma_map_page(dev->dev, src_pg, src_off, len, DMA_TO_DEVICE);
@@ -963,10 +953,10 @@ dma_async_memcpy_pg_to_pg(struct dma_chan *chan, struct page *dest_pg,
963 tx->callback = NULL; 953 tx->callback = NULL;
964 cookie = tx->tx_submit(tx); 954 cookie = tx->tx_submit(tx);
965 955
966 cpu = get_cpu(); 956 preempt_disable();
967 per_cpu_ptr(chan->local, cpu)->bytes_transferred += len; 957 __this_cpu_add(chan->local->bytes_transferred, len);
968 per_cpu_ptr(chan->local, cpu)->memcpy_count++; 958 __this_cpu_inc(chan->local->memcpy_count);
969 put_cpu(); 959 preempt_enable();
970 960
971 return cookie; 961 return cookie;
972} 962}