remoteproc: Assign kref to rproc_vdev
No functional change Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
This commit is contained in:
parent
be33c28fad
commit
aab8d80223
@ -356,6 +356,8 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc,
|
|||||||
if (!rvdev)
|
if (!rvdev)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
kref_init(&rvdev->refcount);
|
||||||
|
|
||||||
rvdev->rproc = rproc;
|
rvdev->rproc = rproc;
|
||||||
|
|
||||||
/* parse the vrings */
|
/* parse the vrings */
|
||||||
@ -384,6 +386,14 @@ free_rvdev:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rproc_vdev_release(struct kref *ref)
|
||||||
|
{
|
||||||
|
struct rproc_vdev *rvdev = container_of(ref, struct rproc_vdev, refcount);
|
||||||
|
|
||||||
|
list_del(&rvdev->node);
|
||||||
|
kfree(rvdev);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* rproc_handle_trace() - handle a shared trace buffer resource
|
* rproc_handle_trace() - handle a shared trace buffer resource
|
||||||
* @rproc: the remote processor
|
* @rproc: the remote processor
|
||||||
|
@ -49,6 +49,7 @@ struct rproc_fw_ops {
|
|||||||
void rproc_release(struct kref *kref);
|
void rproc_release(struct kref *kref);
|
||||||
irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int vq_id);
|
irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int vq_id);
|
||||||
int rproc_boot_nowait(struct rproc *rproc);
|
int rproc_boot_nowait(struct rproc *rproc);
|
||||||
|
void rproc_vdev_release(struct kref *ref);
|
||||||
|
|
||||||
/* from remoteproc_virtio.c */
|
/* from remoteproc_virtio.c */
|
||||||
int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id);
|
int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id);
|
||||||
|
@ -282,14 +282,13 @@ static const struct virtio_config_ops rproc_virtio_config_ops = {
|
|||||||
* Never call this function directly; it will be called by the driver
|
* Never call this function directly; it will be called by the driver
|
||||||
* core when needed.
|
* core when needed.
|
||||||
*/
|
*/
|
||||||
static void rproc_vdev_release(struct device *dev)
|
static void rproc_virtio_dev_release(struct device *dev)
|
||||||
{
|
{
|
||||||
struct virtio_device *vdev = dev_to_virtio(dev);
|
struct virtio_device *vdev = dev_to_virtio(dev);
|
||||||
struct rproc_vdev *rvdev = vdev_to_rvdev(vdev);
|
struct rproc_vdev *rvdev = vdev_to_rvdev(vdev);
|
||||||
struct rproc *rproc = vdev_to_rproc(vdev);
|
struct rproc *rproc = vdev_to_rproc(vdev);
|
||||||
|
|
||||||
list_del(&rvdev->node);
|
kref_put(&rvdev->refcount, rproc_vdev_release);
|
||||||
kfree(rvdev);
|
|
||||||
|
|
||||||
put_device(&rproc->dev);
|
put_device(&rproc->dev);
|
||||||
}
|
}
|
||||||
@ -313,7 +312,7 @@ int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id)
|
|||||||
vdev->id.device = id,
|
vdev->id.device = id,
|
||||||
vdev->config = &rproc_virtio_config_ops,
|
vdev->config = &rproc_virtio_config_ops,
|
||||||
vdev->dev.parent = dev;
|
vdev->dev.parent = dev;
|
||||||
vdev->dev.release = rproc_vdev_release;
|
vdev->dev.release = rproc_virtio_dev_release;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We're indirectly making a non-temporary copy of the rproc pointer
|
* We're indirectly making a non-temporary copy of the rproc pointer
|
||||||
@ -325,6 +324,9 @@ int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id)
|
|||||||
*/
|
*/
|
||||||
get_device(&rproc->dev);
|
get_device(&rproc->dev);
|
||||||
|
|
||||||
|
/* Reference the vdev and vring allocations */
|
||||||
|
kref_get(&rvdev->refcount);
|
||||||
|
|
||||||
ret = register_virtio_device(vdev);
|
ret = register_virtio_device(vdev);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
put_device(&rproc->dev);
|
put_device(&rproc->dev);
|
||||||
|
@ -487,6 +487,7 @@ struct rproc_vring {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* struct rproc_vdev - remoteproc state for a supported virtio device
|
* struct rproc_vdev - remoteproc state for a supported virtio device
|
||||||
|
* @refcount: reference counter for the vdev and vring allocations
|
||||||
* @node: list node
|
* @node: list node
|
||||||
* @rproc: the rproc handle
|
* @rproc: the rproc handle
|
||||||
* @vdev: the virio device
|
* @vdev: the virio device
|
||||||
@ -494,6 +495,8 @@ struct rproc_vring {
|
|||||||
* @rsc_offset: offset of the vdev's resource entry
|
* @rsc_offset: offset of the vdev's resource entry
|
||||||
*/
|
*/
|
||||||
struct rproc_vdev {
|
struct rproc_vdev {
|
||||||
|
struct kref refcount;
|
||||||
|
|
||||||
struct list_head node;
|
struct list_head node;
|
||||||
struct rproc *rproc;
|
struct rproc *rproc;
|
||||||
struct virtio_device vdev;
|
struct virtio_device vdev;
|
||||||
|
Loading…
Reference in New Issue
Block a user