2022-09-28 12:58:37

by Srinivasa Rao Mandadapu

[permalink] [raw]
Subject: [PATCH v10 0/7] Update ADSP pil loader for SC7280 platform

Update ADSP pil loader driver for SC7280 platforms.

Changes since V9:
-- Add missing unevaluatedProperties in dt-bindings glink-edge.
Changes since V8:
-- Add glink-edge reference in dt-bindings.
-- Remove redundant glinke-edge properties in dt-bindings.
-- Make all reg propertioes as mandatory in dt-bindings.
-- Add iommus property in dt-bindings.
Changes since V7:
-- Drop out of reset time out patch.
-- Remove redundant clocks in dt bindings.
-- Fix dt compilation error in dt bindings.
Changes since V6:
-- Update dt-bindings with glink-edge
-- Add qcom,qmp property.
-- Update parse firmware callback.
-- Update commit message.
-- Update smmu map and unmap function names.
-- Revert adsp_ops const change.
-- Move iommu check to within smmu map/unmap functions.
Changes since V5:
-- Remove adsp_rproc_unmap_smmu, adsp_of_unmap_smmu, adsp_of_map_smmu and
adsp_rproc_map_smmu functions.
-- Remove find_loaded_rsc_table call back initialization.
-- Rename adsp_sandbox_needed to has_iommu.
-- Update parse_fw callback in rproc ops.
-- Remove qcom,adsp-memory-regions property in dt-bindings.
-- Change adsp binary extension name.
Changes since V4:
-- Update halt registers description in dt bindings.
-- Update Memory sandboxing with proper APIs for resource
allocation and free.
Changes since V3:
-- Rename is_adsp_sb_needed to adsp_sandbox_needed.
-- Update sc7280 compatible name entry in sorted order.
-- Add smmu unmapping in error case and in adsp stop.
-- Revert converting sdm845 dt bindings to generic and
create new dt bindings for sc7280.
Changes since V2:
-- Generated patch with -M flag.
-- Add Clock property in dt bindings.
-- Add qcom,adsp-memory-regions property.
-- Add is_adsp_sb_needed flag instead of is_wpss.
-- Initialize is_adsp_sb_needed flag.
-- Remove empty proxy pds array.
-- Replace platform_bus_type with adsp->dev->bus.
-- Use API of_parse_phandle_with_args() instead of
of_parse_phandle_with_fixed_args().
-- Replace adsp->is_wpss with adsp->is_adsp.
-- Update error handling in adsp_start().
Changes since V1:
-- Change reg property maxItems to minItems and update description.
-- Fix typo errors.

Srinivasa Rao Mandadapu (7):
dt-bindings: remoteproc: qcom: Add SC7280 ADSP support
remoteproc: qcom: Add flag in adsp private data structure
remoteproc: qcom: Add compatible name for SC7280 ADSP
remoteproc: qcom: Update rproc parse firmware callback
remoteproc: qcom: Replace hard coded values with macros
remoteproc: qcom: Add efuse evb selection control
remoteproc: qcom: Add support for memory sandbox

.../bindings/remoteproc/qcom,sc7280-adsp-pil.yaml | 195 +++++++++++++++++++++
drivers/remoteproc/qcom_q6v5_adsp.c | 124 ++++++++++++-
2 files changed, 315 insertions(+), 4 deletions(-)
create mode 100644 Documentation/devicetree/bindings/remoteproc/qcom,sc7280-adsp-pil.yaml

--
2.7.4


2022-09-28 12:59:31

by Srinivasa Rao Mandadapu

[permalink] [raw]
Subject: [PATCH v10 7/7] remoteproc: qcom: Add support for memory sandbox

Update pil driver with SMMU mapping for allowing authorised
memory access to ADSP firmware, by carveout reserved adsp memory
region from device tree file.

Signed-off-by: Srinivasa Rao Mandadapu <[email protected]>
---
Changes since V6:
-- Update smmu map and unmap function names.
-- Revert adsp_ops const change.
-- Move iommu check to within smmu map/unmap functions.
Changes since V5:
-- Remove adsp_rproc_unmap_smmu, adsp_of_unmap_smmu, adsp_of_map_smmu and
adsp_rproc_map_smmu functions.
-- Remove find_loaded_rsc_table call back initialization.
-- Rename adsp_sandbox_needed to has_iommu.
Changes since V4:
-- Split the code and add appropriate APIs for resource allocation and free.
-- Update adsp_unmap_smmu with missing free ops call.
-- Update normalizing length value in adsp_of_unmap_smmu.
Changes since V3:
-- Rename is_adsp_sb_needed to adsp_sandbox_needed.
-- Add smmu unmapping in error case and in adsp stop.
Changes since V2:
-- Replace platform_bus_type with adsp->dev->bus.
-- Use API of_parse_phandle_with_args() instead of of_parse_phandle_with_fixed_args().
-- Replace adsp->is_wpss with adsp->is_adsp.
-- Update error handling in adsp_start().

drivers/remoteproc/qcom_q6v5_adsp.c | 56 ++++++++++++++++++++++++++++++++++++-
1 file changed, 55 insertions(+), 1 deletion(-)

