Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp3943549ima; Tue, 23 Oct 2018 13:59:34 -0700 (PDT) X-Google-Smtp-Source: ACcGV60v+3TicAK21fNHFgfz1AhQfiQLkUTKrPsONRe0haM1vB1ykAhuWo73Vv+rLkT7fpGkliHY X-Received: by 2002:a62:583:: with SMTP id 125-v6mr38771906pff.186.1540328374295; Tue, 23 Oct 2018 13:59:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540328374; cv=none; d=google.com; s=arc-20160816; b=sBkSjb5yUatuVI2US3dmRcQCML4CTH/hkqglH6CX8BlMOW9eQU+PKPDv1zisHI1k7e msKzVCrEaYaTqx8WQREdY5GqLfUx0NaFmGV1Xa7V0qEf3+YUSTbOgr2ClgPMiWnmOBoq /gtuhSwmblHl55235MKr+f4mOihkPGxXoDrtn6NKWfrx8JTgeY1MYL3S3NA4mq1V8oTs Ife4T0ldo8uOjT8uGn+tcunFcR5gAOW80maUzhrAuCWmNCy2UcGgGsgkfhPDqWccR9Kh mqO6JghezEyCSKjJq7XSOwVxSWXs2szyUtHi1KauxuFAvj67JF8gpA9NEsEi2XqPaRP9 uB7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject; bh=PBofpBl07a2Y+yOEnN9JJW3HLSEOC4SiUe1KEpINIQs=; b=OA064xmn2gssnOEIv9vS/mlPDa86oFBCq60DBNAjRocfy5WJqZ0P6PcD96Kp9Z9NYZ KwsFUBQef2g4XfMEIUUgUmSeqhIiq6iavm7IWnDMqUVg4iD6K2KYQU05srs2bRAgbJiP 3O7ZP5F9RqK1CzCvZO2ksC1mQqRMFFF2/M0cHN5NM0yFilStqL8rCd/1ny+rtJPuYRhR Bhf/lEXpym8VknuhpXktC1/ZOZ9WFDbVVute90JEWxNVppqPFsjMFgCK5bpjQgJ4p9gm Vl38XXJprdSYqq08PjLv5BUpLJgUmhaIgiauNak5hwg3LXbzXDm87WZNhocAy5pdbITg lOSQ== 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; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d16-v6si2436187pgd.555.2018.10.23.13.59.11; Tue, 23 Oct 2018 13:59:34 -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; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727685AbeJXFNl (ORCPT + 99 others); Wed, 24 Oct 2018 01:13:41 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:35360 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725266AbeJXFNl (ORCPT ); Wed, 24 Oct 2018 01:13:41 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id w9NKmZFE118050; Tue, 23 Oct 2018 15:48:35 -0500 Received: from DFLE103.ent.ti.com (dfle103.ent.ti.com [10.64.6.24]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id w9NKmZfQ121162 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 23 Oct 2018 15:48:35 -0500 Received: from DFLE112.ent.ti.com (10.64.6.33) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Tue, 23 Oct 2018 15:48:34 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Tue, 23 Oct 2018 15:48:34 -0500 Received: from [128.247.58.153] (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id w9NKmYaf008358; Tue, 23 Oct 2018 15:48:34 -0500 Subject: Re: [PATCH v4 03/17] remoteproc: add release ops in rproc_mem_entry struct From: Suman Anna To: Loic Pallardy , , CC: , , , References: <1532697292-14272-1-git-send-email-loic.pallardy@st.com> <1532697292-14272-4-git-send-email-loic.pallardy@st.com> <90b2b81b-a3e1-fcfc-2a14-64050637d440@ti.com> Message-ID: Date: Tue, 23 Oct 2018 15:48:34 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <90b2b81b-a3e1-fcfc-2a14-64050637d440@ti.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/23/18 11:53 AM, Suman Anna wrote: > On 7/27/18 8:14 AM, 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 > > Acked-by: Suman Anna > >> --- >> 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 Missed this earlier, move this line after the @node. regards Suman >> * @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; >> >> /** >> >