mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ashutosh Dixit <ashutosh.dixit@intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Dan Williams <dan.j.williams@intel.com>,
	Vinod Koul <vinod.koul@intel.com>,
	linux-kernel@vger.kernel.org
Cc: Ashutosh Dixit <ashutosh.dixit@intel.com>,
	Sudeep Dutt <sudeep.dutt@intel.com>,
	Nikhil Rao <nikhil.rao@intel.com>,
	Siva Yerramreddy <yshivakrishna@gmail.com>
Subject: [PATCH char-misc-next 11/19] dma: Add support to program MIC x100 status descriptiors
Date: Mon, 27 Jul 2015 16:58:17 -0700	[thread overview]
Message-ID: <0c2dec1519fdd81dfe6335efc2a1edb0b142639b.1438040669.git.ashutosh.dixit@intel.com> (raw)
In-Reply-To: <cover.1438040669.git.ashutosh.dixit@intel.com>

From: Siva Yerramreddy <yshivakrishna@gmail.com>

The MIC X100 DMA engine has a special status descriptor which writes
an 8 byte value to a destination location.  This is used to signal
completion of all DMA descriptors prior to the status descriptor. This
patch uses the src field as a value since the DMA engine API does not
allow passing a value as an argument, if the length is 8 bytes.  This
special case works since the MIC x100 DMA engine requires cache line
(64 byte) aligned src/dst/len so we can use the 8 byte length as a
special case to enable programming status descriptors without
requiring a change to the DMA engine API.

Reviewed-by: Nikhil Rao <nikhil.rao@intel.com>
Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Reviewed-by: Sudeep Dutt <sudeep.dutt@intel.com>
Signed-off-by: Siva Yerramreddy <yshivakrishna@gmail.com>
---
 drivers/dma/mic_x100_dma.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 43 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/mic_x100_dma.c b/drivers/dma/mic_x100_dma.c
