From patchwork Thu Feb 27 12:13:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Badicioiu X-Patchwork-Id: 25594 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f199.google.com (mail-ob0-f199.google.com [209.85.214.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 290EB20E1E for ; Mon, 3 Mar 2014 08:07:33 +0000 (UTC) Received: by mail-ob0-f199.google.com with SMTP id wo20sf18318968obc.10 for ; Mon, 03 Mar 2014 00:07:32 -0800 (PST) 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=dw0cgkhOrFeH1B7in411i0qVBZJkmw3+XSiTaxPeWyE=; b=NKINgoHkY9nrvOQvAQSl4Dab+lH3WXA4B5Goe5FGTP9amUikLcNDVYHTkVGNaxDITL sP7xZt8GqW+8I7hjyt7F+z+IHuuiejmlk4egR2ifuBzctNKAOgBvLZOGb9kxuwOOdXx/ PPqY9imwTf5taNdsWn2c0GXjMc/Au8tgxHXRCPD0kjbqW1txgIOqiPVNt/N4OQS+7pYy 5HEKWrE8Lht6LSowlqgdvBWkqU+oZyk1SWDi+Cc/drK6ZBBEKc7GdS9pYPPupUX9i/l+ vMVEjDwt2PwmshFTB/nvAJo+nAamu2vbAHDYGlQ+SEdEY5WhDQ8K0oTogk0YVNzJN6td k1gA== X-Gm-Message-State: ALoCoQnZAmHwG1wOJTCWP1SyK8hY1rSX/OG2c4VBLBVbnP6sy4Oha+xPU6x8/PrRFnDYOjlqM8UQ X-Received: by 10.43.88.73 with SMTP id az9mr2062597icc.5.1393834052692; Mon, 03 Mar 2014 00:07:32 -0800 (PST) X-BeenThere: lng-odp@linaro.org Received: by 10.182.29.9 with SMTP id f9ls753098obh.22.gmail; Mon, 03 Mar 2014 00:07:32 -0800 (PST) X-Received: by 10.182.109.200 with SMTP id hu8mr13542467obb.20.1393834052529; Mon, 03 Mar 2014 00:07:32 -0800 (PST) Received: by 10.224.127.199 with SMTP id h7msqas; Thu, 27 Feb 2014 04:14:30 -0800 (PST) X-Received: by 10.224.169.11 with SMTP id w11mr15469879qay.71.1393503269924; Thu, 27 Feb 2014 04:14:29 -0800 (PST) Received: from co9outboundpool.messaging.microsoft.com (co9ehsobe003.messaging.microsoft.com. [207.46.163.26]) by mx.google.com with ESMTPS id o46si1937656qgo.58.2014.02.27.04.14.29 for (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 27 Feb 2014 04:14:29 -0800 (PST) Received-SPF: neutral (google.com: 207.46.163.26 is neither permitted nor denied by best guess record for domain of alexandru.badicioiu@linaro.org) client-ip=207.46.163.26; Received: from mail146-co9-R.bigfish.com (10.236.132.247) by CO9EHSOBE030.bigfish.com (10.236.130.93) with Microsoft SMTP Server id 14.1.225.22; Thu, 27 Feb 2014 12:14:28 +0000 Received: from mail146-co9 (localhost [127.0.0.1]) by mail146-co9-R.bigfish.com (Postfix) with ESMTP id A8E0B5E01D8; Thu, 27 Feb 2014 12:14:28 +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(zze0eahzz1f42h208ch1ee6h1de0h1fdah2073h2146h1202h1e76h2189h1d1ah1d2ah21bch21a7h1fc6hzz1de098h8275dh1de097hz2dh87h2a8h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1b2fh2222h224fh1fb3h1d0ch1d2eh1d3fh1dc1h1dfeh1dffh1e23h1fe8h1ff5h2218h2216h226dh22d0h24afh2327h2336h2438h2461h2487h24d7h2516h2545h255eh25cch1151h1155h) X-FB-DOMAIN-IP-MATCH: fail Received: from mail146-co9 (localhost.localdomain [127.0.0.1]) by mail146-co9 (MessageSwitch) id 1393503266790404_17489; Thu, 27 Feb 2014 12:14:26 +0000 (UTC) Received: from CO9EHSMHS029.bigfish.com (unknown [10.236.132.251]) by mail146-co9.bigfish.com (Postfix) with ESMTP id BB508C800A7; Thu, 27 Feb 2014 12:14:26 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CO9EHSMHS029.bigfish.com (10.236.130.39) with Microsoft SMTP Server (TLS) id 14.16.227.3; Thu, 27 Feb 2014 12:14:26 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-002.039d.mgd.msft.net (10.84.1.15) with Microsoft SMTP Server (TLS) id 14.3.158.2; Thu, 27 Feb 2014 12:14:25 +0000 Received: from fsr-fed1364-15.ea.freescale.net (fsr-fed1364-15.ea.freescale.net [10.171.81.144]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id s1RCEO3E021998; Thu, 27 Feb 2014 05:14:24 -0700 From: To: CC: Alexandru Badicioiu Subject: [lng-odp][PATCH 1/1] Compile ODP for PowerPC targets Date: Thu, 27 Feb 2014 14:13:09 +0200 Message-ID: <1393503189-3430-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: 207.46.163.26 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, 75 insertions(+), 5 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..b4ec87c 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,7 +100,7 @@ void *odp_shm_reserve(const char *name, uint64_t size, uint64_t align) int i; odp_shm_block_t *block; void *addr; - uint64_t huge_sz, page_sz; + uint64_t huge_sz ODP_UNUSED, page_sz ODP_UNUSED; huge_sz = odp_sys_huge_page_size(); page_sz = odp_sys_page_size(); 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