From patchwork Wed Nov 19 15:07:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "yan.songming" X-Patchwork-Id: 41174 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C1BA020CBB for ; Wed, 19 Nov 2014 15:07:48 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id l15sf843642wiw.4 for ; Wed, 19 Nov 2014 07:07:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:date:from:to:references :mime-version:message-id:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list:content-type; bh=d/saJtA/FAoWUNeDHdqPMG2I+gHvlg/Qq8SS/P3haNE=; b=IRJUJqMz/6yFbB4aLtVweB/OJvuZUPn0zrnkorIhbR+tN++czI9F7jKq2s0hdPeZ/1 tnPAUt+f7/V0eEhncXTOYt7Z+lOtdlhXnVWoT3B2KQc9s8l40hf7UuVY0NGhcWdYDKB9 +UJLUSDzuTq1+M6tIu6prsun0dNSQ2LhTcFvHYgDTufXW5nPN118/yPK/3obFjGF0daI 8ZeiNmubz3lRvNl60Do/SjJt+2NyYzE6Bm0Bs0TkLpILA2ABlcU4jGWeFwdaYyCR5pTo 3wFkJUVSLyenrCNpnJyBp5pQg1wOIu54YORLXHLj88d9oJhla+kAAUUaFff+FQeWujPl ZJSg== X-Gm-Message-State: ALoCoQmjoj/2CEXJIaji5hHv+qdpQgdFwKKb+sv5aILmrrChHSEYhCp3Ok97EFejOxcWXFv+1wlt X-Received: by 10.180.85.97 with SMTP id g1mr5193579wiz.0.1416409668081; Wed, 19 Nov 2014 07:07:48 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.39 with SMTP id b7ls1205780lae.38.gmail; Wed, 19 Nov 2014 07:07:47 -0800 (PST) X-Received: by 10.112.168.39 with SMTP id zt7mr5829392lbb.72.1416409667828; Wed, 19 Nov 2014 07:07:47 -0800 (PST) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id ew1si2010692lbc.134.2014.11.19.07.07.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 19 Nov 2014 07:07:47 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by mail-lb0-f175.google.com with SMTP id n15so630971lbi.20 for ; Wed, 19 Nov 2014 07:07:47 -0800 (PST) X-Received: by 10.152.42.226 with SMTP id r2mr5938854lal.29.1416409667677; Wed, 19 Nov 2014 07:07:47 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp98791lbc; Wed, 19 Nov 2014 07:07:46 -0800 (PST) X-Received: by 10.170.36.133 with SMTP id 127mr1863407yke.109.1416409666148; Wed, 19 Nov 2014 07:07:46 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id s4si2491492qcq.11.2014.11.19.07.07.44 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 19 Nov 2014 07:07:46 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Xr6r9-0000Zr-O4; Wed, 19 Nov 2014 15:07:43 +0000 Received: from mail-pa0-f47.google.com ([209.85.220.47]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Xr6r3-0000Zm-Gb for lng-odp@lists.linaro.org; Wed, 19 Nov 2014 15:07:37 +0000 Received: by mail-pa0-f47.google.com with SMTP id kq14so410301pab.20 for ; Wed, 19 Nov 2014 07:07:32 -0800 (PST) X-Received: by 10.66.222.41 with SMTP id qj9mr46446253pac.21.1416409651846; Wed, 19 Nov 2014 07:07:31 -0800 (PST) Received: from A5DLIUBKQ4JO6O3 ([223.65.140.106]) by mx.google.com with ESMTPSA id ba7sm2041763pdb.87.2014.11.19.07.07.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Nov 2014 07:07:30 -0800 (PST) Date: Wed, 19 Nov 2014 23:07:28 +0800 From: "yan.songming@linaro.org" To: mike.holmes References: <1416405598-12262-1-git-send-email-yan.songming@linaro.org>, X-Priority: 3 X-Has-Attach: no X-Mailer: Foxmail 7, 2, 5, 140[cn] Mime-Version: 1.0 Message-ID: <201411192307264101426@linaro.org> X-Topics: patch Cc: lng-odp Subject: Re: [lng-odp] [PATCH v2] add implement for odp_shm_free X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: yan.songming@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 "return 0 on success, otherwise non-zero" May not very well. Maybe we should change to this ? @retval 0 for success @retval -1 on failure yan.songming@linaro.org From: Mike Holmes Date: 2014-11-19 22:49 To: Yan Songming CC: lng-odp Subject: Re: [lng-odp] [PATCH v2] add implement for odp_shm_free The current header file lists failure as 1 in doxygen so we need to change the description in the header file in this patch http://docs.opendataplane.org/arch/html/group__odp__shared__memory.html On 19 November 2014 08:59, Yan Songming wrote: New API implementing odp_shm_free to match the odp_shm_reserve. Signed-off-by: Yan Songming --- v2 fix the problem which Maxim found. --- platform/linux-generic/odp_shared_memory.c | 43 +++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 6 deletions(-) -- 1.8.3.1 _______________________________________________ lng-odp mailing list lng-odp@lists.linaro.org http://lists.linaro.org/mailman/listinfo/lng-odp -- Mike Holmes Linaro Sr Technical Manager LNG - ODP diff --git a/platform/linux-generic/odp_shared_memory.c b/platform/linux-generic/odp_shared_memory.c index 24a5d60..a1321bf 100644 --- a/platform/linux-generic/odp_shared_memory.c +++ b/platform/linux-generic/odp_shared_memory.c @@ -114,6 +114,43 @@ static int find_block(const char *name, uint32_t *index) return 0; } +int odp_shm_free(odp_shm_t shm) +{ + uint32_t i; + int ret; + odp_shm_block_t *shm_block; + uint64_t alloc_size; + + i = from_handle(shm); + if (odp_shm_tbl->block[i].addr == NULL) { + /* free block */ + ODP_DBG("odp_shm_free: Free block failed\n"); + return 0; + } + + odp_spinlock_lock(&odp_shm_tbl->lock); + shm_block = &odp_shm_tbl->block[i]; + + alloc_size = shm_block->size + shm_block->align; + ret = munmap(shm_block->addr, alloc_size); + if (0 != ret) { + ODP_DBG("odp_shm_free: munmap failed\n"); + odp_spinlock_unlock(&odp_shm_tbl->lock); + return -1; + } + + if (shm_block->flags & ODP_SHM_PROC) { + ret = shm_unlink(shm_block->name); + if (0 != ret) { + ODP_DBG("odp_shm_free: shm_unlink failed\n"); + odp_spinlock_unlock(&odp_shm_tbl->lock); + return -1; + } + } + memset(&odp_shm_tbl->block[i], 0, sizeof(odp_shm_block_t)); + odp_spinlock_unlock(&odp_shm_tbl->lock); + return 0; +} odp_shm_t odp_shm_reserve(const char *name, uint64_t size, uint64_t align, uint32_t flags) @@ -221,12 +258,6 @@ odp_shm_t odp_shm_reserve(const char *name, uint64_t size, uint64_t align, return block->hdl; } -int odp_shm_free(odp_shm_t shm ODP_UNUSED) -{ - ODP_UNIMPLEMENTED(); - return 0; -} - odp_shm_t odp_shm_lookup(const char *name) { uint32_t i;