diff --git a/drivers/remoteproc/qcom_q6v5_adsp.c b/drivers/remoteproc/qcom_q6v5_adsp.c
index 4e70e76..2dc850f 100644
--- a/drivers/remoteproc/qcom_q6v5_adsp.c
+++ b/drivers/remoteproc/qcom_q6v5_adsp.c
@@ -9,6 +9,7 @@
#include <linux/firmware.h>
#include <linux/interrupt.h>
#include <linux/io.h>
+#include <linux/iommu.h>
#include <linux/iopoll.h>
#include <linux/kernel.h>
#include <linux/mfd/syscon.h>
@@ -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
@@ -332,6 +335,47 @@ static int adsp_load(struct rproc *rproc, const struct firmware *fw)
return 0;
}

+static void adsp_unmap_carveout(struct rproc *rproc)
+{
+ struct qcom_adsp *adsp = rproc->priv;
+
+ if (adsp->has_iommu)
+ iommu_unmap(rproc->domain, adsp->mem_phys, adsp->mem_size);
+}
+
+static int adsp_map_carveout(struct rproc *rproc)
+{
+ struct qcom_adsp *adsp = rproc->priv;
+ struct of_phandle_args args;
+ long long sid;
+ unsigned long iova;
+ int ret;
+
+ if (!adsp->has_iommu)
+ return 0;
+
+ if (!rproc->domain)
+ return -EINVAL;
+
+ ret = of_parse_phandle_with_args(adsp->dev->of_node, "iommus", "#iommu-cells", 0, &args);
+ if (ret < 0)
+ return ret;
+
+ sid = args.args[0] & SID_MASK_DEFAULT;
+
+ /* Add SID configuration for ADSP Firmware to SMMU */
+ iova = adsp->mem_phys | (sid << 32);
+
+ ret = iommu_map(rproc->domain, iova, adsp->mem_phys,
+ adsp->mem_size, IOMMU_READ | IOMMU_WRITE);
+ if (ret) {
+ dev_err(adsp->dev, "Unable to map ADSP Physical Memory\n");
+ return ret;
+ }
+
+ return 0;
+}
+
static int adsp_start(struct rproc *rproc)
{
struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv;
@@ -342,9 +386,15 @@ static int adsp_start(struct rproc *rproc)
if (ret)
return ret;

+ ret = adsp_map_carveout(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);
@@ -400,6 +450,8 @@ 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:
+ adsp_unmap_carveout(rproc);
disable_irqs:
qcom_q6v5_unprepare(&adsp->q6v5);

@@ -428,6 +480,8 @@ static int adsp_stop(struct rproc *rproc)
if (ret)
dev_err(adsp->dev, "failed to shutdown: %d\n", ret);

+ adsp_unmap_carveout(rproc);
+
handover = qcom_q6v5_unprepare(&adsp->q6v5);
if (handover)
qcom_adsp_pil_handover(&adsp->q6v5);
--
2.7.4

2022-09-28 13:00:00

by Srinivasa Rao Mandadapu

[permalink] [raw]
Subject: [PATCH v10 6/7] remoteproc: qcom: Add efuse evb selection control

Add efuse evb selection control and enable it for starting ADSP.

Signed-off-by: Srinivasa Rao Mandadapu <[email protected]>
Reviewed-by: Stephen Boyd <[email protected]>
Reviewed-by: Sibi Sankar <[email protected]>
---
Changes since V5:
-- Split devm_platform_ioremap_resource_byname function.

drivers/remoteproc/qcom_q6v5_adsp.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)

diff --git a/drivers/remoteproc/qcom_q6v5_adsp.c b/drivers/remoteproc/qcom_q6v5_adsp.c
index 14c94af..4e70e76 100644
--- a/drivers/remoteproc/qcom_q6v5_adsp.c
+++ b/drivers/remoteproc/qcom_q6v5_adsp.c
@@ -56,6 +56,7 @@

#define LPASS_BOOT_CORE_START BIT(0)
#define LPASS_BOOT_CMD_START BIT(0)
+#define LPASS_EFUSE_Q6SS_EVB_SEL 0x0

