From patchwork Mon Mar 17 07:55:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Badicioiu X-Patchwork-Id: 26340 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f199.google.com (mail-vc0-f199.google.com [209.85.220.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2492420143 for ; Mon, 17 Mar 2014 07:58:02 +0000 (UTC) Received: by mail-vc0-f199.google.com with SMTP id lh14sf12719054vcb.6 for ; Mon, 17 Mar 2014 00:58:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe:content-type; bh=b1dNK/InwXsThwgrp7GVHd+nDMhVRnYzOxF7QQYbbgI=; b=T4bPj+hDOo7xeZVqyKSLGAyMKprDtbDgcnDQdubU6kl+cxTB0W0mhS9E+sV0tnLY7E jfShEa7PUdO4F+maFZqBL/Sq2clQj8TCDZQz0Q6016T8jamX8aj6RJr6I1PgXrakC8aM am1jnkI0gvouXJy2nP4iBTXK+zb9Hi+29SRGjVR8hN4PG+F07jhAQWI+hwJtpEf5+aEk QezTvdQMYtTU0qd6xEHfUd+tYTlmKMXg3SxYe/LG7laBfK1MawtB7UdFVBnXpg/rXdkq QCwja5fSuaYqLcQFw5OQnDsPnbpgV+dJ2xsDvKmzEo5bub/CC7LihVISdlrQqnu20qwT 9o1g== X-Gm-Message-State: ALoCoQnrZPtK5X7vJDFyIxkBDVcQR8OCDwm+rgbQbKZq60u1+mI0KUG6eFO8blELSgRbUzq3dHuL X-Received: by 10.224.95.9 with SMTP id b9mr8743924qan.2.1395043081831; Mon, 17 Mar 2014 00:58:01 -0700 (PDT) X-BeenThere: lng-odp@linaro.org Received: by 10.140.107.198 with SMTP id h64ls311446qgf.84.gmail; Mon, 17 Mar 2014 00:58:01 -0700 (PDT) X-Received: by 10.224.151.130 with SMTP id c2mr26321692qaw.67.1395043081662; Mon, 17 Mar 2014 00:58:01 -0700 (PDT) Received: from am1outboundpool.messaging.microsoft.com (am1ehsobe003.messaging.microsoft.com. [213.199.154.206]) by mx.google.com with ESMTPS id d8si8095035qao.16.2014.03.17.00.58.01 for (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Mar 2014 00:58:01 -0700 (PDT) Received-SPF: neutral (google.com: 213.199.154.206 is neither permitted nor denied by best guess record for domain of alexandru.badicioiu@linaro.org) client-ip=213.199.154.206; Received: from mail85-am1-R.bigfish.com (10.3.201.246) by AM1EHSOBE019.bigfish.com (10.3.207.141) with Microsoft SMTP Server id 14.1.225.22; Mon, 17 Mar 2014 07:57:59 +0000 Received: from mail85-am1 (localhost [127.0.0.1]) by mail85-am1-R.bigfish.com (Postfix) with ESMTP id 584E1A020C; Mon, 17 Mar 2014 07:57:59 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VS0(zze0eahzz1f42h208ch1ee6h1de0h1fdah2073h2146h1202h1e76h2189h1d1ah1d2ah21bch21a7h1fc6hzz1de098h8275dh1de097hz2dh87h2a8h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1b2fh2222h224fh1fb3h1d0ch1d2eh1d3fh1dc1h1dfeh1dffh1e23h1fe8h1ff5h2218h2216h226dh22d0h24afh2327h2336h2438h2461h2487h24d7h2516h2545h255eh25cch25f6h2605h1151h1155h) X-FB-DOMAIN-IP-MATCH: fail Received: from mail85-am1 (localhost.localdomain [127.0.0.1]) by mail85-am1 (MessageSwitch) id 139504306563621_17207; Mon, 17 Mar 2014 07:57:45 +0000 (UTC) Received: from AM1EHSMHS007.bigfish.com (unknown [10.3.201.251]) by mail85-am1.bigfish.com (Postfix) with ESMTP id 0BBBA1200DC; Mon, 17 Mar 2014 07:57:45 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by AM1EHSMHS007.bigfish.com (10.3.207.107) with Microsoft SMTP Server (TLS) id 14.16.227.3; Mon, 17 Mar 2014 07:57:44 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-003.039d.mgd.msft.net (10.84.1.16) with Microsoft SMTP Server (TLS) id 14.3.158.2; Mon, 17 Mar 2014 07:57:43 +0000 Received: from fsr-fed1364-15.ea.freescale.net (fsr-fed1364-15.ea.freescale.net [10.171.81.144]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id s2H7vfts002422; Mon, 17 Mar 2014 00:57:42 -0700 From: To: CC: Alexandru Badicioiu Subject: [lng-odp][PATCH v2 1/1] Compile ODP for PowerPC targets Date: Mon, 17 Mar 2014 09:55:10 +0200 Message-ID: <1395042910-18389-1-git-send-email-alexandru.badicioiu@linaro.org> X-Mailer: git-send-email 1.7.3.4 MIME-Version: 1.0 X-OriginatorOrg: sigmatel.com X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% X-Original-Sender: alexandru.badicioiu@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 213.199.154.206 is neither permitted nor denied by best guess record for domain of alexandru.badicioiu@linaro.org) smtp.mail=alexandru.badicioiu@linaro.org Precedence: list Mailing-list: list lng-odp@linaro.org; contact lng-odp+owners@linaro.org List-ID: X-Google-Group-Id: 474323889996 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Alexandru Badicioiu - define cache line size - fallback to 32bit atomics on 32bit platforms - enable hugetlb mappings - fix compilation errors when hugetlb mappings are not used - cpuinfo parser Signed-off-by: Alexandru Badicioiu --- include/odp_align.h | 4 ++ include/odp_atomic.h | 21 ++++++++- platform/linux-generic/source/odp_shared_memory.c | 5 ++ platform/linux-generic/source/odp_system_info.c | 50 ++++++++++++++++++++- 4 files changed, 76 insertions(+), 4 deletions(-) diff --git a/include/odp_align.h b/include/odp_align.h index 0f0c614..67a7cdc 100644 --- a/include/odp_align.h +++ b/include/odp_align.h @@ -42,6 +42,10 @@ extern "C" { #define ODP_CACHE_LINE_SIZE 128 +#elif defined __powerpc__ + +#define ODP_CACHE_LINE_SIZE 64 + #else #error GCC target not found #endif diff --git a/include/odp_atomic.h b/include/odp_atomic.h index 3a8a18d..763436a 100644 --- a/include/odp_atomic.h +++ b/include/odp_atomic.h @@ -353,12 +353,21 @@ static inline void odp_atomic_add_u64(odp_atomic_u64_t *ptr, uint64_t value) * * @return Value of the variable before the operation */ + +#if defined __powerpc__ && !defined __powerpc64__ +static inline uint64_t odp_atomic_fetch_add_u64(odp_atomic_u64_t *ptr, + uint64_t value) +{ + return __sync_fetch_and_add((odp_atomic_u32_t *)ptr, + (uint32_t)value); +} +#else static inline uint64_t odp_atomic_fetch_add_u64(odp_atomic_u64_t *ptr, uint64_t value) { return __sync_fetch_and_add(ptr, value); } - +#endif /** * Subtract atomic uint64 * @@ -379,12 +388,20 @@ static inline void odp_atomic_sub_u64(odp_atomic_u64_t *ptr, uint64_t value) * * @return Value of the variable before the operation */ +#if defined __powerpc__ && !defined __powerpc64__ +static inline uint64_t odp_atomic_fetch_sub_u64(odp_atomic_u64_t *ptr, + uint64_t value) +{ + return __sync_fetch_and_sub((odp_atomic_u32_t *)ptr, + (uint32_t)value); +} +#else static inline uint64_t odp_atomic_fetch_sub_u64(odp_atomic_u64_t *ptr, uint64_t value) { return __sync_fetch_and_sub(ptr, value); } - +#endif /** * Fetch and increment atomic uint64 by 1 * diff --git a/platform/linux-generic/source/odp_shared_memory.c b/platform/linux-generic/source/odp_shared_memory.c index ef4bfcd..c607c99 100644 --- a/platform/linux-generic/source/odp_shared_memory.c +++ b/platform/linux-generic/source/odp_shared_memory.c @@ -13,6 +13,9 @@ #include #include +#ifdef __powerpc__ +#include +#endif #include #include @@ -97,10 +100,12 @@ void *odp_shm_reserve(const char *name, uint64_t size, uint64_t align) int i; odp_shm_block_t *block; void *addr; +#ifdef MAP_HUGETLB uint64_t huge_sz, page_sz; huge_sz = odp_sys_huge_page_size(); page_sz = odp_sys_page_size(); +#endif odp_spinlock_lock(&odp_shm_tbl->lock); diff --git a/platform/linux-generic/source/odp_system_info.c b/platform/linux-generic/source/odp_system_info.c index 43129db..17617b0 100644 --- a/platform/linux-generic/source/odp_system_info.c +++ b/platform/linux-generic/source/odp_system_info.c @@ -60,7 +60,8 @@ static int sysconf_core_count(void) } -#if defined __x86_64__ || defined __i386__ || defined __OCTEON__ +#if defined __x86_64__ || defined __i386__ || defined __OCTEON__ || \ +defined __powerpc__ /* * Analysis of /sys/devices/system/cpu/ files */ @@ -213,6 +214,46 @@ static int cpuinfo_octeon(FILE *file, odp_system_info_t *sysinfo) return 0; } +#elif defined __powerpc__ +static int cpuinfo_powerpc(FILE *file, odp_system_info_t *sysinfo) +{ + char str[1024]; + char *pos; + double mhz = 0.0; + int model = 0; + int count = 2; + + while (fgets(str, sizeof(str), file) != NULL && count > 0) { + if (!mhz) { + pos = strstr(str, "clock"); + + if (pos) { + sscanf(pos, "clock : %lf", &mhz); + count--; + } + } + + if (!model) { + pos = strstr(str, "cpu"); + + if (pos) { + int len; + pos = strchr(str, ':'); + strncpy(sysinfo->model_str, pos+2, + sizeof(sysinfo->model_str)); + len = strlen(sysinfo->model_str); + sysinfo->model_str[len - 1] = 0; + model = 1; + count--; + } + } + + sysinfo->cpu_hz = (uint64_t) (mhz * 1000000.0); + } + + + return 0; +} #else #error GCC target not found @@ -231,13 +272,18 @@ static odp_compiler_info_t compiler_info = { .cpu_arch_str = "octeon", .cpuinfo_parser = cpuinfo_octeon + #elif defined __powerpc__ + .cpu_arch_str = "powerpc", + .cpuinfo_parser = cpuinfo_powerpc + #else #error GCC target not found #endif }; -#if defined __x86_64__ || defined __i386__ || defined __OCTEON__ +#if defined __x86_64__ || defined __i386__ || defined __OCTEON__ || \ +defined __powerpc__ /* * Analysis of /sys/devices/system/cpu/ files