Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4395015ooa; Tue, 14 Aug 2018 05:31:11 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxrOp5ETdbEgOEp5ZNfwfRwjaT2izMzSC3PkMIa5VXYFitqI4HsXwelnCxAzRyIPkt5RcOW X-Received: by 2002:a63:a042:: with SMTP id u2-v6mr20499021pgn.80.1534249871352; Tue, 14 Aug 2018 05:31:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534249871; cv=none; d=google.com; s=arc-20160816; b=Lsq9c48owaerUf64ZWGZeXbqTm9Z0tQLaVZ6JqerDNjeTNGlyfK5awAtOAekW8xpFo klEGt+AH0ps1sEC5xQlpKG9zuG68JfLrfdi2JhhyS7UhY/mAZdJM5ebS6b0ldBIZPFhY T66ui9en/apDPouhpSwVJ6o+jLVyD0YjoTS3M2/Tb+sIt8nHmOA4ihnXhHqgadKEEmbJ P/ckONUKfQLsOOGVfJ7SwSiChxrpgWL/hhoRFOEXvQvsRjEVnKlzS6eGC9a90RDsVoZn h3TdgnwlZ0tlI2a/lHlYMh+5aRDbYi6olc2etdLB0aGSrtsPso+65KHiAxfJs+uaLhDT 31tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=HahNMrCBU7hJMsYnmMpWCWKfg2ysRuSWyWVHtL6b9R4=; b=mSvUe9hNWknUxXD5Rh7eAwwrw9TBKPJKpJd9M7mgWDr1PcFIcLyCZwnjy93XdViL2w 05Y6vUspIWYJw7RdPp9jzM4g5beupWykrD/xR1s3MpJ3x9GBM/1pg+t+73ZjPfkSjq53 oRw9W54i77mW9nHkrC2iy/rtM13da0WDMLkm/m1G7OsD4KQLAveBbY77JwGexD8D+vbl jXH57Nz2aNoL935oLAr8GLb8dZp6pDDN5Qhj5JFSqUdWJ0euaX7HQ7t70UKI1dmEu98Q AmlXM6pReHudwWNDxRmOyiocWQvRCL9zYbQdVAFXaz5uNq/HiAUWHq1aHb6OKKEhhNha an1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=FCgi8+Ua; dkim=pass header.i=@codeaurora.org header.s=default header.b=LCNSDemZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h18-v6si19728322pgd.238.2018.08.14.05.30.45; Tue, 14 Aug 2018 05:31:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=FCgi8+Ua; dkim=pass header.i=@codeaurora.org header.s=default header.b=LCNSDemZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731990AbeHNO7t (ORCPT + 99 others); Tue, 14 Aug 2018 10:59:49 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:36370 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729420AbeHNO7t (ORCPT ); Tue, 14 Aug 2018 10:59:49 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 68E5160B22; Tue, 14 Aug 2018 12:12:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1534248774; bh=LrvAJtJJ+JQt0h+Tk7S33Gv+IzID2CSgiMwyPSI1Pt8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FCgi8+UadWN8r6uFYwGUgqISdKekb/OyEUlzOZ6IU7xZM64SHC2/PcZtJSDv99wre yuEUUGpzwoI4+ozNO7CPsOcPFYhlfQbjJ0BOvoSciZm4xEf0UpdJZw85YaKR+kWBi5 pMlRtzheklFbHFVzvx/F0v+D2XoosZEtZtF244Jg= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from srichara-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sricharan@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7261560BE2; Tue, 14 Aug 2018 12:12:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1534248773; bh=LrvAJtJJ+JQt0h+Tk7S33Gv+IzID2CSgiMwyPSI1Pt8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LCNSDemZLZbOoJ4F3IqSIECwC9CKTrZp9Ie2WQDCqFMXZpelTkHtfaT4lcifpjhZv 5IcEiYk4dnqAGoCpBJ0UiwPhGxXfRxbyowcWGI9wV+QWu8/9UeE6Vl0gUoPvM5BL/b /cu05XSTCHTelweXqrCmaoyZPpbTr9Z9iaU3TGCY= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 7261560BE2 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=sricharan@codeaurora.org From: Sricharan R To: mark.rutland@arm.com, robh@kernel.org, sudeep.holla@arm.com, linux@arm.linux.org.uk, ctatlor97@gmail.com, rjw@rjwysocki.net, viresh.kumar@linaro.org, mturquette@baylibre.com, linux-pm@vger.kernel.org, sboyd@codeaurora.org, linux@armlinux.org.uk, thierry.escande@linaro.org, linux-kernel@vger.kernel.org, david.brown@linaro.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, andy.gross@linaro.org, linux-soc@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, niklas.cassel@linaro.org Cc: sricharan@codeaurora.org Subject: [PATCH v12 01/14] ARM: Add Krait L2 register accessor functions Date: Tue, 14 Aug 2018 17:42:20 +0530 Message-Id: <1534248753-2440-2-git-send-email-sricharan@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1534248753-2440-1-git-send-email-sricharan@codeaurora.org> References: <1534248753-2440-1-git-send-email-sricharan@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stephen Boyd Krait CPUs have a handful of L2 cache controller registers that live behind a cp15 based indirection register. First you program the indirection register (l2cpselr) to point the L2 'window' register (l2cpdr) at what you want to read/write. Then you read/write the 'window' register to do what you want. The l2cpselr register is not banked per-cpu so we must lock around accesses to it to prevent other CPUs from re-pointing l2cpdr underneath us. Cc: Mark Rutland Cc: Russell King Acked-by: Bjorn Andersson Signed-off-by: Stephen Boyd Signed-off-by: Sricharan R --- arch/arm/common/Kconfig | 3 ++ arch/arm/common/Makefile | 1 + arch/arm/common/krait-l2-accessors.c | 48 +++++++++++++++++++++++++++++++ arch/arm/include/asm/krait-l2-accessors.h | 9 ++++++ 4 files changed, 61 insertions(+) create mode 100644 arch/arm/common/krait-l2-accessors.c create mode 100644 arch/arm/include/asm/krait-l2-accessors.h diff --git a/arch/arm/common/Kconfig b/arch/arm/common/Kconfig index e5ad070..c8e1986 100644 --- a/arch/arm/common/Kconfig +++ b/arch/arm/common/Kconfig @@ -7,6 +7,9 @@ config DMABOUNCE bool select ZONE_DMA +config KRAIT_L2_ACCESSORS + bool + config SHARP_LOCOMO bool diff --git a/arch/arm/common/Makefile b/arch/arm/common/Makefile index 3157be4..219a260 100644 --- a/arch/arm/common/Makefile +++ b/arch/arm/common/Makefile @@ -7,6 +7,7 @@ obj-y += firmware.o obj-$(CONFIG_SA1111) += sa1111.o obj-$(CONFIG_DMABOUNCE) += dmabounce.o +obj-$(CONFIG_KRAIT_L2_ACCESSORS) += krait-l2-accessors.o obj-$(CONFIG_SHARP_LOCOMO) += locomo.o obj-$(CONFIG_SHARP_PARAM) += sharpsl_param.o obj-$(CONFIG_SHARP_SCOOP) += scoop.o diff --git a/arch/arm/common/krait-l2-accessors.c b/arch/arm/common/krait-l2-accessors.c new file mode 100644 index 0000000..9a97dda --- /dev/null +++ b/arch/arm/common/krait-l2-accessors.c @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2018, The Linux Foundation. All rights reserved. + +#include +#include + +#include +#include + +static DEFINE_RAW_SPINLOCK(krait_l2_lock); + +void krait_set_l2_indirect_reg(u32 addr, u32 val) +{ + unsigned long flags; + + raw_spin_lock_irqsave(&krait_l2_lock, flags); + /* + * Select the L2 window by poking l2cpselr, then write to the window + * via l2cpdr. + */ + asm volatile ("mcr p15, 3, %0, c15, c0, 6 @ l2cpselr" : : "r" (addr)); + isb(); + asm volatile ("mcr p15, 3, %0, c15, c0, 7 @ l2cpdr" : : "r" (val)); + isb(); + + raw_spin_unlock_irqrestore(&krait_l2_lock, flags); +} +EXPORT_SYMBOL(krait_set_l2_indirect_reg); + +u32 krait_get_l2_indirect_reg(u32 addr) +{ + u32 val; + unsigned long flags; + + raw_spin_lock_irqsave(&krait_l2_lock, flags); + /* + * Select the L2 window by poking l2cpselr, then read from the window + * via l2cpdr. + */ + asm volatile ("mcr p15, 3, %0, c15, c0, 6 @ l2cpselr" : : "r" (addr)); + isb(); + asm volatile ("mrc p15, 3, %0, c15, c0, 7 @ l2cpdr" : "=r" (val)); + + raw_spin_unlock_irqrestore(&krait_l2_lock, flags); + + return val; +} +EXPORT_SYMBOL(krait_get_l2_indirect_reg); diff --git a/arch/arm/include/asm/krait-l2-accessors.h b/arch/arm/include/asm/krait-l2-accessors.h new file mode 100644 index 0000000..a5f2cdd --- /dev/null +++ b/arch/arm/include/asm/krait-l2-accessors.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __ASMARM_KRAIT_L2_ACCESSORS_H +#define __ASMARM_KRAIT_L2_ACCESSORS_H + +extern void krait_set_l2_indirect_reg(u32 addr, u32 val); +extern u32 krait_get_l2_indirect_reg(u32 addr); + +#endif -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation