From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ohad Ben-Cohen Subject: [PATCH 3/7] remoteproc: safer boot/shutdown order Date: Thu, 1 Mar 2012 10:11:33 +0200 Message-ID: <1330589497-4139-4-git-send-email-ohad@wizery.com> References: <1330589497-4139-1-git-send-email-ohad@wizery.com> Mime-Version: 1.0 Return-path: In-Reply-To: <1330589497-4139-1-git-send-email-ohad@wizery.com> Sender: linux-kernel-owner@vger.kernel.org To: linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Ohad Ben-Cohen , Brian Swetland , Iliyan Malchev , Arnd Bergmann , Grant Likely , Rusty Russell , Mark Grosen , John Williams , Michal Simek , Loic PALLARDY , Ludovic BARRE , Omar Ramirez Luna , Guzman Lugo Fernando , Anna Suman , Clark Rob , Stephen Boyd , Saravana Kannan , David Brown , Kieran Bingham , Tony Lindgren List-Id: linux-omap@vger.kernel.org Boot the remote processor only after setting up the virtqueues, and shut it down before deleting them. Remote processors should obey virtio status changes, and therefore not manipulate/trigger the virtqueues while the virtio driver isn't ready, but it's just safer not to rely on that (plus a vq access might already be inflight while a vdev status is changed). We also don't have yet status change notifications, but that's a temporary limitation. Signed-off-by: Ohad Ben-Cohen Cc: Brian Swetland Cc: Iliyan Malchev Cc: Arnd Bergmann Cc: Grant Likely Cc: Rusty Russell Cc: Mark Grosen Cc: John Williams Cc: Michal Simek Cc: Loic PALLARDY Cc: Ludovic BARRE Cc: Omar Ramirez Luna Cc: Guzman Lugo Fernando Cc: Anna Suman Cc: Clark Rob Cc: Stephen Boyd Cc: Saravana Kannan Cc: David Brown Cc: Kieran Bingham Cc: Tony Lindgren --- drivers/remoteproc/remoteproc_virtio.c | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c index 4f73e81..78d8527 100644 --- a/drivers/remoteproc/remoteproc_virtio.c +++ b/drivers/remoteproc/remoteproc_virtio.c @@ -123,14 +123,14 @@ static void rproc_virtio_del_vqs(struct virtio_device *vdev) struct virtqueue *vq, *n; struct rproc *rproc = vdev_to_rproc(vdev); + /* power down the remote processor before deleting vqs */ + rproc_shutdown(rproc); + list_for_each_entry_safe(vq, n, &vdev->vqs, list) { struct rproc_virtio_vq_info *rpvq = vq->priv; vring_del_virtqueue(vq); kfree(rpvq); } - - /* power down the remote processor */ - rproc_shutdown(rproc); } static int rproc_virtio_find_vqs(struct virtio_device *vdev, unsigned nvqs, @@ -145,13 +145,6 @@ static int rproc_virtio_find_vqs(struct virtio_device *vdev, unsigned nvqs, if (nvqs != 2) return -EINVAL; - /* boot the remote processor */ - ret = rproc_boot(rproc); - if (ret) { - dev_err(rproc->dev, "rproc_boot() failed %d\n", ret); - goto error; - } - for (i = 0; i < nvqs; ++i) { vqs[i] = rp_find_vq(vdev, i, callbacks[i], names[i]); if (IS_ERR(vqs[i])) { @@ -160,6 +153,13 @@ static int rproc_virtio_find_vqs(struct virtio_device *vdev, unsigned nvqs, } } + /* now that the vqs are all set, boot the remote processor */ + ret = rproc_boot(rproc); + if (ret) { + dev_err(rproc->dev, "rproc_boot() failed %d\n", ret); + goto error; + } + return 0; error: -- 1.7.5.4