mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tomas Winkler <tomas.winkler@intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Alexander Usyskin <alexander.usyskin@intel.com>,
	linux-kernel@vger.kernel.org,
	Tomas Winkler <tomas.winkler@intel.com>
Subject: [char-misc-next 08/12] mei: hw: add dma ring control block
Date: Tue, 31 Jul 2018 09:35:40 +0300	[thread overview]
Message-ID: <20180731063544.25540-9-tomas.winkler@intel.com> (raw)
In-Reply-To: <20180731063544.25540-1-tomas.winkler@intel.com>

The DMA ring control block contains write and read
indices for host and device circular buffers.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
---
 drivers/misc/mei/dma-ring.c | 21 +++++++++++++++++++++
 drivers/misc/mei/hbm.c      |  2 ++
 drivers/misc/mei/hw.h       | 23 +++++++++++++++++++++++
 drivers/misc/mei/mei_dev.h  |  1 +
 4 files changed, 47 insertions(+)

diff --git a/drivers/misc/mei/dma-ring.c b/drivers/misc/mei/dma-ring.c
index 368012116196..70901319534e 100644
--- a/drivers/misc/mei/dma-ring.c
+++ b/drivers/misc/mei/dma-ring.c
@@ -101,3 +101,24 @@ bool mei_dma_ring_is_allocated(struct mei_device *dev)
 {
 	return !!dev->dr_dscr[DMA_DSCR_HOST].vaddr;
 }
+
+static inline
+struct hbm_dma_ring_ctrl *mei_dma_ring_ctrl(struct mei_device *dev)
+{
+	return (struct hbm_dma_ring_ctrl *)dev->dr_dscr[DMA_DSCR_CTRL].vaddr;
+}
+
+/**
+ * mei_dma_ring_reset - reset the dma control block
+ *
+ * @dev: mei device
+ */
+void mei_dma_ring_reset(struct mei_device *dev)
+{
+	struct hbm_dma_ring_ctrl *ctrl = mei_dma_ring_ctrl(dev);
+
+	if (!ctrl)
+		return;
+
+	memset(ctrl, 0, sizeof(*ctrl));
+}
diff --git a/drivers/misc/mei/hbm.c b/drivers/misc/mei/hbm.c
index a3cdffb9ef62..f15d44bda28e 100644
--- a/drivers/misc/mei/hbm.c
+++ b/drivers/misc/mei/hbm.c
@@ -324,6 +324,8 @@ static int mei_hbm_dma_setup_req(struct mei_device *dev)
 		req.dma_dscr[i].size = dev->dr_dscr[i].size;
 	}
 
+	mei_dma_ring_reset(dev);
+
 	ret = mei_hbm_write_message(dev, &mei_hdr, &req);
 	if (ret) {
 		dev_err(dev->dev, "dma setup request write failed: ret = %d.\n",
diff --git a/drivers/misc/mei/hw.h b/drivers/misc/mei/hw.h
index 65655925791a..4f09bbcdbc2a 100644
--- a/drivers/misc/mei/hw.h
+++ b/drivers/misc/mei/hw.h
@@ -512,4 +512,27 @@ struct hbm_dma_setup_response {
 	u8 reserved[2];
 } __packed;
 
+/**
+ * struct mei_dma_ring_ctrl - dma ring control block
+ *
+ * @hbuf_wr_idx: host circular buffer write index in slots
+ * @reserved1: reserved for alignment
+ * @hbuf_rd_idx: host circular buffer read index in slots
+ * @reserved2: reserved for alignment
+ * @dbuf_wr_idx: device circular buffer write index in slots
+ * @reserved3: reserved for alignment
+ * @dbuf_rd_idx: device circular buffer read index in slots
+ * @reserved4: reserved for alignment
+ */
+struct hbm_dma_ring_ctrl {
+	u32 hbuf_wr_idx;
+	u32 reserved1;
+	u32 hbuf_rd_idx;
+	u32 reserved2;
+	u32 dbuf_wr_idx;
+	u32 reserved3;
+	u32 dbuf_rd_idx;
+	u32 reserved4;
+} __packed;
+
 #endif
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index a6796e3f712b..033b5eff8e59 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -597,6 +597,7 @@ void mei_cancel_work(struct mei_device *dev);
 int mei_dmam_ring_alloc(struct mei_device *dev);
 void mei_dmam_ring_free(struct mei_device *dev);
 bool mei_dma_ring_is_allocated(struct mei_device *dev);
+void mei_dma_ring_reset(struct mei_device *dev);
 
 /*
  *  MEI interrupt functions prototype
-- 
2.14.4


  parent reply	other threads:[~2018-07-31  6:37 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-31  6:35 [char-misc-next 00/12] mei: Add DMA ring Tomas Winkler
2018-07-31  6:35 ` [char-misc-next 01/12] mei: add support for variable length mei headers Tomas Winkler
2018-07-31  6:35 ` [char-misc-next 02/12] mei: hbm: define dma ring setup protocol Tomas Winkler
2018-07-31  6:35 ` [char-misc-next 03/12] mei: hbm: introduce dma bit in the message header Tomas Winkler
2018-07-31  6:35 ` [char-misc-next 04/12] mei: restrict dma ring support to hbm version 2.1 Tomas Winkler
2018-07-31  6:35 ` [char-misc-next 05/12] mei: define dma ring buffer sizes for PCH12 HW and newer Tomas Winkler
2018-07-31  6:35 ` [char-misc-next 06/12] mei: dma ring buffers allocation Tomas Winkler
2018-08-02  8:18   ` Greg Kroah-Hartman
2018-08-02  8:20     ` Winkler, Tomas
2018-08-05 20:38     ` Winkler, Tomas
2018-09-12  7:13       ` Greg Kroah-Hartman
2018-07-31  6:35 ` [char-misc-next 07/12] mei: hbm: setup dma ring Tomas Winkler
2018-07-31  6:35 ` Tomas Winkler [this message]
2018-07-31  6:35 ` [char-misc-next 09/12] mei: dma ring: implement rx circular buffer logic Tomas Winkler
2018-07-31  6:35 ` [char-misc-next 10/12] mei: dma ring: implement transmit flow Tomas Winkler
2018-07-31  6:35 ` [char-misc-next 11/12] mei: bump hbm version to 2.1 Tomas Winkler
2018-07-31  6:35 ` [char-misc-next 12/12] mei: me: mark CNP devices as having dma support Tomas Winkler
2018-08-02  8:19 ` [char-misc-next 00/12] mei: Add DMA ring Greg Kroah-Hartman
2018-08-08 16:11   ` Winkler, Tomas
2018-08-19  5:34     ` Winkler, Tomas
2018-08-19  6:12       ` 'Greg Kroah-Hartman'
2018-09-12  7:12     ` Greg Kroah-Hartman

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=20180731063544.25540-9-tomas.winkler@intel.com \
    --to=tomas.winkler@intel.com \
    --cc=alexander.usyskin@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /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®