From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933072AbcGEO4m (ORCPT ); Tue, 5 Jul 2016 10:56:42 -0400 Received: from foss.arm.com ([217.140.101.70]:53607 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933022AbcGEO4i (ORCPT ); Tue, 5 Jul 2016 10:56:38 -0400 Date: Tue, 5 Jul 2016 15:56:31 +0100 From: Will Deacon To: Suzuki K Poulose Cc: catalin.marinas@arm.com, mark.rutland@arm.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, steve.capper@linaro.org, stuart.monteith@linaro.org Subject: Re: [PATCH v8] arm64: cpuinfo: Expose MIDR_EL1 and REVIDR_EL1 to sysfs Message-ID: <20160705145631.GB28482@arm.com> References: <1467624020-29240-1-git-send-email-suzuki.poulose@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1467624020-29240-1-git-send-email-suzuki.poulose@arm.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 04, 2016 at 10:20:20AM +0100, Suzuki K Poulose wrote: > From: Steve Capper > > It can be useful for JIT software to be aware of MIDR_EL1 and > REVIDR_EL1 to ascertain the presence of any core errata that could > affect code generation. > > This patch exposes these registers through sysfs: > > /sys/devices/system/cpu/cpu$ID/regs/identification/midr_el1 > /sys/devices/system/cpu/cpu$ID/regs/identification/revidr_el1 > > where $ID is the cpu number. For big.LITTLE systems, one can have a > mixture of cores (e.g. Cortex A53 and Cortex A57), thus all CPUs need > to be enumerated. > > If the kernel does not have valid information to populate these entries > with, an empty string is returned to userspace. [...] > +static int cpuid_add_regs(int cpu) > +{ > + int rc; > + struct device *dev; > + struct cpuinfo_arm64 *info = &per_cpu(cpu_data, cpu); > + > + dev = get_cpu_device(cpu); > + if (dev) { > + rc = kobject_add(&info->kobj, &dev->kobj, "regs"); > + if (!rc) > + rc = sysfs_create_group(&info->kobj, &cpuregs_attr_group); If this call fails... > + } else { > + return -ENODEV; > + } > + > + return rc; > +} > + > +static int cpuid_remove_regs(int cpu) > +{ > + int rc = 0; > + struct device *dev; > + struct cpuinfo_arm64 *info = &per_cpu(cpu_data, cpu); > + > + dev = get_cpu_device(cpu); > + if (dev) { > + sysfs_remove_group(&info->kobj, &cpuregs_attr_group); ... then we still call sysfs_remove_group on the CPU_DEAD path. I think that just results in a WARN, but it would be good to double-check this (perhaps by forcing the failure path). Will