From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Lezcano Subject: Re: [PATCH v9 2/4] arm64: arch_timer: Introduce a generic erratum handing mechanism for fsl-a008585 Date: Mon, 30 Jan 2017 22:59:27 +0100 Message-ID: <20170130215927.GK2206@mai> References: <1484832916-7248-1-git-send-email-dingtianhong@huawei.com> <1484832916-7248-3-git-send-email-dingtianhong@huawei.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <1484832916-7248-3-git-send-email-dingtianhong-hv44wF8Li93QT0dZR+AlfA@public.gmane.org> Sender: devicetree-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Ding Tianhong Cc: catalin.marinas-5wv7dgnIgG8@public.gmane.org, will.deacon-5wv7dgnIgG8@public.gmane.org, marc.zyngier-5wv7dgnIgG8@public.gmane.org, mark.rutland-5wv7dgnIgG8@public.gmane.org, oss-fOR+EgIDQEHk1uMJSBkQmQ@public.gmane.org, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, shawnguo-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, stuart.yoder-3arQi8VN3Tc@public.gmane.org, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linuxarm-hv44wF8Li93QT0dZR+AlfA@public.gmane.org List-Id: devicetree@vger.kernel.org On Thu, Jan 19, 2017 at 09:35:14PM +0800, Ding Tianhong wrote: > The workaround for hisilicon,161010101 will check the return value of the system counter > by different way, in order to distinguish with the fsl-a008585 workaround, introduce s/way/ways/ > a new generic erratum handing mechanism for fsl-a008585 and rename some functions. s/handing/handling/ > After discussion with Marc and Will, a consensus decision was made to remove the commandline > parameter for enabling fsl,erratum-a008585 erratum. Lines are more than 78 char large. > Signed-off-by: Ding Tianhong > --- > Documentation/admin-guide/kernel-parameters.txt | 9 -- > arch/arm64/include/asm/arch_timer.h | 38 +++------ > drivers/clocksource/Kconfig | 8 ++ > drivers/clocksource/arm_arch_timer.c | 105 ++++++++++++++---------- > 4 files changed, 84 insertions(+), 76 deletions(-) > > diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt > index 21e2d88..76437ad 100644 > --- a/Documentation/admin-guide/kernel-parameters.txt > +++ b/Documentation/admin-guide/kernel-parameters.txt > @@ -539,15 +539,6 @@ > loops can be debugged more effectively on production > systems. > > - clocksource.arm_arch_timer.fsl-a008585= > - [ARM64] > - Format: > - Enable/disable the workaround of Freescale/NXP > - erratum A-008585. This can be useful for KVM > - guests, if the guest device tree doesn't show the > - erratum. If unspecified, the workaround is > - enabled based on the device tree. > - > clearcpuid=BITNUM [X86] > Disable CPUID feature X for the kernel. See > arch/x86/include/asm/cpufeatures.h for the valid bit > diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/arch_timer.h > index eaa5bbe..b4b3400 100644 > --- a/arch/arm64/include/asm/arch_timer.h > +++ b/arch/arm64/include/asm/arch_timer.h > @@ -29,41 +29,29 @@ > > #include > > -#if IS_ENABLED(CONFIG_FSL_ERRATUM_A008585) > +#if IS_ENABLED(CONFIG_ARM_ARCH_TIMER_OOL_WORKAROUND) > extern struct static_key_false arch_timer_read_ool_enabled; > -#define needs_fsl_a008585_workaround() \ > +#define needs_unstable_timer_counter_workaround() \ > static_branch_unlikely(&arch_timer_read_ool_enabled) > #else > -#define needs_fsl_a008585_workaround() false > +#define needs_unstable_timer_counter_workaround() false > #endif > > -u32 __fsl_a008585_read_cntp_tval_el0(void); > -u32 __fsl_a008585_read_cntv_tval_el0(void); > -u64 __fsl_a008585_read_cntvct_el0(void); > > -/* > - * The number of retries is an arbitrary value well beyond the highest number > - * of iterations the loop has been observed to take. > - */ > -#define __fsl_a008585_read_reg(reg) ({ \ > - u64 _old, _new; \ > - int _retries = 200; \ > - \ > - do { \ > - _old = read_sysreg(reg); \ > - _new = read_sysreg(reg); \ > - _retries--; \ > - } while (unlikely(_old != _new) && _retries); \ > - \ > - WARN_ON_ONCE(!_retries); \ > - _new; \ > -}) > +struct arch_timer_erratum_workaround { > + const char *id; /* Indicate the Erratum ID */ > + u32 (*read_cntp_tval_el0)(void); > + u32 (*read_cntv_tval_el0)(void); > + u64 (*read_cntvct_el0)(void); > +}; > + > +extern const struct arch_timer_erratum_workaround *timer_unstable_counter_workaround; > > #define arch_timer_reg_read_stable(reg) \ > ({ \ > u64 _val; \ > - if (needs_fsl_a008585_workaround()) \ > - _val = __fsl_a008585_read_##reg(); \ > + if (needs_unstable_timer_counter_workaround()) \ > + _val = timer_unstable_counter_workaround->read_##reg();\ > else \ > _val = read_sysreg(reg); \ > _val; \ > diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig > index 4866f7a..6693e07 100644 > --- a/drivers/clocksource/Kconfig > +++ b/drivers/clocksource/Kconfig > @@ -325,10 +325,18 @@ config ARM_ARCH_TIMER_EVTSTREAM > This must be disabled for hardware validation purposes to detect any > hardware anomalies of missing events. > > +config ARM_ARCH_TIMER_OOL_WORKAROUND > + bool > + depends on FSL_ERRATUM_A008585 This dependency is not needed as well as the help text below because it is a silent option. -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html