From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH v3 1/8] x86: clean up psr boot parameter parsing Date: Thu, 26 Mar 2015 20:42:22 +0000 Message-ID: <55146F2E.1080200@citrix.com> References: <1427373505-9303-1-git-send-email-chao.p.peng@linux.intel.com> <1427373505-9303-2-git-send-email-chao.p.peng@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1427373505-9303-2-git-send-email-chao.p.peng@linux.intel.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Chao Peng , xen-devel@lists.xen.org Cc: keir@xen.org, Ian.Campbell@citrix.com, stefano.stabellini@eu.citrix.com, Ian.Jackson@eu.citrix.com, will.auld@intel.com, JBeulich@suse.com, wei.liu2@citrix.com, dgdegra@tycho.nsa.gov List-Id: xen-devel@lists.xenproject.org On 26/03/15 12:38, Chao Peng wrote: > Change type of opt_psr from bool to int so more psr features can fit. > > Introduce a new routine to parse bool parameter so that both cmt and > future psr features like cat can use it. > > Signed-off-by: Chao Peng > --- > Changes in v3: > * Set "off" value explicity if requested. > --- > xen/arch/x86/psr.c | 40 ++++++++++++++++++++++++---------------- > 1 file changed, 24 insertions(+), 16 deletions(-) > > diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c > index 2ef83df..cfa534b 100644 > --- a/xen/arch/x86/psr.c > +++ b/xen/arch/x86/psr.c > @@ -26,11 +26,31 @@ struct psr_assoc { > }; > > struct psr_cmt *__read_mostly psr_cmt; > -static bool_t __initdata opt_psr; > +static unsigned int __initdata opt_psr; > static unsigned int __initdata opt_rmid_max = 255; > static uint64_t rmid_mask; > static DEFINE_PER_CPU(struct psr_assoc, psr_assoc); > > +static void __init parse_psr_bool(char* s, char* value, char* feature, int bit) * should be on the right hand side of the space for all char * parmaters. Each string should also be const, and bit should be unsigned to match opt_psr. Futhermore, it should probably be named mask, or you work with (1U << bit). > +{ > + if ( !strcmp(s, feature) ) > + { > + if ( !value ) > + opt_psr |= bit; > + else > + { > + int val_int = parse_bool(value); > + > + if ( val_int == 0 ) > + opt_psr &= ~bit; > + else if ( val_int == 1 ) > + opt_psr |= bit; > + else > + printk("PSR: unknown %s value: %s\n", feature, value); This all runs before the console has been set up. These printk()s go nowhere useful. I would just discard them. ~Andrew > + } > + } > +} > + > static void __init parse_psr_param(char *s) > { > char *ss, *val_str; > @@ -44,21 +64,9 @@ static void __init parse_psr_param(char *s) > if ( val_str ) > *val_str++ = '\0'; > > - if ( !strcmp(s, "cmt") ) > - { > - if ( !val_str ) > - opt_psr |= PSR_CMT; > - else > - { > - int val_int = parse_bool(val_str); > - if ( val_int == 1 ) > - opt_psr |= PSR_CMT; > - else if ( val_int != 0 ) > - printk("PSR: unknown cmt value: %s - CMT disabled!\n", > - val_str); > - } > - } > - else if ( val_str && !strcmp(s, "rmid_max") ) > + parse_psr_bool(s, val_str, "cmt", PSR_CMT); > + > + if ( val_str && !strcmp(s, "rmid_max") ) > opt_rmid_max = simple_strtoul(val_str, NULL, 0); > > s = ss + 1;