From patchwork Thu Feb 13 08:44:31 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: 11380001 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 2C90217F0 for ; Thu, 13 Feb 2020 08:45:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 01BC1218AC for ; Thu, 13 Feb 2020 08:45:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=cypress.com header.i=@cypress.com header.b="Xusgp/l4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729662AbgBMIpT (ORCPT ); Thu, 13 Feb 2020 03:45:19 -0500 Received: from mail-bn8nam11on2105.outbound.protection.outlook.com ([40.107.236.105]:59328 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729619AbgBMIpT (ORCPT ); Thu, 13 Feb 2020 03:45:19 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KuB34LNzbg+ZGix1dz8ej+AHTfbhyKhlsdF5TrBFkOQ5a3LTp3U6304p8v6JhZtu5WcR8mtMLR24cPRDatUGCF24CQrdCuORIqIIBGvxUqnLN/0xhLdUb1N2M21Sx1Lfbr4Wgjs6BlW8FLjKiTiAEhIJHnoV/oN5PUvpWmctTa3q0gI1WpDCJvwGcq33l4L88fh5fisQTHrr7UrEUGhpsCimFhQGeeVn8eOuDO5uNgv72P7M+aAjq4LE+trHbKcbd8Ew6NvWVK8WkOeXq9OvT6hR2tcxzONem+R54/DquwZC2Vt1xzsxbaBs1ZK7qq+cK5mhGPssXcl9YOeINM7NuA== 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=hvyxLNM4MNi63Msk8yofKFWB0f+1AGVvZIwEsap7ZympM9SIvbpjXGIf8glYiLMcOk1zCLyhH/LcyQMDg9qhBTwoIjqwGn6tEs7MtAXk7hMo6w8k0BdzJcS/vEguW8EVNYjeR/LV3hgftEgOYSQq1lFkwUF9w0LwiGegqnHDfwcSwsL87AvhKieR01rZOPJ57Jw67WUcc8s/MFOEUCJK5ASjArQJ1hhEdLDLljNNEAhDvXl4hGToXpQ0w0jKlaJ3Ga1Ll+6Htux704FtU5tArXK2M1EpKJC/FO4oUZTqnw30edZVOgD5C/m+PESpOOVpLr+VwWnkAk4JIApkPCWAxg== 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=Xusgp/l4d0b7B4PsMh1IT2clLK9syIaguLy/M5dxhi7e44eMmd9YTs6JDpAtUgLbMiDZfEnR15OGoGhBJos8FsP8LT/gBA0rTfw+VT73gyzqO38b2GWHRzvcNOm0D8X+dBlJ86AHCLWlwm1jyfV+lBzq4dL52ctHsEzniQGyiSE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Chi-Hsien.Lin@cypress.com; Received: from BYAPR06MB4901.namprd06.prod.outlook.com (20.177.184.30) by BYAPR06MB5623.namprd06.prod.outlook.com (20.178.196.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.29; Thu, 13 Feb 2020 08:45:16 +0000 Received: from BYAPR06MB4901.namprd06.prod.outlook.com ([fe80::61cf:307a:df0a:c031]) by BYAPR06MB4901.namprd06.prod.outlook.com ([fe80::61cf:307a:df0a:c031%3]) with mapi id 15.20.2707.030; Thu, 13 Feb 2020 08:45:16 +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 1/6] brcmfmac: Fix driver crash on USB control transfer timeout Date: Thu, 13 Feb 2020 02:44:31 -0600 Message-Id: <1581583476-60155-2-git-send-email-chi-hsien.lin@cypress.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1581583476-60155-1-git-send-email-chi-hsien.lin@cypress.com> References: <1581583476-60155-1-git-send-email-chi-hsien.lin@cypress.com> X-ClientProxiedBy: BYAPR02CA0050.namprd02.prod.outlook.com (2603:10b6:a03:54::27) To BYAPR06MB4901.namprd06.prod.outlook.com (2603:10b6:a03:7a::30) MIME-Version: 1.0 Received: from aremote02.aus.cypress.com (12.110.209.245) by BYAPR02CA0050.namprd02.prod.outlook.com (2603:10b6:a03:54::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.29 via Frontend Transport; Thu, 13 Feb 2020 08:45:15 +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: 13e9e2eb-2ee1-4c1b-91d9-08d7b0610c1e X-MS-TrafficTypeDiagnostic: BYAPR06MB5623:|BYAPR06MB5623: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3044; X-Forefront-PRVS: 031257FE13 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(39860400002)(136003)(346002)(376002)(396003)(366004)(189003)(199004)(16526019)(478600001)(2906002)(186003)(4326008)(2616005)(316002)(26005)(5660300002)(36756003)(956004)(86362001)(6666004)(8676002)(54906003)(8936002)(66556008)(52116002)(107886003)(66476007)(81166006)(81156014)(6486002)(6916009)(7696005)(66946007);DIR:OUT;SFP:1102;SCL:1;SRVR:BYAPR06MB5623;H:BYAPR06MB4901.namprd06.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; 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: uxF8T8MYrgqD3nRCLV/uZ34BpdT0NLl9MO1oKy8+0IFFMazjQwf3JhVX2Ep/+PQAxAU3o5aaMhWhoMKaptCz9xFnj5mQbEXXNZ1tqLo5b+KgkPwSlYcP2ABNWH3VQAwP1Y84FMmhCnRIGxodA0hfHWrh+SBeFZ17S/wp29sizUuuVLJN/ZhRgEalTNC0bJqntDdJObeyUAiqOmTHyQKtq+aIRrOBz0UoT9wIq0dJ3TWnBOBsiUe7JGSY84zJsU4vutVTkvCHpjKRY3ZB/cL60k/o8VzReaSfPlx6jrEXpiLmq2hI4XMClY79tilrTzGpiQ9VDL3zMzj1ND/lEO/FyTfQ6zg5rm5Oxgk3xY6SbCfOz72+E+C74kmIfCIToX3TboASLYsW/vgBiPJxJ3d4730YStP2AgoKfwnFvqkLvtnUU8qFXNMnuEHi7NbKWCfy X-MS-Exchange-AntiSpam-MessageData: zVpB47iS+p5YcYXXD+mqTJNG9QeX+g+4+/mmXvRYoDuKGqSAIKfhlWFOPedVmN1KAY+OU4waQ/iSif7AcfvsyRUPIlp/gh70FtsNDlgBowU7iTLM47VUjmuKeP9kBzakMlEpptWH1o+1jRngGL+Fog== X-OriginatorOrg: cypress.com X-MS-Exchange-CrossTenant-Network-Message-Id: 13e9e2eb-2ee1-4c1b-91d9-08d7b0610c1e X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2020 08:45:16.2668 (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: X7n/0Nq7ynr/inSdq0ZvS2ZoYk+3YcwwMiWWElTyMiEjN+0saYnamvICNCMM+EF2XSooSzjoYqeM+06V1MQbgQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR06MB5623 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 Thu Feb 13 08:44:32 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: 11380003 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 6A8EC1395 for ; Thu, 13 Feb 2020 08:45:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 49752217F4 for ; Thu, 13 Feb 2020 08:45:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=cypress.com header.i=@cypress.com header.b="pe7n+PVr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729669AbgBMIpV (ORCPT ); Thu, 13 Feb 2020 03:45:21 -0500 Received: from mail-bn8nam11on2105.outbound.protection.outlook.com ([40.107.236.105]:59328 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726232AbgBMIpV (ORCPT ); Thu, 13 Feb 2020 03:45:21 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NIN/w3ovoXqk5Zi9bSvQ238LgoXpjoVzvWkufF0wMS/d7ldJtdbUjVvwwlexgbjLIb7bpGVg5XuDYvpjS+HHTaIai7YIy9kk/5ZSV94y+sFPNvaqGHJi0va9Sl10dvrm/GhjhsXGyodYgcSw7gwe4+ln4yJ141wKs0zVucT2/H3OOwiqs/ncoPvvykADwq6ztwn/Q1IwssFWmYgEsd9+QvQ5qcjMRBWD/YlXW/Fx0+gSOFa7OtzsV9oGM+FpUCaGffLKIJdsVjU2r4qEE9Hb0S7RB+NRDnrot3DHHP22K6Jt4qH16nmPL72uzsNllMnkvFY5RbHvFWF+BYJWa7uRpA== 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=glYE9pF7LJrP7/oUkim8Bit5DwXAlP9VfGLL172gNEIkw9UNG50lABBpmlKlRyH4ypixw+yMjjQlMPefx14UTVsI5czdk7AzB2NlUDenYdy3LTI5RnnZsRsYhJKBXoAW5OdNj28YpvmPTfqla6MbwCiJDUMNZOq4Zv01/0xc6UWE65Zg/EEaWUlmtLU9AryUhKqncz6RD08cQmKRawp6I1a4GKmgcHhJFN1VJF5EIvhYtzYjyPZD6jvH6iGsLKydxxZc5c1StjYHIKKJnqhOj8vnsnH+IBdntJlIVnTPmwmt1yo2ZGRqZLjPuYhjFXUPZLJr/dqRj7JUAvPI2g4zLg== 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=pe7n+PVrm/79EtUbzsTJAtl+nIjWiZn7+UU4JNUFXnonTCwBoHjapAApCybOYIQYy1bQGVZ7h+LpplOLEY4xX2sIDyee4NmtGi4AjmYPxquhYDxU/6mvkqLy/enlPpnTCeqJen1fyw4ujsS533s40E2lmNvvBOW3BWzdKAl/I4A= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Chi-Hsien.Lin@cypress.com; Received: from BYAPR06MB4901.namprd06.prod.outlook.com (20.177.184.30) by BYAPR06MB5623.namprd06.prod.outlook.com (20.178.196.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.29; Thu, 13 Feb 2020 08:45:17 +0000 Received: from BYAPR06MB4901.namprd06.prod.outlook.com ([fe80::61cf:307a:df0a:c031]) by BYAPR06MB4901.namprd06.prod.outlook.com ([fe80::61cf:307a:df0a:c031%3]) with mapi id 15.20.2707.030; Thu, 13 Feb 2020 08:45:17 +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 2/6] brcmfmac: Fix double freeing in the fmac usb data path Date: Thu, 13 Feb 2020 02:44:32 -0600 Message-Id: <1581583476-60155-3-git-send-email-chi-hsien.lin@cypress.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1581583476-60155-1-git-send-email-chi-hsien.lin@cypress.com> References: <1581583476-60155-1-git-send-email-chi-hsien.lin@cypress.com> X-ClientProxiedBy: BYAPR02CA0050.namprd02.prod.outlook.com (2603:10b6:a03:54::27) To BYAPR06MB4901.namprd06.prod.outlook.com (2603:10b6:a03:7a::30) MIME-Version: 1.0 Received: from aremote02.aus.cypress.com (12.110.209.245) by BYAPR02CA0050.namprd02.prod.outlook.com (2603:10b6:a03:54::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.29 via Frontend Transport; Thu, 13 Feb 2020 08:45:16 +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: 96671ed7-4ebe-48d6-855c-08d7b0610cd2 X-MS-TrafficTypeDiagnostic: BYAPR06MB5623:|BYAPR06MB5623: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-Forefront-PRVS: 031257FE13 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(39860400002)(136003)(346002)(376002)(396003)(366004)(189003)(199004)(16526019)(478600001)(2906002)(186003)(4326008)(2616005)(316002)(26005)(5660300002)(36756003)(956004)(86362001)(6666004)(8676002)(54906003)(8936002)(66556008)(52116002)(107886003)(66476007)(81166006)(81156014)(6486002)(6916009)(7696005)(66946007);DIR:OUT;SFP:1102;SCL:1;SRVR:BYAPR06MB5623;H:BYAPR06MB4901.namprd06.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; 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: /sYL9DxL9++XjkCitVWfSW1PkiAkGcShxniupxGPHVtJ7Q9EV5oiAEhuV2q97hIjwz/TuEjWnMEBAwD6tAVKG4HJiaWsAL6AfslAce6uBNnUbNCUDFNNgG9ieURfVchJoZUFpohA5PHg/y0M98qyVg79WzcnL9d5gHDbMimKRC21nUbVz3s111PdrzLjILuouQEvbzV2/xk7qbX9pwj3JUqrJPXxbALOafEtZvvZ+OM8AsZ8LP0TgHve28v4LVQyO9xW41VphQQ1TEBgLuguU2On5DiQmEerY6iwcfAs4fwzpCgojqRiWggh2O4TGPeY3kQLCJKpCNq2UEAoqgyYO8dK/7XdxiclxfzTzGMveIySHcxtlXF8UQLd5RUqJH6lrzAuJmBFUk/mDzbXvWNoMAFEiXEfcrFUG0gapZuFU+GX0ST5uTL/ZwezRScr9pR+ X-MS-Exchange-AntiSpam-MessageData: +yz5mKF+PBIhEl3m1iVuNVaLDI1/Vd5XQaMoGlSw1Bi4xFRv2lPbF4s+G7HnqH+ZonwHD16zKHHLSn0shGKcJ4t70Mk4k97cG5jgfrukgWpEpxTwzrfwZUc158NQ+WmOrNpqChhfS8lEnEN9QDrVqg== X-OriginatorOrg: cypress.com X-MS-Exchange-CrossTenant-Network-Message-Id: 96671ed7-4ebe-48d6-855c-08d7b0610cd2 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2020 08:45:17.4461 (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: KMcGM2EhNn46eavUyx7J8HP4syVO3K5CsGr4zQZQbT8VxUQ/EkDSK5XZngKAS3O6rB5xewcHiI/tJdw471CZXw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR06MB5623 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 Thu Feb 13 08:44:33 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: 11380005 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 6CDE217F0 for ; Thu, 13 Feb 2020 08:45:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4AB5F218AC for ; Thu, 13 Feb 2020 08:45:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=cypress.com header.i=@cypress.com header.b="ihtKxa28" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729673AbgBMIpX (ORCPT ); Thu, 13 Feb 2020 03:45:23 -0500 Received: from mail-bn8nam11on2105.outbound.protection.outlook.com ([40.107.236.105]:59328 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729619AbgBMIpX (ORCPT ); Thu, 13 Feb 2020 03:45:23 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LvNjz9iIX19XPjVPU+YOXP+/KFuWT4aQXCZI1vxmAFuWv+YkvRXKdZ+8/EqCaK77gkeuBm5wUUIDujq/Bj1t38QskanJ3E+NwoaE6cRLACLW7CViVuj5m6PgwcJeToC1dlX7IeBNW7w76Vyu6wVlcceEoEG5/E4a/l1paHM1HG5sIHN1i2zjrG4pKp7YpTqijoL0YTuefqfI5f7zSYIBKZwuTQruk72UmKrjRAJuPSYYY9pltGK7hcWwQSlVGpaY/RfzwWRIg/TO2acVbcB6mpCEegKVKadpePZGytqd0eYGlWwEcmfi+Z9FqkeMNHaNPUNUEu7fSKAmY0I2xPhvLw== 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=p48uRjw1CGoBMH+Wc346yKPibmrv7SfJ6ftVAvf9NGs=; b=fprkDLVVqmVMtzdcmy/b+eUkdimxWIk1iR5gaNHOmNjQ0k+7wzMdrEI6P+plgVw+7CSisWxKTON/7phXPzdd0llszTaI/1yB8h5F+OtDHW/uihLzfRAqMLqQYvwc4j/ituGrSbwVDHcijsRKAibPBvWh6CGm4bU2DpacHjH0bBmkhGZDfc6o677D2oHv4NOQfsSKS0HKK/fJ4JnOvsUXrqqGpaPIOqG55vH9veiijqYlUfVlKhDee7zutij4gVjOplOlLb24/yfUUwuktMELdD8n2s9sx+1FSVjkp297KZiJ6LoM+ilSysBBp/JRe0aZYm3ADgbCmt2xRVUklhqVXg== 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=p48uRjw1CGoBMH+Wc346yKPibmrv7SfJ6ftVAvf9NGs=; b=ihtKxa2857bQWpUpMnQSVR5sEd+BaG/7K8JXogIAUfrfaDIOOLoACHFen33P3Uf3DE/cCvKP+CAJcTWOwp6PI2EIebZIe4trW7BEjExcn0rl58vR1a/wjrfV3bXI/TAJXEAx4dLfSNr+j2sFYHLhR/rjP0BPVvnwaN5ykYR/R1Y= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Chi-Hsien.Lin@cypress.com; Received: from BYAPR06MB4901.namprd06.prod.outlook.com (20.177.184.30) by BYAPR06MB5623.namprd06.prod.outlook.com (20.178.196.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.29; Thu, 13 Feb 2020 08:45:18 +0000 Received: from BYAPR06MB4901.namprd06.prod.outlook.com ([fe80::61cf:307a:df0a:c031]) by BYAPR06MB4901.namprd06.prod.outlook.com ([fe80::61cf:307a:df0a:c031%3]) with mapi id 15.20.2707.030; Thu, 13 Feb 2020 08:45: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 , Chi-hsien Lin Subject: [PATCH 3/6] brcmfmac: fix the incorrect return value in brcmf_inform_single_bss(). Date: Thu, 13 Feb 2020 02:44:33 -0600 Message-Id: <1581583476-60155-4-git-send-email-chi-hsien.lin@cypress.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1581583476-60155-1-git-send-email-chi-hsien.lin@cypress.com> References: <1581583476-60155-1-git-send-email-chi-hsien.lin@cypress.com> X-ClientProxiedBy: BYAPR02CA0050.namprd02.prod.outlook.com (2603:10b6:a03:54::27) To BYAPR06MB4901.namprd06.prod.outlook.com (2603:10b6:a03:7a::30) MIME-Version: 1.0 Received: from aremote02.aus.cypress.com (12.110.209.245) by BYAPR02CA0050.namprd02.prod.outlook.com (2603:10b6:a03:54::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.29 via Frontend Transport; Thu, 13 Feb 2020 08:45:17 +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: 6cdcd0eb-502e-47b7-3c1d-08d7b0610d87 X-MS-TrafficTypeDiagnostic: BYAPR06MB5623:|BYAPR06MB5623: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-Forefront-PRVS: 031257FE13 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(39860400002)(136003)(346002)(376002)(396003)(366004)(189003)(199004)(16526019)(478600001)(2906002)(186003)(4326008)(2616005)(316002)(26005)(5660300002)(36756003)(956004)(86362001)(6666004)(8676002)(54906003)(8936002)(66556008)(52116002)(107886003)(66476007)(81166006)(81156014)(6486002)(6916009)(7696005)(66946007);DIR:OUT;SFP:1102;SCL:1;SRVR:BYAPR06MB5623;H:BYAPR06MB4901.namprd06.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; 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: R/Z/zQZ/mVjTIdHbFxgMkeJdgU0hQ17ltP9TQm4Zp/ndcwnHDnA1QRfKVhNqELMReVgBZSyqM6eZwfd1OMDNpMFRObALcIRVjuHgqRf3p9nSxF7ApVheCvKGs6bT9JGUykbVmAYq6OMnhkpaoZLyHQL+uH0OyXbRpgcJ0v+FaYhA9/09WMSLPWqvAu4sYR7EOesWoSXgnsesZn3j32HA/vqhSffAahzz1VrZ37R8OoHQzs11kaZ60dWojVNOfEt7QKLi9g/3Dxf/BtJq+9ScbEyiJOsHxEcbK3OJzAz6cOCy7rKVqSr038wHAvFMHIP+QlufabfCdzCZim7eXawt8ygArev/MeZ6gy1vtu8Aa6jxUqnx3u9Ti/JzUqbdREFLc1HQCZDxlUOKLXsN7863SWzkhJrxhNCvOKS88snAxMP72wfOIdSXSwRaFRGFV2Io X-MS-Exchange-AntiSpam-MessageData: go7GMDIm+hz5zHkIT9CeH7RIsEid5zb6VfVwa+6v7TvF+LYHV4RxbZf1Mo/jkPHFMiFEUxXPiXUZXE+FHlZj6L/hMvpBFRDZo4fE00FBAothvZrIrsMaX9i6ScspeXtWaLuozXpE0TDUkywsg7aHcQ== X-OriginatorOrg: cypress.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6cdcd0eb-502e-47b7-3c1d-08d7b0610d87 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2020 08:45:18.7014 (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: kLgv2tYxhqqsAkH9o13SZhDYimQCnuqERyCcAOXH8QwN+4lMHo3i6nAdOdOZPnI3wiP8eEWNLzI74veEX7zM8g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR06MB5623 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 SVT 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 SVT was resolved. Signed-off-by: Raveendran Somu Signed-off-by: Chi-hsien Lin Reviewed-by: Arend van Spriel --- 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 Thu Feb 13 08:44:34 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: 11380007 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 7DB7F17F0 for ; Thu, 13 Feb 2020 08:45:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5D848218AC for ; Thu, 13 Feb 2020 08:45:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=cypress.com header.i=@cypress.com header.b="Qoo08IP9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729675AbgBMIpY (ORCPT ); Thu, 13 Feb 2020 03:45:24 -0500 Received: from mail-bn8nam11on2105.outbound.protection.outlook.com ([40.107.236.105]:59328 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726232AbgBMIpY (ORCPT ); Thu, 13 Feb 2020 03:45:24 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zswzb+0izLQE6uKVsaamOqHJlTf6jaffjliFfUer5ttIpB3R9+nu+2A69C3aWeV19mtkiyf4gGK5qxz6hUGdIL695SLAFKZMeBKMDljsQzeeNjlAhIeEPJoz/0ZArXFNJI3LTAlXxbItu2xrpbsQ8WlkUH7C17BCL+q4QW71TMhGuAb50iAjrX0eg8mqADIzSV95y/2S3GZ/szMrU7WdJvryTJgj2pEhVRXhiSrBwQ8w3dsFTXLgFyfq9LOkWh2XOECT1ozeJmKH5Gh8gab5f1whBIVs/97GumGA9cwv+lkHRHd1rd2wYMhsLpRM0m+iwO7bOee0NN4EuyT13nx7Jw== 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=I4qgJcGLXI+XsLVyYZAUmWar7WyiaClAi9QwpblnUmwsdEcr3NXzakByokeuxedtHjJdzMwatWL25bUlUX5FUtylcDs4e25VikzhDI+QYWaSXYGAf3jxdjTgtkeLgPgMGtSpvdX30XsBFu6BjrX9egG7KVF2tmXFvAzJMdMI+0gfW1cV1vwyfiWGVW4cAQZcHY4OLBMf7/LeI0CKYKdFrmrmIqiVQ2/NE5a9ZfiRPmCUxiAh3l+Q84tza4A0Pdb1tlsKcA0TLXbk6Nw6doRa2HG8XPG9z3dgRB8zI1BBzP38bqGdrlvWd1VU4SPVrDOFhUQjdIiowojdOwDH0YGXbQ== 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=Qoo08IP9zdraGYZQiLlRZzaUTyCIuZkvzognX99vYx5OmJA451X3N2iH0+XUBFP7ylIFyWDdzWJgRDBQxU8W+8ayK3HHAGkatFYGCX5UEmSj+riNVr5PgfeX+zLEQp5Vkdwe15k+7lWLykPwj5xmj8oZKNkp2HfdiGuagRL9hgc= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Chi-Hsien.Lin@cypress.com; Received: from BYAPR06MB4901.namprd06.prod.outlook.com (20.177.184.30) by BYAPR06MB5623.namprd06.prod.outlook.com (20.178.196.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.29; Thu, 13 Feb 2020 08:45:20 +0000 Received: from BYAPR06MB4901.namprd06.prod.outlook.com ([fe80::61cf:307a:df0a:c031]) by BYAPR06MB4901.namprd06.prod.outlook.com ([fe80::61cf:307a:df0a:c031%3]) with mapi id 15.20.2707.030; Thu, 13 Feb 2020 08:45:20 +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 4/6] brcmfmac: increase max hanger slots from 1K to 3K in fws layer Date: Thu, 13 Feb 2020 02:44:34 -0600 Message-Id: <1581583476-60155-5-git-send-email-chi-hsien.lin@cypress.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1581583476-60155-1-git-send-email-chi-hsien.lin@cypress.com> References: <1581583476-60155-1-git-send-email-chi-hsien.lin@cypress.com> X-ClientProxiedBy: BYAPR02CA0050.namprd02.prod.outlook.com (2603:10b6:a03:54::27) To BYAPR06MB4901.namprd06.prod.outlook.com (2603:10b6:a03:7a::30) MIME-Version: 1.0 Received: from aremote02.aus.cypress.com (12.110.209.245) by BYAPR02CA0050.namprd02.prod.outlook.com (2603:10b6:a03:54::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.29 via Frontend Transport; Thu, 13 Feb 2020 08:45:18 +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: 1108d2f8-2bbc-48a4-02d8-08d7b0610e4f X-MS-TrafficTypeDiagnostic: BYAPR06MB5623:|BYAPR06MB5623: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3826; X-Forefront-PRVS: 031257FE13 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(39860400002)(136003)(346002)(376002)(396003)(366004)(189003)(199004)(16526019)(478600001)(2906002)(186003)(4326008)(2616005)(316002)(26005)(5660300002)(36756003)(956004)(86362001)(6666004)(8676002)(54906003)(8936002)(66556008)(52116002)(107886003)(66476007)(81166006)(81156014)(6486002)(6916009)(7696005)(66946007);DIR:OUT;SFP:1102;SCL:1;SRVR:BYAPR06MB5623;H:BYAPR06MB4901.namprd06.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; 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: jqbrNYGNBYgaw97a485o5h3kk/nwRJA1iL+UA8xUJe45+p2TJkJmguiKrptD7Tixn7bGiG2e4L++sFhIR1YuXnct+52SZg2P5pMttMwiGSI8q7eKNnsDaWnW6eoZcJbd1fYSLdWSOXt9eRQ8SF93sD6G/cr9o0dwDEdIDGTOiRFQrkSdaaZNiLqXqEINLOChZaOURggVFo5NjwJwAVr2EX76Uf0n3og6GjTyVGUyoUCNeGW6XQm2+MEZCm7mjzGYcqOUV0lOl3CxDlDk2MmbBtyQj/9UCTg+vRpSN0MZNbl0rWpWN9RBy57vUprdzq6oQGTF2rQERzS8joIbsCOhTgSBujp/oFoMMNKcBuHE11FxSVzUBpukx+upBDDMn/VmlgpA37yBInuZmH+EJuNZaoqPBrgISke+wUrsWe+mc2i9E/R0H6M14/NkhxipWa4L X-MS-Exchange-AntiSpam-MessageData: 1g4QiISez/9SjMU1WILU5pRKWYYCepbo0zr45JVpSjZlAuTGFx/ClmdfzRpW2E4dPOQXxozdDtb/tAcMbtuE7Y9j8JbDOjvxxU3Ucz0Iif9SE9xAzH2lukC8GNqIoMtLfgvJ2+giLu7542fMlJc6Zw== X-OriginatorOrg: cypress.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1108d2f8-2bbc-48a4-02d8-08d7b0610e4f X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2020 08:45:19.9627 (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: yetMLStXuGV9H+GuGqdliQjBLY4YWPC6pPUw+nS9iLgPQCY5E84im9NzlKqYle08/yTroyLsFD0xIRY0S7JwgQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR06MB5623 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 Thu Feb 13 08:44:35 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: 11380009 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 375C61395 for ; Thu, 13 Feb 2020 08:45:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EDDD4218AC for ; Thu, 13 Feb 2020 08:45:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=cypress.com header.i=@cypress.com header.b="lEhJXuYQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729681AbgBMIp1 (ORCPT ); Thu, 13 Feb 2020 03:45:27 -0500 Received: from mail-bn8nam11on2105.outbound.protection.outlook.com ([40.107.236.105]:59328 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729485AbgBMIp1 (ORCPT ); Thu, 13 Feb 2020 03:45:27 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CT4jnzNA1wqbS9wJIxUXbE5xJGAUNb1DGmfPWP5A4Y5kciZchyO2/mHmH7MoSCVD9k/DbNAZ92jvnCAseRIMQrk9doxPIN2X3xCCE7HPFsJ+wfcqMXxVPRSYEEv3CXVVx9BaOMvif0MvzAbVMUi/3wXji2oT0q74oWjsnJQo6pZEUPnQx0/y+jRb6tAYEg5+RweVjxhv1/U6e+mBZqHH2Zei2PUyo0RJw87INVpHAsntXG7jHem+3CNFe4X5hEBV6YTvuFhvm7m7ktBUzaLj5rO0znCC6unTIcWi3iyagbeIETmPUxVMyPhBSUhUnrMr6+iDUGaBCNy9uYbD3gwEOA== 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=6dfvJm7g6YJBnL4CH5iuHvNWUwg+m+aQ+QGhl+OwLC4=; b=DuUBfTBzcVASi+pBxRyu/xKL+42AGVQA4/hX5HZnyFh2po+t9oMEvJX5/+EbH0uFG/PMrTVMGAdaH7lEz+loVPJJSpq/0vJLQcyYpWAMPGvZ9p9QYHJJhGcqP8GFu1CpS7kwKl6rwCfhpZAzT1J0qlgzb3A6+waHF1eQDCP1vVveGCuBAU3YLhtPSD+KtGe3Mh248sQ3wy4K8TcMbUdVSQp7JR1qx5g84VkDQiXkFl8VevegYGCYF4m/oARcQH9dGCBW4U8wjcAxJRqa//QMpD4SrhfidbHZJ72r0fcG6eA3ctFmTwItWQSCC+DXqreTM4U+dR1MsIk1mKB15yTscw== 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=6dfvJm7g6YJBnL4CH5iuHvNWUwg+m+aQ+QGhl+OwLC4=; b=lEhJXuYQnHMzkXRU50KHXP3+FdsUDR3kEajNEIDrsoqzy8SgYX/OWGR9lhsJ9A9UmZXEF6pAe+Qi5FI8InBkBFE1u4dDAdkJKr12xlbrv7RON2+PRXjYiUbxvawJcFF9yVYenKQbZjBkWa73PFPVVdVVHjcCit6kNtCm0hDwuX8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Chi-Hsien.Lin@cypress.com; Received: from BYAPR06MB4901.namprd06.prod.outlook.com (20.177.184.30) by BYAPR06MB5623.namprd06.prod.outlook.com (20.178.196.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.29; Thu, 13 Feb 2020 08:45:21 +0000 Received: from BYAPR06MB4901.namprd06.prod.outlook.com ([fe80::61cf:307a:df0a:c031]) by BYAPR06MB4901.namprd06.prod.outlook.com ([fe80::61cf:307a:df0a:c031%3]) with mapi id 15.20.2707.030; Thu, 13 Feb 2020 08:45:21 +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 5/6] brcmfmac: add USB autosuspend feature support Date: Thu, 13 Feb 2020 02:44:35 -0600 Message-Id: <1581583476-60155-6-git-send-email-chi-hsien.lin@cypress.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1581583476-60155-1-git-send-email-chi-hsien.lin@cypress.com> References: <1581583476-60155-1-git-send-email-chi-hsien.lin@cypress.com> X-ClientProxiedBy: BYAPR02CA0050.namprd02.prod.outlook.com (2603:10b6:a03:54::27) To BYAPR06MB4901.namprd06.prod.outlook.com (2603:10b6:a03:7a::30) MIME-Version: 1.0 Received: from aremote02.aus.cypress.com (12.110.209.245) by BYAPR02CA0050.namprd02.prod.outlook.com (2603:10b6:a03:54::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.29 via Frontend Transport; Thu, 13 Feb 2020 08:45:20 +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: 1ebb3c4c-b961-4831-ed6e-08d7b0610f06 X-MS-TrafficTypeDiagnostic: BYAPR06MB5623:|BYAPR06MB5623: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:207; X-Forefront-PRVS: 031257FE13 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(39860400002)(136003)(346002)(376002)(396003)(366004)(189003)(199004)(16526019)(478600001)(2906002)(186003)(4326008)(2616005)(316002)(26005)(5660300002)(36756003)(956004)(86362001)(6666004)(8676002)(54906003)(8936002)(66556008)(52116002)(107886003)(66476007)(81166006)(81156014)(6486002)(6916009)(7696005)(66946007);DIR:OUT;SFP:1102;SCL:1;SRVR:BYAPR06MB5623;H:BYAPR06MB4901.namprd06.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; 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: y+g6VyM3D180B5WZbHA+K9ea9bFMD+OCqUrBdbxmxUCDNjc6j5eiNZJJfCHTq8TmuMliztNJ3A2isHVLFKH90jUKInCAiPimMGMv86l+7bRA7TcWxRAUqyVAMAZR/2GpkMJP7S9sQ3ZvmgFQblW/Rwa+KXMS1rBRBEIbLWuc0UKk8I7HHlZwpltrQPj0wQGIX+Kyvmfgtz/ViUnu0cX/BQ02IgV1clKYTLCi6gJFhIMN2faipuqdIG/fwfaH9U2NrlT/YRVvl+P4oO3s4uZXeqWpc72yWAHGMqEQXsG3S3PhbNNfSAMGLvsYnxHgZUUOsVmeo2LTbs02jjZp/qPxaeDxnOZYjZIu7oetryTJ5FdHoz1+gtHxUEwnCzjRls2GqGteWXyZhcQWBIRUcJFDpwlYtFAQdja4a2MpL8BzHdC9fPcDl5qrKOY5xxEMwYrz X-MS-Exchange-AntiSpam-MessageData: M3MhQXdFCabI3U30UvjCEgEh4MT5lu2P30MU1O+9YmwRuZ5kG7FKZHYlYsOvuvyMByfS65opj4Vm71uIGkpyCn2kt3WTuC886m/pMBkxw5WnQk4B7z88LKB13jKHxfZKhtD+nj4FlJRyZPuG0PmeMQ== X-OriginatorOrg: cypress.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1ebb3c4c-b961-4831-ed6e-08d7b0610f06 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2020 08:45:21.1320 (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: K69/0knbMVnNpZCrwJ/Rx4/Id7lT0H5L4xIICjTlA5/tS+Bk1Y0E93GgyOdLxfhklRmjWkrSc2+iS6MXNc6gCg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR06MB5623 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. It can let platform cut down idle power consumption. To support autosuspend feature in host driver. Kernel need to be build with CONFIG_USB_SUSPEND and autosuspend need to be turn on. 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 Thu Feb 13 08:44:36 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: 11380011 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 EC41017F0 for ; Thu, 13 Feb 2020 08:45:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C1B87222C2 for ; Thu, 13 Feb 2020 08:45:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=cypress.com header.i=@cypress.com header.b="OMa04Wt2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729629AbgBMIpa (ORCPT ); Thu, 13 Feb 2020 03:45:30 -0500 Received: from mail-bn8nam11on2105.outbound.protection.outlook.com ([40.107.236.105]:59328 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729678AbgBMIp3 (ORCPT ); Thu, 13 Feb 2020 03:45:29 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZbINMakZA6CF5qWP0YRxmQPiTlAfAJCHaUyiQvrmuN7922nZoFWf4pocru5TbszlWO83PqIuXDQHCpAFxha5aSUe/2PQan1jzMpUz9+bYsTO+dDXBeCF2llU93TEYStgcPe5c9Vxf44bhj2/QbyHZy+reaRZGPK3ujqBT8odB8XN7k5RcQIlVY0RHtZvOGBr+DSw2ssSSqgbUPPgqR7oHJg1P7vEtFJVpPUjQnU/eqV23qB0rqug95fjR6/NhIvt5VaPTwCHJ3xb4NxWXwUbloVGKGwFOXurQmJDlTEHSmHt65c2FjkzXlJ46eglLmg5uWpcFo2VtfVX7cgQ5gaKtw== 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=QiFlZBH5i28NEZsbR6ePiQB8vf+vfx6hhA486X7qbrBM9GdDY2UsMjNK2h7Lt32VRyV+2jVc2JLDe+9bs8Z/bjW4t6UThG3X98V2OPCzS6tIdICxm3WQ2i5f+RvGSymo0bpepMy8dYkZ7EFipd2HYMO8jrVa9ACiZwdOf7kf7yeKKLn1zMGA7fH0hKKPaFLeQyZL7YNxwg7gnkyXCQmgJL0MppTcsL1XSM0g0weW/mGHDj3RCbCDV8pjFhiwowTqOIspDIIC/kbbu3jC94zAi0yOXEsxwiDOCE2J3aS2njh3OlLi/kY1l0pzuziJNd572Js2bJKq7Rj/4yAoEIzNvA== 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=OMa04Wt2MMDeg9YMnEYsgLf8dH1UfWjHSr28IhYU9VhNpB5V5caEu+CtOvy2gNrP4QLmojqyrH+BUmA0ihNS99zpAYLNB45sszdDpShmUZEaAibefJxT4rY+rnBsMoQJKjqYmIlHGK8bElK/D94iZeID1B5bhtZKmFw6Nyr+BKA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Chi-Hsien.Lin@cypress.com; Received: from BYAPR06MB4901.namprd06.prod.outlook.com (20.177.184.30) by BYAPR06MB5623.namprd06.prod.outlook.com (20.178.196.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.29; Thu, 13 Feb 2020 08:45:22 +0000 Received: from BYAPR06MB4901.namprd06.prod.outlook.com ([fe80::61cf:307a:df0a:c031]) by BYAPR06MB4901.namprd06.prod.outlook.com ([fe80::61cf:307a:df0a:c031%3]) with mapi id 15.20.2707.030; Thu, 13 Feb 2020 08:45: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 , Raveendran Somu , Chi-hsien Lin Subject: [PATCH 6/6] brcmfmac: To support printing USB console messages Date: Thu, 13 Feb 2020 02:44:36 -0600 Message-Id: <1581583476-60155-7-git-send-email-chi-hsien.lin@cypress.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1581583476-60155-1-git-send-email-chi-hsien.lin@cypress.com> References: <1581583476-60155-1-git-send-email-chi-hsien.lin@cypress.com> X-ClientProxiedBy: BYAPR02CA0050.namprd02.prod.outlook.com (2603:10b6:a03:54::27) To BYAPR06MB4901.namprd06.prod.outlook.com (2603:10b6:a03:7a::30) MIME-Version: 1.0 Received: from aremote02.aus.cypress.com (12.110.209.245) by BYAPR02CA0050.namprd02.prod.outlook.com (2603:10b6:a03:54::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.29 via Frontend Transport; Thu, 13 Feb 2020 08:45:21 +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: 05f1d1ce-07ad-459c-3b30-08d7b0610fc7 X-MS-TrafficTypeDiagnostic: BYAPR06MB5623:|BYAPR06MB5623: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2089; X-Forefront-PRVS: 031257FE13 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(39860400002)(136003)(346002)(376002)(396003)(366004)(189003)(199004)(16526019)(478600001)(2906002)(186003)(4326008)(2616005)(316002)(26005)(5660300002)(36756003)(956004)(86362001)(6666004)(8676002)(54906003)(8936002)(66556008)(52116002)(107886003)(66476007)(81166006)(81156014)(6486002)(15650500001)(6916009)(7696005)(66946007);DIR:OUT;SFP:1102;SCL:1;SRVR:BYAPR06MB5623;H:BYAPR06MB4901.namprd06.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; 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: auLXJX/PpIBbDb+yRg9bazjTmFw1Lcn7uVLXe86o8LemF0M8+riM20Zk0IvKhlLqfOyEHntqv/JZTUHXpYRh7klU1iJ+fv07cMJlRsmlvCDZMDaU+Q4YN7mMj0f2VSS8rpu2jENmPyoBKQtJjuBvBp0T5jYVVMZY0CQeWKIz1ISVwX7AYcQJtiBfj4XJWLLyXCFc3CJ/Utw052jrdjTx2VWuBtyvNQu993nTIIpmml28oHIhERduUQPXLJW9PNwu6uFcdON9UUUfJH7m0szpT39spbY+CABmduTHiZl9/uMtPKOVrnwQE4dP9dJqm2A23ibvjtdOK5V4cadWbwRrtiM2wx3THHX20B5JB1KmblR40ziRHcDofnYNWnT/k9JraBHLXIy+M44ZxCrtfq0UWonxXyor2p41dI9q/9nYmS7iUaIgYU61sdZHkXcU9xUF X-MS-Exchange-AntiSpam-MessageData: CB9BV/iOwfk8JpBPNn4jzn1UEIG7cXhlwdAYfpY0xLOQ494fXdhNmag+NM9lkH+EPMylfVVtwMOsh+NNHV3H20HXPLifUuvYzPYfSlI5VYmO/ehtzk1WpMAvW8CpIkN6AmYxvsazTly/kXxMe+pO+w== X-OriginatorOrg: cypress.com X-MS-Exchange-CrossTenant-Network-Message-Id: 05f1d1ce-07ad-459c-3b30-08d7b0610fc7 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2020 08:45:22.3743 (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: GtoSsptueWSjhOEFJB068iV53A6Jhwzefsxv9YKBFIwgRzv/zwmWg1IoXEWXNKNpXIlruvJndReVT+R17iuQNw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR06MB5623 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;