index 74d9db0..8d8acfc 100644
--- a/drivers/dma/mic_x100_dma.c
+++ b/drivers/dma/mic_x100_dma.c
@@ -193,8 +193,16 @@ static void mic_dma_prog_intr(struct mic_dma_chan *ch)
 static int mic_dma_do_dma(struct mic_dma_chan *ch, int flags, dma_addr_t src,
 			  dma_addr_t dst, size_t len)
 {
-	if (-ENOMEM == mic_dma_prog_memcpy_desc(ch, src, dst, len))
+	if (len && -ENOMEM == mic_dma_prog_memcpy_desc(ch, src, dst, len)) {
 		return -ENOMEM;
+	} else {
+		/* 3 is the maximum number of status descriptors */
+		int ret = mic_dma_avail_desc_ring_space(ch, 3);
+
+		if (ret < 0)
+			return ret;
+	}
+
 	/* Above mic_dma_prog_memcpy_desc() makes sure we have enough space */
 	if (flags & DMA_PREP_FENCE) {
 		mic_dma_prep_status_desc(&ch->desc_ring[ch->head], 0,
@@ -208,6 +216,21 @@ static int mic_dma_do_dma(struct mic_dma_chan *ch, int flags, dma_addr_t src,
 	return 0;
 }
 
+/* Program a status descriptor with phys as address and value to be written */
+static int mic_dma_do_status_update(struct mic_dma_chan *ch, dma_addr_t phys,
+				    u64 value)
+{
+	int ret = mic_dma_avail_desc_ring_space(ch, 4);
+
+	if (ret < 0)
+		return ret;
+	ret = 0;
+	mic_dma_prep_status_desc(&ch->desc_ring[ch->head],
+				 value, phys, false);
+	mic_dma_hw_ring_inc_head(ch);
+	return ret;
+}
+
 static inline void mic_dma_issue_pending(struct dma_chan *ch)
 {
 	struct mic_dma_chan *mic_ch = to_mic_dma_chan(ch);
@@ -287,9 +310,28 @@ mic_dma_prep_memcpy_lock(struct dma_chan *ch, dma_addr_t dma_dest,
 		return NULL;
 
 	spin_lock(&mic_ch->prep_lock);
+	if (len == 8) {
+		/*
+		 * This is a hack to program status descriptor since
+		 * DMA engine API doesn't have support for this.
+		 */
+		result = mic_dma_do_status_update(mic_ch, dma_dest, dma_src);
+		if (result)
+			goto error;
+
+		result = mic_dma_do_dma(mic_ch, DMA_PREP_FENCE, 0, 0, 0);
+		if (result < 0)
+			goto error;
+		result = mic_dma_do_dma(mic_ch, flags, 0, 0, 0);
+		if (result < 0)
+			goto error;
+		return allocate_tx(mic_ch);
+	}
+
 	result = mic_dma_do_dma(mic_ch, flags, dma_src, dma_dest, len);
 	if (result >= 0)
 		return allocate_tx(mic_ch);
+error:
 	dev_err(dev, "Error enqueueing dma, error=%d\n", result);
 	spin_unlock(&mic_ch->prep_lock);
 	return NULL;
-- 
2.0.0.rc3.2.g998f840


  parent reply	other threads:[~2015-07-27 23:34 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-27 23:52 [PATCH char-misc-next 00/19] misc: mic: Enable COSM and remaining SCIF functionality Ashutosh Dixit
2015-07-27 23:53 ` [PATCH char-misc-next 01/19] misc: mic: SCIF poll Ashutosh Dixit
2015-07-27 23:53 ` [PATCH char-misc-next 02/19] misc: mic: Add support for kernel mode SCIF clients Ashutosh Dixit
2015-07-27 23:54 ` [PATCH char-misc-next 03/19] misc: mic: MIC COSM bus Ashutosh Dixit
2015-07-27 23:54 ` [PATCH char-misc-next 04/19] misc: mic: Coprocessor State Management (COSM) driver Ashutosh Dixit
2015-07-27 23:55 ` [PATCH char-misc-next 05/19] misc: mic: COSM SCIF server Ashutosh Dixit
2015-07-27 23:55 ` [PATCH char-misc-next 06/19] misc: mic: COSM client driver Ashutosh Dixit
2015-07-27 23:55 ` [PATCH char-misc-next 07/19] misc: mic: Remove COSM functionality from the MIC host driver Ashutosh Dixit
2015-07-27 23:55 ` [PATCH char-misc-next 08/19] misc: mic: Remove COSM functionality from the MIC card driver Ashutosh Dixit
2015-07-27 23:56 ` [PATCH char-misc-next 09/19] misc: mic: Update MIC host daemon with COSM changes Ashutosh Dixit
2015-07-27 23:57 ` [PATCH char-misc-next 10/19] lib: convert iova.c into a library Ashutosh Dixit
2015-07-28 10:03   ` Joerg Roedel
2015-07-28 10:41     ` Robin Murphy
2015-07-28 14:38       ` David Woodhouse
2015-07-28 17:01         ` Sudeep Dutt
2015-07-28 20:40   ` Andrew Morton
2015-07-31  0:31     ` Ashutosh Dixit
2015-07-27 23:58 ` Ashutosh Dixit [this message]
2015-08-20  5:20   ` [PATCH char-misc-next 11/19] dma: Add support to program MIC x100 status descriptiors Vinod Koul
2015-08-20 17:30     ` Sudeep Dutt
2015-08-21  8:29       ` Vinod Koul
2015-08-21 16:14         ` Sudeep Dutt
2015-07-27 23:59 ` [PATCH char-misc-next 12/19] misc: mic: SCIF RMA header file and IOCTL changes Ashutosh Dixit
2015-07-27 23:59 ` [PATCH char-misc-next 13/19] misc: mic: SCIF RMA header file Ashutosh Dixit
2015-07-27 23:59 ` [PATCH char-misc-next 14/19] misc: mic: SCIF memory registration and unregistration Ashutosh Dixit
2015-07-28  0:00 ` [PATCH char-misc-next 15/19] misc: mic: SCIF RMA list operations Ashutosh Dixit
2015-07-28  0:00 ` [PATCH char-misc-next 16/19] misc: mic: SCIF remote memory map/unmap interface Ashutosh Dixit
2015-07-28  0:00 ` [PATCH char-misc-next 17/19] misc: mic: SCIF DMA and CPU copy interface Ashutosh Dixit
2015-07-28  0:00 ` [PATCH char-misc-next 18/19] misc: mic: SCIF fence Ashutosh Dixit
2015-07-28  0:01 ` [PATCH char-misc-next 19/19] misc: mic: SCIF RMA nodeqp and minor miscellaneous changes Ashutosh Dixit

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=0c2dec1519fdd81dfe6335efc2a1edb0b142639b.1438040669.git.ashutosh.dixit@intel.com \
    --to=ashutosh.dixit@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nikhil.rao@intel.com \
    --cc=sudeep.dutt@intel.com \
    --cc=vinod.koul@intel.com \
    --cc=yshivakrishna@gmail.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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®