From patchwork Tue Dec 2 19:17:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 41831 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f72.google.com (mail-ee0-f72.google.com [74.125.83.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 10E2425E3D for ; Tue, 2 Dec 2014 19:17:47 +0000 (UTC) Received: by mail-ee0-f72.google.com with SMTP id e53sf8703965eek.7 for ; Tue, 02 Dec 2014 11:17:46 -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:from:to:date:message-id:in-reply-to :references:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=fy9qNU8goJ/9QDv46s78W2a7z8Up8fv4OtO2a0UB+Zc=; b=Ni8MlehidpSWxyA9C6DJ8g2/ZqzxBe17IVrZFr6onyZRCW4fawqDUKZZaGx9j6KzF7 rVIs9tLjJWEs66fbnaguU4lg+YndCApu3oc2cjOxss/fB3Vtl+05xN+vRmsVOO08uNBi dRGqJlFooxcU3jXdNJ/RasCckLrKpA0mgMu02sfpW8RI8mtIbzlGDzRk2VE34Apabf7S HXTlXX3HZzWZ5HKFzEdDUbjHzPM+x8ByoTHzMVXJ+rxgPhpdUKdLB9wLFjzo5cT8NkJT jSBLYU5HIa/Kgsoh7q8mJXU79bNXVn+9WIB8x0eLYy5fxUkYY33Nh3R6kJPuMZ/6jDPS awvw== X-Gm-Message-State: ALoCoQkEddDViUT578rVrF8/0PvE3KSIj37U8MCTNqCUNMPTejY5fEkZy+s1a3XwR88prOFL+Mo/ X-Received: by 10.180.98.165 with SMTP id ej5mr17034853wib.1.1417547866346; Tue, 02 Dec 2014 11:17:46 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.29.37 with SMTP id g5ls69271lah.102.gmail; Tue, 02 Dec 2014 11:17:46 -0800 (PST) X-Received: by 10.152.37.6 with SMTP id u6mr821094laj.74.1417547866048; Tue, 02 Dec 2014 11:17:46 -0800 (PST) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id p7si21158447lae.87.2014.12.02.11.17.45 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 02 Dec 2014 11:17:46 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by mail-la0-f44.google.com with SMTP id ge10so11303857lab.17 for ; Tue, 02 Dec 2014 11:17:45 -0800 (PST) X-Received: by 10.112.189.10 with SMTP id ge10mr741911lbc.23.1417547865921; Tue, 02 Dec 2014 11:17:45 -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 ew9csp546220lbc; Tue, 2 Dec 2014 11:17:45 -0800 (PST) X-Received: by 10.170.194.8 with SMTP id l8mr1410088yke.27.1417547864561; Tue, 02 Dec 2014 11:17:44 -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 o9si25317554qcg.16.2014.12.02.11.17.41 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 02 Dec 2014 11:17:44 -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 1XvsxA-0002xm-5u; Tue, 02 Dec 2014 19:17:40 +0000 Received: from mail-ob0-f174.google.com ([209.85.214.174]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Xvswq-0002wm-9K for lng-odp@lists.linaro.org; Tue, 02 Dec 2014 19:17:20 +0000 Received: by mail-ob0-f174.google.com with SMTP id nt9so3343971obb.19 for ; Tue, 02 Dec 2014 11:17:15 -0800 (PST) X-Received: by 10.202.46.71 with SMTP id u68mr646521oiu.20.1417547835047; Tue, 02 Dec 2014 11:17:15 -0800 (PST) Received: from localhost.localdomain (cpe-24-28-70-239.austin.res.rr.com. [24.28.70.239]) by mx.google.com with ESMTPSA id v73sm10216102oie.19.2014.12.02.11.17.14 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 02 Dec 2014 11:17:14 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Tue, 2 Dec 2014 13:17:03 -0600 Message-Id: <1417547823-16522-3-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1417547823-16522-1-git-send-email-bill.fischofer@linaro.org> References: <1417547823-16522-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv2 3/3] Add odp_buffer_pool_destroy() implementation 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: , MIME-Version: 1.0 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: bill.fischofer@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.215.44 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 Signed-off-by: Bill Fischofer --- platform/linux-generic/odp_buffer_pool.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/platform/linux-generic/odp_buffer_pool.c b/platform/linux-generic/odp_buffer_pool.c index fa72972..0004726 100644 --- a/platform/linux-generic/odp_buffer_pool.c +++ b/platform/linux-generic/odp_buffer_pool.c @@ -374,6 +374,32 @@ int odp_buffer_pool_info(odp_buffer_pool_t pool_hdl, return 0; } +int odp_buffer_pool_destroy(odp_buffer_pool_t pool_hdl) +{ + uint32_t pool_id = pool_handle_to_index(pool_hdl); + pool_entry_t *pool = get_pool_entry(pool_id); + + if (pool == NULL) + return -1; + + LOCK(&pool->s.lock); + + if (pool->s.pool_shm == ODP_SHM_INVALID || + odp_atomic_load_u32(&pool->s.bufcount) > 0 || + pool->s.flags.predefined) { + UNLOCK(&pool->s.lock); + return -1; + } + + if (!pool->s.flags.user_supplied_shm) + odp_shm_free(pool->s.pool_shm); + + pool->s.pool_shm = ODP_SHM_INVALID; + UNLOCK(&pool->s.lock); + + return 0; +} + odp_buffer_t buffer_alloc(odp_buffer_pool_t pool_hdl, size_t size) { pool_entry_t *pool = odp_pool_to_entry(pool_hdl);