Received: by 10.223.185.116 with SMTP id b49csp7631561wrg; Thu, 1 Mar 2018 08:30:30 -0800 (PST) X-Google-Smtp-Source: AG47ELt5J+VvAVvO25QCTsjnPK43DTuPKJpIsD3wXaRylY88S/0oRcWtXLaOhYYh+jkpSrEQ4ncN X-Received: by 10.98.19.21 with SMTP id b21mr2509064pfj.236.1519921829968; Thu, 01 Mar 2018 08:30:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519921829; cv=none; d=google.com; s=arc-20160816; b=XBBRTi2EV4TIzs4xJoPoc0atl7YjucMhxaJxGWBGq/1gKJAPJnMSOmUQr8zXzx0Xf/ 372KQHL8wr4XltNAbjkmPUYM6yHb0wsfzh+PpMl++fhwLjUmNFvhTkZs06LHo25jbHkX r4TiM1ZRpJSnqX3iF3Y1Kz3qGYaYLxxgm1bkKImAv13JpFfq5uUHq10x+FueP+BC1W2I XbCecSeaxvYi/L8ZhSuUR48q+ch8/B9M2g5YFhyobOcvxPNXVb9SA/zgq7znGABp0UKs CK7h5BzNDo8YUKj1wydaRP1oa6HA7kFddhoT3dJzmIXbZzmk78pQl6mDONwNknI+wcbG +icA== 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=yo6MsyMPlyWPIajVQOw1q4Ed083B8RrWZfE1M7Ithk8=; b=nQIqFe+YMbfy32srISkv/E3QQwg6zBdQh/2kzqyXDDywlIkTcQV7HR0URbXcp2zMhW 2o9UbjuirVmdNGok7QY2u/8yyx+Vtmyz1l+h+NRS+w+9hCTwHMCz/4V6gYc5P2LILlp1 Bhqyyy0M6Fm6jxHSoGTlVX4rwjU7bQIaZwYkOVvk4uDVqyG6DNY9dj/mAPMPtsgM56QV 6F7+giDTqI+Z6rNX3mAoCoBLe2GB3xwH/CyG8V1LOzX7MTs21CKcWoNm2HJbWQLYt1dO ZRsZhluituPqKQaJstm4eX94gyPvR/zOgWtF4krf+CnJWcdvtmaGFQSN9IeMbr0klyEU DG5A== 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 g24si3240949pfe.107.2018.03.01.08.30.15; Thu, 01 Mar 2018 08:30:29 -0800 (PST) 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 S1033147AbeCAQ1r (ORCPT + 99 others); Thu, 1 Mar 2018 11:27:47 -0500 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:19567 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032933AbeCAQYO (ORCPT ); Thu, 1 Mar 2018 11:24:14 -0500 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w21GIdOJ028249; Thu, 1 Mar 2018 17:24:13 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2gbwb1dpjn-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 01 Mar 2018 17:24:13 +0100 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 B7B2038; Thu, 1 Mar 2018 16:24:12 +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 89CBA51FD; Thu, 1 Mar 2018 16:24:12 +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; Thu, 1 Mar 2018 17:24:11 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v3 03/13] remoteproc: add release ops in rproc_mem_entry struct Date: Thu, 1 Mar 2018 17:23:50 +0100 Message-ID: <1519921440-21356-4-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1519921440-21356-1-git-send-email-loic.pallardy@st.com> References: <1519921440-21356-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: SFHDAG8NODE3.st.com (10.75.127.24) To SFHDAG7NODE2.st.com (10.75.127.20) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-03-01_08:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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