mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wendy Liang <wendy.liang@xilinx.com>
To: <bjorn.andersson@linaro.org>
Cc: <linux-remoteproc@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	"Wendy Liang" <wendy.liang@xilinx.com>,
	Wendy Liang <jliang@xilinx.com>,
	Michal Simek <michal.simek@xilinx.com>
Subject: [RFC LINUX PATCH 12/19] remoteproc: use rproc_id_rsc for data got from idr_find()
Date: Fri, 24 Mar 2017 12:22:28 -0700	[thread overview]
Message-ID: <1490383355-23176-13-git-send-email-jliang@xilinx.com> (raw)
In-Reply-To: <1490383355-23176-1-git-send-email-jliang@xilinx.com>

From: Wendy Liang <wendy.liang@xilinx.com>

As not just rproc_vring can have notifyid, rproc uses rproc_id_rsc
for the resource which has notifyid. And thus, the data got from
idr_find() can be something else rather than rproc_vring.
And thus, add the virtio_interrupt() to handle interrupt not
just for vrings, and change the existing vq_interrupt() to call
virtio_interrupt().

Signed-off-by: Wendy Liang <jliang@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---
 drivers/remoteproc/remoteproc_core.c     |  7 +++---
 drivers/remoteproc/remoteproc_internal.h |  1 +
 drivers/remoteproc/remoteproc_virtio.c   | 42 +++++++++++++++++++++++++++-----
 3 files changed, 41 insertions(+), 9 deletions(-)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index d711345..ffd1de2 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -274,7 +274,7 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i)
 	 * TODO: assign a notifyid for rvdev updates as well
 	 * TODO: support predefined notifyids (via resource table)
 	 */
-	ret = idr_alloc(&rproc->notifyids, rvring, 0, 0, GFP_KERNEL);
+	ret = rproc_idr_alloc(rproc, rvring, RPROC_IDR_VRING, 0, 0);
 	if (ret < 0) {
 		dev_err(dev, "idr_alloc failed: %d\n", ret);
 		dma_free_coherent(dev->parent, size, va, dma);
@@ -337,8 +337,9 @@ void rproc_free_vring(struct rproc_vring *rvring)
 	int idx = rvring->rvdev->vring - rvring;
 	struct fw_rsc_vdev *rsc;
 
-	dma_free_coherent(rproc->dev.parent, size, rvring->va, rvring->dma);
-	idr_remove(&rproc->notifyids, rvring->notifyid);
+	dma_free_coherent(rproc->dev.parent, size, rvring->va,
+				  rvring->dma);
+	rproc_idr_remove(rproc, rvring->notifyid);
 
 	/* reset resource entry info */
 	rsc = (void *)rproc->table_ptr + rvring->rvdev->rsc_offset;
diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h
index 865bd1c..0cfc942 100644
--- a/drivers/remoteproc/remoteproc_internal.h
+++ b/drivers/remoteproc/remoteproc_internal.h
@@ -72,6 +72,7 @@ struct rproc_fw_ops {
 
 /* from remoteproc_core.c */
 void rproc_release(struct kref *kref);
+irqreturn_t rproc_virtio_interrupt(struct rproc *rproc, int notifyid);
 irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int vq_id);
 int rproc_boot_nowait(struct rproc *rproc);
 void rproc_vdev_release(struct kref *ref);
diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c
index 0142cc3..e45e17b 100644
--- a/drivers/remoteproc/remoteproc_virtio.c
+++ b/drivers/remoteproc/remoteproc_virtio.c
@@ -43,7 +43,7 @@ static bool rproc_virtio_notify(struct virtqueue *vq)
 }
 
 /**
- * rproc_vq_interrupt() - tell remoteproc that a virtqueue is interrupted
+ * rproc_virtio_interrupt() - tell remoteproc that a vdev is interrupted
  * @rproc: handle to the remote processor
  * @notifyid: index of the signalled virtqueue (unique per this @rproc)
  *
@@ -54,17 +54,47 @@ static bool rproc_virtio_notify(struct virtqueue *vq)
  * Returns IRQ_NONE if no message was found in the @notifyid virtqueue,
  * and otherwise returns IRQ_HANDLED.
  */
-irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int notifyid)
+irqreturn_t rproc_virtio_interrupt(struct rproc *rproc, int notifyid)
 {
+	struct rproc_id_rsc *rsc;
 	struct rproc_vring *rvring;
 
-	dev_dbg(&rproc->dev, "vq index %d is interrupted\n", notifyid);
+	dev_dbg(&rproc->dev, "virtio index %d is interrupted\n", notifyid);
+
+	rsc = idr_find(&rproc->notifyids, notifyid);
+	if (!rsc || !rsc->rsc_ptr)
+		return IRQ_NONE;
 
-	rvring = idr_find(&rproc->notifyids, notifyid);
-	if (!rvring || !rvring->vq)
+	if (rsc->rsc_type == RPROC_IDR_VRING) {
+		rvring = rsc->rsc_ptr;
+		if (!rvring->vq)
+			return IRQ_NONE;
+		return vring_interrupt(0, rvring->vq);
+	} else if (rsc->rsc_type == RPROC_IDR_VDEV) {
+		dev_info(&rproc->dev, "vdev intr is not supported yet.\n");
 		return IRQ_NONE;
+	}
 
-	return vring_interrupt(0, rvring->vq);
+	dev_err(&rproc->dev, "Unknown rsc type: 0x%x\n", rsc->rsc_type);
+	return IRQ_NONE;
+}
+EXPORT_SYMBOL(rproc_virtio_interrupt);
+
+/**
+ * rproc_vq_interrupt() - tell remoteproc that a virtqueue is interrupted
+ * @rproc: handle to the remote processor
+ * @notifyid: index of the signalled virtqueue (unique per this @rproc)
+ *
+ * This function should be called by the platform-specific rproc driver,
+ * when the remote processor signals that a specific virtqueue has pending
+ * messages available.
+ *
+ * Returns IRQ_NONE if no message was found in the @notifyid virtqueue,
+ * and otherwise returns IRQ_HANDLED.
+ */
+irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int notifyid)
+{
+	return rproc_virtio_interrupt(rproc, notifyid);
 }
 EXPORT_SYMBOL(rproc_vq_interrupt);
 
-- 
1.9.1

  parent reply	other threads:[~2017-03-24 19:32 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-24 19:22 [RFC LINUX PATCH 00/19] Allow master to restart without restarting slave Wendy Liang
2017-03-24 19:22 ` [RFC LINUX PATCH 01/19] remoteproc: Add is_runinng to remoteproc ops Wendy Liang
2017-03-24 19:22 ` [RFC LINUX PATCH 02/19] remtoeproc: Add an operation to check if remote is running Wendy Liang
2017-03-24 19:22 ` [RFC LINUX PATCH 03/19] remoteproc: Add a running independent state Wendy Liang
2017-03-24 19:22 ` [RFC LINUX PATCH 04/19] remoteproc: sysfs: Add " Wendy Liang
2017-03-24 19:22 ` [RFC LINUX PATCH 05/19] remoteproc: check if remote is running the fw before reload fw Wendy Liang
2017-03-24 19:22 ` [RFC LINUX PATCH 06/19] remoteproc: elf loader: Add get checksum firmware implementation Wendy Liang
2017-03-24 19:22 ` [RFC LINUX PATCH 07/19] remoteproc: Add firmware checksum resource entry Wendy Liang
2017-03-24 19:22 ` [RFC LINUX PATCH 08/19] remoteproc: add a function to set fw checksum rsc Wendy Liang
2017-03-24 19:22 ` [RFC LINUX PATCH 09/19] remoteproc: check firmware checksum in rproc_is_running_fw() Wendy Liang
2017-03-24 19:22 ` [RFC LINUX PATCH 10/19] remoteproc: Add rproc resource with id struct Wendy Liang
2017-03-24 19:22 ` [RFC LINUX PATCH 11/19] remoteproc: Add rproc_idr_alloc/remove wrapper Wendy Liang
2017-03-24 19:22 ` Wendy Liang [this message]
2017-03-24 19:22 ` [RFC LINUX PATCH 13/19] remoteproc: add config_wait_complete to rproc_vdev Wendy Liang
2017-03-24 19:22 ` [RFC LINUX PATCH 14/19] remoteproc virtio: handle rproc vdev notification Wendy Liang
2017-03-24 19:22 ` [RFC LINUX PATCH 15/19] remoteproc: virtio: rename rproc_virtio_notify to rproc_vq_notify Wendy Liang
2017-03-24 19:22 ` [RFC LINUX PATCH 16/19] remoteproc: virtio: use rproc_virtio_notify() to notify vdev changes Wendy Liang
2017-03-24 19:22 ` [RFC LINUX PATCH 17/19] remoteproc: virtio: kick in reset virtio Wendy Liang
2017-03-24 19:22 ` [RFC LINUX PATCH 18/19] remoteproc: shutdown: set state to OFFLINE after stopping remote Wendy Liang
2017-03-24 19:22 ` [RFC LINUX PATCH 19/19] remoteproc: virtio: idr_alloc for rvdev Wendy Liang

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=1490383355-23176-13-git-send-email-jliang@xilinx.com \
    --to=wendy.liang@xilinx.com \
    --cc=bjorn.andersson@linaro.org \
    --cc=jliang@xilinx.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=michal.simek@xilinx.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®