From patchwork Thu Dec 18 16:40:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taras Kondratiuk X-Patchwork-Id: 42465 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f70.google.com (mail-ee0-f70.google.com [74.125.83.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 060DE26C6B for ; Thu, 18 Dec 2014 16:41:11 +0000 (UTC) Received: by mail-ee0-f70.google.com with SMTP id b57sf1163047eek.1 for ; Thu, 18 Dec 2014 08:41:09 -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: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=nUYfLNc/N+MZMZFhVk3Po1sxQG/8UEFZoLQ9vJjOMzo=; b=Zj0+xXo/bZwhxVVaYWMYRNoBGxKUtlLzhLIFHjZDuDPla6euT0sHEscyk6MmaLJs47 V64Ddbk0Hkbo13UqyGNvDWWrXl+bIH8l7dIro8PRifiFdSnlsL4FWnHl5J+ATtn/cTMr Iz+YaHZYmya8FOXZVvANvrGjRH1luauaKKwExcOfxk3jx668JRc2dqtrxgJcRtr+8l52 9fCRx17wWS+XxuwNZdofrSKif8ppjY35viGo+jC96GOFmWakLIzN3Xd8mfgpkYPNt5Lm T7DWo8WBk94cuZVoaNDfzsZH006LzDAjfJmr/F4PQA9oEeX0dSeokX1alPDT+7LrSgNV QE2w== X-Gm-Message-State: ALoCoQmmd17BbC7UXlBT6GU86VKv/Zoh58ozGutnZ2FlOlljDxSQtKPKegM/f/7Tt3eAB8tacbU6 X-Received: by 10.152.37.193 with SMTP id a1mr480803lak.3.1418920869868; Thu, 18 Dec 2014 08:41:09 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.204.104 with SMTP id kx8ls1185848lac.82.gmail; Thu, 18 Dec 2014 08:41:09 -0800 (PST) X-Received: by 10.112.150.102 with SMTP id uh6mr3303175lbb.50.1418920869641; Thu, 18 Dec 2014 08:41:09 -0800 (PST) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id lc1si7396765lab.57.2014.12.18.08.41.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 18 Dec 2014 08:41:09 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by mail-lb0-f179.google.com with SMTP id z11so1254032lbi.38 for ; Thu, 18 Dec 2014 08:41:09 -0800 (PST) X-Received: by 10.112.131.1 with SMTP id oi1mr3222143lbb.2.1418920869300; Thu, 18 Dec 2014 08:41:09 -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.142.69 with SMTP id ru5csp1764247lbb; Thu, 18 Dec 2014 08:41:08 -0800 (PST) X-Received: by 10.170.86.65 with SMTP id d62mr2976142yka.52.1418920867918; Thu, 18 Dec 2014 08:41:07 -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 z2si8771998qad.91.2014.12.18.08.41.06 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 18 Dec 2014 08:41:07 -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 1Y1e8O-0008PE-Mu; Thu, 18 Dec 2014 16:41:04 +0000 Received: from mail-lb0-f182.google.com ([209.85.217.182]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Y1e8H-0008O7-SS for lng-odp@lists.linaro.org; Thu, 18 Dec 2014 16:40:58 +0000 Received: by mail-lb0-f182.google.com with SMTP id f15so1417926lbj.13 for ; Thu, 18 Dec 2014 08:40:52 -0800 (PST) X-Received: by 10.152.22.67 with SMTP id b3mr3275083laf.82.1418920851901; Thu, 18 Dec 2014 08:40:51 -0800 (PST) Received: from uglx0153363.synapse.com ([195.238.92.128]) by mx.google.com with ESMTPSA id h5sm1916904lbj.8.2014.12.18.08.40.50 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Dec 2014 08:40:51 -0800 (PST) From: Taras Kondratiuk To: lng-odp@lists.linaro.org Date: Thu, 18 Dec 2014 18:40:38 +0200 Message-Id: <1418920838-17488-1-git-send-email-taras.kondratiuk@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Subject: [lng-odp] [PATCH] linux-generic: buffer: add buffer pool termination 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: taras.kondratiuk@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.179 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: Taras Kondratiuk --- platform/linux-generic/include/odp_internal.h | 2 ++ platform/linux-generic/odp_buffer_pool.c | 37 +++++++++++++++++++++++++-- platform/linux-generic/odp_init.c | 10 +++++++- platform/linux-generic/odp_linux.c | 1 - 4 files changed, 46 insertions(+), 4 deletions(-) diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h index 549d406..4fc8a5e 100644 --- a/platform/linux-generic/include/odp_internal.h +++ b/platform/linux-generic/include/odp_internal.h @@ -29,6 +29,8 @@ int odp_shm_init_global(void); int odp_shm_init_local(void); int odp_buffer_pool_init_global(void); +int odp_buffer_pool_term_global(void); +int odp_buffer_pool_term_local(void); int odp_pktio_init_global(void); int odp_pktio_init_local(void); diff --git a/platform/linux-generic/odp_buffer_pool.c b/platform/linux-generic/odp_buffer_pool.c index 48be24f..bb235ee 100644 --- a/platform/linux-generic/odp_buffer_pool.c +++ b/platform/linux-generic/odp_buffer_pool.c @@ -55,6 +55,7 @@ typedef struct pool_table_t { /* The pool table */ static pool_table_t *pool_tbl; +static const char shm_name[] = "odp_buffer_pools"; /* Pool entry pointers (for inlining) */ void *pool_entry_ptr[ODP_CONFIG_BUFFER_POOLS]; @@ -67,7 +68,7 @@ int odp_buffer_pool_init_global(void) uint32_t i; odp_shm_t shm; - shm = odp_shm_reserve("odp_buffer_pools", + shm = odp_shm_reserve(shm_name, sizeof(pool_table_t), sizeof(pool_entry_t), 0); @@ -95,10 +96,42 @@ int odp_buffer_pool_init_global(void) return 0; } +int odp_buffer_pool_term_global(void) +{ + odp_shm_t shm; + int i; + pool_entry_t *pool; + int ret = 0; + + for (i = 0; i < ODP_CONFIG_BUFFER_POOLS; i++) { + pool = get_pool_entry(i); + + POOL_LOCK(&pool->s.lock); + if (pool->s.pool_shm != ODP_SHM_INVALID) { + ODP_ERR("Not destroyed pool: %s\n", pool->s.name); + ret = -1; + } + POOL_UNLOCK(&pool->s.lock); + } + if (ret) + return ret; + + shm = odp_shm_lookup(shm_name); + if (shm == ODP_SHM_INVALID) + return -1; + ret = odp_shm_free(shm); + + return ret; +} + +int odp_buffer_pool_term_local(void) +{ + _odp_flush_caches(); + return 0; +} /** * Buffer pool creation */ - odp_buffer_pool_t odp_buffer_pool_create(const char *name, odp_shm_t shm, odp_buffer_pool_param_t *params) diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c index 7210430..80a3c19 100644 --- a/platform/linux-generic/odp_init.c +++ b/platform/linux-generic/odp_init.c @@ -64,7 +64,10 @@ int odp_init_global(odp_init_t *params ODP_UNUSED, int odp_term_global(void) { - ODP_UNIMPLEMENTED(); + if (odp_buffer_pool_term_global()) { + ODP_ERR("ODP buffer pool term failed.\n"); + return -1; + } return 0; } @@ -90,5 +93,10 @@ int odp_init_local(void) int odp_term_local(void) { + if (odp_buffer_pool_term_local()) { + ODP_ERR("ODP buffer pool local term failed.\n"); + return -1; + } + return (odp_thread_term_local() > 0) ? 1 : 0; } diff --git a/platform/linux-generic/odp_linux.c b/platform/linux-generic/odp_linux.c index 229d24e..92b8d53 100644 --- a/platform/linux-generic/odp_linux.c +++ b/platform/linux-generic/odp_linux.c @@ -44,7 +44,6 @@ static void *odp_run_start_routine(void *arg) } void *ret_ptr = start_args->start_routine(start_args->arg); - _odp_flush_caches(); int ret = odp_term_local(); if (ret < 0) ODP_ERR("Local term failed\n");