From patchwork Mon Aug 4 08:16:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 34764 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f198.google.com (mail-ie0-f198.google.com [209.85.223.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 77DEF20F2E for ; Mon, 4 Aug 2014 08:18:50 +0000 (UTC) Received: by mail-ie0-f198.google.com with SMTP id rl12sf39843280iec.9 for ; Mon, 04 Aug 2014 01:18:50 -0700 (PDT) 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:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=j/SPnFr+EX6/ipT/oElW2z9IKrA4HLgABr0GlkHtO7o=; b=OtZ04Qsz7StOFioYS6yqR/nic8d+jMxU56SWsIks8Y/sJeLs0/UHLJKXXIs1kjwvcl Ut9WFu6BYTJRX7hXaP6PvHZQxoF9AhJqHp7eP8o0VLQY7bMmOAWEwtKvjpBoylurZP2k 0D8qVHW/4Xg6i5Yji1JL6pL15hovIdGJp64DpQShf7upzHpi3pFvNc9z1itfGKUu+Bwm 2te1sZouCR7dc/NJtQ5yyROphCyK7XxpvnvMZQT9rAd2zX7c0UdPOX1Woignu66fzD7I A+Ut0ZhfwxFM/g/8MH5zx1ruHbieeltSnxqKcNEAo+T4lYQS7OKFl+hDDHDjCo8H0krL q4dA== X-Gm-Message-State: ALoCoQknRqpyDw+kYYKx2NzGUAMT3yHXMO1jRE8xynm00cVEBhuld+S8ohtFYPpQpg2Los1tGpZm X-Received: by 10.50.50.130 with SMTP id c2mr8230493igo.4.1407140330037; Mon, 04 Aug 2014 01:18:50 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.20.132 with SMTP id 4ls2015901qgj.12.gmail; Mon, 04 Aug 2014 01:18:49 -0700 (PDT) X-Received: by 10.52.61.99 with SMTP id o3mr18410565vdr.46.1407140329927; Mon, 04 Aug 2014 01:18:49 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id ee14si4979225vcb.93.2014.08.04.01.18.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 04 Aug 2014 01:18:49 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.171 as permitted sender) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id hq11so10451638vcb.2 for ; Mon, 04 Aug 2014 01:18:49 -0700 (PDT) X-Received: by 10.53.7.204 with SMTP id de12mr18468128vdd.41.1407140329803; Mon, 04 Aug 2014 01:18:49 -0700 (PDT) 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.221.37.5 with SMTP id tc5csp286629vcb; Mon, 4 Aug 2014 01:18:49 -0700 (PDT) X-Received: by 10.70.118.136 with SMTP id km8mr1677444pdb.125.1407140328808; Mon, 04 Aug 2014 01:18:48 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id sj7si16800073pbc.44.2014.08.04.01.18.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Aug 2014 01:18:48 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XEDSc-0006Gy-42; Mon, 04 Aug 2014 08:17:38 +0000 Received: from mail-we0-f175.google.com ([74.125.82.175]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XEDSQ-00068s-9J for linux-arm-kernel@lists.infradead.org; Mon, 04 Aug 2014 08:17:29 +0000 Received: by mail-we0-f175.google.com with SMTP id t60so7309799wes.20 for ; Mon, 04 Aug 2014 01:17:03 -0700 (PDT) X-Received: by 10.180.106.138 with SMTP id gu10mr27847058wib.21.1407140222965; Mon, 04 Aug 2014 01:17:02 -0700 (PDT) Received: from ards-macbook-pro.local ([188.252.229.85]) by mx.google.com with ESMTPSA id ub11sm38363410wib.1.2014.08.04.01.17.01 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 04 Aug 2014 01:17:02 -0700 (PDT) From: Ard Biesheuvel To: will.deacon@arm.com, mark.rutland@arm.com, catalin.marinas@arm.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/3] arm64: add helper functions to read I-cache attributes Date: Mon, 4 Aug 2014 10:16:55 +0200 Message-Id: <1407140216-22747-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1407140216-22747-1-git-send-email-ard.biesheuvel@linaro.org> References: <1407140216-22747-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140804_011726_480402_ADB445C6 X-CRM114-Status: GOOD ( 11.49 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.175 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [74.125.82.175 listed in wl.mailspike.net] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: Ard Biesheuvel X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@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.220.171 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 This adds helper functions and #defines to to read the line size and the number of sets from the level 1 instruction cache. Signed-off-by: Ard Biesheuvel --- arch/arm64/include/asm/cachetype.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/arch/arm64/include/asm/cachetype.h b/arch/arm64/include/asm/cachetype.h index 7a2e0762cb40..c0bf1fc3d6a0 100644 --- a/arch/arm64/include/asm/cachetype.h +++ b/arch/arm64/include/asm/cachetype.h @@ -39,6 +39,34 @@ extern unsigned long __icache_flags; +#define CCSIDR_EL1_LINESIZE_MASK 0x7 +#define CCSIDR_EL1_LINESIZE(x) (x & CCSIDR_EL1_LINESIZE_MASK) + +#define CCSIDR_EL1_NUMSETS_SHIFT 13 +#define CCSIDR_EL1_NUMSETS_MASK (0x7fff << CCSIDR_EL1_NUMSETS_SHIFT) +#define CCSIDR_EL1_NUMSETS(x) \ + ((x & CCSIDR_EL1_NUMSETS_MASK) >> CCSIDR_EL1_NUMSETS_SHIFT) + +static inline __attribute_const__ u32 icache_get_ccsidr(void) +{ + u32 ccsidr; + + /* Select L1 I-cache and read its size ID register */ + asm("msr csselr_el1, %x1; isb; mrs %x0, ccsidr_el1" + : "=r"(ccsidr) : "r"(0x1)); + return ccsidr; +} + +static inline int icache_get_linesize(void) +{ + return 16 << CCSIDR_EL1_LINESIZE(icache_get_ccsidr()); +} + +static inline int icache_get_numsets(void) +{ + return 1 + CCSIDR_EL1_NUMSETS(icache_get_ccsidr()); +} + /* * Whilst the D-side always behaves as PIPT on AArch64, aliasing is * permitted in the I-cache.