From patchwork Mon Sep 13 13:01:35 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: 12488947 X-Patchwork-Delegate: johannes@sipsolutions.net 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=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 E7239C433F5 for ; Mon, 13 Sep 2021 13:02:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D1D0260F9F for ; Mon, 13 Sep 2021 13:02:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238325AbhIMNDs (ORCPT ); Mon, 13 Sep 2021 09:03:48 -0400 Received: from mail-bn8nam08on2055.outbound.protection.outlook.com ([40.107.100.55]:54369 "EHLO NAM04-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238235AbhIMNDn (ORCPT ); Mon, 13 Sep 2021 09:03:43 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IDhIJaAIz3IGiTO0VYKvWmyMbwwYVeVkMKSsr1ReCN82B3STwjTcm8+iMdIIE02ua8ItpZA39pUsOuWZFQQBOBlr7KolO/uv+2uVi5/R6QT6tnRU9bT8gW67yvSGfCBVHER3l7W+wEUkiThfodghqbUtJB8zgvqsh3vHUVpPX9/rQZtTRJt70h+AeuGhDezTVknPDXkpeY+5q6EfFWAFKpyJnMcc6bitWZ88T0C34HcvYvOdB/l1X/eV7uyfgqZ3WVTPC/EL+GhOZcEZlsp5LEB9xahv8ixaC6gZLpAM/6wJqZZEz7rDnxLlkvYU+l8yRxR9tnG83ZlpHAc+s6M32Q== 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=f3e9bzoPIadgok4mVpDF/az+bY5QV6M16yGGzSp/zkDZYViPfkgNGrM23kGZvXX0PdGi0HTEIeOUMS4Rn++IS9+DARvS9Fp6WSrosYU0aeU3OqvX+bz9ewK7TWh76XoBZsQDJlMupCmGmPVfIolNvDXiwzDJrd84IKBYX1pKJxdZAOCZhlU2WbyMav58IVqDmMpw6xREDulRcqg2CbNigld8x4DE1MJLhr3Drchowd6Cv1n9ID2YUfM6xb4/Y1cPw7H8WlAE7+qvKOvq7ClG6a3xP7Lb3SvmhsztAP+L/jh2lxWz8/8G8wop3gjElwxGCdsU0MDlv1xujKY2zjVcSw== 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=QDZ4fxs/MuJv5JFpZb85RwN5+Ux9YSHrCDnCaxNGYBH+AzNjPOd6kn2gpASqUy4tJ+cSZy30bOnTwInvjFn+XrsyD1ibe8a5KbA0rsldIcdXUoVitv3XHOO9pMUGWhAjewacN4GpcbyhMiqSQsxZuPEb1epZ66TqYdZo1tlElLQ= 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 (2603:10b6:805:63::18) by SA2PR11MB4860.namprd11.prod.outlook.com (2603:10b6:806:11b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14; Mon, 13 Sep 2021 13:02:24 +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 13:02:24 +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 v3 04/32] staging: wfx: wait for SCAN_CMPL after a SCAN_STOP Date: Mon, 13 Sep 2021 15:01:35 +0200 Message-Id: <20210913130203.1903622-5-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913130203.1903622-1-Jerome.Pouiller@silabs.com> References: <20210913130203.1903622-1-Jerome.Pouiller@silabs.com> X-ClientProxiedBy: PR2P264CA0021.FRAP264.PROD.OUTLOOK.COM (2603:10a6:101::33) 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 PR2P264CA0021.FRAP264.PROD.OUTLOOK.COM (2603:10a6:101::33) 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 13:02:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 16814723-fed5-469b-b454-08d976b6baea X-MS-TrafficTypeDiagnostic: SA2PR11MB4860: 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: ggVBmqoy/QHjgqy8zapkjjJnamggkUS3drCd7NnNKe8p/OfBI97LUvJgawpof4hmVqHw3dOwjMSM8T9JfRKBkjG2cWrwvNcKkDvZQv4O6yM0OXEr6Z3KdZeXWqJw8jEK+ta4hp8npQSo4LwMnwfbv9vZEdMNXYo8Ov8pjX6k1T2LvwzHelJ1pa/PY9I8gD3O/gzXmSLssRWXN2shxstiXA6mk8bB3mMbBBkSQbDzOQY9hzb8GcElgIIekOoRPT7Jb1/R0PEaw3oa8cX1FFy1FvKZyGlaiRP0O70tjCYdySfeWXHTIyUuZU+RfNX3eL1ZuDTfur796gXXQwYTg3OvMpFwfmNpoN5CsTs1ogxjWL05fRW33li+Qz2m10286LZTgYOd16m3gwweG7PyXakkpxPWlhyXbmfaDIP/gZLRnu6RjLkDVzcKZStitl1o0AKkJXv4ngZGLAcvteCpKS+CQAyyodPTb15ZzX3+QGMnk0WRGlUVru4Zmw5iKAw0eYdtZFESZyjaIJlKxSVyq0GKKwYG3no5GKoWY61U/KhkN3ERspsaQuaK059FOdv8zfMsCmJQ/GO5mp8tIS1YyeQ+PEzjScZCFDQCWp9q/T55sKMW071MJvZmxFE81z90E6TBP21ug0l/DlajKEV4oq4DF/gPJZ9oBlrKOiqxpvIdW3yFofJ0JxFopKnciEyPXv26zXAFP93SB5JcFuvyUS4WRw== 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)(956004)(66574015)(6666004)(66946007)(2616005)(26005)(36756003)(38100700002)(38350700002)(316002)(4326008)(107886003)(7696005)(54906003)(5660300002)(52116002)(66556008)(1076003)(66476007)(6486002)(508600001)(8936002)(83380400001)(86362001)(2906002)(8676002)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?yn+4b/sRe6d+p282UsSOT/BLWGEp?= =?utf-8?q?LnXyuXQXCyXX1YjHtQdrpIOpDpGz0iDt3P+51EdZU7jBNMwHJyasbl4kPLVjHYxTa?= =?utf-8?q?TpNNbUjHbqWuRGmE1l3LL875AhXrgPfDsVLU73vXRHNnRl4pc8B6/dCkFAdUHkWKa?= =?utf-8?q?nWsgP43hJUjjStgNpYR64oErJ3KmMvpaYboNP3PHe4PkKqrJbCVpJSG003QmMcP+e?= =?utf-8?q?gGiz2+5G1MLy2Cia6xZnu9SVcZG4ZxxN+Z9vl+SMOVhbvQw51g1aVjoDOjuGaOW6n?= =?utf-8?q?RYsXhnS72wQ7ArR2UE6c2a/4/yb6kLPJPLq5HOXCRDPvs8vk3ADfse+4g5+8nkpJK?= =?utf-8?q?KXDsJyzhWbFhyLsE76ip51iOX1JmLXRMnI9SN29Gkiz3G9SAJKOPIV5+QJAmZApSZ?= =?utf-8?q?PR/Fbe6DrLqQClYIeUx+4lVn2XQKtN/Yq55cnNiHmpZiMuJM5aHdMilHOPxIjzyjT?= =?utf-8?q?8lr7U2+xeruWq50i8qqAyscrgxzE91hx30uA+xpiEo0m2YilOZgsq/ibOxB8K6rKy?= =?utf-8?q?UuTI/8PHTc0RLO1Ey1ZThAEVvPf3KQZ97iUDqP62lJHYvQi7U9uzk8QzZjVpdD6wP?= =?utf-8?q?gK9ZgcdsPn77p/MUwwQhit0u2ULFJu76G0At/ZQmJBo5kjdShmYk8VPrNE7+hyc5p?= =?utf-8?q?M0qxiiHxRxTTE5CQVZQX6hpcFJDlAh0vwiTleUHSMVFp+n80s+Pd1TfyKLhzsB1ib?= =?utf-8?q?gzLzKsfDYZKdDlTcKOdXfScBhmoHcDlU1ZVbK5qV86XeUG0RdDbNor6+kraudXO4W?= =?utf-8?q?+5uPlI27C4UJWFOlofJP8+rKEiKwd7R4lGq6bCrX+4pGoJv1M6aW7YoazdECMmyoY?= =?utf-8?q?q9UB1JI3c+11wdQHqIArS4chsazcxT4synE1Wh2gKr/FMKbWGCN6abBfRV0Oe8Qu1?= =?utf-8?q?Zo4JJ4K36QeGRgxRJ9v/a0rzkmQJro0pRB/HMk3kU6if2w8wlZb5B7wkJWJMsrYqi?= =?utf-8?q?rlUUiJrl6U95gbBK8g9S3NlmLP7sx/27WFiLmx0GQNpI1C4N01tq1iLrdFdSvLktm?= =?utf-8?q?E7WK7jsSHpuOJ1H9Bk3e1kOZhR7fQmHAz7DyZXNQdvIsp/rbWAPVLud6RTANJYCEA?= =?utf-8?q?HpOfV8dtdCWMYni4Z/IfP9y0nG4PFkA+6axDvAJt+zL6lKNhGNIhFF0htdJmqPkRr?= =?utf-8?q?CRZ/scY6Mk0ZrcC8clGtpw1D58YkEjHIb61xqDiuEiTSGvwM5fzGmRes+pRCD035q?= =?utf-8?q?PInT59FgUCrZzmouPJ4hQUuThmNNmJ61DzRS4w/lf7ZQHQeyeJmmujTpPyzlfs3dz?= =?utf-8?q?kyjLHYqa3ZGDXXG0?= X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 16814723-fed5-469b-b454-08d976b6baea X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB2718.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2021 13:02:24.3913 (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: zQCI526Z+IOh216yzLQ73aRLCl6SeJnOJFz8UmRmwmWplI2/xTgesOQg7MF0j2/gMAdKpALmxAP05KCL2ATxPg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR11MB4860 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@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; } /*