From patchwork Mon Feb 23 20:36:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robbie King X-Patchwork-Id: 44919 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f69.google.com (mail-ee0-f69.google.com [74.125.83.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E011C21562 for ; Mon, 23 Feb 2015 20:37:50 +0000 (UTC) Received: by eekb15 with SMTP id b15sf12813735eek.0 for ; Mon, 23 Feb 2015 12:37:50 -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=EvGyHIjtBL40N7PYMJ8iYD7WCmlOtwWNDePB3ikYgLU=; b=HvevcQBX2g7FufELuYeelqhDC5/AcwIuU6auGzhWCDNZ96eOoaRj6RuzksBtFOU31N ToE7+P1rFNLJDaFJvCmYR1fAkCL2EXAc/yUWHmkpYT4MUD7uVqg6QrOJuG10xC//891F lO1nbn8Hp9yg0NVgQkJ64C7Xv9oCN8TfHFvjn5URqPei3DkLJT0esFfYzmWfTkiJV/Rj WbveoFdBg7h0AsdnkEw32z9j2FQfDtd/fIESMxq4DRIkVd7S/i5I9cPfEVjk3D/iLPGc 59mC+e3YYnLIG56Ho51DVhqFEGoml7cYijIluy2vMw2Pbm4t3Kh2iLYuHztkUMiac+6R 9pkA== X-Gm-Message-State: ALoCoQmwQ3VkzaLjvcUUtVHHteBDQGK1M0lw+vf7epqG6cmxj7+uGGot/m0nCtMLDcPhwUuMzIEv X-Received: by 10.194.86.1 with SMTP id l1mr1622729wjz.0.1424723870142; Mon, 23 Feb 2015 12:37:50 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.115.207 with SMTP id jq15ls592769lab.107.gmail; Mon, 23 Feb 2015 12:37:49 -0800 (PST) X-Received: by 10.152.21.100 with SMTP id u4mr11276640lae.41.1424723869811; Mon, 23 Feb 2015 12:37:49 -0800 (PST) Received: from mail-lb0-x236.google.com (mail-lb0-x236.google.com. [2a00:1450:4010:c04::236]) by mx.google.com with ESMTPS id pk8si6186972lbb.73.2015.02.23.12.37.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Feb 2015 12:37:49 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::236 as permitted sender) client-ip=2a00:1450:4010:c04::236; Received: by lbvn10 with SMTP id n10so21109010lbv.6 for ; Mon, 23 Feb 2015 12:37:49 -0800 (PST) X-Received: by 10.112.181.41 with SMTP id dt9mr1022129lbc.56.1424723869719; Mon, 23 Feb 2015 12:37:49 -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.35.133 with SMTP id h5csp1500541lbj; Mon, 23 Feb 2015 12:37:49 -0800 (PST) X-Received: by 10.229.83.196 with SMTP id g4mr29304187qcl.18.1424723868766; Mon, 23 Feb 2015 12:37:48 -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 x2si12892269qas.42.2015.02.23.12.37.47 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 23 Feb 2015 12:37:48 -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 1YPzlB-0002p2-OG; Mon, 23 Feb 2015 20:37:45 +0000 Received: from alln-iport-4.cisco.com ([173.37.142.91]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YPzkS-0002d0-QX for lng-odp@lists.linaro.org; Mon, 23 Feb 2015 20:37:00 +0000 X-IronPort-AV: E=Sophos;i="5.09,633,1418083200"; d="scan'208";a="126188409" Received: from alln-core-7.cisco.com ([173.36.13.140]) by alln-iport-4.cisco.com with ESMTP; 23 Feb 2015 20:36:56 +0000 Received: from cpp-rtpbld-55.cisco.com (cpp-rtpbld-55.cisco.com [172.18.5.199]) by alln-core-7.cisco.com (8.14.5/8.14.5) with ESMTP id t1NKasgr010779 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 23 Feb 2015 20:36:55 GMT Received: from cpp-rtpbld-55.cisco.com (localhost.localdomain [127.0.0.1]) by cpp-rtpbld-55.cisco.com (8.13.8/8.13.8) with ESMTP id t1NKar7R030651; Mon, 23 Feb 2015 15:36:53 -0500 Received: (from robking@localhost) by cpp-rtpbld-55.cisco.com (8.13.8/8.13.8/Submit) id t1NKarJ0030650; Mon, 23 Feb 2015 15:36:53 -0500 From: Robbie King To: lng-odp@lists.linaro.org Date: Mon, 23 Feb 2015 15:36:05 -0500 Message-Id: <1424723769-8762-7-git-send-email-robking@cisco.com> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1424723769-8762-1-git-send-email-robking@cisco.com> References: <1424723769-8762-1-git-send-email-robking@cisco.com> X-Topics: patch Subject: [lng-odp] [PATCHv3 06/10] linux-generic: buffer_pool: add term_global 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-Original-Sender: robking@cisco.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::236 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=fail header.i=@cisco.com Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Yan Sonming Signed-off-by: Yan Songming Signed-off-by: Mike Holmes Signed-off-by: Robbie King --- platform/linux-generic/include/odp_internal.h | 1 + platform/linux-generic/odp_init.c | 5 +++++ platform/linux-generic/odp_pool.c | 30 ++++++++++++++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h index c6da30b..c82012d 100644 --- a/platform/linux-generic/include/odp_internal.h +++ b/platform/linux-generic/include/odp_internal.h @@ -39,6 +39,7 @@ int odp_shm_init_global(void); int odp_shm_init_local(void); int odp_pool_init_global(void); +int odp_pool_term_global(void); int odp_pktio_init_global(void); int odp_pktio_term_global(void); diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c index f5e0f25..82735b0 100644 --- a/platform/linux-generic/odp_init.c +++ b/platform/linux-generic/odp_init.c @@ -103,6 +103,11 @@ int odp_term_global(void) rc = -1; } + if (odp_pool_term_global()) { + ODP_ERR("ODP buffer pool term failed.\n"); + rc = -1; + } + return rc; } diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c index 422ff2b..441429a 100644 --- a/platform/linux-generic/odp_pool.c +++ b/platform/linux-generic/odp_pool.c @@ -55,6 +55,7 @@ typedef struct pool_table_t { /* The pool table */ static pool_table_t *pool_tbl; +static const char SHM_DEFAULT_NAME[] = "odp_buffer_pools"; /* Pool entry pointers (for inlining) */ void *pool_entry_ptr[ODP_CONFIG_POOLS]; @@ -67,7 +68,7 @@ int odp_pool_init_global(void) uint32_t i; odp_shm_t shm; - shm = odp_shm_reserve("odp_pools", + shm = odp_shm_reserve(SHM_DEFAULT_NAME, sizeof(pool_table_t), sizeof(pool_entry_t), 0); @@ -95,6 +96,33 @@ int odp_pool_init_global(void) return 0; } +int odp_pool_term_global(void) +{ + int i; + pool_entry_t *pool; + int ret = 0; + int rc = 0; + + for (i = 0; i < ODP_CONFIG_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); + rc = -1; + } + POOL_UNLOCK(&pool->s.lock); + } + + ret = odp_shm_free(odp_shm_lookup(SHM_DEFAULT_NAME)); + if (ret < 0) { + ODP_ERR("shm free failed for %s", SHM_DEFAULT_NAME); + rc = -1; + } + + return rc; +} + /** * Pool creation */