Received: by 10.192.165.148 with SMTP id m20csp532730imm; Wed, 9 May 2018 17:56:09 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoa4ywpu8mWVegacBREL3EiFOUNwMRGB2CnmY3R26Ez0G9n29aSfivdg6sPeEDfND1Kw6pv X-Received: by 2002:a63:7150:: with SMTP id b16-v6mr37306661pgn.326.1525913769536; Wed, 09 May 2018 17:56:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525913769; cv=none; d=google.com; s=arc-20160816; b=TSOvrpBkLLesLlEQTs7A07WbWwUtutQFWke8JnolXkXo14yvAqLBRWk8/W08D3Zk6k 7HCN/cBUeWg3AXnmksTc6NAOdipZpQjMe9BJAhD5R4JRWkyZt7as49ay9UPCvXJ5AjCo YvHA+xq08lmdqRbM4ukXmDwndKjhD/V+Kf2xcV2xamsl6tCymvq3vpSB+2LCqijU2iB3 2Fplus9uJECTyFFdG8IOqm2NPdKBnMi2wi+Se8QEVk63fN3mk+VTvTJU4vy+KTa59hNv 4G8AKnM6sjNNjQMW2C4SfADfU/UpCkg6ZCWN7sE0TvoE97xHtzESn1GLF1q3e31FEe+s G1uw== 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=EwUEpW+f2E2oEYXDbnkUhWYiY+1D+Oq0sNq+hbR9gYI=; b=z34oexS0mbNA+MWhYDx2/pznHqJW5zxHQSIeGDMHM3+X30ovOt5JImR6xIFwosummb IX5He/QGqWQKFP+aqQHcf7pCbF8KUiMke3q4bOv89437GWRF7UK27ZS8CjT32MVxux+N tyh7gwhRqCYR4IkW2Futprg/sf4XTECiQqOLI5AghEA39eFDq9774HjswafoZU6JfBKB 1LCU7+Vsyk0zoIfHpnYDd0gHmHBPGTd+o18tZ5aBdlIoUcan0rJMjBimVuy/7J2SfRnt MLB4xqa4gsebNkIzdbzXCDPuUhP5JygvFyazZGU+sF/+slE+/HIq/u8ttDgUPP24KR39 z9sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U1ZgBBC3; 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 w12-v6si27128806pld.367.2018.05.09.17.55.54; Wed, 09 May 2018 17:56:09 -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=U1ZgBBC3; 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 S966068AbeEJAyC (ORCPT + 99 others); Wed, 9 May 2018 20:54:02 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:43606 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965997AbeEJAyB (ORCPT ); Wed, 9 May 2018 20:54:01 -0400 Received: by mail-pf0-f194.google.com with SMTP id j20-v6so202691pff.10 for ; Wed, 09 May 2018 17:54:01 -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=EwUEpW+f2E2oEYXDbnkUhWYiY+1D+Oq0sNq+hbR9gYI=; b=U1ZgBBC39AGx+YHh5iKjNEsoFCYqWRJq7VeH75L/zcU8h5dhQ9+u8DYwWU9RU7XR3F /qXF+FSblCpbcgKfewEuvolE1R75DqMkOpXjVDM2CyDPL8X/kaxkEmgoQY3uJE47suS0 mmwIFxVKMuwpg+F4iGi5CPhd2rI2BGwszUJ8w= 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=EwUEpW+f2E2oEYXDbnkUhWYiY+1D+Oq0sNq+hbR9gYI=; b=drOf6DMG8ZWJftWs+RqbOndTl3BJy15+76a5TJIFI+QUcbI3N8x5mvf7AliZxq01eK QABl/gF3vC64nPYTYPl7HCO/csG+KsJJnNyNvfPWFLFzc4nYj2w9uB6d0NiahWkCzu/E 30BZ1qqapUu1cJc4Y9VG4Yc1ctuvghiEhomKka/mx7Sf97RxSB+54rGY9vDXT3xZZyej lbvG3Wi19v8g4h7WKufHbMxKqhl5OpbOW8DFkJnSiO/Z32bcMop1lCLvafgKW0XZlXbd oXk7ZXpMDUpZgI2LzRQ31g1fjRi3o1WNVLXUD6MFfGPnxXAzY8sjnmWJUCIaCedm988D qLzw== X-Gm-Message-State: ALQs6tAp+xXObnGOtDQ219S454V9UGytDMaGx7BoIU6Gof1I/IJTkckx v+YUXiJ1BfyOErnbCoY07rzbzA== X-Received: by 2002:a63:41c5:: with SMTP id o188-v6mr37342439pga.280.1525913640497; Wed, 09 May 2018 17:54:00 -0700 (PDT) Received: from builder (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id 5sm49453699pfx.140.2018.05.09.17.53.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 May 2018 17:53:59 -0700 (PDT) Date: Wed, 9 May 2018 17:53:58 -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 03/13] remoteproc: add release ops in rproc_mem_entry struct Message-ID: <20180510005358.GG29093@builder> References: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> <1519921440-21356-4-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-4-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: > Memory entry could be allocated in different ways (ioremap, > dma_alloc_coherent, internal RAM allocator...). > This patch introduces a release ops in rproc_mem_entry structure > to associate dedicated release mechanism to each memory entry descriptor > in order to keep remoteproc core generic. > > Signed-off-by: Loic Pallardy Acked-by: Bjorn Andersson Regards, Bjorn > --- > drivers/remoteproc/remoteproc_core.c | 23 +++++++++++++++++++++-- > include/linux/remoteproc.h | 5 ++++- > 2 files changed, 25 insertions(+), 3 deletions(-) > > diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c > index eb1b779..5f11536 100644 > --- a/drivers/remoteproc/remoteproc_core.c > +++ b/drivers/remoteproc/remoteproc_core.c > @@ -597,6 +597,24 @@ static int rproc_handle_devmem(struct rproc *rproc, struct fw_rsc_devmem *rsc, > } > > /** > + * rproc_release_carveout() - release acquired carveout > + * @rproc: rproc handle > + * @mem: the memory entry to release > + * > + * This function releases specified memory entry @mem allocated via > + * dma_alloc_coherent() function by @rproc. > + */ > +static int rproc_release_carveout(struct rproc *rproc, > + struct rproc_mem_entry *mem) > +{ > + struct device *dev = &rproc->dev; > + > + /* clean up carveout allocations */ > + dma_free_coherent(dev->parent, mem->len, mem->va, mem->dma); > + return 0; > +} > + > +/** > * rproc_handle_carveout() - handle phys contig memory allocation requests > * @rproc: rproc handle > * @rsc: the resource entry > @@ -730,6 +748,7 @@ static int rproc_handle_carveout(struct rproc *rproc, > carveout->len = rsc->len; > carveout->dma = dma; > carveout->da = rsc->da; > + carveout->release = rproc_release_carveout; > > list_add_tail(&carveout->node, &rproc->carveouts); > > @@ -863,8 +882,8 @@ static void rproc_resource_cleanup(struct rproc *rproc) > > /* clean up carveout allocations */ > list_for_each_entry_safe(entry, tmp, &rproc->carveouts, node) { > - dma_free_coherent(dev->parent, entry->len, entry->va, > - entry->dma); > + if (entry->release) > + entry->release(rproc, entry); > list_del(&entry->node); > kfree(entry); > } > diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h > index 728d421..dedc138 100644 > --- a/include/linux/remoteproc.h > +++ b/include/linux/remoteproc.h > @@ -305,12 +305,15 @@ struct fw_rsc_vdev { > struct fw_rsc_vdev_vring vring[0]; > } __packed; > > +struct rproc; > + > /** > * struct rproc_mem_entry - memory entry descriptor > * @va: virtual address > * @dma: dma address > * @len: length, in bytes > * @da: device address > + * @release: release associated memory > * @priv: associated data > * @node: list node > */ > @@ -321,9 +324,9 @@ struct rproc_mem_entry { > u32 da; > void *priv; > struct list_head node; > + int (*release)(struct rproc *rproc, struct rproc_mem_entry *mem); > }; > > -struct rproc; > struct firmware; > > /** > -- > 1.9.1 >