diff options
author | Manuel Lauss <manuel.lauss@googlemail.com> | 2009-10-13 14:22:35 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2010-02-27 06:52:55 -0500 |
commit | 963accbc82a0912b39de39d59e2fd6741db3aa4b (patch) | |
tree | 4ea340b0261ab19f3f0776f47e4fab8708934b5b | |
parent | ea071cc705e8bfba0c8bf84be8d4f9f4e9da6962 (diff) |
MIPS: Alchemy: change dbdma to accept physical memory addresses
DMA can only be done from physical addresses; move the "virt_to_phys"
source/destination buffer address translation from the dbdma queueing
functions (since the hardware can only DMA to/from physical addresses)
to their respective users.
Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r-- | arch/mips/alchemy/common/dbdma.c | 8 | ||||
-rw-r--r-- | arch/mips/include/asm/mach-au1x00/au1xxx_dbdma.h | 4 | ||||
-rw-r--r-- | drivers/ide/au1xxx-ide.c | 8 | ||||
-rw-r--r-- | drivers/mmc/host/au1xmmc.c | 4 | ||||
-rw-r--r-- | drivers/spi/au1550_spi.c | 4 | ||||
-rw-r--r-- | sound/oss/au1550_ac97.c | 12 | ||||
-rw-r--r-- | sound/soc/au1x/dbdma2.c | 12 |
7 files changed, 26 insertions, 26 deletions
diff --git a/arch/mips/alchemy/common/dbdma.c b/arch/mips/alchemy/common/dbdma.c index 864b6dab636..3b2ccc05e20 100644 --- a/arch/mips/alchemy/common/dbdma.c +++ b/arch/mips/alchemy/common/dbdma.c | |||
@@ -571,7 +571,7 @@ EXPORT_SYMBOL(au1xxx_dbdma_ring_alloc); | |||
571 | * This updates the source pointer and byte count. Normally used | 571 | * This updates the source pointer and byte count. Normally used |
572 | * for memory to fifo transfers. | 572 | * for memory to fifo transfers. |
573 | */ | 573 | */ |
574 | u32 au1xxx_dbdma_put_source(u32 chanid, void *buf, int nbytes, u32 flags) | 574 | u32 au1xxx_dbdma_put_source(u32 chanid, dma_addr_t buf, int nbytes, u32 flags) |
575 | { | 575 | { |
576 | chan_tab_t *ctp; | 576 | chan_tab_t *ctp; |
577 | au1x_ddma_desc_t *dp; | 577 | au1x_ddma_desc_t *dp; |
@@ -597,7 +597,7 @@ u32 au1xxx_dbdma_put_source(u32 chanid, void *buf, int nbytes, u32 flags) | |||
597 | return 0; | 597 | return 0; |
598 | 598 | ||
599 | /* Load up buffer address and byte count. */ | 599 | /* Load up buffer address and byte count. */ |
600 | dp->dscr_source0 = virt_to_phys(buf); | 600 | dp->dscr_source0 = buf & ~0UL; |
601 | dp->dscr_cmd1 = nbytes; | 601 | dp->dscr_cmd1 = nbytes; |
602 | /* Check flags */ | 602 | /* Check flags */ |
603 | if (flags & DDMA_FLAGS_IE) | 603 | if (flags & DDMA_FLAGS_IE) |
@@ -630,7 +630,7 @@ EXPORT_SYMBOL(au1xxx_dbdma_put_source); | |||
630 | * This updates the destination pointer and byte count. Normally used | 630 | * This updates the destination pointer and byte count. Normally used |
631 | * to place an empty buffer into the ring for fifo to memory transfers. | 631 | * to place an empty buffer into the ring for fifo to memory transfers. |
632 | */ | 632 | */ |
633 | u32 au1xxx_dbdma_put_dest(u32 chanid, void *buf, int nbytes, u32 flags) | 633 | u32 au1xxx_dbdma_put_dest(u32 chanid, dma_addr_t buf, int nbytes, u32 flags) |
634 | { | 634 | { |
635 | chan_tab_t *ctp; | 635 | chan_tab_t *ctp; |
636 | au1x_ddma_desc_t *dp; | 636 | au1x_ddma_desc_t *dp; |
@@ -660,7 +660,7 @@ u32 au1xxx_dbdma_put_dest(u32 chanid, void *buf, int nbytes, u32 flags) | |||
660 | if (flags & DDMA_FLAGS_NOIE) | 660 | if (flags & DDMA_FLAGS_NOIE) |
661 | dp->dscr_cmd0 &= ~DSCR_CMD0_IE; | 661 | dp->dscr_cmd0 &= ~DSCR_CMD0_IE; |
662 | 662 | ||
663 | dp->dscr_dest0 = virt_to_phys(buf); | 663 | dp->dscr_dest0 = buf & ~0UL; |
664 | dp->dscr_cmd1 = nbytes; | 664 | dp->dscr_cmd1 = nbytes; |
665 | #if 0 | 665 | #if 0 |
666 | printk(KERN_DEBUG "cmd0:%x cmd1:%x source0:%x source1:%x dest0:%x dest1:%x\n", | 666 | printk(KERN_DEBUG "cmd0:%x cmd1:%x source0:%x source1:%x dest0:%x dest1:%x\n", |
diff --git a/arch/mips/include/asm/mach-au1x00/au1xxx_dbdma.h b/arch/mips/include/asm/mach-au1x00/au1xxx_dbdma.h index b417c3bcdcb..8c6b1105ce0 100644 --- a/arch/mips/include/asm/mach-au1x00/au1xxx_dbdma.h +++ b/arch/mips/include/asm/mach-au1x00/au1xxx_dbdma.h | |||
@@ -339,8 +339,8 @@ u32 au1xxx_dbdma_set_devwidth(u32 chanid, int bits); | |||
339 | u32 au1xxx_dbdma_ring_alloc(u32 chanid, int entries); | 339 | u32 au1xxx_dbdma_ring_alloc(u32 chanid, int entries); |
340 | 340 | ||
341 | /* Put buffers on source/destination descriptors. */ | 341 | /* Put buffers on source/destination descriptors. */ |
342 | u32 au1xxx_dbdma_put_source(u32 chanid, void *buf, int nbytes, u32 flags); | 342 | u32 au1xxx_dbdma_put_source(u32 chanid, dma_addr_t buf, int nbytes, u32 flags); |
343 | u32 au1xxx_dbdma_put_dest(u32 chanid, void *buf, int nbytes, u32 flags); | 343 | u32 au1xxx_dbdma_put_dest(u32 chanid, dma_addr_t buf, int nbytes, u32 flags); |
344 | 344 | ||
345 | /* Get a buffer from the destination descriptor. */ | 345 | /* Get a buffer from the destination descriptor. */ |
346 | u32 au1xxx_dbdma_get_dest(u32 chanid, void **buf, int *nbytes); | 346 | u32 au1xxx_dbdma_get_dest(u32 chanid, void **buf, int *nbytes); |
diff --git a/drivers/ide/au1xxx-ide.c b/drivers/ide/au1xxx-ide.c index 377412e1d32..349a67bf1a3 100644 --- a/drivers/ide/au1xxx-ide.c +++ b/drivers/ide/au1xxx-ide.c | |||
@@ -56,7 +56,7 @@ static inline void auide_insw(unsigned long port, void *addr, u32 count) | |||
56 | chan_tab_t *ctp; | 56 | chan_tab_t *ctp; |
57 | au1x_ddma_desc_t *dp; | 57 | au1x_ddma_desc_t *dp; |
58 | 58 | ||
59 | if (!au1xxx_dbdma_put_dest(ahwif->rx_chan, (void*)addr, | 59 | if (!au1xxx_dbdma_put_dest(ahwif->rx_chan, virt_to_phys(addr), |
60 | count << 1, DDMA_FLAGS_NOIE)) { | 60 | count << 1, DDMA_FLAGS_NOIE)) { |
61 | printk(KERN_ERR "%s failed %d\n", __func__, __LINE__); | 61 | printk(KERN_ERR "%s failed %d\n", __func__, __LINE__); |
62 | return; | 62 | return; |
@@ -74,7 +74,7 @@ static inline void auide_outsw(unsigned long port, void *addr, u32 count) | |||
74 | chan_tab_t *ctp; | 74 | chan_tab_t *ctp; |
75 | au1x_ddma_desc_t *dp; | 75 | au1x_ddma_desc_t *dp; |
76 | 76 | ||
77 | if (!au1xxx_dbdma_put_source(ahwif->tx_chan, (void*)addr, | 77 | if (!au1xxx_dbdma_put_source(ahwif->tx_chan, virt_to_phys(addr), |
78 | count << 1, DDMA_FLAGS_NOIE)) { | 78 | count << 1, DDMA_FLAGS_NOIE)) { |
79 | printk(KERN_ERR "%s failed %d\n", __func__, __LINE__); | 79 | printk(KERN_ERR "%s failed %d\n", __func__, __LINE__); |
80 | return; | 80 | return; |
@@ -247,13 +247,13 @@ static int auide_build_dmatable(ide_drive_t *drive, struct ide_cmd *cmd) | |||
247 | 247 | ||
248 | if (iswrite) { | 248 | if (iswrite) { |
249 | if (!au1xxx_dbdma_put_source(ahwif->tx_chan, | 249 | if (!au1xxx_dbdma_put_source(ahwif->tx_chan, |
250 | (void *)sg_virt(sg), tc, flags)) { | 250 | sg_phys(sg), tc, flags)) { |
251 | printk(KERN_ERR "%s failed %d\n", | 251 | printk(KERN_ERR "%s failed %d\n", |
252 | __func__, __LINE__); | 252 | __func__, __LINE__); |
253 | } | 253 | } |
254 | } else { | 254 | } else { |
255 | if (!au1xxx_dbdma_put_dest(ahwif->rx_chan, | 255 | if (!au1xxx_dbdma_put_dest(ahwif->rx_chan, |
256 | (void *)sg_virt(sg), tc, flags)) { | 256 | sg_phys(sg), tc, flags)) { |
257 | printk(KERN_ERR "%s failed %d\n", | 257 | printk(KERN_ERR "%s failed %d\n", |
258 | __func__, __LINE__); | 258 | __func__, __LINE__); |
259 | } | 259 | } |
diff --git a/drivers/mmc/host/au1xmmc.c b/drivers/mmc/host/au1xmmc.c index d295dc5e4f6..c8649dfb2d0 100644 --- a/drivers/mmc/host/au1xmmc.c +++ b/drivers/mmc/host/au1xmmc.c | |||
@@ -651,10 +651,10 @@ static int au1xmmc_prepare_data(struct au1xmmc_host *host, | |||
651 | 651 | ||
652 | if (host->flags & HOST_F_XMIT) { | 652 | if (host->flags & HOST_F_XMIT) { |
653 | ret = au1xxx_dbdma_put_source(channel, | 653 | ret = au1xxx_dbdma_put_source(channel, |
654 | (void *)sg_virt(sg), len, flags); | 654 | sg_phys(sg), len, flags); |
655 | } else { | 655 | } else { |
656 | ret = au1xxx_dbdma_put_dest(channel, | 656 | ret = au1xxx_dbdma_put_dest(channel, |
657 | (void *)sg_virt(sg), len, flags); | 657 | sg_phys(sg), len, flags); |
658 | } | 658 | } |
659 | 659 | ||
660 | if (!ret) | 660 | if (!ret) |
diff --git a/drivers/spi/au1550_spi.c b/drivers/spi/au1550_spi.c index 22f7d729478..ba8ac4f599d 100644 --- a/drivers/spi/au1550_spi.c +++ b/drivers/spi/au1550_spi.c | |||
@@ -412,12 +412,12 @@ static int au1550_spi_dma_txrxb(struct spi_device *spi, struct spi_transfer *t) | |||
412 | } | 412 | } |
413 | 413 | ||
414 | /* put buffers on the ring */ | 414 | /* put buffers on the ring */ |
415 | res = au1xxx_dbdma_put_dest(hw->dma_rx_ch, hw->rx, | 415 | res = au1xxx_dbdma_put_dest(hw->dma_rx_ch, virt_to_phys(hw->rx), |
416 | t->len, DDMA_FLAGS_IE); | 416 | t->len, DDMA_FLAGS_IE); |
417 | if (!res) | 417 | if (!res) |
418 | dev_err(hw->dev, "rx dma put dest error\n"); | 418 | dev_err(hw->dev, "rx dma put dest error\n"); |
419 | 419 | ||
420 | res = au1xxx_dbdma_put_source(hw->dma_tx_ch, (void *)hw->tx, | 420 | res = au1xxx_dbdma_put_source(hw->dma_tx_ch, virt_to_phys(hw->tx), |
421 | t->len, DDMA_FLAGS_IE); | 421 | t->len, DDMA_FLAGS_IE); |
422 | if (!res) | 422 | if (!res) |
423 | dev_err(hw->dev, "tx dma put source error\n"); | 423 | dev_err(hw->dev, "tx dma put source error\n"); |
diff --git a/sound/oss/au1550_ac97.c b/sound/oss/au1550_ac97.c index b9ff0b79803..c1070e33b32 100644 --- a/sound/oss/au1550_ac97.c +++ b/sound/oss/au1550_ac97.c | |||
@@ -614,7 +614,7 @@ start_adc(struct au1550_state *s) | |||
614 | /* Put two buffers on the ring to get things started. | 614 | /* Put two buffers on the ring to get things started. |
615 | */ | 615 | */ |
616 | for (i=0; i<2; i++) { | 616 | for (i=0; i<2; i++) { |
617 | au1xxx_dbdma_put_dest(db->dmanr, db->nextIn, | 617 | au1xxx_dbdma_put_dest(db->dmanr, virt_to_phys(db->nextIn), |
618 | db->dma_fragsize, DDMA_FLAGS_IE); | 618 | db->dma_fragsize, DDMA_FLAGS_IE); |
619 | 619 | ||
620 | db->nextIn += db->dma_fragsize; | 620 | db->nextIn += db->dma_fragsize; |
@@ -733,8 +733,9 @@ static void dac_dma_interrupt(int irq, void *dev_id) | |||
733 | db->dma_qcount--; | 733 | db->dma_qcount--; |
734 | 734 | ||
735 | if (db->count >= db->fragsize) { | 735 | if (db->count >= db->fragsize) { |
736 | if (au1xxx_dbdma_put_source(db->dmanr, db->nextOut, | 736 | if (au1xxx_dbdma_put_source(db->dmanr, |
737 | db->fragsize, DDMA_FLAGS_IE) == 0) { | 737 | virt_to_phys(db->nextOut), db->fragsize, |
738 | DDMA_FLAGS_IE) == 0) { | ||
738 | err("qcount < 2 and no ring room!"); | 739 | err("qcount < 2 and no ring room!"); |
739 | } | 740 | } |
740 | db->nextOut += db->fragsize; | 741 | db->nextOut += db->fragsize; |
@@ -778,7 +779,7 @@ static void adc_dma_interrupt(int irq, void *dev_id) | |||
778 | 779 | ||
779 | /* Put a new empty buffer on the destination DMA. | 780 | /* Put a new empty buffer on the destination DMA. |
780 | */ | 781 | */ |
781 | au1xxx_dbdma_put_dest(dp->dmanr, dp->nextIn, | 782 | au1xxx_dbdma_put_dest(dp->dmanr, virt_to_phys(dp->nextIn), |
782 | dp->dma_fragsize, DDMA_FLAGS_IE); | 783 | dp->dma_fragsize, DDMA_FLAGS_IE); |
783 | 784 | ||
784 | dp->nextIn += dp->dma_fragsize; | 785 | dp->nextIn += dp->dma_fragsize; |
@@ -1180,7 +1181,8 @@ au1550_write(struct file *file, const char *buffer, size_t count, loff_t * ppos) | |||
1180 | */ | 1181 | */ |
1181 | while ((db->dma_qcount < 2) && (db->count >= db->fragsize)) { | 1182 | while ((db->dma_qcount < 2) && (db->count >= db->fragsize)) { |
1182 | if (au1xxx_dbdma_put_source(db->dmanr, | 1183 | if (au1xxx_dbdma_put_source(db->dmanr, |
1183 | db->nextOut, db->fragsize, DDMA_FLAGS_IE) == 0) { | 1184 | virt_to_phys(db->nextOut), db->fragsize, |
1185 | DDMA_FLAGS_IE) == 0) { | ||
1184 | err("qcount < 2 and no ring room!"); | 1186 | err("qcount < 2 and no ring room!"); |
1185 | } | 1187 | } |
1186 | db->nextOut += db->fragsize; | 1188 | db->nextOut += db->fragsize; |
diff --git a/sound/soc/au1x/dbdma2.c b/sound/soc/au1x/dbdma2.c index 2929f1c4226..6d9f4c62494 100644 --- a/sound/soc/au1x/dbdma2.c +++ b/sound/soc/au1x/dbdma2.c | |||
@@ -51,8 +51,8 @@ struct au1xpsc_audio_dmadata { | |||
51 | struct snd_pcm_substream *substream; | 51 | struct snd_pcm_substream *substream; |
52 | unsigned long curr_period; /* current segment DDMA is working on */ | 52 | unsigned long curr_period; /* current segment DDMA is working on */ |
53 | unsigned long q_period; /* queue period(s) */ | 53 | unsigned long q_period; /* queue period(s) */ |
54 | unsigned long dma_area; /* address of queued DMA area */ | 54 | dma_addr_t dma_area; /* address of queued DMA area */ |
55 | unsigned long dma_area_s; /* start address of DMA area */ | 55 | dma_addr_t dma_area_s; /* start address of DMA area */ |
56 | unsigned long pos; /* current byte position being played */ | 56 | unsigned long pos; /* current byte position being played */ |
57 | unsigned long periods; /* number of SG segments in total */ | 57 | unsigned long periods; /* number of SG segments in total */ |
58 | unsigned long period_bytes; /* size in bytes of one SG segment */ | 58 | unsigned long period_bytes; /* size in bytes of one SG segment */ |
@@ -94,8 +94,7 @@ static const struct snd_pcm_hardware au1xpsc_pcm_hardware = { | |||
94 | 94 | ||
95 | static void au1x_pcm_queue_tx(struct au1xpsc_audio_dmadata *cd) | 95 | static void au1x_pcm_queue_tx(struct au1xpsc_audio_dmadata *cd) |
96 | { | 96 | { |
97 | au1xxx_dbdma_put_source(cd->ddma_chan, | 97 | au1xxx_dbdma_put_source(cd->ddma_chan, cd->dma_area, |
98 | (void *)phys_to_virt(cd->dma_area), | ||
99 | cd->period_bytes, DDMA_FLAGS_IE); | 98 | cd->period_bytes, DDMA_FLAGS_IE); |
100 | 99 | ||
101 | /* update next-to-queue period */ | 100 | /* update next-to-queue period */ |
@@ -109,8 +108,7 @@ static void au1x_pcm_queue_tx(struct au1xpsc_audio_dmadata *cd) | |||
109 | 108 | ||
110 | static void au1x_pcm_queue_rx(struct au1xpsc_audio_dmadata *cd) | 109 | static void au1x_pcm_queue_rx(struct au1xpsc_audio_dmadata *cd) |
111 | { | 110 | { |
112 | au1xxx_dbdma_put_dest(cd->ddma_chan, | 111 | au1xxx_dbdma_put_dest(cd->ddma_chan, cd->dma_area, |
113 | (void *)phys_to_virt(cd->dma_area), | ||
114 | cd->period_bytes, DDMA_FLAGS_IE); | 112 | cd->period_bytes, DDMA_FLAGS_IE); |
115 | 113 | ||
116 | /* update next-to-queue period */ | 114 | /* update next-to-queue period */ |
@@ -233,7 +231,7 @@ static int au1xpsc_pcm_hw_params(struct snd_pcm_substream *substream, | |||
233 | pcd->substream = substream; | 231 | pcd->substream = substream; |
234 | pcd->period_bytes = params_period_bytes(params); | 232 | pcd->period_bytes = params_period_bytes(params); |
235 | pcd->periods = params_periods(params); | 233 | pcd->periods = params_periods(params); |
236 | pcd->dma_area_s = pcd->dma_area = (unsigned long)runtime->dma_addr; | 234 | pcd->dma_area_s = pcd->dma_area = runtime->dma_addr; |
237 | pcd->q_period = 0; | 235 | pcd->q_period = 0; |
238 | pcd->curr_period = 0; | 236 | pcd->curr_period = 0; |
239 | pcd->pos = 0; | 237 | pcd->pos = 0; |