From patchwork Mon Oct 28 12:42: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: 177927 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3340479ill; Mon, 28 Oct 2019 05:44:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqyAl+fTTOxCrlZ+FWHSkNgz0Mhb51GgBSOtZG9I9L9zAuwVr6xV6S3SIR4H0fD4AUZI9fBM X-Received: by 2002:a17:906:d971:: with SMTP id rp17mr13659608ejb.230.1572266664089; Mon, 28 Oct 2019 05:44:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572266664; cv=none; d=google.com; s=arc-20160816; b=J00N4S8aqmy6vxclXhRwenINBSoqkpuNO9sfy4y73AO/n8AMUvuZi+W+HVcg5Lq6gd oQbhjKgoobgqwwxldekb2HVEfeyY96R1NO1E2tdzJKadt9WylleRi0jLNQDDySPxPwpK qNdoiYv6PaBvRRClKTXZVu4KIzmfwsWE4+C/rq3Hk1yKYncKCd7STENHLSvq4vC2qcqj ilKlOW9PYEEdV+H9Lvf9qfo6Jabg4zd3WXBu0Egnlpo7V16EdHozvdhyd6JZGAdjdTiP 4ryHA8Irr0kFo72FMGYabev+68tA7ulAkZtr6WqLzZZZindmLBiLprtjJncrQ+fy6767 1B2g== 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=FXTKXxDdQiZwKiSmvkYRplWS1hOLsC+szyRFCRSvzi0=; b=qa8HDIqgK5MU3MVJgU7rHlBSWReLgRQ1yEZjLzROXd9dtMYRLEWG24qOquXFhr87FV OXdiGm3pK+cQj1MOg0g0sx4uOxKtEP2MpRrPLpN/x6S3kPEFGJmkR7Gn5hmXVcva33cb aeCoUZX38h/P1hPPBljclKHy4TzvHPWnDpHFWVMJpNupW0j83VzpF3HT4G1kIymy4eWg QLkT9s9nBgJbpC8MDZoa2r21BgYMGeqwUR1o2OXp8z5N5c2cdVduMf0fH+MAGUEfkU6g 2J2YxfjlxxmqqRyFQddRFAcLSlNSpX8pv0CzNIYGFGSYnJQKamnWsj3gK6E961jLlr1g sRMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=RImCKkTu; 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 f7si4013312ejt.373.2019.10.28.05.44.23; Mon, 28 Oct 2019 05:44:24 -0700 (PDT) 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=RImCKkTu; 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 S1728743AbfJ1MoX (ORCPT + 5 others); Mon, 28 Oct 2019 08:44:23 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:48214 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389274AbfJ1MnF (ORCPT ); Mon, 28 Oct 2019 08:43:05 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id x9SCh1Ak016567; Mon, 28 Oct 2019 07:43:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1572266581; bh=FXTKXxDdQiZwKiSmvkYRplWS1hOLsC+szyRFCRSvzi0=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=RImCKkTuGXWhzhliQYLUBe3Pbsqnn6ofSMP2MuzTS95iqMtQ0SkTk+ifGLarTT/z3 enp44nx7CGhchPF6Q0T62dKVGNNErUKQkeFCVDd85RLJ1UfxCVo/mKh7H6viLymPhw RT4Ezy2myeVovgpFb2hVJRF2je2YOr8yJDDBoh2E= Received: from DLEE102.ent.ti.com (dlee102.ent.ti.com [157.170.170.32]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id x9SCh1E7072305; Mon, 28 Oct 2019 07:43:01 -0500 Received: from DLEE101.ent.ti.com (157.170.170.31) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Mon, 28 Oct 2019 07:42:47 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE101.ent.ti.com (157.170.170.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Mon, 28 Oct 2019 07:42:47 -0500 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 x9SCgogt063574; Mon, 28 Oct 2019 07:42:57 -0500 From: Tero Kristo To: , , CC: , , , Tony Lindgren , Tero Kristo Subject: [PATCH 03/17] remoteproc/omap: Add device tree support Date: Mon, 28 Oct 2019 14:42:24 +0200 Message-ID: <20191028124238.19224-4-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191028124238.19224-1-t-kristo@ti.com> References: <20191028124238.19224-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 omap_device, omap_hwmod and control module 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 dependency on omap_device API for clock and reset control remains though and is to be achieved through OMAP rproc specific platform data ops, and the required implementations to boot and shutdown have been added in the machine layer. These need to be plugged in to the remoteproc devices through pdata quirks, for properly booting the remote processors. The OMAP remoteproc driver expects the firmware images to have fixed names. This used to be defined through platform data previously, and are now coded into the driver. The following names are to be expected of the firmwares, OMAP4 - IPU: omap4-ipu-fw.xem3 DSP: omap4-dsp-fw.xe64T OMAP5 - IPU: omap5-ipu-fw.xem4 DSP: omap5-dsp-fw.xe64T 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 | 187 +++++++++++++++++++++++---- 1 file changed, 164 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..cd776189d20b 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-2018 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 + * @fw_name: firmware name to use + */ +struct omap_rproc_dev_data { + const char *device_name; + const char *fw_name; }; /** @@ -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,118 @@ 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", + .fw_name = "omap4-dsp-fw.xe64T", +}; + +static const struct omap_rproc_dev_data omap4_ipu_dev_data = { + .device_name = "ipu", + .fw_name = "omap4-ipu-fw.xem3", +}; + +static const struct omap_rproc_dev_data omap5_dsp_dev_data = { + .device_name = "dsp", + .fw_name = "omap5-dsp-fw.xe64T", +}; + +static const struct omap_rproc_dev_data omap5_ipu_dev_data = { + .device_name = "ipu", + .fw_name = "omap5-ipu-fw.xem4", +}; + +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 struct omap_rproc_dev_data *data; + + data = of_device_get_match_data(&pdev->dev); + if (!data) + return ERR_PTR(-ENODEV); + + return data->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; + int ret; + + if (!of_device_is_compatible(np, "ti,omap4-dsp") && + !of_device_is_compatible(np, "ti,omap5-dsp")) + 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, "syscon-bootreg")) { + dev_err(&pdev->dev, "syscon-bootreg property is missing\n"); + return -EINVAL; + } + + oproc->boot_data->syscon = + syscon_regmap_lookup_by_phandle(np, "syscon-bootreg"); + if (IS_ERR(oproc->boot_data->syscon)) { + ret = PTR_ERR(oproc->boot_data->syscon); + return ret; + } + + if (of_property_read_u32_index(np, "syscon-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 +323,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 +366,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 Mon Oct 28 12:42: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: 177916 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3339289ill; Mon, 28 Oct 2019 05:43:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqxvlNTl2HP0Eh/lSuIblHPPJdwCETrJB4Q2YXrkS45IlMUcF+Vp7MjYTJM0HE405CgYqYKN X-Received: by 2002:a50:9269:: with SMTP id j38mr19129533eda.5.1572266596137; Mon, 28 Oct 2019 05:43:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572266596; cv=none; d=google.com; s=arc-20160816; b=iFN1qJqgZhJp1osVKaZx3MXebCP/ghuJDwuhOxhUt9dpxJ8VxoQr3vHDdP4+Enawtm wSFnrZD6i7CPghCfjI4COZP+9E/mMulNh3S+qO3/l+cZ8d7CmJCSvXKnLT1dsAoZxf+4 maHmnoEJoRmdl4OfpDBsZipTLr87k4VViSryZVOkG7GbQ2U+d9wSHwMLwsmi8g9dkgGf /a/SUzi5enSfbqdIXAZFMeAQqIF3AMsrf+siyNpgBb5FahmdUD4sJlK81O1CIyXizq2w 0JT2ioM17u7cWLMSY9QdnKCfCyMZJrq8hLrINQio099CX2m0AmlBNPZG1rxEhpvaJa4R Li3Q== 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=+vxhIXyc/GT5P7zxyphEpVcZECI2GZVgNs5s8U8O+pQ=; b=kEtPPg/9MBwXCH3+bCM05RrpmWxdsjhfbV7mipPNCkHIf2hlhC3XYZZdHat3GSmNQs woUhPzuaKQV1KQOPiV4bos326dKErmMTxF7eL7DLUHtrGo8DsftmSNhEbZH0DC+BA4GT d7eqoN+Dn1Z8B94c8VpDYnCkTfWG0HwB/ufjd2RIT8TEMEqfvQeKmkSGI8eoAEB/bY/r PQy6jlpBB312GF3Cw9Rw0aPR0tKrscVKYLmISIiIlr0MZ/OfzIP+2Iu5Hy1WI3KhkLaW T92lyQOZStn5OGKsTA9U7BqZkprVJKYozcjC+kXyZMsRM+v4kHa2kZwTEbpIesxGj9qD r6HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=u0Qzlixe; 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 ce3si625614edb.441.2019.10.28.05.43.15; Mon, 28 Oct 2019 05:43:16 -0700 (PDT) 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=u0Qzlixe; 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 S2389347AbfJ1MnO (ORCPT + 5 others); Mon, 28 Oct 2019 08:43:14 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:54500 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389339AbfJ1MnO (ORCPT ); Mon, 28 Oct 2019 08:43:14 -0400 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id x9SChC52067164; Mon, 28 Oct 2019 07:43:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1572266593; bh=+vxhIXyc/GT5P7zxyphEpVcZECI2GZVgNs5s8U8O+pQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=u0QzlixeDwNvypkxpLzvPQj+vw0UwhdJv1lvJ87HrOQ7rePOORO0j9yiSQznNsJOg iN5aenQeznZuxbUzuZgGGg+7PdfqpNtxE0GTqOhr/XgOTVeh4wqOd+Yw2hz/XC2LfF HVpZsE+yz+L7H0dJkxTxZIeGmGN1Zn2qszC4vrw4= Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x9SChCIi040394 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 28 Oct 2019 07:43:12 -0500 Received: from DLEE114.ent.ti.com (157.170.170.25) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Mon, 28 Oct 2019 07:43:00 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Mon, 28 Oct 2019 07:43:00 -0500 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 x9SCgoh1063574; Mon, 28 Oct 2019 07:43:10 -0500 From: Tero Kristo To: , , CC: , , , Tero Kristo Subject: [PATCH 09/17] remoteproc/omap: Remove the unused fields from platform data Date: Mon, 28 Oct 2019 14:42:30 +0200 Message-ID: <20191028124238.19224-10-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191028124238.19224-1-t-kristo@ti.com> References: <20191028124238.19224-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 --- 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 Reviewed-by: Bjorn Andersson 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 Mon Oct 28 12:42:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 177921 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3339460ill; Mon, 28 Oct 2019 05:43:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqyL1vk8gb7v7BW/y7B1QrQdd5MGd6GorRZwECTrTer/lus2fZ7rPkIj2OAVcGEj+RT0WHgU X-Received: by 2002:a05:6402:1349:: with SMTP id y9mr19129762edw.74.1572266607977; Mon, 28 Oct 2019 05:43:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572266607; cv=none; d=google.com; s=arc-20160816; b=CfP2kT/YYc4scT+xMDwnqSkuaeGNnvMbbs+BunxT9KxLx3Ue+wa9MEDJT8L2hJNlZr hZaoFtOMHCBJwJGwgOIv8+aChSmoSy4sQYuacH06Wc4ZJewWaY1cJYcmqjDUH0Hx3Ev+ j5vXQ0Jyn7kBnISC7IYGckdkYqd3fQvDG+8/FQWcWs7NqpQGPlxJ8Pd+bYTM2Rzfw6af lpRtBYnbNap0zlnPkp/x+mEu36hPQNt7LRew4RxkIqGN2fHb3P1iRuq6zzTK+xXAu17A Fj2aE3dKMth+19rGWpjMCLNjPM6+oO1cuBZe30R4IxHEgBMteVztFD0YPq4ThUIl9yUm g6Xg== 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=ObxkZR5S8p6PF891MPqgpe6CFyxBPc2I0M1HLauGAGg=; b=UioFBRFXmYmUWdbdpVyCXIFJ9OweCLDIhCnD58e29Th7HZtCgYfVz3hW9vI9wb7Wc1 EB+2Uf/JzXCphJCdLblu2y3MCqJZXjpttovCR32M4KvFYV/pP+C0G0lwN3OTlRRRiQ+4 WWCmS6NyR8yyxAsEJo+8dvjZBKMvDv+H0Or/xM1yhAEuzK60Fj35i1Y9TcTFImZj1hgl z1XhKHGi1jqqfwgFeEywi5asNAGjuaNSJIa9GjguMYBSHjwSzIrJ2EMHVO7aN/Bp3941 Evp9MFxqZAYUc7/Cej7jMKzd+7oAaY7QUhlmfsRSEfBohUEqi0sJl8hYDRx2mwYZOEZr mEcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=qpz6p7Iu; 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 26si7378003edz.340.2019.10.28.05.43.27; Mon, 28 Oct 2019 05:43:27 -0700 (PDT) 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=qpz6p7Iu; 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 S2389415AbfJ1Mn1 (ORCPT + 5 others); Mon, 28 Oct 2019 08:43:27 -0400 Received: from lelv0142.ext.ti.com ([198.47.23.249]:46302 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389382AbfJ1MnZ (ORCPT ); Mon, 28 Oct 2019 08:43:25 -0400 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id x9SChN9Q047834; Mon, 28 Oct 2019 07:43:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1572266603; bh=ObxkZR5S8p6PF891MPqgpe6CFyxBPc2I0M1HLauGAGg=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=qpz6p7IuON0egvY4FHVW22JOh3mqCXOUGyJmV/yoWUoLbypHaAct/YNuDsZr4CiLm qq2/IE4uSfB2N1WLsEaWHJbhHHGTNv6nQmi/EcGnIoOGKXyXmIixCL1vuqNi2oo5jT QOjJZQMOeoNk8trNbgWeKXedX88jVLS+BO7G8nDk= Received: from DFLE105.ent.ti.com (dfle105.ent.ti.com [10.64.6.26]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x9SChN2Y069706 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 28 Oct 2019 07:43:23 -0500 Received: from DFLE112.ent.ti.com (10.64.6.33) 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.1713.5; Mon, 28 Oct 2019 07:43:11 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Mon, 28 Oct 2019 07:43:11 -0500 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 x9SCgoh6063574; Mon, 28 Oct 2019 07:43:21 -0500 From: Tero Kristo To: , , CC: , , , Tero Kristo Subject: [PATCH 14/17] remoteproc/omap: add support for runtime auto-suspend/resume Date: Mon, 28 Oct 2019 14:42:35 +0200 Message-ID: <20191028124238.19224-15-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191028124238.19224-1-t-kristo@ti.com> References: <20191028124238.19224-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 This patch enhances the PM support in the OMAP remoteproc driver to support the runtime auto-suspend. A remoteproc may not be required to be running all the time, and typically will need to be active only during certain usecases. As such, to save power, it should be turned off during potential long periods of inactivity between usecases. This suspend and resume of the device is a relatively heavy process in terms of latencies, so a remoteproc should be suspended only after a certain period of prolonged inactivity. The OMAP remoteproc driver leverages the runtime pm framework's auto_suspend feature to accomplish this functionality. This feature is automatically enabled when a remote processor has successfully booted. The 'autosuspend_delay_ms' for each device dictates the inactivity period/time to wait for before suspending the device. The runtime auto-suspend design relies on marking the last busy time on every communication (virtqueue kick) to and from the remote processor. When there has been no activity for 'autosuspend_delay_ms' time, the runtime PM framework invokes the driver's runtime pm suspend callback to suspend the device. The remote processor will be woken up on the initiation of the next communication message through the runtime pm resume callback. The current auto-suspend design also allows a remote processor to deny a auto-suspend attempt, if it wishes to, by sending a NACK response to the initial suspend request message sent to the remote processor as part of the suspend process. The auto-suspend request is also only attempted if the remote processor is idled and in standby at the time of inactivity timer expiry. This choice is made to avoid unnecessary messaging, and the auto-suspend is simply rescheduled to be attempted again after a further lapse of autosuspend_delay_ms. The runtime pm callbacks functionality in this patch reuses most of the core logic from the suspend/resume support code, and make use of an additional auto_suspend flag to differentiate the logic in common code from system suspend. The system suspend/resume sequences are also updated to reflect the proper pm_runtime statuses, and also to really perform a suspend/resume only if the remoteproc has not been auto-suspended at the time of request. The remote processor is left in suspended state on a system resume if it has been auto-suspended before, and will be woken up only when a usecase needs to run. The other significant change in this patch is to reset the remoteproc device's pm_domain so as to avoid conflicts with the ordering sequences in the device pm_domain's runtime callbacks and the reset management and clock management implemented within the runtime callbacks in the driver. The OMAP remoteproc driver currently uses a default value of 10 seconds for all OMAP remoteprocs, and a different value can be chosen either by choosing a positive value for the 'autosuspend_delay' in the device's omap_rproc_fw_data in the driver match data or by updating the 'autosuspend_delay_ms' field at runtime through the sysfs interface. Eg: To use 25 seconds for IPU2 on DRA7xx, echo 25000 > /sys/bus/platform/devices/55020000.ipu/power/autosuspend_delay_ms The runtime suspend feature can also be similarly enabled or disabled by writing 'auto' or 'on' to the device's 'control' power field. The default is enabled. Eg: To disable auto-suspend for IPU2 on DRA7xx SoC, echo on > /sys/bus/platform/devices/55020000.ipu/power/control Signed-off-by: Suman Anna [t-kristo@ti.com: converted to use ti-sysc instead of hwmod] Signed-off-by: Tero Kristo --- drivers/remoteproc/omap_remoteproc.c | 228 ++++++++++++++++++++++++++- 1 file changed, 222 insertions(+), 6 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 410bf1b56e93..8bd415c8fc86 100644 --- a/drivers/remoteproc/omap_remoteproc.c +++ b/drivers/remoteproc/omap_remoteproc.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -41,6 +42,9 @@ #define OMAP_RPROC_DSP_LOCAL_MEM_OFFSET (0x00800000) #define OMAP_RPROC_IPU_L2RAM_DEV_ADDR (0x20000000) +/* default auto-suspend delay (ms) */ +#define DEFAULT_AUTOSUSPEND_DELAY 10000 + /** * struct omap_rproc_boot_data - boot data structure for the DSP omap rprocs * @syscon: regmap handle for the system control configuration module @@ -87,6 +91,8 @@ struct omap_rproc_timer { * @num_mems: number of internal memory regions * @num_timers: number of rproc timer(s) * @timers: timer(s) info used by rproc + * @autosuspend_delay: auto-suspend delay value to be used for runtime pm + * @need_resume: if true a resume is needed in the system resume callback * @rproc: rproc handle * @reset: reset handle * @pm_comp: completion primitive to sync for suspend response @@ -101,6 +107,8 @@ struct omap_rproc { int num_mems; int num_timers; struct omap_rproc_timer *timers; + int autosuspend_delay; + bool need_resume; struct rproc *rproc; struct reset_control *reset; struct completion pm_comp; @@ -112,10 +120,12 @@ struct omap_rproc { * struct omap_rproc_dev_data - device data for the omap remote processor * @device_name: device name of the remote processor * @fw_name: firmware name to use + * @autosuspend_delay: custom auto-suspend delay value in milliseconds */ struct omap_rproc_dev_data { const char *device_name; const char *fw_name; + int autosuspend_delay; }; /** @@ -381,11 +391,23 @@ static void omap_rproc_kick(struct rproc *rproc, int vqid) struct device *dev = rproc->dev.parent; int ret; + /* wake up the rproc before kicking it */ + ret = pm_runtime_get_sync(dev); + if (WARN_ON(ret < 0)) { + dev_err(dev, "pm_runtime_get_sync() failed during kick, ret = %d\n", + ret); + pm_runtime_put_noidle(dev); + return; + } + /* send the index of the triggered virtqueue in the mailbox payload */ ret = mbox_send_message(oproc->mbox, (void *)vqid); if (ret < 0) dev_err(dev, "failed to send mailbox message, status = %d\n", ret); + + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); } /** @@ -470,6 +492,19 @@ static int omap_rproc_start(struct rproc *rproc) goto put_mbox; } + /* + * remote processor is up, so update the runtime pm status and + * enable the auto-suspend. The device usage count is incremented + * manually for balancing it for auto-suspend + */ + pm_runtime_set_active(dev); + pm_runtime_set_autosuspend_delay(dev, oproc->autosuspend_delay); + pm_runtime_use_autosuspend(dev); + pm_runtime_get(dev); + pm_runtime_enable(dev); + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); + reset_control_deassert(oproc->reset); return 0; @@ -482,9 +517,26 @@ 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 omap_rproc *oproc = rproc->priv; int ret; + /* + * cancel any possible scheduled runtime suspend by incrementing + * the device usage count, and resuming the device. The remoteproc + * also needs to be woken up if suspended, to avoid the remoteproc + * OS to continue to remember any context that it has saved, and + * avoid potential issues in misindentifying a subsequent device + * reboot as a power restore boot + */ + ret = pm_runtime_get_sync(dev); + if (ret < 0) { + pm_runtime_put_noidle(dev); + return ret; + } + + pm_runtime_put_sync(dev); + reset_control_assert(oproc->reset); ret = omap_rproc_disable_timers(rproc, true); @@ -493,6 +545,15 @@ static int omap_rproc_stop(struct rproc *rproc) mbox_free_channel(oproc->mbox); + /* + * update the runtime pm states and status now that the remoteproc + * has stopped + */ + pm_runtime_disable(dev); + pm_runtime_dont_use_autosuspend(dev); + pm_runtime_put_noidle(dev); + pm_runtime_set_suspended(dev); + return 0; } @@ -545,17 +606,19 @@ static bool _is_rproc_in_standby(struct omap_rproc *oproc) /* 1 sec is long enough time to let the remoteproc side suspend the device */ #define DEF_SUSPEND_TIMEOUT 1000 -static int _omap_rproc_suspend(struct rproc *rproc) +static int _omap_rproc_suspend(struct rproc *rproc, bool auto_suspend) { struct device *dev = rproc->dev.parent; struct omap_rproc *oproc = rproc->priv; unsigned long to = msecs_to_jiffies(DEF_SUSPEND_TIMEOUT); unsigned long ta = jiffies + to; + u32 suspend_msg = auto_suspend ? + RP_MBOX_SUSPEND_AUTO : RP_MBOX_SUSPEND_SYSTEM; int ret; reinit_completion(&oproc->pm_comp); oproc->suspend_acked = false; - ret = mbox_send_message(oproc->mbox, (void *)RP_MBOX_SUSPEND_SYSTEM); + ret = mbox_send_message(oproc->mbox, (void *)suspend_msg); if (ret < 0) { dev_err(dev, "PM mbox_send_message failed: %d\n", ret); return ret; @@ -595,25 +658,55 @@ static int _omap_rproc_suspend(struct rproc *rproc) goto enable_device; } + /* + * IOMMUs would have to be disabled specifically for runtime suspend. + * They are handled automatically through System PM callbacks for + * regular system suspend + */ + if (auto_suspend) { + ret = omap_iommu_domain_deactivate(rproc->domain); + if (ret) { + dev_err(dev, "iommu domain deactivate failed %d\n", + ret); + goto enable_timers; + } + } + return 0; +enable_timers: + /* ignore errors on re-enabling code */ + omap_rproc_enable_timers(rproc, false); enable_device: reset_control_deassert(oproc->reset); return ret; } -static int _omap_rproc_resume(struct rproc *rproc) +static int _omap_rproc_resume(struct rproc *rproc, bool auto_suspend) { struct device *dev = rproc->dev.parent; struct omap_rproc *oproc = rproc->priv; int ret; + /* + * IOMMUs would have to be enabled specifically for runtime resume. + * They would have been already enabled automatically through System + * PM callbacks for regular system resume + */ + if (auto_suspend) { + ret = omap_iommu_domain_activate(rproc->domain); + if (ret) { + dev_err(dev, "omap_iommu activate failed %d\n", ret); + goto out; + } + } + /* boot address could be lost after suspend, so restore it */ if (oproc->boot_data) { ret = omap_rproc_write_dsp_boot_addr(rproc); if (ret) { dev_err(dev, "boot address restore failed %d\n", ret); - goto out; + goto suspend_iommu; } } @@ -626,6 +719,12 @@ static int _omap_rproc_resume(struct rproc *rproc) reset_control_deassert(oproc->reset); + return 0; + +suspend_iommu: + if (auto_suspend) + omap_iommu_domain_deactivate(rproc->domain); + out: return ret; } @@ -634,6 +733,7 @@ static int __maybe_unused omap_rproc_suspend(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct rproc *rproc = platform_get_drvdata(pdev); + struct omap_rproc *oproc = rproc->priv; int ret = 0; mutex_lock(&rproc->lock); @@ -648,13 +748,25 @@ static int __maybe_unused omap_rproc_suspend(struct device *dev) goto out; } - ret = _omap_rproc_suspend(rproc); + ret = _omap_rproc_suspend(rproc, false); if (ret) { dev_err(dev, "suspend failed %d\n", ret); goto out; } + /* + * remoteproc is running at the time of system suspend, so remember + * it so as to wake it up during system resume + */ + oproc->need_resume = 1; rproc->state = RPROC_SUSPENDED; + + /* + * update the runtime pm status to be suspended, without decrementing + * the device usage count + */ + pm_runtime_disable(dev); + pm_runtime_set_suspended(dev); out: mutex_unlock(&rproc->lock); return ret; @@ -664,6 +776,7 @@ static int __maybe_unused omap_rproc_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct rproc *rproc = platform_get_drvdata(pdev); + struct omap_rproc *oproc = rproc->priv; int ret = 0; mutex_lock(&rproc->lock); @@ -675,17 +788,86 @@ static int __maybe_unused omap_rproc_resume(struct device *dev) goto out; } - ret = _omap_rproc_resume(rproc); + /* + * remoteproc was auto-suspended at the time of system suspend, + * so no need to wake-up the processor (leave it in suspended + * state, will be woken up during a subsequent runtime_resume) + */ + if (!oproc->need_resume) + goto out; + + ret = _omap_rproc_resume(rproc, false); if (ret) { dev_err(dev, "resume failed %d\n", ret); goto out; } + oproc->need_resume = false; rproc->state = RPROC_RUNNING; + + /* + * update the runtime pm status to be active, without incrementing + * the device usage count + */ + pm_runtime_set_active(dev); + pm_runtime_enable(dev); + pm_runtime_mark_last_busy(dev); out: mutex_unlock(&rproc->lock); return ret; } + +static int omap_rproc_runtime_suspend(struct device *dev) +{ + struct rproc *rproc = dev_get_drvdata(dev); + struct omap_rproc *oproc = rproc->priv; + int ret; + + if (WARN_ON(rproc->state != RPROC_RUNNING)) { + dev_err(dev, "rproc cannot be runtime suspended when not running!\n"); + return -EBUSY; + } + + /* + * do not even attempt suspend if the remote processor is not + * idled for runtime auto-suspend + */ + if (!_is_rproc_in_standby(oproc)) { + ret = -EBUSY; + goto abort; + } + + ret = _omap_rproc_suspend(rproc, true); + if (ret) + goto abort; + + rproc->state = RPROC_SUSPENDED; + return 0; + +abort: + pm_runtime_mark_last_busy(dev); + return ret; +} + +static int omap_rproc_runtime_resume(struct device *dev) +{ + struct rproc *rproc = dev_get_drvdata(dev); + int ret; + + if (WARN_ON(rproc->state != RPROC_SUSPENDED)) { + dev_err(dev, "rproc cannot be runtime resumed if not suspended!\n"); + return -EBUSY; + } + + ret = _omap_rproc_resume(rproc, true); + if (ret) { + dev_err(dev, "runtime resume failed %d\n", ret); + return ret; + } + + rproc->state = RPROC_RUNNING; + return 0; +} #endif /* CONFIG_PM */ static const struct omap_rproc_dev_data omap4_dsp_dev_data = { @@ -761,6 +943,33 @@ static const struct of_device_id omap_rproc_of_match[] = { }; MODULE_DEVICE_TABLE(of, omap_rproc_of_match); +static int omap_rproc_get_autosuspend_delay(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + const struct omap_rproc_dev_data *data; + int delay = -EINVAL; + + data = of_device_get_match_data(&pdev->dev); + if (!data) + return -ENODEV; + + if (!of_device_is_compatible(np, "ti,dra7-dsp") && + !of_device_is_compatible(np, "ti,dra7-ipu")) { + delay = data->autosuspend_delay; + goto out; + } + + for (; data && data->device_name; data++) { + if (!strcmp(dev_name(&pdev->dev), data->device_name)) { + delay = data->autosuspend_delay; + break; + } + } + +out: + return (delay > 0) ? delay : DEFAULT_AUTOSUSPEND_DELAY; +} + static const char *omap_rproc_get_firmware(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; @@ -973,6 +1182,11 @@ static int omap_rproc_probe(struct platform_device *pdev) } init_completion(&oproc->pm_comp); + oproc->autosuspend_delay = omap_rproc_get_autosuspend_delay(pdev); + if (oproc->autosuspend_delay < 0) { + ret = oproc->autosuspend_delay; + goto free_rproc; + } oproc->fck = of_clk_get(np, 0); if (IS_ERR(oproc->fck)) { @@ -1015,6 +1229,8 @@ static int omap_rproc_remove(struct platform_device *pdev) static const struct dev_pm_ops omap_rproc_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(omap_rproc_suspend, omap_rproc_resume) + SET_RUNTIME_PM_OPS(omap_rproc_runtime_suspend, + omap_rproc_runtime_resume, NULL) }; static struct platform_driver omap_rproc_driver = { From patchwork Mon Oct 28 12:42:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 177922 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3339484ill; Mon, 28 Oct 2019 05:43:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqyT8gSewYS2kxC9ARqv9oqqq2ifzyI8+MytVuVwkAX2zuozOLeETp2dKiM4lEQ1egWf1rMm X-Received: by 2002:a50:a9e3:: with SMTP id n90mr1667506edc.52.1572266608662; Mon, 28 Oct 2019 05:43:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572266608; cv=none; d=google.com; s=arc-20160816; b=C133U6cbi+nErSMw4QF5Xiwt1cMbGXQNV0pP5fPlIxdA9+UCUwgW2BrSaIyTbtIn2C VT6q+XSd9xiBuGBmzKcarkGE982sbe9kOTVQ1+mf8b/gQlmEg9FO7uLbqEFJxKfHBA5R a1mjaqPqHkn0u+BEvdfTAgEMNI/++7xcjQXsjmlgRBkevi+Vl6K2EVAE87Ouw5S6hIOd d0zYjnomPiWL0y++sPhRLIKekP3VjfO8uXSbfvMYla5ozXWe5C1U/ycR1Z44fuqy7vV8 vJ9Bu78wiRFudlXFCOJxqf0/3C6PVgxw795kwz58lEdr4ZYUqaPL879D0zwbg9Wb1Mq6 GprQ== 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=rPONEiSmD4pWcodXkaa3Ko/nwYMCIwTFmnmZ81Du1bQ=; b=zLpMdzwDR31ZRrbIXs9Xknz/1NFI93GnliIJ9WtNXmAV8xzrqUch34VHkb/8P0X9pP NPhuvWfCaw7eIn4iDqJietiKGMWau+s/nUqo9wxRWgKGhc923lQrhfJLEvpEw6DcI3jp OeycdF2PSQgCKzSNH51G3+V3dOc82yBLYx1xN4Il/yw+h3rZR2FY5bNzyC+hvvDSPyx2 xwFX+/pn3GII61HoOrbbO0vFi5dhh1d8/bVEGnHT8Ww9FbdlC39pOnqx8c7JF4i7fBGq fZ17J7QFqaRPpiwXHqD9UdKuViyzr63bIBcDSxzarW/rF9iDk4VkPXVqCzF+Nn3KtJ4F Uhsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=xi1wofiD; 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 26si7378003edz.340.2019.10.28.05.43.28; Mon, 28 Oct 2019 05:43:28 -0700 (PDT) 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=xi1wofiD; 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 S2389418AbfJ1Mn1 (ORCPT + 5 others); Mon, 28 Oct 2019 08:43:27 -0400 Received: from lelv0142.ext.ti.com ([198.47.23.249]:46308 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389395AbfJ1Mn0 (ORCPT ); Mon, 28 Oct 2019 08:43:26 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id x9SChPX5047842; Mon, 28 Oct 2019 07:43:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1572266605; bh=rPONEiSmD4pWcodXkaa3Ko/nwYMCIwTFmnmZ81Du1bQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=xi1wofiDyEyagV8/CCDO2EjZI1c92oqOCkDr1QCvVg8K7Bwr/xzEFKvZUCyeSpP1E hwD6sHID11de9EXQOcBFwLE31wCBVZ/1soJhZaJSUNGhnzkZUU/a+dkiwCffybr8/W ksgUoDb/cYz0BWiXRJyaXzzNBf5R/svCiqIzlNlY= Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x9SChPLs075631 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 28 Oct 2019 07:43:25 -0500 Received: from DFLE102.ent.ti.com (10.64.6.23) 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.1713.5; Mon, 28 Oct 2019 07:43:13 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Mon, 28 Oct 2019 07:43:13 -0500 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 x9SCgoh7063574; Mon, 28 Oct 2019 07:43:23 -0500 From: Tero Kristo To: , , CC: , , , Tero Kristo Subject: [PATCH 15/17] remoteproc/omap: report device exceptions and trigger recovery Date: Mon, 28 Oct 2019 14:42:36 +0200 Message-ID: <20191028124238.19224-16-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191028124238.19224-1-t-kristo@ti.com> References: <20191028124238.19224-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 OMAP remote processors send a special mailbox message (RP_MBOX_CRASH) when they crash and detect an internal device exception. Add support to the mailbox handling function upon detection of this special message to report this crash to the remoteproc core. The remoteproc core can trigger a recovery using the prevailing recovery mechanism, already in use for MMU Fault recovery. Signed-off-by: Subramaniam Chanderashekarapuram Signed-off-by: Suman Anna Signed-off-by: Tero Kristo --- drivers/remoteproc/omap_remoteproc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) -- 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 8bd415c8fc86..6f797025bb6b 100644 --- a/drivers/remoteproc/omap_remoteproc.c +++ b/drivers/remoteproc/omap_remoteproc.c @@ -360,8 +360,12 @@ static void omap_rproc_mbox_callback(struct mbox_client *client, void *data) switch (msg) { case RP_MBOX_CRASH: - /* just log this for now. later, we'll also do recovery */ + /* + * remoteproc detected an exception, notify the rproc core. + * The remoteproc core will handle the recovery. + */ dev_err(dev, "omap rproc %s crashed\n", name); + rproc_report_crash(oproc->rproc, RPROC_FATAL_ERROR); break; case RP_MBOX_ECHO_REPLY: dev_info(dev, "received echo reply from %s\n", name);