Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp6012536ybe; Tue, 10 Sep 2019 12:08:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqzXWBsuRIV+fpcdFQkq8Te2fOAXlrYZU7KJyb+IQzNCkiZDficOHrPxiHDKdDLBV0JrLbP/ X-Received: by 2002:aa7:df81:: with SMTP id b1mr32097536edy.281.1568142515377; Tue, 10 Sep 2019 12:08:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568142515; cv=none; d=google.com; s=arc-20160816; b=m7dCIJlI1RfExh28dkZzJD7hLnfbCVReL6Mo5UG+zwjJ47AjrdRFNMvUUjf5ZOjJ9C h5TZdJA3jRlbpRh4cIdZt42YCje3gCSYcb75oYlNJJC/lCUFfOSEi0LzCrrJ1inETbLu 7Tsm4CkwZixogthnRmesylpGbH0pkPRWrXFpAHP58OgfeVyjrYBeAUGwBMAu8IKEAbnz uPIodX/5QEyHql4zgkvT+268YN/WK2KW7/fygg2oM7c/xLWJHy6/bQfuwDwz9jEHdw4r 1QYnmlduuZmF82jBUwltBwnh2M/Rwxx+vT1XymHc6gXUfLXJLnRjYN4VD8YP33GmlClY vWkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:subject:cc:to:from :date:user-agent:references:message-id; bh=42XYL3bEhW4zw8VZ49aNiI20oHEQdBNHTO1JqC4PFrU=; b=Uc74onc6+EP9lKSyY4trc8Wu88oCRUe16DeELtU34wpDhl/9wH4xsF/BS++HYFElkY gNWXF7ZlgAd2AW2V5UtajAKI5vyra25tV0suw+TQZU4dL/hUDnukIxoW1ggFApqLvBbF Twr0hV/dt8oNC/KhHe2xqbmWpZ2WxjcveojragOQp7BUNHFvRKuFUAURFLQlACQMTfAu mBilCgw3o2B1XJIMwRyXIAmGiZSjmCeduY/DXwdTFwPXpGkvMXoJTVHiL2fT6OfM7t0g PcwQmYJuTipjKewv/6UD6a+Nw6Spe5XpxonCa2kP1DQ07gy6dAIoXpm9zG+aysHRQAvX aJwA== 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=hpe.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id jr9si3194900ejb.118.2019.09.10.12.08.11; Tue, 10 Sep 2019 12:08:35 -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=hpe.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405656AbfIJPAT (ORCPT + 99 others); Tue, 10 Sep 2019 11:00:19 -0400 Received: from mx0b-002e3701.pphosted.com ([148.163.143.35]:38820 "EHLO mx0b-002e3701.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388133AbfIJPAO (ORCPT ); Tue, 10 Sep 2019 11:00:14 -0400 Received: from pps.filterd (m0134423.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x8AEpgGs018083; Tue, 10 Sep 2019 15:00:00 GMT Received: from g4t3427.houston.hpe.com (g4t3427.houston.hpe.com [15.241.140.73]) by mx0b-002e3701.pphosted.com with ESMTP id 2ux843n647-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 10 Sep 2019 14:59:59 +0000 Received: from stormcage.eag.rdlabs.hpecorp.net (stormcage.eag.rdlabs.hpecorp.net [128.162.236.70]) by g4t3427.houston.hpe.com (Postfix) with ESMTP id 3B01F66; Tue, 10 Sep 2019 14:59:59 +0000 (UTC) Received: by stormcage.eag.rdlabs.hpecorp.net (Postfix, from userid 5508) id A3E56201FCF1F; Tue, 10 Sep 2019 09:59:58 -0500 (CDT) Message-Id: <20190910145840.294981941@stormcage.eag.rdlabs.hpecorp.net> References: <20190910145839.604369497@stormcage.eag.rdlabs.hpecorp.net> User-Agent: quilt/0.46-1 Date: Tue, 10 Sep 2019 09:58:47 -0500 From: Mike Travis To: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Andrew Morton , Borislav Petkov , Christoph Hellwig Cc: Dimitri Sivanich , Russ Anderson , Hedi Berriche , Steve Wahl , Justin Ernst , x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V2 8/8] x86/platform/uv: Account for UV Hubless in is_uvX_hub Ops Content-Disposition: inline; filename=mod-is_uvX_hub X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.70,1.0.8 definitions=2019-09-10_10:2019-09-10,2019-09-10 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 spamscore=0 clxscore=1015 suspectscore=0 bulkscore=0 mlxlogscore=577 mlxscore=0 adultscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1906280000 definitions=main-1909100144 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The references in the is_uvX_hub() function uses the hub_info pointer which will be NULL when the system is hubless. This change avoids that NULL dereference. It is also an optimization in performance. Signed-off-by: Mike Travis Reviewed-by: Steve Wahl Reviewed-by: Dimitri Sivanich --- V2: Add WARNING that the is UVx supported defines will be removed. --- arch/x86/include/asm/uv/.uv_hub.h.swp |binary arch/x86/include/asm/uv/uv_hub.h | 61 ++++++++++++--------------------------- 1 file changed, 20 insertions(+), 41 deletions(-) Binary files linux.orig/arch/x86/include/asm/uv/.uv_hub.h.swp and linux/arch/x86/include/asm/uv/.uv_hub.h.swp differ --- linux.orig/arch/x86/include/asm/uv/uv_hub.h +++ linux/arch/x86/include/asm/uv/uv_hub.h @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -243,83 +244,61 @@ static inline int uv_hub_info_check(int #define UV4_HUB_REVISION_BASE 7 #define UV4A_HUB_REVISION_BASE 8 /* UV4 (fixed) rev 2 */ -#ifdef UV1_HUB_IS_SUPPORTED +/* WARNING: UVx_HUB_IS_SUPPORTED defines are deprecated and will be removed */ static inline int is_uv1_hub(void) { - return uv_hub_info->hub_revision < UV2_HUB_REVISION_BASE; -} +#ifdef UV1_HUB_IS_SUPPORTED + return is_uv_hubbed(uv(1)); #else -static inline int is_uv1_hub(void) -{ return 0; -} #endif +} -#ifdef UV2_HUB_IS_SUPPORTED static inline int is_uv2_hub(void) { - return ((uv_hub_info->hub_revision >= UV2_HUB_REVISION_BASE) && - (uv_hub_info->hub_revision < UV3_HUB_REVISION_BASE)); -} +#ifdef UV2_HUB_IS_SUPPORTED + return is_uv_hubbed(uv(2)); #else -static inline int is_uv2_hub(void) -{ return 0; -} #endif +} -#ifdef UV3_HUB_IS_SUPPORTED static inline int is_uv3_hub(void) { - return ((uv_hub_info->hub_revision >= UV3_HUB_REVISION_BASE) && - (uv_hub_info->hub_revision < UV4_HUB_REVISION_BASE)); -} +#ifdef UV3_HUB_IS_SUPPORTED + return is_uv_hubbed(uv(3)); #else -static inline int is_uv3_hub(void) -{ return 0; -} #endif +} /* First test "is UV4A", then "is UV4" */ -#ifdef UV4A_HUB_IS_SUPPORTED -static inline int is_uv4a_hub(void) -{ - return (uv_hub_info->hub_revision >= UV4A_HUB_REVISION_BASE); -} -#else static inline int is_uv4a_hub(void) { +#ifdef UV4A_HUB_IS_SUPPORTED + if (is_uv_hubbed(uv(4))) + return (uv_hub_info->hub_revision == UV4A_HUB_REVISION_BASE); +#endif return 0; } -#endif -#ifdef UV4_HUB_IS_SUPPORTED static inline int is_uv4_hub(void) { - return uv_hub_info->hub_revision >= UV4_HUB_REVISION_BASE; -} +#ifdef UV4_HUB_IS_SUPPORTED + return is_uv_hubbed(uv(4)); #else -static inline int is_uv4_hub(void) -{ return 0; -} #endif +} static inline int is_uvx_hub(void) { - if (uv_hub_info->hub_revision >= UV2_HUB_REVISION_BASE) - return uv_hub_info->hub_revision; - - return 0; + return (is_uv_hubbed(-2) >= uv(2)); } static inline int is_uv_hub(void) { -#ifdef UV1_HUB_IS_SUPPORTED - return uv_hub_info->hub_revision; -#endif - return is_uvx_hub(); + return is_uv1_hub() || is_uvx_hub(); } union uvh_apicid { --