struct adsp_pil_data {
int crash_reason_smem;
@@ -86,6 +87,7 @@ struct qcom_adsp {
struct clk_bulk_data *clks;

void __iomem *qdsp6ss_base;
+ void __iomem *lpass_efuse;

struct reset_control *pdc_sync_reset;
struct reset_control *restart;
@@ -367,6 +369,9 @@ static int adsp_start(struct rproc *rproc)
/* Program boot address */
writel(adsp->mem_phys >> 4, adsp->qdsp6ss_base + RST_EVB_REG);

+ if (adsp->lpass_efuse)
+ writel(LPASS_EFUSE_Q6SS_EVB_SEL, adsp->lpass_efuse);
+
/* De-assert QDSP6 stop core. QDSP6 will execute after out of reset */
writel(LPASS_BOOT_CORE_START, adsp->qdsp6ss_base + CORE_START_REG);

@@ -533,6 +538,7 @@ static int adsp_init_reset(struct qcom_adsp *adsp)
static int adsp_init_mmio(struct qcom_adsp *adsp,
struct platform_device *pdev)
{
+ struct resource *efuse_region;
struct device_node *syscon;
int ret;

@@ -542,6 +548,17 @@ static int adsp_init_mmio(struct qcom_adsp *adsp,
return PTR_ERR(adsp->qdsp6ss_base);
}

+ efuse_region = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+ if (!efuse_region) {
+ adsp->lpass_efuse = NULL;
+ dev_dbg(adsp->dev, "failed to get efuse memory region\n");
+ } else {
+ adsp->lpass_efuse = devm_ioremap_resource(&pdev->dev, efuse_region);
+ if (IS_ERR(adsp->lpass_efuse)) {
+ dev_err(adsp->dev, "failed to map efuse registers\n");
+ return PTR_ERR(adsp->lpass_efuse);
+ }
+ }
syscon = of_parse_phandle(pdev->dev.of_node, "qcom,halt-regs", 0);
if (!syscon) {
dev_err(&pdev->dev, "failed to parse qcom,halt-regs\n");
--
2.7.4

2022-12-28 18:43:37

by Bjorn Andersson

[permalink] [raw]
Subject: Re: [PATCH v10 0/7] Update ADSP pil loader for SC7280 platform

On Wed, 28 Sep 2022 17:57:46 +0530, Srinivasa Rao Mandadapu wrote:
> Update ADSP pil loader driver for SC7280 platforms.
>
> Changes since V9:
> -- Add missing unevaluatedProperties in dt-bindings glink-edge.
> Changes since V8:
> -- Add glink-edge reference in dt-bindings.
> -- Remove redundant glinke-edge properties in dt-bindings.
> -- Make all reg propertioes as mandatory in dt-bindings.
> -- Add iommus property in dt-bindings.
> Changes since V7:
> -- Drop out of reset time out patch.
> -- Remove redundant clocks in dt bindings.
> -- Fix dt compilation error in dt bindings.
> Changes since V6:
> -- Update dt-bindings with glink-edge
> -- Add qcom,qmp property.
> -- Update parse firmware callback.
> -- Update commit message.
> -- Update smmu map and unmap function names.
> -- Revert adsp_ops const change.
> -- Move iommu check to within smmu map/unmap functions.
> Changes since V5:
> -- Remove adsp_rproc_unmap_smmu, adsp_of_unmap_smmu, adsp_of_map_smmu and
> adsp_rproc_map_smmu functions.
> -- Remove find_loaded_rsc_table call back initialization.
> -- Rename adsp_sandbox_needed to has_iommu.
> -- Update parse_fw callback in rproc ops.
> -- Remove qcom,adsp-memory-regions property in dt-bindings.
> -- Change adsp binary extension name.
> Changes since V4:
> -- Update halt registers description in dt bindings.
> -- Update Memory sandboxing with proper APIs for resource
> allocation and free.
> Changes since V3:
> -- Rename is_adsp_sb_needed to adsp_sandbox_needed.
> -- Update sc7280 compatible name entry in sorted order.
> -- Add smmu unmapping in error case and in adsp stop.
> -- Revert converting sdm845 dt bindings to generic and
> create new dt bindings for sc7280.
> Changes since V2:
> -- Generated patch with -M flag.
> -- Add Clock property in dt bindings.
> -- Add qcom,adsp-memory-regions property.
> -- Add is_adsp_sb_needed flag instead of is_wpss.
> -- Initialize is_adsp_sb_needed flag.
> -- Remove empty proxy pds array.
> -- Replace platform_bus_type with adsp->dev->bus.
> -- Use API of_parse_phandle_with_args() instead of
> of_parse_phandle_with_fixed_args().
> -- Replace adsp->is_wpss with adsp->is_adsp.
> -- Update error handling in adsp_start().
> Changes since V1:
> -- Change reg property maxItems to minItems and update description.
> -- Fix typo errors.
>
> [...]

Applied, thanks!

[1/7] dt-bindings: remoteproc: qcom: Add SC7280 ADSP support
commit: 8490a99586abd480d7139893f78c019790a58979
[2/7] remoteproc: qcom: Add flag in adsp private data structure
commit: 272dca8d14c46d03c633756d150b1c48c1dcb594
[3/7] remoteproc: qcom: Add compatible name for SC7280 ADSP
commit: 66cab0c5c3f9dae0213b9d02af03791b75565986
[4/7] remoteproc: qcom: Update rproc parse firmware callback
commit: 48ab209c6f5f84a5adcd68e150dc0f614c8bfba7
[5/7] remoteproc: qcom: Replace hard coded values with macros
commit: c36d6aa67932788ec04820ba65693ccd41b1042f
[6/7] remoteproc: qcom: Add efuse evb selection control
commit: 9ece961916631aab81b9d9f8d9c2770d05548662
[7/7] remoteproc: qcom: Add support for memory sandbox
commit: f22eedff28aff912bde7f8deabebd121cb64fae3

Best regards,
--
Bjorn Andersson <[email protected]>