From patchwork Wed Mar 25 08:20:24 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: 11457137 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BB52213A4 for ; Wed, 25 Mar 2020 08:21:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9B6502070A for ; Wed, 25 Mar 2020 08:21:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=cypress.com header.i=@cypress.com header.b="RhRF3krT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726154AbgCYIVC (ORCPT ); Wed, 25 Mar 2020 04:21:02 -0400 Received: from mail-dm6nam10on2113.outbound.protection.outlook.com ([40.107.93.113]:25385 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726072AbgCYIVB (ORCPT ); Wed, 25 Mar 2020 04:21:01 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hYsbgTdnuA4Q6f50zTEcYqzwKc5aiCZDga0rRP9uGapVRKjWWjjMvvN6IQ3oiJ9E1M59CHTIMfJDoySzTWjoF+mobo/bAPy+akLKhSH00DxhsSeL4V+sHaR0GYrCf+H5DwuL09ygQViJ6vNNuElunPXyAA+tJSr4GKTuPu5Ye0cfGcU3dk2n9iXmwkCyXmfbHcj0LQlh6h+iEcghR9lbUxpwg0KzvBLnv9ROIZ0DzOydnmqfft5qIznaXFS95xwinJLOWtQkavSX6Q2s+dkk7wpefF5dJ0jBl1zkZvLW2o1VrnpufZFS1g4zda+KKzee40bGqfDCZ3nJamqqmfjF8A== 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=8jhe+/iEp3wP27V/WKNDbaMb5SGw0eXT8zY1Gkxc0lc=; b=ESzhgYwFqc6rlsTmGuxAxkjcKoOBdrnCGUhHGSD19LisSWoyx3tEvKo/nbiPpqy0UhdrGXmJkzFSKF2//5PK89vJVJGfFn81EOqD1oL/Hdk0/bIcOxJBDDf21aMBUPMs0Sfo00G9FsSVBRgfUcnBB9YKD2cBe9eRbsNhaJgkbfJWwh+FvvxnEC2C3iWv42H4PViGEiGajyndZ+I0n5wvvOAoR9ShIaAhYQUBsV0mUcnjCQ1R0kX7RoZKPCaBfap6otu2Gh1UYn0dbfgU4nuulULBVfSiahqtNWpxoDMdv9N/DLSRgJOgXTTg3cryvsoQpNO2JJnRwlliyXTUDuwsAw== 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=8jhe+/iEp3wP27V/WKNDbaMb5SGw0eXT8zY1Gkxc0lc=; b=RhRF3krT5Zs9VCM4ifTBwgJqWJXbtIV0AUniDLcS8C8mKnpNTCTcb3KlmM0UWv6H5Ml/FVfD6pCcFYMDzyri2HkZxwXWXhY4lzTkC2kclKZ0krEKDsGb9HCfjqPwQM3anYsE/0sR+YjHTD/EnJ8M2QkAG+JnPff2IXRbm3LQU74= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Chi-Hsien.Lin@cypress.com; Received: from BYAPR06MB4901.namprd06.prod.outlook.com (2603:10b6:a03:7a::30) by BYAPR06MB5189.namprd06.prod.outlook.com (2603:10b6:a03:cf::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.15; Wed, 25 Mar 2020 08:20:52 +0000 Received: from BYAPR06MB4901.namprd06.prod.outlook.com ([fe80::69bb:5671:e8b:74c1]) by BYAPR06MB4901.namprd06.prod.outlook.com ([fe80::69bb:5671:e8b:74c1%3]) with mapi id 15.20.2835.023; Wed, 25 Mar 2020 08:20:52 +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 , Chi-hsien Lin Subject: [PATCH V3 1/6] brcmfmac: Fix driver crash on USB control transfer timeout Date: Wed, 25 Mar 2020 03:20:24 -0500 Message-Id: <1585124429-97371-2-git-send-email-chi-hsien.lin@cypress.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1585124429-97371-1-git-send-email-chi-hsien.lin@cypress.com> References: <1585124429-97371-1-git-send-email-chi-hsien.lin@cypress.com> X-ClientProxiedBy: BYAPR08CA0027.namprd08.prod.outlook.com (2603:10b6:a03:100::40) 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 BYAPR08CA0027.namprd08.prod.outlook.com (2603:10b6:a03:100::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.20 via Frontend Transport; Wed, 25 Mar 2020 08:20:51 +0000 X-Mailer: git-send-email 2.1.0 X-Originating-IP: [12.110.209.245] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 4534677b-d535-4e57-5e94-08d7d0956ebe X-MS-TrafficTypeDiagnostic: BYAPR06MB5189:|BYAPR06MB5189: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3044; X-Forefront-PRVS: 0353563E2B X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(366004)(66556008)(8676002)(81156014)(2906002)(66476007)(66946007)(81166006)(6486002)(8936002)(6916009)(16526019)(26005)(956004)(2616005)(498600001)(6666004)(54906003)(86362001)(52116002)(7696005)(186003)(36756003)(5660300002)(107886003)(4326008);DIR:OUT;SFP:1102;SCL:1;SRVR:BYAPR06MB5189;H:BYAPR06MB4901.namprd06.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords; Received-SPF: None (protection.outlook.com: cypress.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Cz2VuUk6yT/OHWEqrDFbZZwJMm6G63IepUvmUvV9YP5ksJcLc3oQAFyop4PkC1ielnz3OlAzMb1CiuTxd1LWwQ4Sb/HcmdwUOlTxvZDbFsWRH0UvdSd4swfrNr+Z/nfFKSFWXExyCw6rMJF+B85n1qwwQpLzhWSHlHp2FMb+S3Zyz7BIw1z7bNxCxg7A4KGpS3kecCi/fGl72ZKEyXicR+4EYP5iuD1qXtrsDm8pCJNmYcNvnSkIITGMSWgqnCPsTHkH1qMf7VmofKgXlRwa7mFF1WR6/N7e7IadsiTPokvU93UmNI1Pcy35XG5uQB/KW7d17/rJXDlJyM0QAtNfuFnt28Nlrf500efBFNoGqm3PrB8zvXrsdqi816aHaxfUFLXPh7QD+VzYLPO04usKX6aue5BORGq/qL/dKby6GWcdIQQpJsb9vgoVkyDhVs78 X-MS-Exchange-AntiSpam-MessageData: yyjnH+MaKcbBBeD7bJ/zMGuRcjuHNp6yyGwRSTk9rTemovmQSzeMzMTnKfj1DCRLiGHp3Dh17frKaXlhjeWSvSW8J9p/oKOVS7KT0AxmEW0DikxTS+Yh3Qrm8L2cDWST7Vlq8DMDSp9WM638+neyHA== X-OriginatorOrg: cypress.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4534677b-d535-4e57-5e94-08d7d0956ebe X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2020 08:20:52.7586 (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: GqOVXjGBT4C7dDuPKu9RpfgCS4hK5+9jTWG3ZFUUG4honkqwOMfsw2PK9ud1tXrEVL59ZAzPTebyHdHVoda6QQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR06MB5189 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Raveendran Somu When the control transfer gets timed out, the error status was returned without killing that urb, this leads to using the same urb. This issue causes the kernel crash as the same urb is sumbitted multiple times. The fix is to kill the urb for timeout transfer before returning error Signed-off-by: Raveendran Somu Signed-off-by: Chi-hsien Lin --- drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c index 575ed19e9195..10387a7f5d56 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c @@ -328,11 +328,12 @@ static int brcmf_usb_tx_ctlpkt(struct device *dev, u8 *buf, u32 len) return err; } timeout = brcmf_usb_ioctl_resp_wait(devinfo); - clear_bit(0, &devinfo->ctl_op); if (!timeout) { brcmf_err("Txctl wait timed out\n"); + usb_kill_urb(devinfo->ctl_urb); err = -EIO; } + clear_bit(0, &devinfo->ctl_op); return err; } @@ -358,11 +359,12 @@ static int brcmf_usb_rx_ctlpkt(struct device *dev, u8 *buf, u32 len) } timeout = brcmf_usb_ioctl_resp_wait(devinfo); err = devinfo->ctl_urb_status; - clear_bit(0, &devinfo->ctl_op); if (!timeout) { brcmf_err("rxctl wait timed out\n"); + usb_kill_urb(devinfo->ctl_urb); err = -EIO; } + clear_bit(0, &devinfo->ctl_op); if (!err) return devinfo->ctl_urb_actual_length; else From patchwork Wed Mar 25 08:20:25 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: 11457139 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 433FC13A4 for ; Wed, 25 Mar 2020 08:21:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1665E2070A for ; Wed, 25 Mar 2020 08:21:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=cypress.com header.i=@cypress.com header.b="ZeQpbw+b" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726239AbgCYIVD (ORCPT ); Wed, 25 Mar 2020 04:21:03 -0400 Received: from mail-dm6nam10on2113.outbound.protection.outlook.com ([40.107.93.113]:25385 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725903AbgCYIVD (ORCPT ); Wed, 25 Mar 2020 04:21:03 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eXYu7My3cU0oTY7cOUYPIcyL0GCsZHs2AdkbLE5j0pogPnJa/6iGswGB7/KSOAleK12jZfHa2Mg5c0RItLM4rMfU4OEr2mwdZI00KiJUDkVlSDgB1pkJQTE+K8n8tqwWMz9AsQ6Fx0v6fJmfYsLgV4TdbUIQ/s8/mhYcOHhHrjiMnpgneSyeTe3k12YVrKljax2dWmlPhd7mMNdnZw4aBsQ1SzVOxxzRX7BWSPUJQflNBKwBaHZwEHTWdwNhfsYKDES7IPlK/csNbRIbCCB8BZobyPZ6fMVNGxrnLZSQggangLxMrhMWA9/QGoYaUNbpS77i2FLCsi+HsimNHreyaA== 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=vHjIAUP8pch+iU7C2NvkHDOGwlDOkgTnRp9+Y5FR1pg=; b=kmf/gmbXIgyAds6Aj+R7m8H3lgCeqbFwXQNfr/8jQ+uqiYp8U+A/vm0KyGRnidXv0gyhkOPI4lJlUCyA6jwN10yVTw+ywbEbiv1QyNE9vrr8tLGXXk9uMoIdL9jhznKq5O2h0f3Kafbq7t6Fzt2YnlXiGXgSMSPgiivowFKwD2Q1t9DAWnY5z0EpxPY9z43ifXTgPa46Tvx7PCY1msaYTX6YWBl4bNI383Q1boeLKI2kQM7HpJDjUDPQqdLmRULmOXJ/YnZdxTDuQJNnCSIBkDFcM91bnyVq0fSkuGE2kXpCwyhGJoe5bXMecRcKOSLWn+rg39OHauq1+v+K8zC38g== 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=vHjIAUP8pch+iU7C2NvkHDOGwlDOkgTnRp9+Y5FR1pg=; b=ZeQpbw+bvn4yR/GyhRvOpV8tTHGqJOTUYaEL3Eg5HcMITmwTsRyTkBHZdiQOOnW/9fXnqI8SbHMIY6CI34Eam3cz+g2flWxrwaMjN9d+TMX1CyIpev9DjwuRbXGfN7VP51q79QQWlS4H7ZCd/DBGWY0s3Epsoh90+ghecIM0B3w= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Chi-Hsien.Lin@cypress.com; Received: from BYAPR06MB4901.namprd06.prod.outlook.com (2603:10b6:a03:7a::30) by BYAPR06MB5189.namprd06.prod.outlook.com (2603:10b6:a03:cf::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.15; Wed, 25 Mar 2020 08:20:54 +0000 Received: from BYAPR06MB4901.namprd06.prod.outlook.com ([fe80::69bb:5671:e8b:74c1]) by BYAPR06MB4901.namprd06.prod.outlook.com ([fe80::69bb:5671:e8b:74c1%3]) with mapi id 15.20.2835.023; Wed, 25 Mar 2020 08:20:54 +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 , Chi-hsien Lin Subject: [PATCH V3 2/6] brcmfmac: Fix double freeing in the fmac usb data path Date: Wed, 25 Mar 2020 03:20:25 -0500 Message-Id: <1585124429-97371-3-git-send-email-chi-hsien.lin@cypress.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1585124429-97371-1-git-send-email-chi-hsien.lin@cypress.com> References: <1585124429-97371-1-git-send-email-chi-hsien.lin@cypress.com> X-ClientProxiedBy: BYAPR08CA0027.namprd08.prod.outlook.com (2603:10b6:a03:100::40) 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 BYAPR08CA0027.namprd08.prod.outlook.com (2603:10b6:a03:100::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.20 via Frontend Transport; Wed, 25 Mar 2020 08:20:52 +0000 X-Mailer: git-send-email 2.1.0 X-Originating-IP: [12.110.209.245] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 3093e7df-9913-4625-fbe3-08d7d0956f6c X-MS-TrafficTypeDiagnostic: BYAPR06MB5189:|BYAPR06MB5189: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-Forefront-PRVS: 0353563E2B X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(366004)(66556008)(8676002)(81156014)(2906002)(66476007)(66946007)(81166006)(6486002)(8936002)(6916009)(16526019)(26005)(956004)(2616005)(498600001)(6666004)(54906003)(86362001)(52116002)(7696005)(186003)(36756003)(5660300002)(107886003)(4326008);DIR:OUT;SFP:1102;SCL:1;SRVR:BYAPR06MB5189;H:BYAPR06MB4901.namprd06.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords; Received-SPF: None (protection.outlook.com: cypress.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: y5B7ZRAcAHyAljo7flt+xsgDru+7eInkYGDiOnYyPgesiwZ7nGmknw8voL0UY/IifbZf42VE2FMV9gV2ECaNwMFnyLCdkyFxge5cF1IQgcU1fe+auOJoefw0k3s1mZpTEEr7xxOFoU6x5z/66UeNpBwhcstWab/U388s64u5MAZYTXyEwVDDPexU4n7UUmK8Vwq12G933ndg8lcSZP7tXyU1txvWrNigKKq19WggdNBG1DkhFxM4iPEMKBKaTgkvnubcZDglPpc0acJq8PxWJoiZBu2BCT1g9zQF2qAjhWSAFK3IGB7M7PYYO1KMZz2Dvjq12nRjgDzcnuvWJ0oosIjtz7gYxLiyZJHgsamIkf5jvgr0QyauqymT6e112jrvwEnIEdMJcmH6LGN4nuqSs46Tyx8gr17JjbaRR57f+mGMO53+ArEi8QE75MFIO9bQ X-MS-Exchange-AntiSpam-MessageData: 9ziLpQugvDafq8i2rdDGw3M1izytLuNsIDnQt05yll4keuzEKpHfD77dmrN60yYsCjnGXk0GWEi2Ei6Y+MbE6my6/fNaQRz7/t4iytYCXB4Tdn7tbY37ci2hJ+Z12CRH8kcSke0gggr7VdZ2IMZHvQ== X-OriginatorOrg: cypress.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3093e7df-9913-4625-fbe3-08d7d0956f6c X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2020 08:20:53.9479 (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: WLZxMejCZ52nz+hj9XcJ4xC4/jJJMj3gIHEZB+SnI+q9r6aMAo+mRw/b+VXy3/DZAbX3/gcO15zdJRdxH1xrPA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR06MB5189 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Raveendran Somu When the brcmf_fws_process_skb() fails to get hanger slot for queuing the skb, it tries to free the skb. But the caller brcmf_netdev_start_xmit() of that funciton frees the packet on error return value. This causes the double freeing and which caused the kernel crash. Signed-off-by: Raveendran Somu Signed-off-by: Chi-hsien Lin --- drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c index 5e1a11c07551..10022c765354 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c @@ -2145,8 +2145,7 @@ int brcmf_fws_process_skb(struct brcmf_if *ifp, struct sk_buff *skb) brcmf_fws_enq(fws, BRCMF_FWS_SKBSTATE_DELAYED, fifo, skb); brcmf_fws_schedule_deq(fws); } else { - bphy_err(drvr, "drop skb: no hanger slot\n"); - brcmf_txfinalize(ifp, skb, false); + bphy_err(drvr, "no hanger slot available\n"); rc = -ENOMEM; } brcmf_fws_unlock(fws); From patchwork Wed Mar 25 08:20:26 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: 11457141 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 029CC17D4 for ; Wed, 25 Mar 2020 08:21:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CD26B2070A for ; Wed, 25 Mar 2020 08:21:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=cypress.com header.i=@cypress.com header.b="iaPItU+P" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726313AbgCYIVF (ORCPT ); Wed, 25 Mar 2020 04:21:05 -0400 Received: from mail-dm6nam10on2113.outbound.protection.outlook.com ([40.107.93.113]:25385 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726072AbgCYIVE (ORCPT ); Wed, 25 Mar 2020 04:21:04 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kqtEV48y4CfnUrD/xoL1kn2i5Ur+2yc/LFHCCGRCvLA05rjiTTwfdRhQjZZAxKy+nMrkRzcSXwReJ/q3fd8HlYF0WMQyERxNxCUAsBk9YtIYgQ7C2HZ0sJCvUdf03KT2PYlqwf70tuvXn6YYYOmn095r/LJptY2PyPO3Sf2M+e3Pun21yPy9kPFUikLC6Oj6ADJ+2fI0IP+3Jmv1zMRnd+cKECbcxf4LyBjgSf4D2ZWz6opGtcLfe5gei9bxFwofYDzQJSAyZBZU44+sGhnEBdqHoVOaUflzF+MIlwMxNGz0nk22AZXEbQ8J07kigx5x3bagb9ABmkueWKUMT4e0EA== 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=tp/XWRTwvr80437RcBtCuvYDovgnHn+kzgYBZ3/mbyk=; b=EeftBN1e2cFJ+cbI6kWyuqE5qt39j0lkQP63ydDfzh/F3V/83i/SgIwqarj/FV5FBRN2xbw6r/4c/lPGFi39HfAYtwk8ibkkyvNrdzRWrk0CY8J1AJdWpewcR2RtEniuqXl5+GzR2sBxI6KiqW6pKrQsaVs41QF9PJdyKZpG42RT7MKd5U0H1qzp7EftJs5BULkTu5enYz8QuzqmMY8/PXK3fCWo9Qq9y9q9NkQ+4qhXzQlu4vrAp7K557Crcb1/IV6mq06+kz5h1BJGx+Rv8YDHEVN1q+R3SQVH3siemrNmiWpDN3I39KywUpjby5FAxbY2/iCliS39rnR+4RodXQ== 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=tp/XWRTwvr80437RcBtCuvYDovgnHn+kzgYBZ3/mbyk=; b=iaPItU+Pxz+t4bJVQLvD7JrCC00BVk4Rbx1oyvnW41gn68zdJEMjXgRgt4J9SAJvULffhhFtwynMdmnrwoqkAT37ERXxqYwW1jm+vKoGv3dwgrACdVM/o0XE4wKtb/2n+QF6n4QHYQUa4XGHo5WHjkmxNXmbQWrF6e5/+x0cLKc= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Chi-Hsien.Lin@cypress.com; Received: from BYAPR06MB4901.namprd06.prod.outlook.com (2603:10b6:a03:7a::30) by BYAPR06MB5189.namprd06.prod.outlook.com (2603:10b6:a03:cf::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.15; Wed, 25 Mar 2020 08:20:55 +0000 Received: from BYAPR06MB4901.namprd06.prod.outlook.com ([fe80::69bb:5671:e8b:74c1]) by BYAPR06MB4901.namprd06.prod.outlook.com ([fe80::69bb:5671:e8b:74c1%3]) with mapi id 15.20.2835.023; Wed, 25 Mar 2020 08:20:55 +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 , Chi-hsien Lin Subject: [PATCH V3 3/6] brcmfmac: fix the incorrect return value in brcmf_inform_single_bss(). Date: Wed, 25 Mar 2020 03:20:26 -0500 Message-Id: <1585124429-97371-4-git-send-email-chi-hsien.lin@cypress.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1585124429-97371-1-git-send-email-chi-hsien.lin@cypress.com> References: <1585124429-97371-1-git-send-email-chi-hsien.lin@cypress.com> X-ClientProxiedBy: BYAPR08CA0027.namprd08.prod.outlook.com (2603:10b6:a03:100::40) 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 BYAPR08CA0027.namprd08.prod.outlook.com (2603:10b6:a03:100::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.20 via Frontend Transport; Wed, 25 Mar 2020 08:20:54 +0000 X-Mailer: git-send-email 2.1.0 X-Originating-IP: [12.110.209.245] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 6d4635c3-89c3-44a2-94b9-08d7d095701d X-MS-TrafficTypeDiagnostic: BYAPR06MB5189:|BYAPR06MB5189: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-Forefront-PRVS: 0353563E2B X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(366004)(66556008)(8676002)(81156014)(2906002)(66476007)(66946007)(81166006)(6486002)(8936002)(6916009)(16526019)(26005)(956004)(2616005)(498600001)(6666004)(54906003)(86362001)(52116002)(7696005)(186003)(36756003)(5660300002)(107886003)(4326008);DIR:OUT;SFP:1102;SCL:1;SRVR:BYAPR06MB5189;H:BYAPR06MB4901.namprd06.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords; Received-SPF: None (protection.outlook.com: cypress.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: n8mNemSU5Td0qfHX1xvQ3IGN4Zeh+lZpkuOZV5UsNHnkOlHGg8gnYaPwiD0z1e5ifL2oT7ooxXpaGvFlnZuiCeQbxalb7Zqk3yFFEVBGKl1zrmcagUx2w4VHtccJ36EbzLU0ClkTO0rgDulsrNDZfMeh1DifNFu3tnXYnLcPIBQrCjrZlxDM0jF5LXJRdfPG7FhCYER8TZXIOhUFYrWc8/DkzWF64pjv9SWvdXE2X9NEMjFyek7Bo8RNROh5MlwACLrznONCmPY+1JhrCUkWyc1PclFkFegOKULpbTgDN7UNL1BtEEV669l1OALeL7N3IbN5JcPO9bFnabnhVrAK5PQvp14zTKg7lKmK81CxPRXnSV1tw/Mzltb59iAeavnk4FyWbDmI7nKl48my8PC6WvI7k1vX60kHd2d89BubuI5wAaqxRVjpc4VAMNnmocuI X-MS-Exchange-AntiSpam-MessageData: 2oTbmh43Uw+pTRVroibQFW8SPAzVUt1VqYF+BEJmbq2vUGpSzJAQnX/piEqHP5ynnfBkCuyKDLbdRuXVCIj5VqaoeUbl/rUpY7shIkAb2s+RVdAPFq1gQalnBwl3SCDwALX/eSgajhRp69mbJjRQiQ== X-OriginatorOrg: cypress.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6d4635c3-89c3-44a2-94b9-08d7d095701d X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2020 08:20:54.9963 (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: 3UOEDeLwp1VMhPTYjKoFHBLqm6X5j1PZxjoMx3R6msRqVrndRxwvhNriT1XdEoAEs9nDo/T9FYe4OgcNqiS3tA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR06MB5189 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Raveendran Somu The function brcmf_inform_single_bss returns the value as success, even when the length exceeds the maximum value. The fix is to send appropriate code on this error. This issue is observed when Cypress test group reported random fmac crashes when running their tests and the path was identified from the crash logs. With this fix the random failure issue in Cypress test group was resolved. Reviewed-by: Arend van Spriel Signed-off-by: Raveendran Somu Signed-off-by: Chi-hsien Lin --- drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c index a2328d3eee03..2ba165330038 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c @@ -2953,7 +2953,7 @@ static s32 brcmf_inform_single_bss(struct brcmf_cfg80211_info *cfg, if (le32_to_cpu(bi->length) > WL_BSS_INFO_MAX) { bphy_err(drvr, "Bss info is larger than buffer. Discarding\n"); - return 0; + return -EINVAL; } if (!bi->ctl_ch) { From patchwork Wed Mar 25 08:20:27 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: 11457143 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E21F11731 for ; Wed, 25 Mar 2020 08:21:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B8FF22070A for ; Wed, 25 Mar 2020 08:21:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=cypress.com header.i=@cypress.com header.b="HDeUcEIY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726842AbgCYIVG (ORCPT ); Wed, 25 Mar 2020 04:21:06 -0400 Received: from mail-dm6nam10on2113.outbound.protection.outlook.com ([40.107.93.113]:25385 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725903AbgCYIVF (ORCPT ); Wed, 25 Mar 2020 04:21:05 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T+t82hd20CsQBvEFjMKutsTlCe38gf4sAtmu4COcTeh0Dv56G1vWAK4G4y+mMVJi8adkvqAronhd5IsdmjWrRnys0MXArQiboE5yAlPCfx65y5/7H3O/5zS3DS77oj2KJJBv+tlIjXTlU8CmgHGqbNoq55onqUzzW+u+StS94mLsI5LVZSTzckw/Yx6N0uGN8c5PMH+66W0UxONiSBqmbX3QHMbYeWPUTUljq09iIHQ4rG54vkYQfBI23m/ECDIoHiy7Ks1/Rs+84yqhmL43vUFq7gXMh8WrAcCpdGpVGioAxjw1sCEt/O0t8ZYQWQEhqfxKxUfp3rzhurCNY7dMgw== 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=wVwKgTRJ+ZGENUgkjH6k1eLuK8rNyFEdHOaSWhrh/ZY=; b=WXq9FD9lvi7QSE0nk5gEfrCzyfnA1ptxbBWk63wzOXvC553o/ZHPq26ZrGKw45kbWD4d2XBrhgwrdAhQdHQSfFES60jekBHtfc28Keo3xXOTjLCW6qG9EE4iZuEjTicptubeGuA+b7BsXiiNKcQZUyvL401ZsgCjNnH4GwE2BObcOp16qcy/ttGLSzHzVTujRFv3ODZLRmtHravTVULqbL3rRZLsTLL+DvZ9PEJLRdOn6j6U8pFzWZEXyrEWlc4jXvTBAYJWPa4jJQuObzyM5TC2WoAub7fL7ye3RmMZ/hRLpmS7zWtq6Y+FX0rGZcFYLqHMk5Jt2o7NTSHlGzI6Xw== 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=wVwKgTRJ+ZGENUgkjH6k1eLuK8rNyFEdHOaSWhrh/ZY=; b=HDeUcEIYHYL9nihX3HrIiLpsJcet0d0lnSsfvjVfsFcW7+s5XaT0ovoUYXP8aMx+0g9Tx7Rq+na/MZjsrUIa5QamGn019BZdNoFvoc5ekdGrzJifgu/9HEKidbQ1yP3VnjHYqUY2/OAG+Fc9KEBnfLMwrFENMILb5jzG/rMuEhg= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Chi-Hsien.Lin@cypress.com; Received: from BYAPR06MB4901.namprd06.prod.outlook.com (2603:10b6:a03:7a::30) by BYAPR06MB5189.namprd06.prod.outlook.com (2603:10b6:a03:cf::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.15; Wed, 25 Mar 2020 08:20:56 +0000 Received: from BYAPR06MB4901.namprd06.prod.outlook.com ([fe80::69bb:5671:e8b:74c1]) by BYAPR06MB4901.namprd06.prod.outlook.com ([fe80::69bb:5671:e8b:74c1%3]) with mapi id 15.20.2835.023; Wed, 25 Mar 2020 08:20:56 +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 , Madhan Mohan R , Madhan Mohan R , Chi-hsien Lin Subject: [PATCH V3 4/6] brcmfmac: increase max hanger slots from 1K to 3K in fws layer Date: Wed, 25 Mar 2020 03:20:27 -0500 Message-Id: <1585124429-97371-5-git-send-email-chi-hsien.lin@cypress.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1585124429-97371-1-git-send-email-chi-hsien.lin@cypress.com> References: <1585124429-97371-1-git-send-email-chi-hsien.lin@cypress.com> X-ClientProxiedBy: BYAPR08CA0027.namprd08.prod.outlook.com (2603:10b6:a03:100::40) 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 BYAPR08CA0027.namprd08.prod.outlook.com (2603:10b6:a03:100::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.20 via Frontend Transport; Wed, 25 Mar 2020 08:20:55 +0000 X-Mailer: git-send-email 2.1.0 X-Originating-IP: [12.110.209.245] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 537b9879-a7af-4130-aafb-08d7d09570d3 X-MS-TrafficTypeDiagnostic: BYAPR06MB5189:|BYAPR06MB5189: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3826; X-Forefront-PRVS: 0353563E2B X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(366004)(66556008)(8676002)(81156014)(2906002)(66476007)(66946007)(81166006)(6486002)(8936002)(6916009)(16526019)(26005)(956004)(2616005)(498600001)(6666004)(54906003)(86362001)(52116002)(7696005)(186003)(36756003)(5660300002)(107886003)(4326008);DIR:OUT;SFP:1102;SCL:1;SRVR:BYAPR06MB5189;H:BYAPR06MB4901.namprd06.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords; Received-SPF: None (protection.outlook.com: cypress.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pBT6cIIWMcgegIMCJ9Tej2rtByzHPUv3gBZramKQcMAXxspj8bHwAeDlVaI28r8EUlbdJArhF7sDAEN1DpgyzWQSgJuIT9DuRlSplLPAcBALQT2cFmuO8D+vHBrgx/VZaklH4rD1W4yxLQjLCEAN/eq+2Hp3CoodF2H5gJpT/LQZHaVNMUMmEFBsiMMSlgWw4Mfj80FBWGYA67P4Ykl+VrUx1WC5G5ng2aWB//95drr0WptzdsLyK15dOmjrmeIznXnrsDwGtb6XL2uRW8MwyUCV3Cx8bt4MJiKaGVw/XZQrOzvM3zTr5NnkYk6mPoiQc1M3Hb3cJOVhZoKj8PSmZbOm1rSC5Jy4l5YStEqNKVFnvr1dFz0ATalezn0Q8xZt8O+A8ueNN+S6nhYmzeYEs2XLM2Ahlil3i9nuHEj1gNi1ugeIVwUJjI/ijH7ISqdP X-MS-Exchange-AntiSpam-MessageData: mPlSbElvCi9Aile8ySJbXBSIyuaz/cWc1FbICeU/Cid2o4QemnzjB79lRIe5WlsQPjT6KNUDNWLSdX104jAN/4mE2mVFrUtXMTCj8Sm/y3yKBIsCJglO1hxqbB//d5Wf302EI0TZIAam6RKemsrLgQ== X-OriginatorOrg: cypress.com X-MS-Exchange-CrossTenant-Network-Message-Id: 537b9879-a7af-4130-aafb-08d7d09570d3 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2020 08:20:56.2606 (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: 2hOJFknIx48dV12tdj6rWPZEEqSQ/Y2RwpdxpqpHYCMLuK+EceEIWFWiobXMgISvUWu0kskFC/SgxMNWH8z0yg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR06MB5189 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Madhan Mohan R Will enable FMAC to push more packets to bus tx queue and help improve throughput when fws queuing is enabled. This change is required to tune the throughput for passing WMM CERT tests. Signed-off-by: Madhan Mohan R Signed-off-by: Chi-hsien Lin --- drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c index 10022c765354..8cc52935fd41 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c @@ -404,7 +404,7 @@ struct brcmf_fws_mac_descriptor { u8 traffic_lastreported_bmp; }; -#define BRCMF_FWS_HANGER_MAXITEMS 1024 +#define BRCMF_FWS_HANGER_MAXITEMS 3072 /** * enum brcmf_fws_hanger_item_state - state of hanger item. From patchwork Wed Mar 25 08:20:28 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: 11457145 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D7C4913A4 for ; Wed, 25 Mar 2020 08:21:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A650F2070A for ; Wed, 25 Mar 2020 08:21:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=cypress.com header.i=@cypress.com header.b="ULeWTwXQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727158AbgCYIVI (ORCPT ); Wed, 25 Mar 2020 04:21:08 -0400 Received: from mail-dm6nam10on2113.outbound.protection.outlook.com ([40.107.93.113]:25385 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726072AbgCYIVI (ORCPT ); Wed, 25 Mar 2020 04:21:08 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i4OtHFPgsx4dKufm8nDe0sEjGKPqkWFjSiYc1VBytzT7v77t+7Z9W4mrCVg2rCPOTP2INEGjSkuDuMbbCnLmbrjWyxw1qdwXCPrSdLj958PtGz+OOUqweWnSCThCcaa8imXspAC8Kt4/NwZu8ihEggrKpVBxBY4fJ24OrP9RhSVA/oLKTmwdl9ocov4x0nbpIxH8bKyKA1MYeWtMoKCvq+IqGnz/pImY/wHehnt2A4GxZunohA5qD1zNM84De6s8CVpp01VvZ7n/ZaMmhTFJ25avkA4HPym9dq6umwp40I7BT8RSS05sTVx1kKelQ0SYRe9+t4dzY8Jk98fDK0hkWA== 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=fuw8RhWao9lrRfa+OSDejbozIWpA5cQBAZoztrmqxaQ=; b=auMrCr00ZBAuFb23j1pme0xsAQtSLeco2acLWMl7dnK5/IfW2GunuVaPpIJn44pPJbZTpC0S/QWjkYoAeoTHnt/651PTLl1pabVIKx1axSP6tWkOC2jQN6Xorg9xu9wZ3XZJsRJq7Rsnkf1mVg4yq06FqSHZYj+TVGeSJpL7W8ounbfpZ+48SCk6ej8d0EXNxMGobA2tMTmSfUuYNuGBCXFrl3KDQr9nb+lvTxXyqJ6IRcPK4cZOG/X11s1mSQY/FMd1K8hihU/47qvr+F5v7WuCVdAmmGSZCEPHp3henSSLCLOJh/ek57S6nYT6aiTUoXRBOUVbOAhe9VSkdSVQ/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=fuw8RhWao9lrRfa+OSDejbozIWpA5cQBAZoztrmqxaQ=; b=ULeWTwXQta7BxWbGQhwA8uO66rp/xc0t+RUbXV9xKM3Y2eCpHpjXnn0F8XzPOd1AeM1FUN6KgbkmEZ3E2OPLlhpCnL3KqqlGrc5eqwUAnc0d32/TyxpdNKskcJMTHh4vNA4lBGgv/28Zzya2LyO1Uab3IFG/2pBv3s+SxNhrj5M= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Chi-Hsien.Lin@cypress.com; Received: from BYAPR06MB4901.namprd06.prod.outlook.com (2603:10b6:a03:7a::30) by BYAPR06MB5189.namprd06.prod.outlook.com (2603:10b6:a03:cf::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.15; Wed, 25 Mar 2020 08:20:57 +0000 Received: from BYAPR06MB4901.namprd06.prod.outlook.com ([fe80::69bb:5671:e8b:74c1]) by BYAPR06MB4901.namprd06.prod.outlook.com ([fe80::69bb:5671:e8b:74c1%3]) with mapi id 15.20.2835.023; Wed, 25 Mar 2020 08:20:57 +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 , Chi-Hsien Lin Subject: [PATCH V3 5/6] brcmfmac: add USB autosuspend feature support Date: Wed, 25 Mar 2020 03:20:28 -0500 Message-Id: <1585124429-97371-6-git-send-email-chi-hsien.lin@cypress.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1585124429-97371-1-git-send-email-chi-hsien.lin@cypress.com> References: <1585124429-97371-1-git-send-email-chi-hsien.lin@cypress.com> X-ClientProxiedBy: BYAPR08CA0027.namprd08.prod.outlook.com (2603:10b6:a03:100::40) 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 BYAPR08CA0027.namprd08.prod.outlook.com (2603:10b6:a03:100::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.20 via Frontend Transport; Wed, 25 Mar 2020 08:20:56 +0000 X-Mailer: git-send-email 2.1.0 X-Originating-IP: [12.110.209.245] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: af345b62-7387-405f-108d-08d7d0957178 X-MS-TrafficTypeDiagnostic: BYAPR06MB5189:|BYAPR06MB5189: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:241; X-Forefront-PRVS: 0353563E2B X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(366004)(66556008)(8676002)(81156014)(2906002)(66476007)(66946007)(81166006)(6486002)(8936002)(6916009)(16526019)(26005)(956004)(2616005)(498600001)(6666004)(54906003)(86362001)(52116002)(7696005)(186003)(36756003)(5660300002)(107886003)(4326008);DIR:OUT;SFP:1102;SCL:1;SRVR:BYAPR06MB5189;H:BYAPR06MB4901.namprd06.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords; Received-SPF: None (protection.outlook.com: cypress.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: N74wmAWyJNYBfuLkdwl78jZ7p62lcqTFo7f8j+Id3LKk35azpzhHRFJUKPaicEDjPTEGXSLreeUNIOQoAwTSEj+x8oBkmJQBG4MfSp5Zp4Ayf0FWA57ql6Stz6uBm5Ci55NVy0LyEVMfFceVWNufycaAZcH2w4QHMEy0p+K48t/QW9//M2to2E/R4TC14bhezTpwlczW5AjWN7IghJutuyQmNqvFZeR1X54pHl7IsjKyohohDlDFKQSxIUKDSh7cVdarHZzifYW6wTYzGbtnoxlPf6II2n2MOLg+xlzm6MGbAOH3hf3KEhZf4qLzMVRLl5xlA9TZ8LQTamAANBjqfQb9AajwwYKZmgEp2ycP7C6Z0QSUvdOiCptNGCbEuw96acviWzG0GDpJcOWDTuaA3HSfHKsAnT5wT+S3QprrbVoBtInVWZw1QAfCSJSgSHoY X-MS-Exchange-AntiSpam-MessageData: loDYy1SOF8cFEqC3rvB7kzfLxcYCXSr2qqbZfBMq/nwhqIjFYr22uq/TnkhuvFH4GP2JB6KStBfd+Bcn6GgMQZ3UmvjeSKuyI8lZWpEN+66yFvmWgFq2v8BOY9T+h6DgPW/7Kker7xyedTPoaaQHKA== X-OriginatorOrg: cypress.com X-MS-Exchange-CrossTenant-Network-Message-Id: af345b62-7387-405f-108d-08d7d0957178 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2020 08:20:57.3450 (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: oAtBZ6ILtn7LlQx2ZLUh5ZG3IGD9YWCS6OWGfGBEW+IrRsD+iTK6ynnULsfSMxUn9nYku+gr9whwigevxrYV1g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR06MB5189 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Wright Feng We add enable dynamic suspend (autosuspend) support in host driver, and it can let platform cut down idle power consumption. To support autosuspend feature in host driver, kernel need to be built with CONFIG_USB_SUSPEND and autosuspend need to be turn on. And we also replace wowl feature with adding "needs_remote_wakeup", so that host still can be waken by wireless device. Signed-off-by: Wright Feng Signed-off-by: Chi-Hsien Lin --- .../net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 121 ++++++++++++--------- 1 file changed, 71 insertions(+), 50 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c index 10387a7f5d56..ac5463838fcf 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c @@ -164,7 +164,6 @@ struct brcmf_usbdev_info { struct urb *bulk_urb; /* used for FW download */ - bool wowl_enabled; struct brcmf_mp_device *settings; }; @@ -312,28 +311,43 @@ static int brcmf_usb_tx_ctlpkt(struct device *dev, u8 *buf, u32 len) int err = 0; int timeout = 0; struct brcmf_usbdev_info *devinfo = brcmf_usb_get_businfo(dev); + struct usb_interface *intf = to_usb_interface(dev); brcmf_dbg(USB, "Enter\n"); - if (devinfo->bus_pub.state != BRCMFMAC_USB_STATE_UP) - return -EIO; - if (test_and_set_bit(0, &devinfo->ctl_op)) - return -EIO; + err = usb_autopm_get_interface(intf); + if (err) + goto out; + + if (devinfo->bus_pub.state != BRCMFMAC_USB_STATE_UP) { + err = -EIO; + goto fail; + } + + if (test_and_set_bit(0, &devinfo->ctl_op)) { + err = -EIO; + goto fail; + } devinfo->ctl_completed = false; err = brcmf_usb_send_ctl(devinfo, buf, len); if (err) { brcmf_err("fail %d bytes: %d\n", err, len); clear_bit(0, &devinfo->ctl_op); - return err; + goto fail; } timeout = brcmf_usb_ioctl_resp_wait(devinfo); if (!timeout) { brcmf_err("Txctl wait timed out\n"); usb_kill_urb(devinfo->ctl_urb); err = -EIO; + goto fail; } clear_bit(0, &devinfo->ctl_op); + +fail: + usb_autopm_put_interface(intf); +out: return err; } @@ -342,20 +356,30 @@ static int brcmf_usb_rx_ctlpkt(struct device *dev, u8 *buf, u32 len) int err = 0; int timeout = 0; struct brcmf_usbdev_info *devinfo = brcmf_usb_get_businfo(dev); + struct usb_interface *intf = to_usb_interface(dev); brcmf_dbg(USB, "Enter\n"); - if (devinfo->bus_pub.state != BRCMFMAC_USB_STATE_UP) - return -EIO; - if (test_and_set_bit(0, &devinfo->ctl_op)) - return -EIO; + err = usb_autopm_get_interface(intf); + if (err) + goto out; + + if (devinfo->bus_pub.state != BRCMFMAC_USB_STATE_UP) { + err = -EIO; + goto fail; + } + + if (test_and_set_bit(0, &devinfo->ctl_op)) { + err = -EIO; + goto fail; + } devinfo->ctl_completed = false; err = brcmf_usb_recv_ctl(devinfo, buf, len); if (err) { brcmf_err("fail %d bytes: %d\n", err, len); clear_bit(0, &devinfo->ctl_op); - return err; + goto fail; } timeout = brcmf_usb_ioctl_resp_wait(devinfo); err = devinfo->ctl_urb_status; @@ -363,12 +387,15 @@ static int brcmf_usb_rx_ctlpkt(struct device *dev, u8 *buf, u32 len) brcmf_err("rxctl wait timed out\n"); usb_kill_urb(devinfo->ctl_urb); err = -EIO; + goto fail; } clear_bit(0, &devinfo->ctl_op); +fail: + usb_autopm_put_interface(intf); if (!err) return devinfo->ctl_urb_actual_length; - else - return err; +out: + return err; } static struct brcmf_usbreq *brcmf_usb_deq(struct brcmf_usbdev_info *devinfo, @@ -502,10 +529,12 @@ static void brcmf_usb_rx_complete(struct urb *urb) return; } - if (devinfo->bus_pub.state == BRCMFMAC_USB_STATE_UP) { + if (devinfo->bus_pub.state == BRCMFMAC_USB_STATE_UP || + devinfo->bus_pub.state == BRCMFMAC_USB_STATE_SLEEP) { skb_put(skb, urb->actual_length); brcmf_rx_frame(devinfo->dev, skb, true); brcmf_usb_rx_refill(devinfo, req); + usb_mark_last_busy(urb->dev); } else { brcmu_pkt_buf_free_skb(skb); brcmf_usb_enq(devinfo, &devinfo->rx_freeq, req, NULL); @@ -589,6 +618,11 @@ static int brcmf_usb_tx(struct device *dev, struct sk_buff *skb) struct brcmf_usbreq *req; int ret; unsigned long flags; + struct usb_interface *intf = to_usb_interface(dev); + + ret = usb_autopm_get_interface(intf); + if (ret) + goto out; brcmf_dbg(USB, "Enter, skb=%p\n", skb); if (devinfo->bus_pub.state != BRCMFMAC_USB_STATE_UP) { @@ -627,9 +661,10 @@ static int brcmf_usb_tx(struct device *dev, struct sk_buff *skb) devinfo->tx_flowblock = true; } spin_unlock_irqrestore(&devinfo->tx_flowblock_lock, flags); - return 0; fail: + usb_autopm_put_interface(intf); +out: return ret; } @@ -993,20 +1028,32 @@ static int brcmf_usb_fw_download(struct brcmf_usbdev_info *devinfo) { int err; + struct usb_interface *intf; brcmf_dbg(USB, "Enter\n"); - if (devinfo == NULL) - return -ENODEV; + if (!devinfo) { + err = -ENODEV; + goto out; + } if (!devinfo->image) { brcmf_err("No firmware!\n"); - return -ENOENT; + err = -ENOENT; + goto out; } + intf = to_usb_interface(devinfo->dev); + err = usb_autopm_get_interface(intf); + if (err) + goto out; + err = brcmf_usb_dlstart(devinfo, (u8 *)devinfo->image, devinfo->image_len); if (err == 0) err = brcmf_usb_dlrun(devinfo); + + usb_autopm_put_interface(intf); +out: return err; } @@ -1107,18 +1154,6 @@ struct brcmf_usbdev *brcmf_usb_attach(struct brcmf_usbdev_info *devinfo, return NULL; } -static void brcmf_usb_wowl_config(struct device *dev, bool enabled) -{ - struct brcmf_usbdev_info *devinfo = brcmf_usb_get_businfo(dev); - - brcmf_dbg(USB, "Configuring WOWL, enabled=%d\n", enabled); - devinfo->wowl_enabled = enabled; - if (enabled) - device_set_wakeup_enable(devinfo->dev, true); - else - device_set_wakeup_enable(devinfo->dev, false); -} - static int brcmf_usb_get_fwname(struct device *dev, const char *ext, u8 *fw_name) { @@ -1145,7 +1180,6 @@ static const struct brcmf_bus_ops brcmf_usb_bus_ops = { .txdata = brcmf_usb_tx, .txctl = brcmf_usb_tx_ctlpkt, .rxctl = brcmf_usb_rx_ctlpkt, - .wowl_config = brcmf_usb_wowl_config, .get_fwname = brcmf_usb_get_fwname, }; @@ -1334,6 +1368,8 @@ brcmf_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) usb_set_intfdata(intf, devinfo); + intf->needs_remote_wakeup = 1; + /* Check that the device supports only one configuration */ if (usb->descriptor.bNumConfigurations != 1) { brcmf_err("Number of configurations: %d not supported\n", @@ -1447,12 +1483,8 @@ static int brcmf_usb_suspend(struct usb_interface *intf, pm_message_t state) brcmf_dbg(USB, "Enter\n"); devinfo->bus_pub.state = BRCMFMAC_USB_STATE_SLEEP; - if (devinfo->wowl_enabled) { - brcmf_cancel_all_urbs(devinfo); - } else { - brcmf_detach(&usb->dev); - brcmf_free(&usb->dev); - } + brcmf_cancel_all_urbs(devinfo); + device_set_wakeup_enable(devinfo->dev, true); return 0; } @@ -1465,22 +1497,10 @@ static int brcmf_usb_resume(struct usb_interface *intf) struct brcmf_usbdev_info *devinfo = brcmf_usb_get_businfo(&usb->dev); brcmf_dbg(USB, "Enter\n"); - if (!devinfo->wowl_enabled) { - int err; - - err = brcmf_alloc(&usb->dev, devinfo->settings); - if (err) - return err; - - err = brcmf_attach(devinfo->dev); - if (err) { - brcmf_free(devinfo->dev); - return err; - } - } devinfo->bus_pub.state = BRCMFMAC_USB_STATE_UP; brcmf_usb_rx_fill_all(devinfo); + device_set_wakeup_enable(devinfo->dev, false); return 0; } @@ -1537,6 +1557,7 @@ static struct usb_driver brcmf_usbdrvr = { .suspend = brcmf_usb_suspend, .resume = brcmf_usb_resume, .reset_resume = brcmf_usb_reset_resume, + .supports_autosuspend = true, .disable_hub_initiated_lpm = 1, }; From patchwork Wed Mar 25 08:20:29 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: 11457147 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AAF1C13A4 for ; Wed, 25 Mar 2020 08:21:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 779B12070A for ; Wed, 25 Mar 2020 08:21:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=cypress.com header.i=@cypress.com header.b="pD2+9fsb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727177AbgCYIVL (ORCPT ); Wed, 25 Mar 2020 04:21:11 -0400 Received: from mail-dm6nam10on2113.outbound.protection.outlook.com ([40.107.93.113]:25385 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725903AbgCYIVL (ORCPT ); Wed, 25 Mar 2020 04:21:11 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HgNjAlR3QwM2mSmI9ssRmKlAHsNd/QpRoRqxKoAvapL+fYhPb7DZW9xLIb4wWUkx+/ufRIgElTxcWWnnr1dcgxgnoS5BaVpVjFa7h5yC7h90ulbH8XmTdNIfV8Yjl2A3t9lgX2rsfzP8In6xRTYFno/+oDB+fJKJ9A9PFac/VmD3a2AYlDr8IE84UqSZ1QjdfrSTZP8uBttCJgFTdvRUAD/MOtAcmEmSKuPCA4sc41cFkR9rmFHmCtSQxw3p1a+C3yFVFxFi3nl6jGNjkulwKqVjTaNgZ8pD41LaNEnaKbPKbd6NqPc3gh9nAbdQJY0h+VNN1iwYiqWjkDVPNNkHEQ== 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=zNkBuUVZU/ozrIYmxaegt/1j7J9Lw4n/0KUwNJLGlZs=; b=YDE83RmdMKSiGgL0yWKcOOUFezP80yJtlf2f9RnkFuBcZxW9LblKS8flZHVmO8z7xUBeiBMEIKrqEN36pNRJSa7HIRVyDL8AP/7EIVTU/hVuodHMGQjwU2nKKKp17jREAJ42OWS8FKaDxRVACNr7Rin4t6GUZ2eG67mRRejK/o4IIiQNyyCqa7POmjpcJggkvz5iIpAoRGkIsvHiC/rjOs4niSQ5Nx+bO7A10OcR8vMh2Eb8W6afRj5/0x6SZPBqqiLHQkO6bvbxh8inL7uzp4LcIlGMkKWu4ujEaLWYNWy7PI7Q7/Pw6yeShp1Fj5sihMh9LanVMVehqjnKL42b9Q== 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=zNkBuUVZU/ozrIYmxaegt/1j7J9Lw4n/0KUwNJLGlZs=; b=pD2+9fsbWinS2tEw5Zd5EBaQbk2crvHUwzoPQCex61Frw+vbrZhU7uIsSnR8wDPsGKzJOkI5/IkbAPKjgA81s8+WSiLSthsOTz1Sm75jo4PBaMKBOwJx4SCFnljsHmnwT6lHw9dlwOYC0nDJMeTsCafZDc759A3K/IzU6TyY3Nk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Chi-Hsien.Lin@cypress.com; Received: from BYAPR06MB4901.namprd06.prod.outlook.com (2603:10b6:a03:7a::30) by BYAPR06MB5189.namprd06.prod.outlook.com (2603:10b6:a03:cf::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.15; Wed, 25 Mar 2020 08:20:59 +0000 Received: from BYAPR06MB4901.namprd06.prod.outlook.com ([fe80::69bb:5671:e8b:74c1]) by BYAPR06MB4901.namprd06.prod.outlook.com ([fe80::69bb:5671:e8b:74c1%3]) with mapi id 15.20.2835.023; Wed, 25 Mar 2020 08:20:58 +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 , Chi-hsien Lin Subject: [PATCH V3 6/6] brcmfmac: To support printing USB console messages Date: Wed, 25 Mar 2020 03:20:29 -0500 Message-Id: <1585124429-97371-7-git-send-email-chi-hsien.lin@cypress.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1585124429-97371-1-git-send-email-chi-hsien.lin@cypress.com> References: <1585124429-97371-1-git-send-email-chi-hsien.lin@cypress.com> X-ClientProxiedBy: BYAPR08CA0027.namprd08.prod.outlook.com (2603:10b6:a03:100::40) 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 BYAPR08CA0027.namprd08.prod.outlook.com (2603:10b6:a03:100::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.20 via Frontend Transport; Wed, 25 Mar 2020 08:20:57 +0000 X-Mailer: git-send-email 2.1.0 X-Originating-IP: [12.110.209.245] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 4016b762-e215-44ff-d8c4-08d7d095722d X-MS-TrafficTypeDiagnostic: BYAPR06MB5189:|BYAPR06MB5189: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2089; X-Forefront-PRVS: 0353563E2B X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(366004)(66556008)(8676002)(81156014)(2906002)(66476007)(66946007)(81166006)(6486002)(8936002)(6916009)(16526019)(26005)(956004)(2616005)(498600001)(6666004)(54906003)(86362001)(52116002)(7696005)(15650500001)(186003)(36756003)(5660300002)(107886003)(4326008);DIR:OUT;SFP:1102;SCL:1;SRVR:BYAPR06MB5189;H:BYAPR06MB4901.namprd06.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords; Received-SPF: None (protection.outlook.com: cypress.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rtcw9TyVqgvoiLQqKggtaJQhmb9zBGFbxjQo2XnYoHyuCEE5uj7w/yzx91lUt3BERFdn17eaubALQIjECIC5dvLUj7OIPPdWMOTmLh974VvoPx9BH2kFSACN3VJgcZQ4jODjPzuL4kW87ikKgGzCL3fHzFOCsJZGTtbuccaxAzharF7EcgukFcZ9QUGqtMjBG6eFWQZaflVoJyAMUeZFB2ug4hrbeAcY5LeOVeiQMiKTHEXUhPevMA6NfOxtLkzJ++sZzJVbrVYyV7Fs2wuB+9MBPJeaaK/wZrlVBNcTHc2fpCIBGZHIWHl3O/G1xbiF5YYxoJg9Prf89qu0yW4R6FqH1wzedFAJoEk9pm2oRrBbAa8WZWW6XXzRwbvra9TN0rexIVjqzT/2gsHv9tEgz/gU7q4vBB+Qabk1p+O4I6c1aQLyNbseq5O2rzqsEfKx X-MS-Exchange-AntiSpam-MessageData: mk4RpTCkgwB2I6ionznOssZZpj037mmdh3tYeXtck6q4l/ri4SLvnD9X/7LAAAB8PfRVueIJsDBR5lBiKa150g9W2+vgt28/DrrDk4OIBzynhAznpYQeYjANQq1CH6iESIP/o6XCR4ZYpCu/TMXuYg== X-OriginatorOrg: cypress.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4016b762-e215-44ff-d8c4-08d7d095722d X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2020 08:20:58.6722 (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: EQ4f/wWvU1Vhq4ZGpxSpiPWew+wnQ4yOjfdHAJXVip8ZjkEbWqZ25YJ4Mvjua/o/tMKrO0R7n1NHZSEYv4Rq6A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR06MB5189 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Raveendran Somu This change is to add support for printing the firmware console messges of a USB interface chip to the host. To enable this feature, build option '-msgtrace' should be enabled in the firmware. And in the host, debug=0x100000 should be provided as a module parameter. Signed-off-by: Raveendran Somu Signed-off-by: Chi-hsien Lin --- .../net/wireless/broadcom/brcm80211/brcmfmac/bus.h | 1 + .../wireless/broadcom/brcm80211/brcmfmac/core.c | 8 +++ .../wireless/broadcom/brcm80211/brcmfmac/debug.c | 82 ++++++++++++++++++++++ .../wireless/broadcom/brcm80211/brcmfmac/debug.h | 24 +++++++ .../net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 14 ++++ 5 files changed, 129 insertions(+) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h index 623c0168da79..c8063ca50611 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h @@ -271,6 +271,7 @@ void brcmf_bus_change_state(struct brcmf_bus *bus, enum brcmf_bus_state state); s32 brcmf_iovar_data_set(struct device *dev, char *name, void *data, u32 len); void brcmf_bus_add_txhdrlen(struct device *dev, uint len); +int brcmf_fwlog_attach(struct device *dev); #ifdef CONFIG_BRCMFMAC_SDIO void brcmf_sdio_exit(void); diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c index 23627c953a5e..fab852461cf1 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c @@ -1117,6 +1117,14 @@ static int brcmf_inet6addr_changed(struct notifier_block *nb, } #endif +int brcmf_fwlog_attach(struct device *dev) +{ + struct brcmf_bus *bus_if = dev_get_drvdata(dev); + struct brcmf_pub *drvr = bus_if->drvr; + + return brcmf_debug_fwlog_init(drvr); +} + static int brcmf_revinfo_read(struct seq_file *s, void *data) { struct brcmf_bus *bus_if = dev_get_drvdata(s->private); diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c index 120515fe8250..64c8ba0ef8af 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c @@ -14,6 +14,82 @@ #include "fweh.h" #include "debug.h" +static int +brcmf_debug_msgtrace_seqchk(u32 *prev, u32 cur) +{ + if ((cur == 0 && *prev == 0xFFFFFFFF) || ((cur - *prev) == 1)) { + goto done; + } else if (cur == *prev) { + brcmf_dbg(FWCON, "duplicate trace\n"); + return -1; + } else if (cur > *prev) { + brcmf_dbg(FWCON, "lost %d packets\n", cur - *prev); + } else { + brcmf_dbg(FWCON, "seq out of order, host %d, dongle %d\n", + *prev, cur); + } +done: + *prev = cur; + return 0; +} + +static int +brcmf_debug_msg_parser(void *event_data) +{ + int err = 0; + struct msgtrace_hdr *hdr; + char *data, *s; + static u32 seqnum_prev; + + hdr = (struct msgtrace_hdr *)event_data; + data = (char *)event_data + MSGTRACE_HDRLEN; + + /* There are 2 bytes available at the end of data */ + data[ntohs(hdr->len)] = '\0'; + + if (ntohl(hdr->discarded_bytes) || ntohl(hdr->discarded_printf)) { + brcmf_dbg(FWCON, "Discarded_bytes %d discarded_printf %d\n", + ntohl(hdr->discarded_bytes), + ntohl(hdr->discarded_printf)); + } + + err = brcmf_debug_msgtrace_seqchk(&seqnum_prev, ntohl(hdr->seqnum)); + if (err) + return err; + + while (*data != '\0' && (s = strstr(data, "\n")) != NULL) { + *s = '\0'; + brcmf_dbg(FWCON, "CONSOLE: %s\n", data); + data = s + 1; + } + if (*data) + brcmf_dbg(FWCON, "CONSOLE: %s", data); + + return err; +} + +static int +brcmf_debug_trace_parser(struct brcmf_if *ifp, + const struct brcmf_event_msg *evtmsg, + void *event_data) +{ + int err = 0; + struct msgtrace_hdr *hdr; + + hdr = (struct msgtrace_hdr *)event_data; + if (hdr->version != MSGTRACE_VERSION) { + brcmf_dbg(FWCON, "trace version mismatch host %d dngl %d\n", + MSGTRACE_VERSION, hdr->version); + err = -EPROTO; + return err; + } + + if (hdr->trace_type == MSGTRACE_HDR_TYPE_MSG) + err = brcmf_debug_msg_parser(event_data); + + return err; +} + int brcmf_debug_create_memdump(struct brcmf_bus *bus, const void *data, size_t len) { @@ -42,6 +118,12 @@ int brcmf_debug_create_memdump(struct brcmf_bus *bus, const void *data, return 0; } +int brcmf_debug_fwlog_init(struct brcmf_pub *drvr) +{ + return brcmf_fweh_register(drvr, BRCMF_E_TRACE, + brcmf_debug_trace_parser); +} + struct dentry *brcmf_debugfs_get_devdir(struct brcmf_pub *drvr) { return drvr->wiphy->debugfsdir; diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h index 9b221b509ade..d61508b62d2c 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h @@ -103,6 +103,10 @@ do { \ #endif /* defined(DEBUG) || defined(CONFIG_BRCM_TRACING) */ +#define MSGTRACE_VERSION 1 +#define MSGTRACE_HDR_TYPE_MSG 0 +#define MSGTRACE_HDR_TYPE_LOG 1 + #define brcmf_dbg_hex_dump(test, data, len, fmt, ...) \ do { \ trace_brcmf_hexdump((void *)data, len); \ @@ -120,6 +124,7 @@ int brcmf_debugfs_add_entry(struct brcmf_pub *drvr, const char *fn, int (*read_fn)(struct seq_file *seq, void *data)); int brcmf_debug_create_memdump(struct brcmf_bus *bus, const void *data, size_t len); +int brcmf_debug_fwlog_init(struct brcmf_pub *drvr); #else static inline struct dentry *brcmf_debugfs_get_devdir(struct brcmf_pub *drvr) { @@ -137,6 +142,25 @@ int brcmf_debug_create_memdump(struct brcmf_bus *bus, const void *data, { return 0; } + +static inline +int brcmf_debug_fwlog_init(struct brcmf_pub *drvr) +{ + return 0; +} #endif +/* Message trace header */ +struct msgtrace_hdr { + u8 version; + u8 trace_type; + u16 len; /* Len of the trace */ + u32 seqnum; /* Sequence number of message */ + /* Number of discarded bytes because of trace overflow */ + u32 discarded_bytes; + /* Number of discarded printf because of trace overflow */ + u32 discarded_printf; +}; + +#define MSGTRACE_HDRLEN sizeof(struct msgtrace_hdr) #endif /* BRCMFMAC_DEBUG_H */ diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c index ac5463838fcf..89220cf3a4de 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c @@ -1219,6 +1219,12 @@ static void brcmf_usb_probe_phase2(struct device *dev, int ret, if (ret) goto error; + if (BRCMF_FWCON_ON()) { + ret = brcmf_fwlog_attach(devinfo->dev); + if (ret) + goto error; + } + /* Attach to the common driver interface */ ret = brcmf_attach(devinfo->dev); if (ret) @@ -1295,9 +1301,17 @@ static int brcmf_usb_probe_cb(struct brcmf_usbdev_info *devinfo) ret = brcmf_alloc(devinfo->dev, devinfo->settings); if (ret) goto fail; + + if (BRCMF_FWCON_ON()) { + ret = brcmf_fwlog_attach(devinfo->dev); + if (ret) + goto fail; + } + ret = brcmf_attach(devinfo->dev); if (ret) goto fail; + /* we are done */ complete(&devinfo->dev_init_done); return 0;