From patchwork Thu Jun 8 07:10:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Gerhold X-Patchwork-Id: 104844 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp95661vqr; Thu, 8 Jun 2023 00:13:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ43yWT04/2wZJ/Bu3REcs9mDepF/zwy/gq/lQA8iNBBSlelPLIRTpY+E0LvlBEeIjMdA5uW X-Received: by 2002:a05:6a20:12c1:b0:10c:467a:536f with SMTP id v1-20020a056a2012c100b0010c467a536fmr6544804pzg.14.1686208399035; Thu, 08 Jun 2023 00:13:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686208399; cv=pass; d=google.com; s=arc-20160816; b=PBt7US8GY6U/GEXgrYG287YOR0wAR7Dt0CA5Df+pNdeX/1w0tQvBnezUuAyAJ4IN/O pNPoTm7/roOGYDZ+/T9VZiV0igrot0GTxgRFgAYCpCbX6LGNxqFr3jlv2d4Jki3QmXZm oHOLJNstA2rgXwiUYYntxktiN2y3oJJ93paY3aJCm+yZRVS8Ml/GuIuUcvVxdVVSMgGf 4AHvAYQsGDY/rS79ZfFJ2Oi6BKr/Y7PFczr+m4F2kHx6GZfsD5Ql9vGPWXqtt4jBXJyv dToEe9zCYObzVKUCXvuVDJ8C/K8EpTz6MWTMt+Ka0k66eDJQc+f2UTfRPC/5r2z5pUGJ oNRQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature:dkim-signature; bh=l/8mcRN+TlGYtBCi00HTVZhrkyxZgFaeeP1BtcLCr2U=; b=IkdCGd14Z6KUG1lxLxZjUEQmEU7EC+Vo2oxEO7AQXgYOC6scHyEXVjRuJskwnKWs3B CA44rDsfuRwZ+Jf7pTaYrOEABxyxX/fAnfQwEElk7PFfJRFKwrk0O23cqIPP4f7nrk7q hE9cJhk6R2XGFrvAHMu20gAW1RFEqoYPFVhCyiZPmkm0WYrVl5sshT4eW53u1tClmPKi MariPB2mR1VW1kfySNL1iFlPg5ZTkH5wvT/RmI6KbKN+VAl/csdf4/v/kdMJ+6m2Hddv rFd5oUBNW8p3S/Cg9Ko0t7HBLhh3aU5a5GLXcaodkdSJKHeBp/DtwVj1Hwq4PK2LD9Jb MMoA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gerhold.net header.s=strato-dkim-0002 header.b=bMrOq4xL; dkim=neutral (no key) header.i=@gerhold.net; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v189-20020a6389c6000000b005429972ba91si528537pgd.823.2023.06.08.00.13.04; Thu, 08 Jun 2023 00:13:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gerhold.net header.s=strato-dkim-0002 header.b=bMrOq4xL; dkim=neutral (no key) header.i=@gerhold.net; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235384AbjFHHLm (ORCPT + 99 others); Thu, 8 Jun 2023 03:11:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235330AbjFHHLU (ORCPT ); Thu, 8 Jun 2023 03:11:20 -0400 Received: from mo4-p03-ob.smtp.rzone.de (mo4-p03-ob.smtp.rzone.de [81.169.146.173]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E794137; Thu, 8 Jun 2023 00:11:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686208273; cv=none; d=strato.com; s=strato-dkim-0002; b=eBCb6uIPvhCwp7IvX1cC2QbipNEm7rAW6z+DvCUVeVphOt8yPEvY6hX5HmQwrALvne FwNVdUJUKduQbOxYMYsWq2JMfEUi5S9TtVKqgkeWCsEISy8ScS+wEkSMaElqBkRlH1lY NqF1UExPjfDo6HvG/utnxGbKSKCdpiO3wDDqZ7hpacCgATa2R7p/Nu17dcgagvk1uN3z jG3R+RhCaUdO4XTDSNOSHAyDF+ZGUQyFplGh1mqDJPoLKaDEQTmDVLfWPpsP5Lt0t25T f7uBUWCz/wzy8Ya6aDSaIu41/PrdQCffZH0cE2E8sROM/md2RSxS3D43Mm2+78ubE7jZ a3rQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1686208273; s=strato-dkim-0002; d=strato.com; h=Cc:To:In-Reply-To:References:Message-Id:Subject:Date:From:Cc:Date: From:Subject:Sender; bh=l/8mcRN+TlGYtBCi00HTVZhrkyxZgFaeeP1BtcLCr2U=; b=phH3AWtJ2yGumbEmd0U593q8AEeTR644uoRx/kFLLHg6lwXLyccwdiCkRyIPzlWyON WuHjbB32Es9z0BaEOGFNbMB7SSi03xG/WUj0HxfCo2T6q0O2knyWfgZl04/R1I3N/RAu AXh6prQty3bJaF1A3Y+hjV8UUQmE/D/A9b0wAchBS5yxONsjhBZU7kuIbDJnRyMrWxz8 ugRJrofVa0CIPVPdNRGD0hnA+d6tzMn3i9UoBhPsOHaj2Xz2oiD/up6v9SKNKYcjWXps bMgY43g5+meidmqg2RY2hVkbvM0vaBY6wHpSzauVoyM3/rK0oGZCgWdYKjXIKGY3+tZY PKaw== ARC-Authentication-Results: i=1; strato.com; arc=none; dkim=none X-RZG-CLASS-ID: mo03 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1686208273; s=strato-dkim-0002; d=gerhold.net; h=Cc:To:In-Reply-To:References:Message-Id:Subject:Date:From:Cc:Date: From:Subject:Sender; bh=l/8mcRN+TlGYtBCi00HTVZhrkyxZgFaeeP1BtcLCr2U=; b=bMrOq4xLkJx+oSfulwUCsG3+7+Lv/LOREI91TbvqT/6NHt0knavDlQ5UU6b2IUl/3z Is3/pXx8y5cKIn26i4zqm+AjIZJlk8Wwf1XTAJGk1vqF1OR2CxMPk5bsnWoxPq30nG7Z 5BM2mX2Twfs6lcximlEtFG9i9KLIzLc82MH/eGx1ilbIjkoPbrA7rE1znsicy1OaW1FG AhWFPq/x/7hTcKwb5MI5Lp4bb8FWMxJoahQg8fFS1OFaDcuRSud9BzrvuY06p/Uolhua 27dP15qOKajfWmGDksr/oageWtdDX7T/+wXqxTaGXhkUhCrRuR2x8Bi/klf2lL/YbKuE I1sw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; t=1686208273; s=strato-dkim-0003; d=gerhold.net; h=Cc:To:In-Reply-To:References:Message-Id:Subject:Date:From:Cc:Date: From:Subject:Sender; bh=l/8mcRN+TlGYtBCi00HTVZhrkyxZgFaeeP1BtcLCr2U=; b=s+BJ/B/yjlV5tA8tl4etHV9WY7g3nIkMSmlrJBbPNxJj0Dqq1NhzrLm9aEh3W2fokQ qikH2sO4WE4fBBDOwEAw== X-RZG-AUTH: ":P3gBZUipdd93FF5ZZvYFPugejmSTVR2nRPhVOQjVd4CteZ/7jYgS+mLFY+H0JAn8u4ly9TY=" Received: from [192.168.244.3] by smtp.strato.de (RZmta 49.5.3 DYNA|AUTH) with ESMTPSA id Z82ec2z587BDKI0 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Thu, 8 Jun 2023 09:11:13 +0200 (CEST) From: Stephan Gerhold Date: Thu, 08 Jun 2023 09:10:27 +0200 Subject: [PATCH v2 07/12] rpmsg: qcom_smd: Use qcom_smem_is_available() MIME-Version: 1.0 Message-Id: <20230531-rpm-rproc-v2-7-56a4a00c8260@gerhold.net> References: <20230531-rpm-rproc-v2-0-56a4a00c8260@gerhold.net> In-Reply-To: <20230531-rpm-rproc-v2-0-56a4a00c8260@gerhold.net> To: Bjorn Andersson Cc: Andy Gross , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Mathieu Poirier , linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org, Stephan Gerhold X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768117658298758364?= X-GMAIL-MSGID: =?utf-8?q?1768117658298758364?= 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. Signed-off-by: Stephan Gerhold Reviewed-by: Konrad Dybcio --- drivers/rpmsg/qcom_smd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/rpmsg/qcom_smd.c b/drivers/rpmsg/qcom_smd.c index 7b9c298aa491..43f601c84b4f 100644 --- a/drivers/rpmsg/qcom_smd.c +++ b/drivers/rpmsg/qcom_smd.c @@ -1479,6 +1479,9 @@ struct qcom_smd_edge *qcom_smd_register_edge(struct device *parent, struct qcom_smd_edge *edge; int ret; + if (!qcom_smem_is_available()) + return ERR_PTR(-EPROBE_DEFER); + edge = kzalloc(sizeof(*edge), GFP_KERNEL); if (!edge) return ERR_PTR(-ENOMEM); @@ -1553,12 +1556,9 @@ EXPORT_SYMBOL(qcom_smd_unregister_edge); static int qcom_smd_probe(struct platform_device *pdev) { struct device_node *node; - void *p; - /* Wait for smem */ - p = qcom_smem_get(QCOM_SMEM_HOST_ANY, smem_items[0].alloc_tbl_id, NULL); - if (PTR_ERR(p) == -EPROBE_DEFER) - return PTR_ERR(p); + if (!qcom_smem_is_available()) + return -EPROBE_DEFER; for_each_available_child_of_node(pdev->dev.of_node, node) qcom_smd_register_edge(&pdev->dev, node);