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: 216205 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, URIBL_BLOCKED, 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 DE0E2C54FD0 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 AC7C020663 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: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: 216204 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, URIBL_BLOCKED, 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 D518CC54FD0 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 AE1B220663 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: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: 216203 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, URIBL_BLOCKED, 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 DD0FFC54FD0 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 A440520663 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, };