From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751582AbcERFPc (ORCPT ); Wed, 18 May 2016 01:15:32 -0400 Received: from us01smtprelay-2.synopsys.com ([198.182.47.9]:54178 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750925AbcERFPb (ORCPT ); Wed, 18 May 2016 01:15:31 -0400 Subject: Re: [PATCH] ARC: Troubleshoot execution of UP Linux on SMP HW and vice versa To: Alexey Brodkin , References: <1463519219-20500-1-git-send-email-abrodkin@synopsys.com> CC: Newsgroups: gmane.linux.kernel,gmane.linux.kernel.arc From: Vineet Gupta Message-ID: <573BFA63.1080307@synopsys.com> Date: Wed, 18 May 2016 10:45:15 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: <1463519219-20500-1-git-send-email-abrodkin@synopsys.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.12.197.158] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wednesday 18 May 2016 02:36 AM, Alexey Brodkin wrote: > ARC SMP hardware heavily relies on Interrupt Distribution Unit (IDU) > for all interrupts serving. And UP ARC hardware lacks this block. > > That leads to incompatibility between UP and SMP Linux builds. > > Even though UP build of Linux will run on SMP hardware at some > point strange behavior will appear. Very good example is serial port > will stop functioning once it switches from earlycon driver (which > doesn't use interrupts) to full-scale serial driver (that will rely > on interrupts). > > The same is applicable to reverse combination: SMP build won't > work on UP hardware and symptoms will be pretty much the same. This is not necessarily correct. I'm pretty sure that if u have right DT (despite embedded, if you have uboot provide a different one), SMP kernel will infact boot on UP hardware - and if not - we should actively try to achieve that. That is where world is moving: fwiw ARM64 kernel forces CONFIG_SMP because and doesn't even support UP anymore. > And so to save [especially newcomers] from spending hours in > frustration we're doing a check very early on boot if the kernel was > configured with CONFIG_ARC_MCIP (which is automatically selected as > a dependency of CONFIG_SMP) and in run-time we're seeing SMP-specific > register that holds a number of SMP cores. > > Signed-off-by: Alexey Brodkin > --- > arch/arc/kernel/setup.c | 12 ++++++++++++ ... > @@ -374,6 +375,8 @@ static inline int is_kernel(unsigned long addr) > > void __init setup_arch(char **cmdline_p) > { > + unsigned int num_cores; > + > #ifdef CONFIG_ARC_UBOOT_SUPPORT > /* make sure that uboot passed pointer to cmdline/dtb is valid */ > if (uboot_tag && is_kernel((unsigned long)uboot_arg)) > @@ -413,6 +416,15 @@ void __init setup_arch(char **cmdline_p) > if (machine_desc->init_early) > machine_desc->init_early(); > > + num_cores = (read_aux_reg(ARC_REG_MCIP_BCR) >> 16) & 0x3F; > +#ifdef CONFIG_ARC_MCIP > + if (!num_cores) > + panic("SMP kernel is run on a UP hardware!\n"); > +#else > + if (num_cores) > + panic("UP kernel is run on a SMP hardware!\n"); > +#endif This is ugly: if AXS platform has trouble booting with UP/SMP hw/sw mismatch, do that in platform early init code w/o littering platform agnostic code unless absolutely necessary. > + > smp_init_cpus(); > > setup_processor(); >