From patchwork Fri Dec 13 12:55:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 181555 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp598073ile; Fri, 13 Dec 2019 04:57:04 -0800 (PST) X-Google-Smtp-Source: APXvYqwFHY9VgYEwRFr1DXT0/wQVD4G66VRgZuqj6ubwWigu5RXK2YnMdOiO8ieXdosNRiEb7Tye X-Received: by 2002:a05:6830:2001:: with SMTP id e1mr13812707otp.97.1576241824378; Fri, 13 Dec 2019 04:57:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576241824; cv=none; d=google.com; s=arc-20160816; b=oSxFIFV79YGEHJyO9+Iyp+94EyWmxN3Qyw7k4UCs8XFoUM2kLhGFRBDyFkOwlH67ts rp7yEPOFykZoZvBt7AufwTifVJFC5aQXfXrMZ2f5qAvRxIqEVnU5fMMy7KqeJS9t1TwN 7rj13GlhfMOidifVECrtfAA53HxyLAcyIbg+dOKM1mmR/C2fs1m5k35J8surlwQr9PmU omxHj3+CnaRBFIDjcLPx743oJx88cOYgehhfwTtpJtl+3ZobWcfo059vlvfuPpA+5KWs SGlVvIuh9b1aOw1Vamx4rx3icXTwN4+ccE3E1XaK8vnElxScbQljDBKk9/x1NuZO5DDi FaPw== 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=FoynO9z6P/deyXUVpUBGISXV3a70IYkqN3HgGeVOdSY=; b=Hj+NSsEFjfEmAa77eXHQFDIlg0ir3v+BdN6NG9q2tAi+lfdk67wgWShE7SLVwOqOnr 2kTtKTtai0HlHrmWe+Tg5/VOyvm1XojEaMIK4O+akRWD5tmnqNaEycxU2MYxEKV+LEUT 0q8Z9toXYa1bdn0MJ0H4BWVjseFMpU2DafkXDWIFGCh8B6gP9s8D3MCAVfuUXUzT+stx fNrxT7+oWU4mODn5IoS9W6pdtOyD3rP8gOy1JtePRJ70lWnU4JtZitfpEpDL+M/Ba3Q6 bOCo1bguEzXQOcIYEmyaSy5x1Dypjwxru/lzIk+5zHWHpytkbWeFvPVvDY8avDD9euZU HY9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=H9wZDKZX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 v15si5863268otn.100.2019.12.13.04.57.04; Fri, 13 Dec 2019 04:57:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=H9wZDKZX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1727599AbfLMM5C (ORCPT + 27 others); Fri, 13 Dec 2019 07:57:02 -0500 Received: from lelv0142.ext.ti.com ([198.47.23.249]:48486 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726345AbfLMM4N (ORCPT ); Fri, 13 Dec 2019 07:56:13 -0500 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id xBDCuCSx068969; Fri, 13 Dec 2019 06:56:12 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1576241772; bh=FoynO9z6P/deyXUVpUBGISXV3a70IYkqN3HgGeVOdSY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=H9wZDKZXQwpV6h0y1sW1P7543qxkanGSbFOM0hJhNxDW2mc4YL4GAiC2dJvASJl0R igIayiMBn4nNrzdrFpvip+qynKNV2mRRNZcu69UNMo8huEL/tYdBJMpSp0tPfXa8EH L3pTH6jkcaP60O6MD7HtnYqueBJKz0+uI05TVFTQ= 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 xBDCuCwa008930; Fri, 13 Dec 2019 06:56:12 -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:11 -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:11 -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 xBDCtwVK127295; Fri, 13 Dec 2019 06:56:09 -0600 From: Tero Kristo To: , , CC: , , , Suman Anna , Tero Kristo Subject: [PATCHv3 05/15] remoteproc/omap: Add the rproc ops .da_to_va() implementation Date: Fri, 13 Dec 2019 14:55:27 +0200 Message-ID: <20191213125537.11509-6-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suman Anna An implementation for the rproc ops .da_to_va() has been added that provides the address translation between device addresses to kernel virtual addresses for internal RAMs present on that particular remote processor device. The implementation provides the translations based on the addresses parsed and stored during the probe. This ops gets invoked by the exported rproc_da_to_va() function and allows the remoteproc core's ELF loader to be able to load program data directly into the internal memories. Signed-off-by: Suman Anna Signed-off-by: Tero Kristo --- drivers/remoteproc/omap_remoteproc.c | 39 ++++++++++++++++++++++++++++ 1 file changed, 39 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 844703507a74..28f14e24b389 100644 --- a/drivers/remoteproc/omap_remoteproc.c +++ b/drivers/remoteproc/omap_remoteproc.c @@ -232,10 +232,49 @@ static int omap_rproc_stop(struct rproc *rproc) return 0; } +/** + * omap_rproc_da_to_va() - internal memory translation helper + * @rproc: remote processor to apply the address translation for + * @da: device address to translate + * @len: length of the memory buffer + * + * Custom function implementing the rproc .da_to_va ops to provide address + * translation (device address to kernel virtual address) for internal RAMs + * present in a DSP or IPU device). The translated addresses can be used + * either by the remoteproc core for loading, or by any rpmsg bus drivers. + * Returns the translated virtual address in kernel memory space, or NULL + * in failure. + */ +static void *omap_rproc_da_to_va(struct rproc *rproc, u64 da, int len) +{ + struct omap_rproc *oproc = rproc->priv; + int i; + u32 offset; + + if (len <= 0) + return NULL; + + if (!oproc->num_mems) + return NULL; + + for (i = 0; i < oproc->num_mems; i++) { + if (da >= oproc->mem[i].dev_addr && da + len <= + oproc->mem[i].dev_addr + oproc->mem[i].size) { + offset = da - oproc->mem[i].dev_addr; + /* __force to make sparse happy with type conversion */ + return (__force void *)(oproc->mem[i].cpu_addr + + offset); + } + } + + return NULL; +} + static const struct rproc_ops omap_rproc_ops = { .start = omap_rproc_start, .stop = omap_rproc_stop, .kick = omap_rproc_kick, + .da_to_va = omap_rproc_da_to_va, }; static const char * const ipu_mem_names[] = {