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: 510306 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 8B282C4332F for ; Mon, 13 Sep 2021 13:02:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6F3F860E8B for ; Mon, 13 Sep 2021 13:02:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238671AbhIMNDw (ORCPT ); Mon, 13 Sep 2021 09:03:52 -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/BLW?= =?utf-8?q?GEpLnXyuXQXCyXX1YjHtQdrpIOpDpGz0iDt3P+51EdZU7jBNMwHJyasb?= =?utf-8?q?l4kPLVjHYxTaTpNNbUjHbqWuRGmE1l3LL875AhXrgPfDsVLU73vXRHNn?= =?utf-8?q?Rl4pc8B6/dCkFAdUHkWKanWsgP43hJUjjStgNpYR64oErJ3KmMvpaYbo?= =?utf-8?q?NP3PHe4PkKqrJbCVpJSG003QmMcP+egGiz2+5G1MLy2Cia6xZnu9SVcZ?= =?utf-8?q?G4ZxxN+Z9vl+SMOVhbvQw51g1aVjoDOjuGaOW6nRYsXhnS72wQ7ArR2U?= =?utf-8?q?E6c2a/4/yb6kLPJPLq5HOXCRDPvs8vk3ADfse+4g5+8nkpJKKXDsJyzh?= =?utf-8?q?WbFhyLsE76ip51iOX1JmLXRMnI9SN29Gkiz3G9SAJKOPIV5+QJAmZApS?= =?utf-8?q?ZPR/Fbe6DrLqQClYIeUx+4lVn2XQKtN/Yq55cnNiHmpZiMuJM5aHdMil?= =?utf-8?q?HOPxIjzyjT8lr7U2+xeruWq50i8qqAyscrgxzE91hx30uA+xpiEo0m2Y?= =?utf-8?q?ilOZgsq/ibOxB8K6rKyUuTI/8PHTc0RLO1Ey1ZThAEVvPf3KQZ97iUDq?= =?utf-8?q?P62lJHYvQi7U9uzk8QzZjVpdD6wPgK9ZgcdsPn77p/MUwwQhit0u2ULF?= =?utf-8?q?Ju76G0At/ZQmJBo5kjdShmYk8VPrNE7+hyc5pM0qxiiHxRxTTE5CQVZQ?= =?utf-8?q?X6hpcFJDlAh0vwiTleUHSMVFp+n80s+Pd1TfyKLhzsB1ibgzLzKsfDYZ?= =?utf-8?q?KdDlTcKOdXfScBhmoHcDlU1ZVbK5qV86XeUG0RdDbNor6+kraudXO4W+?= =?utf-8?q?5uPlI27C4UJWFOlofJP8+rKEiKwd7R4lGq6bCrX+4pGoJv1M6aW7Yoaz?= =?utf-8?q?dECMmyoYq9UB1JI3c+11wdQHqIArS4chsazcxT4synE1Wh2gKr/FMKbW?= =?utf-8?q?GCN6abBfRV0Oe8Qu1Zo4JJ4K36QeGRgxRJ9v/a0rzkmQJro0pRB/HMk3?= =?utf-8?q?kU6if2w8wlZb5B7wkJWJMsrYqirlUUiJrl6U95gbBK8g9S3NlmLP7sx/?= =?utf-8?q?27WFiLmx0GQNpI1C4N01tq1iLrdFdSvLktmE7WK7jsSHpuOJ1H9Bk3e1?= =?utf-8?q?kOZhR7fQmHAz7DyZXNQdvIsp/rbWAPVLud6RTANJYCEAHpOfV8dtdCWM?= =?utf-8?q?Yni4Z/IfP9y0nG4PFkA+6axDvAJt+zL6lKNhGNIhFF0htdJmqPkRrCRZ?= =?utf-8?q?/scY6Mk0ZrcC8clGtpw1D58YkEjHIb61xqDiuEiTSGvwM5fzGmRes+pR?= =?utf-8?q?CD035qPInT59FgUCrZzmouPJ4hQUuThmNNmJ61DzRS4w/lf7ZQHQeyeJ?= =?utf-8?q?mmujTpPyzlfs3dzkyjLHYqa3ZGDXXG0?= 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: 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; } /*