From patchwork Tue Nov 19 14:16: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: 179749 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp697134ilf; Tue, 19 Nov 2019 06:17:15 -0800 (PST) X-Google-Smtp-Source: APXvYqwbtzqFtKZSUjSXgkRNQ3vWZ6Jz29d9P6EEWNig8JrA8Cm/6YV005XVZdAyTq48CenUr/ix X-Received: by 2002:a17:906:404d:: with SMTP id y13mr36190586ejj.276.1574173035419; Tue, 19 Nov 2019 06:17:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574173035; cv=none; d=google.com; s=arc-20160816; b=RrFU8rcls89NpHfJLcX7GmZmgKXzabOcdf6qnQdJmHb+gJ/Fij318aYxIuPlsH78X8 aaX1EL9xpR+KefMKHKV0cQl2ch+aZ44ThyJai2pCw3CPG1RmlMA1XuR5czvwLEIyMEYh sgrPF1ENEuEDbFVQk589VOhJ+M2eoTahMcEzz3XHdiNpV7VW2wFLEnfF8zFdUSTPeMrm I8GadmvR9TDUcvnJ18b28GkG5AhxC7QvmQeZC+MM4VOZ36UOinR/csm4U1aJNszgak4v +C/qT1RAEDouci4l8qlMT/Xxej3Z0ksD3r8FuM3CQvCHC4bB8i0Snga79IrsTUuKrKjJ 8T8A== 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=/riSbTGFb04QZzBqTbkVcs7lENw6NXmNR+s7C5cYK1I=; b=qRYCT58XL3hbTL7xAo5Wq4GWxYpT3VsJlEutomEw1BZ7CCoHkeZCGLDTkc5azOXQ0p jkQ4Z4p8hchwFjfhoCV5pvz4TfkdKrjvaIKQleknGJpq+aO9BpRpV6YFR5CVfBOn0+iR lSotz21gzeRke8DmOhz+c5lAciuP+IEt6MUgYDsDbSMokhcEKxXKo1hGTqrBcNEAqy9t yuCc2FIZ0f/2H2xm0Jo3WzwYdR5vEYqoJiqGo3w/SdMRcdpVMdyFmz4ftP1ozvbHRGld RX0FcZ9KXGcQt/wiHxtJSd7O2rOgr3fSqNo5HiyeSmDOzo7LgTatry6gilXxLJpoFa5x b/sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=qtprrkhC; 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 ov27si13744486ejb.197.2019.11.19.06.17.15; Tue, 19 Nov 2019 06:17:15 -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=qtprrkhC; 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 S1728068AbfKSORN (ORCPT + 5 others); Tue, 19 Nov 2019 09:17:13 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:58518 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728040AbfKSORM (ORCPT ); Tue, 19 Nov 2019 09:17:12 -0500 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id xAJEHBGI117175; Tue, 19 Nov 2019 08:17:11 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1574173031; bh=/riSbTGFb04QZzBqTbkVcs7lENw6NXmNR+s7C5cYK1I=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=qtprrkhC8/zt7ANCSvodvCu90HnCNmDrBBFBCu9SxgrvainVvEpqW3KKbhHviFneD L+3UT28wGwp9UewgWgGHWQOTV+y8c0XQtsYvzLPascLwg02B7QgLrzyQdv1WsBasGU gcYqUe5EGVlaNsPiPmIh8nb2JYgDf5mKDDGFvDAU= Received: from DLEE103.ent.ti.com (dlee103.ent.ti.com [157.170.170.33]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id xAJEHBq7022649 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 19 Nov 2019 08:17:11 -0600 Received: from DLEE104.ent.ti.com (157.170.170.34) 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.1847.3; Tue, 19 Nov 2019 08:17:10 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) 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.1847.3 via Frontend Transport; Tue, 19 Nov 2019 08:17:10 -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 xAJEGvYw027070; Tue, 19 Nov 2019 08:17:08 -0600 From: Tero Kristo To: , , CC: , , , Tero Kristo Subject: [PATCHv2 05/15] remoteproc/omap: Add the rproc ops .da_to_va() implementation Date: Tue, 19 Nov 2019 16:16:35 +0200 Message-ID: <20191119141645.19777-6-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191119141645.19777-1-t-kristo@ti.com> References: <20191119141645.19777-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 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 --- v2: - minor cleanups of code, fixed kerneldoc comments 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[] = {