All of lore.kernel.org
 help / color / mirror / Atom feed
From: thomas.petazzoni@free-electrons.com (Thomas Petazzoni)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH RFCv1 2/6] ARM: mvebu: add a coherency_available() call
Date: Thu, 26 Dec 2013 15:12:52 +0100	[thread overview]
Message-ID: <1388067176-18177-3-git-send-email-thomas.petazzoni@free-electrons.com> (raw)
In-Reply-To: <1388067176-18177-1-git-send-email-thomas.petazzoni@free-electrons.com>

This commit extends the coherency fabric code to provide a
coherency_available()function that the SoC code can call to be told
whether coherency support is available or not. On Armada 370/XP,
coherency support is available as soon as the relevant DT node is
present. On some upcoming SoCs, the DT node needs to be present *and*
the system running with CONFIG_SMP enabled.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 arch/arm/mach-mvebu/coherency.c | 30 +++++++++++++++++++++++-------
 arch/arm/mach-mvebu/coherency.h |  1 +
 2 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-mvebu/coherency.c b/arch/arm/mach-mvebu/coherency.c
index a8209ae..70db4e9 100644
--- a/arch/arm/mach-mvebu/coherency.c
+++ b/arch/arm/mach-mvebu/coherency.c
@@ -38,6 +38,7 @@ static void __iomem *coherency_cpu_base;
 #define IO_SYNC_BARRIER_CTL_OFFSET		   0x0
 
 enum {
+	COHERENCY_FABRIC_TYPE_NONE,
 	COHERENCY_FABRIC_TYPE_ARMADA_370_XP,
 };
 
@@ -149,7 +150,7 @@ static void __init armada_370_coherency_init(struct device_node *np)
 	set_cpu_coherent(cpu_logical_map(smp_processor_id()), 0);
 }
 
-int __init coherency_init(void)
+static int coherency_type(void)
 {
 	struct device_node *np;
 
@@ -160,27 +161,42 @@ int __init coherency_init(void)
 		int type;
 
 		type = (int) match->data;
+
 		pr_info("Initializing Coherency fabric\n");
 
+		/* Armada 370/XP coherency works in both UP and SMP */
 		if (type == COHERENCY_FABRIC_TYPE_ARMADA_370_XP)
-			armada_370_coherency_init(np);
+			return type;
 
 		of_node_put(np);
 	}
 
-	return 0;
+	return COHERENCY_FABRIC_TYPE_NONE;
 }
 
-static int __init coherency_late_init(void)
+int coherency_available(void)
 {
+	return coherency_type() != COHERENCY_FABRIC_TYPE_NONE;
+}
+
+int __init coherency_init(void)
+{
+	int type = coherency_type();
 	struct device_node *np;
 
 	np = of_find_matching_node(NULL, of_coherency_table);
-	if (np) {
+
+	if (type == COHERENCY_FABRIC_TYPE_ARMADA_370_XP)
+		armada_370_coherency_init(np);
+
+	return 0;
+}
+
+static int __init coherency_late_init(void)
+{
+	if (coherency_available())
 		bus_register_notifier(&platform_bus_type,
 				      &mvebu_hwcc_platform_nb);
-		of_node_put(np);
-	}
 	return 0;
 }
 
diff --git a/arch/arm/mach-mvebu/coherency.h b/arch/arm/mach-mvebu/coherency.h
index df33ad8..2a05b6e 100644
--- a/arch/arm/mach-mvebu/coherency.h
+++ b/arch/arm/mach-mvebu/coherency.h
@@ -16,5 +16,6 @@
 
 int set_cpu_coherent(int cpu_id, int smp_group_id);
 int coherency_init(void);
+int coherency_available(void);
 
 #endif	/* __MACH_370_XP_COHERENCY_H */
-- 
1.8.3.2

  parent reply	other threads:[~2013-12-26 14:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-26 14:12 [PATCH RFCv1 0/6] ARM: mvebu: coherency support improvements Thomas Petazzoni
2013-12-26 14:12 ` [PATCH RFCv1 1/6] ARM: mvebu: prepare coherency code to support more SOCs Thomas Petazzoni
2013-12-26 14:12 ` Thomas Petazzoni [this message]
2013-12-26 14:12 ` [PATCH RFCv1 3/6] bus: mvebu: pass the coherency availability information at init time Thomas Petazzoni
2013-12-26 14:12 ` [PATCH RFCv1 4/6] ARM: mvebu: use of_find_matching_node_and_match() in coherency.c Thomas Petazzoni
2013-12-26 14:12 ` [PATCH RFCv1 5/6] ARM: mvebu: update Armada 370/XP DT to use new coherency compatible string Thomas Petazzoni
2013-12-26 14:12 ` [PATCH RFCv1 6/6] ARM: mvebu: update coherency fabric DT binding documentation Thomas Petazzoni
2013-12-27 17:32 ` [PATCH RFCv1 0/6] ARM: mvebu: coherency support improvements Jason Cooper
2013-12-27 17:46   ` Jason Cooper
2013-12-27 17:55 ` Jason Cooper
     [not found] <1388067146-18111-1-git-send-email-thomas.petazzoni@free-electrons.com>
     [not found] ` <1388067146-18111-3-git-send-email-thomas.petazzoni@free-electrons.com>
     [not found]   ` <1388067146-18111-3-git-send-email-thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2013-12-27 17:57     ` [PATCH RFCv1 2/6] ARM: mvebu: add a coherency_available() call Jason Cooper
2013-12-27 17:57       ` Jason Cooper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1388067176-18177-3-git-send-email-thomas.petazzoni@free-electrons.com \
    --to=thomas.petazzoni@free-electrons.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.