From patchwork Wed Jun 10 15:21:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chi-Hsien Lin X-Patchwork-Id: 215357 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45748C433DF for ; Wed, 10 Jun 2020 15:21:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1AC9720734 for ; Wed, 10 Jun 2020 15:21:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=cypress.com header.i=@cypress.com header.b="FtG5wBg9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728474AbgFJPVW (ORCPT ); Wed, 10 Jun 2020 11:21:22 -0400 Received: from mail-eopbgr750110.outbound.protection.outlook.com ([40.107.75.110]:38746 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727102AbgFJPVV (ORCPT ); Wed, 10 Jun 2020 11:21:21 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h7t1lPhwOnmghy7DhZ19YUvyaWEMe04gK1ZYPM4H8qMtq7+gl+qwHhUqSBJo4i7ofIUsfMax2RFmBfdsxyJfzbnyjWL4pYtCZOk7TKy1EF16aXw1LERkFKh83WTT9dZcGV7NzAyqMh8K5MT/GOgv68Jw6UIrpmfaYY9cVag0sNUKr36w92YiYiAZ7ggxBy8MbU2KHOwMfUl5zikf9HpPQVTVFMxLdx1tjJibzkSHba92lrtfaLD1bOsxR0XNAWpY/uLVpeAi8Rl1WNnoCuZLqTa0+po8LrXfwehj0wql6sSYn3AoCQg2sv2QSRbQXC6fPpLmQ2MYWvPTlK4VhMDq/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F6hCBd/N3JOcl/l1jLoYrGAz18ECTLlK0LAuxUBiMCQ=; b=C+eTh22xa5xzH6GFIw0V66XIAczqaUFX0ZV6mTCZWsB0KrL4NYbNbqh4oftBibX+jdWN1qcQLKmQ61wWofkkfPwYk22MDkosvAhue7yI2n43sZ/xPhaEchHTHRFfpDhc3DUtsShk9pkr/SOdR/V2u19/7lJXlyu5kkwRMEpo6gMAp2ziVz9A3u+tsVXZBQNcTNGCyCZX+WuUvBMyfeMYP6taqJOMDiahWnBkQDeu0sZYkEGdzACrrUxb/53f/VUp2MOLIrSLBphJ3k51KrcVMhidWNMAI1xlQ89Z9F6pkqU1Ofoh5tdnrsbCmSku2d5QoK/DN5N2dvCyENOedhgUhg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cypress.com; dmarc=pass action=none header.from=cypress.com; dkim=pass header.d=cypress.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cypress.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F6hCBd/N3JOcl/l1jLoYrGAz18ECTLlK0LAuxUBiMCQ=; b=FtG5wBg927ggKLD+8UfLWcenBsUhst8sPOsKU/UOkC1h3hbTg1vQ6c3dlwS6rJfYydDTcP9EsEGasYNO90/L4la1/zGCC+lETEoLw1v0EDxGylBYxbdpe/2H++lQYYzMyHEy5RdVtW9Y4o7PrY3HdXsNZ70RY+YxgAttyN8XuA4= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=cypress.com; Received: from BYAPR06MB4901.namprd06.prod.outlook.com (2603:10b6:a03:7a::30) by BYAPR06MB5621.namprd06.prod.outlook.com (2603:10b6:a03:ab::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.22; Wed, 10 Jun 2020 15:21:18 +0000 Received: from BYAPR06MB4901.namprd06.prod.outlook.com ([fe80::b972:c25d:c8fc:fc0e]) by BYAPR06MB4901.namprd06.prod.outlook.com ([fe80::b972:c25d:c8fc:fc0e%7]) with mapi id 15.20.3088.018; Wed, 10 Jun 2020 15:21:18 +0000 From: Chi-Hsien Lin To: linux-wireless@vger.kernel.org Cc: brcm80211-dev-list@broadcom.com, brcm80211-dev-list@cypress.com, Arend van Spriel , Franky Lin , Hante Meuleman , Wright Feng , Kalle Valo , Raveendran Somu , Jia-Shyr Chuang , Chung-Hsien Hsu , Chi-hsien Lin Subject: [PATCH V2 1/6] brcmfmac: allow credit borrowing for all access categories Date: Wed, 10 Jun 2020 10:21:01 -0500 Message-Id: <20200610152106.175257-2-chi-hsien.lin@cypress.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200610152106.175257-1-chi-hsien.lin@cypress.com> References: <20200610152106.175257-1-chi-hsien.lin@cypress.com> X-ClientProxiedBy: MN2PR08CA0019.namprd08.prod.outlook.com (2603:10b6:208:239::24) To BYAPR06MB4901.namprd06.prod.outlook.com (2603:10b6:a03:7a::30) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from aremote02.aus.cypress.com (12.110.209.245) by MN2PR08CA0019.namprd08.prod.outlook.com (2603:10b6:208:239::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.21 via Frontend Transport; Wed, 10 Jun 2020 15:21:15 +0000 X-Mailer: git-send-email 2.25.0 X-Originating-IP: [12.110.209.245] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: e409f7a0-8d64-4e58-b4bc-08d80d51ebe3 X-MS-TrafficTypeDiagnostic: BYAPR06MB5621: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-Forefront-PRVS: 0430FA5CB7 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cTalAY+PqSA13QJi5E1jCAMWKnmTTEeTL+uH66kiPgkEGHq2L3m2E4N8iyZlfPrYExjfow7eWSSNiFY+m3Vqzx6SyYvxD9kWfK9uG/3+rdO/uKW8ng6bYft1V7QqnPGbEnGPmZJZjQog4SRwrzoA1F/EdwGR/Rbhk/1Ngni2Q6e0gHb0ep6aaoFv2nImebQNq70/hgKGom+C58dAWHiY4oUlMSuZn+/55sh0/fXiuOeHk3QjKPdizRLb2Scgh96FRv4cLCzShMsXHGAZ3eH6axBCX9VgvpXGGKK1Sgsh+c7E4BkZg4KOUZ9EJ1EHjpP3HIyrNhV28gZ2nzkOtFHEqw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR06MB4901.namprd06.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(396003)(366004)(136003)(39860400002)(346002)(376002)(16526019)(107886003)(2616005)(956004)(8936002)(26005)(1076003)(6916009)(316002)(6486002)(186003)(6666004)(2906002)(8676002)(7696005)(86362001)(66556008)(4326008)(36756003)(52116002)(54906003)(66476007)(5660300002)(478600001)(83380400001)(66946007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: mIPXTI5IMECyn1Z8SV2KgXKWzp4o+JUZcMZtR1qfaoRpMiLb+HHjUaRZpLN8mxxq355JLgTmMGuq4KrXd55pQp7h58oR1wdPqjmg5fkXGFTubLix1pvyhks6ZS1odB4g0lC4ejxA96Mfzhg/BD6Ra40dF882pmByNaQUXE3gEzRSe82+xZ+PlYfy2fffgJNMwNCXt9Teo9DewyVfC98e7zy0/XEE/O1BUamQEv6vK3ZyBQYeNCK05w2YClZwHI6SuYm5lQgBGwo9JPKBCp7+xc/NqP7qjl7TYFXBs65Cg7rL2ATyDpALp3rdYNld+6IUApA0Crr0dw07q/pbOil43fRpEnoXPtPBKm/nzE2np7aldrl4cbDyhBj+pFAYA2/MocxSPzdsiiFLPvljDyPv3cE788czcpj3SiQj4SbMbOxq4Fa9rsSry2XNzXg+DovJju3H2ptT5/dMfcYYU4wTALI1WAJSCI3767CY7kHBks9vOGZ2/fV46SBPvsmxCOti X-OriginatorOrg: cypress.com X-MS-Exchange-CrossTenant-Network-Message-Id: e409f7a0-8d64-4e58-b4bc-08d80d51ebe3 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jun 2020 15:21:17.8983 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 011addfc-2c09-450d-8938-e0bbc2dd2376 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5DP98hHWOYA4Iawet7blVgVZBZFFq5Y8dbtIfE+XUDnC30WqwbrRc/bcN/22SEWqrnoPqoQwLzxg9iN48RxyoQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR06MB5621 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Raveendran Somu Current credit borrowing allows only the access category BE to borrow the credits. This change is to fix the credit borrowing logic, to make borrowing available for all access categories and also to borrow only from the lower categories. This fixes WFA 802.11n certs 5.2.27 failures. Signed-off-by: Raveendran Somu Signed-off-by: Jia-Shyr Chuang Signed-off-by: Chung-Hsien Hsu Signed-off-by: Chi-hsien Lin --- .../broadcom/brcm80211/brcmfmac/fwsignal.c | 61 +++++++++++-------- 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c index 09701262330d..d7c36af4b566 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c @@ -383,6 +383,7 @@ struct brcmf_fws_mac_descriptor { }; #define BRCMF_FWS_HANGER_MAXITEMS 3072 +#define BRCMF_BORROW_RATIO 3 /** * enum brcmf_fws_hanger_item_state - state of hanger item. @@ -479,7 +480,8 @@ struct brcmf_fws_info { u32 fifo_enqpkt[BRCMF_FWS_FIFO_COUNT]; int fifo_credit[BRCMF_FWS_FIFO_COUNT]; int init_fifo_credit[BRCMF_FWS_FIFO_COUNT]; - int credits_borrowed[BRCMF_FWS_FIFO_AC_VO + 1]; + int credits_borrowed[BRCMF_FWS_FIFO_AC_VO + 1] + [BRCMF_FWS_FIFO_AC_VO + 1]; int deq_node_pos[BRCMF_FWS_FIFO_COUNT]; u32 fifo_credit_map; u32 fifo_delay_map; @@ -1185,13 +1187,11 @@ static void brcmf_fws_return_credits(struct brcmf_fws_info *fws, if (!credits) return; - fws->fifo_credit_map |= 1 << fifo; - - if ((fifo == BRCMF_FWS_FIFO_AC_BE) && - (fws->credits_borrowed[0])) { + if (fifo > BRCMF_FWS_FIFO_AC_BK && + fifo <= BRCMF_FWS_FIFO_AC_VO) { for (lender_ac = BRCMF_FWS_FIFO_AC_VO; lender_ac >= 0; lender_ac--) { - borrowed = &fws->credits_borrowed[lender_ac]; + borrowed = &fws->credits_borrowed[fifo][lender_ac]; if (*borrowed) { fws->fifo_credit_map |= (1 << lender_ac); fifo_credit = &fws->fifo_credit[lender_ac]; @@ -1208,7 +1208,11 @@ static void brcmf_fws_return_credits(struct brcmf_fws_info *fws, } } - fws->fifo_credit[fifo] += credits; + if (credits) { + fws->fifo_credit[fifo] += credits; + fws->fifo_credit_map |= 1 << fifo; + } + if (fws->fifo_credit[fifo] > fws->init_fifo_credit[fifo]) fws->fifo_credit[fifo] = fws->init_fifo_credit[fifo]; @@ -2005,27 +2009,31 @@ static void brcmf_fws_rollback_toq(struct brcmf_fws_info *fws, } } -static int brcmf_fws_borrow_credit(struct brcmf_fws_info *fws) +static int brcmf_fws_borrow_credit(struct brcmf_fws_info *fws, + int highest_lender_ac, int borrower_ac, + bool borrow_all) { - int lender_ac; + int lender_ac, borrow_limit = 0; - if (time_after(fws->borrow_defer_timestamp, jiffies)) { - fws->fifo_credit_map &= ~(1 << BRCMF_FWS_FIFO_AC_BE); - return -ENAVAIL; - } + for (lender_ac = 0; lender_ac <= highest_lender_ac; lender_ac++) { - for (lender_ac = 0; lender_ac <= BRCMF_FWS_FIFO_AC_VO; lender_ac++) { - if (fws->fifo_credit[lender_ac] > 0) { - fws->credits_borrowed[lender_ac]++; + if (!borrow_all) + borrow_limit = + fws->init_fifo_credit[lender_ac] / BRCMF_BORROW_RATIO; + else + borrow_limit = 0; + + if (fws->fifo_credit[lender_ac] > borrow_limit) { + fws->credits_borrowed[borrower_ac][lender_ac]++; fws->fifo_credit[lender_ac]--; if (fws->fifo_credit[lender_ac] == 0) fws->fifo_credit_map &= ~(1 << lender_ac); - fws->fifo_credit_map |= (1 << BRCMF_FWS_FIFO_AC_BE); + fws->fifo_credit_map |= (1 << borrower_ac); brcmf_dbg(DATA, "borrow credit from: %d\n", lender_ac); return 0; } } - fws->fifo_credit_map &= ~(1 << BRCMF_FWS_FIFO_AC_BE); + fws->fifo_credit_map &= ~(1 << borrower_ac); return -ENAVAIL; } @@ -2216,9 +2224,10 @@ static void brcmf_fws_dequeue_worker(struct work_struct *worker) } continue; } - while ((fws->fifo_credit[fifo] > 0) || + + while ((fws->fifo_credit[fifo]) || ((!fws->bcmc_credit_check) && - (fifo == BRCMF_FWS_FIFO_BCMC))) { + (fifo == BRCMF_FWS_FIFO_BCMC))) { skb = brcmf_fws_deq(fws, fifo); if (!skb) break; @@ -2228,10 +2237,14 @@ static void brcmf_fws_dequeue_worker(struct work_struct *worker) if (fws->bus_flow_blocked) break; } - if ((fifo == BRCMF_FWS_FIFO_AC_BE) && - (fws->fifo_credit[fifo] <= 0) && - (!fws->bus_flow_blocked)) { - while (brcmf_fws_borrow_credit(fws) == 0) { + + if (fifo >= BRCMF_FWS_FIFO_AC_BE && + fifo <= BRCMF_FWS_FIFO_AC_VO && + fws->fifo_credit[fifo] == 0 && + !fws->bus_flow_blocked) { + while (brcmf_fws_borrow_credit(fws, + fifo - 1, fifo, + true) == 0) { skb = brcmf_fws_deq(fws, fifo); if (!skb) { brcmf_fws_return_credits(fws, fifo, 1); From patchwork Wed Jun 10 15:21:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chi-Hsien Lin X-Patchwork-Id: 215356 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E5D3C433E2 for ; Wed, 10 Jun 2020 15:21:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 31A062078C for ; Wed, 10 Jun 2020 15:21:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=cypress.com header.i=@cypress.com header.b="CH9OBDju" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730114AbgFJPVa (ORCPT ); Wed, 10 Jun 2020 11:21:30 -0400 Received: from mail-eopbgr750110.outbound.protection.outlook.com ([40.107.75.110]:38746 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727102AbgFJPV3 (ORCPT ); Wed, 10 Jun 2020 11:21:29 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lDX7GWlT9fTnraaCodr13+SYXRlEHxI0mdIXMGrKg1ZC1BeKKiE70e/uPxj1ayvJ4h96HiLsvSNF8w3hg6LPaU+tCG9+snsz++qyt9l53MscbSQ38ad+a4JvsRWQqRez1Su/zN4gwEy5Mpuf3fdhce4J8Pkk04Th5O7Df0QX8vlZSgZCqcifFLEzX8ae6fiMwx1lV3HpOTiwif8thiGI7paGZ+b/9C99SAZiqO9+O1Vw4qaEaQKbV1nZSpoQ/zXwQ0gLlCgBRPBA2Pj9R1FDzaFove/YUAF48XUY3/8ftv8W88kocEovD+r+ucK/6KhA11TqOotAStNpPrfJb8TU4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VqvVsvBdTd4F2vCiN7cyq4Nhx8dKj4yLYoitzKtPBi0=; b=Pzybi6oZ9Xifq4213hMNGYw18U4mp7VwCN4xLHGW3n7ARrVVJuqZIdSyYDBSWQ+OWdhX8VsCPKrVWBxsHH2hxZLns/pG1lzQm+ocNL3/xEKQnaKgoCPCT2f/WeiL36SAU06QfvyAZVrx3LGs9y6GMwmTpnpjBgYLKhHqI2YzmAb4i020FWuFZncDzhfKr0vJhXQ6pzcCdJfBj1yR5bUthBv3YaTjv2G+fvohJC5s+IEmRvlXSjGStP8K7RHZft48v/KXMkT0cekROkyj2K28acJr6c3xF352gZeUapak8vNysHx8KNixcL3NqCeCH010Ga4lmSy7AkOBSi5krytmOQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cypress.com; dmarc=pass action=none header.from=cypress.com; dkim=pass header.d=cypress.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cypress.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VqvVsvBdTd4F2vCiN7cyq4Nhx8dKj4yLYoitzKtPBi0=; b=CH9OBDju80Jy4C2OkTBEEB/1p686ppm7l+gHs921HKh61hYKYn1rqNobUj9Fy63SFl5uIZvIHlamVdwggeS/ISW4ZSg8lBwGhy2xTjQ3koCh3PR5ELzWtHyS0Xb75HgU0jGYqE7cRROhXqi22FuHJmaO4/p+aB3SLQD+37zZVGg= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=cypress.com; Received: from BYAPR06MB4901.namprd06.prod.outlook.com (2603:10b6:a03:7a::30) by BYAPR06MB5621.namprd06.prod.outlook.com (2603:10b6:a03:ab::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.22; Wed, 10 Jun 2020 15:21:22 +0000 Received: from BYAPR06MB4901.namprd06.prod.outlook.com ([fe80::b972:c25d:c8fc:fc0e]) by BYAPR06MB4901.namprd06.prod.outlook.com ([fe80::b972:c25d:c8fc:fc0e%7]) with mapi id 15.20.3088.018; Wed, 10 Jun 2020 15:21:22 +0000 From: Chi-Hsien Lin To: linux-wireless@vger.kernel.org Cc: brcm80211-dev-list@broadcom.com, brcm80211-dev-list@cypress.com, Arend van Spriel , Franky Lin , Hante Meuleman , Wright Feng , Kalle Valo , Amar Shankar , Jia-Shyr Chuang , Chi-Hsien Lin Subject: [PATCH V2 3/6] brcmfmac: reserve 2 credits for host tx control path Date: Wed, 10 Jun 2020 10:21:03 -0500 Message-Id: <20200610152106.175257-4-chi-hsien.lin@cypress.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200610152106.175257-1-chi-hsien.lin@cypress.com> References: <20200610152106.175257-1-chi-hsien.lin@cypress.com> X-ClientProxiedBy: MN2PR08CA0019.namprd08.prod.outlook.com (2603:10b6:208:239::24) To BYAPR06MB4901.namprd06.prod.outlook.com (2603:10b6:a03:7a::30) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from aremote02.aus.cypress.com (12.110.209.245) by MN2PR08CA0019.namprd08.prod.outlook.com (2603:10b6:208:239::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.21 via Frontend Transport; Wed, 10 Jun 2020 15:21:20 +0000 X-Mailer: git-send-email 2.25.0 X-Originating-IP: [12.110.209.245] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: a64db2f3-8d9a-44ae-b6a8-08d80d51ee70 X-MS-TrafficTypeDiagnostic: BYAPR06MB5621: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-Forefront-PRVS: 0430FA5CB7 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: r1rsuWUhYljGNN2Wl0rS7RfY88KCyLbcdXyXaqrsToxkNvAsabcyhGk7bBVIgmOnpGb3o1EgYFuKgio6q0+230mlTtXLPFiSQFmlj2vYuWzjxoeEcMSZGNjU7Bj4c5s4+S2H07R/G7/iChBtiAylG4j1RpsDoFzVbl1nj2oEipC2AaNc4AVI4eerERN/gxztAM/94Cq4+sfuLsOel4oS4IeZTifI88tmIQBXLoVM/MIgyxQh/azocVcaGIFGT40K+YLGCtcdm2dkcZOp9qfIVO4/f5iI+N2cMQDmfRK2c40duzlythC/Xz8IdvVyeZHe X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR06MB4901.namprd06.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(396003)(366004)(136003)(39860400002)(346002)(376002)(16526019)(107886003)(2616005)(956004)(8936002)(26005)(1076003)(6916009)(316002)(6486002)(186003)(6666004)(2906002)(8676002)(7696005)(86362001)(66556008)(4326008)(36756003)(52116002)(54906003)(66476007)(5660300002)(478600001)(83380400001)(66946007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 52t2ye4kC9Fdl6Zrk/j5P857HfsXrC4Qln/NC1J4PaIB6zr59AlKlNpfEhO4EGTdFZ8T2dYWwn0y85utLAL2aadfa15rZC9gbD8ef2+jsdUpIS2BpwUsJVNu4PSemvT6fTCyiIVNDQG9ooh8uq9LBjmjxpr08lBUlQoNPHmmZDO2MjGFEXW6EfvM0APe0ecq4UoiJ5Cvi3NZTZJEGfV4L5y+OATzg4UZ8ykHQqzwxDw3KtdJQbT8qV38PISZ6xNKfv2MuM8rXPKd7hGXRTTPDuvUEy+fDODpG+3NZFvtGM7O8hMT9HHOtUGhKPNTnQur09yPUmrOlPUjMF4/4nqA4mbS/3BqZyhGLQMP8jApC8qInd0Npl3gS+cbT8kIuHBWBMaQtF4N3V2Cu3CIsFet+yR0WYUH0TgNaqEqjBUqPkiU3HQAQYzWlohIAwGV48Gb4WyyrLGwaBVgz1/IfilFTeoAZvncVgqGDlGjHw1t+ZPdC8rUiyXwNsn7p9MrbilN X-OriginatorOrg: cypress.com X-MS-Exchange-CrossTenant-Network-Message-Id: a64db2f3-8d9a-44ae-b6a8-08d80d51ee70 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jun 2020 15:21:22.5906 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 011addfc-2c09-450d-8938-e0bbc2dd2376 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 43paNZXugn2bbwaMwCoqYYY/X5wY7MaBMHczPq3k3fJCBiredLR4YbW4DnhB9m+QQDFOIeADlsymszJOZiUxBQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR06MB5621 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Amar Shankar It is observed that sometimes when sdiod is low in tx credits in low rssi scenarios, the data path consumes all sdiod rx all credits and there is no sdiod rx credit available for control path causing host and card to go out of sync resulting in link loss between host and card. So in order to prevent it some credits are reserved for control path. Note that TXCTL_CREDITS can't be larger than the firmware default credit update threshold 2; otherwise there will be a deadlock for both side waiting for each other. Signed-off-by: Amar Shankar Signed-off-by: Jia-Shyr Chuang Signed-off-by: Chi-Hsien Lin Tested-by: Dmitry Osipenko --- .../broadcom/brcm80211/brcmfmac/sdio.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c index ce6f15284277..4da40436b4ab 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c @@ -635,6 +635,8 @@ static const struct brcmf_firmware_mapping brcmf_sdio_fwnames[] = { BRCMF_FW_ENTRY(CY_CC_43012_CHIP_ID, 0xFFFFFFFF, 43012) }; +#define TXCTL_CREDITS 2 + static void pkt_align(struct sk_buff *p, int len, int align) { uint datalign; @@ -648,8 +650,16 @@ static void pkt_align(struct sk_buff *p, int len, int align) /* To check if there's window offered */ static bool data_ok(struct brcmf_sdio *bus) { - return (u8)(bus->tx_max - bus->tx_seq) != 0 && - ((u8)(bus->tx_max - bus->tx_seq) & 0x80) == 0; + /* Reserve TXCTL_CREDITS credits for txctl */ + return (bus->tx_max - bus->tx_seq) > TXCTL_CREDITS && + ((bus->tx_max - bus->tx_seq) & 0x80) == 0; +} + +/* To check if there's window offered */ +static bool txctl_ok(struct brcmf_sdio *bus) +{ + return (bus->tx_max - bus->tx_seq) != 0 && + ((bus->tx_max - bus->tx_seq) & 0x80) == 0; } static int @@ -2655,7 +2665,7 @@ static void brcmf_sdio_dpc(struct brcmf_sdio *bus) brcmf_sdio_clrintr(bus); if (bus->ctrl_frame_stat && (bus->clkstate == CLK_AVAIL) && - data_ok(bus)) { + txctl_ok(bus)) { sdio_claim_host(bus->sdiodev->func1); if (bus->ctrl_frame_stat) { err = brcmf_sdio_tx_ctrlframe(bus, bus->ctrl_frame_buf, @@ -2663,6 +2673,9 @@ static void brcmf_sdio_dpc(struct brcmf_sdio *bus) bus->ctrl_frame_err = err; wmb(); bus->ctrl_frame_stat = false; + if (err) + brcmf_err("sdio ctrlframe tx failed err=%d\n", + err); } sdio_release_host(bus->sdiodev->func1); brcmf_sdio_wait_event_wakeup(bus); From patchwork Wed Jun 10 15:21:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chi-Hsien Lin X-Patchwork-Id: 215355 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC351C433E1 for ; Wed, 10 Jun 2020 15:21:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C939020734 for ; Wed, 10 Jun 2020 15:21:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=cypress.com header.i=@cypress.com header.b="IhAyd+yr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730122AbgFJPVc (ORCPT ); Wed, 10 Jun 2020 11:21:32 -0400 Received: from mail-eopbgr750110.outbound.protection.outlook.com ([40.107.75.110]:38746 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729987AbgFJPVb (ORCPT ); Wed, 10 Jun 2020 11:21:31 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WPLurr1KbJgmRqxMElL0ne40uChl8ZwCnyHGZT7u48gTPcgray7dgoyyOsSIqRSCM60GBf/LZQrDfbIjgW4sHioqrw0uYRTRReH97hiFbwNwywfelSk63/dbivGU+qbzckHOGGlmijg0+X4Bax3/mku3ZPo3gMFzrYHCS862KDNrrCSJyC0EknXFo31FgXWxC08A0/Cg80VxDB6Bj89rvuaSmsOEA64naTqZwVPlJltFJPirAIJfIeplv1pbyRlF2szfOu35veJzORDatGSRdO5TzcgMVSi3AEzyDL8CRoIlyMnJBMZ/UHtZvf9BwO8EMmQjRh2NshQtMu8e50nydg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9oTcvlhQieqo502sxUGI7vgIZdSYAA2sHcjDKoWqD0A=; b=npsmg4YbcmwhpB4TFUh7YfKM+tbqB/36zvw4snE+KlMh3eFsCE+ckaEnNBzHod7roEhekXHfdr1bMgZyH0e7pRpwT7uLNM6F9LxEoMMVV5FDuNl5fOXFS9N103rHYt8myg9rshBSSnOsHBaZw+g511xZZvJNO5Z8a4pUV6pvy+NT/b56OpWoPBN3YoQD3w7qvzlq6PdewTADaJtJ/8BDU6JQxomHyx2X86Rxnncl9F14T1LU7AUxIC/UbDCdLB6Yq01BapsxmxyVdC09KWX74mf+6olnZiT11G7XpCBWdM/ZxHDnb8MFQnFStZZSBi8wHi9Z6n3JjfujMn4OrmJk+g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cypress.com; dmarc=pass action=none header.from=cypress.com; dkim=pass header.d=cypress.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cypress.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9oTcvlhQieqo502sxUGI7vgIZdSYAA2sHcjDKoWqD0A=; b=IhAyd+yrsUcfMvlTgUEgnynN9hp8ItX66QJpE39YUePpXjSBwf4g/tuAHehGIszcAux5u57oztznr+4LyzSdPqvdqvBOqp1Hf4frxUaFYjr8CCoNrTF4+yzEp7kUePMfPEeUu+2eDxUKTmvwk9HLUSynQZW0tGsSnYeXg8H3sm8= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=cypress.com; Received: from BYAPR06MB4901.namprd06.prod.outlook.com (2603:10b6:a03:7a::30) by BYAPR06MB5621.namprd06.prod.outlook.com (2603:10b6:a03:ab::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.22; Wed, 10 Jun 2020 15:21:24 +0000 Received: from BYAPR06MB4901.namprd06.prod.outlook.com ([fe80::b972:c25d:c8fc:fc0e]) by BYAPR06MB4901.namprd06.prod.outlook.com ([fe80::b972:c25d:c8fc:fc0e%7]) with mapi id 15.20.3088.018; Wed, 10 Jun 2020 15:21:24 +0000 From: Chi-Hsien Lin To: linux-wireless@vger.kernel.org Cc: brcm80211-dev-list@broadcom.com, brcm80211-dev-list@cypress.com, Arend van Spriel , Franky Lin , Hante Meuleman , Wright Feng , Kalle Valo , Chung-Hsien Hsu , Chi-hsien Lin Subject: [PATCH V2 4/6] brcmfmac: update tx status flags to sync with firmware Date: Wed, 10 Jun 2020 10:21:04 -0500 Message-Id: <20200610152106.175257-5-chi-hsien.lin@cypress.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200610152106.175257-1-chi-hsien.lin@cypress.com> References: <20200610152106.175257-1-chi-hsien.lin@cypress.com> X-ClientProxiedBy: MN2PR08CA0019.namprd08.prod.outlook.com (2603:10b6:208:239::24) To BYAPR06MB4901.namprd06.prod.outlook.com (2603:10b6:a03:7a::30) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from aremote02.aus.cypress.com (12.110.209.245) by MN2PR08CA0019.namprd08.prod.outlook.com (2603:10b6:208:239::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.21 via Frontend Transport; Wed, 10 Jun 2020 15:21:22 +0000 X-Mailer: git-send-email 2.25.0 X-Originating-IP: [12.110.209.245] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 5e8201d8-02db-4eb9-a47b-08d80d51efef X-MS-TrafficTypeDiagnostic: BYAPR06MB5621: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-Forefront-PRVS: 0430FA5CB7 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ILGOpp6QnLYsB2sdOb8ucpfCrrSFWOJTvaKjcBkY5Lb1KJLNN56Lvl4Hv9bGFdw3bgOsGxrLU/aPa+iWUXEUUNv4qXKRDfXqTXKUcpm2b/cdds0imn8acZ0ERLPu43DIl79FAGMGjU4K3kYSFrKCHX55kmyko96f1D1a8iEdUW5HqVE8mLilLJ7PWZDxNd+ywczcy5tT4TOawIJY0ZgJkv+AcbBDtRPYJ+f5s6m6pdJhTCrPH4ZpSHcAyuhgCYmYxxmhAX7QtlGYvg9LQS5MEkrihmXbT23swsyQgaRVzuLvf40eZ4degYiBOC63ij5D2obmxwOG25QaPwNcODUpaQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR06MB4901.namprd06.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(396003)(366004)(136003)(39860400002)(346002)(376002)(16526019)(107886003)(2616005)(956004)(8936002)(26005)(1076003)(6916009)(316002)(6486002)(186003)(6666004)(2906002)(8676002)(7696005)(86362001)(66556008)(4326008)(36756003)(52116002)(54906003)(66476007)(15650500001)(5660300002)(478600001)(83380400001)(66946007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: vbSSorH5Qc4TROJncqrhIzqwz+QW5t9J+2bfrMX7xCdDb73pUxv5YL1wP+gruBcRyuR8TVtiM0a4IgJ6R7z4nSsSg12VSs218CwI1y/k06bnVS1pZaX+oavSACRnAXGnqFg485ct5m7ToaGX+z9IYnRT1/SVf11huoxJpE7TEIdwRlPa1oSsiIcncy4DB/gSe4T0YzKOMG03o+kJ/9UHyoE8TIZ7k9X0KRKTdCvBJhaNKotw+A+8vjwuepEyYL188qRBo8JZEvk+MRFP0X6y61wnVLkSpXHrJlfCHfWr5Nb/t5nkbQIAGrA+QueM2fg/bFe40oFT7iY9AWsDGx7VTov/CpTXUKBBv+JeauDL0HaF+oKssw2UWZlOV4FIgE4vOID2m7M9er90wszjGXnVXPiO7ciM2rMn95k9UmMs9cOc8ONGWeSYuPJkKvwIB1mnSu4SNZ6atFymTKq6K2yq5CP6N6PEXjbtvYo+amfKXuDZIIeO4ohRYH7pYaHMgVtY X-OriginatorOrg: cypress.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5e8201d8-02db-4eb9-a47b-08d80d51efef X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jun 2020 15:21:24.7403 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 011addfc-2c09-450d-8938-e0bbc2dd2376 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: PJdAem5VuW1x4nyA6yQi2Q6DciEGq/MquqFCQGWvSHu8id3U9WsBfZdunxn9WTeS5Hpd/kBmd39GpJaTeniEwA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR06MB5621 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Chung-Hsien Hsu There is a mismatch of tx status flag values between host and firmware. It makes the host mistake the flags and have incorrect behavior of credit returns. So update the flags to sync with the firmware ones. Signed-off-by: Chung-Hsien Hsu Signed-off-by: Chi-hsien Lin --- .../wireless/broadcom/brcm80211/brcmfmac/fwsignal.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c index d7c36af4b566..ce8c6ceafc58 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c @@ -323,6 +323,10 @@ struct brcmf_skbuff_cb { * firmware suppress the packet as device is already in PS mode. * @BRCMF_FWS_TXSTATUS_FW_TOSSED: * firmware tossed the packet. + * @BRCMF_FWS_TXSTATUS_FW_DISCARD_NOACK: + * firmware tossed the packet after retries. + * @BRCMF_FWS_TXSTATUS_FW_SUPPRESS_ACKED: + * firmware wrongly reported suppressed previously, now fixing to acked. * @BRCMF_FWS_TXSTATUS_HOST_TOSSED: * host tossed the packet. */ @@ -331,6 +335,8 @@ enum brcmf_fws_txstatus { BRCMF_FWS_TXSTATUS_CORE_SUPPRESS, BRCMF_FWS_TXSTATUS_FW_PS_SUPPRESS, BRCMF_FWS_TXSTATUS_FW_TOSSED, + BRCMF_FWS_TXSTATUS_FW_DISCARD_NOACK, + BRCMF_FWS_TXSTATUS_FW_SUPPRESS_ACKED, BRCMF_FWS_TXSTATUS_HOST_TOSSED }; @@ -1455,6 +1461,10 @@ brcmf_fws_txs_process(struct brcmf_fws_info *fws, u8 flags, u32 hslot, remove_from_hanger = false; } else if (flags == BRCMF_FWS_TXSTATUS_FW_TOSSED) fws->stats.txs_tossed += compcnt; + else if (flags == BRCMF_FWS_TXSTATUS_FW_DISCARD_NOACK) + fws->stats.txs_discard += compcnt; + else if (flags == BRCMF_FWS_TXSTATUS_FW_SUPPRESS_ACKED) + fws->stats.txs_discard += compcnt; else if (flags == BRCMF_FWS_TXSTATUS_HOST_TOSSED) fws->stats.txs_host_tossed += compcnt; else