From patchwork Thu Mar 1 16:23:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 130333 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp3007971edc; Thu, 1 Mar 2018 08:27:51 -0800 (PST) X-Google-Smtp-Source: AG47ELvljbtu6pZ/ivvSv1WuB4UBQWgCqTgIjaaHa39NJzcY2M3U3hsinHr6qgjIxB9Oh+hea1Zm X-Received: by 10.101.93.71 with SMTP id e7mr2032505pgt.248.1519921671450; Thu, 01 Mar 2018 08:27:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519921671; cv=none; d=google.com; s=arc-20160816; b=raFpOSvH3FfunV/EBNbvyNaQ0If8bsck920QhjqS3L+S/lq6Ms9jc5qbCQ4VB3rdBI fly+zfwZOlrhvPxFeKuoBFor3vo5k8GsnfVVGYeYW3rdXJvqDrJcDWL2a8uppYagnPs3 znQ96GeCFsEZJ1uSN0VezwKdSo/J5jXeDEE59c08I1b8tPK5tAIPY/54nGjnEwriJUgJ 7HXGgXG3W3vG78qyab/qA6tZblcJqfG4EEvTSiPahS/1amJ6NHikqVeIkZa9xMO+0ftb iad2gnUL2pUTQaO1m9rNn7EJPPFB+gyzNhfuc42t+kij/UmxVsOQIniCqWcQmhWVJzDV k3wQ== 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 q4-v6si3267529plb.29.2018.03.01.08.27.51; Thu, 01 Mar 2018 08:27:51 -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 S1033150AbeCAQ1r (ORCPT + 28 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 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(-) -- 1.9.1 Acked-by: Bjorn Andersson 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; /**