[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210517093428.670-10-xieyongji@bytedance.com>
Date: Mon, 17 May 2021 17:34:22 +0800
From: Xie Yongji <xieyongji@...edance.com>
To: mst@...hat.com, jasowang@...hat.com, stefanha@...hat.com
Cc: amit@...nel.org, arei.gonglei@...wei.com, airlied@...ux.ie,
kraxel@...hat.com, jean-philippe@...aro.org, ohad@...ery.com,
bjorn.andersson@...aro.org, david@...hat.com, vgoyal@...hat.com,
miklos@...redi.hu, lucho@...kov.net, asmadeus@...ewreck.org,
virtualization@...ts.linux-foundation.org,
linux-kernel@...r.kernel.org
Subject: [RFC PATCH 08/15] rpmsg: virtio: Handle virtio_device_ready() failure
Now virtio_device_ready() will return error if we get
invalid status. Let's handle this case on probe.
Signed-off-by: Xie Yongji <xieyongji@...edance.com>
---
drivers/rpmsg/virtio_rpmsg_bus.c | 31 +++++++++++++++++++------------
1 file changed, 19 insertions(+), 12 deletions(-)
diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c
index 10df8bc0c3e1..6a8eb8c74bca 100644
--- a/drivers/rpmsg/virtio_rpmsg_bus.c
+++ b/drivers/rpmsg/virtio_rpmsg_bus.c
@@ -812,6 +812,19 @@ static void rpmsg_xmit_done(struct virtqueue *svq)
wake_up_interruptible(&vrp->sendq);
}
+static int rpmsg_remove_device(struct device *dev, void *data)
+{
+ device_unregister(dev);
+
+ return 0;
+}
+
+static void virtio_rpmsg_remove_device(struct virtio_device *vdev)
+{
+ if (device_for_each_child(&vdev->dev, NULL, rpmsg_remove_device))
+ dev_warn(&vdev->dev, "can't remove rpmsg device: %d\n", ret);
+}
+
static int rpmsg_probe(struct virtio_device *vdev)
{
vq_callback_t *vq_cbs[] = { rpmsg_recv_done, rpmsg_xmit_done };
@@ -924,7 +937,9 @@ static int rpmsg_probe(struct virtio_device *vdev)
notify = virtqueue_kick_prepare(vrp->rvq);
/* From this point on, we can notify and get callbacks. */
- virtio_device_ready(vdev);
+ err = virtio_device_ready(vdev);
+ if (err)
+ goto remove_rpmsg_dev;
/* tell the remote processor it can start sending messages */
/*
@@ -937,7 +952,8 @@ static int rpmsg_probe(struct virtio_device *vdev)
dev_info(&vdev->dev, "rpmsg host is online\n");
return 0;
-
+remove_rpmsg_dev:
+ virtio_rpmsg_remove_device(vdev);
free_coherent:
kfree(vch);
dma_free_coherent(vdev->dev.parent, total_buf_space,
@@ -949,13 +965,6 @@ static int rpmsg_probe(struct virtio_device *vdev)
return err;
}
-static int rpmsg_remove_device(struct device *dev, void *data)
-{
- device_unregister(dev);
-
- return 0;
-}
-
static void rpmsg_remove(struct virtio_device *vdev)
{
struct virtproc_info *vrp = vdev->priv;
@@ -964,9 +973,7 @@ static void rpmsg_remove(struct virtio_device *vdev)
vdev->config->reset(vdev);
- ret = device_for_each_child(&vdev->dev, NULL, rpmsg_remove_device);
- if (ret)
- dev_warn(&vdev->dev, "can't remove rpmsg device: %d\n", ret);
+ virtio_rpmsg_remove_device(vdev);
idr_destroy(&vrp->endpoints);
--
2.11.0
Powered by blists - more mailing lists