Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1160206ybp; Fri, 4 Oct 2019 10:21:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqweYBk8KwmKPwEGu2JOYxOuSI1ou1NiCGVx4dNK9Lhaql0ldSbPfdRANf7qeb8nPrQWIQhF X-Received: by 2002:a05:6402:17a2:: with SMTP id j2mr16614613edy.121.1570209698227; Fri, 04 Oct 2019 10:21:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570209698; cv=none; d=google.com; s=arc-20160816; b=T9sf/NfzgEjbJ4DRoy/Lfh+D+n/T4msQc9iQ4k7NWm6W6hFNYBmFW6zXWJZaVBEkGA uVmjuB4Yeb0ZpbQoTFRvMxbbetPSfz7DzBZq1xE5fPPEkWMJsUEPOOmEVDg96SkdcrEN A4vWoHiLcKxFybqfYZ9IgLXRRQ163pDAzZO9rYQBcl2JVDj1MHLml4D2rg3CHpiC7Itv m/TvhHRLlmqMFycMGFt96zPvRG4LOeEffqGKA3RmnGgBmunIqRbBu/+jG9WfrhPPXSfS I8wgbqay8Gu+7HQtrg6yWRIZuUcYNMvZlHzBpvlFPKswCwMkdSKo3F5aLhs88FLXJQBM JQMw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=cAXc7+xJ79elQHAGWryfSV2S/vpsJHEQ/unRaRWrtz8=; b=kxApFxJw80Mv3inwnN1aKDATTJhfX+3b52qFDKYZBYbsu2vyvpFlKY56fKjEU0b2Oa le6ZQdWAmZgx4FkVXZ19DHL8OKYZRtGoRLEzixN4Di/nUA8aGPT0OtuNRmSPprbagpb3 nh5ABMsDtJXBqOAgkiwH3tSKUlwFrgF0ErBi0shljygc9GHX8hCI1yLKaU2RPT5gmwRJ 6jkWDmgMbn0ebgtZcmh2XYHf+WJ+Mn3YIF0MAdnqgj9aU8fEDR97+zTsdoJtemSyClpo 9NU6/Dabp+GSzuOCYE2CVLQwPuPzSaarL2fh8GR9BkCpvRYj5l0c53kbKHvE8hd0DcWi 8zJQ== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c28si3969257ede.3.2019.10.04.10.21.14; Fri, 04 Oct 2019 10:21:38 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387920AbfJDRS5 (ORCPT + 99 others); Fri, 4 Oct 2019 13:18:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50938 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387458AbfJDRS5 (ORCPT ); Fri, 4 Oct 2019 13:18:57 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0935910DCCA6; Fri, 4 Oct 2019 17:18:57 +0000 (UTC) Received: from prarit.bos.redhat.com (prarit-guest.khw1.lab.eng.bos.redhat.com [10.16.200.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7BB3419C69; Fri, 4 Oct 2019 17:18:56 +0000 (UTC) Subject: Re: [PATCH v2 3/7] intel-speed-select: Add check for CascadeLake-N models To: Srinivas Pandruvada , platform-driver-x86@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Andy Shevchenko References: <20191003121112.25870-1-prarit@redhat.com> <20191003121112.25870-4-prarit@redhat.com> From: Prarit Bhargava Message-ID: <8c831fa0-bb42-76bf-a624-12b063cf8e8b@redhat.com> Date: Fri, 4 Oct 2019 13:18:55 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.64]); Fri, 04 Oct 2019 17:18:57 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/4/19 1:15 PM, Srinivas Pandruvada wrote: > 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. Odd, I ran multiple tests and never hit the segfault :(. Thanks for fixing. P. > > 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(); >