All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nathan Fontenot <nfont@linux.vnet.ibm.com>
To: linuxppc-dev@ozlabs.org
Subject: [PATCH 4/11] Add platform_has_feature()
Date: Fri, 08 Mar 2013 22:02:31 -0600	[thread overview]
Message-ID: <513AB457.9000409@linux.vnet.ibm.com> (raw)
In-Reply-To: <513AB2E3.6090209@linux.vnet.ibm.com>

The firmware_has_feature() function makes it easy to check for supported
features of the hardware. There is not corresponding function to check for
features supported by the client architecture.

This patch adds a platform_has_feature() function to check features selected
by firmware and reported via the device tree 'ibm,architecture-vec5'
property. As part of this the #defines used for the architecture vector are
moved to prom.h and re-defined such that the vector 5 options have the vector
index and the feature bits encoded into them. This allows for callers of
platform_has_feature() to pass in a single pre-defined value.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
---
 arch/powerpc/include/asm/prom.h |   41 +++++++++++++++++++++++-----------------
 arch/powerpc/kernel/prom.c      |   19 ++++++++++++++++++
 arch/powerpc/kernel/prom_init.c |   14 +++++++------
 3 files changed, 51 insertions(+), 23 deletions(-)

Index: powerpc/arch/powerpc/include/asm/prom.h
===================================================================
--- powerpc.orig/arch/powerpc/include/asm/prom.h	2013-03-08 19:57:05.000000000 -0600
+++ powerpc/arch/powerpc/include/asm/prom.h	2013-03-08 19:57:14.000000000 -0600
@@ -111,31 +111,37 @@
 /* Option vector 4: IBM PAPR implementation */
 #define OV4_MIN_ENT_CAP		0x01	/* minimum VP entitled capacity */
 
-/* Option vector 5: PAPR/OF options supported */
-#define OV5_LPAR		0x80	/* logical partitioning supported */
-#define OV5_SPLPAR		0x40	/* shared-processor LPAR supported */
+/* Option vector 5: PAPR/OF options supported
+ * These bits are also used for the platform_has_feature() call so
+ * we encode the vector index in the define and use the OV5_FEAT()
+ * and OV5_INDX() macros to extract the desired information.
+ */
+#define OV5_FEAT(x)	((x) & 0xff)
+#define OV5_INDX(x)	((x) >> 8)
+#define OV5_LPAR		0x0280	/* logical partitioning supported */
+#define OV5_SPLPAR		0x0240	/* shared-processor LPAR supported */
 /* ibm,dynamic-reconfiguration-memory property supported */
-#define OV5_DRCONF_MEMORY	0x20
-#define OV5_LARGE_PAGES		0x10	/* large pages supported */
-#define OV5_DONATE_DEDICATE_CPU	0x02	/* donate dedicated CPU support */
+#define OV5_DRCONF_MEMORY	0x0220
+#define OV5_LARGE_PAGES		0x0210	/* large pages supported */
+#define OV5_DONATE_DEDICATE_CPU	0x0202	/* donate dedicated CPU support */
 /* PCIe/MSI support.  Without MSI full PCIe is not supported */
 #ifdef CONFIG_PCI_MSI
-#define OV5_MSI			0x01	/* PCIe/MSI support */
+#define OV5_MSI			0x0201	/* PCIe/MSI support */
 #else
-#define OV5_MSI			0x00
+#define OV5_MSI			0x0200
 #endif /* CONFIG_PCI_MSI */
 #ifdef CONFIG_PPC_SMLPAR
-#define OV5_CMO			0x80	/* Cooperative Memory Overcommitment */
-#define OV5_XCMO		0x40	/* Page Coalescing */
+#define OV5_CMO			0x0480	/* Cooperative Memory Overcommitment */
+#define OV5_XCMO		0x0440	/* Page Coalescing */
 #else
-#define OV5_CMO			0x00
-#define OV5_XCMO		0x00
+#define OV5_CMO			0x0400
+#define OV5_XCMO		0x0400
 #endif
-#define OV5_TYPE1_AFFINITY	0x80	/* Type 1 NUMA affinity */
-#define OV5_PFO_HW_RNG		0x80	/* PFO Random Number Generator */
-#define OV5_PFO_HW_842		0x40	/* PFO Compression Accelerator */
-#define OV5_PFO_HW_ENCR		0x20	/* PFO Encryption Accelerator */
-#define OV5_SUB_PROCESSORS	0x01	/* 1,2,or 4 Sub-Processors supported */
+#define OV5_TYPE1_AFFINITY	0x0580	/* Type 1 NUMA affinity */
+#define OV5_PFO_HW_RNG		0x0E80	/* PFO Random Number Generator */
+#define OV5_PFO_HW_842		0x0E40	/* PFO Compression Accelerator */
+#define OV5_PFO_HW_ENCR		0x0E20	/* PFO Encryption Accelerator */
+#define OV5_SUB_PROCESSORS	0x0F01	/* 1,2,or 4 Sub-Processors supported */
 
 /* Option Vector 6: IBM PAPR hints */
 #define OV6_LINUX		0x02	/* Linux is our OS */
@@ -145,6 +151,7 @@
  * followed by # option vectors - 1, followed by the option vectors.
  */
 extern unsigned char ibm_architecture_vec[];
