Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp794465imm; Fri, 27 Jul 2018 06:17:55 -0700 (PDT) X-Google-Smtp-Source: AAOMgpebZQjP3uFvhEqiSvDRPjN0s0AcgYq+cHtmX9ly4vPM6Q5yjMk/vQUI9iGkgav/OO+f647U X-Received: by 2002:a17:902:7891:: with SMTP id q17-v6mr6195361pll.186.1532697475473; Fri, 27 Jul 2018 06:17:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532697475; cv=none; d=google.com; s=arc-20160816; b=NiJ8SL1IRjc4ACFaizC07B7v6aW5TwepNFq85Mos8MWzKBCpeC49LuvNM9tfMIhemz s/EF0hMjGmVv9rBWRQmbJFw9x73JrAx76Xumx9j2UiG6FvSg48FQFF0MnwRn/jsDMBXb Vn2hzsrUPU9D4jgIO0uMqHoeWVc12tc45czJAH/HjqrsFcMM+0+ROyF53uqaGP01+xs/ xPzNnlQOf2ps5T5tLUQTVLuurObVhy3rS6C060xz+ypeD3YiEa1coKukAC2973kAx2Ij v40Mu9JPsToVQGA6cZMhwPRfzz8YYItE4xuqjH5l2jesyp98L1tmh6iBC+0Y5wEinBQb 5E+w== 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:arc-authentication-results; bh=NL32liJace6XLmVtTt1gqTLNcIC3JsCfnfjVXqQKTYM=; b=a+FnyssIgtDqjvNYOxyZ7Kd/fhgBIS7TjXn8F8Cfz0ZacQjjtKiIRKRNKl38KHWOiV j/kX+S4wke0KqwBxfOa5kHRbwYfqSxCIkszZJjp8SVl8eqQypx/6KgVG5R7tPg67Tz+0 hkVh56/Gk3np7T5othWVpIfLmPDvz7pus7QPPUo5k4pI1hgE6duL2OKMLdAMmMPOXm/P d5JjrNyoanvasdKOJxn+cKkFHQPF2hiIgs0VxLKLep2mww0T3zle95rn07fFvyr0+FRl Ou5OWT9zAvVsgpWXu20XDooCPdsYmUhWEC7CS/uMJtRn25I9liO4U6fPzzk7N9H1IeEH GXkw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 60-v6si3631501ple.65.2018.07.27.06.17.40; Fri, 27 Jul 2018 06:17:55 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388881AbeG0OiL (ORCPT + 99 others); Fri, 27 Jul 2018 10:38:11 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:39860 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388587AbeG0Oh0 (ORCPT ); Fri, 27 Jul 2018 10:37:26 -0400 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w6RDE4if014486; Fri, 27 Jul 2018 15:15:29 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2kg1tj8pu4-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 27 Jul 2018 15:15:29 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 054C431; Fri, 27 Jul 2018 13:15:29 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag7node2.st.com [10.75.127.20]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id DDBD5577A; Fri, 27 Jul 2018 13:15:28 +0000 (GMT) Received: from localhost (10.75.127.49) by SFHDAG7NODE2.st.com (10.75.127.20) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Fri, 27 Jul 2018 15:15:28 +0200 From: Loic Pallardy To: , CC: , , , , , Loic Pallardy Subject: [PATCH v4 11/17] remoteproc: modify rproc_handle_carveout to support pre-registered region Date: Fri, 27 Jul 2018 15:14:46 +0200 Message-ID: <1532697292-14272-12-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1532697292-14272-1-git-send-email-loic.pallardy@st.com> References: <1532697292-14272-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.49] X-ClientProxiedBy: SFHDAG5NODE2.st.com (10.75.127.14) To SFHDAG7NODE2.st.com (10.75.127.20) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-07-27_06:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In current version rproc_handle_carveout() function registers carveout for allocation. This patch extends rproc_handle_carveout() function to support pre-registered region. Match is done on region name, then requested device address and length are checked. If match found, pre-registered region is associated with resource table request. If no name match found, new carveout is registered for allocation. Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 5dd5edf..c543d04 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -840,6 +840,29 @@ static int rproc_handle_carveout(struct rproc *rproc, dev_dbg(dev, "carveout rsc: name: %s, da 0x%x, pa 0x%x, len 0x%x, flags 0x%x\n", rsc->name, rsc->da, rsc->pa, rsc->len, rsc->flags); + /* + * Check carveout rsc already part of a registered carveout, + * Search by name, then check the da and length + */ + carveout = rproc_find_carveout_by_name(rproc, rsc->name); + + if (carveout) { + if (carveout->rsc_offset != FW_RSC_ADDR_ANY) { + dev_err(dev, + "Carveout already associated to resource table\n"); + return -ENOMEM; + } + + if (rproc_check_carveout_da(rproc, carveout, rsc->da, rsc->len)) + return -ENOMEM; + + /* Update memory carveout with resource table info */ + carveout->rsc_offset = offset; + carveout->flags = rsc->flags; + + return 0; + } + /* Register carveout in in list */ carveout = rproc_mem_entry_init(dev, 0, 0, rsc->len, rsc->da, rproc_alloc_carveout, @@ -1120,8 +1143,15 @@ static int rproc_alloc_registered_carveouts(struct rproc *rproc) * In this case, the device address and the physical address * are the same. */ + + /* Use va if defined else dma to generate pa */ if (entry->va) rsc->pa = (u32)rproc_va_to_pa(entry->va); + else + rsc->pa = (u32)entry->dma; + + rsc->da = entry->da; + rsc->len = entry->len; } } -- 1.9.1