From patchwork Wed Jun 14 21:15:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 105584 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp488787qgd; Wed, 14 Jun 2017 14:17:47 -0700 (PDT) X-Received: by 10.98.1.72 with SMTP id 69mr1838675pfb.124.1497475066948; Wed, 14 Jun 2017 14:17:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497475066; cv=none; d=google.com; s=arc-20160816; b=yt2cruH9SDfapglhI0gzASIw0/EY4EBeJoD6wbq/nvjSDdJ0mCzdW/uvRmjIREoKm/ ZEWeOhOQEFgowZirJ9C0uRnIRjcRf2mPZoJG05AGFHMQckacBIKKpHBIUavnJx9J6YgL gz1tgxY2mSpLUWKVgzVFs1+J28b1Ornao3FeRApbxNGy2mt0FUiNPBum/xHw9KompAUW lpAMLsinvQ6uxNeWnEVoVAjDMtRDBREag4fVnzVJudMZQcbkR9YiW30+1ui6XLw7nJ7a tR6PoOQ1DFu+1sjZKohBxbjwkAdEXe3+0pxuzscJz7sAJX23H8QygVmt/U0UbEi0wpYC p0Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=Ixq9y875j8DWpWRu8nu4Dz5m50rdZiBUaxR2D5X06ng=; b=T21IW5tMAFQadGtAGMVPXefcIgqiSvPLAxvFcr9tvzUFxUEeyyI9Y64ZsR4tBpx5g5 EZFV0X3PVtCzxfyvqcXhhLpZxPfahk7lzPhDprSE3/PNjhwvqyG5bXzUE6vulGWzXMW2 TwiWeK8r/thQwkbfpsh7Z75mwb0oHq1x28Y6VV9MpxJtIS40b24ff5jrjEp9VTnBWepR DurrfjZvejb+Aijk35uMX8ldxObIaYlJvQpG7qsI2H5tC27q0CA5gBTV9S060pxKBIPj 6OZ2Nlo35/KkY2LgvDhhY1Lgi6Y85d8gQpKJpy2IFJ4t04QtBXJhxs0lm10OBRc/A4+7 hvnA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 66si6829plb.534.2017.06.14.14.17.46; Wed, 14 Jun 2017 14:17:46 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752562AbdFNVR3 (ORCPT + 25 others); Wed, 14 Jun 2017 17:17:29 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:50386 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752098AbdFNVR1 (ORCPT ); Wed, 14 Jun 2017 17:17:27 -0400 Received: from wuerfel.lan ([78.42.17.5]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.129]) with ESMTPA (Nemesis) id 0MBevm-1dVezy3EfO-00AVa6; Wed, 14 Jun 2017 23:17:16 +0200 From: Arnd Bergmann To: Andrew Morton Cc: kasan-dev@googlegroups.com, Dmitry Vyukov , Alexander Potapenko , Andrey Ryabinin , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Arend van Spriel , Arnd Bergmann Subject: [PATCH v2 01/11] compiler: introduce noinline_if_stackbloat annotation Date: Wed, 14 Jun 2017 23:15:36 +0200 Message-Id: <20170614211556.2062728-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170614211556.2062728-1-arnd@arndb.de> References: <20170614211556.2062728-1-arnd@arndb.de> X-Provags-ID: V03:K0:+tGQB6NdWJwGazOfEPEbnzEBysfXUiv3tsiUtkOrgh4wYL0j6tz VXfj77Q+NIQsx5lKmOFRxkg55grWJwVcOSgghlH5yZDoK8alDvHBCEeIha7iQxsMcOKYQHy Hff7KX73co/5PvwQ3TNr+l/jcQ9eAvR3MsmqAP0CmZLxkVd+MpR7istWgxluhpQcbbO36s9 8u0yjMZkCXBWVKELY3w1A== X-UI-Out-Filterresults: notjunk:1; V01:K0:pV5ohuZLQ88=:wHsGVCorTo1zc/648OWXVC 2nUvrt9H8kVN9UX2JvaICE2mu6zg8l6GGyDRfGUtLWrRrGnvFO1yJQmsTXI3YZFLxMsEwnm8I /JEIl5Yc31TeKqxYRldoc1jbyUd/eWqctWfpukiUVProrghpb0FzHcPd7fdo2+uAfUH6+xoBr 2ijKJ+OLSmhjGEQBHnWlwsnPRaL4HWVzJVfHi7QyGdtu1NPIQy2jgkda6KPtnxPzJxmYFxGFf DJBYZvIV3PDf69hHyZqT4n0PZTmudx9eJkzUQZYTmASUclkoHlPRUZg59+78MrDXOl/24/34J hD29fHGSyJPQ7NrTWDFqizN2kftHYMdWFBej3SedUeBQZp5E34d+Fr0TFllEUvt+hwSod8dXI ToIDdoY3/YtuzrBerXFaCPIihnKb0VMKmZ2CGPyfCBaWqEmtnGLToSem3KTOWli55FKpXIFLK kFKnQ01Jjks7CWKlh798M0UuePe87hsIG+Bf3K2ZCAGwUvMQjnPVezaDgg91Y8y07Cx44hB+s zN+YrCrPtw+I+XIQD6/yNygFA0h3QOI1d/MVjhpRiaojlhlufYLZn7IpxFMZMcx4VtK9ORDVg pASEcokPnzwTJPh7bqywQWDqPKhjhUMZrAZJgpwLLGA0fBYvv4n794gMFN8PTDkyN5Uxhb8K2 H+O6TrfvMv8B0KWIub0Cn7m8iWvgqYWUsa5XYIFMQzTF8A9AqPOEbe80eh7ISvvavSMk= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When CONFIG_KASAN is set, we can run into some code that uses incredible amounts of kernel stack: drivers/staging/dgnc/dgnc_neo.c:1056:1: error: the frame size of 11112 bytes is larger than 2048 bytes [-Werror=frame-larger-than=] drivers/media/i2c/cx25840/cx25840-core.c:4960:1: error: the frame size of 94000 bytes is larger than 2048 bytes [-Werror=frame-larger-than=] drivers/media/dvb-frontends/stv090x.c:3430:1: error: the frame size of 5312 bytes is larger than 3072 bytes [-Werror=frame-larger-than=] This happens when a sanitizer uses stack memory each time an inline function gets called. This introduces a new annotation for those functions to make them either 'inline' or 'noinline' depending on the CONFIG_KASAN symbol. Signed-off-by: Arnd Bergmann --- include/linux/compiler.h | 11 +++++++++++ 1 file changed, 11 insertions(+) -- 2.9.0 diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 219f82f3ec1a..a402c43c07d2 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -412,6 +412,17 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s */ #define noinline_for_stack noinline +/* + * CONFIG_KASAN can lead to extreme stack usage with certain patterns when + * one function gets inlined many times and each instance requires a stack + * ckeck. + */ +#ifdef CONFIG_KASAN +#define noinline_if_stackbloat noinline __maybe_unused +#else +#define noinline_if_stackbloat inline +#endif + #ifndef __always_inline #define __always_inline inline #endif From patchwork Wed Jun 14 21:15:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 105585 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp489009qgd; Wed, 14 Jun 2017 14:18:26 -0700 (PDT) X-Received: by 10.84.179.65 with SMTP id a59mr2151081plc.82.1497475106756; Wed, 14 Jun 2017 14:18:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497475106; cv=none; d=google.com; s=arc-20160816; b=dJKIVlOph366PkNq/ORPuZH1mow+3AFNmiPw9nrnbLjwvw379TWu6o++TbO1uaFEw4 Hgf3um1g6fgomSIrSSC8/rqtz7jm8auMyrcTKRRk9ZhBCa5QMKnWZaqhJyaAJj76T9Z1 gVQBHbNypxJL2XwHaiD5Ad8zRkN06OIYzpP0g5Ua8weTmgGvTBoVjrVvEruVq53l3p+Y JWo4A8QCIdkOPT1gZFSuAjiIi9MbQ33L4AIrRbM3Ondr88qL4iQtVjtmKvFM3hfAPs2X 6vva8f59jmF/KetSgugQfGA2Qz382d2ab0o+1vPmtBR4EtsxmL7bAqKvwT7FXZ4Y8jIC oqXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=10B0P9CK356snv41bf1z4MNmIwoWz/pAi1ycHzvQ3v8=; b=h2S6tRpmso+plpFmIVAqoS5r1Y67oRAoN6QRUSTjxOBM3vbgGq46Mjyn07RC0vAaea K7syV+ZX/O+XmTjTW+mLY+JhbZdKjuNwHzVllbtM1ONqP9WGMpHwidawxhiyFYb9uIXo Fc+4gmhc1cU1drnzHVdwOPQs2rOxJ9LyHTSn/C/u95HjScecfVrCFHyxhfcS9dJsLdKw 2U47F6aOjoirGvXcLHAwxAFnK827HqcG+vQMDmmboobNknDquNM1Lz2ARPy52NhLQqss oUyipVkZDUyGiOuTcwQujGPrc+lehmXF7HOu9gJT7ZHEeBa5xIsJ8OgNqbIckmFjcwrJ 8VbA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 66si6829plb.534.2017.06.14.14.18.26; Wed, 14 Jun 2017 14:18:26 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752589AbdFNVSY (ORCPT + 25 others); Wed, 14 Jun 2017 17:18:24 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:56740 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751760AbdFNVSV (ORCPT ); Wed, 14 Jun 2017 17:18:21 -0400 Received: from wuerfel.lan ([78.42.17.5]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.129]) with ESMTPA (Nemesis) id 0MPuXS-1dQDTh2FWc-004x8Y; Wed, 14 Jun 2017 23:17:43 +0200 From: Arnd Bergmann To: Andrew Morton Cc: kasan-dev@googlegroups.com, Dmitry Vyukov , Alexander Potapenko , Andrey Ryabinin , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Arend van Spriel , Arnd Bergmann , "David S. Miller" , Johannes Berg , Alexey Dobriyan Subject: [PATCH v2 02/11] netlink: mark nla_put_{u8, u16, u32} noinline_if_stackbloat Date: Wed, 14 Jun 2017 23:15:37 +0200 Message-Id: <20170614211556.2062728-3-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170614211556.2062728-1-arnd@arndb.de> References: <20170614211556.2062728-1-arnd@arndb.de> X-Provags-ID: V03:K0:TKL0Byza9vYr2CVMkrAqqlEgTOqakS66rWF8Ku06lRXzJ8SO7mt F9OlkuIBQFcF7rGD8LIlqKYprULL+EWj622o6/rmwEiHtc+7nQwMgnOwJhfMf9xxIROyrug GtOksf/kVCjqVMMPWHvedaOA+1sVIkLWNnY4sY9KHeO2gznOFXMwquruiddRS0sAlw0TPZW xYpDiV1JKkaIOYip4yHUw== X-UI-Out-Filterresults: notjunk:1; V01:K0:04/dfBfZEck=:TERwiQUKocfV2ZtyDpmN1N tLVsksWdo0pqIdX6zA+FMX3YZqqh2T1RI6CJtpF/4t61o8vJp4BNsc/xGvQ5V5ZgosslMjj2B rCY3qDqVqUqm4fRHKEi2zXa9a5BsLxyGWp/gdfQSpsJMaQr6PyBD9DbaKHCeQtgnid6wb4MKq 3um+wMhuLYHqOMddgzEJFUc8IALuPaF8E/DJQSFmrY2wZirNEHn7aUcJHr0iTfNU4x+I1O03V NNEGSsc9SAEFAnaEQ7lDfh/Twueh4muU9d1P7Tv4z2Ei+jLUIkqug7DNkmd3ma9Qw3XYGcuT8 knr5WdGPsatNIwv1I45GVMLe9vwsP/2/nqLBMFS76bg7So6w9T9xXxjkSvZpPxPqti5afVgMj vPsGdxikjGdTP5hUvE0yMvNaoODtMPszhIjkT+U8JrDzuqw357F1bhdyCXuy0IItibwAssqFW D4RfGNZKN6YUBJVmYcJbQ1GRSFGcyjKJqIbmAu944l3yCwm9lmu3w+fGT5LmMLO9LCSzNjTi4 0T939W7qAnwFzFpj5ZHXKpN93MLJIChx5EV6DpWG/zfdM3UBfysq7iP4SDPGUCmb5cy0IV0Eh snGRYXH6cmErdYMWcXjOJcv3KDoiAI6PTvidaDiDYp+9vEyjWr1Y1SYWnvlwqff7ndnM5dJck RxvWl4P5+zAOAu9Kn1qnz1N7LvI9OKnxX+gc/aEEuNW0lDAmhXM3wPBKHqAURRdUofWM= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When CONFIG_KASAN is enabled, the "--param asan-stack=1" causes rather large stack frames in some functions. This goes unnoticed normally because CONFIG_FRAME_WARN is disabled with CONFIG_KASAN by default as of commit 3f181b4d8652 ("lib/Kconfig.debug: disable -Wframe-larger-than warnings with KASAN=y"). The kernelci.org build bot however has the warning enabled and that led me to investigate it a little further, as every build produces these warnings: net/wireless/nl80211.c:4389:1: warning: the frame size of 2240 bytes is larger than 2048 bytes [-Wframe-larger-than=] net/wireless/nl80211.c:1895:1: warning: the frame size of 3776 bytes is larger than 2048 bytes [-Wframe-larger-than=] net/wireless/nl80211.c:1410:1: warning: the frame size of 2208 bytes is larger than 2048 bytes [-Wframe-larger-than=] net/bridge/br_netlink.c:1282:1: warning: the frame size of 2544 bytes is larger than 2048 bytes [-Wframe-larger-than=] With the new noinline_if_stackbloat annotation, we can avoid the problem when KASAN is enabled but not change anything otherwise. Cc: Andrey Ryabinin Cc: Alexander Potapenko Cc: Dmitry Vyukov Cc: kasan-dev@googlegroups.com Signed-off-by: Arnd Bergmann --- include/net/netlink.h | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) -- 2.9.0 diff --git a/include/net/netlink.h b/include/net/netlink.h index 01709172b3d3..24b4badd6eaf 100644 --- a/include/net/netlink.h +++ b/include/net/netlink.h @@ -766,7 +766,7 @@ static inline int nla_parse_nested(struct nlattr *tb[], int maxtype, * @attrtype: attribute type * @value: numeric value */ -static inline int nla_put_u8(struct sk_buff *skb, int attrtype, u8 value) +static noinline_if_stackbloat int nla_put_u8(struct sk_buff *skb, int attrtype, u8 value) { return nla_put(skb, attrtype, sizeof(u8), &value); } @@ -777,7 +777,7 @@ static inline int nla_put_u8(struct sk_buff *skb, int attrtype, u8 value) * @attrtype: attribute type * @value: numeric value */ -static inline int nla_put_u16(struct sk_buff *skb, int attrtype, u16 value) +static noinline_if_stackbloat int nla_put_u16(struct sk_buff *skb, int attrtype, u16 value) { return nla_put(skb, attrtype, sizeof(u16), &value); } @@ -788,7 +788,7 @@ static inline int nla_put_u16(struct sk_buff *skb, int attrtype, u16 value) * @attrtype: attribute type * @value: numeric value */ -static inline int nla_put_be16(struct sk_buff *skb, int attrtype, __be16 value) +static noinline_if_stackbloat int nla_put_be16(struct sk_buff *skb, int attrtype, __be16 value) { return nla_put(skb, attrtype, sizeof(__be16), &value); } @@ -799,7 +799,7 @@ static inline int nla_put_be16(struct sk_buff *skb, int attrtype, __be16 value) * @attrtype: attribute type * @value: numeric value */ -static inline int nla_put_net16(struct sk_buff *skb, int attrtype, __be16 value) +static noinline_if_stackbloat int nla_put_net16(struct sk_buff *skb, int attrtype, __be16 value) { return nla_put_be16(skb, attrtype | NLA_F_NET_BYTEORDER, value); } @@ -810,7 +810,7 @@ static inline int nla_put_net16(struct sk_buff *skb, int attrtype, __be16 value) * @attrtype: attribute type * @value: numeric value */ -static inline int nla_put_le16(struct sk_buff *skb, int attrtype, __le16 value) +static noinline_if_stackbloat int nla_put_le16(struct sk_buff *skb, int attrtype, __le16 value) { return nla_put(skb, attrtype, sizeof(__le16), &value); } @@ -821,7 +821,7 @@ static inline int nla_put_le16(struct sk_buff *skb, int attrtype, __le16 value) * @attrtype: attribute type * @value: numeric value */ -static inline int nla_put_u32(struct sk_buff *skb, int attrtype, u32 value) +static noinline_if_stackbloat int nla_put_u32(struct sk_buff *skb, int attrtype, u32 value) { return nla_put(skb, attrtype, sizeof(u32), &value); } @@ -832,7 +832,7 @@ static inline int nla_put_u32(struct sk_buff *skb, int attrtype, u32 value) * @attrtype: attribute type * @value: numeric value */ -static inline int nla_put_be32(struct sk_buff *skb, int attrtype, __be32 value) +static noinline_if_stackbloat int nla_put_be32(struct sk_buff *skb, int attrtype, __be32 value) { return nla_put(skb, attrtype, sizeof(__be32), &value); } @@ -843,7 +843,7 @@ static inline int nla_put_be32(struct sk_buff *skb, int attrtype, __be32 value) * @attrtype: attribute type * @value: numeric value */ -static inline int nla_put_net32(struct sk_buff *skb, int attrtype, __be32 value) +static noinline_if_stackbloat int nla_put_net32(struct sk_buff *skb, int attrtype, __be32 value) { return nla_put_be32(skb, attrtype | NLA_F_NET_BYTEORDER, value); } @@ -854,7 +854,7 @@ static inline int nla_put_net32(struct sk_buff *skb, int attrtype, __be32 value) * @attrtype: attribute type * @value: numeric value */ -static inline int nla_put_le32(struct sk_buff *skb, int attrtype, __le32 value) +static noinline_if_stackbloat int nla_put_le32(struct sk_buff *skb, int attrtype, __le32 value) { return nla_put(skb, attrtype, sizeof(__le32), &value); } @@ -866,7 +866,7 @@ static inline int nla_put_le32(struct sk_buff *skb, int attrtype, __le32 value) * @value: numeric value * @padattr: attribute type for the padding */ -static inline int nla_put_u64_64bit(struct sk_buff *skb, int attrtype, +static noinline_if_stackbloat int nla_put_u64_64bit(struct sk_buff *skb, int attrtype, u64 value, int padattr) { return nla_put_64bit(skb, attrtype, sizeof(u64), &value, padattr); @@ -879,7 +879,7 @@ static inline int nla_put_u64_64bit(struct sk_buff *skb, int attrtype, * @value: numeric value * @padattr: attribute type for the padding */ -static inline int nla_put_be64(struct sk_buff *skb, int attrtype, __be64 value, +static noinline_if_stackbloat int nla_put_be64(struct sk_buff *skb, int attrtype, __be64 value, int padattr) { return nla_put_64bit(skb, attrtype, sizeof(__be64), &value, padattr); @@ -892,7 +892,7 @@ static inline int nla_put_be64(struct sk_buff *skb, int attrtype, __be64 value, * @value: numeric value * @padattr: attribute type for the padding */ -static inline int nla_put_net64(struct sk_buff *skb, int attrtype, __be64 value, +static noinline_if_stackbloat int nla_put_net64(struct sk_buff *skb, int attrtype, __be64 value, int padattr) { return nla_put_be64(skb, attrtype | NLA_F_NET_BYTEORDER, value, @@ -906,7 +906,7 @@ static inline int nla_put_net64(struct sk_buff *skb, int attrtype, __be64 value, * @value: numeric value * @padattr: attribute type for the padding */ -static inline int nla_put_le64(struct sk_buff *skb, int attrtype, __le64 value, +static noinline_if_stackbloat int nla_put_le64(struct sk_buff *skb, int attrtype, __le64 value, int padattr) { return nla_put_64bit(skb, attrtype, sizeof(__le64), &value, padattr); @@ -918,7 +918,7 @@ static inline int nla_put_le64(struct sk_buff *skb, int attrtype, __le64 value, * @attrtype: attribute type * @value: numeric value */ -static inline int nla_put_s8(struct sk_buff *skb, int attrtype, s8 value) +static noinline_if_stackbloat int nla_put_s8(struct sk_buff *skb, int attrtype, s8 value) { return nla_put(skb, attrtype, sizeof(s8), &value); } @@ -929,7 +929,7 @@ static inline int nla_put_s8(struct sk_buff *skb, int attrtype, s8 value) * @attrtype: attribute type * @value: numeric value */ -static inline int nla_put_s16(struct sk_buff *skb, int attrtype, s16 value) +static noinline_if_stackbloat int nla_put_s16(struct sk_buff *skb, int attrtype, s16 value) { return nla_put(skb, attrtype, sizeof(s16), &value); } @@ -940,7 +940,7 @@ static inline int nla_put_s16(struct sk_buff *skb, int attrtype, s16 value) * @attrtype: attribute type * @value: numeric value */ -static inline int nla_put_s32(struct sk_buff *skb, int attrtype, s32 value) +static noinline_if_stackbloat int nla_put_s32(struct sk_buff *skb, int attrtype, s32 value) { return nla_put(skb, attrtype, sizeof(s32), &value); } @@ -952,7 +952,7 @@ static inline int nla_put_s32(struct sk_buff *skb, int attrtype, s32 value) * @value: numeric value * @padattr: attribute type for the padding */ -static inline int nla_put_s64(struct sk_buff *skb, int attrtype, s64 value, +static noinline_if_stackbloat int nla_put_s64(struct sk_buff *skb, int attrtype, s64 value, int padattr) { return nla_put_64bit(skb, attrtype, sizeof(s64), &value, padattr); @@ -987,7 +987,7 @@ static inline int nla_put_flag(struct sk_buff *skb, int attrtype) * @njiffies: number of jiffies to convert to msecs * @padattr: attribute type for the padding */ -static inline int nla_put_msecs(struct sk_buff *skb, int attrtype, +static noinline_if_stackbloat int nla_put_msecs(struct sk_buff *skb, int attrtype, unsigned long njiffies, int padattr) { u64 tmp = jiffies_to_msecs(njiffies); From patchwork Wed Jun 14 21:15:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 105588 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp489377qgd; Wed, 14 Jun 2017 14:19:32 -0700 (PDT) X-Received: by 10.101.89.2 with SMTP id f2mr1902822pgu.237.1497475172878; Wed, 14 Jun 2017 14:19:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497475172; cv=none; d=google.com; s=arc-20160816; b=ER3rtovXa5GYdq3JGs7R3PHpYp5ybYKGVsW6FkaJlVdq3HfAQJsQFkGeMx+ezG+Rt8 m5tMtyiNgdcwvcJpkAYOto8l11lAcDu5r+tIJlxjwJY+6Z7lNb/JeZGgwdtRQl10qv/8 v0T8j+igyBx2bWOMF6z1XgzNAkYwuaow89TQ0uDAYq2Z9nOAiXtZX/lJM7FlhejESBIj Wx+ss/SR7yGgH9jgV8Ke5GSGzZaJUztO5gvSbDCQb74zwo72pbidr1f5Vr2XUegSpvn3 nbTm5OYj9iY7/hMzZCJ+og7NCyDmRSFtUJQmc07CiHcxb2KewIdz5YLkP+1/UuENbuRV 23uA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=AQGiwZmMI40LJIyL+0wOUaWvktGACzMo7rVbHmaXNaA=; b=Y4PDDfSP4hEPuR+6OrIdUxYtlz8Fge+o8lB1XovjSZokrVFOwFy25+gW5QerIoSvOs Y/4roznERh/4BMam0z+s15dt/Qm3SGKVur06HEawf80bVCb6wKYgNeSSPzrdhfQ1/EDO 6BKUAtcnu8LXsd3BfFh5vmhJfuleN8wn3AlD+rnULNSPVp/KEQQWWv/Gm5Ndywv1R+rZ +/eFZCZChwpr4Fazh/tTdGMF8x3Slb5DDXAFBdEwEdHZ8jZxNy3wP2esONQerq6AvqR/ 8QL7IqOc/JYCBESJeieqG0ir4UVM05A2vbh1a8mwBaYJ8fIoyiK12D5b6ls5fJNvItCf iWBQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 203si692589pfc.406.2017.06.14.14.19.32; Wed, 14 Jun 2017 14:19:32 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752557AbdFNVTb (ORCPT + 25 others); Wed, 14 Jun 2017 17:19:31 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:57813 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752080AbdFNVT3 (ORCPT ); Wed, 14 Jun 2017 17:19:29 -0400 Received: from wuerfel.lan ([78.42.17.5]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.129]) with ESMTPA (Nemesis) id 0MbGQ7-1d6Bw42MCR-00KihD; Wed, 14 Jun 2017 23:18:15 +0200 From: Arnd Bergmann To: Andrew Morton Cc: kasan-dev@googlegroups.com, Dmitry Vyukov , Alexander Potapenko , Andrey Ryabinin , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Arend van Spriel , Arnd Bergmann , Greg Kroah-Hartman , Jiri Slaby , Samuel Thibault , Dmitry Torokhov Subject: [PATCH v2 03/11] tty: kbd: reduce stack size with KASAN Date: Wed, 14 Jun 2017 23:15:38 +0200 Message-Id: <20170614211556.2062728-4-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170614211556.2062728-1-arnd@arndb.de> References: <20170614211556.2062728-1-arnd@arndb.de> X-Provags-ID: V03:K0:obbGuMO3DfZICmHs6PMFQe5qb/AC5L2+g3P1WTGL1QfU8Rem7/A 6L7YNT4foR6C7EfAA51tIoQLuOvRx3160f3QqzWjWyNd0JvGA1lAjVk7dBCA7XkFq8JpBa5 4nfgGTD6uw8PhJPjfcfNflkS7QUUSgvdVCtIgvV7Fg3ew5HKc+RIr+aZM2rqrrqdwJxbEKY 93C2HEv311Fbt/G0Quc8Q== X-UI-Out-Filterresults: notjunk:1; V01:K0:ExKX8DQOxWI=:7X19Lo/0InpzIz1yu/QY+5 GSF721TJm1FFg+al+cbotBUrj+c2FoVVBy+7TrUQBUTQPDOSe/Ctpim6qkN3D1xcnv8HOgDfd oiHVrLg2whgLQqH1M2Qi5GGFbbFsAsBWwii/bksnnYuWXu7zwtQsrhCxiPkshGBq7Sfv7KWRJ X4fQstEbrii7AtgpG6/FWZbBqPg8VV4KCogna4BuHU6h7Spl8FWMkBQ3w0seQXFBEpklXcIp3 U6LiLjl39zqNyZndzic0go17ATKkph2yspsttSCREcJoibnuPI9AlsxYjv3Lb0koaqnfvcFqv 1+D/zZXfBYI5P5sWdBUG+ZL0BP5W8RgjncqDqatHlAncI/geF4Xoo8wnwif9QXvWbApph6aRk QPlmrBET+aKZPuC6ifhnB5DN86grGJdFCdi73VNiZ4OkLOEhTH4q+YDfK6LwtF8z6+/8+IwnX L8iV4mB3QvREAY11FCM0JyYnm7cjlIaed+3rMKvgIb1is6g57BlFonZFyAbC3MhBw0I+augjv sW6b3WQhKWPlD3U/lpdehWAc85+/JaN/XvHcZRxBBTkDYfY5L2rX+kt1cKHfDB/36nZKf0pTF cslrmE0OW7M2vtQfm5kOkd4KYRwyPD6ww+drgNaVLSt6hYFLSndDhRePtCrAc+2NvIfYJRSBb 55Q9lWtwa+ssSjIs01+0Qty4B3ms6Vlqs9NPbuvhnm5x4KHRnVYgn9gX82501Ealluzw= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As reported by kernelci, some functions in the VT code use significant amounts of kernel stack when local variables get inlined into the caller multiple times: drivers/tty/vt/keyboard.c: In function 'kbd_keycode': drivers/tty/vt/keyboard.c:1452:1: error: the frame size of 2240 bytes is larger than 2048 bytes [-Werror=frame-larger-than=] Annotating those functions as noinline_if_stackbloat prevents the inlining and reduces the overall stack usage in this driver. Signed-off-by: Arnd Bergmann --- drivers/tty/vt/keyboard.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.9.0 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c index f4166263bb3a..c0d111444a0e 100644 --- a/drivers/tty/vt/keyboard.c +++ b/drivers/tty/vt/keyboard.c @@ -301,13 +301,13 @@ int kbd_rate(struct kbd_repeat *rpt) /* * Helper Functions. */ -static void put_queue(struct vc_data *vc, int ch) +static noinline_if_stackbloat void put_queue(struct vc_data *vc, int ch) { tty_insert_flip_char(&vc->port, ch, 0); tty_schedule_flip(&vc->port); } -static void puts_queue(struct vc_data *vc, char *cp) +static noinline_if_stackbloat void puts_queue(struct vc_data *vc, char *cp) { while (*cp) { tty_insert_flip_char(&vc->port, *cp, 0); @@ -555,7 +555,7 @@ static void fn_inc_console(struct vc_data *vc) set_console(i); } -static void fn_send_intr(struct vc_data *vc) +static noinline_if_stackbloat void fn_send_intr(struct vc_data *vc) { tty_insert_flip_char(&vc->port, 0, TTY_BREAK); tty_schedule_flip(&vc->port); From patchwork Wed Jun 14 21:15:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 105586 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp489136qgd; Wed, 14 Jun 2017 14:18:48 -0700 (PDT) X-Received: by 10.98.212.73 with SMTP id u9mr1882089pfl.101.1497475128739; Wed, 14 Jun 2017 14:18:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497475128; cv=none; d=google.com; s=arc-20160816; b=h6f7LoseDMm6y/ovgnKGOMC24nE8Jmcjk7cYMqUMmgiCjterbii/5y+vHdf5Lh7Reg 2AT2RX6PFA09bCWTlStkyVjsBBUdqfSBrkJUIAKRXhlp2xqeIqCaEtwxPvoUxQuCG8lk YKL6zsq0yC2QA0KTtOpXpaJVMBDufDxfxKfTKlgEotqq1h9rVTzrJDPoSJ38If2fgZis zQA8qzZjpFRIDHZ1aY4cQygaNFGFAEhMZ30UyAtZvO2j6wN/lWPukoBwjqdrz+Q496EJ SQbrsbQAY6IGJ1e16GnZZkY0zw0EPViTgWR1590S7WUgcprIkPTgzwfAacUaUJTeQ914 +JyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=E6gM1g7artpJjtGiFQnuEHY10fTIOitMegO8wrxBefw=; b=QuSpbbZWNjObaM3Gm3OH9fdvA2Ijm8OCQ6pHHcfjbEC87hKag1JnP17Jg6kqngOjCN F8hjpdDQtFdn3JzlFfoC8kjsbXKJnS6vSBMgMMdxox8pyqGD5KYeA6yJsqQ/F53l07h7 AjQRI0ij3YOuFfvlNCg3bVwn49kOzKnzz1JtRiHKOqYBIB/av0SzIY8Wj/BmFQirwoU6 b+MXiHBrLrkMq1gVtHhJvTfjndQpnrN1/+U1MVxZw0mHoK6mPEtyn4BDsbjMXVDpi8iz gLQf+3zhiUI8Nqm08IO5vXdc+8n4lpz4DBfYYz2CCw0PDyrgk0l0btCtBths0BCaAT8/ RPZw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 203si692589pfc.406.2017.06.14.14.18.48; Wed, 14 Jun 2017 14:18:48 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752624AbdFNVSi (ORCPT + 25 others); Wed, 14 Jun 2017 17:18:38 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:56038 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752272AbdFNVSg (ORCPT ); Wed, 14 Jun 2017 17:18:36 -0400 Received: from wuerfel.lan ([78.42.17.5]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.129]) with ESMTPA (Nemesis) id 0MdziP-1dBA1W0rV7-00Pee9; Wed, 14 Jun 2017 23:18:27 +0200 From: Arnd Bergmann To: Andrew Morton Cc: kasan-dev@googlegroups.com, Dmitry Vyukov , Alexander Potapenko , Andrey Ryabinin , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Arend van Spriel , Arnd Bergmann , Jiri Pirko Subject: [PATCH v2 04/11] rocker: mark rocker_tlv_put_* functions as noinline_if_stackbloat Date: Wed, 14 Jun 2017 23:15:39 +0200 Message-Id: <20170614211556.2062728-5-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170614211556.2062728-1-arnd@arndb.de> References: <20170614211556.2062728-1-arnd@arndb.de> X-Provags-ID: V03:K0:N8MvLMXQqi4I7IGzAHKnT2mQXNtSNaxpj0ueBjiGqbtbekK27DU ugBTDlLXn5e7Tn7Om7CZfH3jz6rcG8xz1/eIX3Lb5txXuXOEWbOu5GQ8q3BrhxVVPae2MEP ejWN9p1BLhgnLQE4G5dd8862czPUVTZtxNjjc/wTweZoG7zNAVH42F+8ygNltBA8NoXrvjq 1aVsdcbdVzOW2dEW4647A== X-UI-Out-Filterresults: notjunk:1; V01:K0:ro9uji92QhY=:74EHqjgdAPiyN/h1FbNECO gVltqU3vPMQLAAI+14W7phUakyxTN8PSu+gv1kP6OOID4nDemyVIKo5royiSiOFQhFKJgO5tZ CLJt2+AASy4xA5rKisnq/sHSkpEYrwzGDu0kiI8mZFRTa4DujqXYEnA9ijZSlGN1E951oMz0w ESFAclC9wOAaqdAM3gUN4BgTgfYh38T7ogsk+wSCjLp40gxbw8ZYlL8Qa4SXdQBgXfxxatlQ9 grwRDycBrtJfbc3SmwaXd1D11zTO54F0NMw9T8mITSaUT4XPY+YmVSTkbrt6yXqu7yCkHhHoG vtVaWcv7G4HdzCb/aTyN9nj3KB8I87uoOf0g9je+sGF5HcCoJDsqoM/gT3OLloGI4y8ZtWdd6 vf5yKeFI981HPFpAHBfju+yecDCJ8kKg6Ej4GfVQZdzxzw3qeszy+1fkD5myiIv4msmZDdUiS mwunqEIqe8YALio3xwiH5W2goXEKhmzlJFDHbFRQsYV3ApiwluHdhs1gEFJ11lc8kOA6cHUq7 AwqB2s3hwpNs8ZIGUmqF1/4boHGWC9f9fQquOUUU+HGJUaQs8g2mHJ7jrnYWqWoxDPrUyL70x fxsEy4Lbo+grbT49jyvKwjUfdvhlnP0lGTH9nAL5rs1Z9MWpNMbyfH/yPzMrwq/8ojoBAOavj qsvDppt8Ar47KEt7wCaTG+JuPU0J0IqyUfJxOK4Hg+xCFTV9isK1fNateiYbUxjWscv4= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Inlining these functions creates lots of stack variables when KASAN is enabled, leading to this warning about potential stack overflow: drivers/net/ethernet/rocker/rocker_ofdpa.c: In function 'ofdpa_cmd_flow_tbl_add': drivers/net/ethernet/rocker/rocker_ofdpa.c:621:1: error: the frame size of 2752 bytes is larger than 1536 bytes [-Werror=frame-larger-than=] This marks all of them noinline_if_stackbloat, which solves the problem by keeping the redzone inside of the separate stack frames. Signed-off-by: Arnd Bergmann --- drivers/net/ethernet/rocker/rocker_tlv.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) -- 2.9.0 diff --git a/drivers/net/ethernet/rocker/rocker_tlv.h b/drivers/net/ethernet/rocker/rocker_tlv.h index a63ef82e7c72..8970a414eb5b 100644 --- a/drivers/net/ethernet/rocker/rocker_tlv.h +++ b/drivers/net/ethernet/rocker/rocker_tlv.h @@ -139,38 +139,38 @@ rocker_tlv_start(struct rocker_desc_info *desc_info) int rocker_tlv_put(struct rocker_desc_info *desc_info, int attrtype, int attrlen, const void *data); -static inline int rocker_tlv_put_u8(struct rocker_desc_info *desc_info, - int attrtype, u8 value) +static noinline_if_stackbloat int +rocker_tlv_put_u8(struct rocker_desc_info *desc_info, int attrtype, u8 value) { return rocker_tlv_put(desc_info, attrtype, sizeof(u8), &value); } -static inline int rocker_tlv_put_u16(struct rocker_desc_info *desc_info, - int attrtype, u16 value) +static noinline_if_stackbloat int +rocker_tlv_put_u16(struct rocker_desc_info *desc_info, int attrtype, u16 value) { return rocker_tlv_put(desc_info, attrtype, sizeof(u16), &value); } -static inline int rocker_tlv_put_be16(struct rocker_desc_info *desc_info, - int attrtype, __be16 value) +static noinline_if_stackbloat int +rocker_tlv_put_be16(struct rocker_desc_info *desc_info, int attrtype, __be16 value) { return rocker_tlv_put(desc_info, attrtype, sizeof(__be16), &value); } -static inline int rocker_tlv_put_u32(struct rocker_desc_info *desc_info, - int attrtype, u32 value) +static noinline_if_stackbloat int +rocker_tlv_put_u32(struct rocker_desc_info *desc_info, int attrtype, u32 value) { return rocker_tlv_put(desc_info, attrtype, sizeof(u32), &value); } -static inline int rocker_tlv_put_be32(struct rocker_desc_info *desc_info, - int attrtype, __be32 value) +static noinline_if_stackbloat int +rocker_tlv_put_be32(struct rocker_desc_info *desc_info, int attrtype, __be32 value) { return rocker_tlv_put(desc_info, attrtype, sizeof(__be32), &value); } -static inline int rocker_tlv_put_u64(struct rocker_desc_info *desc_info, - int attrtype, u64 value) +static noinline_if_stackbloat int +rocker_tlv_put_u64(struct rocker_desc_info *desc_info, int attrtype, u64 value) { return rocker_tlv_put(desc_info, attrtype, sizeof(u64), &value); } From patchwork Wed Jun 14 21:15:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 105589 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp489788qgd; Wed, 14 Jun 2017 14:20:42 -0700 (PDT) X-Received: by 10.84.134.162 with SMTP id 31mr2126383plh.57.1497475242757; Wed, 14 Jun 2017 14:20:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497475242; cv=none; d=google.com; s=arc-20160816; b=w13+wjnEwfDf1ET+2+y1S/V+KUSeX8FG9fvDo1bXxvUhLUUa9P8HkCjxovlIK+yXBw H9zFH79RZqeQFbTx1WnxVTuwjn0qrUaqmAutZmQy6d4FTZmWQlr+g36RKfRjJmKiJLzg jQWmR+wWxcEDDLYZdEbnXpmfDJBczlITy4ARsSPIdtFTCNuTyfGbwH1ZAvIL+XkTBE4O xS+hVICJ7JkzeZl3ZyIlyPH8x7y+Seo52Jit80Br+KqdFCDbs1A8sRa/WYKns0t14wrV tjWiYDAAgRyGTLp4abZ2e2iOfS6wkOKi/Yxde13kopBQU0g0ES9vri+j9CpL6QHMYWnI zBSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=1D0k+hRDLNtGoCL+QULqUEHHmQPV/uXCcvoTQVnxZQA=; b=SZ3aALbFw6Sq+6yxacTrVuuMbDWMiPXRn4dxITqNIq4tKhUGXBqp3ME4uA1FSDv4UW cf+IESHwKk4uBhDwQ3GGdtz8DkJ0b6IL/9KU62UMi8QIFrzB+NN61AOUuV7UEthuoCxu UhGiddVSrj7By9rOy3o0oD6cHnYJSMAe7nojC8T4OsvH9eXSPxaxyrw9lZYy3Uqack0+ eqjkKAfKyFu61poH9oP7CnTxWLrcbmw7QM7MhBMU3rMatvkkxobdMmMCZ91smapJkDot BjZPuvBBG5Asb+WV+mQj9tCW02g7I8YhbpDZyeSsR6AilbzmmmjTp6xmXE6yZxnyZDla YcJw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m66si768606pfc.39.2017.06.14.14.20.42; Wed, 14 Jun 2017 14:20:42 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752697AbdFNVUj (ORCPT + 25 others); Wed, 14 Jun 2017 17:20:39 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:52639 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752450AbdFNVUf (ORCPT ); Wed, 14 Jun 2017 17:20:35 -0400 Received: from wuerfel.lan ([78.42.17.5]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.129]) with ESMTPA (Nemesis) id 0MClOM-1dUZNt1c6U-009P7W; Wed, 14 Jun 2017 23:20:23 +0200 From: Arnd Bergmann To: Andrew Morton Cc: kasan-dev@googlegroups.com, Dmitry Vyukov , Alexander Potapenko , Andrey Ryabinin , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Arend van Spriel , Arnd Bergmann , Abylay Ospan , Mauro Carvalho Chehab , linux-media@vger.kernel.org Subject: [PATCH v2 06/11] dvb-frontends: reduce stack size in i2c access Date: Wed, 14 Jun 2017 23:15:41 +0200 Message-Id: <20170614211556.2062728-7-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170614211556.2062728-1-arnd@arndb.de> References: <20170614211556.2062728-1-arnd@arndb.de> X-Provags-ID: V03:K0:oQjCIwu8rH63ETbmuk62SFiD3wGkOcafQI93KgV78V4j1lyShx/ RKnSIL9GgNa1xLm9W95DSQTVOlSF7agWu4J907rTA6CRQp/Vqe6oR9ACQlUYp7WRo1KkZ2F k585ELq+DIWcdrYNme7Kx9quVLCip4ed9bis4ehXo28g8bjQbUNY+N/sr6sURpKwgoxk7RG iI2DWYefGZxULpzYNE0+g== X-UI-Out-Filterresults: notjunk:1; V01:K0:GsxPTKPYFk0=:84fQsmeTvEdbOvosPPKN36 cV+Gy1w5pjmXaSrqP9s6Wt4shm2MbPEBHBHkrYH3cvrzSpIR+vO2n0cbkCnapKA1vhhJzSADF gzQcZklPSl1JPyD/GkTkioXRsZIPS1EckLFq7GTyAezwR9xalRdeOSu2OGBRLhTfTdBvkCDui Ech535rCwy/yOf1WH0LRqCq2Od2RiscGhEByHoZBuPAsdasX0wXoDAJgx8Xr2+kZWlXrhxttT wbto7FHLD1dbInravqGtNNEQ6aZ5eQCcrit+lIlBobrb3SRYE9L+mIzkW4DcQa9xRBdz9dT9v K2I/DnLtQ5CfFrSjy0RvM4cmUz/Jh1iba2oxTh2Kg7aHPjNPWGQMRiEgSE9OyK//+ERWu1gds LfAffuPxI2LhpMh2jaahCIcJczcj9XNsm+hYSG4UB69MohmI6Tr7OP3J6zDZP2n3V7T9s/Yb3 5unf/qF+YmP09QHc/nK5AZIw0J4yxHkOR1vtXvxJoOdc2m4KzdWByb5A2aFQMgFRC/+jfE0Tw 4shLQhJcRYATD0FiRqE7GcZX36JLy3Uil/cHY849R4U6s4uGIUN2UXeCbPk531z7tM1I3i79J 0lSUAr2Co/8AfbfWz+2k17s4Uk9Qyo9RwMSDAOgTjQhCjRaae0RuUW2irR+QFYypocCMeHKFm bCrrsN2BPM5sNS+DjepmVKgEuDJ/YYDhh+eo+FHm2US6GrY+3jrDbW8USNXAmk1BqmCU= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A typical code fragment was copied across many dvb-frontend drivers and causes large stack frames when built with -fsanitize-address-use-after-scope, e.g. drivers/media/dvb-frontends/cxd2841er.c:3225:1: error: the frame size of 3992 bytes is larger than 3072 bytes [-Werror=frame-larger-than=] drivers/media/dvb-frontends/cxd2841er.c:3404:1: error: the frame size of 3136 bytes is larger than 3072 bytes [-Werror=frame-larger-than=] drivers/media/dvb-frontends/stv0367.c:3143:1: error: the frame size of 4016 bytes is larger than 3072 bytes [-Werror=frame-larger-than=] drivers/media/dvb-frontends/stv090x.c:3430:1: error: the frame size of 5312 bytes is larger than 3072 bytes [-Werror=frame-larger-than=] drivers/media/dvb-frontends/stv090x.c:4248:1: error: the frame size of 4872 bytes is larger than 3072 bytes [-Werror=frame-larger-than=] By marking the register access functions as noinline_if_stackbloat, we can completely avoid this problem. Signed-off-by: Arnd Bergmann --- drivers/media/dvb-frontends/ascot2e.c | 3 ++- drivers/media/dvb-frontends/cxd2841er.c | 4 ++-- drivers/media/dvb-frontends/drx39xyj/drxj.c | 14 +++++++------- drivers/media/dvb-frontends/helene.c | 4 ++-- drivers/media/dvb-frontends/horus3a.c | 2 +- drivers/media/dvb-frontends/itd1000.c | 2 +- drivers/media/dvb-frontends/mt312.c | 2 +- drivers/media/dvb-frontends/si2165.c | 14 +++++++------- drivers/media/dvb-frontends/stb0899_drv.c | 2 +- drivers/media/dvb-frontends/stb6100.c | 2 +- drivers/media/dvb-frontends/stv0367.c | 2 +- drivers/media/dvb-frontends/stv090x.c | 2 +- drivers/media/dvb-frontends/stv6110.c | 2 +- drivers/media/dvb-frontends/stv6110x.c | 2 +- drivers/media/dvb-frontends/tda8083.c | 2 +- drivers/media/dvb-frontends/zl10039.c | 2 +- 16 files changed, 31 insertions(+), 30 deletions(-) -- 2.9.0 Acked-by: Mauro Carvalho Chehab diff --git a/drivers/media/dvb-frontends/ascot2e.c b/drivers/media/dvb-frontends/ascot2e.c index 0ee0df53b91b..da1d1fc03c5e 100644 --- a/drivers/media/dvb-frontends/ascot2e.c +++ b/drivers/media/dvb-frontends/ascot2e.c @@ -153,7 +153,8 @@ static int ascot2e_write_regs(struct ascot2e_priv *priv, return 0; } -static int ascot2e_write_reg(struct ascot2e_priv *priv, u8 reg, u8 val) +static noinline_if_stackbloat int ascot2e_write_reg(struct ascot2e_priv *priv, + u8 reg, u8 val) { return ascot2e_write_regs(priv, reg, &val, 1); } diff --git a/drivers/media/dvb-frontends/cxd2841er.c b/drivers/media/dvb-frontends/cxd2841er.c index ce37dc2e89c7..6b851a948ce0 100644 --- a/drivers/media/dvb-frontends/cxd2841er.c +++ b/drivers/media/dvb-frontends/cxd2841er.c @@ -258,7 +258,7 @@ static int cxd2841er_write_regs(struct cxd2841er_priv *priv, return 0; } -static int cxd2841er_write_reg(struct cxd2841er_priv *priv, +static noinline_if_stackbloat int cxd2841er_write_reg(struct cxd2841er_priv *priv, u8 addr, u8 reg, u8 val) { return cxd2841er_write_regs(priv, addr, reg, &val, 1); @@ -306,7 +306,7 @@ static int cxd2841er_read_regs(struct cxd2841er_priv *priv, return 0; } -static int cxd2841er_read_reg(struct cxd2841er_priv *priv, +static noinline_if_stackbloat int cxd2841er_read_reg(struct cxd2841er_priv *priv, u8 addr, u8 reg, u8 *val) { return cxd2841er_read_regs(priv, addr, reg, val, 1); diff --git a/drivers/media/dvb-frontends/drx39xyj/drxj.c b/drivers/media/dvb-frontends/drx39xyj/drxj.c index 14040c915dbb..ec5b13ca630b 100644 --- a/drivers/media/dvb-frontends/drx39xyj/drxj.c +++ b/drivers/media/dvb-frontends/drx39xyj/drxj.c @@ -1516,7 +1516,7 @@ static int drxdap_fasi_read_block(struct i2c_device_addr *dev_addr, * ******************************/ -static int drxdap_fasi_read_reg16(struct i2c_device_addr *dev_addr, +static noinline_if_stackbloat int drxdap_fasi_read_reg16(struct i2c_device_addr *dev_addr, u32 addr, u16 *data, u32 flags) { @@ -1549,7 +1549,7 @@ static int drxdap_fasi_read_reg16(struct i2c_device_addr *dev_addr, * ******************************/ -static int drxdap_fasi_read_reg32(struct i2c_device_addr *dev_addr, +static noinline_if_stackbloat int drxdap_fasi_read_reg32(struct i2c_device_addr *dev_addr, u32 addr, u32 *data, u32 flags) { @@ -1722,7 +1722,7 @@ static int drxdap_fasi_write_block(struct i2c_device_addr *dev_addr, * ******************************/ -static int drxdap_fasi_write_reg16(struct i2c_device_addr *dev_addr, +static noinline_if_stackbloat int drxdap_fasi_write_reg16(struct i2c_device_addr *dev_addr, u32 addr, u16 data, u32 flags) { @@ -1795,7 +1795,7 @@ static int drxdap_fasi_read_modify_write_reg16(struct i2c_device_addr *dev_addr, * ******************************/ -static int drxdap_fasi_write_reg32(struct i2c_device_addr *dev_addr, +static noinline_if_stackbloat int drxdap_fasi_write_reg32(struct i2c_device_addr *dev_addr, u32 addr, u32 data, u32 flags) { @@ -2172,7 +2172,7 @@ int drxj_dap_atomic_read_write_block(struct i2c_device_addr *dev_addr, * \fn int drxj_dap_atomic_read_reg32() * \brief Atomic read of 32 bits words */ -static +static noinline_if_stackbloat int drxj_dap_atomic_read_reg32(struct i2c_device_addr *dev_addr, u32 addr, u32 *data, u32 flags) @@ -4192,7 +4192,7 @@ int drxj_dap_scu_atomic_read_write_block(struct i2c_device_addr *dev_addr, u32 a * \fn int DRXJ_DAP_AtomicReadReg16() * \brief Atomic read of 16 bits words */ -static +static noinline_if_stackbloat int drxj_dap_scu_atomic_read_reg16(struct i2c_device_addr *dev_addr, u32 addr, u16 *data, u32 flags) @@ -4220,7 +4220,7 @@ int drxj_dap_scu_atomic_read_reg16(struct i2c_device_addr *dev_addr, * \fn int drxj_dap_scu_atomic_write_reg16() * \brief Atomic read of 16 bits words */ -static +static noinline_if_stackbloat int drxj_dap_scu_atomic_write_reg16(struct i2c_device_addr *dev_addr, u32 addr, u16 data, u32 flags) diff --git a/drivers/media/dvb-frontends/helene.c b/drivers/media/dvb-frontends/helene.c index 4bf5a551ba40..849a18a837d0 100644 --- a/drivers/media/dvb-frontends/helene.c +++ b/drivers/media/dvb-frontends/helene.c @@ -329,7 +329,7 @@ static int helene_write_regs(struct helene_priv *priv, return 0; } -static int helene_write_reg(struct helene_priv *priv, u8 reg, u8 val) +static noinline_if_stackbloat int helene_write_reg(struct helene_priv *priv, u8 reg, u8 val) { return helene_write_regs(priv, reg, &val, 1); } @@ -374,7 +374,7 @@ static int helene_read_regs(struct helene_priv *priv, return 0; } -static int helene_read_reg(struct helene_priv *priv, u8 reg, u8 *val) +static noinline_if_stackbloat int helene_read_reg(struct helene_priv *priv, u8 reg, u8 *val) { return helene_read_regs(priv, reg, val, 1); } diff --git a/drivers/media/dvb-frontends/horus3a.c b/drivers/media/dvb-frontends/horus3a.c index 68d759c4c52e..f879af6c3188 100644 --- a/drivers/media/dvb-frontends/horus3a.c +++ b/drivers/media/dvb-frontends/horus3a.c @@ -87,7 +87,7 @@ static int horus3a_write_regs(struct horus3a_priv *priv, return 0; } -static int horus3a_write_reg(struct horus3a_priv *priv, u8 reg, u8 val) +static noinline_if_stackbloat int horus3a_write_reg(struct horus3a_priv *priv, u8 reg, u8 val) { return horus3a_write_regs(priv, reg, &val, 1); } diff --git a/drivers/media/dvb-frontends/itd1000.c b/drivers/media/dvb-frontends/itd1000.c index 5bb1e73a10b4..8bd6d04362cc 100644 --- a/drivers/media/dvb-frontends/itd1000.c +++ b/drivers/media/dvb-frontends/itd1000.c @@ -93,7 +93,7 @@ static int itd1000_read_reg(struct itd1000_state *state, u8 reg) return val; } -static inline int itd1000_write_reg(struct itd1000_state *state, u8 r, u8 v) +static noinline_if_stackbloat int itd1000_write_reg(struct itd1000_state *state, u8 r, u8 v) { int ret = itd1000_write_regs(state, r, &v, 1); state->shadow[r] = v; diff --git a/drivers/media/dvb-frontends/mt312.c b/drivers/media/dvb-frontends/mt312.c index 961b9a2508e0..d7a701da598a 100644 --- a/drivers/media/dvb-frontends/mt312.c +++ b/drivers/media/dvb-frontends/mt312.c @@ -139,7 +139,7 @@ static inline int mt312_readreg(struct mt312_state *state, return mt312_read(state, reg, val, 1); } -static inline int mt312_writereg(struct mt312_state *state, +static noinline_if_stackbloat int mt312_writereg(struct mt312_state *state, const enum mt312_reg_addr reg, const u8 val) { return mt312_write(state, reg, &val, 1); diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c index 528b82a5dd46..8b1ac134f9d8 100644 --- a/drivers/media/dvb-frontends/si2165.c +++ b/drivers/media/dvb-frontends/si2165.c @@ -140,7 +140,7 @@ static int si2165_read(struct si2165_state *state, return 0; } -static int si2165_readreg8(struct si2165_state *state, +static noinline_if_stackbloat int si2165_readreg8(struct si2165_state *state, const u16 reg, u8 *val) { unsigned int val_tmp; @@ -150,7 +150,7 @@ static int si2165_readreg8(struct si2165_state *state, return ret; } -static int si2165_readreg16(struct si2165_state *state, +static noinline_if_stackbloat int si2165_readreg16(struct si2165_state *state, const u16 reg, u16 *val) { u8 buf[2]; @@ -161,26 +161,26 @@ static int si2165_readreg16(struct si2165_state *state, return ret; } -static int si2165_writereg8(struct si2165_state *state, const u16 reg, u8 val) +static noinline_if_stackbloat int si2165_writereg8(struct si2165_state *state, const u16 reg, u8 val) { return regmap_write(state->regmap, reg, val); } -static int si2165_writereg16(struct si2165_state *state, const u16 reg, u16 val) +static noinline_if_stackbloat int si2165_writereg16(struct si2165_state *state, const u16 reg, u16 val) { u8 buf[2] = { val & 0xff, (val >> 8) & 0xff }; return si2165_write(state, reg, buf, 2); } -static int si2165_writereg24(struct si2165_state *state, const u16 reg, u32 val) +static noinline_if_stackbloat int si2165_writereg24(struct si2165_state *state, const u16 reg, u32 val) { u8 buf[3] = { val & 0xff, (val >> 8) & 0xff, (val >> 16) & 0xff }; return si2165_write(state, reg, buf, 3); } -static int si2165_writereg32(struct si2165_state *state, const u16 reg, u32 val) +static noinline_if_stackbloat int si2165_writereg32(struct si2165_state *state, const u16 reg, u32 val) { u8 buf[4] = { val & 0xff, @@ -191,7 +191,7 @@ static int si2165_writereg32(struct si2165_state *state, const u16 reg, u32 val) return si2165_write(state, reg, buf, 4); } -static int si2165_writereg_mask8(struct si2165_state *state, const u16 reg, +static noinline_if_stackbloat int si2165_writereg_mask8(struct si2165_state *state, const u16 reg, u8 val, u8 mask) { if (mask != 0xff) { diff --git a/drivers/media/dvb-frontends/stb0899_drv.c b/drivers/media/dvb-frontends/stb0899_drv.c index 02347598277a..9258085b8d35 100644 --- a/drivers/media/dvb-frontends/stb0899_drv.c +++ b/drivers/media/dvb-frontends/stb0899_drv.c @@ -537,7 +537,7 @@ int stb0899_write_regs(struct stb0899_state *state, unsigned int reg, u8 *data, return 0; } -int stb0899_write_reg(struct stb0899_state *state, unsigned int reg, u8 data) +noinline_if_stackbloat int stb0899_write_reg(struct stb0899_state *state, unsigned int reg, u8 data) { return stb0899_write_regs(state, reg, &data, 1); } diff --git a/drivers/media/dvb-frontends/stb6100.c b/drivers/media/dvb-frontends/stb6100.c index 17a955d0031b..675dffe1ef20 100644 --- a/drivers/media/dvb-frontends/stb6100.c +++ b/drivers/media/dvb-frontends/stb6100.c @@ -224,7 +224,7 @@ static int stb6100_write_reg_range(struct stb6100_state *state, u8 buf[], int st return 0; } -static int stb6100_write_reg(struct stb6100_state *state, u8 reg, u8 data) +static noinline_if_stackbloat int stb6100_write_reg(struct stb6100_state *state, u8 reg, u8 data) { if (unlikely(reg >= STB6100_NUMREGS)) { dprintk(verbose, FE_ERROR, 1, "Invalid register offset 0x%x", reg); diff --git a/drivers/media/dvb-frontends/stv0367.c b/drivers/media/dvb-frontends/stv0367.c index fd49c436a36d..2316c0bb3e21 100644 --- a/drivers/media/dvb-frontends/stv0367.c +++ b/drivers/media/dvb-frontends/stv0367.c @@ -798,7 +798,7 @@ int stv0367_writeregs(struct stv0367_state *state, u16 reg, u8 *data, int len) return (ret != 1) ? -EREMOTEIO : 0; } -static int stv0367_writereg(struct stv0367_state *state, u16 reg, u8 data) +static noinline_if_stackbloat int stv0367_writereg(struct stv0367_state *state, u16 reg, u8 data) { return stv0367_writeregs(state, reg, &data, 1); } diff --git a/drivers/media/dvb-frontends/stv090x.c b/drivers/media/dvb-frontends/stv090x.c index 7ef469c0c866..8afecc2e3637 100644 --- a/drivers/media/dvb-frontends/stv090x.c +++ b/drivers/media/dvb-frontends/stv090x.c @@ -753,7 +753,7 @@ static int stv090x_write_regs(struct stv090x_state *state, unsigned int reg, u8 return 0; } -static int stv090x_write_reg(struct stv090x_state *state, unsigned int reg, u8 data) +static noinline_if_stackbloat int stv090x_write_reg(struct stv090x_state *state, unsigned int reg, u8 data) { return stv090x_write_regs(state, reg, &data, 1); } diff --git a/drivers/media/dvb-frontends/stv6110.c b/drivers/media/dvb-frontends/stv6110.c index e4fd9c1b0560..ddef3a912615 100644 --- a/drivers/media/dvb-frontends/stv6110.c +++ b/drivers/media/dvb-frontends/stv6110.c @@ -137,7 +137,7 @@ static int stv6110_read_regs(struct dvb_frontend *fe, u8 regs[], return 0; } -static int stv6110_read_reg(struct dvb_frontend *fe, int start) +static noinline_if_stackbloat int stv6110_read_reg(struct dvb_frontend *fe, int start) { u8 buf[] = { 0 }; stv6110_read_regs(fe, buf, start, 1); diff --git a/drivers/media/dvb-frontends/stv6110x.c b/drivers/media/dvb-frontends/stv6110x.c index 66eba38f1014..80c7024971de 100644 --- a/drivers/media/dvb-frontends/stv6110x.c +++ b/drivers/media/dvb-frontends/stv6110x.c @@ -95,7 +95,7 @@ static int stv6110x_write_regs(struct stv6110x_state *stv6110x, int start, u8 da return 0; } -static int stv6110x_write_reg(struct stv6110x_state *stv6110x, u8 reg, u8 data) +static noinline_if_stackbloat int stv6110x_write_reg(struct stv6110x_state *stv6110x, u8 reg, u8 data) { return stv6110x_write_regs(stv6110x, reg, &data, 1); } diff --git a/drivers/media/dvb-frontends/tda8083.c b/drivers/media/dvb-frontends/tda8083.c index aa3200d3c352..646f22aab24e 100644 --- a/drivers/media/dvb-frontends/tda8083.c +++ b/drivers/media/dvb-frontends/tda8083.c @@ -88,7 +88,7 @@ static int tda8083_readregs (struct tda8083_state* state, u8 reg1, u8 *b, u8 len return ret == 2 ? 0 : -1; } -static inline u8 tda8083_readreg (struct tda8083_state* state, u8 reg) +static noinline_if_stackbloat u8 tda8083_readreg (struct tda8083_state* state, u8 reg) { u8 val; diff --git a/drivers/media/dvb-frontends/zl10039.c b/drivers/media/dvb-frontends/zl10039.c index 623355fc2666..0075725cb161 100644 --- a/drivers/media/dvb-frontends/zl10039.c +++ b/drivers/media/dvb-frontends/zl10039.c @@ -130,7 +130,7 @@ static inline int zl10039_readreg(struct zl10039_state *state, return zl10039_read(state, reg, val, 1); } -static inline int zl10039_writereg(struct zl10039_state *state, +static noinline_if_stackbloat int zl10039_writereg(struct zl10039_state *state, const enum zl10039_reg_addr reg, const u8 val) { From patchwork Wed Jun 14 21:15:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 105590 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp490097qgd; Wed, 14 Jun 2017 14:21:34 -0700 (PDT) X-Received: by 10.99.181.67 with SMTP id u3mr1942201pgo.89.1497475293999; Wed, 14 Jun 2017 14:21:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497475293; cv=none; d=google.com; s=arc-20160816; b=iYU0fzkjdDjHAaXh7CZ5SKJtxoZLGXJFi5fcdSnntvZ/xneooNOXm16xAOcMatDcBR 2bZwWH8+IW8X8OJxQ7qdXZjlmiGZ5x9wLnTJBTVKU6IIOT6AWLxqxgGXEz3Pb75waGod AJaPCY5KSUxNmrbCHpc9adfBmwWeITB4gDwbyMoggUh1fPzXJeJnjOsYlr5Byt19BdSw UqSW7rPXgwO/9WkWucP3/OeTQeV2bbBtawlKq4w2qUXKCpzkRuc4VMn1lZ4OkAqfouos CY40VR+isH/i56fMftOi9t1/t+cSoMjQM3NydiTcG5TwMRQV7Nk+zjmsw5PFiOP5SeDT 4e9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=mPgebXo3tUwXrrNvS7DgVzS7u4fsVq/wNdZAkwRSiNk=; b=CkPvIy2u+rigai7IluIjHV/Xdk+H/DFntMIES34DAtbyfUWOi/dFqBTNQbJcYeqopU zPuHTgF7zFTgOij/o3q2DfHdudWHpU4xV8GH31JE3KzJIr8HWtNPtXUrBf2hq36ByyQY ZeBYqiKq2MuM2coqJ6IzdqZr33wnFrebcQq4op/M9RoN/4MvmCxpQMuZdHoy8zH9WGEV h2iS3H2wCUILW03hODoZgbgtuCiKfymefugMFop+RyTNPmOu7bZWivzGlEJw1rZ1k+rY RZZ+hLYotdamsxXH5dFiOA4EGLX9nwnND9XznWcSfY8HrAHQtH0a+6xFHkM/2gWoesP9 wKEA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m125si752146pfc.59.2017.06.14.14.21.33; Wed, 14 Jun 2017 14:21:33 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752711AbdFNVVK (ORCPT + 25 others); Wed, 14 Jun 2017 17:21:10 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:58098 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752080AbdFNVVH (ORCPT ); Wed, 14 Jun 2017 17:21:07 -0400 Received: from wuerfel.lan ([78.42.17.5]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.129]) with ESMTPA (Nemesis) id 0Mh1yy-1d88iD2Dbs-00M4HU; Wed, 14 Jun 2017 23:20:53 +0200 From: Arnd Bergmann To: Andrew Morton Cc: kasan-dev@googlegroups.com, Dmitry Vyukov , Alexander Potapenko , Andrey Ryabinin , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Arend van Spriel , Arnd Bergmann , Mauro Carvalho Chehab , Max Kellermann , linux-media@vger.kernel.org Subject: [PATCH v2 07/11] r820t: mark register functions as noinline_if_stackbloat Date: Wed, 14 Jun 2017 23:15:42 +0200 Message-Id: <20170614211556.2062728-8-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170614211556.2062728-1-arnd@arndb.de> References: <20170614211556.2062728-1-arnd@arndb.de> X-Provags-ID: V03:K0:W+qASqLecJdV3n3QI71L+Fbnp+HBFaIA3Q1KKOUu75zpaVCI+wB 8VdInnNjpj1sPaHoiqRE8uG7HHfTszWKX5zxozpMc8sN/G/Y80LWoW2xzpf4/u1n2L/x8vw RI0JgT5B7vksICgrP/Qv6Q6pgKWyTRXh0hqCVDSvnixX7JKOCNu/H+jqDr0D2chiFagY15n x0pMygzZ6jj+/djbP9GJg== X-UI-Out-Filterresults: notjunk:1; V01:K0:8UUQ1BzEd/I=:KnY9wf0pJvHTGM4fxS70K5 gtTgwjrlsLKk6enaWx+QMycml4Z8JjSDCi+tBzBiAiXztgkHiCrFPVZ7n+sn1w6xgEZ06odBQ 6qmPaUUrghPjYZi1efZ7xoo8zBq7LF77yYw2ot4eQOYfE+yVQo02DBG+XLuZ4OK47OjE4yX30 fU2YR+NwO4GjhM43H4wugLPzx7rOr1XePl7yVfoQK0h/Igpdw2qHyDRDVtQahWhX5m6kYJXB4 zgU1/l8ZiAzA2JB8LGUEYXLJnmK0DRZ1x9Km3voJqOVPATUjXQ+FYe3n3MCJW9s63iX+LrTSz ZajvVM1c523fIBuFwR5e+1htILzp2mlCPTDplWOpA2Bk1hLGn9AIfRXCbvr9yxYzkff6EqGjF 3APHGvTEgBTyvp8EsP+4BuRK5nTUQlNFLHmWbDaYsvKa78GW04cNVma/tvpgHudHBfNT1POlA ZgPg5GPKV1erKJFveWMQdcn0d4670CNifrQm7jYZE9iRen1nZwTxo+8Y144T6sZSQtKJ5uxHS 1uFJEfjGfNHeHFgUuFHRpAlUhCvU3oTLRba0ZUFgpm8dw4mNv+BUDDqDHTKT2lXW56h2Mw4jv yPsHtz0h5EJu9peHWKbFdYZBq4h3v8cED4UfIXKBzKy7XJnBark5dzE1cN1h5mA/rPAK3OhwN Ebpy1dQEwpBleLsWv1Pw4YhlBiHr1K9c9xDw99hb+OLXaUj0FoErIqo456H4C0sk3hvg= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With KASAN, we get an overly long stack frame due to inlining the register access function: drivers/media/tuners/r820t.c: In function 'generic_set_freq.isra.7': drivers/media/tuners/r820t.c:1334:1: error: the frame size of 2880 bytes is larger than 2048 bytes [-Werror=frame-larger-than=] An earlier patch I tried used an open-coded r820t_write_reg() implementation that may have been more efficent, while this version simply adds the annotation, which has a lower risk for regressions. Signed-off-by: Arnd Bergmann --- drivers/media/tuners/r820t.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.9.0 diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c index ba80376a3b86..a26d0eb64555 100644 --- a/drivers/media/tuners/r820t.c +++ b/drivers/media/tuners/r820t.c @@ -396,7 +396,7 @@ static int r820t_write(struct r820t_priv *priv, u8 reg, const u8 *val, return 0; } -static int r820t_write_reg(struct r820t_priv *priv, u8 reg, u8 val) +static noinline_if_stackbloat int r820t_write_reg(struct r820t_priv *priv, u8 reg, u8 val) { return r820t_write(priv, reg, &val, 1); } @@ -411,7 +411,7 @@ static int r820t_read_cache_reg(struct r820t_priv *priv, int reg) return -EINVAL; } -static int r820t_write_reg_mask(struct r820t_priv *priv, u8 reg, u8 val, +static noinline_if_stackbloat int r820t_write_reg_mask(struct r820t_priv *priv, u8 reg, u8 val, u8 bit_mask) { int rc = r820t_read_cache_reg(priv, reg); From patchwork Wed Jun 14 21:15:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 105591 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp490101qgd; Wed, 14 Jun 2017 14:21:34 -0700 (PDT) X-Received: by 10.99.178.16 with SMTP id x16mr1905542pge.220.1497475294832; Wed, 14 Jun 2017 14:21:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497475294; cv=none; d=google.com; s=arc-20160816; b=SSsrIqx4zMTSX3YYUbdDssxWLy30D8kxQo8jmQLz/s4yel9fjMh6y4HlWApZivxfz0 lGP+XQkVyWUnGTWY/drFTnmbqvcylVuAnU4M9kcZjYe0uoZtKC0rN2qNZtEFUwFXr/XP 2xHkt1LlQfNxVaecGx/UptxY2t3hXskrJO9QLLFozRk76EM4bPJ7GLr3PXj2Mk4ljBuR zUdwgTgGopNxLTgp1O7ZIfDOqmw5Jqri3S4ZTAKwQSiGQrD27+zp4Yxf6doM/n6vq0w8 6mSGl8Ztrrs8hxEE6ViGQLXF1l4TvAh1uKmy+Za9awF1RbwGXzvvweTXHjFj88ACBV+O oocA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=FGK0tPY7ij0xOMyBn8KhaGfsKMRpKgdhwYj9acH/2Bg=; b=CiZiaj/LFgOsaf2w40PzzgNRr2YqYP9Lnp7WYGYyZZq/N0loovOIM02x4LDxksFAIj Xh8YoJGKhtW8UP3SDuMIOPTbExOleoOHTHZY2X9EZlhYrwdv7pOZ7fvyqjaLR61ljypo 8pXaFsJA/r4hiH+tdf39w7RvMFIX5wLTV1rMNZ36aTRiAuHzAZr8HR97NtEW+MBRNf/7 pJPpedM9hLrnCwnKiLPBSZDDhNkZT5Ldtz3T1LTdfPwseZjPMfFJ55cagGLiclz9B4rB KuvJVSdFqpVXQEdmF+EOPmL0DxFItyQP0vxdIBReJyGddQkPMX9/Jqp5wSesusXzPKQN IbJw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m125si752146pfc.59.2017.06.14.14.21.34; Wed, 14 Jun 2017 14:21:34 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752736AbdFNVVW (ORCPT + 25 others); Wed, 14 Jun 2017 17:21:22 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:59747 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752080AbdFNVVS (ORCPT ); Wed, 14 Jun 2017 17:21:18 -0400 Received: from wuerfel.lan ([78.42.17.5]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.129]) with ESMTPA (Nemesis) id 0M2U69-1ddc1I0j0H-00sOkr; Wed, 14 Jun 2017 23:21:09 +0200 From: Arnd Bergmann To: Andrew Morton Cc: kasan-dev@googlegroups.com, Dmitry Vyukov , Alexander Potapenko , Andrey Ryabinin , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Arend van Spriel , Arnd Bergmann , Franky Lin , Hante Meuleman , Kalle Valo , linux-wireless@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com Subject: [PATCH v2 08/11] brcmsmac: make some local variables 'static const' to reduce stack size Date: Wed, 14 Jun 2017 23:15:43 +0200 Message-Id: <20170614211556.2062728-9-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170614211556.2062728-1-arnd@arndb.de> References: <20170614211556.2062728-1-arnd@arndb.de> X-Provags-ID: V03:K0:ZKdc7CtfLABHOh7pY9ApBCUmKAm3G7K+UEuviYnVVXrY0AUPAD+ AxX/zF/2gCUNlBd5sYJM/n+KO9BxnOdX+SUzZfKGAu9nBrZi+SsNfUWUddig+ukN1oF934V U/nI6q4qA2oaBXq3did68w0s66Ks1d2TgmAOhu57DtKY4X5BOx2YCDHdx7pz9soAbQ/9UcK n0O/t73OpD6U/ix9n2LKw== X-UI-Out-Filterresults: notjunk:1; V01:K0:qo8tV988ge0=:73nPFQCkUzeAKMytx1h/6E juktomBjUV58NQZk3XHzxBLuyUIHnIxC+B/geYyzEnkZfdhadBXEB+qQhtOI4FHPNHOE7UHnN 2UWA2wXUVzrki7TUFCQDr8r5hcLahcoA63R9DeIe6yjuOfa7YjUnghEkH4/KS9hmA1ona4vpP hW33oaW9LpEZF0chbK0B6ZZrj4Lsyxokxm0jLhhL+i4dWJoR+J2ljrIu2UPLtYrKTE7u9xky1 cW7fd0czNLyJ6jMr7oNk17HFJRnWoMjDCaV4Y8gAHXmGXj5sdUEzgZKvQtJfCIWZqBtyVPRzq 3nc5fMrygPZxws62udyyLRUXtoWhy80O3amnO3HRRRpkK4HaUDGfj2CvvJVcrvprnz9RaYcs7 ekVB/vZGx6eeNUSO4SIuQyZ1L0ghvcZjzqY5by/UtulEMVXYDczUQ2Hwo0e3TKtVrtYUcbeyj x8ycIi/PrMLB0u/w17rVWq15T30TuUfARtkLXa6ZXTBEdm8JXDovHJ/TswWyNkGDv4RuGYW+Z fqRAPaVih18WuzXAsi++tbr+FybDDYmLNMmpqlEjd1arjZSfSHhUOcHaCMiIBsd1tjDcIiUxP 1grfEFCx/S7g2FDLbejHeUZDLn2LTAE7Tvl77OfrkGnTZtjFaRPLGZaJzQEDbRRvXzz1vJ++y 0jesxC6AUsMsAuEXnUv/4tabh1nPwIt+Xvf/GI+4enKKT21+FLue2vyyaQnyNTmw2AGg= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With KASAN and a couple of other patches applied, this driver is one of the few remaining ones that actually use more than 2048 bytes of kernel stack: broadcom/brcm80211/brcmsmac/phy/phy_n.c: In function 'wlc_phy_workarounds_nphy_gainctrl': broadcom/brcm80211/brcmsmac/phy/phy_n.c:16065:1: warning: the frame size of 3264 bytes is larger than 2048 bytes [-Wframe-larger-than=] broadcom/brcm80211/brcmsmac/phy/phy_n.c: In function 'wlc_phy_workarounds_nphy': broadcom/brcm80211/brcmsmac/phy/phy_n.c:17138:1: warning: the frame size of 2864 bytes is larger than 2048 bytes [-Wframe-larger-than=] Here, I'm reducing the stack size by marking as many local variables as 'static const' as I can without changing the actual code. Acked-by: Arend van Spriel Signed-off-by: Arnd Bergmann --- .../broadcom/brcm80211/brcmsmac/phy/phy_n.c | 197 ++++++++++----------- 1 file changed, 97 insertions(+), 100 deletions(-) -- 2.9.0 diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c index b3aab2fe96eb..ef685465f80a 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c @@ -14764,8 +14764,8 @@ static void wlc_phy_ipa_restore_tx_digi_filts_nphy(struct brcms_phy *pi) } static void -wlc_phy_set_rfseq_nphy(struct brcms_phy *pi, u8 cmd, u8 *events, u8 *dlys, - u8 len) +wlc_phy_set_rfseq_nphy(struct brcms_phy *pi, u8 cmd, const u8 *events, + const u8 *dlys, u8 len) { u32 t1_offset, t2_offset; u8 ctr; @@ -15240,16 +15240,16 @@ static void wlc_phy_workarounds_nphy_gainctrl_2057_rev5(struct brcms_phy *pi) static void wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi) { u16 currband; - s8 lna1G_gain_db_rev7[] = { 9, 14, 19, 24 }; - s8 *lna1_gain_db = NULL; - s8 *lna1_gain_db_2 = NULL; - s8 *lna2_gain_db = NULL; - s8 tiaA_gain_db_rev7[] = { -9, -6, -3, 0, 3, 3, 3, 3, 3, 3 }; - s8 *tia_gain_db; - s8 tiaA_gainbits_rev7[] = { 0, 1, 2, 3, 4, 4, 4, 4, 4, 4 }; - s8 *tia_gainbits; - u16 rfseqA_init_gain_rev7[] = { 0x624f, 0x624f }; - u16 *rfseq_init_gain; + static const s8 lna1G_gain_db_rev7[] = { 9, 14, 19, 24 }; + const s8 *lna1_gain_db = NULL; + const s8 *lna1_gain_db_2 = NULL; + const s8 *lna2_gain_db = NULL; + static const s8 tiaA_gain_db_rev7[] = { -9, -6, -3, 0, 3, 3, 3, 3, 3, 3 }; + const s8 *tia_gain_db; + static const s8 tiaA_gainbits_rev7[] = { 0, 1, 2, 3, 4, 4, 4, 4, 4, 4 }; + const s8 *tia_gainbits; + static const u16 rfseqA_init_gain_rev7[] = { 0x624f, 0x624f }; + const u16 *rfseq_init_gain; u16 init_gaincode; u16 clip1hi_gaincode; u16 clip1md_gaincode = 0; @@ -15310,10 +15310,9 @@ static void wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi) if ((freq <= 5080) || (freq == 5825)) { - s8 lna1A_gain_db_rev7[] = { 11, 16, 20, 24 }; - s8 lna1A_gain_db_2_rev7[] = { - 11, 17, 22, 25}; - s8 lna2A_gain_db_rev7[] = { -1, 6, 10, 14 }; + static const s8 lna1A_gain_db_rev7[] = { 11, 16, 20, 24 }; + static const s8 lna1A_gain_db_2_rev7[] = { 11, 17, 22, 25}; + static const s8 lna2A_gain_db_rev7[] = { -1, 6, 10, 14 }; crsminu_th = 0x3e; lna1_gain_db = lna1A_gain_db_rev7; @@ -15321,10 +15320,9 @@ static void wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi) lna2_gain_db = lna2A_gain_db_rev7; } else if ((freq >= 5500) && (freq <= 5700)) { - s8 lna1A_gain_db_rev7[] = { 11, 17, 21, 25 }; - s8 lna1A_gain_db_2_rev7[] = { - 12, 18, 22, 26}; - s8 lna2A_gain_db_rev7[] = { 1, 8, 12, 16 }; + static const s8 lna1A_gain_db_rev7[] = { 11, 17, 21, 25 }; + static const s8 lna1A_gain_db_2_rev7[] = { 12, 18, 22, 26}; + static const s8 lna2A_gain_db_rev7[] = { 1, 8, 12, 16 }; crsminu_th = 0x45; clip1md_gaincode_B = 0x14; @@ -15335,10 +15333,9 @@ static void wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi) lna2_gain_db = lna2A_gain_db_rev7; } else { - s8 lna1A_gain_db_rev7[] = { 12, 18, 22, 26 }; - s8 lna1A_gain_db_2_rev7[] = { - 12, 18, 22, 26}; - s8 lna2A_gain_db_rev7[] = { -1, 6, 10, 14 }; + static const s8 lna1A_gain_db_rev7[] = { 12, 18, 22, 26 }; + static const s8 lna1A_gain_db_2_rev7[] = { 12, 18, 22, 26}; + static const s8 lna2A_gain_db_rev7[] = { -1, 6, 10, 14 }; crsminu_th = 0x41; lna1_gain_db = lna1A_gain_db_rev7; @@ -15450,65 +15447,65 @@ static void wlc_phy_workarounds_nphy_gainctrl(struct brcms_phy *pi) NPHY_RFSEQ_CMD_CLR_HIQ_DIS, NPHY_RFSEQ_CMD_SET_HPF_BW }; - u8 rfseq_updategainu_dlys[] = { 10, 30, 1 }; - s8 lna1G_gain_db[] = { 7, 11, 16, 23 }; - s8 lna1G_gain_db_rev4[] = { 8, 12, 17, 25 }; - s8 lna1G_gain_db_rev5[] = { 9, 13, 18, 26 }; - s8 lna1G_gain_db_rev6[] = { 8, 13, 18, 25 }; - s8 lna1G_gain_db_rev6_224B0[] = { 10, 14, 19, 27 }; - s8 lna1A_gain_db[] = { 7, 11, 17, 23 }; - s8 lna1A_gain_db_rev4[] = { 8, 12, 18, 23 }; - s8 lna1A_gain_db_rev5[] = { 6, 10, 16, 21 }; - s8 lna1A_gain_db_rev6[] = { 6, 10, 16, 21 }; - s8 *lna1_gain_db = NULL; - s8 lna2G_gain_db[] = { -5, 6, 10, 14 }; - s8 lna2G_gain_db_rev5[] = { -3, 7, 11, 16 }; - s8 lna2G_gain_db_rev6[] = { -5, 6, 10, 14 }; - s8 lna2G_gain_db_rev6_224B0[] = { -5, 6, 10, 15 }; - s8 lna2A_gain_db[] = { -6, 2, 6, 10 }; - s8 lna2A_gain_db_rev4[] = { -5, 2, 6, 10 }; - s8 lna2A_gain_db_rev5[] = { -7, 0, 4, 8 }; - s8 lna2A_gain_db_rev6[] = { -7, 0, 4, 8 }; - s8 *lna2_gain_db = NULL; - s8 tiaG_gain_db[] = { + static const u8 rfseq_updategainu_dlys[] = { 10, 30, 1 }; + static const s8 lna1G_gain_db[] = { 7, 11, 16, 23 }; + static const s8 lna1G_gain_db_rev4[] = { 8, 12, 17, 25 }; + static const s8 lna1G_gain_db_rev5[] = { 9, 13, 18, 26 }; + static const s8 lna1G_gain_db_rev6[] = { 8, 13, 18, 25 }; + static const s8 lna1G_gain_db_rev6_224B0[] = { 10, 14, 19, 27 }; + static const s8 lna1A_gain_db[] = { 7, 11, 17, 23 }; + static const s8 lna1A_gain_db_rev4[] = { 8, 12, 18, 23 }; + static const s8 lna1A_gain_db_rev5[] = { 6, 10, 16, 21 }; + static const s8 lna1A_gain_db_rev6[] = { 6, 10, 16, 21 }; + const s8 *lna1_gain_db = NULL; + static const s8 lna2G_gain_db[] = { -5, 6, 10, 14 }; + static const s8 lna2G_gain_db_rev5[] = { -3, 7, 11, 16 }; + static const s8 lna2G_gain_db_rev6[] = { -5, 6, 10, 14 }; + static const s8 lna2G_gain_db_rev6_224B0[] = { -5, 6, 10, 15 }; + static const s8 lna2A_gain_db[] = { -6, 2, 6, 10 }; + static const s8 lna2A_gain_db_rev4[] = { -5, 2, 6, 10 }; + static const s8 lna2A_gain_db_rev5[] = { -7, 0, 4, 8 }; + static const s8 lna2A_gain_db_rev6[] = { -7, 0, 4, 8 }; + const s8 *lna2_gain_db = NULL; + static const s8 tiaG_gain_db[] = { 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A }; - s8 tiaA_gain_db[] = { + static const s8 tiaA_gain_db[] = { 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13 }; - s8 tiaA_gain_db_rev4[] = { + static const s8 tiaA_gain_db_rev4[] = { 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d }; - s8 tiaA_gain_db_rev5[] = { + static const s8 tiaA_gain_db_rev5[] = { 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d }; - s8 tiaA_gain_db_rev6[] = { + static const s8 tiaA_gain_db_rev6[] = { 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d }; - s8 *tia_gain_db; - s8 tiaG_gainbits[] = { + const s8 *tia_gain_db; + static const s8 tiaG_gainbits[] = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 }; - s8 tiaA_gainbits[] = { + static const s8 tiaA_gainbits[] = { 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06 }; - s8 tiaA_gainbits_rev4[] = { + static const s8 tiaA_gainbits_rev4[] = { 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 }; - s8 tiaA_gainbits_rev5[] = { + static const s8 tiaA_gainbits_rev5[] = { 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 }; - s8 tiaA_gainbits_rev6[] = { + static const s8 tiaA_gainbits_rev6[] = { 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 }; - s8 *tia_gainbits; - s8 lpf_gain_db[] = { 0x00, 0x06, 0x0c, 0x12, 0x12, 0x12 }; - s8 lpf_gainbits[] = { 0x00, 0x01, 0x02, 0x03, 0x03, 0x03 }; - u16 rfseqG_init_gain[] = { 0x613f, 0x613f, 0x613f, 0x613f }; - u16 rfseqG_init_gain_rev4[] = { 0x513f, 0x513f, 0x513f, 0x513f }; - u16 rfseqG_init_gain_rev5[] = { 0x413f, 0x413f, 0x413f, 0x413f }; - u16 rfseqG_init_gain_rev5_elna[] = { + const s8 *tia_gainbits; + static const s8 lpf_gain_db[] = { 0x00, 0x06, 0x0c, 0x12, 0x12, 0x12 }; + static const s8 lpf_gainbits[] = { 0x00, 0x01, 0x02, 0x03, 0x03, 0x03 }; + static const u16 rfseqG_init_gain[] = { 0x613f, 0x613f, 0x613f, 0x613f }; + static const u16 rfseqG_init_gain_rev4[] = { 0x513f, 0x513f, 0x513f, 0x513f }; + static const u16 rfseqG_init_gain_rev5[] = { 0x413f, 0x413f, 0x413f, 0x413f }; + static const u16 rfseqG_init_gain_rev5_elna[] = { 0x013f, 0x013f, 0x013f, 0x013f }; - u16 rfseqG_init_gain_rev6[] = { 0x513f, 0x513f }; - u16 rfseqG_init_gain_rev6_224B0[] = { 0x413f, 0x413f }; - u16 rfseqG_init_gain_rev6_elna[] = { 0x113f, 0x113f }; - u16 rfseqA_init_gain[] = { 0x516f, 0x516f, 0x516f, 0x516f }; - u16 rfseqA_init_gain_rev4[] = { 0x614f, 0x614f, 0x614f, 0x614f }; - u16 rfseqA_init_gain_rev4_elna[] = { + static const u16 rfseqG_init_gain_rev6[] = { 0x513f, 0x513f }; + static const u16 rfseqG_init_gain_rev6_224B0[] = { 0x413f, 0x413f }; + static const u16 rfseqG_init_gain_rev6_elna[] = { 0x113f, 0x113f }; + static const u16 rfseqA_init_gain[] = { 0x516f, 0x516f, 0x516f, 0x516f }; + static const u16 rfseqA_init_gain_rev4[] = { 0x614f, 0x614f, 0x614f, 0x614f }; + static const u16 rfseqA_init_gain_rev4_elna[] = { 0x314f, 0x314f, 0x314f, 0x314f }; - u16 rfseqA_init_gain_rev5[] = { 0x714f, 0x714f, 0x714f, 0x714f }; - u16 rfseqA_init_gain_rev6[] = { 0x714f, 0x714f }; - u16 *rfseq_init_gain; + static const u16 rfseqA_init_gain_rev5[] = { 0x714f, 0x714f, 0x714f, 0x714f }; + static const u16 rfseqA_init_gain_rev6[] = { 0x714f, 0x714f }; + const u16 *rfseq_init_gain; u16 initG_gaincode = 0x627e; u16 initG_gaincode_rev4 = 0x527e; u16 initG_gaincode_rev5 = 0x427e; @@ -15538,10 +15535,10 @@ static void wlc_phy_workarounds_nphy_gainctrl(struct brcms_phy *pi) u16 clip1mdA_gaincode_rev6 = 0x2084; u16 clip1md_gaincode = 0; u16 clip1loG_gaincode = 0x0074; - u16 clip1loG_gaincode_rev5[] = { + static const u16 clip1loG_gaincode_rev5[] = { 0x0062, 0x0064, 0x006a, 0x106a, 0x106c, 0x1074, 0x107c, 0x207c }; - u16 clip1loG_gaincode_rev6[] = { + static const u16 clip1loG_gaincode_rev6[] = { 0x106a, 0x106c, 0x1074, 0x107c, 0x007e, 0x107e, 0x207e, 0x307e }; u16 clip1loG_gaincode_rev6_224B0 = 0x1074; @@ -16066,7 +16063,7 @@ static void wlc_phy_workarounds_nphy_gainctrl(struct brcms_phy *pi) static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) { - u8 rfseq_rx2tx_events[] = { + static const u8 rfseq_rx2tx_events[] = { NPHY_RFSEQ_CMD_NOP, NPHY_RFSEQ_CMD_RXG_FBW, NPHY_RFSEQ_CMD_TR_SWITCH, @@ -16076,7 +16073,7 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) NPHY_RFSEQ_CMD_EXT_PA }; u8 rfseq_rx2tx_dlys[] = { 8, 6, 6, 2, 4, 60, 1 }; - u8 rfseq_tx2rx_events[] = { + static const u8 rfseq_tx2rx_events[] = { NPHY_RFSEQ_CMD_NOP, NPHY_RFSEQ_CMD_EXT_PA, NPHY_RFSEQ_CMD_TX_GAIN, @@ -16085,8 +16082,8 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) NPHY_RFSEQ_CMD_RXG_FBW, NPHY_RFSEQ_CMD_CLR_HIQ_DIS }; - u8 rfseq_tx2rx_dlys[] = { 8, 6, 2, 4, 4, 6, 1 }; - u8 rfseq_tx2rx_events_rev3[] = { + static const u8 rfseq_tx2rx_dlys[] = { 8, 6, 2, 4, 4, 6, 1 }; + static const u8 rfseq_tx2rx_events_rev3[] = { NPHY_REV3_RFSEQ_CMD_EXT_PA, NPHY_REV3_RFSEQ_CMD_INT_PA_PU, NPHY_REV3_RFSEQ_CMD_TX_GAIN, @@ -16096,7 +16093,7 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) NPHY_REV3_RFSEQ_CMD_CLR_HIQ_DIS, NPHY_REV3_RFSEQ_CMD_END }; - u8 rfseq_tx2rx_dlys_rev3[] = { 8, 4, 2, 2, 4, 4, 6, 1 }; + static const u8 rfseq_tx2rx_dlys_rev3[] = { 8, 4, 2, 2, 4, 4, 6, 1 }; u8 rfseq_rx2tx_events_rev3[] = { NPHY_REV3_RFSEQ_CMD_NOP, NPHY_REV3_RFSEQ_CMD_RXG_FBW, @@ -16110,7 +16107,7 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) }; u8 rfseq_rx2tx_dlys_rev3[] = { 8, 6, 6, 4, 4, 18, 42, 1, 1 }; - u8 rfseq_rx2tx_events_rev3_ipa[] = { + static const u8 rfseq_rx2tx_events_rev3_ipa[] = { NPHY_REV3_RFSEQ_CMD_NOP, NPHY_REV3_RFSEQ_CMD_RXG_FBW, NPHY_REV3_RFSEQ_CMD_TR_SWITCH, @@ -16121,15 +16118,15 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) NPHY_REV3_RFSEQ_CMD_INT_PA_PU, NPHY_REV3_RFSEQ_CMD_END }; - u8 rfseq_rx2tx_dlys_rev3_ipa[] = { 8, 6, 6, 4, 4, 16, 43, 1, 1 }; - u16 rfseq_rx2tx_dacbufpu_rev7[] = { 0x10f, 0x10f }; + static const u8 rfseq_rx2tx_dlys_rev3_ipa[] = { 8, 6, 6, 4, 4, 16, 43, 1, 1 }; + static const u16 rfseq_rx2tx_dacbufpu_rev7[] = { 0x10f, 0x10f }; s16 alpha0, alpha1, alpha2; s16 beta0, beta1, beta2; u32 leg_data_weights, ht_data_weights, nss1_data_weights, stbc_data_weights; u8 chan_freq_range = 0; - u16 dac_control = 0x0002; + static const u16 dac_control = 0x0002; u16 aux_adc_vmid_rev7_core0[] = { 0x8e, 0x96, 0x96, 0x96 }; u16 aux_adc_vmid_rev7_core1[] = { 0x8f, 0x9f, 0x9f, 0x96 }; u16 aux_adc_vmid_rev4[] = { 0xa2, 0xb4, 0xb4, 0x89 }; @@ -16139,8 +16136,8 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) u16 aux_adc_gain_rev4[] = { 0x02, 0x02, 0x02, 0x00 }; u16 aux_adc_gain_rev3[] = { 0x02, 0x02, 0x02, 0x00 }; u16 *aux_adc_gain; - u16 sk_adc_vmid[] = { 0xb4, 0xb4, 0xb4, 0x24 }; - u16 sk_adc_gain[] = { 0x02, 0x02, 0x02, 0x02 }; + static const u16 sk_adc_vmid[] = { 0xb4, 0xb4, 0xb4, 0x24 }; + static const u16 sk_adc_gain[] = { 0x02, 0x02, 0x02, 0x02 }; s32 min_nvar_val = 0x18d; s32 min_nvar_offset_6mbps = 20; u8 pdetrange; @@ -16151,9 +16148,9 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) u16 rfseq_rx2tx_lpf_h_hpc_rev7 = 0x77; u16 rfseq_tx2rx_lpf_h_hpc_rev7 = 0x77; u16 rfseq_pktgn_lpf_h_hpc_rev7 = 0x77; - u16 rfseq_htpktgn_lpf_hpc_rev7[] = { 0x77, 0x11, 0x11 }; - u16 rfseq_pktgn_lpf_hpc_rev7[] = { 0x11, 0x11 }; - u16 rfseq_cckpktgn_lpf_hpc_rev7[] = { 0x11, 0x11 }; + static const u16 rfseq_htpktgn_lpf_hpc_rev7[] = { 0x77, 0x11, 0x11 }; + static const u16 rfseq_pktgn_lpf_hpc_rev7[] = { 0x11, 0x11 }; + static const u16 rfseq_cckpktgn_lpf_hpc_rev7[] = { 0x11, 0x11 }; u16 ipalvlshift_3p3_war_en = 0; u16 rccal_bcap_val, rccal_scap_val; u16 rccal_tx20_11b_bcap = 0; @@ -24291,13 +24288,13 @@ static void wlc_phy_update_txcal_ladder_nphy(struct brcms_phy *pi, u16 core) u16 bbmult; u16 tblentry; - struct nphy_txiqcal_ladder ladder_lo[] = { + static const struct nphy_txiqcal_ladder ladder_lo[] = { {3, 0}, {4, 0}, {6, 0}, {9, 0}, {13, 0}, {18, 0}, {25, 0}, {25, 1}, {25, 2}, {25, 3}, {25, 4}, {25, 5}, {25, 6}, {25, 7}, {35, 7}, {50, 7}, {71, 7}, {100, 7} }; - struct nphy_txiqcal_ladder ladder_iq[] = { + static const struct nphy_txiqcal_ladder ladder_iq[] = { {3, 0}, {4, 0}, {6, 0}, {9, 0}, {13, 0}, {18, 0}, {25, 0}, {35, 0}, {50, 0}, {71, 0}, {100, 0}, {100, 1}, {100, 2}, {100, 3}, {100, 4}, {100, 5}, {100, 6}, {100, 7} @@ -25773,67 +25770,67 @@ wlc_phy_cal_txiqlo_nphy(struct brcms_phy *pi, struct nphy_txgains target_gain, u16 cal_gain[2]; struct nphy_iqcal_params cal_params[2]; u32 tbl_len; - void *tbl_ptr; + const void *tbl_ptr; bool ladder_updated[2]; u8 mphase_cal_lastphase = 0; int bcmerror = 0; bool phyhang_avoid_state = false; - u16 tbl_tx_iqlo_cal_loft_ladder_20[] = { + static const u16 tbl_tx_iqlo_cal_loft_ladder_20[] = { 0x0300, 0x0500, 0x0700, 0x0900, 0x0d00, 0x1100, 0x1900, 0x1901, 0x1902, 0x1903, 0x1904, 0x1905, 0x1906, 0x1907, 0x2407, 0x3207, 0x4607, 0x6407 }; - u16 tbl_tx_iqlo_cal_iqimb_ladder_20[] = { + static const u16 tbl_tx_iqlo_cal_iqimb_ladder_20[] = { 0x0200, 0x0300, 0x0600, 0x0900, 0x0d00, 0x1100, 0x1900, 0x2400, 0x3200, 0x4600, 0x6400, 0x6401, 0x6402, 0x6403, 0x6404, 0x6405, 0x6406, 0x6407 }; - u16 tbl_tx_iqlo_cal_loft_ladder_40[] = { + static const u16 tbl_tx_iqlo_cal_loft_ladder_40[] = { 0x0200, 0x0300, 0x0400, 0x0700, 0x0900, 0x0c00, 0x1200, 0x1201, 0x1202, 0x1203, 0x1204, 0x1205, 0x1206, 0x1207, 0x1907, 0x2307, 0x3207, 0x4707 }; - u16 tbl_tx_iqlo_cal_iqimb_ladder_40[] = { + static const u16 tbl_tx_iqlo_cal_iqimb_ladder_40[] = { 0x0100, 0x0200, 0x0400, 0x0700, 0x0900, 0x0c00, 0x1200, 0x1900, 0x2300, 0x3200, 0x4700, 0x4701, 0x4702, 0x4703, 0x4704, 0x4705, 0x4706, 0x4707 }; - u16 tbl_tx_iqlo_cal_startcoefs[] = { + static const u16 tbl_tx_iqlo_cal_startcoefs[] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }; - u16 tbl_tx_iqlo_cal_cmds_fullcal[] = { + static const u16 tbl_tx_iqlo_cal_cmds_fullcal[] = { 0x8123, 0x8264, 0x8086, 0x8245, 0x8056, 0x9123, 0x9264, 0x9086, 0x9245, 0x9056 }; - u16 tbl_tx_iqlo_cal_cmds_recal[] = { + static const u16 tbl_tx_iqlo_cal_cmds_recal[] = { 0x8101, 0x8253, 0x8053, 0x8234, 0x8034, 0x9101, 0x9253, 0x9053, 0x9234, 0x9034 }; - u16 tbl_tx_iqlo_cal_startcoefs_nphyrev3[] = { + static const u16 tbl_tx_iqlo_cal_startcoefs_nphyrev3[] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }; - u16 tbl_tx_iqlo_cal_cmds_fullcal_nphyrev3[] = { + static const u16 tbl_tx_iqlo_cal_cmds_fullcal_nphyrev3[] = { 0x8434, 0x8334, 0x8084, 0x8267, 0x8056, 0x8234, 0x9434, 0x9334, 0x9084, 0x9267, 0x9056, 0x9234 }; - u16 tbl_tx_iqlo_cal_cmds_recal_nphyrev3[] = { + static const u16 tbl_tx_iqlo_cal_cmds_recal_nphyrev3[] = { 0x8423, 0x8323, 0x8073, 0x8256, 0x8045, 0x8223, 0x9423, 0x9323, 0x9073, 0x9256, 0x9045, 0x9223 }; From patchwork Wed Jun 14 21:15:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 105592 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp490303qgd; Wed, 14 Jun 2017 14:22:15 -0700 (PDT) X-Received: by 10.99.177.5 with SMTP id r5mr1864434pgf.21.1497475335119; Wed, 14 Jun 2017 14:22:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497475335; cv=none; d=google.com; s=arc-20160816; b=A1TwDfLVwdI7NdP/3CJkoOOi6S6Wxuahkyi9KiSqxIdvpFkniiJgLKZYZVkkH1vBJz nqK2x6WW+iZkBkvRi3vpgq+EfSxgIt4xevFVNeRlaeqv5MCCDrgGxEecDqYA33WTleBf rvK37MAI4nnRIE9+bg3ACXkSzfrIaXtGe0kr/dSqdA+at9SX/l2KUjgVmDHN60x3xJXH cgO0EHBwbgrlSpf8XqFA/mjCyxt1oVDpJ75vj0rLpN7QLt2TCJQkfE/abJLCFcyGC5gi Oisxj/X7+1OHCJz0hMpuq6QXdvximThN2mdEIGRoQNA4c5p3DpuPkCEDRj1kkeaDlLkU Iwww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=vbc14lqEhwwWdPHqkJAmna14fEL1qnyMb2sp6+ycRXg=; b=AdbyEwde4dKVfRd7HwZFDC8N3KOGZAC5GGvg3p2GYMGcoR4oR+n4WhWSMYdtMhgVca nBQekXT/Lf6q2U9opQAujvybIv6UVoE0zel4RnATEzV+Ud9DpapzWrRxoCSVAqWe5bks GGiBTr6H4aelMbTVIeYfrV84DPsABKHGa57bhPRSyctahBQeT7jvmWSUw1bVMqHlEKlA ZiwXJP3NkUjFYHzTDfwoQqbk5PEryM3gUaBm1sZWsX95iZixwPtQkCK37LmUdnSWAn+9 IMVU67grH3O9uynnww3dlJ045wfa5l2RuQqoVGsxeTw5QLFgrbJKSKyA+ZRe7/YmzweZ MD2Q== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p29si825980pli.22.2017.06.14.14.22.14; Wed, 14 Jun 2017 14:22:15 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752745AbdFNVVx (ORCPT + 25 others); Wed, 14 Jun 2017 17:21:53 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:63461 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752441AbdFNVVv (ORCPT ); Wed, 14 Jun 2017 17:21:51 -0400 Received: from wuerfel.lan ([78.42.17.5]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.129]) with ESMTPA (Nemesis) id 0MWsiR-1dJNEo3sFP-00Xw7b; Wed, 14 Jun 2017 23:21:22 +0200 From: Arnd Bergmann To: Andrew Morton Cc: kasan-dev@googlegroups.com, Dmitry Vyukov , Alexander Potapenko , Andrey Ryabinin , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Arend van Spriel , Arnd Bergmann , Franky Lin , Hante Meuleman , Kalle Valo , linux-wireless@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com Subject: [PATCH v2 09/11] brcmsmac: split up wlc_phy_workarounds_nphy Date: Wed, 14 Jun 2017 23:15:44 +0200 Message-Id: <20170614211556.2062728-10-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170614211556.2062728-1-arnd@arndb.de> References: <20170614211556.2062728-1-arnd@arndb.de> X-Provags-ID: V03:K0:zXdBmSRw67UDdrEYBicbmtiA+6uGXskHQ3Y0N7tid3w4HWo3bkf +89M77jPSUI18aPA31YFUTuFAj2FAP9s5AMlAN7tbzQ+fCi1qEwBcV7Xvb4aCNDCP8AK+aY dE0qCWGdOGfHerUJ3JjfCSqvBfnRCqyPLYzApmu22ex1g6Ov3FxpsjE0Aoc8v2Fa1CtT1Yc 6YWTbZ8OKznBEwWzjMYLA== X-UI-Out-Filterresults: notjunk:1; V01:K0:TwPTFF4vbj0=:tEqRwC9ueiVUFaty/ZETao lMwKS2LFVQIl9o0rx0MIKNBQ65uH9zU34gHq3o+Oabg9Nl97Q6oYh1/yF+CoP+1RCD1Oaajq5 DHVMiQXjrTG0QsufRoZEHRy1Ye9VyGLeyCreWFq91y/oJWS9GBg4ZJZcL3yQ7HhLcEbnfZBLx FG+xHRUMhZ2JSt0/A8P6KocM7YfdEJNEjsfbmXAlfabkio63nngV0Wvzt6hFpaZ7WqqDxoGBH c+gamXzf1E550j+jIf8XRnTHM1Pwii3A5kiFXp0ttJvhAHKdvy3H0pMQx0R5rrqxHrqrM6cjI ydcBCPWMut6dr+YjnjiHkKI4ZTnZNUvQijV7eZPhEfLYCmkpFiNTiEWCVAMZYV38ZJjg/b8KV TOLfNYbsAUQN8jR5wTdzojd1xqU++QwuuyafEdaJaOQXhVMzdtP8gVoGVRiL+TlxSTsCBR2NT WUx64rF1shGtx7ZnG6rjKnh3HPRozwFaguB4nAKISovhMzakwiz4zz3Y84619krKpmzwtNXu6 Me9XR5T0nNFn9mA5sYi+6EITltspNbjXtggpP+NLnCodsr05+dni6wNxHnPD02i/pJDHc0qFj zywg6z53/XOC084MzLdKyEl31vIWRPxMg2g6q1lBRd855OyzIbt9Z9Qv6iFa8frOOhcYnD1jL KZbpE/2zqEn/a/6FlSwhStZbvHcsIG8IhdBBLMWMpGfVcrtVsFXC0H2GPwycRzV02o6w= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The stack consumption in this driver is still relatively high, with one remaining warning if the warning level is lowered to 1536 bytes: drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c:17135:1: error: the frame size of 1880 bytes is larger than 1536 bytes [-Werror=frame-larger-than=] The affected function is actually a collection of three separate implementations, and each of them is fairly large by itself. Splitting them up is done easily and improves readability at the same time. I'm leaving the original indentation to make the review easier. Acked-by: Arend van Spriel Signed-off-by: Arnd Bergmann --- .../broadcom/brcm80211/brcmsmac/phy/phy_n.c | 178 ++++++++++++--------- 1 file changed, 104 insertions(+), 74 deletions(-) -- 2.9.0 diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c index ef685465f80a..ed409a80f3d2 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c @@ -16061,52 +16061,8 @@ static void wlc_phy_workarounds_nphy_gainctrl(struct brcms_phy *pi) } } -static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) +static void wlc_phy_workarounds_nphy_rev7(struct brcms_phy *pi) { - static const u8 rfseq_rx2tx_events[] = { - NPHY_RFSEQ_CMD_NOP, - NPHY_RFSEQ_CMD_RXG_FBW, - NPHY_RFSEQ_CMD_TR_SWITCH, - NPHY_RFSEQ_CMD_CLR_HIQ_DIS, - NPHY_RFSEQ_CMD_RXPD_TXPD, - NPHY_RFSEQ_CMD_TX_GAIN, - NPHY_RFSEQ_CMD_EXT_PA - }; - u8 rfseq_rx2tx_dlys[] = { 8, 6, 6, 2, 4, 60, 1 }; - static const u8 rfseq_tx2rx_events[] = { - NPHY_RFSEQ_CMD_NOP, - NPHY_RFSEQ_CMD_EXT_PA, - NPHY_RFSEQ_CMD_TX_GAIN, - NPHY_RFSEQ_CMD_RXPD_TXPD, - NPHY_RFSEQ_CMD_TR_SWITCH, - NPHY_RFSEQ_CMD_RXG_FBW, - NPHY_RFSEQ_CMD_CLR_HIQ_DIS - }; - static const u8 rfseq_tx2rx_dlys[] = { 8, 6, 2, 4, 4, 6, 1 }; - static const u8 rfseq_tx2rx_events_rev3[] = { - NPHY_REV3_RFSEQ_CMD_EXT_PA, - NPHY_REV3_RFSEQ_CMD_INT_PA_PU, - NPHY_REV3_RFSEQ_CMD_TX_GAIN, - NPHY_REV3_RFSEQ_CMD_RXPD_TXPD, - NPHY_REV3_RFSEQ_CMD_TR_SWITCH, - NPHY_REV3_RFSEQ_CMD_RXG_FBW, - NPHY_REV3_RFSEQ_CMD_CLR_HIQ_DIS, - NPHY_REV3_RFSEQ_CMD_END - }; - static const u8 rfseq_tx2rx_dlys_rev3[] = { 8, 4, 2, 2, 4, 4, 6, 1 }; - u8 rfseq_rx2tx_events_rev3[] = { - NPHY_REV3_RFSEQ_CMD_NOP, - NPHY_REV3_RFSEQ_CMD_RXG_FBW, - NPHY_REV3_RFSEQ_CMD_TR_SWITCH, - NPHY_REV3_RFSEQ_CMD_CLR_HIQ_DIS, - NPHY_REV3_RFSEQ_CMD_RXPD_TXPD, - NPHY_REV3_RFSEQ_CMD_TX_GAIN, - NPHY_REV3_RFSEQ_CMD_INT_PA_PU, - NPHY_REV3_RFSEQ_CMD_EXT_PA, - NPHY_REV3_RFSEQ_CMD_END - }; - u8 rfseq_rx2tx_dlys_rev3[] = { 8, 6, 6, 4, 4, 18, 42, 1, 1 }; - static const u8 rfseq_rx2tx_events_rev3_ipa[] = { NPHY_REV3_RFSEQ_CMD_NOP, NPHY_REV3_RFSEQ_CMD_RXG_FBW, @@ -16120,29 +16076,15 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) }; static const u8 rfseq_rx2tx_dlys_rev3_ipa[] = { 8, 6, 6, 4, 4, 16, 43, 1, 1 }; static const u16 rfseq_rx2tx_dacbufpu_rev7[] = { 0x10f, 0x10f }; - - s16 alpha0, alpha1, alpha2; - s16 beta0, beta1, beta2; - u32 leg_data_weights, ht_data_weights, nss1_data_weights, - stbc_data_weights; + u32 leg_data_weights; u8 chan_freq_range = 0; static const u16 dac_control = 0x0002; u16 aux_adc_vmid_rev7_core0[] = { 0x8e, 0x96, 0x96, 0x96 }; u16 aux_adc_vmid_rev7_core1[] = { 0x8f, 0x9f, 0x9f, 0x96 }; - u16 aux_adc_vmid_rev4[] = { 0xa2, 0xb4, 0xb4, 0x89 }; - u16 aux_adc_vmid_rev3[] = { 0xa2, 0xb4, 0xb4, 0x89 }; - u16 *aux_adc_vmid; u16 aux_adc_gain_rev7[] = { 0x02, 0x02, 0x02, 0x02 }; - u16 aux_adc_gain_rev4[] = { 0x02, 0x02, 0x02, 0x00 }; - u16 aux_adc_gain_rev3[] = { 0x02, 0x02, 0x02, 0x00 }; - u16 *aux_adc_gain; - static const u16 sk_adc_vmid[] = { 0xb4, 0xb4, 0xb4, 0x24 }; - static const u16 sk_adc_gain[] = { 0x02, 0x02, 0x02, 0x02 }; s32 min_nvar_val = 0x18d; s32 min_nvar_offset_6mbps = 20; u8 pdetrange; - u8 triso; - u16 regval; u16 afectrl_adc_ctrl1_rev7 = 0x20; u16 afectrl_adc_ctrl2_rev7 = 0x0; u16 rfseq_rx2tx_lpf_h_hpc_rev7 = 0x77; @@ -16171,17 +16113,6 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) u16 freq; int coreNum; - if (CHSPEC_IS5G(pi->radio_chanspec)) - wlc_phy_classifier_nphy(pi, NPHY_ClassifierCtrl_cck_en, 0); - else - wlc_phy_classifier_nphy(pi, NPHY_ClassifierCtrl_cck_en, 1); - - if (pi->phyhang_avoid) - wlc_phy_stay_in_carriersearch_nphy(pi, true); - - or_phy_reg(pi, 0xb1, NPHY_IQFlip_ADC1 | NPHY_IQFlip_ADC2); - - if (NREV_GE(pi->pubpi.phy_rev, 7)) { if (NREV_IS(pi->pubpi.phy_rev, 7)) { mod_phy_reg(pi, 0x221, (0x1 << 4), (1 << 4)); @@ -16703,8 +16634,62 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) &aux_adc_gain_rev7); wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, 0x1c, 16, &aux_adc_gain_rev7); +} - } else if (NREV_GE(pi->pubpi.phy_rev, 3)) { +static void wlc_phy_workarounds_nphy_rev3(struct brcms_phy *pi) +{ + static const u8 rfseq_tx2rx_events_rev3[] = { + NPHY_REV3_RFSEQ_CMD_EXT_PA, + NPHY_REV3_RFSEQ_CMD_INT_PA_PU, + NPHY_REV3_RFSEQ_CMD_TX_GAIN, + NPHY_REV3_RFSEQ_CMD_RXPD_TXPD, + NPHY_REV3_RFSEQ_CMD_TR_SWITCH, + NPHY_REV3_RFSEQ_CMD_RXG_FBW, + NPHY_REV3_RFSEQ_CMD_CLR_HIQ_DIS, + NPHY_REV3_RFSEQ_CMD_END + }; + static const u8 rfseq_tx2rx_dlys_rev3[] = { 8, 4, 2, 2, 4, 4, 6, 1 }; + u8 rfseq_rx2tx_events_rev3[] = { + NPHY_REV3_RFSEQ_CMD_NOP, + NPHY_REV3_RFSEQ_CMD_RXG_FBW, + NPHY_REV3_RFSEQ_CMD_TR_SWITCH, + NPHY_REV3_RFSEQ_CMD_CLR_HIQ_DIS, + NPHY_REV3_RFSEQ_CMD_RXPD_TXPD, + NPHY_REV3_RFSEQ_CMD_TX_GAIN, + NPHY_REV3_RFSEQ_CMD_INT_PA_PU, + NPHY_REV3_RFSEQ_CMD_EXT_PA, + NPHY_REV3_RFSEQ_CMD_END + }; + u8 rfseq_rx2tx_dlys_rev3[] = { 8, 6, 6, 4, 4, 18, 42, 1, 1 }; + static const u8 rfseq_rx2tx_events_rev3_ipa[] = { + NPHY_REV3_RFSEQ_CMD_NOP, + NPHY_REV3_RFSEQ_CMD_RXG_FBW, + NPHY_REV3_RFSEQ_CMD_TR_SWITCH, + NPHY_REV3_RFSEQ_CMD_CLR_HIQ_DIS, + NPHY_REV3_RFSEQ_CMD_RXPD_TXPD, + NPHY_REV3_RFSEQ_CMD_TX_GAIN, + NPHY_REV3_RFSEQ_CMD_CLR_RXRX_BIAS, + NPHY_REV3_RFSEQ_CMD_INT_PA_PU, + NPHY_REV3_RFSEQ_CMD_END + }; + static const u8 rfseq_rx2tx_dlys_rev3_ipa[] = { 8, 6, 6, 4, 4, 16, 43, 1, 1 }; + s16 alpha0, alpha1, alpha2; + s16 beta0, beta1, beta2; + u32 leg_data_weights, ht_data_weights, nss1_data_weights, + stbc_data_weights; + u8 chan_freq_range = 0; + static const u16 dac_control = 0x0002; + u16 aux_adc_vmid_rev4[] = { 0xa2, 0xb4, 0xb4, 0x89 }; + u16 aux_adc_vmid_rev3[] = { 0xa2, 0xb4, 0xb4, 0x89 }; + u16 *aux_adc_vmid; + u16 aux_adc_gain_rev4[] = { 0x02, 0x02, 0x02, 0x00 }; + u16 aux_adc_gain_rev3[] = { 0x02, 0x02, 0x02, 0x00 }; + u16 *aux_adc_gain; + static const u16 sk_adc_vmid[] = { 0xb4, 0xb4, 0xb4, 0x24 }; + static const u16 sk_adc_gain[] = { 0x02, 0x02, 0x02, 0x02 }; + s32 min_nvar_val = 0x18d; + u8 pdetrange; + u8 triso; write_phy_reg(pi, 0x23f, 0x1f8); write_phy_reg(pi, 0x240, 0x1f8); @@ -17030,7 +17015,33 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) MHF4_BPHY_TXCORE0, MHF4_BPHY_TXCORE0, BRCM_BAND_ALL); } - } else { +} + +void wlc_phy_workarounds_nphy_rev1(struct brcms_phy *pi) +{ + static const u8 rfseq_rx2tx_events[] = { + NPHY_RFSEQ_CMD_NOP, + NPHY_RFSEQ_CMD_RXG_FBW, + NPHY_RFSEQ_CMD_TR_SWITCH, + NPHY_RFSEQ_CMD_CLR_HIQ_DIS, + NPHY_RFSEQ_CMD_RXPD_TXPD, + NPHY_RFSEQ_CMD_TX_GAIN, + NPHY_RFSEQ_CMD_EXT_PA + }; + u8 rfseq_rx2tx_dlys[] = { 8, 6, 6, 2, 4, 60, 1 }; + static const u8 rfseq_tx2rx_events[] = { + NPHY_RFSEQ_CMD_NOP, + NPHY_RFSEQ_CMD_EXT_PA, + NPHY_RFSEQ_CMD_TX_GAIN, + NPHY_RFSEQ_CMD_RXPD_TXPD, + NPHY_RFSEQ_CMD_TR_SWITCH, + NPHY_RFSEQ_CMD_RXG_FBW, + NPHY_RFSEQ_CMD_CLR_HIQ_DIS + }; + static const u8 rfseq_tx2rx_dlys[] = { 8, 6, 2, 4, 4, 6, 1 }; + s16 alpha0, alpha1, alpha2; + s16 beta0, beta1, beta2; + u16 regval; if (pi->sh->boardflags2 & BFL2_SKWRKFEM_BRD || (pi->sh->boardtype == 0x8b)) { @@ -17128,7 +17139,26 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) mod_phy_reg(pi, 0x221, NPHY_FORCESIG_DECODEGATEDCLKS, NPHY_FORCESIG_DECODEGATEDCLKS); - } +} + +static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) +{ + if (CHSPEC_IS5G(pi->radio_chanspec)) + wlc_phy_classifier_nphy(pi, NPHY_ClassifierCtrl_cck_en, 0); + else + wlc_phy_classifier_nphy(pi, NPHY_ClassifierCtrl_cck_en, 1); + + if (pi->phyhang_avoid) + wlc_phy_stay_in_carriersearch_nphy(pi, true); + + or_phy_reg(pi, 0xb1, NPHY_IQFlip_ADC1 | NPHY_IQFlip_ADC2); + + if (NREV_GE(pi->pubpi.phy_rev, 7)) + wlc_phy_workarounds_nphy_rev7(pi); + else if (NREV_GE(pi->pubpi.phy_rev, 3)) + wlc_phy_workarounds_nphy_rev3(pi); + else + wlc_phy_workarounds_nphy_rev1(pi); if (pi->phyhang_avoid) wlc_phy_stay_in_carriersearch_nphy(pi, false); From patchwork Wed Jun 14 21:15:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 105593 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp490307qgd; Wed, 14 Jun 2017 14:22:15 -0700 (PDT) X-Received: by 10.98.194.73 with SMTP id l70mr1861330pfg.41.1497475335558; Wed, 14 Jun 2017 14:22:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497475335; cv=none; d=google.com; s=arc-20160816; b=k9F8Q6AF8euj0C6UhaBma/W/zo8qGaW5Bme4MVmSEnGh5s4/3bNenzWrBdQcHVKeZ0 oAURbMZaENiNq/ws3PZJHMpnb7b2y0mJZQxNy9xLwHFs23Y1Mo217ZU0DsLQndyNfA6h 1hwYweEPb2+zjV6J9p1uV84kRv0DBXD1g0QqZ3U7oy9AkdvUGwzhmEHOr0d6a7juObI/ 8HLtK+txNKlmgJbJ7x8NG3h/KyrxhXECvJ/0wSv4kUcSX5u45+EnkvQ4DDcuvV9sK5t3 4CvfDKTI++D/jbrtcwerFOxNklDqnvVfFAY5PutH2UACBT9gEFQC4SYABdw5qFAN/pcH JLHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=CEhKivFzNE+Cgpfhd9/HIrBqXA1fnT4vcEGIPSjpbBs=; b=gY0SKPDoabOg0pstgQaOguc68Gn3alnBmGbIse93ZsOWjjMgvQDQ5GWoP9c6G4N8hC c0Tc0m8Wflu5ndz/Q5/II0XNBD+aOFbZ8miy8NRqYGU4QVTwDTkOqn3cP+OvnjYP394M KVkJfUpAgS6MIJW3w0sy761C/0j5+gY3kfWR+gKt1oGtbjzCEH0s0lhs7tVYvfSLN80r eK2J8zI2hftqw1L4Z/Jus5MoZuVgwhcpak3BLjUvaYucSRoQUFycsGn3UHm2SFPWyIP3 G0RBLnnkg5HAbX9XL+a9LCn4eF8VgFcsByPBnhqKDH+/BQ7n62DeYWAQa2vzIZNGF6vx pb6A== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p29si825980pli.22.2017.06.14.14.22.15; Wed, 14 Jun 2017 14:22:15 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752772AbdFNVWE (ORCPT + 25 others); Wed, 14 Jun 2017 17:22:04 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:60163 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752441AbdFNVWA (ORCPT ); Wed, 14 Jun 2017 17:22:00 -0400 Received: from wuerfel.lan ([78.42.17.5]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.129]) with ESMTPA (Nemesis) id 0MEOE4-1dacsB3iJ6-00FRX2; Wed, 14 Jun 2017 23:21:36 +0200 From: Arnd Bergmann To: Andrew Morton Cc: kasan-dev@googlegroups.com, Dmitry Vyukov , Alexander Potapenko , Andrey Ryabinin , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Arend van Spriel , Arnd Bergmann , Franky Lin , Hante Meuleman , Kalle Valo , linux-wireless@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com Subject: [PATCH v2 10/11] brcmsmac: reindent split functions Date: Wed, 14 Jun 2017 23:15:45 +0200 Message-Id: <20170614211556.2062728-11-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170614211556.2062728-1-arnd@arndb.de> References: <20170614211556.2062728-1-arnd@arndb.de> X-Provags-ID: V03:K0:taLQtY4Utw5luaDVxsE+7I6Q4FtAt2tC66SmJIZE4UfRA1ABpS+ 5vKB92WxpDQTFMgcnQkSTBo284lFyMj3Uau0v3g/wBNSR5Lib3HqjrlMS9eparOwfpRyW7U dl/i5uTKudygwsjc4okU+4nI8teOR2lL3a5wVBbxsk9PREpKO9mbrAuqFXy6lSRPCS9m3/d MygFJ1iKOWZfE2Eg1k3/g== X-UI-Out-Filterresults: notjunk:1; V01:K0:gSMad2UMzWo=:MLPZbAkwXs/VaBBfCkl+Ny MsG8V/HebY5zPICo3rWt9jLdYT04fc4/PWQGdplZ/E8VaNsEq4dQgr2acEFD06T8YDhTP0+R+ ET4eDmtr5sNZsT+GtNk716+JxTQnzqcKRp9IETZK5QnaKt6U44sbwrnvT/MEbRsft4QrItxHO Ts3jrQvZ5QelflseKWgUmyXKTRM5HfOgXrUdW4IuVK/ptzXySLO5Rh5z96AW7ZH+HIbLh0U1k 0DdWptbnJ8edyUTXLq0SQx9RaCQSW4iz2kcqEIYPCtwdzHgFKCD2n90TY9CWWpV30hq7o87MI klTNWxTvVJvQ986gbb2P9gjy3WWrG8ZZNzwg7wqUuAC806wvS99yJ1B7hwEVYxgP7Rwx6GZNm dqG5oAhlRp2lJPRfghGL0KuB1ItsSkgGHkciA6ae/T1PeoYnN/OtqimRB3IMfg3ysKPvzfN3o kPLO7y7g+MuLfyL/2zpdWRRiSSZcm534G6OiGQMjdWhTyRvZpsUMUp5fT9zcrcyDoD+w9eKIe o6irnoYCK5zoJY+7tvV1vkNR70LuiIcPVaDb3SzKdMOIgw21r89Fo0+J+pjZEo5MooIp1mHnx tBCQhMEF607o8fy4xGGn0s8wDhqdFM26c3WVzLcgY6kaBsSN45y7K3e6TiNZlIdHqnS/9JJMC /v4Z88DrlvWRjWnEkfSY7WezGSj04bKfbYt65jwbIIPEWuDHftF5pUOAKRm6jUjh1XIs= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the previous commit I left the indentation alone to help reviewing the patch, this one now runs the three new functions through 'indent -kr -8' with some manual fixups to avoid silliness. No changes other than whitespace are intended here. Signed-off-by: Arnd Bergmann Acked-by: Arend van Spriel --- .../broadcom/brcm80211/brcmsmac/phy/phy_n.c | 1507 +++++++++----------- 1 file changed, 697 insertions(+), 810 deletions(-) -- 2.9.0 diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c index ed409a80f3d2..763e8ba6b178 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c @@ -16074,7 +16074,8 @@ static void wlc_phy_workarounds_nphy_rev7(struct brcms_phy *pi) NPHY_REV3_RFSEQ_CMD_INT_PA_PU, NPHY_REV3_RFSEQ_CMD_END }; - static const u8 rfseq_rx2tx_dlys_rev3_ipa[] = { 8, 6, 6, 4, 4, 16, 43, 1, 1 }; + static const u8 rfseq_rx2tx_dlys_rev3_ipa[] = + { 8, 6, 6, 4, 4, 16, 43, 1, 1 }; static const u16 rfseq_rx2tx_dacbufpu_rev7[] = { 0x10f, 0x10f }; u32 leg_data_weights; u8 chan_freq_range = 0; @@ -16114,526 +16115,452 @@ static void wlc_phy_workarounds_nphy_rev7(struct brcms_phy *pi) int coreNum; - if (NREV_IS(pi->pubpi.phy_rev, 7)) { - mod_phy_reg(pi, 0x221, (0x1 << 4), (1 << 4)); - - mod_phy_reg(pi, 0x160, (0x7f << 0), (32 << 0)); - mod_phy_reg(pi, 0x160, (0x7f << 8), (39 << 8)); - mod_phy_reg(pi, 0x161, (0x7f << 0), (46 << 0)); - mod_phy_reg(pi, 0x161, (0x7f << 8), (51 << 8)); - mod_phy_reg(pi, 0x162, (0x7f << 0), (55 << 0)); - mod_phy_reg(pi, 0x162, (0x7f << 8), (58 << 8)); - mod_phy_reg(pi, 0x163, (0x7f << 0), (60 << 0)); - mod_phy_reg(pi, 0x163, (0x7f << 8), (62 << 8)); - mod_phy_reg(pi, 0x164, (0x7f << 0), (62 << 0)); - mod_phy_reg(pi, 0x164, (0x7f << 8), (63 << 8)); - mod_phy_reg(pi, 0x165, (0x7f << 0), (63 << 0)); - mod_phy_reg(pi, 0x165, (0x7f << 8), (64 << 8)); - mod_phy_reg(pi, 0x166, (0x7f << 0), (64 << 0)); - mod_phy_reg(pi, 0x166, (0x7f << 8), (64 << 8)); - mod_phy_reg(pi, 0x167, (0x7f << 0), (64 << 0)); - mod_phy_reg(pi, 0x167, (0x7f << 8), (64 << 8)); - } - - if (NREV_LE(pi->pubpi.phy_rev, 8)) { - write_phy_reg(pi, 0x23f, 0x1b0); - write_phy_reg(pi, 0x240, 0x1b0); - } + if (NREV_IS(pi->pubpi.phy_rev, 7)) { + mod_phy_reg(pi, 0x221, (0x1 << 4), (1 << 4)); + + mod_phy_reg(pi, 0x160, (0x7f << 0), (32 << 0)); + mod_phy_reg(pi, 0x160, (0x7f << 8), (39 << 8)); + mod_phy_reg(pi, 0x161, (0x7f << 0), (46 << 0)); + mod_phy_reg(pi, 0x161, (0x7f << 8), (51 << 8)); + mod_phy_reg(pi, 0x162, (0x7f << 0), (55 << 0)); + mod_phy_reg(pi, 0x162, (0x7f << 8), (58 << 8)); + mod_phy_reg(pi, 0x163, (0x7f << 0), (60 << 0)); + mod_phy_reg(pi, 0x163, (0x7f << 8), (62 << 8)); + mod_phy_reg(pi, 0x164, (0x7f << 0), (62 << 0)); + mod_phy_reg(pi, 0x164, (0x7f << 8), (63 << 8)); + mod_phy_reg(pi, 0x165, (0x7f << 0), (63 << 0)); + mod_phy_reg(pi, 0x165, (0x7f << 8), (64 << 8)); + mod_phy_reg(pi, 0x166, (0x7f << 0), (64 << 0)); + mod_phy_reg(pi, 0x166, (0x7f << 8), (64 << 8)); + mod_phy_reg(pi, 0x167, (0x7f << 0), (64 << 0)); + mod_phy_reg(pi, 0x167, (0x7f << 8), (64 << 8)); + } - if (NREV_GE(pi->pubpi.phy_rev, 8)) - mod_phy_reg(pi, 0xbd, (0xff << 0), (114 << 0)); + if (NREV_LE(pi->pubpi.phy_rev, 8)) { + write_phy_reg(pi, 0x23f, 0x1b0); + write_phy_reg(pi, 0x240, 0x1b0); + } - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 0x00, 16, - &dac_control); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 0x10, 16, - &dac_control); + if (NREV_GE(pi->pubpi.phy_rev, 8)) + mod_phy_reg(pi, 0xbd, (0xff << 0), (114 << 0)); - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_CMPMETRICDATAWEIGHTTBL, - 1, 0, 32, &leg_data_weights); - leg_data_weights = leg_data_weights & 0xffffff; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CMPMETRICDATAWEIGHTTBL, - 1, 0, 32, &leg_data_weights); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 0x00, 16, + &dac_control); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 0x10, 16, + &dac_control); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, - 2, 0x15e, 16, - rfseq_rx2tx_dacbufpu_rev7); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 2, 0x16e, 16, - rfseq_rx2tx_dacbufpu_rev7); + wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_CMPMETRICDATAWEIGHTTBL, + 1, 0, 32, &leg_data_weights); + leg_data_weights = leg_data_weights & 0xffffff; + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CMPMETRICDATAWEIGHTTBL, + 1, 0, 32, &leg_data_weights); - if (PHY_IPA(pi)) - wlc_phy_set_rfseq_nphy(pi, NPHY_RFSEQ_RX2TX, - rfseq_rx2tx_events_rev3_ipa, - rfseq_rx2tx_dlys_rev3_ipa, - ARRAY_SIZE(rfseq_rx2tx_events_rev3_ipa)); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, + 2, 0x15e, 16, rfseq_rx2tx_dacbufpu_rev7); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 2, 0x16e, 16, + rfseq_rx2tx_dacbufpu_rev7); - mod_phy_reg(pi, 0x299, (0x3 << 14), (0x1 << 14)); - mod_phy_reg(pi, 0x29d, (0x3 << 14), (0x1 << 14)); + if (PHY_IPA(pi)) + wlc_phy_set_rfseq_nphy(pi, NPHY_RFSEQ_RX2TX, + rfseq_rx2tx_events_rev3_ipa, + rfseq_rx2tx_dlys_rev3_ipa, + ARRAY_SIZE + (rfseq_rx2tx_events_rev3_ipa)); - tx_lpf_bw_ofdm_20mhz = wlc_phy_read_lpf_bw_ctl_nphy(pi, 0x154); - tx_lpf_bw_ofdm_40mhz = wlc_phy_read_lpf_bw_ctl_nphy(pi, 0x159); - tx_lpf_bw_11b = wlc_phy_read_lpf_bw_ctl_nphy(pi, 0x152); + mod_phy_reg(pi, 0x299, (0x3 << 14), (0x1 << 14)); + mod_phy_reg(pi, 0x29d, (0x3 << 14), (0x1 << 14)); - if (PHY_IPA(pi)) { + tx_lpf_bw_ofdm_20mhz = wlc_phy_read_lpf_bw_ctl_nphy(pi, 0x154); + tx_lpf_bw_ofdm_40mhz = wlc_phy_read_lpf_bw_ctl_nphy(pi, 0x159); + tx_lpf_bw_11b = wlc_phy_read_lpf_bw_ctl_nphy(pi, 0x152); - if (((pi->pubpi.radiorev == 5) - && (CHSPEC_IS40(pi->radio_chanspec) == 1)) - || (pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) { + if (PHY_IPA(pi)) { - rccal_bcap_val = - read_radio_reg( - pi, - RADIO_2057_RCCAL_BCAP_VAL); - rccal_scap_val = - read_radio_reg( - pi, - RADIO_2057_RCCAL_SCAP_VAL); + if (((pi->pubpi.radiorev == 5) + && (CHSPEC_IS40(pi->radio_chanspec) == 1)) + || (pi->pubpi.radiorev == 7) + || (pi->pubpi.radiorev == 8)) { - rccal_tx20_11b_bcap = rccal_bcap_val; - rccal_tx20_11b_scap = rccal_scap_val; + rccal_bcap_val = + read_radio_reg(pi, RADIO_2057_RCCAL_BCAP_VAL); + rccal_scap_val = + read_radio_reg(pi, RADIO_2057_RCCAL_SCAP_VAL); - if ((pi->pubpi.radiorev == 5) && - (CHSPEC_IS40(pi->radio_chanspec) == 1)) { + rccal_tx20_11b_bcap = rccal_bcap_val; + rccal_tx20_11b_scap = rccal_scap_val; - rccal_tx20_11n_bcap = rccal_bcap_val; - rccal_tx20_11n_scap = rccal_scap_val; - rccal_tx40_11n_bcap = 0xc; - rccal_tx40_11n_scap = 0xc; + if ((pi->pubpi.radiorev == 5) && + (CHSPEC_IS40(pi->radio_chanspec) == 1)) { - rccal_ovrd = true; + rccal_tx20_11n_bcap = rccal_bcap_val; + rccal_tx20_11n_scap = rccal_scap_val; + rccal_tx40_11n_bcap = 0xc; + rccal_tx40_11n_scap = 0xc; - } else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) { + rccal_ovrd = true; - tx_lpf_bw_ofdm_20mhz = 4; - tx_lpf_bw_11b = 1; + } else if ((pi->pubpi.radiorev == 7) + || (pi->pubpi.radiorev == 8)) { - if (CHSPEC_IS2G(pi->radio_chanspec)) { - rccal_tx20_11n_bcap = 0xc; - rccal_tx20_11n_scap = 0xc; - rccal_tx40_11n_bcap = 0xa; - rccal_tx40_11n_scap = 0xa; - } else { - rccal_tx20_11n_bcap = 0x14; - rccal_tx20_11n_scap = 0x14; - rccal_tx40_11n_bcap = 0xf; - rccal_tx40_11n_scap = 0xf; - } + tx_lpf_bw_ofdm_20mhz = 4; + tx_lpf_bw_11b = 1; - rccal_ovrd = true; + if (CHSPEC_IS2G(pi->radio_chanspec)) { + rccal_tx20_11n_bcap = 0xc; + rccal_tx20_11n_scap = 0xc; + rccal_tx40_11n_bcap = 0xa; + rccal_tx40_11n_scap = 0xa; + } else { + rccal_tx20_11n_bcap = 0x14; + rccal_tx20_11n_scap = 0x14; + rccal_tx40_11n_bcap = 0xf; + rccal_tx40_11n_scap = 0xf; } + + rccal_ovrd = true; } + } - } else { + } else { - if (pi->pubpi.radiorev == 5) { + if (pi->pubpi.radiorev == 5) { - tx_lpf_bw_ofdm_20mhz = 1; - tx_lpf_bw_ofdm_40mhz = 3; + tx_lpf_bw_ofdm_20mhz = 1; + tx_lpf_bw_ofdm_40mhz = 3; - rccal_bcap_val = - read_radio_reg( - pi, - RADIO_2057_RCCAL_BCAP_VAL); - rccal_scap_val = - read_radio_reg( - pi, - RADIO_2057_RCCAL_SCAP_VAL); + rccal_bcap_val = + read_radio_reg(pi, RADIO_2057_RCCAL_BCAP_VAL); + rccal_scap_val = + read_radio_reg(pi, RADIO_2057_RCCAL_SCAP_VAL); - rccal_tx20_11b_bcap = rccal_bcap_val; - rccal_tx20_11b_scap = rccal_scap_val; + rccal_tx20_11b_bcap = rccal_bcap_val; + rccal_tx20_11b_scap = rccal_scap_val; - rccal_tx20_11n_bcap = 0x13; - rccal_tx20_11n_scap = 0x11; - rccal_tx40_11n_bcap = 0x13; - rccal_tx40_11n_scap = 0x11; + rccal_tx20_11n_bcap = 0x13; + rccal_tx20_11n_scap = 0x11; + rccal_tx40_11n_bcap = 0x13; + rccal_tx40_11n_scap = 0x11; - rccal_ovrd = true; - } + rccal_ovrd = true; } + } - if (rccal_ovrd) { - - rx2tx_lpf_rc_lut_tx20_11b = - (rccal_tx20_11b_bcap << 8) | - (rccal_tx20_11b_scap << 3) | - tx_lpf_bw_11b; - rx2tx_lpf_rc_lut_tx20_11n = - (rccal_tx20_11n_bcap << 8) | - (rccal_tx20_11n_scap << 3) | - tx_lpf_bw_ofdm_20mhz; - rx2tx_lpf_rc_lut_tx40_11n = - (rccal_tx40_11n_bcap << 8) | - (rccal_tx40_11n_scap << 3) | - tx_lpf_bw_ofdm_40mhz; + if (rccal_ovrd) { - for (coreNum = 0; coreNum <= 1; coreNum++) { - wlc_phy_table_write_nphy( - pi, NPHY_TBL_ID_RFSEQ, - 1, - 0x152 + coreNum * 0x10, - 16, - &rx2tx_lpf_rc_lut_tx20_11b); - wlc_phy_table_write_nphy( - pi, NPHY_TBL_ID_RFSEQ, - 1, - 0x153 + coreNum * 0x10, - 16, - &rx2tx_lpf_rc_lut_tx20_11n); - wlc_phy_table_write_nphy( - pi, NPHY_TBL_ID_RFSEQ, - 1, - 0x154 + coreNum * 0x10, - 16, - &rx2tx_lpf_rc_lut_tx20_11n); - wlc_phy_table_write_nphy( - pi, NPHY_TBL_ID_RFSEQ, - 1, - 0x155 + coreNum * 0x10, - 16, - &rx2tx_lpf_rc_lut_tx40_11n); - wlc_phy_table_write_nphy( - pi, NPHY_TBL_ID_RFSEQ, - 1, - 0x156 + coreNum * 0x10, - 16, - &rx2tx_lpf_rc_lut_tx40_11n); - wlc_phy_table_write_nphy( - pi, NPHY_TBL_ID_RFSEQ, - 1, - 0x157 + coreNum * 0x10, - 16, - &rx2tx_lpf_rc_lut_tx40_11n); - wlc_phy_table_write_nphy( - pi, NPHY_TBL_ID_RFSEQ, - 1, - 0x158 + coreNum * 0x10, - 16, - &rx2tx_lpf_rc_lut_tx40_11n); - wlc_phy_table_write_nphy( - pi, NPHY_TBL_ID_RFSEQ, - 1, - 0x159 + coreNum * 0x10, - 16, - &rx2tx_lpf_rc_lut_tx40_11n); - } + rx2tx_lpf_rc_lut_tx20_11b = + (rccal_tx20_11b_bcap << 8) | + (rccal_tx20_11b_scap << 3) | tx_lpf_bw_11b; + rx2tx_lpf_rc_lut_tx20_11n = + (rccal_tx20_11n_bcap << 8) | + (rccal_tx20_11n_scap << 3) | tx_lpf_bw_ofdm_20mhz; + rx2tx_lpf_rc_lut_tx40_11n = + (rccal_tx40_11n_bcap << 8) | + (rccal_tx40_11n_scap << 3) | tx_lpf_bw_ofdm_40mhz; - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 4), - 1, 0x3, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID2); + for (coreNum = 0; coreNum <= 1; coreNum++) { + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 1, + 0x152 + coreNum * 0x10, 16, + &rx2tx_lpf_rc_lut_tx20_11b); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 1, + 0x153 + coreNum * 0x10, 16, + &rx2tx_lpf_rc_lut_tx20_11n); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 1, + 0x154 + coreNum * 0x10, 16, + &rx2tx_lpf_rc_lut_tx20_11n); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 1, + 0x155 + coreNum * 0x10, 16, + &rx2tx_lpf_rc_lut_tx40_11n); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 1, + 0x156 + coreNum * 0x10, 16, + &rx2tx_lpf_rc_lut_tx40_11n); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 1, + 0x157 + coreNum * 0x10, 16, + &rx2tx_lpf_rc_lut_tx40_11n); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 1, + 0x158 + coreNum * 0x10, 16, + &rx2tx_lpf_rc_lut_tx40_11n); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 1, + 0x159 + coreNum * 0x10, 16, + &rx2tx_lpf_rc_lut_tx40_11n); } - write_phy_reg(pi, 0x32f, 0x3); + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 4), 1, 0x3, 0, + NPHY_REV7_RFCTRLOVERRIDE_ID2); + } - if ((pi->pubpi.radiorev == 4) || (pi->pubpi.radiorev == 6)) - wlc_phy_rfctrl_override_nphy_rev7( - pi, (0x1 << 2), - 1, 0x3, 0, - NPHY_REV7_RFCTRLOVERRIDE_ID0); + write_phy_reg(pi, 0x32f, 0x3); - if ((pi->pubpi.radiorev == 3) || (pi->pubpi.radiorev == 4) || - (pi->pubpi.radiorev == 6)) { - if ((pi->sh->sromrev >= 8) - && (pi->sh->boardflags2 & BFL2_IPALVLSHIFT_3P3)) - ipalvlshift_3p3_war_en = 1; - - if (ipalvlshift_3p3_war_en) { - write_radio_reg(pi, RADIO_2057_GPAIO_CONFIG, - 0x5); - write_radio_reg(pi, RADIO_2057_GPAIO_SEL1, - 0x30); - write_radio_reg(pi, RADIO_2057_GPAIO_SEL0, 0x0); - or_radio_reg(pi, - RADIO_2057_RXTXBIAS_CONFIG_CORE0, - 0x1); - or_radio_reg(pi, - RADIO_2057_RXTXBIAS_CONFIG_CORE1, - 0x1); - - ipa2g_mainbias = 0x1f; - - ipa2g_casconv = 0x6f; - - ipa2g_biasfilt = 0xaa; - } else { + if ((pi->pubpi.radiorev == 4) || (pi->pubpi.radiorev == 6)) + wlc_phy_rfctrl_override_nphy_rev7(pi, (0x1 << 2), 1, 0x3, 0, + NPHY_REV7_RFCTRLOVERRIDE_ID0); - ipa2g_mainbias = 0x2b; + if ((pi->pubpi.radiorev == 3) || (pi->pubpi.radiorev == 4) || + (pi->pubpi.radiorev == 6)) { + if ((pi->sh->sromrev >= 8) + && (pi->sh->boardflags2 & BFL2_IPALVLSHIFT_3P3)) + ipalvlshift_3p3_war_en = 1; - ipa2g_casconv = 0x7f; + if (ipalvlshift_3p3_war_en) { + write_radio_reg(pi, RADIO_2057_GPAIO_CONFIG, 0x5); + write_radio_reg(pi, RADIO_2057_GPAIO_SEL1, 0x30); + write_radio_reg(pi, RADIO_2057_GPAIO_SEL0, 0x0); + or_radio_reg(pi, RADIO_2057_RXTXBIAS_CONFIG_CORE0, 0x1); + or_radio_reg(pi, RADIO_2057_RXTXBIAS_CONFIG_CORE1, 0x1); - ipa2g_biasfilt = 0xee; - } + ipa2g_mainbias = 0x1f; - if (CHSPEC_IS2G(pi->radio_chanspec)) { - for (coreNum = 0; coreNum <= 1; coreNum++) { - WRITE_RADIO_REG4(pi, RADIO_2057, CORE, - coreNum, IPA2G_IMAIN, - ipa2g_mainbias); - WRITE_RADIO_REG4(pi, RADIO_2057, CORE, - coreNum, IPA2G_CASCONV, - ipa2g_casconv); - WRITE_RADIO_REG4(pi, RADIO_2057, CORE, - coreNum, - IPA2G_BIAS_FILTER, - ipa2g_biasfilt); - } - } - } + ipa2g_casconv = 0x6f; - if (PHY_IPA(pi)) { - if (CHSPEC_IS2G(pi->radio_chanspec)) { - if ((pi->pubpi.radiorev == 3) - || (pi->pubpi.radiorev == 4) - || (pi->pubpi.radiorev == 6)) - txgm_idac_bleed = 0x7f; + ipa2g_biasfilt = 0xaa; + } else { - for (coreNum = 0; coreNum <= 1; coreNum++) { - if (txgm_idac_bleed != 0) - WRITE_RADIO_REG4( - pi, RADIO_2057, - CORE, coreNum, - TXGM_IDAC_BLEED, - txgm_idac_bleed); - } + ipa2g_mainbias = 0x2b; - if (pi->pubpi.radiorev == 5) { - - for (coreNum = 0; coreNum <= 1; - coreNum++) { - WRITE_RADIO_REG4(pi, RADIO_2057, - CORE, coreNum, - IPA2G_CASCONV, - 0x13); - WRITE_RADIO_REG4(pi, RADIO_2057, - CORE, coreNum, - IPA2G_IMAIN, - 0x1f); - WRITE_RADIO_REG4( - pi, RADIO_2057, - CORE, coreNum, - IPA2G_BIAS_FILTER, - 0xee); - WRITE_RADIO_REG4(pi, RADIO_2057, - CORE, coreNum, - PAD2G_IDACS, - 0x8a); - WRITE_RADIO_REG4( - pi, RADIO_2057, - CORE, coreNum, - PAD_BIAS_FILTER_BWS, - 0x3e); - } + ipa2g_casconv = 0x7f; - } else if ((pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) { + ipa2g_biasfilt = 0xee; + } - if (CHSPEC_IS40(pi->radio_chanspec) == - 0) { - WRITE_RADIO_REG4(pi, RADIO_2057, - CORE, 0, - IPA2G_IMAIN, - 0x14); - WRITE_RADIO_REG4(pi, RADIO_2057, - CORE, 1, - IPA2G_IMAIN, - 0x12); - } else { - WRITE_RADIO_REG4(pi, RADIO_2057, - CORE, 0, - IPA2G_IMAIN, - 0x16); - WRITE_RADIO_REG4(pi, RADIO_2057, - CORE, 1, - IPA2G_IMAIN, - 0x16); - } - } + if (CHSPEC_IS2G(pi->radio_chanspec)) { + for (coreNum = 0; coreNum <= 1; coreNum++) { + WRITE_RADIO_REG4(pi, RADIO_2057, CORE, + coreNum, IPA2G_IMAIN, + ipa2g_mainbias); + WRITE_RADIO_REG4(pi, RADIO_2057, CORE, + coreNum, IPA2G_CASCONV, + ipa2g_casconv); + WRITE_RADIO_REG4(pi, RADIO_2057, CORE, + coreNum, + IPA2G_BIAS_FILTER, + ipa2g_biasfilt); + } + } + } - } else { - freq = CHAN5G_FREQ(CHSPEC_CHANNEL( - pi->radio_chanspec)); - if (((freq >= 5180) && (freq <= 5230)) - || ((freq >= 5745) && (freq <= 5805))) { - WRITE_RADIO_REG4(pi, RADIO_2057, CORE, - 0, IPA5G_BIAS_FILTER, - 0xff); - WRITE_RADIO_REG4(pi, RADIO_2057, CORE, - 1, IPA5G_BIAS_FILTER, - 0xff); - } + if (PHY_IPA(pi)) { + if (CHSPEC_IS2G(pi->radio_chanspec)) { + if ((pi->pubpi.radiorev == 3) + || (pi->pubpi.radiorev == 4) + || (pi->pubpi.radiorev == 6)) + txgm_idac_bleed = 0x7f; + + for (coreNum = 0; coreNum <= 1; coreNum++) { + if (txgm_idac_bleed != 0) + WRITE_RADIO_REG4(pi, RADIO_2057, + CORE, coreNum, + TXGM_IDAC_BLEED, + txgm_idac_bleed); } - } else { - if (pi->pubpi.radiorev != 5) { + if (pi->pubpi.radiorev == 5) { for (coreNum = 0; coreNum <= 1; coreNum++) { + WRITE_RADIO_REG4(pi, RADIO_2057, + CORE, coreNum, + IPA2G_CASCONV, + 0x13); + WRITE_RADIO_REG4(pi, RADIO_2057, + CORE, coreNum, + IPA2G_IMAIN, + 0x1f); + WRITE_RADIO_REG4(pi, RADIO_2057, + CORE, coreNum, + IPA2G_BIAS_FILTER, + 0xee); + WRITE_RADIO_REG4(pi, RADIO_2057, + CORE, coreNum, + PAD2G_IDACS, + 0x8a); + WRITE_RADIO_REG4(pi, RADIO_2057, + CORE, coreNum, + PAD_BIAS_FILTER_BWS, + 0x3e); + } + } else if ((pi->pubpi.radiorev == 7) || + (pi->pubpi.radiorev == 8)) { + + if (CHSPEC_IS40(pi->radio_chanspec) == 0) { + WRITE_RADIO_REG4(pi, RADIO_2057, CORE, + 0, IPA2G_IMAIN, 0x14); + WRITE_RADIO_REG4(pi, RADIO_2057, CORE, + 1, IPA2G_IMAIN, 0x12); + } else { WRITE_RADIO_REG4(pi, RADIO_2057, CORE, - coreNum, - TXMIX2G_TUNE_BOOST_PU, - 0x61); + 0, IPA2G_IMAIN, 0x16); WRITE_RADIO_REG4(pi, RADIO_2057, CORE, - coreNum, - TXGM_IDAC_BLEED, 0x70); + 1, IPA2G_IMAIN, 0x16); } } - } - if (pi->pubpi.radiorev == 4) { - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, - 0x05, 16, - &afectrl_adc_ctrl1_rev7); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, - 0x15, 16, - &afectrl_adc_ctrl1_rev7); + } else { + freq = + CHAN5G_FREQ(CHSPEC_CHANNEL + (pi->radio_chanspec)); + if (((freq >= 5180) && (freq <= 5230)) + || ((freq >= 5745) && (freq <= 5805))) { + WRITE_RADIO_REG4(pi, RADIO_2057, CORE, + 0, IPA5G_BIAS_FILTER, 0xff); + WRITE_RADIO_REG4(pi, RADIO_2057, CORE, + 1, IPA5G_BIAS_FILTER, 0xff); + } + } + } else { + if (pi->pubpi.radiorev != 5) { for (coreNum = 0; coreNum <= 1; coreNum++) { WRITE_RADIO_REG4(pi, RADIO_2057, CORE, coreNum, - AFE_VCM_CAL_MASTER, 0x0); - WRITE_RADIO_REG4(pi, RADIO_2057, CORE, coreNum, - AFE_SET_VCM_I, 0x3f); + TXMIX2G_TUNE_BOOST_PU, 0x61); WRITE_RADIO_REG4(pi, RADIO_2057, CORE, coreNum, - AFE_SET_VCM_Q, 0x3f); + TXGM_IDAC_BLEED, 0x70); } - } else { - mod_phy_reg(pi, 0xa6, (0x1 << 2), (0x1 << 2)); - mod_phy_reg(pi, 0x8f, (0x1 << 2), (0x1 << 2)); - mod_phy_reg(pi, 0xa7, (0x1 << 2), (0x1 << 2)); - mod_phy_reg(pi, 0xa5, (0x1 << 2), (0x1 << 2)); - - mod_phy_reg(pi, 0xa6, (0x1 << 0), 0); - mod_phy_reg(pi, 0x8f, (0x1 << 0), (0x1 << 0)); - mod_phy_reg(pi, 0xa7, (0x1 << 0), 0); - mod_phy_reg(pi, 0xa5, (0x1 << 0), (0x1 << 0)); - - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, - 0x05, 16, - &afectrl_adc_ctrl2_rev7); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, - 0x15, 16, - &afectrl_adc_ctrl2_rev7); - - mod_phy_reg(pi, 0xa6, (0x1 << 2), 0); - mod_phy_reg(pi, 0x8f, (0x1 << 2), 0); - mod_phy_reg(pi, 0xa7, (0x1 << 2), 0); - mod_phy_reg(pi, 0xa5, (0x1 << 2), 0); } + } - write_phy_reg(pi, 0x6a, 0x2); + if (pi->pubpi.radiorev == 4) { + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 0x05, 16, + &afectrl_adc_ctrl1_rev7); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 0x15, 16, + &afectrl_adc_ctrl1_rev7); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, 256, 32, - &min_nvar_offset_6mbps); + for (coreNum = 0; coreNum <= 1; coreNum++) { + WRITE_RADIO_REG4(pi, RADIO_2057, CORE, coreNum, + AFE_VCM_CAL_MASTER, 0x0); + WRITE_RADIO_REG4(pi, RADIO_2057, CORE, coreNum, + AFE_SET_VCM_I, 0x3f); + WRITE_RADIO_REG4(pi, RADIO_2057, CORE, coreNum, + AFE_SET_VCM_Q, 0x3f); + } + } else { + mod_phy_reg(pi, 0xa6, (0x1 << 2), (0x1 << 2)); + mod_phy_reg(pi, 0x8f, (0x1 << 2), (0x1 << 2)); + mod_phy_reg(pi, 0xa7, (0x1 << 2), (0x1 << 2)); + mod_phy_reg(pi, 0xa5, (0x1 << 2), (0x1 << 2)); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 2, 0x138, 16, - &rfseq_pktgn_lpf_hpc_rev7); + mod_phy_reg(pi, 0xa6, (0x1 << 0), 0); + mod_phy_reg(pi, 0x8f, (0x1 << 0), (0x1 << 0)); + mod_phy_reg(pi, 0xa7, (0x1 << 0), 0); + mod_phy_reg(pi, 0xa5, (0x1 << 0), (0x1 << 0)); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 1, 0x141, 16, - &rfseq_pktgn_lpf_h_hpc_rev7); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 0x05, 16, + &afectrl_adc_ctrl2_rev7); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 0x15, 16, + &afectrl_adc_ctrl2_rev7); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 3, 0x133, 16, - &rfseq_htpktgn_lpf_hpc_rev7); + mod_phy_reg(pi, 0xa6, (0x1 << 2), 0); + mod_phy_reg(pi, 0x8f, (0x1 << 2), 0); + mod_phy_reg(pi, 0xa7, (0x1 << 2), 0); + mod_phy_reg(pi, 0xa5, (0x1 << 2), 0); + } - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 2, 0x146, 16, - &rfseq_cckpktgn_lpf_hpc_rev7); + write_phy_reg(pi, 0x6a, 0x2); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 1, 0x123, 16, - &rfseq_tx2rx_lpf_h_hpc_rev7); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, 256, 32, + &min_nvar_offset_6mbps); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 1, 0x12A, 16, - &rfseq_rx2tx_lpf_h_hpc_rev7); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 2, 0x138, 16, + &rfseq_pktgn_lpf_hpc_rev7); - if (CHSPEC_IS40(pi->radio_chanspec) == 0) { - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, 3, - 32, &min_nvar_val); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, - 127, 32, &min_nvar_val); - } else { - min_nvar_val = noise_var_tbl_rev7[3]; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, 3, - 32, &min_nvar_val); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 1, 0x141, 16, + &rfseq_pktgn_lpf_h_hpc_rev7); - min_nvar_val = noise_var_tbl_rev7[127]; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, - 127, 32, &min_nvar_val); - } + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 3, 0x133, 16, + &rfseq_htpktgn_lpf_hpc_rev7); - wlc_phy_workarounds_nphy_gainctrl(pi); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 2, 0x146, 16, + &rfseq_cckpktgn_lpf_hpc_rev7); - pdetrange = - (CHSPEC_IS5G(pi->radio_chanspec)) ? pi->srom_fem5g. - pdetrange : pi->srom_fem2g.pdetrange; + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 1, 0x123, 16, + &rfseq_tx2rx_lpf_h_hpc_rev7); - if (pdetrange == 0) { - chan_freq_range = - wlc_phy_get_chan_freq_range_nphy(pi, 0); - if (chan_freq_range != WL_CHAN_FREQ_RANGE_2G) { - aux_adc_vmid_rev7_core0[3] = 0x70; - aux_adc_vmid_rev7_core1[3] = 0x70; - aux_adc_gain_rev7[3] = 2; - } else { - aux_adc_vmid_rev7_core0[3] = 0x80; - aux_adc_vmid_rev7_core1[3] = 0x80; - aux_adc_gain_rev7[3] = 3; - } - } else if (pdetrange == 1) { - if (chan_freq_range != WL_CHAN_FREQ_RANGE_2G) { - aux_adc_vmid_rev7_core0[3] = 0x7c; - aux_adc_vmid_rev7_core1[3] = 0x7c; - aux_adc_gain_rev7[3] = 2; - } else { - aux_adc_vmid_rev7_core0[3] = 0x8c; - aux_adc_vmid_rev7_core1[3] = 0x8c; - aux_adc_gain_rev7[3] = 1; - } - } else if (pdetrange == 2) { - if (pi->pubpi.radioid == BCM2057_ID) { - if ((pi->pubpi.radiorev == 5) - || (pi->pubpi.radiorev == 7) - || (pi->pubpi.radiorev == 8)) { - if (chan_freq_range == - WL_CHAN_FREQ_RANGE_2G) { - aux_adc_vmid_rev7_core0[3] = - 0x8c; - aux_adc_vmid_rev7_core1[3] = - 0x8c; - aux_adc_gain_rev7[3] = 0; - } else { - aux_adc_vmid_rev7_core0[3] = - 0x96; - aux_adc_vmid_rev7_core1[3] = - 0x96; - aux_adc_gain_rev7[3] = 0; - } + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_RFSEQ, 1, 0x12A, 16, + &rfseq_rx2tx_lpf_h_hpc_rev7); + + if (CHSPEC_IS40(pi->radio_chanspec) == 0) { + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, 3, + 32, &min_nvar_val); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, + 127, 32, &min_nvar_val); + } else { + min_nvar_val = noise_var_tbl_rev7[3]; + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, 3, + 32, &min_nvar_val); + + min_nvar_val = noise_var_tbl_rev7[127]; + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, + 127, 32, &min_nvar_val); + } + + wlc_phy_workarounds_nphy_gainctrl(pi); + + pdetrange = (CHSPEC_IS5G(pi->radio_chanspec)) ? + pi->srom_fem5g.pdetrange : pi->srom_fem2g.pdetrange; + + if (pdetrange == 0) { + chan_freq_range = wlc_phy_get_chan_freq_range_nphy(pi, 0); + if (chan_freq_range != WL_CHAN_FREQ_RANGE_2G) { + aux_adc_vmid_rev7_core0[3] = 0x70; + aux_adc_vmid_rev7_core1[3] = 0x70; + aux_adc_gain_rev7[3] = 2; + } else { + aux_adc_vmid_rev7_core0[3] = 0x80; + aux_adc_vmid_rev7_core1[3] = 0x80; + aux_adc_gain_rev7[3] = 3; + } + } else if (pdetrange == 1) { + if (chan_freq_range != WL_CHAN_FREQ_RANGE_2G) { + aux_adc_vmid_rev7_core0[3] = 0x7c; + aux_adc_vmid_rev7_core1[3] = 0x7c; + aux_adc_gain_rev7[3] = 2; + } else { + aux_adc_vmid_rev7_core0[3] = 0x8c; + aux_adc_vmid_rev7_core1[3] = 0x8c; + aux_adc_gain_rev7[3] = 1; + } + } else if (pdetrange == 2) { + if (pi->pubpi.radioid == BCM2057_ID) { + if ((pi->pubpi.radiorev == 5) + || (pi->pubpi.radiorev == 7) + || (pi->pubpi.radiorev == 8)) { + if (chan_freq_range == + WL_CHAN_FREQ_RANGE_2G) { + aux_adc_vmid_rev7_core0[3] = 0x8c; + aux_adc_vmid_rev7_core1[3] = 0x8c; + aux_adc_gain_rev7[3] = 0; + } else { + aux_adc_vmid_rev7_core0[3] = 0x96; + aux_adc_vmid_rev7_core1[3] = 0x96; + aux_adc_gain_rev7[3] = 0; } } + } - } else if (pdetrange == 3) { - if (chan_freq_range == WL_CHAN_FREQ_RANGE_2G) { - aux_adc_vmid_rev7_core0[3] = 0x89; - aux_adc_vmid_rev7_core1[3] = 0x89; - aux_adc_gain_rev7[3] = 0; - } + } else if (pdetrange == 3) { + if (chan_freq_range == WL_CHAN_FREQ_RANGE_2G) { + aux_adc_vmid_rev7_core0[3] = 0x89; + aux_adc_vmid_rev7_core1[3] = 0x89; + aux_adc_gain_rev7[3] = 0; + } - } else if (pdetrange == 5) { + } else if (pdetrange == 5) { - if (chan_freq_range != WL_CHAN_FREQ_RANGE_2G) { - aux_adc_vmid_rev7_core0[3] = 0x80; - aux_adc_vmid_rev7_core1[3] = 0x80; - aux_adc_gain_rev7[3] = 3; - } else { - aux_adc_vmid_rev7_core0[3] = 0x70; - aux_adc_vmid_rev7_core1[3] = 0x70; - aux_adc_gain_rev7[3] = 2; - } + if (chan_freq_range != WL_CHAN_FREQ_RANGE_2G) { + aux_adc_vmid_rev7_core0[3] = 0x80; + aux_adc_vmid_rev7_core1[3] = 0x80; + aux_adc_gain_rev7[3] = 3; + } else { + aux_adc_vmid_rev7_core0[3] = 0x70; + aux_adc_vmid_rev7_core1[3] = 0x70; + aux_adc_gain_rev7[3] = 2; } + } - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, 0x08, 16, - &aux_adc_vmid_rev7_core0); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, 0x18, 16, - &aux_adc_vmid_rev7_core1); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, 0x0c, 16, - &aux_adc_gain_rev7); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, 0x1c, 16, - &aux_adc_gain_rev7); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, 0x08, 16, + &aux_adc_vmid_rev7_core0); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, 0x18, 16, + &aux_adc_vmid_rev7_core1); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, 0x0c, 16, + &aux_adc_gain_rev7); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, 0x1c, 16, + &aux_adc_gain_rev7); } static void wlc_phy_workarounds_nphy_rev3(struct brcms_phy *pi) @@ -16672,7 +16599,8 @@ static void wlc_phy_workarounds_nphy_rev3(struct brcms_phy *pi) NPHY_REV3_RFSEQ_CMD_INT_PA_PU, NPHY_REV3_RFSEQ_CMD_END }; - static const u8 rfseq_rx2tx_dlys_rev3_ipa[] = { 8, 6, 6, 4, 4, 16, 43, 1, 1 }; + static const u8 rfseq_rx2tx_dlys_rev3_ipa[] = + { 8, 6, 6, 4, 4, 16, 43, 1, 1 }; s16 alpha0, alpha1, alpha2; s16 beta0, beta1, beta2; u32 leg_data_weights, ht_data_weights, nss1_data_weights, @@ -16691,330 +16619,290 @@ static void wlc_phy_workarounds_nphy_rev3(struct brcms_phy *pi) u8 pdetrange; u8 triso; - write_phy_reg(pi, 0x23f, 0x1f8); - write_phy_reg(pi, 0x240, 0x1f8); - - wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_CMPMETRICDATAWEIGHTTBL, - 1, 0, 32, &leg_data_weights); - leg_data_weights = leg_data_weights & 0xffffff; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CMPMETRICDATAWEIGHTTBL, - 1, 0, 32, &leg_data_weights); - - alpha0 = 293; - alpha1 = 435; - alpha2 = 261; - beta0 = 366; - beta1 = 205; - beta2 = 32; - write_phy_reg(pi, 0x145, alpha0); - write_phy_reg(pi, 0x146, alpha1); - write_phy_reg(pi, 0x147, alpha2); - write_phy_reg(pi, 0x148, beta0); - write_phy_reg(pi, 0x149, beta1); - write_phy_reg(pi, 0x14a, beta2); - - write_phy_reg(pi, 0x38, 0xC); - write_phy_reg(pi, 0x2ae, 0xC); - - wlc_phy_set_rfseq_nphy(pi, NPHY_RFSEQ_TX2RX, - rfseq_tx2rx_events_rev3, - rfseq_tx2rx_dlys_rev3, - ARRAY_SIZE(rfseq_tx2rx_events_rev3)); - - if (PHY_IPA(pi)) - wlc_phy_set_rfseq_nphy(pi, NPHY_RFSEQ_RX2TX, - rfseq_rx2tx_events_rev3_ipa, - rfseq_rx2tx_dlys_rev3_ipa, - ARRAY_SIZE(rfseq_rx2tx_events_rev3_ipa)); - - if ((pi->sh->hw_phyrxchain != 0x3) && - (pi->sh->hw_phyrxchain != pi->sh->hw_phytxchain)) { - - if (PHY_IPA(pi)) { - rfseq_rx2tx_dlys_rev3[5] = 59; - rfseq_rx2tx_dlys_rev3[6] = 1; - rfseq_rx2tx_events_rev3[7] = - NPHY_REV3_RFSEQ_CMD_END; - } - - wlc_phy_set_rfseq_nphy( - pi, NPHY_RFSEQ_RX2TX, - rfseq_rx2tx_events_rev3, - rfseq_rx2tx_dlys_rev3, - ARRAY_SIZE(rfseq_rx2tx_events_rev3)); - } + write_phy_reg(pi, 0x23f, 0x1f8); + write_phy_reg(pi, 0x240, 0x1f8); + + wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_CMPMETRICDATAWEIGHTTBL, + 1, 0, 32, &leg_data_weights); + leg_data_weights = leg_data_weights & 0xffffff; + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CMPMETRICDATAWEIGHTTBL, + 1, 0, 32, &leg_data_weights); + + alpha0 = 293; + alpha1 = 435; + alpha2 = 261; + beta0 = 366; + beta1 = 205; + beta2 = 32; + write_phy_reg(pi, 0x145, alpha0); + write_phy_reg(pi, 0x146, alpha1); + write_phy_reg(pi, 0x147, alpha2); + write_phy_reg(pi, 0x148, beta0); + write_phy_reg(pi, 0x149, beta1); + write_phy_reg(pi, 0x14a, beta2); + + write_phy_reg(pi, 0x38, 0xC); + write_phy_reg(pi, 0x2ae, 0xC); + + wlc_phy_set_rfseq_nphy(pi, NPHY_RFSEQ_TX2RX, + rfseq_tx2rx_events_rev3, + rfseq_tx2rx_dlys_rev3, + ARRAY_SIZE(rfseq_tx2rx_events_rev3)); - if (CHSPEC_IS2G(pi->radio_chanspec)) - write_phy_reg(pi, 0x6a, 0x2); - else - write_phy_reg(pi, 0x6a, 0x9c40); - - mod_phy_reg(pi, 0x294, (0xf << 8), (7 << 8)); + if (PHY_IPA(pi)) + wlc_phy_set_rfseq_nphy(pi, NPHY_RFSEQ_RX2TX, + rfseq_rx2tx_events_rev3_ipa, + rfseq_rx2tx_dlys_rev3_ipa, + ARRAY_SIZE (rfseq_rx2tx_events_rev3_ipa)); - if (CHSPEC_IS40(pi->radio_chanspec) == 0) { - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, 3, - 32, &min_nvar_val); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, - 127, 32, &min_nvar_val); - } else { - min_nvar_val = noise_var_tbl_rev3[3]; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, 3, - 32, &min_nvar_val); + if ((pi->sh->hw_phyrxchain != 0x3) && + (pi->sh->hw_phyrxchain != pi->sh->hw_phytxchain)) { - min_nvar_val = noise_var_tbl_rev3[127]; - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, - 127, 32, &min_nvar_val); + if (PHY_IPA(pi)) { + rfseq_rx2tx_dlys_rev3[5] = 59; + rfseq_rx2tx_dlys_rev3[6] = 1; + rfseq_rx2tx_events_rev3[7] = NPHY_REV3_RFSEQ_CMD_END; } - wlc_phy_workarounds_nphy_gainctrl(pi); + wlc_phy_set_rfseq_nphy(pi, NPHY_RFSEQ_RX2TX, + rfseq_rx2tx_events_rev3, + rfseq_rx2tx_dlys_rev3, + ARRAY_SIZE (rfseq_rx2tx_events_rev3)); + } - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 0x00, 16, - &dac_control); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 0x10, 16, - &dac_control); + if (CHSPEC_IS2G(pi->radio_chanspec)) + write_phy_reg(pi, 0x6a, 0x2); + else + write_phy_reg(pi, 0x6a, 0x9c40); - pdetrange = - (CHSPEC_IS5G(pi->radio_chanspec)) ? pi->srom_fem5g. - pdetrange : pi->srom_fem2g.pdetrange; + mod_phy_reg(pi, 0x294, (0xf << 8), (7 << 8)); - if (pdetrange == 0) { - if (NREV_GE(pi->pubpi.phy_rev, 4)) { - aux_adc_vmid = aux_adc_vmid_rev4; - aux_adc_gain = aux_adc_gain_rev4; - } else { - aux_adc_vmid = aux_adc_vmid_rev3; - aux_adc_gain = aux_adc_gain_rev3; - } - chan_freq_range = - wlc_phy_get_chan_freq_range_nphy(pi, 0); - if (chan_freq_range != WL_CHAN_FREQ_RANGE_2G) { - switch (chan_freq_range) { - case WL_CHAN_FREQ_RANGE_5GL: - aux_adc_vmid[3] = 0x89; - aux_adc_gain[3] = 0; - break; - case WL_CHAN_FREQ_RANGE_5GM: - aux_adc_vmid[3] = 0x89; - aux_adc_gain[3] = 0; - break; - case WL_CHAN_FREQ_RANGE_5GH: - aux_adc_vmid[3] = 0x89; - aux_adc_gain[3] = 0; - break; - default: - break; - } - } - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, - 0x08, 16, aux_adc_vmid); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, - 0x18, 16, aux_adc_vmid); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, - 0x0c, 16, aux_adc_gain); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, - 0x1c, 16, aux_adc_gain); - } else if (pdetrange == 1) { - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, - 0x08, 16, sk_adc_vmid); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, - 0x18, 16, sk_adc_vmid); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, - 0x0c, 16, sk_adc_gain); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, - 0x1c, 16, sk_adc_gain); - } else if (pdetrange == 2) { + if (CHSPEC_IS40(pi->radio_chanspec) == 0) { + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, 3, + 32, &min_nvar_val); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, + 127, 32, &min_nvar_val); + } else { + min_nvar_val = noise_var_tbl_rev3[3]; + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, 3, + 32, &min_nvar_val); - u16 bcm_adc_vmid[] = { 0xa2, 0xb4, 0xb4, 0x74 }; - u16 bcm_adc_gain[] = { 0x02, 0x02, 0x02, 0x04 }; + min_nvar_val = noise_var_tbl_rev3[127]; + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_NOISEVAR, 1, + 127, 32, &min_nvar_val); + } - if (NREV_GE(pi->pubpi.phy_rev, 6)) { - chan_freq_range = - wlc_phy_get_chan_freq_range_nphy(pi, 0); - if (chan_freq_range != WL_CHAN_FREQ_RANGE_2G) { - bcm_adc_vmid[3] = 0x8e; - bcm_adc_gain[3] = 0x03; - } else { - bcm_adc_vmid[3] = 0x94; - bcm_adc_gain[3] = 0x03; - } - } else if (NREV_IS(pi->pubpi.phy_rev, 5)) { - bcm_adc_vmid[3] = 0x84; - bcm_adc_gain[3] = 0x02; - } + wlc_phy_workarounds_nphy_gainctrl(pi); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, - 0x08, 16, bcm_adc_vmid); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, - 0x18, 16, bcm_adc_vmid); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, - 0x0c, 16, bcm_adc_gain); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, - 0x1c, 16, bcm_adc_gain); - } else if (pdetrange == 3) { - chan_freq_range = - wlc_phy_get_chan_freq_range_nphy(pi, 0); - if ((NREV_GE(pi->pubpi.phy_rev, 4)) - && (chan_freq_range == WL_CHAN_FREQ_RANGE_2G)) { + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 0x00, 16, + &dac_control); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 0x10, 16, + &dac_control); - u16 auxadc_vmid[] = { - 0xa2, 0xb4, 0xb4, 0x270 - }; - u16 auxadc_gain[] = { - 0x02, 0x02, 0x02, 0x00 - }; + pdetrange = (CHSPEC_IS5G(pi->radio_chanspec)) ? + pi->srom_fem5g.pdetrange : pi->srom_fem2g.pdetrange; - wlc_phy_table_write_nphy(pi, - NPHY_TBL_ID_AFECTRL, 4, - 0x08, 16, auxadc_vmid); - wlc_phy_table_write_nphy(pi, - NPHY_TBL_ID_AFECTRL, 4, - 0x18, 16, auxadc_vmid); - wlc_phy_table_write_nphy(pi, - NPHY_TBL_ID_AFECTRL, 4, - 0x0c, 16, auxadc_gain); - wlc_phy_table_write_nphy(pi, - NPHY_TBL_ID_AFECTRL, 4, - 0x1c, 16, auxadc_gain); + if (pdetrange == 0) { + if (NREV_GE(pi->pubpi.phy_rev, 4)) { + aux_adc_vmid = aux_adc_vmid_rev4; + aux_adc_gain = aux_adc_gain_rev4; + } else { + aux_adc_vmid = aux_adc_vmid_rev3; + aux_adc_gain = aux_adc_gain_rev3; + } + chan_freq_range = wlc_phy_get_chan_freq_range_nphy(pi, 0); + if (chan_freq_range != WL_CHAN_FREQ_RANGE_2G) { + switch (chan_freq_range) { + case WL_CHAN_FREQ_RANGE_5GL: + aux_adc_vmid[3] = 0x89; + aux_adc_gain[3] = 0; + break; + case WL_CHAN_FREQ_RANGE_5GM: + aux_adc_vmid[3] = 0x89; + aux_adc_gain[3] = 0; + break; + case WL_CHAN_FREQ_RANGE_5GH: + aux_adc_vmid[3] = 0x89; + aux_adc_gain[3] = 0; + break; + default: + break; } - } else if ((pdetrange == 4) || (pdetrange == 5)) { - u16 bcm_adc_vmid[] = { 0xa2, 0xb4, 0xb4, 0x0 }; - u16 bcm_adc_gain[] = { 0x02, 0x02, 0x02, 0x0 }; - u16 Vmid[2], Av[2]; + } + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, + 0x08, 16, aux_adc_vmid); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, + 0x18, 16, aux_adc_vmid); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, + 0x0c, 16, aux_adc_gain); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, + 0x1c, 16, aux_adc_gain); + } else if (pdetrange == 1) { + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, + 0x08, 16, sk_adc_vmid); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, + 0x18, 16, sk_adc_vmid); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, + 0x0c, 16, sk_adc_gain); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, + 0x1c, 16, sk_adc_gain); + } else if (pdetrange == 2) { + + u16 bcm_adc_vmid[] = { 0xa2, 0xb4, 0xb4, 0x74 }; + u16 bcm_adc_gain[] = { 0x02, 0x02, 0x02, 0x04 }; + if (NREV_GE(pi->pubpi.phy_rev, 6)) { chan_freq_range = - wlc_phy_get_chan_freq_range_nphy(pi, 0); + wlc_phy_get_chan_freq_range_nphy(pi, 0); if (chan_freq_range != WL_CHAN_FREQ_RANGE_2G) { - Vmid[0] = (pdetrange == 4) ? 0x8e : 0x89; - Vmid[1] = (pdetrange == 4) ? 0x96 : 0x89; - Av[0] = (pdetrange == 4) ? 2 : 0; - Av[1] = (pdetrange == 4) ? 2 : 0; + bcm_adc_vmid[3] = 0x8e; + bcm_adc_gain[3] = 0x03; } else { - Vmid[0] = (pdetrange == 4) ? 0x89 : 0x74; - Vmid[1] = (pdetrange == 4) ? 0x8b : 0x70; - Av[0] = (pdetrange == 4) ? 2 : 0; - Av[1] = (pdetrange == 4) ? 2 : 0; + bcm_adc_vmid[3] = 0x94; + bcm_adc_gain[3] = 0x03; } + } else if (NREV_IS(pi->pubpi.phy_rev, 5)) { + bcm_adc_vmid[3] = 0x84; + bcm_adc_gain[3] = 0x02; + } + + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, + 0x08, 16, bcm_adc_vmid); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, + 0x18, 16, bcm_adc_vmid); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, + 0x0c, 16, bcm_adc_gain); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, + 0x1c, 16, bcm_adc_gain); + } else if (pdetrange == 3) { + chan_freq_range = wlc_phy_get_chan_freq_range_nphy(pi, 0); + if ((NREV_GE(pi->pubpi.phy_rev, 4)) && + (chan_freq_range == WL_CHAN_FREQ_RANGE_2G)) { + u16 auxadc_vmid[] = { 0xa2, 0xb4, 0xb4, 0x270 }; + u16 auxadc_gain[] = { 0x02, 0x02, 0x02, 0x00 }; - bcm_adc_vmid[3] = Vmid[0]; - bcm_adc_gain[3] = Av[0]; wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, - 0x08, 16, bcm_adc_vmid); + 0x08, 16, auxadc_vmid); wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, - 0x0c, 16, bcm_adc_gain); - - bcm_adc_vmid[3] = Vmid[1]; - bcm_adc_gain[3] = Av[1]; + 0x18, 16, auxadc_vmid); wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, - 0x18, 16, bcm_adc_vmid); + 0x0c, 16, auxadc_gain); wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, - 0x1c, 16, bcm_adc_gain); + 0x1c, 16, auxadc_gain); } + } else if ((pdetrange == 4) || (pdetrange == 5)) { + u16 bcm_adc_vmid[] = { 0xa2, 0xb4, 0xb4, 0x0 }; + u16 bcm_adc_gain[] = { 0x02, 0x02, 0x02, 0x0 }; + u16 Vmid[2], Av[2]; - write_radio_reg(pi, - (RADIO_2056_RX_MIXA_MAST_BIAS | RADIO_2056_RX0), - 0x0); - write_radio_reg(pi, - (RADIO_2056_RX_MIXA_MAST_BIAS | RADIO_2056_RX1), - 0x0); + chan_freq_range = wlc_phy_get_chan_freq_range_nphy(pi, 0); + if (chan_freq_range != WL_CHAN_FREQ_RANGE_2G) { + Vmid[0] = (pdetrange == 4) ? 0x8e : 0x89; + Vmid[1] = (pdetrange == 4) ? 0x96 : 0x89; + Av[0] = (pdetrange == 4) ? 2 : 0; + Av[1] = (pdetrange == 4) ? 2 : 0; + } else { + Vmid[0] = (pdetrange == 4) ? 0x89 : 0x74; + Vmid[1] = (pdetrange == 4) ? 0x8b : 0x70; + Av[0] = (pdetrange == 4) ? 2 : 0; + Av[1] = (pdetrange == 4) ? 2 : 0; + } - write_radio_reg(pi, - (RADIO_2056_RX_MIXA_BIAS_MAIN | RADIO_2056_RX0), - 0x6); - write_radio_reg(pi, - (RADIO_2056_RX_MIXA_BIAS_MAIN | RADIO_2056_RX1), - 0x6); + bcm_adc_vmid[3] = Vmid[0]; + bcm_adc_gain[3] = Av[0]; + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, + 0x08, 16, bcm_adc_vmid); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, + 0x0c, 16, bcm_adc_gain); + + bcm_adc_vmid[3] = Vmid[1]; + bcm_adc_gain[3] = Av[1]; + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, + 0x18, 16, bcm_adc_vmid); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4, + 0x1c, 16, bcm_adc_gain); + } - write_radio_reg(pi, - (RADIO_2056_RX_MIXA_BIAS_AUX | RADIO_2056_RX0), - 0x7); - write_radio_reg(pi, - (RADIO_2056_RX_MIXA_BIAS_AUX | RADIO_2056_RX1), - 0x7); + write_radio_reg(pi, (RADIO_2056_RX_MIXA_MAST_BIAS | RADIO_2056_RX0), 0x0); + write_radio_reg(pi, (RADIO_2056_RX_MIXA_MAST_BIAS | RADIO_2056_RX1), 0x0); - write_radio_reg(pi, - (RADIO_2056_RX_MIXA_LOB_BIAS | RADIO_2056_RX0), - 0x88); - write_radio_reg(pi, - (RADIO_2056_RX_MIXA_LOB_BIAS | RADIO_2056_RX1), - 0x88); + write_radio_reg(pi, (RADIO_2056_RX_MIXA_BIAS_MAIN | RADIO_2056_RX0), 0x6); + write_radio_reg(pi, (RADIO_2056_RX_MIXA_BIAS_MAIN | RADIO_2056_RX1), 0x6); - write_radio_reg(pi, - (RADIO_2056_RX_MIXA_CMFB_IDAC | RADIO_2056_RX0), - 0x0); - write_radio_reg(pi, - (RADIO_2056_RX_MIXA_CMFB_IDAC | RADIO_2056_RX1), - 0x0); + write_radio_reg(pi, (RADIO_2056_RX_MIXA_BIAS_AUX | RADIO_2056_RX0), 0x7); + write_radio_reg(pi, (RADIO_2056_RX_MIXA_BIAS_AUX | RADIO_2056_RX1), 0x7); - write_radio_reg(pi, - (RADIO_2056_RX_MIXG_CMFB_IDAC | RADIO_2056_RX0), - 0x0); - write_radio_reg(pi, - (RADIO_2056_RX_MIXG_CMFB_IDAC | RADIO_2056_RX1), - 0x0); + write_radio_reg(pi, (RADIO_2056_RX_MIXA_LOB_BIAS | RADIO_2056_RX0), 0x88); + write_radio_reg(pi, (RADIO_2056_RX_MIXA_LOB_BIAS | RADIO_2056_RX1), 0x88); - triso = - (CHSPEC_IS5G(pi->radio_chanspec)) ? pi->srom_fem5g. - triso : pi->srom_fem2g.triso; - if (triso == 7) { - wlc_phy_war_force_trsw_to_R_cliplo_nphy(pi, PHY_CORE_0); - wlc_phy_war_force_trsw_to_R_cliplo_nphy(pi, PHY_CORE_1); - } + write_radio_reg(pi, (RADIO_2056_RX_MIXA_CMFB_IDAC | RADIO_2056_RX0), 0x0); + write_radio_reg(pi, (RADIO_2056_RX_MIXA_CMFB_IDAC | RADIO_2056_RX1), 0x0); - wlc_phy_war_txchain_upd_nphy(pi, pi->sh->hw_phytxchain); + write_radio_reg(pi, (RADIO_2056_RX_MIXG_CMFB_IDAC | RADIO_2056_RX0), 0x0); + write_radio_reg(pi, (RADIO_2056_RX_MIXG_CMFB_IDAC | RADIO_2056_RX1), 0x0); - if (((pi->sh->boardflags2 & BFL2_APLL_WAR) && - (CHSPEC_IS5G(pi->radio_chanspec))) || - (((pi->sh->boardflags2 & BFL2_GPLL_WAR) || - (pi->sh->boardflags2 & BFL2_GPLL_WAR2)) && - (CHSPEC_IS2G(pi->radio_chanspec)))) { - nss1_data_weights = 0x00088888; - ht_data_weights = 0x00088888; - stbc_data_weights = 0x00088888; - } else { - nss1_data_weights = 0x88888888; - ht_data_weights = 0x88888888; - stbc_data_weights = 0x88888888; - } - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CMPMETRICDATAWEIGHTTBL, - 1, 1, 32, &nss1_data_weights); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CMPMETRICDATAWEIGHTTBL, - 1, 2, 32, &ht_data_weights); - wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CMPMETRICDATAWEIGHTTBL, - 1, 3, 32, &stbc_data_weights); - - if (NREV_IS(pi->pubpi.phy_rev, 4)) { - if (CHSPEC_IS5G(pi->radio_chanspec)) { - write_radio_reg(pi, - RADIO_2056_TX_GMBB_IDAC | - RADIO_2056_TX0, 0x70); - write_radio_reg(pi, - RADIO_2056_TX_GMBB_IDAC | - RADIO_2056_TX1, 0x70); - } - } + triso = (CHSPEC_IS5G(pi->radio_chanspec)) ? + pi->srom_fem5g.triso : pi->srom_fem2g.triso; + if (triso == 7) { + wlc_phy_war_force_trsw_to_R_cliplo_nphy(pi, PHY_CORE_0); + wlc_phy_war_force_trsw_to_R_cliplo_nphy(pi, PHY_CORE_1); + } - if (!pi->edcrs_threshold_lock) { - write_phy_reg(pi, 0x224, 0x3eb); - write_phy_reg(pi, 0x225, 0x3eb); - write_phy_reg(pi, 0x226, 0x341); - write_phy_reg(pi, 0x227, 0x341); - write_phy_reg(pi, 0x228, 0x42b); - write_phy_reg(pi, 0x229, 0x42b); - write_phy_reg(pi, 0x22a, 0x381); - write_phy_reg(pi, 0x22b, 0x381); - write_phy_reg(pi, 0x22c, 0x42b); - write_phy_reg(pi, 0x22d, 0x42b); - write_phy_reg(pi, 0x22e, 0x381); - write_phy_reg(pi, 0x22f, 0x381); + wlc_phy_war_txchain_upd_nphy(pi, pi->sh->hw_phytxchain); + + if (((pi->sh->boardflags2 & BFL2_APLL_WAR) && + (CHSPEC_IS5G(pi->radio_chanspec))) || + (((pi->sh->boardflags2 & BFL2_GPLL_WAR) || + (pi->sh->boardflags2 & BFL2_GPLL_WAR2)) && + (CHSPEC_IS2G(pi->radio_chanspec)))) { + nss1_data_weights = 0x00088888; + ht_data_weights = 0x00088888; + stbc_data_weights = 0x00088888; + } else { + nss1_data_weights = 0x88888888; + ht_data_weights = 0x88888888; + stbc_data_weights = 0x88888888; + } + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CMPMETRICDATAWEIGHTTBL, + 1, 1, 32, &nss1_data_weights); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CMPMETRICDATAWEIGHTTBL, + 1, 2, 32, &ht_data_weights); + wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_CMPMETRICDATAWEIGHTTBL, + 1, 3, 32, &stbc_data_weights); + + if (NREV_IS(pi->pubpi.phy_rev, 4)) { + if (CHSPEC_IS5G(pi->radio_chanspec)) { + write_radio_reg(pi, + RADIO_2056_TX_GMBB_IDAC | + RADIO_2056_TX0, 0x70); + write_radio_reg(pi, + RADIO_2056_TX_GMBB_IDAC | + RADIO_2056_TX1, 0x70); } + } - if (NREV_GE(pi->pubpi.phy_rev, 6)) { + if (!pi->edcrs_threshold_lock) { + write_phy_reg(pi, 0x224, 0x3eb); + write_phy_reg(pi, 0x225, 0x3eb); + write_phy_reg(pi, 0x226, 0x341); + write_phy_reg(pi, 0x227, 0x341); + write_phy_reg(pi, 0x228, 0x42b); + write_phy_reg(pi, 0x229, 0x42b); + write_phy_reg(pi, 0x22a, 0x381); + write_phy_reg(pi, 0x22b, 0x381); + write_phy_reg(pi, 0x22c, 0x42b); + write_phy_reg(pi, 0x22d, 0x42b); + write_phy_reg(pi, 0x22e, 0x381); + write_phy_reg(pi, 0x22f, 0x381); + } - if (pi->sh->boardflags2 & BFL2_SINGLEANT_CCK) - wlapi_bmac_mhf(pi->sh->physhim, MHF4, - MHF4_BPHY_TXCORE0, - MHF4_BPHY_TXCORE0, BRCM_BAND_ALL); - } + if (NREV_GE(pi->pubpi.phy_rev, 6)) { + + if (pi->sh->boardflags2 & BFL2_SINGLEANT_CCK) + wlapi_bmac_mhf(pi->sh->physhim, MHF4, + MHF4_BPHY_TXCORE0, + MHF4_BPHY_TXCORE0, BRCM_BAND_ALL); + } } void wlc_phy_workarounds_nphy_rev1(struct brcms_phy *pi) @@ -17043,102 +16931,101 @@ void wlc_phy_workarounds_nphy_rev1(struct brcms_phy *pi) s16 beta0, beta1, beta2; u16 regval; - if (pi->sh->boardflags2 & BFL2_SKWRKFEM_BRD || - (pi->sh->boardtype == 0x8b)) { - uint i; - u8 war_dlys[] = { 1, 6, 6, 2, 4, 20, 1 }; - for (i = 0; i < ARRAY_SIZE(rfseq_rx2tx_dlys); i++) - rfseq_rx2tx_dlys[i] = war_dlys[i]; - } + if (pi->sh->boardflags2 & BFL2_SKWRKFEM_BRD || + (pi->sh->boardtype == 0x8b)) { + uint i; + u8 war_dlys[] = { 1, 6, 6, 2, 4, 20, 1 }; + for (i = 0; i < ARRAY_SIZE(rfseq_rx2tx_dlys); i++) + rfseq_rx2tx_dlys[i] = war_dlys[i]; + } - if (CHSPEC_IS5G(pi->radio_chanspec) && pi->phy_5g_pwrgain) { - and_radio_reg(pi, RADIO_2055_CORE1_TX_RF_SPARE, 0xf7); - and_radio_reg(pi, RADIO_2055_CORE2_TX_RF_SPARE, 0xf7); - } else { - or_radio_reg(pi, RADIO_2055_CORE1_TX_RF_SPARE, 0x8); - or_radio_reg(pi, RADIO_2055_CORE2_TX_RF_SPARE, 0x8); - } + if (CHSPEC_IS5G(pi->radio_chanspec) && pi->phy_5g_pwrgain) { + and_radio_reg(pi, RADIO_2055_CORE1_TX_RF_SPARE, 0xf7); + and_radio_reg(pi, RADIO_2055_CORE2_TX_RF_SPARE, 0xf7); + } else { + or_radio_reg(pi, RADIO_2055_CORE1_TX_RF_SPARE, 0x8); + or_radio_reg(pi, RADIO_2055_CORE2_TX_RF_SPARE, 0x8); + } - regval = 0x000a; - wlc_phy_table_write_nphy(pi, 8, 1, 0, 16, ®val); - wlc_phy_table_write_nphy(pi, 8, 1, 0x10, 16, ®val); + regval = 0x000a; + wlc_phy_table_write_nphy(pi, 8, 1, 0, 16, ®val); + wlc_phy_table_write_nphy(pi, 8, 1, 0x10, 16, ®val); - if (NREV_LT(pi->pubpi.phy_rev, 3)) { - regval = 0xcdaa; - wlc_phy_table_write_nphy(pi, 8, 1, 0x02, 16, ®val); - wlc_phy_table_write_nphy(pi, 8, 1, 0x12, 16, ®val); - } + if (NREV_LT(pi->pubpi.phy_rev, 3)) { + regval = 0xcdaa; + wlc_phy_table_write_nphy(pi, 8, 1, 0x02, 16, ®val); + wlc_phy_table_write_nphy(pi, 8, 1, 0x12, 16, ®val); + } - if (NREV_LT(pi->pubpi.phy_rev, 2)) { - regval = 0x0000; - wlc_phy_table_write_nphy(pi, 8, 1, 0x08, 16, ®val); - wlc_phy_table_write_nphy(pi, 8, 1, 0x18, 16, ®val); + if (NREV_LT(pi->pubpi.phy_rev, 2)) { + regval = 0x0000; + wlc_phy_table_write_nphy(pi, 8, 1, 0x08, 16, ®val); + wlc_phy_table_write_nphy(pi, 8, 1, 0x18, 16, ®val); - regval = 0x7aab; - wlc_phy_table_write_nphy(pi, 8, 1, 0x07, 16, ®val); - wlc_phy_table_write_nphy(pi, 8, 1, 0x17, 16, ®val); + regval = 0x7aab; + wlc_phy_table_write_nphy(pi, 8, 1, 0x07, 16, ®val); + wlc_phy_table_write_nphy(pi, 8, 1, 0x17, 16, ®val); - regval = 0x0800; - wlc_phy_table_write_nphy(pi, 8, 1, 0x06, 16, ®val); - wlc_phy_table_write_nphy(pi, 8, 1, 0x16, 16, ®val); - } + regval = 0x0800; + wlc_phy_table_write_nphy(pi, 8, 1, 0x06, 16, ®val); + wlc_phy_table_write_nphy(pi, 8, 1, 0x16, 16, ®val); + } - write_phy_reg(pi, 0xf8, 0x02d8); - write_phy_reg(pi, 0xf9, 0x0301); - write_phy_reg(pi, 0xfa, 0x02d8); - write_phy_reg(pi, 0xfb, 0x0301); + write_phy_reg(pi, 0xf8, 0x02d8); + write_phy_reg(pi, 0xf9, 0x0301); + write_phy_reg(pi, 0xfa, 0x02d8); + write_phy_reg(pi, 0xfb, 0x0301); - wlc_phy_set_rfseq_nphy(pi, NPHY_RFSEQ_RX2TX, rfseq_rx2tx_events, - rfseq_rx2tx_dlys, - ARRAY_SIZE(rfseq_rx2tx_events)); + wlc_phy_set_rfseq_nphy(pi, NPHY_RFSEQ_RX2TX, rfseq_rx2tx_events, + rfseq_rx2tx_dlys, + ARRAY_SIZE(rfseq_rx2tx_events)); - wlc_phy_set_rfseq_nphy(pi, NPHY_RFSEQ_TX2RX, rfseq_tx2rx_events, - rfseq_tx2rx_dlys, - ARRAY_SIZE(rfseq_tx2rx_events)); + wlc_phy_set_rfseq_nphy(pi, NPHY_RFSEQ_TX2RX, rfseq_tx2rx_events, + rfseq_tx2rx_dlys, + ARRAY_SIZE(rfseq_tx2rx_events)); - wlc_phy_workarounds_nphy_gainctrl(pi); + wlc_phy_workarounds_nphy_gainctrl(pi); - if (NREV_LT(pi->pubpi.phy_rev, 2)) { + if (NREV_LT(pi->pubpi.phy_rev, 2)) { - if (read_phy_reg(pi, 0xa0) & NPHY_MLenable) - wlapi_bmac_mhf(pi->sh->physhim, MHF3, - MHF3_NPHY_MLADV_WAR, - MHF3_NPHY_MLADV_WAR, - BRCM_BAND_ALL); + if (read_phy_reg(pi, 0xa0) & NPHY_MLenable) + wlapi_bmac_mhf(pi->sh->physhim, MHF3, + MHF3_NPHY_MLADV_WAR, + MHF3_NPHY_MLADV_WAR, BRCM_BAND_ALL); - } else if (NREV_IS(pi->pubpi.phy_rev, 2)) { - write_phy_reg(pi, 0x1e3, 0x0); - write_phy_reg(pi, 0x1e4, 0x0); - } + } else if (NREV_IS(pi->pubpi.phy_rev, 2)) { + write_phy_reg(pi, 0x1e3, 0x0); + write_phy_reg(pi, 0x1e4, 0x0); + } - if (NREV_LT(pi->pubpi.phy_rev, 2)) - mod_phy_reg(pi, 0x90, (0x1 << 7), 0); - - alpha0 = 293; - alpha1 = 435; - alpha2 = 261; - beta0 = 366; - beta1 = 205; - beta2 = 32; - write_phy_reg(pi, 0x145, alpha0); - write_phy_reg(pi, 0x146, alpha1); - write_phy_reg(pi, 0x147, alpha2); - write_phy_reg(pi, 0x148, beta0); - write_phy_reg(pi, 0x149, beta1); - write_phy_reg(pi, 0x14a, beta2); - - if (NREV_LT(pi->pubpi.phy_rev, 3)) { - mod_phy_reg(pi, 0x142, (0xf << 12), 0); - - write_phy_reg(pi, 0x192, 0xb5); - write_phy_reg(pi, 0x193, 0xa4); - write_phy_reg(pi, 0x194, 0x0); - } + if (NREV_LT(pi->pubpi.phy_rev, 2)) + mod_phy_reg(pi, 0x90, (0x1 << 7), 0); + + alpha0 = 293; + alpha1 = 435; + alpha2 = 261; + beta0 = 366; + beta1 = 205; + beta2 = 32; + write_phy_reg(pi, 0x145, alpha0); + write_phy_reg(pi, 0x146, alpha1); + write_phy_reg(pi, 0x147, alpha2); + write_phy_reg(pi, 0x148, beta0); + write_phy_reg(pi, 0x149, beta1); + write_phy_reg(pi, 0x14a, beta2); + + if (NREV_LT(pi->pubpi.phy_rev, 3)) { + mod_phy_reg(pi, 0x142, (0xf << 12), 0); + + write_phy_reg(pi, 0x192, 0xb5); + write_phy_reg(pi, 0x193, 0xa4); + write_phy_reg(pi, 0x194, 0x0); + } - if (NREV_IS(pi->pubpi.phy_rev, 2)) - mod_phy_reg(pi, 0x221, - NPHY_FORCESIG_DECODEGATEDCLKS, - NPHY_FORCESIG_DECODEGATEDCLKS); + if (NREV_IS(pi->pubpi.phy_rev, 2)) + mod_phy_reg(pi, 0x221, + NPHY_FORCESIG_DECODEGATEDCLKS, + NPHY_FORCESIG_DECODEGATEDCLKS); } static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) From patchwork Wed Jun 14 21:15:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 105594 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp490561qgd; Wed, 14 Jun 2017 14:23:08 -0700 (PDT) X-Received: by 10.84.237.2 with SMTP id s2mr2202858plk.176.1497475388120; Wed, 14 Jun 2017 14:23:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497475388; cv=none; d=google.com; s=arc-20160816; b=bPog4xLlrZeUQfYpVvlsVtzPRWkqw+ZS6YF+d7wQ9z9bnLhtLBzUw/mh35p4Eoqktl XPQLTEcHLl7NjL5GaBBRu9Eg4fwwjT8Wwr85MvmzIMQhNBXIyGT28qcXnfVcE8/F1nJS 0SpFDa4ILpvIOEl1QctH3y4s+VQi7avRWLwds3UE6TPkB1ZGmvbXUWSQB+LyYxhh65sv /NjLDTkM2rFtgmx9cGDRbeS9q2aDzxXuqDdskoUWj5FG8NRzjjyBVjCrrf/3PQ8LcfTY fEqSu1qt9m0pYrZ8GRSNZx/LlmUrtaezKvAxm6eLe0Ej4m9nc3r82tyZZVf3riCHuJ6P 6jLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=vhzMS+cAe3tKF/GyIlcaidIe3N3KrdX49cWF9enqk5s=; b=l72TDgeg4NTqsiWbZhIkcbXmVSs52rgLjf1zbO9SgIVOuCSRu0L76l7AyIm2PGWlDl zsClGTFRrdUV85YQf8rYqwlykSj6QIvuBlNYePUIv1GWvQfrHY2F2+gnxdFzfEFHc6GL NDGz3GHkagywny8ei11mM+nUOf7r7Rm6DzaVBTSaQ8JXj//9ymSVRQ0Azff4Z93TvmxE ADbgOICd8JscaQrTGczPc8E5i7P7o8da4OxgqYowYSX9ZVJ1mtI73l/sSO4aBS306o7b 4VRiZWtr0nzu5gtG0kQZ4dfPd75o5n5+s3BdBWa3CpQC1W4x8XYsC98W0vjHi0oL6A/+ tlIw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x13si809052plm.99.2017.06.14.14.23.07; Wed, 14 Jun 2017 14:23:08 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752609AbdFNVXF (ORCPT + 25 others); Wed, 14 Jun 2017 17:23:05 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:57132 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752097AbdFNVXC (ORCPT ); Wed, 14 Jun 2017 17:23:02 -0400 Received: from wuerfel.lan ([78.42.17.5]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.129]) with ESMTPA (Nemesis) id 0MVmFr-1dKTcB1Pjz-00Z2aB; Wed, 14 Jun 2017 23:22:36 +0200 From: Arnd Bergmann To: Andrew Morton Cc: kasan-dev@googlegroups.com, Dmitry Vyukov , Alexander Potapenko , Andrey Ryabinin , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Arend van Spriel , Arnd Bergmann , Masahiro Yamada , Michal Marek , Kees Cook , Ingo Molnar , "David S. Miller" , linux-kbuild@vger.kernel.org Subject: [PATCH v2 11/11] kasan: rework Kconfig settings Date: Wed, 14 Jun 2017 23:15:46 +0200 Message-Id: <20170614211556.2062728-12-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170614211556.2062728-1-arnd@arndb.de> References: <20170614211556.2062728-1-arnd@arndb.de> X-Provags-ID: V03:K0:UC7R7148ukV/h+Xmfsb2bH5fU43HSGyW7dIgEYMkIjvRsF7ox38 yI+qtRIP5YLlX/s/Fs/lLB1ARVt/vh/8dxvN57jQOOgDaJtXylYf1cuYyrkaOTUtvzy3Y/4 vUxmFV5iVBOgET8ddZ4+dVruQWSzkEHCygOOHucXdnC7rteb5S/qKvIYSXv3gGaZbRG/PA2 RVbExV4O+/67zfMbw4ekw== X-UI-Out-Filterresults: notjunk:1; V01:K0:XWEPciEX5bM=:Gfxx6OFGPpG+Izumbj12Cv p+yaeTNfWmZto3R13FC/joMeIs1b6ZG6IfBcQjdgvWznsfH6RFwP1EQOOUxYIdA6grV5sNU1L 81Dzcn8xoGS3317ah/2FrHL2DYgKFD6+8aeNKS5LUOfwRc3lRuXNNVLPgjrJFAo2E7vaLRn4t Q21gRPCzq/JNdBHX+EhjoK9tw7+n1dl2s4jkJpjJcxgARFWFWRPViJwE56F5yHHIEfKUMMe3q prFNtmr6omgmWHvFd1V+TcU2aO0M+Nh44OBGvIn8gmnYbiQo+nSJMMuANp3PJ3igLxlTw83sX 5DZOzxbFkFKiBsl6FjPIhc8+WyJ1xOXkz8+H6vKhLCd3O+u+Pb6ENqQeprdF6KUres7HuBMC7 GplzkhCBkJ9UYOvFLArYnZJsaorkuL52oL34gnECIkrExpZgMykBaMr+TWQad6WSfMzBeZg0T B29KaFjiq1ZO9SwsuuTrK30ea9oF8m3P/p/Oabsg98+5pbS1f4puEuMZd1NR9XnYnMgNsiUbG wDBoaXWTl/bxFp8Fp4zc7lcbt7vutNznEJadJvaDoEDV3axKrAnIG2p7E9aUsGU2K/RgR1/8G furp6TEf8KICZe168NYzXaIYpCRDFcZ2nlgcQMoXYvgeIxUToXxbSu9eizjAe4RcXlt4IRZkf sR7xyWseirCqdvsoTNRRy5gokv0sFLmC2JQgURwrmGp7zreq18iuolxRdCkhXKwLvR0Q= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We get a lot of very large stack frames using gcc-7.0.1 with the default -fsanitize-address-use-after-scope --param asan-stack=1 options, which can easily cause an overflow of the kernel stack, e.g. drivers/acpi/nfit/core.c:2686:1: warning: the frame size of 4080 bytes is larger than 2048 bytes [-Wframe-larger-than=] drivers/gpu/drm/amd/amdgpu/si.c:1756:1: warning: the frame size of 7304 bytes is larger than 2048 bytes [-Wframe-larger-than=] drivers/gpu/drm/i915/gvt/handlers.c:2200:1: warning: the frame size of 43752 bytes is larger than 2048 bytes [-Wframe-larger-than=] drivers/gpu/drm/vmwgfx/vmwgfx_drv.c:952:1: warning: the frame size of 6032 bytes is larger than 2048 bytes [-Wframe-larger-than=] drivers/isdn/hardware/avm/b1.c:637:1: warning: the frame size of 13200 bytes is larger than 2048 bytes [-Wframe-larger-than=] drivers/media/dvb-frontends/stv090x.c:3089:1: warning: the frame size of 5880 bytes is larger than 2048 bytes [-Wframe-larger-than=] drivers/media/i2c/cx25840/cx25840-core.c:4964:1: warning: the frame size of 93992 bytes is larger than 2048 bytes [-Wframe-larger-than=] drivers/net/wireless/ralink/rt2x00/rt2800lib.c:4994:1: warning: the frame size of 23928 bytes is larger than 2048 bytes [-Wframe-larger-than=] drivers/staging/dgnc/dgnc_tty.c:2788:1: warning: the frame size of 7072 bytes is larger than 2048 bytes [-Wframe-larger-than=] fs/ntfs/mft.c:2762:1: warning: the frame size of 7432 bytes is larger than 2048 bytes [-Wframe-larger-than=] lib/atomic64_test.c:242:1: warning: the frame size of 12648 bytes is larger than 2048 bytes [-Wframe-larger-than=] To reduce this risk, -fsanitize-address-use-after-scope is now split out into a separate Kconfig option, vhich cannot be selected at the same time as KMEMCHECK, leading to stack frames that are smaller than 2 kilobytes most of the time on x86_64. An earlier version of this patch also prevented combining KASAN_EXTRA with KASAN_INLINE, but that is no longer necessary with gcc-7.0.1. A lot of warnings with KASAN_EXTRA go away if we disable KMEMCHECK, as -fsanitize-address-use-after-scope seems to understand the builtin memcpy, but adds checking code around an extern memcpy call. I had to work around a circular dependency, as DEBUG_SLAB/SLUB depended on !KMEMCHECK, while KASAN did it the other way round. Now we handle both the same way. All patches to get the frame size below 2048 bytes with CONFIG_KASAN=y and CONFIG_KASAN_EXTRA=n have been submitted along with this patch, so we can bring back that default now. KASAN_EXTRA=y still causes lots of warnings but now defaults to !COMPILE_TEST to disable it in allmodconfig, and it remains disabled in all other defconfigs since it is a new option. This reverts parts of commit commit 3f181b4 ("lib/Kconfig.debug: disable -Wframe-larger-than warnings with KASAN=y"). I experimented a bit more with smaller stack frames and have another follow-up series that reduces the warning limit for 64-bit architectures to 1280 bytes and 1536 when CONFIG_KASAN (but not KASAN_EXTRA) is enabled, this requires another ~25 patches to address the additional warnings. I also have patches for all KASAN_EXTRA warnings, but we should look at those separately and then decide whether to remove it completely, leaving out -fsanitize-address-use-after-scope. Signed-off-by: Arnd Bergmann --- lib/Kconfig.debug | 4 ++-- lib/Kconfig.kasan | 11 ++++++++++- lib/Kconfig.kmemcheck | 1 + scripts/Makefile.kasan | 3 +++ 4 files changed, 16 insertions(+), 3 deletions(-) -- 2.9.0 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index ddbef2cac189..02ec4a4da7b1 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -217,7 +217,7 @@ config ENABLE_MUST_CHECK config FRAME_WARN int "Warn for stack frames larger than (needs gcc 4.4)" range 0 8192 - default 0 if KASAN + default 3072 if KASAN_EXTRA default 2048 if GCC_PLUGIN_LATENT_ENTROPY default 1024 if !64BIT default 2048 if 64BIT @@ -500,7 +500,7 @@ config DEBUG_OBJECTS_ENABLE_DEFAULT config DEBUG_SLAB bool "Debug slab memory allocations" - depends on DEBUG_KERNEL && SLAB && !KMEMCHECK + depends on DEBUG_KERNEL && SLAB && !KMEMCHECK && !KASAN help Say Y here to have the kernel do limited verification on memory allocation as well as poisoning memory on free to catch use of freed diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan index bd38aab05929..4d17a8f4742f 100644 --- a/lib/Kconfig.kasan +++ b/lib/Kconfig.kasan @@ -5,7 +5,7 @@ if HAVE_ARCH_KASAN config KASAN bool "KASan: runtime memory debugger" - depends on SLUB || (SLAB && !DEBUG_SLAB) + depends on SLUB || SLAB select CONSTRUCTORS select STACKDEPOT help @@ -20,6 +20,15 @@ config KASAN Currently CONFIG_KASAN doesn't work with CONFIG_DEBUG_SLAB (the resulting kernel does not boot). +config KASAN_EXTRA + bool "KAsan: extra checks" + depends on KASAN && !COMPILE_TEST + help + This enables further checks in the kernel address sanitizer, for now + it only includes the address-use-after-scope check that can lead + to excessive kernel stack usage, frame size warnings and longer + compile time. + choice prompt "Instrumentation type" depends on KASAN diff --git a/lib/Kconfig.kmemcheck b/lib/Kconfig.kmemcheck index 846e039a86b4..58b9f3f81dc8 100644 --- a/lib/Kconfig.kmemcheck +++ b/lib/Kconfig.kmemcheck @@ -7,6 +7,7 @@ menuconfig KMEMCHECK bool "kmemcheck: trap use of uninitialized memory" depends on DEBUG_KERNEL depends on !X86_USE_3DNOW + depends on !KASAN_EXTRA depends on SLUB || SLAB depends on !CC_OPTIMIZE_FOR_SIZE depends on !FUNCTION_TRACER diff --git a/scripts/Makefile.kasan b/scripts/Makefile.kasan index 9576775a86f6..3b3148faf866 100644 --- a/scripts/Makefile.kasan +++ b/scripts/Makefile.kasan @@ -29,5 +29,8 @@ else endif endif +ifdef CONFIG_KASAN_EXTRA CFLAGS_KASAN += $(call cc-option, -fsanitize-address-use-after-scope) endif + +endif