Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1154417ybp; Fri, 4 Oct 2019 10:17:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqwn5AMIKKbjsRJ4TEuId5nRgKndQ4N0DYegBIpFxujI73wX8xGTyhFepEA/7lv5orEIo5W9 X-Received: by 2002:a50:91d0:: with SMTP id h16mr16911550eda.152.1570209425074; Fri, 04 Oct 2019 10:17:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570209425; cv=none; d=google.com; s=arc-20160816; b=LhK/yyvR58JYxQSD86usvAerjm9eraolxgLfp3y6bp8WsI6OOlQ3Wdj/sUsR0SSSj4 YJYneIosTW8SXP09Mi7dnnkckJRwtoYTRsnQ/n1MrPBSMxyT8/aCcXv3KDZHgXYHAgAA AFVXvFNRDcPqGi5xbOqV0DJkqtbzisaWP/0R24kUMaUnW3c6i64ujm0Uczb6wGBH2x0Y l7F/q29qE+dwyODvpMjU3qWQvxuD0TNtA/bIbZXff31AiSi5RkkW+G+8dyCfzteCZLu/ EqkWXAy1mlgpPII2JfWFAscUlG9BiSmR/1lsCenIIFWZI9davMpNQwMYcmL5rtV+d/8H WgrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id; bh=UrDamDqToRZjzq/RMbnCIl1k5Tmh23sD1rdRZMw8dEI=; b=cHglSMRxVLIuwEApQ2+ZbiF5eO1ayY+u0J8XdB9f+bR3d9m3nb6c258J1it23xivsG BMfRXiaeEEQJwxAQaZ0FPpQR3I80bQjWs3C24y7Uwc8FaVqNBoT+TxZRv5yB46YPB1c2 Cmoz7K5e+4QSHK1KSs7fzxWlXkADhSHjTBzC162f4FJIptKuMRVtzccKLQI7tBc6RmGG eaaTDgip33dCDjgdNaPXEJgf6PxZeUTSRiQ34eX5MefK17Uhgo3jbMG+Wyl3S1C1tvUC j4/RdTpO3vE/MVv5wkMUbE2zwg148ulCTskkMFKwCdaR8a7sGCWn4clpXFO/u8+IIwB0 N1mQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d24si4037195ede.119.2019.10.04.10.16.40; Fri, 04 Oct 2019 10:17:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387744AbfJDRPW (ORCPT + 99 others); Fri, 4 Oct 2019 13:15:22 -0400 Received: from mga03.intel.com ([134.134.136.65]:37198 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387534AbfJDRPW (ORCPT ); Fri, 4 Oct 2019 13:15:22 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Oct 2019 10:15:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,257,1566889200"; d="scan'208";a="195621580" Received: from spandruv-desk.jf.intel.com ([10.54.75.31]) by orsmga003.jf.intel.com with ESMTP; 04 Oct 2019 10:15:21 -0700 Message-ID: Subject: Re: [PATCH v2 3/7] intel-speed-select: Add check for CascadeLake-N models From: Srinivas Pandruvada To: Prarit Bhargava , platform-driver-x86@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Andy Shevchenko Date: Fri, 04 Oct 2019 10:15:21 -0700 In-Reply-To: <20191003121112.25870-4-prarit@redhat.com> References: <20191003121112.25870-1-prarit@redhat.com> <20191003121112.25870-4-prarit@redhat.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 (3.28.5-3.fc28) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2019-10-03 at 08:11 -0400, Prarit Bhargava wrote: > Three CascadeLake-N models (6252N, 6230N, and 5218N) have SST-PBF > support. > > Return an error if the CascadeLake processor is not one of these > specific > models. > This patch sigfaults immediately on CLX. > v2: Add is_clx_n_platform() > > Signed-off-by: Prarit Bhargava > --- > .../x86/intel-speed-select/isst-config.c | 44 > ++++++++++++++++++- > 1 file changed, 42 insertions(+), 2 deletions(-) > > diff --git a/tools/power/x86/intel-speed-select/isst-config.c > b/tools/power/x86/intel-speed-select/isst-config.c > index f4a23678416e..734a7960458c 100644 > --- a/tools/power/x86/intel-speed-select/isst-config.c > +++ b/tools/power/x86/intel-speed-select/isst-config.c > @@ -23,6 +23,7 @@ static int debug_flag; > static FILE *outf; > > static int cpu_model; > +static int cpu_stepping; > > #define MAX_CPUS_IN_ONE_REQ 64 > static short max_target_cpus; > @@ -72,7 +73,16 @@ void debug_printf(const char *format, ...) > va_end(args); > } > > -static void update_cpu_model(void) > + > +int is_clx_n_platform(void) > +{ > + if (cpu_model == 0x55) > + if (cpu_stepping == 0x6 || cpu_stepping == 0x7) > + return 1; > + return 0; > +} > + > +static int update_cpu_model(void) > { > unsigned int ebx, ecx, edx; > unsigned int fms, family; > @@ -82,6 +92,34 @@ static void update_cpu_model(void) > cpu_model = (fms >> 4) & 0xf; > if (family == 6 || family == 0xf) > cpu_model += ((fms >> 16) & 0xf) << 4; > + > + cpu_stepping = fms & 0xf; > + > + /* only three CascadeLake-N models are supported */ > + if (is_clx_n_platform()) { > + FILE *fp; > + size_t n; > + char *line; Need n = 0 and *line = NULL here as getline() will require if it has to allocate. Anyway I will update the patchset and post after test. Thanks, Srinivas > + int ret = 1; > + > + fp = fopen("/proc/cpuinfo", "r"); > + if (!fp) > + err(-1, "cannot open /proc/cpuinfo\n"); > + > + while (getline(&line, &n, fp) > 0) { > + if (strstr(line, "model name")) { > + if (strstr(line, "6252N") || > + strstr(line, "6230N") || > + strstr(line, "5218N")) > + ret = 0; > + break; > + } > + } > + free(line); > + fclose(fp); > + return ret; > + } > + return 0; > } > > /* Open a file, and exit on failure */ > @@ -1889,7 +1927,9 @@ static void cmdline(int argc, char **argv) > fprintf(stderr, "Feature name and|or command not > specified\n"); > exit(0); > } > - update_cpu_model(); > + ret = update_cpu_model(); > + if (ret) > + err(-1, "Invalid CPU model (%d)\n", cpu_model); > printf("Intel(R) Speed Select Technology\n"); > printf("Executing on CPU model:%d[0x%x]\n", cpu_model, > cpu_model); > set_max_cpu_num();