From patchwork Mon Sep 13 08:30:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= X-Patchwork-Id: 511655 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=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 BB3EFC433F5 for ; Mon, 13 Sep 2021 08:31:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A8C8360FBF for ; Mon, 13 Sep 2021 08:31:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238156AbhIMIci (ORCPT ); Mon, 13 Sep 2021 04:32:38 -0400 Received: from mail-bn8nam12on2070.outbound.protection.outlook.com ([40.107.237.70]:61217 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238077AbhIMIc2 (ORCPT ); Mon, 13 Sep 2021 04:32:28 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=POwVjmZoASYuFi3VBQ15DnBd05zL050hmlIDTz6xzF0M0/GQaiwFogKOL9wLQI6AEs4QWZzFe8ILULsKguf4yiFNLkTL+DHagP1oOL1KHPNRNaw1ugbFyLmiYxogLj5RUfO4B8DHbiBW9GYY1lgCrKgqgSgaI1kaVC1Ebp6bNBXqBGxIKEgZM/XWBiI7s7sqMYe3ezt2OzB3rfaofqrBNeqO+bumbSt6hKaRbLjLqOn+PWgoUtWHz6eThPxZJKUfewSGoL4BZ6yFhsHVaM1odMbwnAa/F1OGJ0MMt3AQG3Lc0HslamORoGegZM/GjFBGm/3I91ZGQz4Ca2xtwylJVw== 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; bh=AmCqsbY3AiU0YiEAlz93ibGj/lSsD0m2Srcg44MoTrQ=; b=DGeNgL+GvaMrAejBVfA3JjEvM0qvBExXxV/sKEbqLtfVb3DU0ZmjUPPdLHV5v8Eyx0ceAlPC1zMS425P+T7iNLImoTo/sOdMJrAc1FhlIW2jzHMzONEvr7k8l4o+Y/JtkNl5HkU6Tj83a5AsuffHmhknvgsZ4jNNLviDrYj2IGyA3KSKBUYWMsw/iAk3IYW054oe5mcJMRrgM2pgbr6QAeT18epbFGUBcMcgoTjcy6hJs08p7buFNhjQB9QWm9Ml8GNiWaoT23G+z2530hijgv1JeJhbKthS2LLEXCPdCJ798rG0ZkMac3gcoUop3HRg3JBNC0PJgDQd5ex+B4Rx9A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=silabs.com; dmarc=pass action=none header.from=silabs.com; dkim=pass header.d=silabs.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silabs.onmicrosoft.com; s=selector2-silabs-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AmCqsbY3AiU0YiEAlz93ibGj/lSsD0m2Srcg44MoTrQ=; b=ku//ZlRZxKs4XuISsZJ4p2zmv9jQbb4bal06NatszIIkS72TIWCDEAiWIm+WuC9xPDM11s5aaNCLHfxIcbaT5rGtEbUeKq8r0e8pMH3I7CwVxN6t0qC3eRPerdxrLEG4pMzQMJkvARx2VRW1GqZqYlH6PyCFKrhKaWV4+8NzodY= Authentication-Results: driverdev.osuosl.org; dkim=none (message not signed) header.d=none; driverdev.osuosl.org; dmarc=none action=none header.from=silabs.com; Received: from SN6PR11MB2718.namprd11.prod.outlook.com (52.135.97.18) by SN6PR11MB3263.namprd11.prod.outlook.com (52.135.109.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.18; Mon, 13 Sep 2021 08:31:11 +0000 Received: from SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::7050:a0a:415:2ccd]) by SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::7050:a0a:415:2ccd%7]) with mapi id 15.20.4500.017; Mon, 13 Sep 2021 08:31:11 +0000 From: Jerome Pouiller To: devel@driverdev.osuosl.org, linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Kalle Valo , "David S . Miller" , =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= Subject: [PATCH v2 04/33] staging: wfx: wait for SCAN_CMPL after a SCAN_STOP Date: Mon, 13 Sep 2021 10:30:16 +0200 Message-Id: <20210913083045.1881321-5-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913083045.1881321-1-Jerome.Pouiller@silabs.com> References: <20210913083045.1881321-1-Jerome.Pouiller@silabs.com> X-ClientProxiedBy: PAZP264CA0067.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:1fd::10) To SN6PR11MB2718.namprd11.prod.outlook.com (2603:10b6:805:63::18) MIME-Version: 1.0 Received: from pc-42.silabs.com (37.71.187.125) by PAZP264CA0067.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:1fd::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Mon, 13 Sep 2021 08:31:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6403d494-b881-479e-60bf-08d97690d740 X-MS-TrafficTypeDiagnostic: SN6PR11MB3263: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 92O4kdBxjrM8NJlZuzisnT07sgUh822Ue2Q3WWRmH9PYoYpRFDwbGFSttzUtrzbtU5Fro+ZLBbwVa4k7WU+PWKFwvw7RNp2eVcpeWNVtqvCumDJsjP47MP9QBDeFFoXpkRR8SDNjBDO+lYr12BA43BGeHi0Jq/vYfVUn0hQqvKrLi5+RDpABoMPboYSqMV5IRW6yGAPIqOuauMbfeSdwADnNe6K0OPNy7MSwYDavv1fDOajcOXDYrZmsDK6a9V9Y3lVk0otGcETIGIyE4lTGRuc9UsUJTzhKK5XRK1dAghcB6THQvX9lWOAOvPKoYHxlSd5HIZjo8Y5EX6a12kboaSQkIorVk/lI4WF31mzlLPwdDQOJyz6vVui5OXMvpgDCBwjX1Xq1nunp6lBEhQXWxpcjNNuSmSEKFeW6O0t57R40duruqqLeCNqz/IyP+lVLQ4QkpPEKWZ9JnJyCsJX4XKsbVJI6abZGbhrr5o287JM/VVZUVfj4w3O5vuiZQbKqzHiCB2Eyx9jKoKAicRRfxz1P0Za1dsODMunv6f1PZekszpfohMCZBlO7PJyZOpi/i2psneOdI4GZlly8RzJ6DRr0ObZKVdGjrO1JKJRKQptDnsKVYmm9VdBtKWlhCHp6cXOnB4dy+HSdUalHOPJbPEkW4gTz8GJQdrbnW9UpuuYQ4LkFkA2lK+t3mEyGdqcrnM4+RfzdxqslBvAUtrilBw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR11MB2718.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(83380400001)(66574015)(107886003)(956004)(2616005)(5660300002)(54906003)(38350700002)(4326008)(6666004)(316002)(38100700002)(66946007)(26005)(66476007)(66556008)(186003)(8676002)(36756003)(8936002)(86362001)(508600001)(52116002)(7696005)(6486002)(1076003)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?wGxKi6HORix5ZIsok8XyfDrR3?= =?utf-8?q?QDcQVgNrFEePGaUl41w+vjnu7J/wvlCoamVUKlwwq0InQDh9nSpmCOjL?= =?utf-8?q?U7ILaPUZPHZvAkBX/qB0w1ini72EdI1ql/mwy5g3SNojvRgtzdikBcHN?= =?utf-8?q?/xyiONeHT5Om2FSbXoJMTGBZTRngAMeqBfThyUUnW20GEiw4SrbSkWWe?= =?utf-8?q?H5pcHKdsu8M0MCQeNHyuKhAiKl+d8KnExgkpOky33ieqT1MelHnWkROd?= =?utf-8?q?cMhwAYCTZMMm40IdSiwY8ATW+iEQFTOPkq7vDAEE2mflLoHHbYBTQBKe?= =?utf-8?q?bP9djMD1qIDNtZOAOM+sUD8PAmFcwKl0qV4Tn8PU2Q9nJZk1lAKQnb1n?= =?utf-8?q?9NRw8NB8DRVz4A46pCOfbgKb7N0fuYlNjzyPuX4mqOzo+MFLpGBJDwzh?= =?utf-8?q?F0ZGPp8xi2LXz8O1NHjp2MT+IRXLwifl+Nbuq3OV+cazRceFVZyqh44m?= =?utf-8?q?K4PPWqrUOzpdeMjFaenYLvpq34Po2AZu6JAofM7drFiY7lKXKfTFoAOM?= =?utf-8?q?CU1cnLsp1j5wAXm3IWv0jDCoE8isSO+9gEhUspwwPKYPEQTzwfli81Tz?= =?utf-8?q?g/aVQgLBQ7GSDdQ65qbCwg3gisEbDQQtPCngkq/f4daVL5YNQ+CGt9Ym?= =?utf-8?q?ufkOFh5Gr/clK0rkgZAVV2O5wchuZhbrx0mdnTMBmFfwqqd9t/J9RMod?= =?utf-8?q?dvmUKNmVPsnxgtD96a8RMDQhSSlvRomk5oTRLi3yXBL1j9Jm8GZF0086?= =?utf-8?q?yT4WEz4uMZ+3dKHylDpXHKWe7+irjgIblLPv/HCMS6zVITEDzCmSYC6Y?= =?utf-8?q?icH11VzEa3ptT+HlOqfXUzSwU9HKdGGtPxN57pF5fnqmDR0mferb0i3P?= =?utf-8?q?OjA3Ct5+H75KAJ0WrnQhqy0gHUnAzdstZkmFUqzTQroWWurEKfDdLmoz?= =?utf-8?q?bW81iMpJ6RQ32mIYAlI++SBaW5wlLj+ofBBo0sVu/mOYZQJyv9QYIMoJ?= =?utf-8?q?WxkAqcwC1L4eXyO0JKctFt3euG1MyqNhfhwQPpV528BvqBt+FEuegYyT?= =?utf-8?q?JZ5Jm9SVtoxeQ0k6FJ/A5ZFalNJaDdpv1jWkRLY93eqNWrvvqltd0OYz?= =?utf-8?q?zz/smRsk9QGno6CR4xuO77P56Q37dao4OuW1SImjv1GThkKlTSWvqgS0?= =?utf-8?q?bhqabeUsnDYwq1KDzJ0+C0lWIHgyUEuPy8QZQsZjw031WbJB/kegGgyX?= =?utf-8?q?AmCXMP4724HOfeNt9M5cE7MU1a7qY/RfG8amOix7qL2kl/imAnkOJTAO?= =?utf-8?q?BQbwFfQKpkUl2Mm/Xwj0bQfHDuC3Jg8Hv72eW4tp6cquEx+CZZ6GRc4+?= =?utf-8?q?bMCwncgAZxqqX1SxsGRnddWZRriEwxo?= X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6403d494-b881-479e-60bf-08d97690d740 X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB2718.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2021 08:31:10.9783 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 54dbd822-5231-4b20-944d-6f4abcd541fb X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: zLTvTeDA0Doq3TGHojxKbM89HeZcvkHSq/doNDyfUEIGsf3a9nZrooGZOdAD6TBQJ2/9XNBD9gwF6e0Ld55Fpg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR11MB3263 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jérôme Pouiller When the device has finished a scan request, it send a scan complete ("SCAN_COMPL") indication. It is also possible to abort a scan request with a "SCAN_STOP" message. A SCAN_COMPL is also send in this case. The driver limits the delay to make a scan request. A timeout happens almost never but is theoretically possible. Currently, if it happens the driver does not wait for the SCAN_COMPL. Then, when the driver starts the next scan request, the device may return -EBUSY (scan requests often occur back-to-back). This patch give a chance to the device to send a SCAN_COMPL after a scan timeout. Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/scan.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/staging/wfx/scan.c b/drivers/staging/wfx/scan.c index fb47c7cddf2f..1e03b130049b 100644 --- a/drivers/staging/wfx/scan.c +++ b/drivers/staging/wfx/scan.c @@ -58,23 +58,31 @@ static int send_scan_req(struct wfx_vif *wvif, reinit_completion(&wvif->scan_complete); ret = hif_scan(wvif, req, start_idx, i - start_idx, &timeout); if (ret) { - wfx_tx_unlock(wvif->wdev); - return -EIO; + ret = -EIO; + goto err_scan_start; } ret = wait_for_completion_timeout(&wvif->scan_complete, timeout); - if (req->channels[start_idx]->max_power != wvif->vif->bss_conf.txpower) - hif_set_output_power(wvif, wvif->vif->bss_conf.txpower); - wfx_tx_unlock(wvif->wdev); if (!ret) { dev_notice(wvif->wdev->dev, "scan timeout\n"); hif_stop_scan(wvif); - return -ETIMEDOUT; + ret = wait_for_completion_timeout(&wvif->scan_complete, 1 * HZ); + if (!ret) + dev_err(wvif->wdev->dev, "scan didn't stop\n"); + ret = -ETIMEDOUT; + goto err_timeout; } if (wvif->scan_abort) { dev_notice(wvif->wdev->dev, "scan abort\n"); - return -ECONNABORTED; + ret = -ECONNABORTED; + goto err_timeout; } - return i - start_idx; + ret = i - start_idx; +err_timeout: + if (req->channels[start_idx]->max_power != wvif->vif->bss_conf.txpower) + hif_set_output_power(wvif, wvif->vif->bss_conf.txpower); +err_scan_start: + wfx_tx_unlock(wvif->wdev); + return ret; } /*