Skip to contentSkip to conversation

dma: tegra: fix residual calculation for cyclic case

PATCH Applied Laxman Dewangan 3 participants 9 messages Jul 2, 2012 – Jul 13, 2012

Subsystems (3)
lore
Share & tools
lore

Laxman Dewangan

author maintainer
#0 lore raw

PATCH 2/2 dma: tegra: fix residual calculation for cyclic case

In cyclic mode of DMA, the byte transferred can be more than the requested size and in this case, calculating residuals based on the current position of DMA transfer to bytes requested i.e. bytes required to transfer to reach bytes requested from current DMA position.

---
 drivers/dma/tegra20-apb-dma.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)
drivers/dma/tegra20-apb-dma.c +9 -6
index 340c617..d52dbc6 100644
@@ -731,6 +731,7 @@ static enum dma_status tegra_dma_tx_status(struct dma_chan *dc,
 	struct tegra_dma_sg_req *sg_req;
 	enum dma_status ret;
 	unsigned long flags;
+	unsigned int residual;
 
 	spin_lock_irqsave(&tdc->lock, flags);
 
@@ -744,9 +745,10 @@ static enum dma_status tegra_dma_tx_status(struct dma_chan *dc,
 	/* Check on wait_ack desc status */
 	list_for_each_entry(dma_desc, &tdc->free_dma_desc, node) {
 		if (dma_desc->txd.cookie == cookie) {
-			dma_set_residue(txstate,
-				dma_desc->bytes_requested -
-				dma_desc->bytes_transferred);
+			residual =  dma_desc->bytes_requested -
+					(dma_desc->bytes_transferred %
+						dma_desc->bytes_requested);
+			dma_set_residue(txstate, residual);
 			ret = dma_desc->dma_status;
 			spin_unlock_irqrestore(&tdc->lock, flags);
 			return ret;
@@ -757,9 +759,10 @@ static enum dma_status tegra_dma_tx_status(struct dma_chan *dc,
 	list_for_each_entry(sg_req, &tdc->pending_sg_req, node) {
 		dma_desc = sg_req->dma_desc;
 		if (dma_desc->txd.cookie == cookie) {
-			dma_set_residue(txstate,
-				dma_desc->bytes_requested -
-				dma_desc->bytes_transferred);
+			residual =  dma_desc->bytes_requested -
+					(dma_desc->bytes_transferred %
+						dma_desc->bytes_requested);
+			dma_set_residue(txstate, residual);
 			ret = dma_desc->dma_status;
 			spin_unlock_irqrestore(&tdc->lock, flags);
 			return ret;
Signature · 1 line
1.7.1.1
author maintainer
#1 lore raw

PATCH 1/2 dma: tegra: rename driver and compatible to match with dts

Rename the compatible name and driver name to match with tegra dts file and as per clock driver.

---
 drivers/dma/tegra20-apb-dma.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/dma/tegra20-apb-dma.c +3 -3
index c0836a7..340c617 100644
@@ -1177,10 +1177,10 @@ static struct tegra_dma_chip_data tegra30_dma_chip_data = {
 
 static const struct of_device_id tegra_dma_of_match[] __devinitconst = {
 	{
-		.compatible = "nvidia,tegra30-apbdma-new",
+		.compatible = "nvidia,tegra30-apbdma",
 		.data = &tegra30_dma_chip_data,
 	}, {
-		.compatible = "nvidia,tegra20-apbdma-new",
+		.compatible = "nvidia,tegra20-apbdma",
 		.data = &tegra20_dma_chip_data,
 	}, {
 	},
@@ -1395,7 +1395,7 @@ static const struct dev_pm_ops tegra_dma_dev_pm_ops __devinitconst = {
 
 static struct platform_driver tegra_dmac_driver = {
 	.driver = {
-		.name	= "tegra20-apbdma",
+		.name	= "tegra-apbdma",
 		.owner = THIS_MODULE,
 		.pm	= &tegra_dma_dev_pm_ops,
 		.of_match_table = of_match_ptr(tegra_dma_of_match),
Signature · 1 line
1.7.1.1
Acked-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] dma: tegra: rename driver and compatible to match with dts

Quoted 4 lines · Laxman Dewangan

Rename the compatible name and driver name to match with tegra dts file and as per clock driver.

The separate config options for the old and new DMA drivers should prevent them conflicting with each-other, even though they both support the same compatible values and driver name. Hence, this patch should be fine.

Acked-by on v1 2/2
#4 lore raw
In reply to Laxman Dewangan
Quoted 7 lines · Laxman Dewangan

In cyclic mode of DMA, the byte transferred can be more than the requested size and in this case, calculating residuals based on the current position of DMA transfer to bytes requested i.e. bytes required to transfer to reach bytes requested from current DMA position.

This makes sense to me, although I wonder if details like this aren't something that the dmaengine core should be handling.

#5 lore raw
Quoted 11 lines · Stephen Warren
Quoted 7 lines · Laxman Dewangan

In cyclic mode of DMA, the byte transferred can be more than the requested size and in this case, calculating residuals based on the current position of DMA transfer to bytes requested i.e. bytes required to transfer to reach bytes requested from current DMA position.

This makes sense to me, although I wonder if details like this aren't something that the dmaengine core should be handling.

No core doesn't know anything about the how much you are transferring and where you are. That is the driver to calculate and provide.

Signature · 1 line
~Vinod
author maintainer
#6 lore raw
Quoted 8 lines · Vinod Koul
Quoted 7 lines · Stephen Warren
Quoted 6 lines · Laxman Dewangan

In cyclic mode of DMA, the byte transferred can be more than the requested size and in this case, calculating residuals based on the current position of DMA transfer to bytes requested i.e. bytes required to transfer to reach bytes requested from current DMA position.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

This makes sense to me, although I wonder if details like this aren't something that the dmaengine core should be handling.

No core doesn't know anything about the how much you are transferring and where you are. That is the driver to calculate and provide.

Just for confirmation, are you going to apply this patch or do I need to do anything here.

Thanks,
Laxman

#7 lore raw
Quoted 9 lines · Laxman Dewangan
Quoted 8 lines · Vinod Koul
Quoted 7 lines · Stephen Warren
Quoted 6 lines · Laxman Dewangan

In cyclic mode of DMA, the byte transferred can be more than the requested size and in this case, calculating residuals based on the current position of DMA transfer to bytes requested i.e. bytes required to transfer to reach bytes requested from current DMA position.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

This makes sense to me, although I wonder if details like this aren't something that the dmaengine core should be handling.

No core doesn't know anything about the how much you are transferring and where you are. That is the driver to calculate and provide.

Just for confirmation, are you going to apply this patch or do I need to do anything here.

???

You didnt get my other mail about applying?

Signature · 1 line
~Vinod
author maintainer
#8 lore raw
Quoted 3 lines · Vinod Koul

On Fri, 2012-07-13 at 11:09 +0530, Laxman Dewangan wrote:
You didnt get my other mail about applying?

Read carefully now and saw both are applied.
Thanks for care.

Thanks,
Laxman