All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Slaby <jslaby@suse.cz>
To: stable@vger.kernel.org
Cc: Dave Olson <olson@cumulusnetworks.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Jiri Slaby <jslaby@suse.cz>
Subject: [patch added to the 3.12 stable tree] powerpc: Fix missing L2 cache size in /sys/devices/system/cpu
Date: Mon,  4 May 2015 14:37:37 +0200	[thread overview]
Message-ID: <1430743082-6957-46-git-send-email-jslaby@suse.cz> (raw)
In-Reply-To: <1430743082-6957-1-git-send-email-jslaby@suse.cz>

From: Dave Olson <olson@cumulusnetworks.com>

This patch has been added to the 3.12 stable tree. If you have any
objections, please let us know.

===============

commit f7e9e358362557c3aa2c1ec47490f29fe880a09e upstream.

This problem appears to have been introduced in 2.6.29 by commit
93197a36a9c1 "Rewrite sysfs processor cache info code".

This caused lscpu to error out on at least e500v2 devices, eg:

  error: cannot open /sys/devices/system/cpu/cpu0/cache/index2/size: No such file or directory

Some embedded powerpc systems use cache-size in DTS for the unified L2
cache size, not d-cache-size, so we need to allow for both DTS names.
Added a new CACHE_TYPE_UNIFIED_D cache_type_info structure to handle
this.

Fixes: 93197a36a9c1 ("powerpc: Rewrite sysfs processor cache info code")
Signed-off-by: Dave Olson <olson@cumulusnetworks.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 arch/powerpc/kernel/cacheinfo.c | 44 +++++++++++++++++++++++++++++++----------
 1 file changed, 34 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/kernel/cacheinfo.c b/arch/powerpc/kernel/cacheinfo.c
index bfb82365bc7a..c26b9355156a 100644
--- a/arch/powerpc/kernel/cacheinfo.c
+++ b/arch/powerpc/kernel/cacheinfo.c
@@ -62,12 +62,22 @@ struct cache_type_info {
 };
 
 /* These are used to index the cache_type_info array. */
