From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 137A8C77B73 for ; Mon, 5 Jun 2023 19:45:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235656AbjFETpo (ORCPT ); Mon, 5 Jun 2023 15:45:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235484AbjFETpm (ORCPT ); Mon, 5 Jun 2023 15:45:42 -0400 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88A1DF7 for ; Mon, 5 Jun 2023 12:45:40 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2b1ac373c9eso49112521fa.0 for ; Mon, 05 Jun 2023 12:45:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685994338; x=1688586338; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=JcZ93fvlNJOqEO0Tdnw3u/AdHxtIux+b0q18hlD/gSA=; b=hJfacGJKJPT71X6jtrr8ZfxHcePnVyeBvNVQMNHCgz/Lf18kj3AceRWGUXv1oJvSpK vzK/wFbc9scOgbo8HjoXwk7uFFyj2O4s3rm7N4OlnZ25cwhXlywk68ySWCPWX8OEmeEw fgzDBmTl7/5IuJR97Yp57a8DrXtDLE6XuOa/rIJzbc/14k5xTuvrl3CfEEJ6VOxV311E DZi/IneYbXGp6Ga09fRl4PE9t5iM4hTdYGvxEidbav0IOBydjVErJhSwR9yzWJJM9S4T +dEZg2wlKiIZO4AMTBAbGSYDYhWzhpLCPR4gTC+bK2HdM3hGxIH1Ea2Am542CKmSh5N+ Cb+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685994338; x=1688586338; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=JcZ93fvlNJOqEO0Tdnw3u/AdHxtIux+b0q18hlD/gSA=; b=Uo1RJR+br3/ELwMPJo5cD0pZfsjA3jSB4LVmD5KmEPAVrLTNLtO7oa9WSOnmqW7EnH N29j976YZidtk2+lci7GaIy32NyGrprwPp63hGswtMiTPriaM/w16kEURKvMbUg1ML3/ zxjYN1Qy/w/zkgrBne4sw4d3sTj6u8iqjULe1dx4ZQW6olI7bcP/Yndu97fMZv++Hu6O tp7a1RTWMIVNkI+8pH9ba4Yqd5ukmkbyBF3Om1s1RN3R+UVFoFfSxvok67WxOOIOeEUv WoZ03rTXSrbvc4rObdUvDodGJo0Cs88lGz9ODCcrg7xnzFIfy474jY/+sKORl82uwXrO 9jLA== X-Gm-Message-State: AC+VfDxRPC0ZR54QwvtQT3c36hvlEQ07tJ8ARrquHCMukcvF/uRD/eSw ooMcFWBbMZMhEkBFR/CEtxT4qA== X-Google-Smtp-Source: ACHHUZ6XGScdOXdySH1nJFnHwOrswCz1ofcR8yZ684/kUM758Hm/V8LTD7XLvT62BZKKf135ntqRAA== X-Received: by 2002:a2e:3515:0:b0:2b1:b6e9:b803 with SMTP id z21-20020a2e3515000000b002b1b6e9b803mr147678ljz.17.1685994338211; Mon, 05 Jun 2023 12:45:38 -0700 (PDT) Received: from [192.168.1.101] (abyj96.neoplus.adsl.tpnet.pl. [83.9.29.96]) by smtp.gmail.com with ESMTPSA id i13-20020a2e864d000000b002a7853b9339sm1575768ljj.119.2023.06.05.12.45.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Jun 2023 12:45:37 -0700 (PDT) Message-ID: <909e2780-80d1-3c9d-7be3-bd2d0c0c6e69@linaro.org> Date: Mon, 5 Jun 2023 21:45:36 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.2 Subject: Re: [PATCH 09/14] rpmsg: qcom_smd: Use qcom_smem_is_available() Content-Language: en-US To: Stephan Gerhold Cc: Bjorn Andersson , Andy Gross , 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 References: <20230531-rpm-rproc-v1-0-e0a3b6de1f14@gerhold.net> <20230531-rpm-rproc-v1-9-e0a3b6de1f14@gerhold.net> <0f48649e-27d6-97f7-98b8-fe10b99d0236@linaro.org> From: Konrad Dybcio In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On 5.06.2023 21:18, Stephan Gerhold wrote: > On Mon, Jun 05, 2023 at 08:56:44PM +0200, Konrad Dybcio wrote: >> >> >> On 5.06.2023 09:08, Stephan Gerhold wrote: >>> 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 >>> --- >>> 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); >> Hm.. we're not checking the return value here, at all.. Perhaps that >> could be improved and we could only check for smem presence inside >> qcom_smd_register_edge()? >> > > I think the goal here it to register as many of the edges as possible, > so we wouldn't necessarily want to abort if one of them fails. That's > why it's enough to check for only for a possible -EPROBE_DEFER first. Hm I guess that's the better option, killing the entire platform (no rpm = no anything) because one edge failed to register would be not very user friendly.. > > But more importantly after this series this is legacy code that exists > only for backwards compatibility with older DTBs. The probe function > won't be called for DTBs in mainline anymore. So I think it's not worth > to improve it much anymore. ;) Right! Konrad > > Thanks, > Stephan