Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp707059pxb; Fri, 8 Jan 2021 16:33:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwIPbGDIJjhlTFNXjVhc4oCiBmZ4ui5JP//BwIOnEIGD9D6p1cesm2Em+NXV1Vir+NSR8oQ X-Received: by 2002:a17:906:cc8c:: with SMTP id oq12mr4347908ejb.419.1610152419601; Fri, 08 Jan 2021 16:33:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610152419; cv=none; d=google.com; s=arc-20160816; b=z/ZRGRHLthjijPuX1HKiTAY2eY8e2UchVtSwuDq/JIxaani1atkUjp2gHL7CQ0nw1o xmWTQFW3qh0//bnhQy22EVP02VEBo8Hg05EXiF9sDPPmejYQAnBzlDl0dcjz51gRsRXO q9PTVB06tJR0dWB7dV0c3Du4Q9M7MYcStk315KbGRGWIh65N9vo4AAeQWBj4ZHPX6v+K F6N8yUQsH7uEyiKAyJcOizNn8EmCfc5tfDQfs9+Ga0gKGfMdRF+f97u+t10xLrWg7nUT 1JYH1mDk1ktRYOq/GjSgtp2VkVsGYl/YBWrc9TX2ADDw3cY75BbHzBt3hy/0YCacsBKM 3ABw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dmarc-filter:sender:dkim-signature; bh=/UzpSUzQlXPBPQkn7Vw+DS3IUNoOjIx7BnHc/ReGtgc=; b=ZwDKcdmP2cxMZkEfzWd0iIr2VroJo6BUuYw+yZMUcDenX20ego8spZ8sDD3OX/iXhm +QF+dTO0dNJKUi8tFqnxBlZjPhiYIBxmBcaMVwT3QXaGo7eVSpcUVSqixd+i2Ao2J7Zm 5L7BoMmmqIckuP1S0HoRK7jr3AmRD5OJoMv3AG6vjaXXYoQ9KYBljCsNdgS7H2rMB25y QQ4ZxvzFuPuzrJUGlKDLuH7aXL/Rc4g/IechnC75RrEe4DAqnte8vXvNnYUM92IiMB9U KMlzc6X7Cr9hDN5+6EWCrjM8NAouz588lT0Xl+6kbtAv0XOQ3W25YcIKSCCNhcGPLWP2 JwxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=fhKOBEPo; 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 p9si4167737edq.97.2021.01.08.16.33.15; Fri, 08 Jan 2021 16:33:39 -0800 (PST) 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; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=fhKOBEPo; 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 S1726410AbhAIAan (ORCPT + 99 others); Fri, 8 Jan 2021 19:30:43 -0500 Received: from so254-31.mailgun.net ([198.61.254.31]:64204 "EHLO so254-31.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726195AbhAIAan (ORCPT ); Fri, 8 Jan 2021 19:30:43 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1610152224; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=/UzpSUzQlXPBPQkn7Vw+DS3IUNoOjIx7BnHc/ReGtgc=; b=fhKOBEPor+f+ubOO/lSgB47gDNE+fQQurL70LWQJxpoRy9ZoC/vgkHMkEdAt7fOfvpMgMqzh uLsHZEZ0CKWDhPRFSQHr6ypdlnMdVxvSqSB3pT/u8Wsqik9u5Qr4RBhnzTOmV9tvl/1MZeE9 BJM0YCicrxUt04ULrFKoUnLRDqw= X-Mailgun-Sending-Ip: 198.61.254.31 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n09.prod.us-east-1.postgun.com with SMTP id 5ff8f8f98fb3cda82f53733f (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Sat, 09 Jan 2021 00:29:45 GMT Sender: sramana=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 3C224C433ED; Sat, 9 Jan 2021 00:29:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from sramana-linux1.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sramana) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7818BC433ED; Sat, 9 Jan 2021 00:29:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 7818BC433ED Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=sramana@codeaurora.org From: Srinivas Ramana To: catalin.marinas@arm.com, will@kernel.org, pajay@qti.qualcomm.com Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-arm-msm@vger.kernel.org, Srinivas Ramana , Prasad Sodagudi Subject: [PATCH 2/3] arm64: cpufeature: Add a filter function to cpufeature Date: Fri, 8 Jan 2021 16:29:22 -0800 Message-Id: <1610152163-16554-3-git-send-email-sramana@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1610152163-16554-1-git-send-email-sramana@codeaurora.org> References: <1610152163-16554-1-git-send-email-sramana@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a filter function to cpufeature so that it can be used when dynamic control of the feature is required. Signed-off-by: Ajay Patil Signed-off-by: Prasad Sodagudi Signed-off-by: Srinivas Ramana --- arch/arm64/include/asm/cpufeature.h | 8 +++++++- arch/arm64/kernel/cpufeature.c | 15 ++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index 9a555809b89c..81a5c97d647d 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -61,6 +61,7 @@ struct arm64_ftr_bits { u8 shift; u8 width; s64 safe_val; /* safe value for FTR_EXACT features */ + s64 (*filter)(const struct arm64_ftr_bits *ftrp, s64 fval); }; /* @@ -566,7 +567,12 @@ cpuid_feature_extract_field(u64 features, int field, bool sign) static inline s64 arm64_ftr_value(const struct arm64_ftr_bits *ftrp, u64 val) { - return (s64)cpuid_feature_extract_field_width(val, ftrp->shift, ftrp->width, ftrp->sign); + s64 fval = (s64)cpuid_feature_extract_field_width(val, ftrp->shift, + ftrp->width, ftrp->sign); + + if (ftrp->filter) + fval = ftrp->filter(ftrp, fval); + return fval; } static inline bool id_aa64mmfr0_mixed_endian_el0(u64 mmfr0) diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 7ffb5f1d8b68..b2ffa9eaaaff 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -132,23 +132,28 @@ DEFINE_STATIC_KEY_ARRAY_FALSE(cpu_hwcap_keys, ARM64_NCAPS); EXPORT_SYMBOL(cpu_hwcap_keys); #define __ARM64_FTR_BITS(SIGNED, VISIBLE, STRICT, TYPE, SHIFT, WIDTH, SAFE_VAL) \ - { \ .sign = SIGNED, \ .visible = VISIBLE, \ .strict = STRICT, \ .type = TYPE, \ .shift = SHIFT, \ .width = WIDTH, \ - .safe_val = SAFE_VAL, \ - } + .safe_val = SAFE_VAL /* Define a feature with unsigned values */ #define ARM64_FTR_BITS(VISIBLE, STRICT, TYPE, SHIFT, WIDTH, SAFE_VAL) \ - __ARM64_FTR_BITS(FTR_UNSIGNED, VISIBLE, STRICT, TYPE, SHIFT, WIDTH, SAFE_VAL) + {__ARM64_FTR_BITS(FTR_UNSIGNED, VISIBLE, STRICT, TYPE, SHIFT, WIDTH, SAFE_VAL), } /* Define a feature with a signed value */ #define S_ARM64_FTR_BITS(VISIBLE, STRICT, TYPE, SHIFT, WIDTH, SAFE_VAL) \ - __ARM64_FTR_BITS(FTR_SIGNED, VISIBLE, STRICT, TYPE, SHIFT, WIDTH, SAFE_VAL) + {__ARM64_FTR_BITS(FTR_SIGNED, VISIBLE, STRICT, TYPE, SHIFT, WIDTH, SAFE_VAL), } + +/* Define a feature with a filter function to process the field value */ +#define FILTERED_ARM64_FTR_BITS(SIGNED, VISIBLE, STRICT, TYPE, SHIFT, WIDTH, SAFE_VAL, filter_fn) \ + { \ + __ARM64_FTR_BITS(SIGNED, VISIBLE, STRICT, TYPE, SHIFT, WIDTH, SAFE_VAL), \ + .filter = filter_fn, \ + } #define ARM64_FTR_END \ { \ -- 2.7.4