From patchwork Mon Feb 4 14:22:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 157420 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3973676jaa; Mon, 4 Feb 2019 06:24:11 -0800 (PST) X-Google-Smtp-Source: ALg8bN4EAOC90XlfxR66Ui1R4q8uPEtfHXubkKNUSrjQzJLfrxuSQdqCVA4p+GLg/IfFsMEwQEsM X-Received: by 2002:a62:55c4:: with SMTP id j187mr51045040pfb.129.1549290251325; Mon, 04 Feb 2019 06:24:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549290251; cv=none; d=google.com; s=arc-20160816; b=spZijLSFXKucPurra5KmOffS5jJparulpLBmy4eqg2wvs+iWaDlTSpKhCAfdcFrAcp pe5ZVSGLWujOvHNN2UClGGOW+sro0SzzgtOkY+yWKRRz7WnfAk8S1yU66N6o1KYO14mo uUWeU96IPo2TtxqDivdXfz/wFjkBhyyF5YgcMGALLderTdLqfl+nJr1wuDHceb168g8Q cCaUsZBleA7iHhNkDQDrkscK+ZtJWRTYANEg/Oha/rVJHwawR/tkuvCihwgfEhhnEAY7 NQEa7CI4GV1OiRUxHVrprgIOWKOGZlm6yLwr6C/zvCR3PdA2y7hd9REMswM6Z6dz89yF D0UA== 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=xYhFn+XoCbY3N+WtnCXNF8c7lPDXw/OdjseI+5U2LQk=; b=HXLmV6JI6NpO8DxwDHqWX61pvzawidQf6GQOIgEhARuq4KMNXzAgunRuT160yFKZSG Qd/pqw+w+wTN8YGEuRqbdU6pnBqUqV3bfOUdjqxaWDh6NhcT7wwt/Dtir5wNZNIIDWaR PXpBsPk5FqcuvPycauaVm/IbZTdteMtF2zdBdC4yHsJIgqH8mojCOZUOGqGv98z2EgRZ rX0LGiLUDXsiHnCtsxsr3CNVPs4qhp5X9lDZvIZ7Q1Fx/lUHdFR2mEO5rTOjP00ilYJH l0qh1aC1oSsFHKRKKuEl6zIYIf24/DpFcMgtPjPOlBaCQBBsBGwdbKSS/svGMMuH0HlD dlpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=H0hmhGAR; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-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 98si162055pls.205.2019.02.04.06.24.11; Mon, 04 Feb 2019 06:24:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-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=H0hmhGAR; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-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 S1729262AbfBDOYK (ORCPT + 7 others); Mon, 4 Feb 2019 09:24:10 -0500 Received: from lelv0143.ext.ti.com ([198.47.23.248]:49802 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728937AbfBDOYK (ORCPT ); Mon, 4 Feb 2019 09:24:10 -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 x14ENGAs043984; Mon, 4 Feb 2019 08:23:16 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1549290196; bh=xYhFn+XoCbY3N+WtnCXNF8c7lPDXw/OdjseI+5U2LQk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=H0hmhGAR/nJFkGmjcDgxw6o4vJ89UPYAYpkZDYdHqkFuFZG79DlXGqsvFILxMZ7Lp qN0dWGL5BjDCffbLCcP/FTeO8eNsJ/9QkprXF8MpNrIiNLKqrsvf9V4Gvx5KagCsdI A2Px/VPEUIyY8jIkyGMesQCHfRwqFVsrzI7PpSl0= Received: from DLEE103.ent.ti.com (dlee103.ent.ti.com [157.170.170.33]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x14ENGcU115765 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 4 Feb 2019 08:23:16 -0600 Received: from DLEE114.ent.ti.com (157.170.170.25) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Mon, 4 Feb 2019 08:23:15 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Mon, 4 Feb 2019 08:23:15 -0600 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id x14EMoKd012232; Mon, 4 Feb 2019 08:23:12 -0600 From: Roger Quadros To: , , CC: , , , , , , , , , , , , Subject: [PATCH v2 05/14] remoteproc: add map parameter to da_to_va Date: Mon, 4 Feb 2019 16:22:38 +0200 Message-ID: <1549290167-876-6-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1549290167-876-1-git-send-email-rogerq@ti.com> References: <1549290167-876-1-git-send-email-rogerq@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: David Lechner This adds a new map parameter to the da_to_va callback for remoteproc devices. This parameter will be used by devices that have more than one memory map, such as the PRU found in TI Sitara SoCs. On these devices, the same physical memory address can refer to two different locations, i.e. instruction memory or data memory both start at 0x0. So, an extra bit of information is needed in the da_to_va callback to tell these apart. Devices that only have a single memory map will just pass 0 for this parameter. For now we are using 0 everywhere, but later patches will modify this value. Signed-off-by: David Lechner Signed-off-by: Roger Quadros --- drivers/remoteproc/imx_rproc.c | 2 +- drivers/remoteproc/keystone_remoteproc.c | 3 ++- drivers/remoteproc/qcom_q6v5_mss.c | 2 +- drivers/remoteproc/qcom_wcnss.c | 2 +- drivers/remoteproc/remoteproc_core.c | 11 +++++++---- drivers/remoteproc/remoteproc_elf_loader.c | 4 ++-- drivers/remoteproc/remoteproc_internal.h | 2 +- drivers/remoteproc/st_slim_rproc.c | 2 +- drivers/remoteproc/wkup_m3_rproc.c | 3 ++- include/linux/remoteproc.h | 2 +- 10 files changed, 19 insertions(+), 14 deletions(-) -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c index 54c07fd..78c3502 100644 --- a/drivers/remoteproc/imx_rproc.c +++ b/drivers/remoteproc/imx_rproc.c @@ -211,7 +211,7 @@ static int imx_rproc_da_to_sys(struct imx_rproc *priv, u64 da, return -ENOENT; } -static void *imx_rproc_da_to_va(struct rproc *rproc, u64 da, int len) +static void *imx_rproc_da_to_va(struct rproc *rproc, u64 da, int len, int map) { struct imx_rproc *priv = rproc->priv; void *va = NULL; diff --git a/drivers/remoteproc/keystone_remoteproc.c b/drivers/remoteproc/keystone_remoteproc.c index aaac311..0f87cf9 100644 --- a/drivers/remoteproc/keystone_remoteproc.c +++ b/drivers/remoteproc/keystone_remoteproc.c @@ -254,7 +254,8 @@ static void keystone_rproc_kick(struct rproc *rproc, int vqid) * can be used either by the remoteproc core for loading (when using kernel * remoteproc loader), or by any rpmsg bus drivers. */ -static void *keystone_rproc_da_to_va(struct rproc *rproc, u64 da, int len) +static void *keystone_rproc_da_to_va(struct rproc *rproc, u64 da, int len, + int map) { struct keystone_rproc *ksproc = rproc->priv; void __iomem *va = NULL; diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c index 01be731..d0cdc34 100644 --- a/drivers/remoteproc/qcom_q6v5_mss.c +++ b/drivers/remoteproc/qcom_q6v5_mss.c @@ -971,7 +971,7 @@ static void qcom_q6v5_dump_segment(struct rproc *rproc, int ret = 0; struct q6v5 *qproc = rproc->priv; unsigned long mask = BIT((unsigned long)segment->priv); - void *ptr = rproc_da_to_va(rproc, segment->da, segment->size); + void *ptr = rproc_da_to_va(rproc, segment->da, segment->size, 0); /* Unlock mba before copying segments */ if (!qproc->dump_mba_loaded) diff --git a/drivers/remoteproc/qcom_wcnss.c b/drivers/remoteproc/qcom_wcnss.c index b0e07e9..92b05fb 100644 --- a/drivers/remoteproc/qcom_wcnss.c +++ b/drivers/remoteproc/qcom_wcnss.c @@ -295,7 +295,7 @@ static int wcnss_stop(struct rproc *rproc) return ret; } -static void *wcnss_da_to_va(struct rproc *rproc, u64 da, int len) +static void *wcnss_da_to_va(struct rproc *rproc, u64 da, int len, int map) { struct qcom_wcnss *wcnss = (struct qcom_wcnss *)rproc->priv; int offset; diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 54ec38f..06ef4fa 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -166,6 +166,8 @@ static phys_addr_t rproc_va_to_pa(void *cpu_addr) * @rproc: handle of a remote processor * @da: remoteproc device address to translate * @len: length of the memory region @da is pointing to + * @map: indicates which memory map to use for devices with more than one + * memory map or 0 for devices that only have a single memory map * * Some remote processors will ask us to allocate them physically contiguous * memory regions (which we call "carveouts"), and map them to specific @@ -190,13 +192,13 @@ static phys_addr_t rproc_va_to_pa(void *cpu_addr) * here the output of the DMA API for the carveouts, which should be more * correct. */ -void *rproc_da_to_va(struct rproc *rproc, u64 da, int len) +void *rproc_da_to_va(struct rproc *rproc, u64 da, int len, int map) { struct rproc_mem_entry *carveout; void *ptr = NULL; if (rproc->ops->da_to_va) { - ptr = rproc->ops->da_to_va(rproc, da, len); + ptr = rproc->ops->da_to_va(rproc, da, len, map); if (ptr) goto out; } @@ -575,7 +577,7 @@ static int rproc_handle_trace(struct rproc *rproc, struct fw_rsc_trace *rsc, } /* what's the kernel address of this resource ? */ - ptr = rproc_da_to_va(rproc, rsc->da, rsc->len); + ptr = rproc_da_to_va(rproc, rsc->da, rsc->len, 0); if (!ptr) { dev_err(dev, "erroneous trace resource entry\n"); return -EINVAL; @@ -1549,7 +1551,8 @@ static void rproc_coredump(struct rproc *rproc) if (segment->dump) { segment->dump(rproc, segment, data + offset); } else { - ptr = rproc_da_to_va(rproc, segment->da, segment->size); + ptr = rproc_da_to_va(rproc, segment->da, + segment->size, 0); if (!ptr) { dev_err(&rproc->dev, "invalid coredump segment (%pad, %zu)\n", diff --git a/drivers/remoteproc/remoteproc_elf_loader.c b/drivers/remoteproc/remoteproc_elf_loader.c index b17d72e..8888d39 100644 --- a/drivers/remoteproc/remoteproc_elf_loader.c +++ b/drivers/remoteproc/remoteproc_elf_loader.c @@ -182,7 +182,7 @@ int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw) } /* grab the kernel address for this device address */ - ptr = rproc_da_to_va(rproc, da, memsz); + ptr = rproc_da_to_va(rproc, da, memsz, 0); if (!ptr) { dev_err(dev, "bad phdr da 0x%x mem 0x%x\n", da, memsz); ret = -EINVAL; @@ -333,6 +333,6 @@ struct resource_table *rproc_elf_find_loaded_rsc_table(struct rproc *rproc, if (!shdr) return NULL; - return rproc_da_to_va(rproc, shdr->sh_addr, shdr->sh_size); + return rproc_da_to_va(rproc, shdr->sh_addr, shdr->sh_size, 0); } EXPORT_SYMBOL(rproc_elf_find_loaded_rsc_table); diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index f6cad24..15e0833 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -51,7 +51,7 @@ void rproc_exit_sysfs(void); void rproc_free_vring(struct rproc_vring *rvring); int rproc_alloc_vring(struct rproc_vdev *rvdev, int i); -void *rproc_da_to_va(struct rproc *rproc, u64 da, int len); +void *rproc_da_to_va(struct rproc *rproc, u64 da, int len, int map); int rproc_trigger_recovery(struct rproc *rproc); int rproc_elf_sanity_check(struct rproc *rproc, const struct firmware *fw); diff --git a/drivers/remoteproc/st_slim_rproc.c b/drivers/remoteproc/st_slim_rproc.c index d711d94..8b843c8 100644 --- a/drivers/remoteproc/st_slim_rproc.c +++ b/drivers/remoteproc/st_slim_rproc.c @@ -178,7 +178,7 @@ static int slim_rproc_stop(struct rproc *rproc) return 0; } -static void *slim_rproc_da_to_va(struct rproc *rproc, u64 da, int len) +static void *slim_rproc_da_to_va(struct rproc *rproc, u64 da, int len, int map) { struct st_slim_rproc *slim_rproc = rproc->priv; void *va = NULL; diff --git a/drivers/remoteproc/wkup_m3_rproc.c b/drivers/remoteproc/wkup_m3_rproc.c index 1ada0e5..12cb26e 100644 --- a/drivers/remoteproc/wkup_m3_rproc.c +++ b/drivers/remoteproc/wkup_m3_rproc.c @@ -88,7 +88,8 @@ static int wkup_m3_rproc_stop(struct rproc *rproc) return 0; } -static void *wkup_m3_rproc_da_to_va(struct rproc *rproc, u64 da, int len) +static void *wkup_m3_rproc_da_to_va(struct rproc *rproc, u64 da, int len, + int map) { struct wkup_m3_rproc *wkupm3 = rproc->priv; void *va = NULL; diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 507a2b5..e908b58 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -356,7 +356,7 @@ struct rproc_ops { int (*start)(struct rproc *rproc); int (*stop)(struct rproc *rproc); void (*kick)(struct rproc *rproc, int vqid); - void * (*da_to_va)(struct rproc *rproc, u64 da, int len); + void * (*da_to_va)(struct rproc *rproc, u64 da, int len, int map); int (*parse_fw)(struct rproc *rproc, const struct firmware *fw); struct resource_table *(*find_loaded_rsc_table)( struct rproc *rproc, const struct firmware *fw); From patchwork Mon Feb 4 14:22:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 157427 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3974088jaa; Mon, 4 Feb 2019 06:24:35 -0800 (PST) X-Google-Smtp-Source: AHgI3IZBKaGnqEhQcnkyb3o2trglQuk8SAWeTjlSl82vSJBCA+/OPN1uJ1UztZn6JQRUSag8HsBL X-Received: by 2002:a63:d949:: with SMTP id e9mr13276766pgj.24.1549290275438; Mon, 04 Feb 2019 06:24:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549290275; cv=none; d=google.com; s=arc-20160816; b=Ulsmfr7ajOUyO/95G/44vvsnm3Nmc0MnrmQcHMsWX9hjPrUorBbuT/6jihd0jeN67I RlX1/46GQSVXUKP1t8tX7cK22cnnzw8dDV0GVxjKzJ7YNYfNutcbN4anv/926Gw4Bct9 d1o/C543UnemcQt1oL7OWMK2d+asGdg1u40yK8/88dY4kt3F2+EVaH+x/w4nklLCGW3j ETooa2VuBB56GcF4r3CN/yojZ/0oPrFaDujeApGRX5NnJ8+tVqf/jR+saxH3NI1IKH55 6fyqmbLh9k5xOJ9ul7Npd/4NEt6gfUMa+2nELyOkT+cLvAq1hWi/RkWw7QPPmJUTu0WE 0ysQ== 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=MFbzKHHqZiG/4G996RXE2tPJ46dinASP/E0HN/KFSkY=; b=Xgh1vX7zqsCc4yqJpsqsbWcQ5rAbmIAMRyXEG4zr6TcbWJFsB6gGAfhzQmHFpnuc/W rn6+NLfKoGxiYJMUzMFiQ5IZEgPsysCvJ2auTjzRe1UJdX0LAWaJtEQzvS0p/chH+9s2 /xjQKReWPwvNzl/A82julNeZDf0ekzJdS2n3NcbYLlykqFGb3worwd9wOXwNeVkmxMmj P7wwl/IPpJsRLeDJ9kDlw2Ls31W8a/VmOutdQ/mjeAzEjzStjkKHOLS65FeJiwLj6EJv ZMK5uGT1kW+YzCmFf4UEhIxcPjH9qsChWGFhsqhmJGLesjYqahkZ83syoLxqnkf9pwbX USkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=lV3AsnZD; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-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 j9si143968pll.437.2019.02.04.06.24.35; Mon, 04 Feb 2019 06:24:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-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=lV3AsnZD; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-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 S1730023AbfBDOYd (ORCPT + 7 others); Mon, 4 Feb 2019 09:24:33 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:43046 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729987AbfBDOYc (ORCPT ); Mon, 4 Feb 2019 09:24:32 -0500 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id x14ENhus023342; Mon, 4 Feb 2019 08:23:43 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1549290223; bh=MFbzKHHqZiG/4G996RXE2tPJ46dinASP/E0HN/KFSkY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=lV3AsnZD15xE8EzsJfS5lQvi4KBrr6sEsPUG2smjWoS6NAkO8bkYasbOo8y/LJQJj EG0BY9mFRidlGgW6yfqeN0r/62JV/7ztzxaZCVK9gyq6XHk/vk4lw3aWt6eKqQCF5a u2VffESGz700SN0QL4yuLPhJYHsMrRcEtOpIww84= Received: from DFLE111.ent.ti.com (dfle111.ent.ti.com [10.64.6.32]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x14ENhoq010455 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 4 Feb 2019 08:23:43 -0600 Received: from DFLE106.ent.ti.com (10.64.6.27) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Mon, 4 Feb 2019 08:23:43 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE106.ent.ti.com (10.64.6.27) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Mon, 4 Feb 2019 08:23:43 -0600 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id x14EMoKk012232; Mon, 4 Feb 2019 08:23:39 -0600 From: Roger Quadros To: , , CC: , , , , , , , , , , , , Subject: [PATCH v2 12/14] remoteproc/pru: Add support for virtio rpmsg stack Date: Mon, 4 Feb 2019 16:22:45 +0200 Message-ID: <1549290167-876-13-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1549290167-876-1-git-send-email-rogerq@ti.com> References: <1549290167-876-1-git-send-email-rogerq@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Suman Anna The PRU remoteproc driver has been enhanced to support the optional rpmsg stack using the virtio-ring based communication transport between MPU and a PRU core. This provides support to any firmware images supporting the virtio devices. The virtio-ring signalling support is provided either through a OMAP mailbox or through two PRU system events on OMAP-architecture based SoCs - one event used in each direction for kicking from one processor and receiving notification on the other processor. The virtio rpmsg signalling is enabled only using using PRU system events for interrupts on the Keystone-architecture based 66AK2G SoCs (it is possible to implement using an alternate Keystone specific IPCGR registers as well). The driver supports both signalling options, though the PRU events based signalling is the recommended option as it avoids an external peripheral access from the PRU side. It also provides a uniform solution across both the OMAP, Keystone and Davinci architectures. The PRU events based signalling takes precedence if both options are mentioned. Either of the options would require the corresponding firmware support though. A build dependency against MAILBOX is also added. Note that the OMAP Mailbox IP is not present on 66AK2G and Davinci SoCs, so it is only selected for OMAP-based SoCs. Signed-off-by: Suman Anna Signed-off-by: Roger Quadros --- drivers/remoteproc/Kconfig | 2 + drivers/remoteproc/pru_rproc.c | 165 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 166 insertions(+), 1 deletion(-) -- 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 333666e..b89acb0 100644 --- a/drivers/remoteproc/Kconfig +++ b/drivers/remoteproc/Kconfig @@ -200,6 +200,8 @@ config ST_SLIM_REMOTEPROC config PRUSS_REMOTEPROC tristate "TI PRUSS remoteproc support" depends on TI_PRUSS + select MAILBOX + select OMAP2PLUS_MBOX if ARCH_OMAP2PLUS default n help Support for TI PRU-ICSS remote processors via the remote processor diff --git a/drivers/remoteproc/pru_rproc.c b/drivers/remoteproc/pru_rproc.c index 85463f7..b47c4fd 100644 --- a/drivers/remoteproc/pru_rproc.c +++ b/drivers/remoteproc/pru_rproc.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -64,6 +65,10 @@ * @debug_regmap: regmap to PRU DEBUG IOMEM * @client_np: client device node * @intc_config: PRU INTC configuration data + * @mbox: mailbox channel handle used for vring signalling with MPU + * @client: mailbox client to request the mailbox channel + * @irq_ring: IRQ number to use for processing vring buffers + * @irq_kick: IRQ number to use to perform virtio kick * @dram0: PRUSS DRAM0 region * @dram1: PRUSS DRAM1 region * @shrdram: PRUSS SHARED RAM region @@ -90,6 +95,10 @@ struct pru_rproc { struct regmap *debug_regmap; struct device_node *client_np; struct pruss_intc_config intc_config; + struct mbox_chan *mbox; + struct mbox_client client; + int irq_vring; + int irq_kick; struct pruss_mem_region dram0; struct pruss_mem_region dram1; struct pruss_mem_region shrdram; @@ -615,6 +624,82 @@ static int pru_rproc_handle_vendor_rsc(struct rproc *rproc, return ret; } +/** + * pru_rproc_mbox_callback() - inbound mailbox message handler + * @client: mailbox client pointer used for requesting the mailbox channel + * @data: mailbox payload + * + * This handler is invoked by omap's mailbox driver whenever a mailbox + * message is received. Usually, the mailbox payload simply contains + * the index of the virtqueue that is kicked by the PRU remote processor, + * and we let remoteproc core handle it. + * + * In addition to virtqueue indices, we might also have some out-of-band + * values that indicates different events. Those values are deliberately + * very big so they don't coincide with virtqueue indices. + */ +static void pru_rproc_mbox_callback(struct mbox_client *client, void *data) +{ + struct pru_rproc *pru = container_of(client, struct pru_rproc, client); + struct device *dev = &pru->rproc->dev; + u32 msg = (u32)data; + + dev_dbg(dev, "mbox msg: 0x%x\n", msg); + + /* msg contains the index of the triggered vring */ + if (rproc_vq_interrupt(pru->rproc, msg) == IRQ_NONE) + dev_dbg(dev, "no message was found in vqid %d\n", msg); +} + +/** + * pru_rproc_vring_interrupt() - interrupt handler for processing vrings + * @irq: irq number associated with the PRU event MPU is listening on + * @data: interrupt handler data, will be a PRU rproc structure + * + * This handler is used by the PRU remoteproc driver when using PRU system + * events for processing the virtqueues. Unlike the mailbox IP, there is + * no payload associated with an interrupt, so either a unique event is + * used for each virtqueue kick, or a both virtqueues are processed on + * a single event. The latter is chosen to conserve the usable PRU system + * events. + */ +static irqreturn_t pru_rproc_vring_interrupt(int irq, void *data) +{ + struct pru_rproc *pru = data; + + dev_dbg(&pru->rproc->dev, "got vring irq\n"); + + /* process incoming buffers on both the Rx and Tx vrings */ + rproc_vq_interrupt(pru->rproc, 0); + rproc_vq_interrupt(pru->rproc, 1); + + return IRQ_HANDLED; +} + +/* kick a virtqueue */ +static void pru_rproc_kick(struct rproc *rproc, int vq_id) +{ + struct device *dev = &rproc->dev; + struct pru_rproc *pru = rproc->priv; + int ret; + + dev_dbg(dev, "kicking vqid %d on PRU%d\n", vq_id, pru->id); + + if (pru->irq_kick > 0) { + ret = pruss_intc_trigger(pru->irq_kick); + if (ret < 0) + dev_err(dev, "pruss_intc_trigger failed: %d\n", ret); + } else if (pru->mbox) { + /* + * send the index of the triggered virtqueue in the mailbox + * payload + */ + ret = mbox_send_message(pru->mbox, (void *)vq_id); + if (ret < 0) + dev_err(dev, "mbox_send_message failed: %d\n", ret); + } +} + /* start a PRU core */ static int pru_rproc_start(struct rproc *rproc) { @@ -635,10 +720,36 @@ static int pru_rproc_start(struct rproc *rproc) } } + if (!list_empty(&pru->rproc->rvdevs)) { + if (!pru->mbox && (pru->irq_vring <= 0 || pru->irq_kick <= 0)) { + dev_err(dev, "virtio vring interrupt mechanisms are not provided\n"); + ret = -EINVAL; + goto fail; + } + + if (!pru->mbox && pru->irq_vring > 0) { + ret = request_threaded_irq(pru->irq_vring, NULL, + pru_rproc_vring_interrupt, + IRQF_ONESHOT, dev_name(dev), + pru); + if (ret) { + dev_err(dev, "failed to enable vring interrupt, ret = %d\n", + ret); + goto fail; + } + } + } + val = CTRL_CTRL_EN | ((rproc->bootaddr >> 2) << 16); regmap_write(pru->ctrl_regmap, PRU_CTRL_CTRL, val); return 0; + +fail: + if (pru->dt_irqs || pru->fw_irqs) + pruss_intc_unconfigure(rproc->dev.parent, &pru->intc_config); + + return ret; } /* stop/disable a PRU core */ @@ -650,6 +761,10 @@ static int pru_rproc_stop(struct rproc *rproc) dev_dbg(dev, "stopping PRU%d\n", pru->id); regmap_update_bits(pru->ctrl_regmap, PRU_CTRL_CTRL, CTRL_CTRL_EN, 0); + if (!list_empty(&pru->rproc->rvdevs) && + !pru->mbox && pru->irq_vring > 0) + free_irq(pru->irq_vring, pru); + /* undo INTC config */ if (pru->dt_irqs || pru->fw_irqs) pruss_intc_unconfigure(rproc->dev.parent, &pru->intc_config); @@ -746,6 +861,7 @@ static void *pru_da_to_va(struct rproc *rproc, u64 da, int len, int map) static struct rproc_ops pru_rproc_ops = { .start = pru_rproc_start, .stop = pru_rproc_stop, + .kick = pru_rproc_kick, .da_to_va = pru_da_to_va, .handle_vendor_rsc = pru_rproc_handle_vendor_rsc, }; @@ -789,6 +905,7 @@ static int pru_rproc_probe(struct platform_device *pdev) struct pru_rproc *pru; const char *fw_name; struct rproc *rproc = NULL; + struct mbox_client *client; struct resource *res; int ret; void __iomem *va; @@ -924,10 +1041,51 @@ static int pru_rproc_probe(struct platform_device *pdev) platform_set_drvdata(pdev, rproc); + /* get optional vring and kick interrupts for supporting virtio rpmsg */ + pru->irq_vring = platform_get_irq_byname(pdev, "vring"); + if (pru->irq_vring <= 0) { + ret = pru->irq_vring; + if (ret == -EPROBE_DEFER) + goto free_rproc; + dev_dbg(dev, "unable to get vring interrupt, status = %d\n", + ret); + } + + pru->irq_kick = platform_get_irq_byname(pdev, "kick"); + if (pru->irq_kick <= 0) { + ret = pru->irq_kick; + if (ret == -EPROBE_DEFER) + goto free_rproc; + dev_dbg(dev, "unable to get kick interrupt, status = %d\n", + ret); + } + + /* + * get optional mailbox for virtio rpmsg signalling if vring and kick + * interrupts are not specified for OMAP architecture based SoCs + */ + if (pru->irq_vring <= 0 && pru->irq_kick <= 0 && + !of_device_is_compatible(np, "ti,k2g-pru") && + !of_device_is_compatible(np, "ti,da850-pru")) { + client = &pru->client; + client->dev = dev; + client->tx_done = NULL; + client->rx_callback = pru_rproc_mbox_callback; + client->tx_block = false; + client->knows_txdone = false; + pru->mbox = mbox_request_channel(client, 0); + if (IS_ERR(pru->mbox)) { + ret = PTR_ERR(pru->mbox); + pru->mbox = NULL; + dev_dbg(dev, "unable to get mailbox channel, status = %d\n", + ret); + } + } + ret = rproc_add(pru->rproc); if (ret) { dev_err(dev, "rproc_add failed: %d\n", ret); - goto free_rproc; + goto put_mbox; } pru_rproc_create_debug_entries(rproc); @@ -936,6 +1094,8 @@ static int pru_rproc_probe(struct platform_device *pdev) return 0; +put_mbox: + mbox_free_channel(pru->mbox); free_rproc: rproc_free(rproc); return ret; @@ -945,9 +1105,12 @@ static int pru_rproc_remove(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct rproc *rproc = platform_get_drvdata(pdev); + struct pru_rproc *pru = rproc->priv; dev_info(dev, "%s: removing rproc %s\n", __func__, rproc->name); + mbox_free_channel(pru->mbox); + rproc_del(rproc); rproc_free(rproc);