Received: by 10.192.165.148 with SMTP id m20csp524367imm; Wed, 9 May 2018 17:43:51 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp/CNYcqG2ebZASopcX2e0oo6YasUSRhocJt11eODmG76mL6wNQNL+a+NN6fKDGcj0Xt68q X-Received: by 2002:a17:902:be0e:: with SMTP id r14-v6mr15317471pls.158.1525913031379; Wed, 09 May 2018 17:43:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525913031; cv=none; d=google.com; s=arc-20160816; b=yE4UoipoPpsn2YiyHZQmnHkJyQS/Rv8El+vtFBBgj2kiw0mpMM5hIKzxfC9qsS4tgk upIcu7hzB7hylarXJaLEWfSfc70VwaAKs6ew/HOM+O9u5SRahaZdIXa+0gKQF0ljXABs WrRJlCElI1uDKH6kIq/pp9ZN0rnSsWkmCjYayiydX28C+KhUBfLQt9MfxKWAIiTRxhEt y5I2B25UNG9tHDx84QH/c6eA1k4JhMrkFR6sJF7+Dk6IL7H7CpDOcHkzpy1iOGyrsuLZ 9y+cuuyAxceXGOFAMPl5nqHYpRO9sjcHNyojeEy4rosE+5/6DYizcKUfzHIll4okO+BC eMkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=kFWZvn0gyNp1cY35fb0n60BxBu22MOFmn793DIubKNA=; b=Z/s4TOFZeNlQGiGIqT09l5nhTXSJFIVhxF6qRG+D2t0Pvi0yNg2qnz4HH7eROtkgKX hnZc/4sV+WXnU1qHFdqPx1rbFga+5yguLIWDPqMMtq3ydFgzCg6QMlmh1VHYFI9CRHJQ VnnCPvXYcEE194PQar1tJzlV4yhMYtjrWBSO/B0u1eWzKyqRzOAkKpFpYs4dSxquKurs rL5GS9pdkOFDn39jLQs81TWpTZt8PEpmrj42aQ4RvFhWT9jQSRjj+mV9EhHpM2CyPTCY Hpjmino1BMSqgVytCr9aLpP0DvjueWHPHATziI1EyLfUq1ngPOCpJ/BwDc/GRrI3YVGG +hqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YrXKoWSg; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g8-v6si29738236pli.75.2018.05.09.17.43.37; Wed, 09 May 2018 17:43:51 -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=@linaro.org header.s=google header.b=YrXKoWSg; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966018AbeEJAmt (ORCPT + 99 others); Wed, 9 May 2018 20:42:49 -0400 Received: from mail-pf0-f178.google.com ([209.85.192.178]:38049 "EHLO mail-pf0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934395AbeEJAmr (ORCPT ); Wed, 9 May 2018 20:42:47 -0400 Received: by mail-pf0-f178.google.com with SMTP id o76-v6so198111pfi.5 for ; Wed, 09 May 2018 17:42:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=kFWZvn0gyNp1cY35fb0n60BxBu22MOFmn793DIubKNA=; b=YrXKoWSgc72elvmgj654egM+Qm4VbuPqRymNgjt+M9slhGU2BwRXxObqa3XSCCB6Fg WH7uq4IOlpvVLVtFZILdYmFgtc5JKmM+I1hc2Msj+gh5tnOtEcC6lUpNcvXt8mMy5qhT n4wj45MIfMqp2AtC40CgY1bNw3+QLg5GwJE1A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=kFWZvn0gyNp1cY35fb0n60BxBu22MOFmn793DIubKNA=; b=Q0mIMN7RfABFMBEdntCqq6uLFkvfpUVYA/lnig064M4BJ3+gYx5QGO1ouRdJeLozL+ ZRA7gybk+J2h7jkIc9/SFZxlVCzL+wfsDL4Z08F9lKfSOXLtbkdE/FUckrdjbIHA1bFR y9Uy4IYbfE6NCbqFpsA4gMgLTGlpd76d095jn6IDtkWz/q0+3tp+M/0FpOiwNnw1bGBh tolhQi6Bng7b394bY6z19tc+S749/KRr8OVixtZUnO2YSHtH5O4eZfWpu9OEeHXNhxmO m3gH51CiSjG2jqgDNrQx6XW4QN29/7ByDsUUTeSz9JdMNKBfohDmsrf1XS5ziYB/SIhA ZRww== X-Gm-Message-State: ALQs6tDhB8gz8D9qh4AdQqlTGTKJdaUTyxTOTS5nlooSoIiDyWN/QeZz XVhjEYXzj2wu20Fd9rdm4CzzIw== X-Received: by 10.98.160.68 with SMTP id r65mr44598819pfe.235.1525912966956; Wed, 09 May 2018 17:42:46 -0700 (PDT) Received: from builder (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id f18-v6sm31853081pgn.60.2018.05.09.17.42.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 May 2018 17:42:46 -0700 (PDT) Date: Wed, 9 May 2018 17:42:44 -0700 From: Bjorn Andersson To: Loic Pallardy Cc: ohad@wizery.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, arnaud.pouliquen@st.com, benjamin.gaignard@linaro.org Subject: Re: [PATCH v3 09/13] remoteproc: modify rproc_handle_carveout to support pre-registered region Message-ID: <20180510004244.GE29093@builder> References: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> <1519921440-21356-10-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1519921440-21356-10-git-send-email-loic.pallardy@st.com> User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 01 Mar 08:23 PST 2018, Loic Pallardy wrote: > In current version rproc_handle_carveout function support only dynamic > region 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 no name match found, original allocation is used. > > Signed-off-by: Loic Pallardy > --- > drivers/remoteproc/remoteproc_core.c | 49 +++++++++++++++++++++++++++++++++++- > 1 file changed, 48 insertions(+), 1 deletion(-) > > diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c > index 0ebbc4f..49b28a0 100644 > --- a/drivers/remoteproc/remoteproc_core.c > +++ b/drivers/remoteproc/remoteproc_core.c > @@ -679,7 +679,7 @@ static int rproc_handle_carveout(struct rproc *rproc, > struct fw_rsc_carveout *rsc, > int offset, int avail) > { > - struct rproc_mem_entry *carveout, *mapping = NULL; > + struct rproc_mem_entry *carveout, *mapping = NULL, *mem; > struct device *dev = &rproc->dev; > dma_addr_t dma; > void *va; > @@ -699,6 +699,51 @@ 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 */ > + mem = rproc_find_carveout_by_name(rproc, rsc->name); > + if (mem) { I don't fancy the concept of "check if there is another registered carveout and if so update this carveouts data based on that one and then skip the bottom half of this function but keep them both on the carveouts list". It's unfortunately not very easy to follow and it doesn't allow us to reuse the carveout-handler for allocations in remoteprocs without a resource table. How about splitting the handling of the resource table in two parts; one that creates or updates a carveout on the carvouts list and a second part that runs through all carveouts and "allocate" (similar to your specific release function) them. The first part of this function would then attempt to find a carveout entry matching the one we're trying to "handle"; * if one is found we check if it's compatible (as you do here), update a rsc_offset (as we do with vrings) and return. * if no match is found we create a new rproc_mem_entry, fill it out based on the fw_rsc_carveout information and stash it at the end of the carveouts list. We do the same in the other resource handlers (just allocate entries onto the lists). As that is done the second step is to loop over all carveouts, devmem, trace and vdev resources and actually "allocate" the resources, by calling a "alloc" function pointer next to your proposed release one. For memremap() memory this could be as simple as filling out the resource table at the associated rsc_offset or simply doing the memremap(). The default alloc (filled out in step 1, if not already specified) would be what's today found in rproc_handle_carveout(). This allows carveout resources not specified in the resource table to be allocated as well. Which comes in handy for the handling of vdev resources: In rproc_parse_vdev() we do a similar operation to the parser of a fw_rsc_carveout and try to find an existing carveout by name and if not create a new one on the list. As the actual allocation of carveouts is done before the "allocation" of vrings there will be an allocated carveout ready when we hit rproc_alloc_vring() - and we don't care if it came from dma_alloc_coherent() or a driver defined region. Does this sound reasonable? Regards, Bjorn