Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp794825imm; Fri, 27 Jul 2018 06:18:20 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc5IgcU2MiS2ppPyMsHHwnXz4Hg+8WaFVmp/adfp8T5awI8covc6KFTWl8ejNlCD/CUh3hg X-Received: by 2002:a65:450a:: with SMTP id n10-v6mr5975119pgq.392.1532697500336; Fri, 27 Jul 2018 06:18:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532697500; cv=none; d=google.com; s=arc-20160816; b=iCtoA5++24njsqn0o71Ww+0FwZ8q0VP1ZFFqoRvgbvdQIO54RhjBM9TTqhTAIXTIXz jV7vLbpTqOUjsyD3eWwTdvuEmiPY9FAiSZW7U9PKez4O31k0YQf2wk902kYcsvOgiDWo kmJc8tAiJ88yn1Jir84mJmFRHS7ZZOYNc7QoFeXXYa5iLkJ0rDgGzoQyFL5uHbeKiUdV tMd5AN/t5IaTUKo2QJaBrp2DiFAs8ChpvvZxDaMeSlzHko+5B51btqs5Gb1yCEZobvQp 4HuEZfAKCavVkrnIUGnzekLN6Dkru7K0/WmUYZEr2ybGFJ3Gyr1rHTiMbDRxzabCGFjR MgiQ== 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=NNokiySKr4QlH/hYeXNKT4XxMmXIooCouRBqOmtPx5o=; b=LD5PLAcU1Q7CC6ju15AswFygoc3zyK77grqmc4nI07ZIwwTvn3Vue1tdYHkK1b1GLd 1vVb4Aqkvmh+Z/PyhLawNnmmhjUIMzyrQF1u7rhjStwDXCR76GSaUOMIWgy1PsnLkDKv UIzKsYfPJeE5kgSK0MgVkpIMj9BixhpEZeCLkFODpuHZgJ4dRg+5r52w/FUYXdh8nSfX 8NakRWaiTvdA/k5PN58Hish6XN0oAjWmFZfSWUYP882/4YXcL9mPGMMhl4Wz2vvD/wMy xorfWcXjKDk4CaeE8hBgCteJvnqMAqHtWyj9nRRYnxW9d4zIXhmLkIX+YzKU0IG922E4 huVg== 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 bi1-v6si3378887plb.399.2018.07.27.06.18.05; Fri, 27 Jul 2018 06:18:20 -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 S2388920AbeG0Oij (ORCPT + 99 others); Fri, 27 Jul 2018 10:38:39 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:31524 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732452AbeG0OhU (ORCPT ); Fri, 27 Jul 2018 10:37:20 -0400 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 w6RDEOMl020459; Fri, 27 Jul 2018 15:15:22 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2kg25fgjtj-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 27 Jul 2018 15:15:22 +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 6DCCA3D; Fri, 27 Jul 2018 13:15:21 +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 49C0A577A; Fri, 27 Jul 2018 13:15:21 +0000 (GMT) Received: from localhost (10.75.127.51) by SFHDAG7NODE2.st.com (10.75.127.20) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Fri, 27 Jul 2018 15:15:20 +0200 From: Loic Pallardy To: , CC: , , , , , Loic Pallardy Subject: [PATCH v4 03/17] remoteproc: add release ops in rproc_mem_entry struct Date: Fri, 27 Jul 2018 15:14:38 +0200 Message-ID: <1532697292-14272-4-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.51] X-ClientProxiedBy: SFHDAG3NODE2.st.com (10.75.127.8) 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 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 --- 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 8e5fe1e..24fe11f 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -600,6 +600,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 @@ -733,6 +751,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); @@ -920,8 +939,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 e3c5d85..bef2e83 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