From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> To: Vinod Koul <vinod.koul@intel.com>, dmaengine@vger.kernel.org Cc: Nadav Haklai <nadavh@marvell.com>, Hanna Hawa <hannah@marvell.com>, Yehuda Yitschak <yehuday@marvell.com>, Jason Cooper <jason@lakedaemon.net>, Andrew Lunn <andrew@lunn.ch>, Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>, Gregory Clement <gregory.clement@free-electrons.com>, linux-arm-kernel@lists.infradead.org, Thomas Petazzoni <thomas.petazzoni@free-electrons.com>, stable@vger.kernel.org Subject: [PATCH 02/10] dma: mv_xor_v2: properly handle wrapping in the array of HW descriptors Date: Fri, 5 May 2017 11:57:45 +0200 [thread overview] Message-ID: <1493978274-12805-3-git-send-email-thomas.petazzoni@free-electrons.com> (raw) In-Reply-To: <1493978274-12805-1-git-send-email-thomas.petazzoni@free-electrons.com> mv_xor_v2_tasklet() is looping over completed HW descriptors. Before the loop, it initializes 'next_pending_hw_desc' to the first HW descriptor to handle, and then the loop simply increments this point, without taking care of wrapping when we reach the last HW descriptor. The 'pending_ptr' index was being wrapped back to 0 at the end, but it wasn't used in each iteration of the loop to calculate next_pending_hw_desc. This commit fixes that, and makes next_pending_hw_desc a variable local to the loop itself. Fixes: 19a340b1a820 ("dmaengine: mv_xor_v2: new driver") Cc: <stable@vger.kernel.org> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> --- drivers/dma/mv_xor_v2.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/dma/mv_xor_v2.c b/drivers/dma/mv_xor_v2.c index e928020..bdfb36e 100644 --- a/drivers/dma/mv_xor_v2.c +++ b/drivers/dma/mv_xor_v2.c @@ -560,7 +560,6 @@ static void mv_xor_v2_tasklet(unsigned long data) { struct mv_xor_v2_device *xor_dev = (struct mv_xor_v2_device *) data; int pending_ptr, num_of_pending, i; - struct mv_xor_v2_descriptor *next_pending_hw_desc = NULL; struct mv_xor_v2_sw_desc *next_pending_sw_desc = NULL; dev_dbg(xor_dev->dmadev.dev, "%s %d\n", __func__, __LINE__); @@ -568,17 +567,10 @@ static void mv_xor_v2_tasklet(unsigned long data) /* get the pending descriptors parameters */ num_of_pending = mv_xor_v2_get_pending_params(xor_dev, &pending_ptr); - /* next HW descriptor */ - next_pending_hw_desc = xor_dev->hw_desq_virt + pending_ptr; - /* loop over free descriptors */ for (i = 0; i < num_of_pending; i++) { - - if (pending_ptr > MV_XOR_V2_DESC_NUM) - pending_ptr = 0; - - if (next_pending_sw_desc != NULL) - next_pending_hw_desc++; + struct mv_xor_v2_descriptor *next_pending_hw_desc = + xor_dev->hw_desq_virt + pending_ptr; /* get the SW descriptor related to the HW descriptor */ next_pending_sw_desc = @@ -614,6 +606,8 @@ static void mv_xor_v2_tasklet(unsigned long data) /* increment the next descriptor */ pending_ptr++; + if (pending_ptr >= MV_XOR_V2_DESC_NUM) + pending_ptr = 0; } if (num_of_pending != 0) { -- 2.7.4
WARNING: multiple messages have this Message-ID (diff)
From: thomas.petazzoni@free-electrons.com (Thomas Petazzoni) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 02/10] dma: mv_xor_v2: properly handle wrapping in the array of HW descriptors Date: Fri, 5 May 2017 11:57:45 +0200 [thread overview] Message-ID: <1493978274-12805-3-git-send-email-thomas.petazzoni@free-electrons.com> (raw) In-Reply-To: <1493978274-12805-1-git-send-email-thomas.petazzoni@free-electrons.com> mv_xor_v2_tasklet() is looping over completed HW descriptors. Before the loop, it initializes 'next_pending_hw_desc' to the first HW descriptor to handle, and then the loop simply increments this point, without taking care of wrapping when we reach the last HW descriptor. The 'pending_ptr' index was being wrapped back to 0 at the end, but it wasn't used in each iteration of the loop to calculate next_pending_hw_desc. This commit fixes that, and makes next_pending_hw_desc a variable local to the loop itself. Fixes: 19a340b1a820 ("dmaengine: mv_xor_v2: new driver") Cc: <stable@vger.kernel.org> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> --- drivers/dma/mv_xor_v2.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/dma/mv_xor_v2.c b/drivers/dma/mv_xor_v2.c index e928020..bdfb36e 100644 --- a/drivers/dma/mv_xor_v2.c +++ b/drivers/dma/mv_xor_v2.c @@ -560,7 +560,6 @@ static void mv_xor_v2_tasklet(unsigned long data) { struct mv_xor_v2_device *xor_dev = (struct mv_xor_v2_device *) data; int pending_ptr, num_of_pending, i; - struct mv_xor_v2_descriptor *next_pending_hw_desc = NULL; struct mv_xor_v2_sw_desc *next_pending_sw_desc = NULL; dev_dbg(xor_dev->dmadev.dev, "%s %d\n", __func__, __LINE__); @@ -568,17 +567,10 @@ static void mv_xor_v2_tasklet(unsigned long data) /* get the pending descriptors parameters */ num_of_pending = mv_xor_v2_get_pending_params(xor_dev, &pending_ptr); - /* next HW descriptor */ - next_pending_hw_desc = xor_dev->hw_desq_virt + pending_ptr; - /* loop over free descriptors */ for (i = 0; i < num_of_pending; i++) { - - if (pending_ptr > MV_XOR_V2_DESC_NUM) - pending_ptr = 0; - - if (next_pending_sw_desc != NULL) - next_pending_hw_desc++; + struct mv_xor_v2_descriptor *next_pending_hw_desc = + xor_dev->hw_desq_virt + pending_ptr; /* get the SW descriptor related to the HW descriptor */ next_pending_sw_desc = @@ -614,6 +606,8 @@ static void mv_xor_v2_tasklet(unsigned long data) /* increment the next descriptor */ pending_ptr++; + if (pending_ptr >= MV_XOR_V2_DESC_NUM) + pending_ptr = 0; } if (num_of_pending != 0) { -- 2.7.4
next prev parent reply other threads:[~2017-05-05 9:57 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-05-05 9:57 [PATCH 00/10] dma: mv_xor_v2: fixes and improvements Thomas Petazzoni 2017-05-05 9:57 ` [PATCH 01/10] dma: mv_xor_v2: handle mv_xor_v2_prep_sw_desc() error properly Thomas Petazzoni 2017-05-05 9:57 ` Thomas Petazzoni 2017-05-05 9:57 ` Thomas Petazzoni [this message] 2017-05-05 9:57 ` [PATCH 02/10] dma: mv_xor_v2: properly handle wrapping in the array of HW descriptors Thomas Petazzoni 2017-05-05 9:57 ` [PATCH 03/10] dma: mv_xor_v2: do not use descriptors not acked by async_tx Thomas Petazzoni 2017-05-05 9:57 ` Thomas Petazzoni 2017-05-05 9:57 ` [PATCH 04/10] dma: mv_xor_v2: enable XOR engine after its configuration Thomas Petazzoni 2017-05-05 9:57 ` Thomas Petazzoni 2017-05-05 9:57 ` [PATCH 05/10] dma: mv_xor_v2: fix tx_submit() implementation Thomas Petazzoni 2017-05-05 9:57 ` Thomas Petazzoni 2017-05-05 9:57 ` [PATCH 06/10] dma: mv_xor_v2: remove interrupt coalescing Thomas Petazzoni 2017-05-05 9:57 ` Thomas Petazzoni 2017-05-05 9:57 ` [PATCH 07/10] dma: mv_xor_v2: set DMA mask to 40 bits Thomas Petazzoni 2017-05-05 9:57 ` Thomas Petazzoni 2017-05-05 9:57 ` [PATCH 08/10] dma: mv_xor_v2: implement proper interrupt coalescing Thomas Petazzoni 2017-05-05 9:57 ` [PATCH 09/10] dma: mv_xor_v2: remove unnecessary write to DESQ_STOP register Thomas Petazzoni 2017-05-05 9:57 ` [PATCH 10/10] dma: mv_xor_v2: add support for suspend/resume Thomas Petazzoni 2017-05-14 12:58 ` [PATCH 00/10] dma: mv_xor_v2: fixes and improvements Vinod Koul 2017-05-14 13:09 ` Thomas Petazzoni
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1493978274-12805-3-git-send-email-thomas.petazzoni@free-electrons.com \ --to=thomas.petazzoni@free-electrons.com \ --cc=andrew@lunn.ch \ --cc=dmaengine@vger.kernel.org \ --cc=gregory.clement@free-electrons.com \ --cc=hannah@marvell.com \ --cc=jason@lakedaemon.net \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=nadavh@marvell.com \ --cc=sebastian.hesselbarth@gmail.com \ --cc=stable@vger.kernel.org \ --cc=vinod.koul@intel.com \ --cc=yehuday@marvell.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.