Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4714506ybb; Tue, 24 Mar 2020 04:03:57 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuA6owxtI2c8VISNSYX0csVGg7pRqMJNjuewYhch1E7En8wlsKQhnNYPb8nEPO73udSKHbl X-Received: by 2002:a9d:728e:: with SMTP id t14mr22268023otj.63.1585047837618; Tue, 24 Mar 2020 04:03:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585047837; cv=none; d=google.com; s=arc-20160816; b=FEYCjGV/3Tw849pfY8dyTdXhZD+OjTnSRMkwlgdCjY92BdXtRG6HOORkLaQlIpA5MO 7OqPsIVMP+GC+Lk6dTDKiZ1QqW3WmFnKR9H9CtMhZJj9Y/I8TYcksB8FST4y2rn07eyV fKGjxZyPfI8suRfMjU0uI1u7wf8mnCNaNa88PkNBmLLeRoH0jjNSB9WMq09R9Is8MXqX ty41rrsNMGYb07SgavEKgWpzlyFu/is6u1oC2QSDkhRyeSGqlyh1TG0P9nY7IIPjWpqw oLrIBLQoSxYwHyfWtuDMO2x7h7CMIxBpKlX/YiK+4vtFpi2KhZQc35Ale+My2YuXQpna faoA== 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=vhrB3829DrdgTQY3EkaCRcbbRHL0MAwarCSWCJkRDVw=; b=FuZkQxJPfcB0+EfetH4jHkguCRJUbsvGGNG6xsqvcMWagmb2xFvUWDpGkbiRwMUgq6 ttkItIqHHlK2c2/sDV7JZ+uhbj0QAFTW1kiSSrlshG0RSgzz3Co95AiZ8trMjFyB2jA7 Fk7y0lBF4MDvv83YQFtzJCSiqLZNLgw8+GeKdmHFCKtwKudiCpwg5o6g/AcduNhh7aQ7 4DXFSeTuw+nMPfKqi9m2Y4g++mRNuijKt1Cx+W4zjREya3mX7/3dmv2fisY7qI6W23RJ PrBV9Wt3e/bLfrRBl0ImMosk3lJbtM3NGgzMZopHkkKmTtoDshQ8CEvQa/G5agC68ncq /CJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=aMDwjYBq; 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 m19si456593otp.106.2020.03.24.04.03.38; Tue, 24 Mar 2020 04:03:57 -0700 (PDT) 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=aMDwjYBq; 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 S1727549AbgCXLBq (ORCPT + 99 others); Tue, 24 Mar 2020 07:01:46 -0400 Received: from lelv0142.ext.ti.com ([198.47.23.249]:47140 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727304AbgCXLBI (ORCPT ); Tue, 24 Mar 2020 07:01:08 -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 02OB17ZJ096508; Tue, 24 Mar 2020 06:01:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1585047667; bh=vhrB3829DrdgTQY3EkaCRcbbRHL0MAwarCSWCJkRDVw=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=aMDwjYBq030LSGxoNYdZxmBbY+lk05tbK093QKRcY+U0ylKVzrLXTMkXYWg929pOL f5krdCQFqLtOr7outsNl2DCw81CpTHXNZcv5TB99v+95uaWNqcMO8vwyFJJ/C60j2X GS/RfTha0hXSjb4g+GPSF7d42FAUeO5Hj6enzPhA= Received: from DFLE110.ent.ti.com (dfle110.ent.ti.com [10.64.6.31]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 02OB17hF112239 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 24 Mar 2020 06:01:07 -0500 Received: from DFLE113.ent.ti.com (10.64.6.34) by DFLE110.ent.ti.com (10.64.6.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Tue, 24 Mar 2020 06:01:06 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE113.ent.ti.com (10.64.6.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, 24 Mar 2020 06:01:06 -0500 Received: from sokoban.bb.dnainternet.fi (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 02OB0rAp008648; Tue, 24 Mar 2020 06:01:04 -0500 From: Tero Kristo To: , , CC: , , , , Tero Kristo Subject: [PATCHv9 05/15] remoteproc/omap: Add the rproc ops .da_to_va() implementation Date: Tue, 24 Mar 2020 13:00:25 +0200 Message-ID: <20200324110035.29907-6-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200324110035.29907-1-t-kristo@ti.com> References: <20200324110035.29907-1-t-kristo@ti.com> MIME-Version: 1.0 Content-Type: text/plain 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 Reviewed-by: Andrew F. Davis Acked-by: Mathieu Poirier --- v9: * compile fix against rproc-next (fixed len parameter type for omap_rproc_da_to_va) drivers/remoteproc/omap_remoteproc.c | 40 ++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/drivers/remoteproc/omap_remoteproc.c b/drivers/remoteproc/omap_remoteproc.c index cdcc9c227b96..fecc68e6d3a8 100644 --- a/drivers/remoteproc/omap_remoteproc.c +++ b/drivers/remoteproc/omap_remoteproc.c @@ -245,10 +245,50 @@ 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. + * + * Return: translated virtual address in kernel memory space on success, + * or NULL on failure. + */ +static void *omap_rproc_da_to_va(struct rproc *rproc, u64 da, size_t 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 struct omap_rproc_mem_data ipu_mems[] = { -- 2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki