Commit 9ca277eb authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'rproc-v4.10-fixes' of git://github.com/andersson/remoteproc

Pull remoteproc fixes from Bjorn Andersson:
 "This fixes two regressions that have been reported to be introduced in
  v4.10-rc1.

   - correct an incorrect usage of the kref api

   - revert the change to make the resource table read-only. As the
     space each vdev resource is used as virtio device config space it
     must be shared with the remote"

* tag 'rproc-v4.10-fixes' of git://github.com/andersson/remoteproc:
  Revert "remoteproc: Merge table_ptr and cached_table pointers"
  remoteproc: fix vdev reference management
parents 1d865da7 a0c10687
...@@ -396,9 +396,6 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc, ...@@ -396,9 +396,6 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc,
goto unwind_vring_allocations; goto unwind_vring_allocations;
} }
/* track the rvdevs list reference */
kref_get(&rvdev->refcount);
list_add_tail(&rvdev->node, &rproc->rvdevs); list_add_tail(&rvdev->node, &rproc->rvdevs);
rproc_add_subdev(rproc, &rvdev->subdev, rproc_add_subdev(rproc, &rvdev->subdev,
...@@ -889,13 +886,15 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) ...@@ -889,13 +886,15 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
/* /*
* Create a copy of the resource table. When a virtio device starts * Create a copy of the resource table. When a virtio device starts
* and calls vring_new_virtqueue() the address of the allocated vring * and calls vring_new_virtqueue() the address of the allocated vring
* will be stored in the table_ptr. Before the device is started, * will be stored in the cached_table. Before the device is started,
* table_ptr will be copied into device memory. * cached_table will be copied into device memory.
*/ */
rproc->table_ptr = kmemdup(table, tablesz, GFP_KERNEL); rproc->cached_table = kmemdup(table, tablesz, GFP_KERNEL);
if (!rproc->table_ptr) if (!rproc->cached_table)
goto clean_up; goto clean_up;
rproc->table_ptr = rproc->cached_table;
/* reset max_notifyid */ /* reset max_notifyid */
rproc->max_notifyid = -1; rproc->max_notifyid = -1;
...@@ -914,16 +913,18 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) ...@@ -914,16 +913,18 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
} }
/* /*
* The starting device has been given the rproc->table_ptr as the * The starting device has been given the rproc->cached_table as the
* resource table. The address of the vring along with the other * resource table. The address of the vring along with the other
* allocated resources (carveouts etc) is stored in table_ptr. * allocated resources (carveouts etc) is stored in cached_table.
* In order to pass this information to the remote device we must copy * In order to pass this information to the remote device we must copy
* this information to device memory. We also update the table_ptr so * this information to device memory. We also update the table_ptr so
* that any subsequent changes will be applied to the loaded version. * that any subsequent changes will be applied to the loaded version.
*/ */
loaded_table = rproc_find_loaded_rsc_table(rproc, fw); loaded_table = rproc_find_loaded_rsc_table(rproc, fw);
if (loaded_table) if (loaded_table) {
memcpy(loaded_table, rproc->table_ptr, tablesz); memcpy(loaded_table, rproc->cached_table, tablesz);
rproc->table_ptr = loaded_table;
}
/* power up the remote processor */ /* power up the remote processor */
ret = rproc->ops->start(rproc); ret = rproc->ops->start(rproc);
...@@ -951,7 +952,8 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) ...@@ -951,7 +952,8 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
clean_up_resources: clean_up_resources:
rproc_resource_cleanup(rproc); rproc_resource_cleanup(rproc);
clean_up: clean_up:
kfree(rproc->table_ptr); kfree(rproc->cached_table);
rproc->cached_table = NULL;
rproc->table_ptr = NULL; rproc->table_ptr = NULL;
rproc_disable_iommu(rproc); rproc_disable_iommu(rproc);
...@@ -1185,7 +1187,8 @@ void rproc_shutdown(struct rproc *rproc) ...@@ -1185,7 +1187,8 @@ void rproc_shutdown(struct rproc *rproc)
rproc_disable_iommu(rproc); rproc_disable_iommu(rproc);
/* Free the copy of the resource table */ /* Free the copy of the resource table */
kfree(rproc->table_ptr); kfree(rproc->cached_table);
rproc->cached_table = NULL;
rproc->table_ptr = NULL; rproc->table_ptr = NULL;
/* if in crash state, unlock crash handler */ /* if in crash state, unlock crash handler */
......
...@@ -408,7 +408,8 @@ enum rproc_crash_type { ...@@ -408,7 +408,8 @@ enum rproc_crash_type {
* @crash_comp: completion used to sync crash handler and the rproc reload * @crash_comp: completion used to sync crash handler and the rproc reload
* @recovery_disabled: flag that state if recovery was disabled * @recovery_disabled: flag that state if recovery was disabled
* @max_notifyid: largest allocated notify id. * @max_notifyid: largest allocated notify id.
* @table_ptr: our copy of the resource table * @table_ptr: pointer to the resource table in effect
* @cached_table: copy of the resource table
* @has_iommu: flag to indicate if remote processor is behind an MMU * @has_iommu: flag to indicate if remote processor is behind an MMU
*/ */
struct rproc { struct rproc {
...@@ -440,6 +441,7 @@ struct rproc { ...@@ -440,6 +441,7 @@ struct rproc {
bool recovery_disabled; bool recovery_disabled;
int max_notifyid; int max_notifyid;
struct resource_table *table_ptr; struct resource_table *table_ptr;
struct resource_table *cached_table;
bool has_iommu; bool has_iommu;
bool auto_boot; bool auto_boot;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment