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, dmaengine@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>,
	Jacek Lawrynowicz <jacek.lawrynowicz@intel.com>
Subject: [PATCH char-misc-next v2 05/22] dma: Add support to program MIC x100 status descriptiors
Date: Tue, 29 Sep 2015 18:09:37 -0700	[thread overview]
Message-ID: <8e003194da11abd636dd1dfebbb5895a0ceac932.1443573394.git.ashutosh.dixit@intel.com> (raw)
In-Reply-To: <cover.1443573394.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 add a new DMA engine API which enables updating a
destination address with an 8 byte immediate data value.

Reviewed-by: Nikhil Rao <nikhil.rao@intel.com>
Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Signed-off-by: Lawrynowicz, Jacek <jacek.lawrynowicz@intel.com>
Signed-off-by: Sudeep Dutt <sudeep.dutt@intel.com>
Signed-off-by: Siva Yerramreddy <yshivakrishna@gmail.com>
---
 drivers/dma/mic_x100_dma.c | 39 ++++++++++++++++++++++++++++++++++++++-
 include/linux/dmaengine.h  |  4 ++++
 2 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/mic_x100_dma.c b/drivers/dma/mic_x100_dma.c
index 74d9db0..068e920 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,
@@ -270,6 +278,33 @@ allocate_tx(struct mic_dma_chan *ch)
 	return tx;
 }
 
