Re: [PATCH 1/7] dmaengine: idxd: rework descriptor free path on failure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 10/24/2021 9:56 PM, Vinod Koul wrote:
On 20-10-21, 09:53, Dave Jiang wrote:
Refactor the completion function to allow skipping of descriptor freeing on
the submission failiure path. This completely removes descriptor freeing
s/failiure/failure

from the submit failure path and leave the responsibility to the caller.

Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>
Signed-off-by: Dave Jiang <dave.jiang@xxxxxxxxx>
---
  drivers/dma/idxd/dma.c    |   10 ++++++++--
  drivers/dma/idxd/idxd.h   |    8 +-------
  drivers/dma/idxd/init.c   |    9 +++------
  drivers/dma/idxd/irq.c    |    8 ++++----
  drivers/dma/idxd/submit.c |   12 +++---------
  5 files changed, 19 insertions(+), 28 deletions(-)

diff --git a/drivers/dma/idxd/dma.c b/drivers/dma/idxd/dma.c
index c39e9483206a..1ea663215909 100644
--- a/drivers/dma/idxd/dma.c
+++ b/drivers/dma/idxd/dma.c
@@ -21,7 +21,8 @@ static inline struct idxd_wq *to_idxd_wq(struct dma_chan *c)
  }
void idxd_dma_complete_txd(struct idxd_desc *desc,
-			   enum idxd_complete_type comp_type)
+			   enum idxd_complete_type comp_type,
+			   bool free_desc)
  {
  	struct dma_async_tx_descriptor *tx;
  	struct dmaengine_result res;
@@ -44,6 +45,9 @@ void idxd_dma_complete_txd(struct idxd_desc *desc,
  		tx->callback = NULL;
  		tx->callback_result = NULL;
  	}
+
+	if (free_desc)
+		idxd_free_desc(desc->wq, desc);
  }
static void op_flag_setup(unsigned long flags, u32 *desc_flags)
@@ -153,8 +157,10 @@ static dma_cookie_t idxd_dma_tx_submit(struct dma_async_tx_descriptor *tx)
  	cookie = dma_cookie_assign(tx);
rc = idxd_submit_desc(wq, desc);
-	if (rc < 0)
+	if (rc < 0) {
+		idxd_free_desc(wq, desc);
if there is an error in submit, should the caller not invoke terminate()
and get the cleanup done?
The driver doesn't have a terminate() implemented. This is the only place we can free the descriptor that has been allocated in prep() if the submission has failed. Also terminate takes chan as the parameter. The chan would not have any access to this failed descriptor. The submission failed and the descriptor is not in the submission list or has been aborted and removed from the submission list. So calling terminate would not actually free the said descriptor. Also there's no reason to stop the channel due to a failed descriptor. In this particular condition, simplest thing would be to just return the allocated descriptor back to the driver.



[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux PCI]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux