Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp438761pxy; Wed, 5 May 2021 06:03:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxclHpgtZFg6CbpjnI3qU/RI3jYDc/pvrrFSeHitY8YRAjYST07AVP5tewGIt+Ucddqw3LJ X-Received: by 2002:a17:906:c297:: with SMTP id r23mr27305202ejz.144.1620219797048; Wed, 05 May 2021 06:03:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620219797; cv=none; d=google.com; s=arc-20160816; b=IZqRsBoT94pQZuldthfUWMBb/GpyUPXGCIw6J04oKoqAiM6Reot6astFM+gAked7Iq 8/TfiARwGe1oYez0q6dr2C2+yz0OmjwEFK+RFEfOu4uq7mIPg1d+ZKcQ8Rr0sERSe3p+ eSZUhVV84ovl0suSOSeIoz63oXr/lRzfWPrByWUf3kpOHpo6/2hCuKkdd02gqkfl4H3W VBbPQYG0J8in9pF9Rqfxj+/qYhIEFOpiKtL2ERETBv6/Dw24cHY03Y109cvyn9Pn+a16 bhPbqRnLY0UsegpGy29l8DdD6+N5XGc6ReZx4CWtVH7/mQLk8tJ8Eorhk68/ymVQZb6w uTow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=kOqgZ3ZRMy0tlrHsf7RCrYq/TwiHxXEEQjJHOD1CnYQ=; b=mREBQUYP1cuCOWnhegpcphtCT0NbWK2gqr9wVeXLeYWCcDaYDKuwUgKsFc+3sB9V3t mdj4ygqIun9BPSRoHgn4EQYzvsMEhkE4ODZKKxOAeCgXZCMS0zdr6loKRpMBcERU6Ytc S5hlsL79FB7FoWcYQvu6mrdA+5qDiSeTySz4AnnUDeClY2BvGgZg/jQv+Pj3ImZgOBTB 5vzZLZlzxPSDrBKjjw0vFk+s8fvPQYY5egWBZrvRodGUS8N0ipx5AKasegKcSltk3J40 GZeWN13vXWob1RugDQk3nuEuqHYRDrcx/6UbyDyA2mWF6gBApNGXuDcgau4IvWHyUmhj 0gAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QSDVus1b; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s25si5735422edy.17.2021.05.05.06.02.48; Wed, 05 May 2021 06:03:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QSDVus1b; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233153AbhEEND0 (ORCPT + 99 others); Wed, 5 May 2021 09:03:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:43814 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233225AbhEENCp (ORCPT ); Wed, 5 May 2021 09:02:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620219706; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kOqgZ3ZRMy0tlrHsf7RCrYq/TwiHxXEEQjJHOD1CnYQ=; b=QSDVus1b6RwlswwKrDGUhDxg+7Pp84SlY1RR6S7kVXBdyfumLOMOjCIaYdARlR5Qdzs4Fu eWzytig6XjnWzxrohxnyggJBGegpN9YhOpLoNWSA107AZOsCCt0IHsFMaY8FDsIqgV+uLp ol3zU2mJaBlmYEL3ztj1gDxQOQCoP2A= Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-400-sCvcxL_AO3mnw9xr6v544Q-1; Wed, 05 May 2021 09:01:40 -0400 X-MC-Unique: sCvcxL_AO3mnw9xr6v544Q-1 Received: by mail-pl1-f199.google.com with SMTP id l18-20020a170902e2d2b02900eefb0acd12so203852plc.18 for ; Wed, 05 May 2021 06:01:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=kOqgZ3ZRMy0tlrHsf7RCrYq/TwiHxXEEQjJHOD1CnYQ=; b=gJ1C0O6VR37ThS5U3n27o1dPiweVHrcMcNWwLc4SyscJ3QyVVgBi2tlBOmhB7TWBco k6zfrf40IFL3s6xOrI97qfM2+MlDEay3nnWEtctiEVG13mRy/ehiiPWxk43FhQmvdht7 alvgsm0op+R8ZX1V6TDNE9KrXL2i99kC3DdnAA4tPVFJT+Ifjf2NprCmbWYRuWRQTeEv Y4MhU7vQYGTyDPNxNanolbrGouawQzLxcRq7fpEt2ZnDUkT8Fxnfkv3VbvxVHYM89yoT 6MK+tr7n+es11gJgNu+TSRsbbUCmMcrn21Uim4t+LapXzDDYBtsO0iYS191Fq7pOP4k+ QQFw== X-Gm-Message-State: AOAM531B+3OM5snP2YUsS2MqizP14KoOanO/AFTjpALpBuAXSMFale/k hvUzMNeEaX459dHtyEfKbLsfmmITHJa2Y0BpkAtcXpQBL1IoqaQvLh4hpH2ETQMb9JsoCK/+LBU J2ad2a9t9xMNHtfCjn8FeZufne7b/zJMX/SSdw4Oh3jE= X-Received: by 2002:a62:808b:0:b029:252:eddc:afb0 with SMTP id j133-20020a62808b0000b0290252eddcafb0mr29611017pfd.41.1620219699389; Wed, 05 May 2021 06:01:39 -0700 (PDT) X-Received: by 2002:a62:808b:0:b029:252:eddc:afb0 with SMTP id j133-20020a62808b0000b0290252eddcafb0mr29610979pfd.41.1620219699037; Wed, 05 May 2021 06:01:39 -0700 (PDT) MIME-Version: 1.0 References: <1620216779.15370.10.camel@realtek.com> In-Reply-To: <1620216779.15370.10.camel@realtek.com> From: Inigo Huguet Date: Wed, 5 May 2021 15:01:27 +0200 Message-ID: Subject: Re: rtlwifi: potential bugs To: Pkshih Cc: "linux-wireless@vger.kernel.org" , "ivecera@redhat.com" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Hi, Thanks for the info. Maybe we should consider adding some comments to clarify this? Other people might also think these are bugs... Regards, On Wed, May 5, 2021 at 2:13 PM Pkshih wrote: > > On Wed, 2021-05-05 at 11:23 +0000, Inigo Huguet wrote: > > On Fri, Apr 23, 2021 at 2:56 PM Inigo Huguet wrote= : > > > > > > Hello, > > > > > > Executing some static analysis on the kernel, we've got this results > > > affecting rtlwifi drivers: > > > > > > Error: IDENTICAL_BRANCHES (CWE-398): [#def212] > > > kernel-5.11.0-0.rc7.151/linux-5.11.0-0.rc7.151.el9.x86_64/drivers/net= /wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.c:2813: > > > identical_branches: The same code is executed regardless of whether > > > "bt_rssi_state =3D=3D BTC_RSSI_STATE_HIGH || bt_rssi_state =3D=3D > > > BTC_RSSI_STATE_STAY_HIGH" is true, because the 'then' and 'else' > > > branches are identical. Should one of the branches be modified, or th= e > > > entire 'if' statement replaced? > > > # 2811| } > > > # 2812| > > > # 2813|-> if ((bt_rssi_state =3D=3D BTC_RSSI_STATE_HIGH) || > > > # 2814| (bt_rssi_state =3D=3D BTC_RSSI_STATE_STAY_HIGH)) { > > > # 2815| btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 23); > > > > > > Error: IDENTICAL_BRANCHES (CWE-398): [#def213] > > > kernel-5.11.0-0.rc7.151/linux-5.11.0-0.rc7.151.el9.x86_64/drivers/net= /wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.c:2947: > > > identical_branches: The same code is executed regardless of whether > > > "bt_rssi_state =3D=3D BTC_RSSI_STATE_HIGH || bt_rssi_state =3D=3D > > > BTC_RSSI_STATE_STAY_HIGH" is true, because the 'then' and 'else' > > > branches are identical. Should one of the branches be modified, or th= e > > > entire 'if' statement replaced? > > > # 2945| } > > > # 2946| > > > # 2947|-> if ((bt_rssi_state =3D=3D BTC_RSSI_STATE_HIGH) || > > > # 2948| (bt_rssi_state =3D=3D BTC_RSSI_STATE_STAY_HIGH)) > > > # 2949| btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 26); > > > > > > Error: IDENTICAL_BRANCHES (CWE-398): [#def214] > > > kernel-5.11.0-0.rc7.151/linux-5.11.0-0.rc7.151.el9.x86_64/drivers/net= /wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.c:3135: > > > identical_branches: The same code is executed regardless of whether > > > "wifi_bw =3D=3D BTC_WIFI_BW_LEGACY" is true, because the 'then' and '= else' > > > branches are identical. Should one of the branches be modified, or th= e > > > entire 'if' statement replaced? > > > # 3133| btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw)= ; > > > # 3134| > > > # 3135|-> if (wifi_bw =3D=3D BTC_WIFI_BW_LEGACY) { > > > # 3136| /* for HID at 11b/g mode */ > > > # 3137| btc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, > > > > > > Error: IDENTICAL_BRANCHES (CWE-398): [#def215] > > > kernel-5.11.0-0.rc7.151/linux-5.11.0-0.rc7.151.el9.x86_64/drivers/net= /wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.c:3324: > > > identical_branches: The same code is executed regardless of whether > > > "bt_rssi_state =3D=3D BTC_RSSI_STATE_HIGH || bt_rssi_state =3D=3D > > > BTC_RSSI_STATE_STAY_HIGH" is true, because the 'then' and 'else' > > > branches are identical. Should one of the branches be modified, or th= e > > > entire 'if' statement replaced? > > > # 3322| } > > > # 3323| > > > # 3324|-> if ((bt_rssi_state =3D=3D BTC_RSSI_STATE_HIGH) || > > > # 3325| (bt_rssi_state =3D=3D BTC_RSSI_STATE_STAY_HIGH)) { > > > # 3326| btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 23); > > > > > > > > > In my opinion, they seem to be real bugs. However, it's very difficul= t > > > to imagine what actions must be taken on each branch of the if-else > > > because they strongly depend on magic numbers, which are different > > > configurations for the hw, I guess. > > > > > > Can the maintainers confirm if these are real bugs and see how to fix= them? > > > > > > Regards > > > -- > > > =C3=8D=C3=B1igo Huguet > > > > Hello, > > > > A few weeks ago I sent the message above notifying a potential bug in > > rtlwifi module. I just wanted to be sure that it has been received. > > Can the maintainers acknowledge whether they have seen it? > > > > Hi, > > Not real bugs. The coexistence programmers preserve the same code of > branches intentionally to fine tune performance easier, because bandwidth= and > RSSI strength are highly related to coexistence performance. > The basic rule of performance tuning is to assign most time slot to BT > for realtime application, and WiFi uses remaining time slot but don't low= er > than low bound. > > -- > Ping-Ke --=20 =C3=8D=C3=B1igo Huguet