From patchwork Fri Dec 13 12:55:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 181542 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp597234ile; Fri, 13 Dec 2019 04:56:11 -0800 (PST) X-Google-Smtp-Source: APXvYqyZqpEgh9ONSJbF/vxZhpUc3QhCUemlmEucrNUFF82uG03eNajAbHqckwO1fmtulnsYUszC X-Received: by 2002:a05:6830:10c9:: with SMTP id z9mr14413774oto.200.1576241771879; Fri, 13 Dec 2019 04:56:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576241771; cv=none; d=google.com; s=arc-20160816; b=R9Xna+l61oR3wHecu22+D1HTGhEeYAchaqWbT9ruJDtY5bdQ01VvMFvpb8+zwatvBQ 3IdYuEoY/Jtk7uMx5rtq9jpcWBlnJE5Dj7aWjGo/AiPSI3yFUaO1mY1QXZSvQLXbY2yb Y4kXv4VtyAFbggEsR5KNKTvBYm/JGEl1ZyClPOkBMe/DzhST/9qtke0kqM2psl6aUUtV E+VjGnSWWa4lOfQ7VUi0Ictv1Z9znsa2FhBeOiBwhy2kFMykS3xvYCqeybRQOYIC2SNA 5Pqk7dqs9KKnaf1aCAdjEfjozQPElnsitJlOCeVqcm1BFo9Oeqx38XoQM8Z7KtbIIU5i GQJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Ja6jKVftOPTintHhHgIzUjMQyMfzH3sype37GkDIl1k=; b=LSwWm55hyPLq1/rko9CDcIESfGGPWiBS+AD6Pv6lueEZ036nU4uQVCRXoctaTHr5ZC 7HCq8ThLPnEvfg3WGWCXntQFu2YeQIRiFhf7vwrPi6RrTjAUixXI/88ahuDSE655Uhii lnZw44NYVBgQoqyudCAAXkfd0//LduRRukDX15dtiUvEb02yupTuae6SNP/C9Go36FFN eXebO4n0RLa4T+aE9clE8ekH0wZg1osDvLQRoOKmQM3CRPi9f+pRLeB8pD7Fmjv1UwpO xhyEyS54SZZiiFZaXIjdKRQaPW2LNJrVvAab9Vh5Q29uhxEZDnC8t8T1AzUn792y7tUE 8CPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=gQZGP6E+; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g5si4710687otj.58.2019.12.13.04.56.11; Fri, 13 Dec 2019 04:56:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=gQZGP6E+; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727319AbfLMM4K (ORCPT + 4 others); Fri, 13 Dec 2019 07:56:10 -0500 Received: from lelv0143.ext.ti.com ([198.47.23.248]:41704 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726345AbfLMM4K (ORCPT ); Fri, 13 Dec 2019 07:56:10 -0500 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id xBDCu6s2018462; Fri, 13 Dec 2019 06:56:06 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1576241766; bh=Ja6jKVftOPTintHhHgIzUjMQyMfzH3sype37GkDIl1k=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=gQZGP6E+qe9UxgL/bQCnr3VS5Q07oPCBssqTwXfnK0V09A2lHTo/19Xfcoybu4pDx rHWKpdkVvqpkNBCXNE8YGC59lepkwh9EL2MV9JGYmSN98I2ulD4AzE9C5U7dEYanMg 1P9vMaOqStW0i633dwyRfMkkyTwhwsCAtAO1rNZQ= Received: from DFLE110.ent.ti.com (dfle110.ent.ti.com [10.64.6.31]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id xBDCu6MD064130 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 13 Dec 2019 06:56:06 -0600 Received: from DFLE114.ent.ti.com (10.64.6.35) by DFLE110.ent.ti.com (10.64.6.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Fri, 13 Dec 2019 06:56:04 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Fri, 13 Dec 2019 06:56:04 -0600 Received: from sokoban.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id xBDCtwVH127295; Fri, 13 Dec 2019 06:56:02 -0600 From: Tero Kristo To: , , CC: , , , Suman Anna , Tony Lindgren , Tero Kristo Subject: [PATCHv3 02/15] remoteproc/omap: Add device tree support Date: Fri, 13 Dec 2019 14:55:24 +0200 Message-ID: <20191213125537.11509-3-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191213125537.11509-1-t-kristo@ti.com> References: <20191213125537.11509-1-t-kristo@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Suman Anna OMAP4+ SoCs support device tree boot only. The OMAP remoteproc driver is enhanced to support remoteproc devices created through Device Tree, support for legacy platform devices has been deprecated. The current DT support handles the IPU and DSP processor subsystems on OMAP4 and OMAP5 SoCs. The OMAP remoteproc driver relies on the ti-sysc, reset, and syscon layers for performing clock, reset and boot vector management (DSP remoteprocs only) of the devices, but some of these are limited only to the machine-specific layers in arch/arm. The dependency against control module API for boot vector management of the DSP remoteprocs has now been removed with added logic to parse the boot register from the DT node and program it appropriately directly within the driver. The OMAP remoteproc driver expects the firmware names to be provided via device tree entries (firmware-name.) These are used to load the proper firmware during boot of the remote processor. Cc: Tony Lindgren Signed-off-by: Suman Anna [t-kristo@ti.com: converted to use ti-sysc framework] Signed-off-by: Tero Kristo --- drivers/remoteproc/omap_remoteproc.c | 191 +++++++++++++++++++++++---- 1 file changed, 168 insertions(+), 23 deletions(-) -- 2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/remoteproc/omap_remoteproc.c b/drivers/remoteproc/omap_remoteproc.c index 6398194075aa..558634624590 100644 --- a/drivers/remoteproc/omap_remoteproc.c +++ b/drivers/remoteproc/omap_remoteproc.c @@ -2,7 +2,7 @@ /* * OMAP Remote Processor driver * - * Copyright (C) 2011 Texas Instruments, Inc. + * Copyright (C) 2011-2019 Texas Instruments Incorporated - http://www.ti.com/ * Copyright (C) 2011 Google, Inc. * * Ohad Ben-Cohen @@ -16,27 +16,53 @@ #include #include #include +#include #include #include #include #include #include - -#include +#include +#include +#include #include "omap_remoteproc.h" #include "remoteproc_internal.h" +/** + * struct omap_rproc_boot_data - boot data structure for the DSP omap rprocs + * @syscon: regmap handle for the system control configuration module + * @boot_reg: boot register offset within the @syscon regmap + */ +struct omap_rproc_boot_data { + struct regmap *syscon; + unsigned int boot_reg; +}; + /** * struct omap_rproc - omap remote processor state * @mbox: mailbox channel handle * @client: mailbox client to request the mailbox channel + * @boot_data: boot data structure for setting processor boot address * @rproc: rproc handle + * @reset: reset handle */ struct omap_rproc { struct mbox_chan *mbox; struct mbox_client client; + struct omap_rproc_boot_data *boot_data; struct rproc *rproc; + struct reset_control *reset; +}; + +/** + * struct omap_rproc_dev_data - device data for the omap remote processor + * @device_name: device name of the remote processor + * @has_bootreg: true if this remote processor has boot register + */ +struct omap_rproc_dev_data { + const char *device_name; + bool has_bootreg; }; /** @@ -92,6 +118,21 @@ static void omap_rproc_kick(struct rproc *rproc, int vqid) ret); } +/** + * omap_rproc_write_dsp_boot_addr - set boot address for a DSP remote processor + * @rproc: handle of a remote processor + * + * Set boot address for a supported DSP remote processor. + */ +static void omap_rproc_write_dsp_boot_addr(struct rproc *rproc) +{ + struct omap_rproc *oproc = rproc->priv; + struct omap_rproc_boot_data *bdata = oproc->boot_data; + u32 offset = bdata->boot_reg; + + regmap_write(bdata->syscon, offset, rproc->bootaddr); +} + /* * Power up the remote processor. * @@ -103,13 +144,11 @@ static int omap_rproc_start(struct rproc *rproc) { struct omap_rproc *oproc = rproc->priv; struct device *dev = rproc->dev.parent; - struct platform_device *pdev = to_platform_device(dev); - struct omap_rproc_pdata *pdata = pdev->dev.platform_data; int ret; struct mbox_client *client = &oproc->client; - if (pdata->set_bootaddr) - pdata->set_bootaddr(rproc->bootaddr); + if (oproc->boot_data) + omap_rproc_write_dsp_boot_addr(rproc); client->dev = dev; client->tx_done = NULL; @@ -117,7 +156,7 @@ static int omap_rproc_start(struct rproc *rproc) client->tx_block = false; client->knows_txdone = false; - oproc->mbox = omap_mbox_request_channel(client, pdata->mbox_name); + oproc->mbox = mbox_request_channel(client, 0); if (IS_ERR(oproc->mbox)) { ret = -EBUSY; dev_err(dev, "mbox_request_channel failed: %ld\n", @@ -138,11 +177,7 @@ static int omap_rproc_start(struct rproc *rproc) goto put_mbox; } - ret = pdata->device_enable(pdev); - if (ret) { - dev_err(dev, "omap_device_enable failed: %d\n", ret); - goto put_mbox; - } + reset_control_deassert(oproc->reset); return 0; @@ -154,15 +189,9 @@ static int omap_rproc_start(struct rproc *rproc) /* power off the remote processor */ static int omap_rproc_stop(struct rproc *rproc) { - struct device *dev = rproc->dev.parent; - struct platform_device *pdev = to_platform_device(dev); - struct omap_rproc_pdata *pdata = pdev->dev.platform_data; struct omap_rproc *oproc = rproc->priv; - int ret; - ret = pdata->device_shutdown(pdev); - if (ret) - return ret; + reset_control_assert(oproc->reset); mbox_free_channel(oproc->mbox); @@ -175,12 +204,122 @@ static const struct rproc_ops omap_rproc_ops = { .kick = omap_rproc_kick, }; +static const struct omap_rproc_dev_data omap4_dsp_dev_data = { + .device_name = "dsp", + .has_bootreg = true, +}; + +static const struct omap_rproc_dev_data omap4_ipu_dev_data = { + .device_name = "ipu", +}; + +static const struct omap_rproc_dev_data omap5_dsp_dev_data = { + .device_name = "dsp", + .has_bootreg = true, +}; + +static const struct omap_rproc_dev_data omap5_ipu_dev_data = { + .device_name = "ipu", +}; + +static const struct of_device_id omap_rproc_of_match[] = { + { + .compatible = "ti,omap4-dsp", + .data = &omap4_dsp_dev_data, + }, + { + .compatible = "ti,omap4-ipu", + .data = &omap4_ipu_dev_data, + }, + { + .compatible = "ti,omap5-dsp", + .data = &omap5_dsp_dev_data, + }, + { + .compatible = "ti,omap5-ipu", + .data = &omap5_ipu_dev_data, + }, + { + /* end */ + }, +}; +MODULE_DEVICE_TABLE(of, omap_rproc_of_match); + +static const char *omap_rproc_get_firmware(struct platform_device *pdev) +{ + const char *fw_name; + int ret; + + ret = of_property_read_string(pdev->dev.of_node, "firmware-name", + &fw_name); + if (ret) + return ERR_PTR(ret); + + return fw_name; +} + +static int omap_rproc_get_boot_data(struct platform_device *pdev, + struct rproc *rproc) +{ + struct device_node *np = pdev->dev.of_node; + struct omap_rproc *oproc = rproc->priv; + const struct omap_rproc_dev_data *data; + int ret; + + data = of_device_get_match_data(&pdev->dev); + if (!data) + return -ENODEV; + + if (!data->has_bootreg) + return 0; + + oproc->boot_data = devm_kzalloc(&pdev->dev, sizeof(*oproc->boot_data), + GFP_KERNEL); + if (!oproc->boot_data) + return -ENOMEM; + + if (!of_property_read_bool(np, "ti,bootreg")) { + dev_err(&pdev->dev, "ti,bootreg property is missing\n"); + return -EINVAL; + } + + oproc->boot_data->syscon = + syscon_regmap_lookup_by_phandle(np, "ti,bootreg"); + if (IS_ERR(oproc->boot_data->syscon)) { + ret = PTR_ERR(oproc->boot_data->syscon); + return ret; + } + + if (of_property_read_u32_index(np, "ti,bootreg", 1, + &oproc->boot_data->boot_reg)) { + dev_err(&pdev->dev, "couldn't get the boot register\n"); + return -EINVAL; + } + + return 0; +} + static int omap_rproc_probe(struct platform_device *pdev) { - struct omap_rproc_pdata *pdata = pdev->dev.platform_data; + struct device_node *np = pdev->dev.of_node; struct omap_rproc *oproc; struct rproc *rproc; + const char *firmware; int ret; + struct reset_control *reset; + + if (!np) { + dev_err(&pdev->dev, "only DT-based devices are supported\n"); + return -ENODEV; + } + + reset = devm_reset_control_array_get_optional_exclusive(&pdev->dev); + if (IS_ERR(reset)) + return PTR_ERR(reset); + + firmware = omap_rproc_get_firmware(pdev); + if (IS_ERR(firmware)) + return PTR_ERR(firmware); ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); if (ret) { @@ -188,16 +327,21 @@ static int omap_rproc_probe(struct platform_device *pdev) return ret; } - rproc = rproc_alloc(&pdev->dev, pdata->name, &omap_rproc_ops, - pdata->firmware, sizeof(*oproc)); + rproc = rproc_alloc(&pdev->dev, dev_name(&pdev->dev), &omap_rproc_ops, + firmware, sizeof(*oproc)); if (!rproc) return -ENOMEM; oproc = rproc->priv; oproc->rproc = rproc; + oproc->reset = reset; /* All existing OMAP IPU and DSP processors have an MMU */ rproc->has_iommu = true; + ret = omap_rproc_get_boot_data(pdev, rproc); + if (ret) + goto free_rproc; + platform_set_drvdata(pdev, rproc); ret = rproc_add(rproc); @@ -226,6 +370,7 @@ static struct platform_driver omap_rproc_driver = { .remove = omap_rproc_remove, .driver = { .name = "omap-rproc", + .of_match_table = omap_rproc_of_match, }, }; From patchwork Fri Dec 13 12:55:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 181546 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp597380ile; Fri, 13 Dec 2019 04:56:23 -0800 (PST) X-Google-Smtp-Source: APXvYqx07AzuuJ0OMMRThnPOJbTd1en3E6LIj9+W2R9sa9OupLKrHrf0DG7Cu6zsTp3LW/ocYqN1 X-Received: by 2002:a05:6830:1e61:: with SMTP id m1mr14638319otr.68.1576241783189; Fri, 13 Dec 2019 04:56:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576241783; cv=none; d=google.com; s=arc-20160816; b=YauMKBlA3IvL7BkLeTPwYZYXwya4UuZE6HEnp9ZzgUqXBCaxuxrLLvnQNLs1I9sxf+ DkddHYKJgRCBG+dN6ukl7kLPboaFOjkfmo9M4pBmmL/hmDO1fDHTEaezpt75tNbKeueF n/6njk/yN//sbKjK5cU/JpkPtsyQnlCVw0t7cuxxnNX9gt2AMcjAk7bVLlxiD70MSqLG 7ZPfr4CRMnrlnnyK75JA/4SQbPb2LkEXFhgbnyXqa4WD9VzZj/NVAABbgzSRQWeVz+uz EHQtwWinC28vrD0MbmxWPpkitGwOHjR+l9SZhQMqn8kEXFftmkVKB9t6c0qgsRrdeM6I XWkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=cZPUDLryljiTau+tMhgFn/36rTJMjWD1u8FWT9ke/dg=; b=XeMe2Vh7BPtYVAxzT7oOWY7XoduiR5NLUnc0VVx8URLDNmaHEPyMdwhL95IEWRA2hq cPFM+QJkmzPn5GpuiLItKoICT7Ckb624dkedtD88DZDtjknk4Fi6dPMe3nqP3JBDw0Fv Bv4Sr5NwQrOIdjrEFz2ayxkcrJVtvmHLYin9DOR3cFxk5wG8X7Xm/Wwkppq+K4SdXv9W v1Bc/c9F6/UUWmPU+kj7pP4tHdVkf2W8KCxHLLpZNeuTYZMuwwXv8ENmXNDQlZK8xPxF fi3dTLvZDw81J2+9Yykau+JtWq4o9ler7ixYqrHF35eEh7e8XlR8FM8aq07Cgthw4LlX QpGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=SLCch5uj; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d6si4964901oic.86.2019.12.13.04.56.23; Fri, 13 Dec 2019 04:56:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=SLCch5uj; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727420AbfLMM4V (ORCPT + 4 others); Fri, 13 Dec 2019 07:56:21 -0500 Received: from lelv0142.ext.ti.com ([198.47.23.249]:48496 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727417AbfLMM4V (ORCPT ); Fri, 13 Dec 2019 07:56:21 -0500 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id xBDCuJKZ068997; Fri, 13 Dec 2019 06:56:19 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1576241779; bh=cZPUDLryljiTau+tMhgFn/36rTJMjWD1u8FWT9ke/dg=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=SLCch5ujnkucQnh3Tqin1Z803EelTj8t8v62HzwOCfXd4FpnXXvrDmmedHGbv0U61 yw9oQB2phu/PYL9ihOcfpI+8vQpC/yL5aIn6hgWYGPesm/wkJcA8jCJbh82/oL2aoE 2/vbI2q6mN6ewLwSUTBxZkxo7OTOXQIZLxEwrsoo= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id xBDCuIL3071054 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 13 Dec 2019 06:56:18 -0600 Received: from DFLE100.ent.ti.com (10.64.6.21) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Fri, 13 Dec 2019 06:56:15 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Fri, 13 Dec 2019 06:56:15 -0600 Received: from sokoban.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id xBDCtwVM127295; Fri, 13 Dec 2019 06:56:13 -0600 From: Tero Kristo To: , , CC: , , , Suman Anna , Tero Kristo Subject: [PATCHv3 07/15] remoteproc/omap: Add support for DRA7xx remote processors Date: Fri, 13 Dec 2019 14:55:29 +0200 Message-ID: <20191213125537.11509-8-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191213125537.11509-1-t-kristo@ti.com> References: <20191213125537.11509-1-t-kristo@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Suman Anna DRA7xx/AM57xx SoCs have two IPU and up to two DSP processor subsystems for offloading different computation algorithms. The IPU processor subsystem contains dual-core ARM Cortex-M4 processors, and is very similar to those on OMAP5. The DSP processor subsystem is based on the TI's standard TMS320C66x DSP CorePac core. Support has been added to the OMAP remoteproc driver through new DRA7xx specific compatibles for properly probing and booting all the different processor subsystem instances on DRA7xx/AM57xx SoCs - IPU1, IPU2, DSP1 & DSP2. A build dependency with SOC_DRA7XX is added to enable the driver to be built in DRA7xx-only configuration. The DSP boot address programming needed enhancement for DRA7xx as the boot register fields are different on DRA7 compared to OMAP4 and OMAP5 SoCs. The register on DRA7xx contains additional fields within the register and the boot address bit-field is right-shifted by 10 bits. The internal memory parsing logic has also been updated to compute the device addresses for the L2 RAM for DSP devices using relative addressing logic, and to parse two additional RAMs at L1 level - L1P and L1D. This allows the remoteproc driver to support loading into these regions for a small subset of firmware images requiring as such. The most common usage would be to use the L1 programmable RAMs as L1 Caches. The firmware lookup logic also has to be adjusted for DRA7xx as there are (can be) more than one instance of both the IPU and DSP remote processors for the first time in OMAP4+ SoCs. Signed-off-by: Suman Anna [t-kristo@ti.com: moved address translation quirks to pdata] Signed-off-by: Tero Kristo --- drivers/remoteproc/Kconfig | 2 +- drivers/remoteproc/omap_remoteproc.c | 44 +++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-) -- 2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig index 94afdde4bc9f..d6450d7fcf92 100644 --- a/drivers/remoteproc/Kconfig +++ b/drivers/remoteproc/Kconfig @@ -25,7 +25,7 @@ config IMX_REMOTEPROC config OMAP_REMOTEPROC tristate "OMAP remoteproc support" - depends on ARCH_OMAP4 || SOC_OMAP5 + depends on ARCH_OMAP4 || SOC_OMAP5 || SOC_DRA7XX depends on OMAP_IOMMU select MAILBOX select OMAP2PLUS_MBOX diff --git a/drivers/remoteproc/omap_remoteproc.c b/drivers/remoteproc/omap_remoteproc.c index 3ad74c4b4071..6cf7f0a9ba9a 100644 --- a/drivers/remoteproc/omap_remoteproc.c +++ b/drivers/remoteproc/omap_remoteproc.c @@ -34,10 +34,13 @@ * struct omap_rproc_boot_data - boot data structure for the DSP omap rprocs * @syscon: regmap handle for the system control configuration module * @boot_reg: boot register offset within the @syscon regmap + * @boot_reg_shift: bit-field shift required for the boot address value in + * @boot_reg */ struct omap_rproc_boot_data { struct regmap *syscon; unsigned int boot_reg; + unsigned int boot_reg_shift; }; /* @@ -78,12 +81,14 @@ struct omap_rproc { * struct omap_rproc_dev_data - device data for the omap remote processor * @device_name: device name of the remote processor * @has_bootreg: true if this remote processor has boot register + * @boot_reg_shift: bit shift for the boot register mask * @mem_names: memory names for this remote processor * @dev_addrs: device addresses corresponding to the memory names */ struct omap_rproc_dev_data { const char *device_name; bool has_bootreg; + int boot_reg_shift; const char * const *mem_names; const u32 *dev_addrs; }; @@ -153,6 +158,8 @@ static int omap_rproc_write_dsp_boot_addr(struct rproc *rproc) struct omap_rproc *oproc = rproc->priv; struct omap_rproc_boot_data *bdata = oproc->boot_data; u32 offset = bdata->boot_reg; + u32 value; + u32 mask; if (rproc->bootaddr & (SZ_1K - 1)) { dev_err(dev, "invalid boot address 0x%x, must be aligned on a 1KB boundary\n", @@ -160,7 +167,10 @@ static int omap_rproc_write_dsp_boot_addr(struct rproc *rproc) return -EINVAL; } - regmap_write(bdata->syscon, offset, rproc->bootaddr); + value = rproc->bootaddr >> bdata->boot_reg_shift; + mask = ~(SZ_1K - 1) >> bdata->boot_reg_shift; + + regmap_update_bits(bdata->syscon, offset, mask, value); return 0; } @@ -286,6 +296,14 @@ static const u32 ipu_dev_addrs[] = { 0x20000000, }; +static const char * const dra7_dsp_mem_names[] = { + "l2ram", "l1pram", "l1dram", NULL +}; + +static const u32 dra7_dsp_dev_addrs[] = { + 0x800000, 0xe00000, 0xf00000, +}; + static const struct omap_rproc_dev_data omap4_dsp_dev_data = { .device_name = "dsp", .has_bootreg = true, @@ -308,6 +326,20 @@ static const struct omap_rproc_dev_data omap5_ipu_dev_data = { .dev_addrs = ipu_dev_addrs, }; +static const struct omap_rproc_dev_data dra7_dsp_dev_data = { + .device_name = "dsp", + .has_bootreg = true, + .boot_reg_shift = 10, + .mem_names = dra7_dsp_mem_names, + .dev_addrs = dra7_dsp_dev_addrs, +}; + +static const struct omap_rproc_dev_data dra7_ipu_dev_data = { + .device_name = "ipu", + .mem_names = ipu_mem_names, + .dev_addrs = ipu_dev_addrs, +}; + static const struct of_device_id omap_rproc_of_match[] = { { .compatible = "ti,omap4-dsp", @@ -325,6 +357,14 @@ static const struct of_device_id omap_rproc_of_match[] = { .compatible = "ti,omap5-ipu", .data = &omap5_ipu_dev_data, }, + { + .compatible = "ti,dra7-dsp", + .data = &dra7_dsp_dev_data, + }, + { + .compatible = "ti,dra7-ipu", + .data = &dra7_ipu_dev_data, + }, { /* end */ }, @@ -382,6 +422,8 @@ static int omap_rproc_get_boot_data(struct platform_device *pdev, return -EINVAL; } + oproc->boot_data->boot_reg_shift = data->boot_reg_shift; + return 0; } From patchwork Fri Dec 13 12:55:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 181545 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp597375ile; Fri, 13 Dec 2019 04:56:23 -0800 (PST) X-Google-Smtp-Source: APXvYqxuWJdbr0JVxr1qlp4jTFNW9MsDqe39Op6SkMSLAHSWxLPSNj8eJT0O3zgb2HLcnw+nEq7n X-Received: by 2002:a05:6830:1cf:: with SMTP id r15mr15199999ota.231.1576241782909; Fri, 13 Dec 2019 04:56:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576241782; cv=none; d=google.com; s=arc-20160816; b=0rAAElZimib+2fweHrA2GbFOGYeIAJx9d5mnTy+UmVDUG38XR3SX9X9bmQq2dH8L8E /j1vycrKF9NhCvatsTPPbkpNKe4vEqVpxywQk/gd8WgzFMW9ZZCULqSyQs0Vt/BlhIUz 9FDXYrW1Cfc1dKG1Tsl6o7hmZB+fl1aVwK63lqYOQSY1RKYyrnOwMqHP4wH653B2e5RR CrHf4jQuUxOobayyqPefivC4mHCCwT9QnKuNis0R79vRf5KXbx7VDMa7eS2+aGjvEM4z jIVM7d3qdy2QfDCuDZKanv0f0rSZdeJl7Cf5upEWMtRyh10gwfr63nu15NwjotlTO8ZS D0VA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=EitgW7O/QRAXjRcxirmHTgfcttX/ymV9l/4WHfD6CQA=; b=VgcG6Ho7hrYmvmxF1DP8bcypQyJg4sdOPXtJ2yS3W63nSNmPrwgXzziwO6dPEwymVG Jzgi2yivC1q/SCVePe5gjJM2mD6psjMrot0kcBY8BQcrSbvmSiBg0vBjAmuffDYkQIvA Q1UXOwC+qhU9Q12pQyLCs1DLoCX1DcsfHzNMNPEdWJ/yp3qw7RFHjhjZ7U2QXPMSwID4 2gtfn3a7tMnkFTU8gno7y4uihPSRW3rG0k5mN2U8/IAMSZkNOMMrrpEoc0uQrckwSq+u nAm2mTSoO+LvVTMv29EkSUikGU+2aA8O0KRR7+Iy8zUjqXJtVVHLjh4AFAL4zu+QK+Qm UpLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Yj4cPkJe; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d6si4964901oic.86.2019.12.13.04.56.22; Fri, 13 Dec 2019 04:56:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Yj4cPkJe; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727427AbfLMM4V (ORCPT + 4 others); Fri, 13 Dec 2019 07:56:21 -0500 Received: from fllv0015.ext.ti.com ([198.47.19.141]:39744 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727411AbfLMM4T (ORCPT ); Fri, 13 Dec 2019 07:56:19 -0500 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id xBDCuIU7056183; Fri, 13 Dec 2019 06:56:18 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1576241778; bh=EitgW7O/QRAXjRcxirmHTgfcttX/ymV9l/4WHfD6CQA=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Yj4cPkJe2Lj3zaLxXkDKCOcBCgbz8eBxHVX/+eD4I6GinIyRqPzajLcP2Ucx0+WOa 5efk9U5gyw7CwUpUVVBjK3QVxLhuYqnJhD1tfCxuJzPd5tqCP4wMwewAR9adQRIvdC 5xnk40DQ6lxWOhonhvklyVeeDsrUZdnFYpk0jOvM= Received: from DFLE100.ent.ti.com (dfle100.ent.ti.com [10.64.6.21]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id xBDCuIDu009040; Fri, 13 Dec 2019 06:56:18 -0600 Received: from DFLE105.ent.ti.com (10.64.6.26) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Fri, 13 Dec 2019 06:56:17 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Fri, 13 Dec 2019 06:56:17 -0600 Received: from sokoban.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id xBDCtwVN127295; Fri, 13 Dec 2019 06:56:16 -0600 From: Tero Kristo To: , , CC: , , , Suman Anna , Tero Kristo Subject: [PATCHv3 08/15] remoteproc/omap: Remove the unused fields from platform data Date: Fri, 13 Dec 2019 14:55:30 +0200 Message-ID: <20191213125537.11509-9-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191213125537.11509-1-t-kristo@ti.com> References: <20191213125537.11509-1-t-kristo@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Suman Anna The following fields: .name, .oh_name, .oh_name_opt, .mbox_name, .firmware, .ops and .set_bootaddr, are removed from the platform data, as these are no longer needed after the addition of DT support to the OMAP remoteproc driver. The .name field was used to give a name to the remoteproc, and this is replaced with the device name. The .ops field was never used by the OMAP remoteproc driver. The .mbox_name was used to define the sub-mailbox node used for communication with the remote processor, and is retrieved using the 'mboxes' property in the DT node. The .firmware field is encoded directly in the OMAP remoteproc driver and is retrieved using driver match data. The .set_bootaddr ops was used for using a OMAP Control Module API to configure the boot address for the processor, and is now implemented within the driver using a syscon property. The .oh_name field is used to define the primary hwmod for the processor node, and is represented using the 'ti,hwmods' property in the DT node. The .oh_name_opt field was primarily defined to identify the hwmod for the second cpu in a dual Cortex-M3/M4 IPU processor sub-system. This hwmod entry is no longer defined usually, but rather a single hwmod representing both the processors in the IPU sub-system is defined. A single firmware image (either in SMP-mode or a combined image for non-SMP mode) is used, with both the resets released together always as part of the device management. Any power management and recovery aspects require that both the processors be managed as one entity due to the presence of shared MMU and unicache within the IPU sub-system. The OMAP remoteproc platform data structure is eventually expected to be removed completely once the other dependencies with the mach-omap layer are met. Signed-off-by: Suman Anna Signed-off-by: Tero Kristo Reviewed-by: Bjorn Andersson --- include/linux/platform_data/remoteproc-omap.h | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) -- 2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/include/linux/platform_data/remoteproc-omap.h b/include/linux/platform_data/remoteproc-omap.h index 7e3a16097672..6bea01e199fe 100644 --- a/include/linux/platform_data/remoteproc-omap.h +++ b/include/linux/platform_data/remoteproc-omap.h @@ -2,38 +2,23 @@ /* * Remote Processor - omap-specific bits * - * Copyright (C) 2011 Texas Instruments, Inc. + * Copyright (C) 2011-2018 Texas Instruments Incorporated - http://www.ti.com/ * Copyright (C) 2011 Google, Inc. */ #ifndef _PLAT_REMOTEPROC_H #define _PLAT_REMOTEPROC_H -struct rproc_ops; struct platform_device; /* * struct omap_rproc_pdata - omap remoteproc's platform data - * @name: the remoteproc's name - * @oh_name: omap hwmod device - * @oh_name_opt: optional, secondary omap hwmod device - * @firmware: name of firmware file to load - * @mbox_name: name of omap mailbox device to use with this rproc - * @ops: start/stop rproc handlers * @device_enable: omap-specific handler for enabling a device * @device_shutdown: omap-specific handler for shutting down a device - * @set_bootaddr: omap-specific handler for setting the rproc boot address */ struct omap_rproc_pdata { - const char *name; - const char *oh_name; - const char *oh_name_opt; - const char *firmware; - const char *mbox_name; - const struct rproc_ops *ops; int (*device_enable)(struct platform_device *pdev); int (*device_shutdown)(struct platform_device *pdev); - void (*set_bootaddr)(u32); }; #if defined(CONFIG_OMAP_REMOTEPROC) || defined(CONFIG_OMAP_REMOTEPROC_MODULE) From patchwork Fri Dec 13 12:55:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 181548 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp597527ile; Fri, 13 Dec 2019 04:56:32 -0800 (PST) X-Google-Smtp-Source: APXvYqyyKqKj0PAvz0W8UzPDYklYwZZT/JibLAfUdEcR5+7l6m+vBflhIbiiNS9DhvJRRF0svVJ1 X-Received: by 2002:a9d:2904:: with SMTP id d4mr13920671otb.214.1576241792356; Fri, 13 Dec 2019 04:56:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576241792; cv=none; d=google.com; s=arc-20160816; b=f2RvzyNMcRibeiuh7Yw4s58WYsV2iBml0WN5qsS+mxVP909Ud3s+C1PBKq0ZO1lFhj SWvIvoVwiidVVwgMR3nRoaTeGiwgBhwv44SB/PSZQ6UdCwW0Z+Oiml/eDKaPaiRZilxI aamMrzoYo1xs43wKxp3n9CG1bG75vwoW5sctZEYSKISzj9Np5zdd0ASKAAZRgEQZFPNY Gyhm/Bx0F5eVnStKtjXEVZ8kDg/220hH9GtoMWPNjCTJKVt2BK6xjFU5/L9zai9/d2hj lcEaKEaVclC6faB7DpF7gIBtjuDbjcDBWDXTfNpkGGzO9sFotOh5EfwiXDZzCFbBZZPI Algw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=iNbjq4C34pR6QNWDK9+NrPFMsPQVY+YacZkcNLYf6FE=; b=Z40T1v/ltnQQgf/XyG+x4BH1KHaZk333cy3X4qg5KVmLiNrJRoTcYDYa/DqCD2fNIt KsQlIb2YDEmQZk38LIRCQUm+0buGUQusQsHks6/BigKkEo7LnS8T0qMB+ewLky/y9C8Y jDPYM/iAQsIBGsR6mtLvPovSxuSm7soYBQnwmd5QvQoIh+k0PcTHxHlPtaRUuA1NHy6/ WpD/wRMCYWQsmw4oV+vaA8jbDiJqNYZOjmds9jmE2xF8e+B91R3FUKs7B4JpbkgzYz8f 0BmE1HNQdlcQcvQqZZJCi/5Jngj9G4eviGKS0aTcrn37gBUV/PevsFtSzfK4PztYeLfG mSdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ys1e1lHs; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h22si5078430otn.279.2019.12.13.04.56.32; Fri, 13 Dec 2019 04:56:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ys1e1lHs; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727483AbfLMM4b (ORCPT + 4 others); Fri, 13 Dec 2019 07:56:31 -0500 Received: from lelv0143.ext.ti.com ([198.47.23.248]:41724 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727443AbfLMM4X (ORCPT ); Fri, 13 Dec 2019 07:56:23 -0500 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id xBDCuMCp018534; Fri, 13 Dec 2019 06:56:22 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1576241782; bh=iNbjq4C34pR6QNWDK9+NrPFMsPQVY+YacZkcNLYf6FE=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ys1e1lHsWA+eHLVC79t34J7h8IfYtipG+cgrMr0dldi79xcjTnHPZYm+m76ixgzBs DgsxQUyxNssk/n9gqy6dWFbE/O3/hF22UqOFMFjlpP5mVwkOIRLP7p769FjlfZY09D lNgHu6NG+3A1yVY9RvD8A4ciP2AX0vhFZV06BImU= Received: from DLEE100.ent.ti.com (dlee100.ent.ti.com [157.170.170.30]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id xBDCuMNK009092; Fri, 13 Dec 2019 06:56:22 -0600 Received: from DLEE107.ent.ti.com (157.170.170.37) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Fri, 13 Dec 2019 06:56:22 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Fri, 13 Dec 2019 06:56:22 -0600 Received: from sokoban.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id xBDCtwVP127295; Fri, 13 Dec 2019 06:56:20 -0600 From: Tero Kristo To: , , CC: , , , Suman Anna , Tero Kristo Subject: [PATCHv3 10/15] remoteproc/omap: Check for undefined mailbox messages Date: Fri, 13 Dec 2019 14:55:32 +0200 Message-ID: <20191213125537.11509-11-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191213125537.11509-1-t-kristo@ti.com> References: <20191213125537.11509-1-t-kristo@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Suman Anna Add some checks in the mailbox callback function to limit any processing in the mailbox callback function to only certain currently valid messages, and drop all the remaining messages. A debug message is added to print any such invalid messages when the appropriate trace control is enabled. Co-developed-by: Subramaniam Chanderashekarapuram Signed-off-by: Subramaniam Chanderashekarapuram Signed-off-by: Suman Anna Signed-off-by: Tero Kristo Reviewed-by: Bjorn Andersson --- drivers/remoteproc/omap_remoteproc.c | 6 ++++++ drivers/remoteproc/omap_remoteproc.h | 7 +++++++ 2 files changed, 13 insertions(+) -- 2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/remoteproc/omap_remoteproc.c b/drivers/remoteproc/omap_remoteproc.c index 6cf7f0a9ba9a..841981c50d8d 100644 --- a/drivers/remoteproc/omap_remoteproc.c +++ b/drivers/remoteproc/omap_remoteproc.c @@ -126,6 +126,12 @@ static void omap_rproc_mbox_callback(struct mbox_client *client, void *data) dev_info(dev, "received echo reply from %s\n", name); break; default: + if (msg >= RP_MBOX_READY && msg < RP_MBOX_END_MSG) + return; + if (msg > oproc->rproc->max_notifyid) { + dev_dbg(dev, "dropping unknown message 0x%x", msg); + return; + } /* msg contains the index of the triggered vring */ if (rproc_vq_interrupt(oproc->rproc, msg) == IRQ_NONE) dev_dbg(dev, "no message was found in vqid %d\n", msg); diff --git a/drivers/remoteproc/omap_remoteproc.h b/drivers/remoteproc/omap_remoteproc.h index f6d2036d383d..72f656c93caa 100644 --- a/drivers/remoteproc/omap_remoteproc.h +++ b/drivers/remoteproc/omap_remoteproc.h @@ -56,6 +56,12 @@ * * @RP_MBOX_ABORT_REQUEST: a "please crash" request, used for testing the * recovery mechanism (to some extent). + * + * Introduce new message definitions if any here. + * + * @RP_MBOX_END_MSG: Indicates end of known/defined messages from remote core + * This should be the last definition. + * */ enum omap_rp_mbox_messages { RP_MBOX_READY = 0xFFFFFF00, @@ -64,6 +70,7 @@ enum omap_rp_mbox_messages { RP_MBOX_ECHO_REQUEST = 0xFFFFFF03, RP_MBOX_ECHO_REPLY = 0xFFFFFF04, RP_MBOX_ABORT_REQUEST = 0xFFFFFF05, + RP_MBOX_END_MSG = 0xFFFFFF06, }; #endif /* _OMAP_RPMSG_H */