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

rpmsg: qcom_smd: Use qcom_smem_is_available()

Rather than looking up a dummy item from SMEM, use the new
qcom_smem_is_available() function to make the code more clear
(and reduce the overhead slightly).

Add the same check to qcom_smd_register_edge() as well to ensure that
it only succeeds if SMEM is already available - if a driver calls the
function and SMEM is not available yet then the initial state will be
read incorrectly and the RPMSG devices might never become available.

Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
Link: https://lore.kernel.org/r/20230531-rpm-rproc-v3-8-a07dcdefd918@gerhold.net
Signed-off-by: Bjorn Andersson <andersson@kernel.org>

authored by

Stephan Gerhold and committed by
Bjorn Andersson
181563be 4dbb9e23

+5 -5
+5 -5
drivers/rpmsg/qcom_smd.c
··· 1479 1479 struct qcom_smd_edge *edge; 1480 1480 int ret; 1481 1481 1482 + if (!qcom_smem_is_available()) 1483 + return ERR_PTR(-EPROBE_DEFER); 1484 + 1482 1485 edge = kzalloc(sizeof(*edge), GFP_KERNEL); 1483 1486 if (!edge) 1484 1487 return ERR_PTR(-ENOMEM); ··· 1556 1553 static int qcom_smd_probe(struct platform_device *pdev) 1557 1554 { 1558 1555 struct device_node *node; 1559 - void *p; 1560 1556 1561 - /* Wait for smem */ 1562 - p = qcom_smem_get(QCOM_SMEM_HOST_ANY, smem_items[0].alloc_tbl_id, NULL); 1563 - if (PTR_ERR(p) == -EPROBE_DEFER) 1564 - return PTR_ERR(p); 1557 + if (!qcom_smem_is_available()) 1558 + return -EPROBE_DEFER; 1565 1559 1566 1560 for_each_available_child_of_node(pdev->dev.of_node, node) 1567 1561 qcom_smd_register_edge(&pdev->dev, node);