From patchwork Mon Mar 9 18:22:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sibi Sankar X-Patchwork-Id: 11427689 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7D6B814E3 for ; Mon, 9 Mar 2020 18:23:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5D5B6208C3 for ; Mon, 9 Mar 2020 18:23:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="rUVDDRXF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727446AbgCISX0 (ORCPT ); Mon, 9 Mar 2020 14:23:26 -0400 Received: from mail27.static.mailgun.info ([104.130.122.27]:27735 "EHLO mail27.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727263AbgCISX0 (ORCPT ); Mon, 9 Mar 2020 14:23:26 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1583778205; h=Content-Transfer-Encoding: MIME-Version: References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=5pJKzeW4cHTF7+UFcjOH7U5y2zK8JxKCVKx6r3Uqg0I=; b=rUVDDRXFTiPYV6Ty2BLuVB0UYUL+PtBB+JIGspYtQv0jrTqeGfqjba7BpzaKd22fVeidVLTf tF2Q746yRT0p0bfp/c5gWxXtz/VVYTjnbY2jSNmStx1QoSRbYMjk3Ls9tpPHYyN/XTsUUvUs ski+8p+EotDqXRbEhMdLDKhV28s= X-Mailgun-Sending-Ip: 104.130.122.27 X-Mailgun-Sid: WyI1MzIzYiIsICJsaW51eC1hcm0tbXNtQHZnZXIua2VybmVsLm9yZyIsICJiZTllNGEiXQ== Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5e66899d.7f98a0d85b58-smtp-out-n03; Mon, 09 Mar 2020 18:23:25 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 5DC64C44791; Mon, 9 Mar 2020 18:23:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from blr-ubuntu-87.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sibis) by smtp.codeaurora.org (Postfix) with ESMTPSA id 85160C43636; Mon, 9 Mar 2020 18:23:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 85160C43636 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=sibis@codeaurora.org From: Sibi Sankar To: bjorn.andersson@linaro.org, robh+dt@kernel.org, joro@8bytes.org Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, iommu@lists.linux-foundation.org, linux-remoteproc@vger.kernel.org, ohad@wizery.com, agross@kernel.org, Sibi Sankar Subject: [PATCH 1/3] iommu: Export "iommu_request_dm_for_dev" Date: Mon, 9 Mar 2020 23:52:53 +0530 Message-Id: <20200309182255.20142-2-sibis@codeaurora.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200309182255.20142-1-sibis@codeaurora.org> References: <20200309182255.20142-1-sibis@codeaurora.org> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Export "iommu_request_dm_for_dev" to allow for modular builds of drivers requesting for direct mapping. Signed-off-by: Sibi Sankar --- drivers/iommu/iommu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 3e3528436e0b2..06a36230fe22d 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -2353,6 +2353,7 @@ int iommu_request_dm_for_dev(struct device *dev) { return request_default_domain_for_dev(dev, IOMMU_DOMAIN_IDENTITY); } +EXPORT_SYMBOL_GPL(iommu_request_dm_for_dev); /* Request that a device can't be direct mapped by the IOMMU */ int iommu_request_dma_domain_for_dev(struct device *dev) From patchwork Mon Mar 9 18:22:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sibi Sankar X-Patchwork-Id: 11427701 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6072E1800 for ; Mon, 9 Mar 2020 18:23:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 416D9208C3 for ; Mon, 9 Mar 2020 18:23:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="G2WghETO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727336AbgCISXk (ORCPT ); Mon, 9 Mar 2020 14:23:40 -0400 Received: from mail27.static.mailgun.info ([104.130.122.27]:37549 "EHLO mail27.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727458AbgCISXj (ORCPT ); Mon, 9 Mar 2020 14:23:39 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1583778219; h=Content-Transfer-Encoding: MIME-Version: References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=0L6hvTnXaIEvYUm41ewmxRMMySvYQQsl8lFHaAgfCVo=; b=G2WghETOV5LbiH69tgkMJOmRruk2OxjPGirzYGVU3JkEHl7Oe5UpYZCN3OV2oblpjE86h3FH KJewckrkQ/btHcPUodhqCS+uRMglt2Nd20DBSkeH6TA3LZTGrvtk2diSXLCa42rpUkrBe/Zr VMM5dIdJzEn8h7eLBn1AU0HeaUQ= X-Mailgun-Sending-Ip: 104.130.122.27 X-Mailgun-Sid: WyI1MzIzYiIsICJsaW51eC1hcm0tbXNtQHZnZXIua2VybmVsLm9yZyIsICJiZTllNGEiXQ== Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5e6689a1.7fa1ff099650-smtp-out-n01; Mon, 09 Mar 2020 18:23:29 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 3BA67C433CB; Mon, 9 Mar 2020 18:23:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from blr-ubuntu-87.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sibis) by smtp.codeaurora.org (Postfix) with ESMTPSA id 6D764C44793; Mon, 9 Mar 2020 18:23:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 6D764C44793 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=sibis@codeaurora.org From: Sibi Sankar To: bjorn.andersson@linaro.org, robh+dt@kernel.org, joro@8bytes.org Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, iommu@lists.linux-foundation.org, linux-remoteproc@vger.kernel.org, ohad@wizery.com, agross@kernel.org, Sibi Sankar Subject: [PATCH 2/3] dt-bindings: remoteproc: qcom: Add modem-firmware bindings Date: Mon, 9 Mar 2020 23:52:54 +0530 Message-Id: <20200309182255.20142-3-sibis@codeaurora.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200309182255.20142-1-sibis@codeaurora.org> References: <20200309182255.20142-1-sibis@codeaurora.org> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Introduce modem-firmware binding to allow Q6 modem to boot on platforms which do not have trustZone. Signed-off-by: Sibi Sankar --- Documentation/devicetree/bindings/remoteproc/qcom,q6v5.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/remoteproc/qcom,q6v5.txt b/Documentation/devicetree/bindings/remoteproc/qcom,q6v5.txt index 88dfa3fc15f78..b1715bc90fb05 100644 --- a/Documentation/devicetree/bindings/remoteproc/qcom,q6v5.txt +++ b/Documentation/devicetree/bindings/remoteproc/qcom,q6v5.txt @@ -198,6 +198,10 @@ The Hexagon node may also have an subnode named either "smd-edge" or related to the Hexagon. See ../soc/qcom/qcom,smd.txt and ../soc/qcom/qcom,glink.txt for details on how to describe these. +The Hexagon node must contain a subnode named "modem-firmware" on +platforms which do not have TrustZone. The sub-node should have the +iommu property as described in ../iommu/iommu.txt. + = EXAMPLE The following example describes the resources needed to boot control the Hexagon, as it is found on MSM8974 boards. From patchwork Mon Mar 9 18:22:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sibi Sankar X-Patchwork-Id: 11427697 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C6BB013A4 for ; Mon, 9 Mar 2020 18:23:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9EB7524658 for ; Mon, 9 Mar 2020 18:23:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="hh+5JS6k" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727492AbgCISXf (ORCPT ); Mon, 9 Mar 2020 14:23:35 -0400 Received: from mail26.static.mailgun.info ([104.130.122.26]:43393 "EHLO mail26.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727473AbgCISXe (ORCPT ); Mon, 9 Mar 2020 14:23:34 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1583778214; h=Content-Transfer-Encoding: MIME-Version: References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=oXtyD64Mkp4ykU5HU0PK0xoug9dx6XnlZHC0tqZFXR8=; b=hh+5JS6kJOjUneOL+wmOuJWsuf+H16IaoitIO7aIfto9Y0+Ueh4ZOjndg2ipQd3GlQNVpybc s9fETMBDECDcPyvnyk2aQRcRHVNOAJn8BwLW6GSSMI6tr3kDCj2x2d8kV9tHlhm6BIR3eTuO uR5Q5a69KwqMiNSy8xQUlUsDsWc= X-Mailgun-Sending-Ip: 104.130.122.26 X-Mailgun-Sid: WyI1MzIzYiIsICJsaW51eC1hcm0tbXNtQHZnZXIua2VybmVsLm9yZyIsICJiZTllNGEiXQ== Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5e6689a6.7f2cf01a2180-smtp-out-n02; Mon, 09 Mar 2020 18:23:34 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id B6A80C433D2; Mon, 9 Mar 2020 18:23:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from blr-ubuntu-87.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sibis) by smtp.codeaurora.org (Postfix) with ESMTPSA id 4282BC43636; Mon, 9 Mar 2020 18:23:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 4282BC43636 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=sibis@codeaurora.org From: Sibi Sankar To: bjorn.andersson@linaro.org, robh+dt@kernel.org, joro@8bytes.org Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, iommu@lists.linux-foundation.org, linux-remoteproc@vger.kernel.org, ohad@wizery.com, agross@kernel.org, Sibi Sankar Subject: [PATCH 3/3] remoteproc: qcom_q6v5_mss: Request direct mapping for firmware subdevice Date: Mon, 9 Mar 2020 23:52:55 +0530 Message-Id: <20200309182255.20142-4-sibis@codeaurora.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200309182255.20142-1-sibis@codeaurora.org> References: <20200309182255.20142-1-sibis@codeaurora.org> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The Q6 modem sub-system has direct access to DDR through memnoc and an indirect access routed through a SMMU which MSS CE (crypto engine sub-component of MSS) uses during out of reset sequence. Request direct mapping for the modem-firmware subdevice since smmu is not expected to provide access control/translation for these SIDs (sandboxing of the modem is achieved through XPUs engaged using SMC calls). Signed-off-by: Sibi Sankar --- drivers/remoteproc/qcom_q6v5_mss.c | 68 ++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c index d7667418a62f4..ceb7f71dd17df 100644 --- a/drivers/remoteproc/qcom_q6v5_mss.c +++ b/drivers/remoteproc/qcom_q6v5_mss.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -202,6 +203,7 @@ struct q6v5 { struct qcom_rproc_subdev smd_subdev; struct qcom_rproc_ssr ssr_subdev; struct qcom_sysmon *sysmon; + struct device *fw_subdev; bool need_mem_protection; bool has_alt_reset; bool has_halt_nav; @@ -378,6 +380,67 @@ static void q6v5_pds_disable(struct q6v5 *qproc, struct device **pds, } } +static int qcom_init_firmware(struct q6v5 *qproc) +{ + struct platform_device_info info; + struct platform_device *pdev; + struct device_node *np; + int ret; + + np = of_get_child_by_name(qproc->dev->of_node, "modem-firmware"); + if (!np) + return 0; + + memset(&info, 0, sizeof(info)); + info.fwnode = &np->fwnode; + info.parent = qproc->dev; + info.name = np->name; + + pdev = platform_device_register_full(&info); + if (IS_ERR(pdev)) { + of_node_put(np); + return PTR_ERR(pdev); + } + + pdev->dev.of_node = np; + ret = of_dma_configure(&pdev->dev, np, true); + if (ret) { + dev_err(&pdev->dev, "Failed to configure DMA\n"); + goto err_unregister; + } + + ret = iommu_request_dm_for_dev(&pdev->dev); + if (ret) { + dev_err(&pdev->dev, "Failed to request direct mapping\n"); + goto err_unregister; + } + + qproc->fw_subdev = &pdev->dev; + of_node_put(np); + return 0; + +err_unregister: + platform_device_unregister(pdev); + of_node_put(np); + return ret; +} + +static void qcom_remove_firmware(struct q6v5 *qproc) +{ + struct iommu_domain *iommu; + + if (!qproc->fw_subdev) + return; + + iommu = iommu_get_domain_for_dev(qproc->fw_subdev); + if (!iommu) + return; + + iommu_detach_device(iommu, qproc->fw_subdev); + iommu_domain_free(iommu); + platform_device_unregister(to_platform_device(qproc->fw_subdev)); +} + static int q6v5_xfer_mem_ownership(struct q6v5 *qproc, int *current_perm, bool local, bool remote, phys_addr_t addr, size_t size) @@ -1722,6 +1785,10 @@ static int q6v5_probe(struct platform_device *pdev) if (ret) goto detach_proxy_pds; + ret = qcom_init_firmware(qproc); + if (ret) + goto detach_proxy_pds; + qproc->mpss_perm = BIT(QCOM_SCM_VMID_HLOS); qproc->mba_perm = BIT(QCOM_SCM_VMID_HLOS); qcom_add_glink_subdev(rproc, &qproc->glink_subdev); @@ -1759,6 +1826,7 @@ static int q6v5_remove(struct platform_device *pdev) qcom_remove_glink_subdev(qproc->rproc, &qproc->glink_subdev); qcom_remove_smd_subdev(qproc->rproc, &qproc->smd_subdev); qcom_remove_ssr_subdev(qproc->rproc, &qproc->ssr_subdev); + qcom_remove_firmware(qproc); q6v5_pds_detach(qproc, qproc->active_pds, qproc->active_pd_count); q6v5_pds_detach(qproc, qproc->proxy_pds, qproc->proxy_pd_count);