Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3627316pxb; Sun, 24 Oct 2021 07:06:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgLP+n26YONHIyAYoVn7UTwaD9FpUc100sXhBFiyvwAepD+FJEtXg65Bwlh2l4rcsXS8yj X-Received: by 2002:a63:874a:: with SMTP id i71mr6574589pge.200.1635084389741; Sun, 24 Oct 2021 07:06:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635084389; cv=none; d=google.com; s=arc-20160816; b=tYeFQg0cIJDvU1oeew5rx1Kt4Cu6qA+Mf+3jk8UdGzDRauuZdOIDdDGwSwFo+JX8mV 4FnyDv3bVDSQPNR/9HIJhEvvf6ennnrdwDrv+VXUkmvU2KIbA/rmuircsfOn5N6jw4gm L72+0C9LpVDJyC4rheKiayx7NX+1tjvA59NvO2XGLqgL/R5XYWATh3unzKK5n/bOeEGv 575JH/+eF253HvNw0AAblIhniuOKbWGKL5k8KtvWwuV+YYqVLhGCA7flip9msV2ALU5Z 2At4dFsFNulCYWEnvmrKFOwCZpcbBkrHisL5B0BEKBQ4cqOO6DclkZQ7N7OD3PbRA4RD zJmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=GMCyWWZB+F6GjYcUII59d8HlYaXQfCLuj1yTlXM312U=; b=zKsdJMCmlzMKllGYhDbSSWjrdO6KHhqqgIkqwa8ejClVQVD5OPW+qVNFv1sPaBtut+ ihKrtMOXYiWE9ezD6XtsJJJyqKQpgAqrGhE8sE8o1yQpWS4SYLAVerGOcJnAqXXTV3YH 2wCadBAkR9NdWNQgnKEqGBppPG68KhR+ZvBFylXaMfYcF022JQ3LiRxqPY8RepI507Zf pzs4JvJm1W92iROCUMsE3+hFECSDoumTWXusWoSAibNakClh1GVD3XUwENOEBJU/jzuq MuyRLL/rc5Xqmpr7iz2ibZal68vRwFfrL85S9BZmofUUuDSlK4t5neRKyU6DiC8UG2nI 5DMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="kFBYELY/"; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g7si11570306plp.282.2021.10.24.07.06.15; Sun, 24 Oct 2021 07:06:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="kFBYELY/"; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231400AbhJXOIQ (ORCPT + 99 others); Sun, 24 Oct 2021 10:08:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231524AbhJXOIO (ORCPT ); Sun, 24 Oct 2021 10:08:14 -0400 Received: from mail-oo1-xc30.google.com (mail-oo1-xc30.google.com [IPv6:2607:f8b0:4864:20::c30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 102D2C061767 for ; Sun, 24 Oct 2021 07:05:54 -0700 (PDT) Received: by mail-oo1-xc30.google.com with SMTP id d144-20020a4a5296000000b002b6cf3f9aceso1641931oob.13 for ; Sun, 24 Oct 2021 07:05:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GMCyWWZB+F6GjYcUII59d8HlYaXQfCLuj1yTlXM312U=; b=kFBYELY/mhygmo1FpH4bAgNd2Q6RwTquDOsCb9ND4E4OvmssrMcVvBfP23gFF/h06U fzVbSHvSGFVUSD7OkSxz/syXxX2EQ+MEMC3rJNJDuNCsvTDuqEUvyhYZRxWe6oOWcMtH 0OtuD5nAcNWgfXnCCGqNPiduNNnvfoP9w9ITGY6MnGA/Clm0M4z7CE49ws549p6o25yP N4SGugTF4fgQRR5VgyXJbkhkPp1mQgl8fmH/8qkz5zBoEKQomIZ6FVP1/cmsPeaAnXAA ofE1FpsOWZQuqUjHsa/Vvj+BqtsRNFrBCkFUyzyefm1OUS+41i+qU9gh/kOzU9ZQsc0A 8BKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GMCyWWZB+F6GjYcUII59d8HlYaXQfCLuj1yTlXM312U=; b=MpK2Itn2lwlGxwPWUDfauF/PV0THp3I05RprvOM/o/EI97sFV7RayviqACzY0Gl1tj oVi7jXIwrXdMSbuJh5Lj0H72o1UN1bsmqABdi/68uGRGe+7CI6l5C9fDVQ24dFRkUbRZ 7Oh2kgNwjZa85MV7kqNPr+FwUVuPptwvmLfMPtIaRIxJa/KCarTIuYdAnj38H0sKUrSF TIy3wvja0k4Tw86xxmson9aPzvRD30ITq2nCTJgsz3onxqd0x8ZYfNqE5Uko2i9g40US 4Q6cKRW/VRwkAzn/Vw5jVnQvEQ5htJyGxNX++lfGuQM+2uK42trOhN84+mWX1Tkcuh/f HpAw== X-Gm-Message-State: AOAM530FD8mjj/FUhYjufOttb85KQm7vg9JkH/BW1BUr9NEqGr3ou48L h8mlUSI5dfHBf8bE/IB0Bk7TIM8j/W0vEQ9pfGRfvA== X-Received: by 2002:a4a:ea96:: with SMTP id r22mr8261639ooh.13.1635084353330; Sun, 24 Oct 2021 07:05:53 -0700 (PDT) MIME-Version: 1.0 References: <20211013105541.68045-1-bhupesh.sharma@linaro.org> <20211013105541.68045-19-bhupesh.sharma@linaro.org> In-Reply-To: From: Bhupesh Sharma Date: Sun, 24 Oct 2021 19:35:42 +0530 Message-ID: Subject: Re: [PATCH v4 18/20] crypto: qce: Defer probing if BAM dma channel is not yet initialized To: Thara Gopinath Cc: MSM , linux-crypto@vger.kernel.org, bhupesh.linux@gmail.com, Linux Kernel Mailing List , devicetree , Rob Herring , Andy Gross , Herbert Xu , "David S . Miller" , Bjorn Andersson Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Hi Thara, On Wed, 20 Oct 2021 at 19:40, Thara Gopinath wrote: > > On 10/13/21 6:55 AM, Bhupesh Sharma wrote: > > Since the Qualcomm qce crypto driver needs the BAM dma driver to be > > setup first (to allow crypto operations), it makes sense to defer > > the qce crypto driver probing in case the BAM dma driver is not yet > > probed. > > > > Move the code leg requesting dma channels earlier in the > > probe() flow. This fixes the qce probe failure issues when both qce > > and BMA dma are compiled as static part of the kernel. > > Hi Bhupesh, > > I am quite curious to know the nature of probe failure you are seeing > with the current sequence. I am not against changing the sequence but > for me when a driver is enabled, it is clocks first, interconnect next > and then dma. Also I have tested the current sequence on sm8150 with > both the modules built in as static and I have not seen the failure. Sure. The problem I faced was the following. Let's consider the scenario where while the qce crypto driver and the interconnect are compiled as static parts of the kernel, the bam DMA driver is compiled as a module, then the -EPROBE_DEFER return leg from the qce crypto driver is very late in the probe() flow, as we first turn on the clocks and then the interconnect. Now the suggested linux deferred probe implementation is to return as early from the caling driver in case the called driver (subdev) is not yet ready. SInce the qce crypto driver requires the bam DMA to be set up first, it makes sense to move 'qce_dma_request' early in the boot flow. If it's not yet probed(), it probably doesn't make sense to set up the clks and interconnects yet in the qce driver. We can do it later when the bam DMA is setup. I have tested the following combinations with the change I made in this patchset: 1. qce - static, bam - module, interconnect - module -> qce_dma_request returned -EPROBE_DEFER 2. qce - static, bam - module, interconnect - static -> qce_dma_request returned -EPROBE_DEFER 3. qce - static, bam - static, interconnect - module -> qce_dma_request returned -EPROBE_DEFER 4. qce - static, bam - static, interconnect - static -> no -EPROBE_DEFER Thanks, Bhupesh > > Cc: Thara Gopinath > > Cc: Bjorn Andersson > > Signed-off-by: Bhupesh Sharma > > --- > > drivers/crypto/qce/core.c | 20 ++++++++++++-------- > > 1 file changed, 12 insertions(+), 8 deletions(-) > > > > diff --git a/drivers/crypto/qce/core.c b/drivers/crypto/qce/core.c > > index cb8c77709e1e..c6f686126fc9 100644 > > --- a/drivers/crypto/qce/core.c > > +++ b/drivers/crypto/qce/core.c > > @@ -209,9 +209,19 @@ static int qce_crypto_probe(struct platform_device *pdev) > > if (ret < 0) > > return ret; > > > > + /* qce driver requires BAM dma driver to be setup first. > > + * In case the dma channel are not set yet, this check > > + * helps use to return -EPROBE_DEFER earlier. > > + */ > > + ret = qce_dma_request(qce->dev, &qce->dma); > > + if (ret) > > + return ret; > > + > > qce->mem_path = of_icc_get(qce->dev, "memory"); > > - if (IS_ERR(qce->mem_path)) > > + if (IS_ERR(qce->mem_path)) { > > + qce_dma_release(&qce->dma); > > return PTR_ERR(qce->mem_path); > > + } > > > > qce->core = devm_clk_get_optional(qce->dev, "core"); > > if (IS_ERR(qce->core)) { > > @@ -247,10 +257,6 @@ static int qce_crypto_probe(struct platform_device *pdev) > > if (ret) > > goto err_clks_iface; > > > > - ret = qce_dma_request(qce->dev, &qce->dma); > > - if (ret) > > - goto err_clks; > > - > > ret = qce_check_version(qce); > > if (ret) > > goto err_clks; > > @@ -265,12 +271,10 @@ static int qce_crypto_probe(struct platform_device *pdev) > > > > ret = qce_register_algs(qce); > > if (ret) > > - goto err_dma; > > + goto err_clks; > > > > return 0; > > > > -err_dma: > > - qce_dma_release(&qce->dma); > > err_clks: > > clk_disable_unprepare(qce->bus); > > err_clks_iface: > > > >