From patchwork Sat Mar 14 00:43:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suman Anna X-Patchwork-Id: 11438155 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8EB6D6CA for ; Sat, 14 Mar 2020 00:43:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6F6B62074A for ; Sat, 14 Mar 2020 00:43:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="UQw0O3pb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727771AbgCNAnk (ORCPT ); Fri, 13 Mar 2020 20:43:40 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:45114 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727695AbgCNAnk (ORCPT ); Fri, 13 Mar 2020 20:43:40 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 02E0hcbl090466; Fri, 13 Mar 2020 19:43:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1584146618; bh=pPGfl1/MfmLCax7BhN6s6oSzE9jBgXIiLPf5nVaagEI=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=UQw0O3pboRXiJCKg5Sg/S7ehhpupRltTIvHm9kn1yNzGpGUwNC6vQTzQfgCht4u7J oiHk2/dUjCZWAGcNOuHfMwCdJdg4rrlzP8thZCncGNrjcOo0ijO3JriLb0AlgTzHLE gwr9lMMAMA4D/iZmmIJ2cZq7H3cbo6LTvi5B2Abw= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 02E0hc6Q055650 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 13 Mar 2020 19:43:38 -0500 Received: from DFLE106.ent.ti.com (10.64.6.27) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Fri, 13 Mar 2020 19:43:38 -0500 Received: from localhost.localdomain (10.64.41.19) by DFLE106.ent.ti.com (10.64.6.27) 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 Mar 2020 19:43:38 -0500 Received: from lelv0597.itg.ti.com (lelv0597.itg.ti.com [10.181.64.32]) by localhost.localdomain (8.15.2/8.15.2) with ESMTP id 02E0hcSQ123457; Fri, 13 Mar 2020 19:43:38 -0500 Received: from localhost (irmo.dhcp.ti.com [128.247.81.254]) by lelv0597.itg.ti.com (8.14.7/8.14.7) with ESMTP id 02E0hcwQ116067; Fri, 13 Mar 2020 19:43:38 -0500 From: Suman Anna To: Bjorn Andersson , Ohad Ben-Cohen , CC: , Mathieu Poirier , Suman Anna , "Andrew F. Davis" , Tero Kristo Subject: [PATCHv8 RESEND 05/15] remoteproc/omap: Add the rproc ops .da_to_va() implementation Date: Fri, 13 Mar 2020 19:43:37 -0500 Message-ID: <20200314004337.26556-1-s-anna@ti.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200313081718.30612-6-t-kristo@ti.com> References: <20200313081718.30612-6-t-kristo@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org 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 --- v8-Resend: Updated to fix compilation issues against rproc-next 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..6091666697ed 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[] = {