提交 433c0e04 编写于 作者: B Bjorn Andersson

remoteproc: Split driver and consumer dereferencing

In order to be able to lock a rproc driver implementations only when
used by a client, we must differ between the dereference operation of a
client and the implementation itself.

This patch brings no functional change.
Signed-off-by: NBjorn Andersson <bjorn.andersson@linaro.org>
上级 229b85a6
...@@ -101,9 +101,9 @@ int dummy_rproc_example(struct rproc *my_rproc) ...@@ -101,9 +101,9 @@ int dummy_rproc_example(struct rproc *my_rproc)
On success, the new rproc is returned, and on failure, NULL. On success, the new rproc is returned, and on failure, NULL.
Note: _never_ directly deallocate @rproc, even if it was not registered Note: _never_ directly deallocate @rproc, even if it was not registered
yet. Instead, when you need to unroll rproc_alloc(), use rproc_put(). yet. Instead, when you need to unroll rproc_alloc(), use rproc_free().
void rproc_put(struct rproc *rproc) void rproc_free(struct rproc *rproc)
- Free an rproc handle that was allocated by rproc_alloc. - Free an rproc handle that was allocated by rproc_alloc.
This function essentially unrolls rproc_alloc(), by decrementing the This function essentially unrolls rproc_alloc(), by decrementing the
rproc's refcount. It doesn't directly free rproc; that would happen rproc's refcount. It doesn't directly free rproc; that would happen
...@@ -131,7 +131,7 @@ int dummy_rproc_example(struct rproc *my_rproc) ...@@ -131,7 +131,7 @@ int dummy_rproc_example(struct rproc *my_rproc)
has completed successfully. has completed successfully.
After rproc_del() returns, @rproc is still valid, and its After rproc_del() returns, @rproc is still valid, and its
last refcount should be decremented by calling rproc_put(). last refcount should be decremented by calling rproc_free().
Returns 0 on success and -EINVAL if @rproc isn't valid. Returns 0 on success and -EINVAL if @rproc isn't valid.
......
...@@ -261,7 +261,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev) ...@@ -261,7 +261,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
return 0; return 0;
free_rproc: free_rproc:
rproc_put(rproc); rproc_free(rproc);
return ret; return ret;
} }
...@@ -290,7 +290,7 @@ static int da8xx_rproc_remove(struct platform_device *pdev) ...@@ -290,7 +290,7 @@ static int da8xx_rproc_remove(struct platform_device *pdev)
disable_irq(drproc->irq); disable_irq(drproc->irq);
rproc_del(rproc); rproc_del(rproc);
rproc_put(rproc); rproc_free(rproc);
return 0; return 0;
} }
......
...@@ -215,7 +215,7 @@ static int omap_rproc_probe(struct platform_device *pdev) ...@@ -215,7 +215,7 @@ static int omap_rproc_probe(struct platform_device *pdev)
return 0; return 0;
free_rproc: free_rproc:
rproc_put(rproc); rproc_free(rproc);
return ret; return ret;
} }
...@@ -224,7 +224,7 @@ static int omap_rproc_remove(struct platform_device *pdev) ...@@ -224,7 +224,7 @@ static int omap_rproc_remove(struct platform_device *pdev)
struct rproc *rproc = platform_get_drvdata(pdev); struct rproc *rproc = platform_get_drvdata(pdev);
rproc_del(rproc); rproc_del(rproc);
rproc_put(rproc); rproc_free(rproc);
return 0; return 0;
} }
......
...@@ -875,7 +875,7 @@ static int q6v5_probe(struct platform_device *pdev) ...@@ -875,7 +875,7 @@ static int q6v5_probe(struct platform_device *pdev)
return 0; return 0;
free_rproc: free_rproc:
rproc_put(rproc); rproc_free(rproc);
return ret; return ret;
} }
...@@ -885,7 +885,7 @@ static int q6v5_remove(struct platform_device *pdev) ...@@ -885,7 +885,7 @@ static int q6v5_remove(struct platform_device *pdev)
struct q6v5 *qproc = platform_get_drvdata(pdev); struct q6v5 *qproc = platform_get_drvdata(pdev);
rproc_del(qproc->rproc); rproc_del(qproc->rproc);
rproc_put(qproc->rproc); rproc_free(qproc->rproc);
return 0; return 0;
} }
......
...@@ -585,7 +585,7 @@ static int wcnss_probe(struct platform_device *pdev) ...@@ -585,7 +585,7 @@ static int wcnss_probe(struct platform_device *pdev)
return of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev); return of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
free_rproc: free_rproc:
rproc_put(rproc); rproc_free(rproc);
return ret; return ret;
} }
...@@ -598,7 +598,7 @@ static int wcnss_remove(struct platform_device *pdev) ...@@ -598,7 +598,7 @@ static int wcnss_remove(struct platform_device *pdev)
qcom_smem_state_put(wcnss->state); qcom_smem_state_put(wcnss->state);
rproc_del(wcnss->rproc); rproc_del(wcnss->rproc);
rproc_put(wcnss->rproc); rproc_free(wcnss->rproc);
return 0; return 0;
} }
......
...@@ -1307,7 +1307,7 @@ static struct device_type rproc_type = { ...@@ -1307,7 +1307,7 @@ static struct device_type rproc_type = {
* On success the new rproc is returned, and on failure, NULL. * On success the new rproc is returned, and on failure, NULL.
* *
* Note: _never_ directly deallocate @rproc, even if it was not registered * Note: _never_ directly deallocate @rproc, even if it was not registered
* yet. Instead, when you need to unroll rproc_alloc(), use rproc_put(). * yet. Instead, when you need to unroll rproc_alloc(), use rproc_free().
*/ */
struct rproc *rproc_alloc(struct device *dev, const char *name, struct rproc *rproc_alloc(struct device *dev, const char *name,
const struct rproc_ops *ops, const struct rproc_ops *ops,
...@@ -1386,7 +1386,22 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, ...@@ -1386,7 +1386,22 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
EXPORT_SYMBOL(rproc_alloc); EXPORT_SYMBOL(rproc_alloc);
/** /**
* rproc_put() - unroll rproc_alloc() * rproc_free() - unroll rproc_alloc()
* @rproc: the remote processor handle
*
* This function decrements the rproc dev refcount.
*
* If no one holds any reference to rproc anymore, then its refcount would
* now drop to zero, and it would be freed.
*/
void rproc_free(struct rproc *rproc)
{
put_device(&rproc->dev);
}
EXPORT_SYMBOL(rproc_free);
/**
* rproc_put() - release rproc reference
* @rproc: the remote processor handle * @rproc: the remote processor handle
* *
* This function decrements the rproc dev refcount. * This function decrements the rproc dev refcount.
...@@ -1411,7 +1426,7 @@ EXPORT_SYMBOL(rproc_put); ...@@ -1411,7 +1426,7 @@ EXPORT_SYMBOL(rproc_put);
* *
* After rproc_del() returns, @rproc isn't freed yet, because * After rproc_del() returns, @rproc isn't freed yet, because
* of the outstanding reference created by rproc_alloc. To decrement that * of the outstanding reference created by rproc_alloc. To decrement that
* one last refcount, one still needs to call rproc_put(). * one last refcount, one still needs to call rproc_free().
* *
* Returns 0 on success and -EINVAL if @rproc isn't valid. * Returns 0 on success and -EINVAL if @rproc isn't valid.
*/ */
......
...@@ -262,7 +262,7 @@ static int st_rproc_probe(struct platform_device *pdev) ...@@ -262,7 +262,7 @@ static int st_rproc_probe(struct platform_device *pdev)
return 0; return 0;
free_rproc: free_rproc:
rproc_put(rproc); rproc_free(rproc);
return ret; return ret;
} }
...@@ -277,7 +277,7 @@ static int st_rproc_remove(struct platform_device *pdev) ...@@ -277,7 +277,7 @@ static int st_rproc_remove(struct platform_device *pdev)
of_reserved_mem_device_release(&pdev->dev); of_reserved_mem_device_release(&pdev->dev);
rproc_put(rproc); rproc_free(rproc);
return 0; return 0;
} }
......
...@@ -257,7 +257,7 @@ static int sproc_drv_remove(struct platform_device *pdev) ...@@ -257,7 +257,7 @@ static int sproc_drv_remove(struct platform_device *pdev)
rproc_del(sproc->rproc); rproc_del(sproc->rproc);
dma_free_coherent(sproc->rproc->dev.parent, SPROC_FW_SIZE, dma_free_coherent(sproc->rproc->dev.parent, SPROC_FW_SIZE,
sproc->fw_addr, sproc->fw_dma_addr); sproc->fw_addr, sproc->fw_dma_addr);
rproc_put(sproc->rproc); rproc_free(sproc->rproc);
mdev->drv_data = NULL; mdev->drv_data = NULL;
...@@ -325,7 +325,7 @@ static int sproc_probe(struct platform_device *pdev) ...@@ -325,7 +325,7 @@ static int sproc_probe(struct platform_device *pdev)
free_rproc: free_rproc:
/* Reset device data upon error */ /* Reset device data upon error */
mdev->drv_data = NULL; mdev->drv_data = NULL;
rproc_put(rproc); rproc_free(rproc);
return err; return err;
} }
......
...@@ -208,7 +208,7 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev) ...@@ -208,7 +208,7 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev)
return 0; return 0;
err_put_rproc: err_put_rproc:
rproc_put(rproc); rproc_free(rproc);
err: err:
pm_runtime_put_noidle(dev); pm_runtime_put_noidle(dev);
pm_runtime_disable(dev); pm_runtime_disable(dev);
...@@ -220,7 +220,7 @@ static int wkup_m3_rproc_remove(struct platform_device *pdev) ...@@ -220,7 +220,7 @@ static int wkup_m3_rproc_remove(struct platform_device *pdev)
struct rproc *rproc = platform_get_drvdata(pdev); struct rproc *rproc = platform_get_drvdata(pdev);
rproc_del(rproc); rproc_del(rproc);
rproc_put(rproc); rproc_free(rproc);
pm_runtime_put_sync(&pdev->dev); pm_runtime_put_sync(&pdev->dev);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
......
...@@ -493,6 +493,7 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, ...@@ -493,6 +493,7 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
void rproc_put(struct rproc *rproc); void rproc_put(struct rproc *rproc);
int rproc_add(struct rproc *rproc); int rproc_add(struct rproc *rproc);
int rproc_del(struct rproc *rproc); int rproc_del(struct rproc *rproc);
void rproc_free(struct rproc *rproc);
int rproc_boot(struct rproc *rproc); int rproc_boot(struct rproc *rproc);
void rproc_shutdown(struct rproc *rproc); void rproc_shutdown(struct rproc *rproc);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册