Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp880581pxf; Wed, 7 Apr 2021 14:02:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8PQIh0yhexqoNyqb6Q7QZtgO9Afqrdb0SUILULP0vGwyGN3MqTKeAlIsxKBEtagEhexaj X-Received: by 2002:a6b:d318:: with SMTP id s24mr4092846iob.89.1617829326700; Wed, 07 Apr 2021 14:02:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617829326; cv=none; d=google.com; s=arc-20160816; b=ZGWL5WEmObJHslLFlHkJItp9Kh1WglHZ9LgQnECx694m1tQ0M8BxsuXDy7oZUy1sdx BawlTgfZpmckTA21QdDZk1wugrGmd2+DtbigUnHTGtDwkcCg+vuXOCoAFPZPNdU3LugT xcz9q7N0PNaa8OUumtylqlz24fBHCw6RaCBdZscBMKZES8soqqmACWd785ezZtqP1CWJ 9gWxFWKJwOySsvScZeZpQq9gYAdiZkoETcq/oujzrpQaHUaQ2tYOPIBsj65cpP8FLhse fs05BoIklPKmIl0xWRCZeiaBal40v6QYwm21UZVbdDpGfEMmwdIWY83/8b5wpi+CYtVt N4Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date; bh=hM4udF+XeOK85Tr5KwzYlPKl2jge6+D/DGh2fz+6cHw=; b=VVHjQVcGyWBFYUYBUiuZ8fQgb5ylKuoc2h6HeRsdxM2ZMKSEpTHwDhv7zJtGMlIzxr XltZGbKvI2JPmuuXHtW/9XIbn7QW5U1iSBdnLNLcfqnwanh2VWRAp4Gbs4pLQ2P0SPwX C7uUnTkqY84TsO1bgI2BbV/q6v7FgKl+Z5yh8P37DlNQ0iowCuLGAgezL0//nijkPvea G17lbzz1m0bjIg/o9qPWdK1MwoObA9eIj91pu/5qXajFr6AS3g5Exz4WuJ2P9ynxBQdO apB/AS5XgWvm0sPiRq+2EDpj2oZMyVXM5UIqTfcOkyOLZdqcZ2buNDVvTWeuycb51CW2 fA5g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g2si544393ile.30.2021.04.07.14.01.53; Wed, 07 Apr 2021 14:02:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343675AbhDGNwt (ORCPT + 99 others); Wed, 7 Apr 2021 09:52:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238334AbhDGNwt (ORCPT ); Wed, 7 Apr 2021 09:52:49 -0400 Received: from angie.orcam.me.uk (angie.orcam.me.uk [IPv6:2001:4190:8020::4]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C38E1C061756; Wed, 7 Apr 2021 06:52:39 -0700 (PDT) Received: by angie.orcam.me.uk (Postfix, from userid 500) id B5A6F92009C; Wed, 7 Apr 2021 15:52:38 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id AEA7D92009B; Wed, 7 Apr 2021 15:52:38 +0200 (CEST) Date: Wed, 7 Apr 2021 15:52:38 +0200 (CEST) From: "Maciej W. Rozycki" To: Ilya Lipnitskiy cc: linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, liwei391@huawei.com, nbd@nbd.name, Thomas Bogendoerfer , yangtiezhu@loongson.cn Subject: Re: [PATCH v2] MIPS: add support for buggy MT7621S core detection In-Reply-To: <20210406042334.1318117-1-ilya.lipnitskiy@gmail.com> Message-ID: References: <20210406042334.1318117-1-ilya.lipnitskiy@gmail.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 5 Apr 2021, Ilya Lipnitskiy wrote: > diff --git a/arch/mips/include/asm/mips-cps.h b/arch/mips/include/asm/mips-cps.h > index fd43d876892e..9f495ffef2b7 100644 > --- a/arch/mips/include/asm/mips-cps.h > +++ b/arch/mips/include/asm/mips-cps.h > @@ -165,11 +167,29 @@ static inline uint64_t mips_cps_cluster_config(unsigned int cluster) > */ > static inline unsigned int mips_cps_numcores(unsigned int cluster) > { > + struct cpulaunch *launch; > + unsigned int ncores; > + > if (!mips_cm_present()) > return 0; > > /* Add one before masking to handle 0xff indicating no cores */ > - return (mips_cps_cluster_config(cluster) + 1) & CM_GCR_CONFIG_PCORES; > + ncores = (mips_cps_cluster_config(cluster) + 1) & CM_GCR_CONFIG_PCORES; > + > + if (IS_ENABLED(CONFIG_SOC_MT7621)) { > + /* > + * Ralink MT7621S SoC is single core, but the GCR_CONFIG method > + * always reports 2 cores. Check the second core's LAUNCH_FREADY > + * flag to detect if the second core is missing. This method > + * only works before the core has been started. > + */ > + launch = (struct cpulaunch *)CKSEG0ADDR(CPULAUNCH); > + launch += 2; /* MT7621 has 2 VPEs per core */ > + if (!(launch->flags & LAUNCH_FREADY)) > + ncores = 1; > + } > + > + return ncores; > } > > /** Much better to me, but please move the declaration of `launch' into the conditional block, which is the only place that uses it. Maciej