diff options
-rw-r--r-- | drivers/soc/qcom/Kconfig | 1 | ||||
-rw-r--r-- | drivers/soc/qcom/rmtfs_mem.c | 34 |
2 files changed, 35 insertions, 0 deletions
diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index e050eb83341d..a993d19fa562 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig | |||
@@ -47,6 +47,7 @@ config QCOM_QMI_HELPERS | |||
47 | config QCOM_RMTFS_MEM | 47 | config QCOM_RMTFS_MEM |
48 | tristate "Qualcomm Remote Filesystem memory driver" | 48 | tristate "Qualcomm Remote Filesystem memory driver" |
49 | depends on ARCH_QCOM | 49 | depends on ARCH_QCOM |
50 | select QCOM_SCM | ||
50 | help | 51 | help |
51 | The Qualcomm remote filesystem memory driver is used for allocating | 52 | The Qualcomm remote filesystem memory driver is used for allocating |
52 | and exposing regions of shared memory with remote processors for the | 53 | and exposing regions of shared memory with remote processors for the |
diff --git a/drivers/soc/qcom/rmtfs_mem.c b/drivers/soc/qcom/rmtfs_mem.c index 0a43b2e8906f..c8999e38b005 100644 --- a/drivers/soc/qcom/rmtfs_mem.c +++ b/drivers/soc/qcom/rmtfs_mem.c | |||
@@ -37,6 +37,8 @@ struct qcom_rmtfs_mem { | |||
37 | phys_addr_t size; | 37 | phys_addr_t size; |
38 | 38 | ||
39 | unsigned int client_id; | 39 | unsigned int client_id; |
40 | |||
41 | unsigned int perms; | ||
40 | }; | 42 | }; |
41 | 43 | ||
42 | static ssize_t qcom_rmtfs_mem_show(struct device *dev, | 44 | static ssize_t qcom_rmtfs_mem_show(struct device *dev, |
@@ -151,9 +153,11 @@ static void qcom_rmtfs_mem_release_device(struct device *dev) | |||
151 | static int qcom_rmtfs_mem_probe(struct platform_device *pdev) | 153 | static int qcom_rmtfs_mem_probe(struct platform_device *pdev) |
152 | { | 154 | { |
153 | struct device_node *node = pdev->dev.of_node; | 155 | struct device_node *node = pdev->dev.of_node; |
156 | struct qcom_scm_vmperm perms[2]; | ||
154 | struct reserved_mem *rmem; | 157 | struct reserved_mem *rmem; |
155 | struct qcom_rmtfs_mem *rmtfs_mem; | 158 | struct qcom_rmtfs_mem *rmtfs_mem; |
156 | u32 client_id; | 159 | u32 client_id; |
160 | u32 vmid; | ||
157 | int ret; | 161 | int ret; |
158 | 162 | ||
159 | rmem = of_reserved_mem_lookup(node); | 163 | rmem = of_reserved_mem_lookup(node); |
@@ -204,10 +208,31 @@ static int qcom_rmtfs_mem_probe(struct platform_device *pdev) | |||
204 | 208 | ||
205 | rmtfs_mem->dev.release = qcom_rmtfs_mem_release_device; | 209 | rmtfs_mem->dev.release = qcom_rmtfs_mem_release_device; |
206 | 210 | ||
211 | ret = of_property_read_u32(node, "qcom,vmid", &vmid); | ||
212 | if (ret < 0 && ret != -EINVAL) { | ||
213 | dev_err(&pdev->dev, "failed to parse qcom,vmid\n"); | ||
214 | goto remove_cdev; | ||
215 | } else if (!ret) { | ||
216 | perms[0].vmid = QCOM_SCM_VMID_HLOS; | ||
217 | perms[0].perm = QCOM_SCM_PERM_RW; | ||
218 | perms[1].vmid = vmid; | ||
219 | perms[1].perm = QCOM_SCM_PERM_RW; | ||
220 | |||
221 | rmtfs_mem->perms = BIT(QCOM_SCM_VMID_HLOS); | ||
222 | ret = qcom_scm_assign_mem(rmtfs_mem->addr, rmtfs_mem->size, | ||
223 | &rmtfs_mem->perms, perms, 2); | ||
224 | if (ret < 0) { | ||
225 | dev_err(&pdev->dev, "assign memory failed\n"); | ||
226 | goto remove_cdev; | ||
227 | } | ||
228 | } | ||
229 | |||
207 | dev_set_drvdata(&pdev->dev, rmtfs_mem); | 230 | dev_set_drvdata(&pdev->dev, rmtfs_mem); |
208 | 231 | ||
209 | return 0; | 232 | return 0; |
210 | 233 | ||
234 | remove_cdev: | ||
235 | cdev_device_del(&rmtfs_mem->cdev, &rmtfs_mem->dev); | ||
211 | put_device: | 236 | put_device: |
212 | put_device(&rmtfs_mem->dev); | 237 | put_device(&rmtfs_mem->dev); |
213 | 238 | ||
@@ -217,6 +242,15 @@ put_device: | |||
217 | static int qcom_rmtfs_mem_remove(struct platform_device *pdev) | 242 | static int qcom_rmtfs_mem_remove(struct platform_device *pdev) |
218 | { | 243 | { |
219 | struct qcom_rmtfs_mem *rmtfs_mem = dev_get_drvdata(&pdev->dev); | 244 | struct qcom_rmtfs_mem *rmtfs_mem = dev_get_drvdata(&pdev->dev); |
245 | struct qcom_scm_vmperm perm; | ||
246 | |||
247 | if (rmtfs_mem->perms) { | ||
248 | perm.vmid = QCOM_SCM_VMID_HLOS; | ||
249 | perm.perm = QCOM_SCM_PERM_RW; | ||
250 | |||
251 | qcom_scm_assign_mem(rmtfs_mem->addr, rmtfs_mem->size, | ||
252 | &rmtfs_mem->perms, &perm, 1); | ||
253 | } | ||
220 | 254 | ||
221 | cdev_device_del(&rmtfs_mem->cdev, &rmtfs_mem->dev); | 255 | cdev_device_del(&rmtfs_mem->cdev, &rmtfs_mem->dev); |
222 | put_device(&rmtfs_mem->dev); | 256 | put_device(&rmtfs_mem->dev); |