+bool platform_has_feature(unsigned int);
 #endif
 
 /* These includes are put at the bottom because they may contain things
Index: powerpc/arch/powerpc/kernel/prom_init.c
===================================================================
--- powerpc.orig/arch/powerpc/kernel/prom_init.c	2013-03-08 19:57:05.000000000 -0600
+++ powerpc/arch/powerpc/kernel/prom_init.c	2013-03-08 19:57:14.000000000 -0600
@@ -684,11 +684,12 @@
 	/* option vector 5: PAPR/OF options */
 	19 - 2,				/* length */
 	0,				/* don't ignore, don't halt */
-	OV5_LPAR | OV5_SPLPAR | OV5_LARGE_PAGES | OV5_DRCONF_MEMORY |
-	OV5_DONATE_DEDICATE_CPU | OV5_MSI,
+	OV5_FEAT(OV5_LPAR) | OV5_FEAT(OV5_SPLPAR) | OV5_FEAT(OV5_LARGE_PAGES) |
+	OV5_FEAT(OV5_DRCONF_MEMORY) | OV5_FEAT(OV5_DONATE_DEDICATE_CPU) |
+	OV5_FEAT(OV5_MSI),
 	0,
-	OV5_CMO | OV5_XCMO,
-	OV5_TYPE1_AFFINITY,
+	OV5_FEAT(OV5_CMO) | OV5_FEAT(OV5_XCMO),
+	OV5_FEAT(OV5_TYPE1_AFFINITY),
 	0,
 	0,
 	0,
@@ -702,8 +703,9 @@
 	0,
 	0,
 	0,
-	OV5_PFO_HW_RNG | OV5_PFO_HW_ENCR | OV5_PFO_HW_842,
-	OV5_SUB_PROCESSORS,
+	OV5_FEAT(OV5_PFO_HW_RNG) | OV5_FEAT(OV5_PFO_HW_ENCR) |
+	OV5_FEAT(OV5_PFO_HW_842),
+	OV5_FEAT(OV5_SUB_PROCESSORS),
 	/* option vector 6: IBM PAPR hints */
 	4 - 2,				/* length */
 	0,
Index: powerpc/arch/powerpc/kernel/prom.c
===================================================================
--- powerpc.orig/arch/powerpc/kernel/prom.c	2013-03-08 19:23:06.000000000 -0600
+++ powerpc/arch/powerpc/kernel/prom.c	2013-03-08 19:57:14.000000000 -0600
@@ -871,6 +871,25 @@
 }
 EXPORT_SYMBOL(of_get_cpu_node);
 
+#if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV)
+bool platform_has_feature(unsigned int feature)
+{
+	struct device_node *chosen;
+	const char *vec5;
+	bool has_option;
+
+	chosen = of_find_node_by_path("/chosen");
+	if (!chosen)
+		return false;
+
+	vec5 = of_get_property(chosen, "ibm,architecture-vec-5", NULL);
+	has_option = vec5 && (vec5[OV5_INDX(feature)] & OV5_FEAT(feature));
+	of_node_put(chosen);
+
+	return has_option;
+}
+#endif
+
 #if defined(CONFIG_DEBUG_FS) && defined(DEBUG)
 static struct debugfs_blob_wrapper flat_dt_blob;
 

  parent reply	other threads:[~2013-03-09  4:02 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-09  3:56 [PATCH 0/11] NUMA CPU Reconfiguration using PRRN Nathan Fontenot
2013-03-09  3:59 ` [PATCH 1/11] Expose pseries devicetree_update() Nathan Fontenot
2013-03-14  8:49   ` Paul Mackerras
2013-03-09  4:00 ` [PATCH2/11] Add PRRN Event Handler Nathan Fontenot
2013-03-14  8:51   ` Paul Mackerras
2013-03-19 18:01     ` Nathan Fontenot
2013-03-09  4:01 ` [PATCH 3/11] Move architecture vector definitions to prom.h Nathan Fontenot
2013-03-14  8:52   ` Paul Mackerras
2013-03-09  4:02 ` Nathan Fontenot [this message]
2013-03-14  8:56   ` [PATCH 4/11] Add platform_has_feature() Paul Mackerras
2013-03-19 18:03     ` Nathan Fontenot
2013-03-14  8:59   ` Paul Mackerras
2013-03-19 18:05     ` Nathan Fontenot
2013-03-14 13:42   ` Michael Ellerman
2013-03-19 18:15     ` Nathan Fontenot
2013-03-22  3:56       ` Michael Ellerman
2013-03-09  4:03 ` [PATCH 5/11] Update numa.c to use platform_has_feature() Nathan Fontenot
2013-03-09  4:04 ` [PATCH 6/11] Update CPU maps Nathan Fontenot
2013-03-09  4:05 ` [PATCH 7/11] Use stop machine to update cpu maps Nathan Fontenot
2013-03-09  4:07 ` [PATCH 8/11] Update numa cpu vdso info Nathan Fontenot
2013-03-14  9:02   ` Paul Mackerras
2013-03-09  4:08 ` [PATCH 9/11] Re-enable Virtual Private Home Node capabilities Nathan Fontenot
2013-03-09  4:08 ` [PATCH 10/11] Enable PRRN Nathan Fontenot
2013-03-09  4:10 ` [PATCH 11/11] Add /proc interface to control topology updates Nathan Fontenot

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=513AB457.9000409@linux.vnet.ibm.com \
    --to=nfont@linux.vnet.ibm.com \
    --cc=linuxppc-dev@ozlabs.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.