Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+19 -14
+16 -13
drivers/remoteproc/remoteproc_core.c
··· 396 396 goto unwind_vring_allocations; 397 397 } 398 398 399 - /* track the rvdevs list reference */ 400 - kref_get(&rvdev->refcount); 401 - 402 399 list_add_tail(&rvdev->node, &rproc->rvdevs); 403 400 404 401 rproc_add_subdev(rproc, &rvdev->subdev, ··· 886 889 /* 887 890 * Create a copy of the resource table. When a virtio device starts 888 891 * and calls vring_new_virtqueue() the address of the allocated vring 889 - * will be stored in the table_ptr. Before the device is started, 890 - * table_ptr will be copied into device memory. 892 + * will be stored in the cached_table. Before the device is started, 893 + * cached_table will be copied into device memory. 891 894 */ 892 - rproc->table_ptr = kmemdup(table, tablesz, GFP_KERNEL); 893 - if (!rproc->table_ptr) 895 + rproc->cached_table = kmemdup(table, tablesz, GFP_KERNEL); 896 + if (!rproc->cached_table) 894 897 goto clean_up; 898 + 899 + rproc->table_ptr = rproc->cached_table; 895 900 896 901 /* reset max_notifyid */ 897 902 rproc->max_notifyid = -1; ··· 913 914 } 914 915 915 916 /* 916 - * The starting device has been given the rproc->table_ptr as the 917 + * The starting device has been given the rproc->cached_table as the 917 918 * resource table. The address of the vring along with the other 918 - * allocated resources (carveouts etc) is stored in table_ptr. 919 + * allocated resources (carveouts etc) is stored in cached_table. 919 920 * In order to pass this information to the remote device we must copy 920 921 * this information to device memory. We also update the table_ptr so 921 922 * that any subsequent changes will be applied to the loaded version. 922 923 */ 923 924 loaded_table = rproc_find_loaded_rsc_table(rproc, fw); 924 - if (loaded_table) 925 - memcpy(loaded_table, rproc->table_ptr, tablesz); 925 + if (loaded_table) { 926 + memcpy(loaded_table, rproc->cached_table, tablesz); 927 + rproc->table_ptr = loaded_table; 928 + } 926 929 927 930 /* power up the remote processor */ 928 931 ret = rproc->ops->start(rproc); ··· 952 951 clean_up_resources: 953 952 rproc_resource_cleanup(rproc); 954 953 clean_up: 955 - kfree(rproc->table_ptr); 954 + kfree(rproc->cached_table); 955 + rproc->cached_table = NULL; 956 956 rproc->table_ptr = NULL; 957 957 958 958 rproc_disable_iommu(rproc); ··· 1187 1185 rproc_disable_iommu(rproc); 1188 1186 1189 1187 /* Free the copy of the resource table */ 1190 - kfree(rproc->table_ptr); 1188 + kfree(rproc->cached_table); 1189 + rproc->cached_table = NULL; 1191 1190 rproc->table_ptr = NULL; 1192 1191 1193 1192 /* if in crash state, unlock crash handler */
+3 -1
include/linux/remoteproc.h
··· 408 408 * @crash_comp: completion used to sync crash handler and the rproc reload 409 409 * @recovery_disabled: flag that state if recovery was disabled 410 410 * @max_notifyid: largest allocated notify id. 411 - * @table_ptr: our copy of the resource table 411 + * @table_ptr: pointer to the resource table in effect 412 + * @cached_table: copy of the resource table 412 413 * @has_iommu: flag to indicate if remote processor is behind an MMU 413 414 */ 414 415 struct rproc { ··· 441 440 bool recovery_disabled; 442 441 int max_notifyid; 443 442 struct resource_table *table_ptr; 443 + struct resource_table *cached_table; 444 444 bool has_iommu; 445 445 bool auto_boot; 446 446 };