From patchwork Fri Jul 27 13:14:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 143064 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp808056ljj; Fri, 27 Jul 2018 06:16:48 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfd5Ue3I/awetRMRzGX6t+1/1XPX0EYngxpk3tZDCoOyMATNRH2K2ueTMeO0HxZ2u8vHJBF X-Received: by 2002:a17:902:780d:: with SMTP id p13-v6mr5915105pll.119.1532697408277; Fri, 27 Jul 2018 06:16:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532697408; cv=none; d=google.com; s=arc-20160816; b=y5EQEobDAN7/5cG99ry69u9rN6igxlqz4cbXECFSN+ImVlwaMQ1IF8vlUxdvURb8aN AXCFvraUTn2kBDZUnnH8wJL5RWJ+fzqZSUpNgUcyrU1+zOa/rSAIRdX6oNMAeJKZ26e3 8LllSxnvd+J2hkOv1ISBc6Qe8uZFgNR1H+75xMY7og3auIHEfoASbLg8sEbuHVpmBA4Y IhmIbJxMesBOGqAyDmBXDN4GTY31B+lzsOG69xJyxPDnNfTYSeohgObSPPzC8iBytK/A 9BUFiQ995ccawsnE1Rsf7OKXCk6VFXX8xDsfZfFVQy6CGFsIfic0qus/HSTCPlBXA2xG tJuA== 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 b25-v6si3817540pgf.545.2018.07.27.06.16.47; Fri, 27 Jul 2018 06:16:48 -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 S2388925AbeG0Oij (ORCPT + 31 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 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(-) -- 1.9.1 Acked-by: Suman Anna 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; /**