Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp4595490rwn; Sun, 11 Sep 2022 16:21:08 -0700 (PDT) X-Google-Smtp-Source: AA6agR5bxUlGl6xyyIdv2J1qDN2IwX0thLqrd+Ispwq3NlF0bO+rZT6nwHIoGVoqZo6gD8z2di8c X-Received: by 2002:a17:903:54a:b0:174:ec04:53ea with SMTP id jo10-20020a170903054a00b00174ec0453eamr23720660plb.3.1662938468286; Sun, 11 Sep 2022 16:21:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662938468; cv=none; d=google.com; s=arc-20160816; b=QqChhSBRDcMFUeCIq5FartPQYaQQyppyuIyTZUNXz9rm2md5QWdJchoWFEGfWCMsUH vnACs1Nxa5OXmm0LbQkLiWeKg5bBhn+pMvDXCd1TiRJ7iGcvgjhwUIyit9xKsCvMtqFv Y4oOhibMamy4DsrmnTQWh60QGnvIqDdSKanKmX/PsM8KIhQvxYqwzkIWd5Tp35L3IBT1 Z6VGRuxqGuoM5l2TegldWKymxTt1WpLvQP8XsFVcudnfgQZjpDQqIK/oaZ3/Z34F1ghu fpXqvcl7LgyeTinX/f5OcLF4e1TfG7yOddsp7AaORi0o14deVw0JEbZLDMB9gPlEDExO 5Tlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:subject:message-id:date:user-agent:from :references:in-reply-to:mime-version:dkim-signature; bh=6zz4KZBW7Xf3j2wSfJkLMRtj9pzF2Gk+JSNytD8QvQo=; b=nTRokQtShMWgkIvg8/cNJE0CeW3ESeLKThAs3s9PVBj+UUppwI0CBDsot0jeQkghb7 WAxXwDV7xmFfayNBLMJK/UEWcn8mN92c0E+lU4Dq8muIkrpl7RzWA/je3jz7IkNiMbDB 4W7BBuxXXiQz27WL/UokwOnAUITIPUFSOHLgwL/I2rMPIKQ80v6SqO5707UN9KP8v9+I QhsLTSX6jMvLbDGPMXPBNvJ5wWQ8h7OKyrTyrsifK6mKDb8Mf5l3MaV+EZp4ev+wBNVg 5xkEexvsKaPhTJVWjUwpXZu72qx/H2kDseEq6gaygsszPmpr6OQ5gLHyBgJCCTItc67r Leow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="KImd/fj3"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s9-20020a170902ea0900b00176cdaf0ad4si8937149plg.286.2022.09.11.16.20.56; Sun, 11 Sep 2022 16:21:08 -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=@chromium.org header.s=google header.b="KImd/fj3"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229631AbiIKXB2 (ORCPT + 99 others); Sun, 11 Sep 2022 19:01:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229751AbiIKXBX (ORCPT ); Sun, 11 Sep 2022 19:01:23 -0400 Received: from mail-oa1-x34.google.com (mail-oa1-x34.google.com [IPv6:2001:4860:4864:20::34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63F072656C for ; Sun, 11 Sep 2022 16:01:21 -0700 (PDT) Received: by mail-oa1-x34.google.com with SMTP id 586e51a60fabf-12b542cb1d3so9263618fac.13 for ; Sun, 11 Sep 2022 16:01:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=to:subject:message-id:date:user-agent:from:references:in-reply-to :mime-version:from:to:cc:subject:date; bh=6zz4KZBW7Xf3j2wSfJkLMRtj9pzF2Gk+JSNytD8QvQo=; b=KImd/fj3U/QgmbidNljOQB0iad08e+8tC7mEvjqEkvixNow+Z+wnVSTmbZV23CPKc0 HVBqKaWCkJGIcrZIoRXaBlNToBktSydSGjlVRnEZNW0TQpsTqVtdIUtF/c4W/YXoR8L6 uT5mXj7nfc2hX+QoF4xeHytsBybIIg2LF5SlM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:user-agent:from:references:in-reply-to :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=6zz4KZBW7Xf3j2wSfJkLMRtj9pzF2Gk+JSNytD8QvQo=; b=qSc4QUDUL6q58pelpPSuZ8ihX1fonkZMpdj9jnJmIDptbbP32mrxdwhJGvj4NGdtlG oFFNrD0ZzYQuZAJVESw8FQ41mrHjjbcp3bfsSNSn2oVsQpe8vRVzIsmnlo5cGGYEhoUk 9LGzMvhGSbt1CYgYfEB+gmbzFQFHwWRK8bsVkDNAZ95QcAsi/5gTSQCknLZ55uEd5VL6 16IK/1aKnonIIwMIPkFvL9Ry6O6rtb5B3/Y2fR6oN1w+LR09s/7w7YckfACPi9Luuy7v Y6/VBpD3KcTV/oouoI30B75nPYYfpwLfjzed8o9RBroik16scLuoPPQCc4eQPPtjBRlG TPSw== X-Gm-Message-State: ACgBeo0yVv1KZgd7oISuB1CLJbFUskJyXNc+QhVfs6mb4qMRvYQf97cH LSyhkh6dYrDhdS/L582vJDm/09ZReHI/hI+hl1r7Fg== X-Received: by 2002:a05:6808:1142:b0:343:86a0:dedc with SMTP id u2-20020a056808114200b0034386a0dedcmr8186288oiu.44.1662937280713; Sun, 11 Sep 2022 16:01:20 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sun, 11 Sep 2022 18:01:20 -0500 MIME-Version: 1.0 In-Reply-To: <1662643422-14909-8-git-send-email-quic_srivasam@quicinc.com> References: <1662643422-14909-1-git-send-email-quic_srivasam@quicinc.com> <1662643422-14909-8-git-send-email-quic_srivasam@quicinc.com> From: Stephen Boyd User-Agent: alot/0.10 Date: Sun, 11 Sep 2022 18:01:20 -0500 Message-ID: Subject: Re: [PATCH v6 7/8] remoteproc: qcom: Add support for memory sandbox To: Srinivasa Rao Mandadapu , agross@kernel.org, bgoswami@quicinc.com, bjorn.andersson@linaro.org, broonie@kernel.org, devicetree@vger.kernel.org, judyhsiao@chromium.org, lgirdwood@gmail.com, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org, perex@perex.cz, quic_plai@quicinc.com, quic_rohkumar@quicinc.com, robh+dt@kernel.org, srinivas.kandagatla@linaro.org, tiwai@suse.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Quoting Srinivasa Rao Mandadapu (2022-09-08 06:23:41) > diff --git a/drivers/remoteproc/qcom_q6v5_adsp.c b/drivers/remoteproc/qcom_q6v5_adsp.c > index ccb5592..e55d593 100644 > --- a/drivers/remoteproc/qcom_q6v5_adsp.c > +++ b/drivers/remoteproc/qcom_q6v5_adsp.c > @@ -9,6 +9,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -48,6 +49,8 @@ > #define LPASS_PWR_ON_REG 0x10 > #define LPASS_HALTREQ_REG 0x0 > > +#define SID_MASK_DEFAULT 0xF > + > #define QDSP6SS_XO_CBCR 0x38 > #define QDSP6SS_CORE_CBCR 0x20 > #define QDSP6SS_SLEEP_CBCR 0x3c > @@ -333,6 +336,42 @@ static int adsp_load(struct rproc *rproc, const struct firmware *fw) > return 0; > } > > +static void adsp_unmap_smmu(struct rproc *rproc) > +{ > + struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; Drop the cast, it's unnecessary. > + > + iommu_unmap(rproc->domain, adsp->mem_phys, adsp->mem_size); > +} > + [..] > @@ -343,9 +382,17 @@ static int adsp_start(struct rproc *rproc) > if (ret) > return ret; > > + if (adsp->has_iommu) { > + ret = adsp_map_smmu(adsp, rproc); > + if (ret) { > + dev_err(adsp->dev, "ADSP smmu mapping failed\n"); > + goto disable_irqs; > + } > + } > + > ret = clk_prepare_enable(adsp->xo); > if (ret) > - goto disable_irqs; > + goto adsp_smmu_unmap; > > ret = qcom_rproc_pds_enable(adsp, adsp->proxy_pds, > adsp->proxy_pd_count); > @@ -401,6 +448,9 @@ static int adsp_start(struct rproc *rproc) > qcom_rproc_pds_disable(adsp, adsp->proxy_pds, adsp->proxy_pd_count); > disable_xo_clk: > clk_disable_unprepare(adsp->xo); > +adsp_smmu_unmap: > + if (adsp->has_iommu) > + adsp_unmap_smmu(rproc); Why not pass adsp directly to adsp_unmap_smmu()? And even better would be to make it a no-op when adsp->has_iommu is false, so that the code reads straight-line otherwise. > disable_irqs: > qcom_q6v5_unprepare(&adsp->q6v5); > > @@ -429,6 +479,9 @@ static int adsp_stop(struct rproc *rproc) > if (ret) > dev_err(adsp->dev, "failed to shutdown: %d\n", ret); > > + if (adsp->has_iommu) > + adsp_unmap_smmu(rproc); > + > handover = qcom_q6v5_unprepare(&adsp->q6v5); > if (handover) > qcom_adsp_pil_handover(&adsp->q6v5); > -- > 2.7.4 >