+/* Program a status descriptor with dst as address and value to be written */
+static struct dma_async_tx_descriptor *
+mic_dma_prep_status_lock(struct dma_chan *ch, dma_addr_t dst, u64 src_val,
+			 unsigned long flags)
+{
+	struct mic_dma_chan *mic_ch = to_mic_dma_chan(ch);
+	int result;
+
+	spin_lock(&mic_ch->prep_lock);
+	result = mic_dma_avail_desc_ring_space(mic_ch, 4);
+	if (result < 0)
+		goto error;
+	mic_dma_prep_status_desc(&mic_ch->desc_ring[mic_ch->head], src_val, dst,
+				 false);
+	mic_dma_hw_ring_inc_head(mic_ch);
+	result = mic_dma_do_dma(mic_ch, flags, 0, 0, 0);
+	if (result < 0)
+		goto error;
+
+	return allocate_tx(mic_ch);
+error:
+	dev_err(mic_dma_ch_to_device(mic_ch),
+		"Error enqueueing dma status descriptor, error=%d\n", result);
+	spin_unlock(&mic_ch->prep_lock);
+	return NULL;
+}
+
 /*
  * Prepare a memcpy descriptor to be added to the ring.
  * Note that the temporary descriptor adds an extra overhead of copying the
@@ -587,6 +622,8 @@ static int mic_dma_register_dma_device(struct mic_dma_device *mic_dma_dev,
 		mic_dma_free_chan_resources;
 	mic_dma_dev->dma_dev.device_tx_status = mic_dma_tx_status;
 	mic_dma_dev->dma_dev.device_prep_dma_memcpy = mic_dma_prep_memcpy_lock;
+	mic_dma_dev->dma_dev.device_prep_dma_imm_data =
+		mic_dma_prep_status_lock;
 	mic_dma_dev->dma_dev.device_prep_dma_interrupt =
 		mic_dma_prep_interrupt_lock;
 	mic_dma_dev->dma_dev.device_issue_pending = mic_dma_issue_pending;
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index 7ea9184..c47c68e 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -645,6 +645,7 @@ enum dmaengine_alignment {
  *	The function takes a buffer of size buf_len. The callback function will
  *	be called after period_len bytes have been transferred.
  * @device_prep_interleaved_dma: Transfer expression in a generic way.
+ * @device_prep_dma_imm_data: DMA's 8 byte immediate data to the dst address
  * @device_config: Pushes a new configuration to a channel, return 0 or an error
  *	code
  * @device_pause: Pauses any transfer happening on a channel. Returns
@@ -727,6 +728,9 @@ struct dma_device {
 	struct dma_async_tx_descriptor *(*device_prep_interleaved_dma)(
 		struct dma_chan *chan, struct dma_interleaved_template *xt,
 		unsigned long flags);
+	struct dma_async_tx_descriptor *(*device_prep_dma_imm_data)(
+		struct dma_chan *chan, dma_addr_t dst, u64 data,
+		unsigned long flags);
 
 	int (*device_config)(struct dma_chan *chan,
 			     struct dma_slave_config *config);
-- 
2.0.0.rc3.2.g998f840


  parent reply	other threads:[~2015-09-30  0:44 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-30  1:06 [PATCH char-misc-next v2 00/22] misc: mic: Enable COSM and remaining SCIF functionality Ashutosh Dixit
2015-09-30  1:07 ` [PATCH char-misc-next v2 01/22] iommu: iova: Move iova cache management to the iova library Ashutosh Dixit
2015-09-30  1:07 ` [PATCH char-misc-next v2 02/22] iommu: iova: Export symbols Ashutosh Dixit
2015-09-30  1:08 ` [PATCH char-misc-next v2 03/22] iommu: Make the iova library a module Ashutosh Dixit
2015-09-30  1:09 ` [PATCH char-misc-next v2 04/22] iommu: Allow iova to be used without requiring IOMMU_SUPPORT Ashutosh Dixit
2015-10-05 10:50   ` Woodhouse, David
2015-10-05 17:38     ` Sudeep Dutt
2015-10-06  5:12       ` gregkh
2015-10-06  5:20         ` gregkh
2015-10-06  5:23           ` Sudeep Dutt
2015-10-06  7:56             ` gregkh
2015-10-06  8:05               ` Sudeep Dutt
2015-10-06  8:33                 ` gregkh
2015-10-06 12:04                   ` Sudeep Dutt
2015-09-30  1:09 ` Ashutosh Dixit [this message]
2015-09-30  1:10 ` [PATCH char-misc-next v2 06/22] misc: mic: SCIF poll Ashutosh Dixit
2015-09-30  1:11 ` [PATCH char-misc-next v2 07/22] misc: mic: Add support for kernel mode SCIF clients Ashutosh Dixit
2015-09-30  1:12 ` [PATCH char-misc-next v2 08/22] misc: mic: MIC COSM bus Ashutosh Dixit
2015-09-30  1:12 ` [PATCH char-misc-next v2 09/22] misc: mic: Coprocessor State Management (COSM) driver Ashutosh Dixit
2015-09-30  1:12 ` [PATCH char-misc-next v2 10/22] misc: mic: COSM SCIF server Ashutosh Dixit
2015-09-30  1:13 ` [PATCH char-misc-next v2 11/22] misc: mic: COSM client driver Ashutosh Dixit
2015-09-30  1:13 ` [PATCH char-misc-next v2 12/22] misc: mic: Remove COSM functionality from the MIC host driver Ashutosh Dixit
2015-09-30  1:13 ` [PATCH char-misc-next v2 13/22] misc: mic: Remove COSM functionality from the MIC card driver Ashutosh Dixit
2015-09-30  1:14 ` [PATCH char-misc-next v2 14/22] misc: mic: Update MIC host daemon with COSM changes Ashutosh Dixit
2015-09-30  1:15 ` [PATCH char-misc-next v2 15/22] misc: mic: SCIF RMA header file and IOCTL changes Ashutosh Dixit
2015-09-30  1:15 ` [PATCH char-misc-next v2 16/22] misc: mic: SCIF RMA header file Ashutosh Dixit
2015-09-30  1:15 ` [PATCH char-misc-next v2 17/22] misc: mic: SCIF memory registration and unregistration Ashutosh Dixit
2015-09-30  1:15 ` [PATCH char-misc-next v2 18/22] misc: mic: SCIF RMA list operations Ashutosh Dixit
2015-09-30  1:15 ` [PATCH char-misc-next v2 19/22] misc: mic: SCIF remote memory map/unmap interface Ashutosh Dixit
2015-09-30  1:16 ` [PATCH char-misc-next v2 20/22] misc: mic: SCIF DMA and CPU copy interface Ashutosh Dixit
2015-09-30  1:16 ` [PATCH char-misc-next v2 21/22] misc: mic: SCIF fence Ashutosh Dixit
2015-09-30  1:16 ` [PATCH char-misc-next v2 22/22] 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=8e003194da11abd636dd1dfebbb5895a0ceac932.1443573394.git.ashutosh.dixit@intel.com \
    --to=ashutosh.dixit@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jacek.lawrynowicz@intel.com \
    --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®