-#define CACHE_TYPE_UNIFIED     0
-#define CACHE_TYPE_INSTRUCTION 1
-#define CACHE_TYPE_DATA        2
+#define CACHE_TYPE_UNIFIED     0 /* cache-size, cache-block-size, etc. */
+#define CACHE_TYPE_UNIFIED_D   1 /* d-cache-size, d-cache-block-size, etc */
+#define CACHE_TYPE_INSTRUCTION 2
+#define CACHE_TYPE_DATA        3
 
 static const struct cache_type_info cache_type_info[] = {
 	{
+		/* Embedded systems that use cache-size, cache-block-size,
+		 * etc. for the Unified (typically L2) cache. */
+		.name            = "Unified",
+		.size_prop       = "cache-size",
+		.line_size_props = { "cache-line-size",
+				     "cache-block-size", },
+		.nr_sets_prop    = "cache-sets",
+	},
+	{
 		/* PowerPC Processor binding says the [di]-cache-*
 		 * must be equal on unified caches, so just use
 		 * d-cache properties. */
@@ -294,7 +304,8 @@ static struct cache *cache_find_first_sibling(struct cache *cache)
 {
 	struct cache *iter;
 
-	if (cache->type == CACHE_TYPE_UNIFIED)
+	if (cache->type == CACHE_TYPE_UNIFIED ||
+	    cache->type == CACHE_TYPE_UNIFIED_D)
 		return cache;
 
 	list_for_each_entry(iter, &cache_list, list)
@@ -325,16 +336,29 @@ static bool cache_node_is_unified(const struct device_node *np)
 	return of_get_property(np, "cache-unified", NULL);
 }
 
-static struct cache *cache_do_one_devnode_unified(struct device_node *node,
-						  int level)
+/*
+ * Unified caches can have two different sets of tags.  Most embedded
+ * use cache-size, etc. for the unified cache size, but open firmware systems
+ * use d-cache-size, etc.   Check on initialization for which type we have, and
+ * return the appropriate structure type.  Assume it's embedded if it isn't
+ * open firmware.  If it's yet a 3rd type, then there will be missing entries
+ * in /sys/devices/system/cpu/cpu0/cache/index2/, and this code will need
+ * to be extended further.
+ */
+static int cache_is_unified_d(const struct device_node *np)
 {
-	struct cache *cache;
+	return of_get_property(np,
+		cache_type_info[CACHE_TYPE_UNIFIED_D].size_prop, NULL) ?
+		CACHE_TYPE_UNIFIED_D : CACHE_TYPE_UNIFIED;
+}
 
+/*
+ */
+static struct cache *cache_do_one_devnode_unified(struct device_node *node, int level)
+{
 	pr_debug("creating L%d ucache for %s\n", level, node->full_name);
 
-	cache = new_cache(CACHE_TYPE_UNIFIED, level, node);
-
-	return cache;
+	return new_cache(cache_is_unified_d(node), level, node);
 }
 
 static struct cache *cache_do_one_devnode_split(struct device_node *node,
-- 
2.3.5


  parent reply	other threads:[~2015-05-04 12:38 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-04 12:36 [patch added to the 3.12 stable tree] drivers: parport: Kconfig: exclude arm64 for PARPORT_PC Jiri Slaby
2015-05-04 12:36 ` [patch added to the 3.12 stable tree] usb: gadget: composite: enable BESL support Jiri Slaby
2015-05-04 12:36 ` [patch added to the 3.12 stable tree] nosave: consolidate __nosave_{begin,end} in <asm/sections.h> Jiri Slaby
2015-05-04 12:36 ` [patch added to the 3.12 stable tree] KVM: s390: Zero out current VMDB of STSI before including level3 data Jiri Slaby
2015-05-04 12:36 ` [patch added to the 3.12 stable tree] s390/hibernate: fix save and restore of kernel text section Jiri Slaby
2015-05-04 12:36 ` [patch added to the 3.12 stable tree] KVM: use slowpath for cross page cached accesses Jiri Slaby
2015-05-04 12:36 ` [patch added to the 3.12 stable tree] MIPS: Hibernate: flush TLB entries earlier Jiri Slaby
2015-05-04 12:36 ` [patch added to the 3.12 stable tree] cdc-wdm: fix endianness bug in debug statements Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] spi: spidev: fix possible arithmetic overflow for multi-transfer message Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] compal-laptop: Check return value of power_supply_register Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] ring-buffer: Replace this_cpu_*() with __this_cpu_*() Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] power_supply: twl4030_madc: Check return value of power_supply_register Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] power_supply: lp8788-charger: Fix leaked power supply on probe fail Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] ARM: 8320/1: fix integer overflow in ELF_ET_DYN_BASE Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] ARM: S3C64XX: Use fixed IRQ bases to avoid conflicts on Cragganmore Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] ARM: dts: dove: Fix uart[23] reg property Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] usb: phy: Find the right match in devm_usb_phy_match Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] usb: define a generic USB_RESUME_TIMEOUT macro Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] usb: host: fusbh200: use new USB_RESUME_TIMEOUT Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] usb: host: uhci: " Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] usb: host: fotg210: " Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] usb: host: r8a66597: " Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] usb: host: isp116x: " Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] usb: host: xhci: " Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] usb: host: sl811: " Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] usb: dwc2: hcd: " Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] usb: core: hub: " Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] ALSA: emu10k1: don't deadlock in proc-functions Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] Input: elantech - fix absolute mode setting on some ASUS laptops Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] fs/binfmt_elf.c: fix bug in loading of PIE binaries Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] ptrace: fix race between ptrace_resume() and wait_task_stopped() Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] rtlwifi: rtl8192cu: Add new USB ID Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] rtlwifi: rtl8192cu: Add new device ID Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] arm64: vdso: fix build error when switching from LE to BE Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] ext4: make fsync to sync parent dir in no-journal for real this time Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] powerpc/perf: Cap 64bit userspace backtraces to PERF_MAX_STACK_DEPTH Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] tools lib traceevent kbuffer: Remove extra update to data pointer in PADDING Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] tools/power turbostat: Use $(CURDIR) instead of $(PWD) and add support for O= option in Makefile Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] UBI: account for bitflips in both the VID header and data Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] UBI: fix out of bounds write Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] UBI: initialize LEB number variable Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] UBI: fix check for "too many bytes" Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] scsi: storvsc: Fix a bug in copy_from_bounce_buffer() Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] target: Fix COMPARE_AND_WRITE with SG_TO_MEM_NOALLOC handling Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] Bluetooth: ath3k: Add support Atheros AR5B195 combo Mini PCIe card Jiri Slaby
2015-05-04 12:37 ` Jiri Slaby [this message]
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] ACPICA: Utilities: split IO address types from data type models Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] xtensa: xtfpga: fix hardware lockup caused by LCD driver Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] xtensa: provide __NR_sync_file_range2 instead of __NR_sync_file_range Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] xtensa: ISS: fix locking in TAP network adapter Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] gpio: mvebu: Fix mask/unmask managment per irq chip type Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] dm crypt: fix deadlock when async crypto algorithm returns -EBUSY Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] Drivers: hv: vmbus: Fix a bug in the error path in vmbus_open() Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] mvsas: fix panic on expander attached SATA devices Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] stk1160: Make sure current buffer is released Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] IB/core: disallow registering 0-sized memory region Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] IB/core: don't disallow registering region starting at 0x0 Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] IB/mlx4: Fix WQE LSO segment calculation Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] i2c: core: Export bus recovery functions Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] drm/radeon: fix doublescan modes (v2) Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] drm/i915: cope with large i2c transfers Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] RCU pathwalk breakage when running into a symlink overmounting something Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] ksoftirqd: Enable IRQs and call cond_resched() before poking RCU Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] e1000: add dummy allocator to fix race condition between mtu change and netpoll Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] lib: memzero_explicit: use barrier instead of OPTIMIZER_HIDE_VAR Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] wl18xx: show rx_frames_per_rates as an array as it really is Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] crypto: omap-aes - Fix support for unequal lengths Jiri Slaby
2015-05-04 12:37 ` [patch added to the 3.12 stable tree] C6x: time: Ensure consistency in __init Jiri Slaby
2015-05-04 12:38 ` [patch added to the 3.12 stable tree] memstick: mspro_block: add missing curly braces Jiri Slaby
2015-05-04 12:38 ` [patch added to the 3.12 stable tree] driver core: bus: Goto appropriate labels on failure in bus_add_device Jiri Slaby
2015-05-04 12:38 ` [patch added to the 3.12 stable tree] fs: take i_mutex during prepare_binprm for set[ug]id executables Jiri Slaby

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=1430743082-6957-46-git-send-email-jslaby@suse.cz \
    --to=jslaby@suse.cz \
    --cc=mpe@ellerman.id.au \
    --cc=olson@cumulusnetworks.com \
    --cc=stable@vger.kernel.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.