From patchwork Tue May 5 12:37:49 2020 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: 219882 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.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, 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=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 D754CC47254 for ; Tue, 5 May 2020 12:39:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A999920735 for ; Tue, 5 May 2020 12:39:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="ihT53FlW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729093AbgEEMjc (ORCPT ); Tue, 5 May 2020 08:39:32 -0400 Received: from mail-eopbgr680041.outbound.protection.outlook.com ([40.107.68.41]:21169 "EHLO NAM04-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729090AbgEEMik (ORCPT ); Tue, 5 May 2020 08:38:40 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SFnx+zMn+SGrfv8KLoswdNk2jkwF2sz8hogbxtRvfdKoR3b1TkLkyzFizeZoF2fqNGya1UbYHgQkIyiWMvodPGUydBemqDR0eRogDn3+Isj45pBICbkPVTOzBOaZRpTwnVG27JK3y3gEyyy6gqL7EEB5l7fJ8JSWcTOPOYvpDF3wWtcsmkF30uhoN7Aik1J7XlYhjKRwDLWWkbcBIMmUtt8ay0YlDBvHKitg7yXBuNL5lqzBVoQwfu/GxbryTmFDOO2dWpzNY4czfxApAfVMyDFVoXr4jzFQCrV6DIPaSc4YlrTd4R3Rkpz/xAMnkPWEteCx0/9ui3cx4kvpdOWkhg== 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=EcUyPk9HZS90+PsFFElskjoPjhRG9AXCGuuvtKpa0IQ=; b=B0C3rXTKnUcu1V3yVT5fpQO195zjvQyT/9fVXTw7XvdspHR+t4NhvtN4Ut3zzD3hgVU9Udsox1ZOcLxPlCtz8VhZA3aOWeZfPnNzHTAa3nWOOCQSVyD9F0rwLurSadSmEQcchvTPnDbaUSXgCP3Pc/zjxHbfpcGPDjj8zJSjvRlGsvVwCvPdR9L0guNnDHE+7QJX3KF9cuyB/+Ht5cdNNO2zsVEwQkSivP0PrQSfiZh5DyA7B1svbLYd6akXBEWTd3HzqNVwuYTxdBiRH7f9BAe0LIDjXVW60kAE1FvTY/O8iDkEjqjGr/0yxtTSusL3QqEgb3t0tJQkGcGb4iXABg== 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=EcUyPk9HZS90+PsFFElskjoPjhRG9AXCGuuvtKpa0IQ=; b=ihT53FlWnxFNCiI+W3+fRQnU2YKM6tkk7mBTb7a06HIy7TkNfoRmusIf16b2sWn76nPVG1174NLH5iCHKSwOBaKQJNPritcAPHE/Nfw9oSm1l79WNo0waEOK0cY8O+5HzzuwhMVRQTDcPz+bfit0XJKJAabx8gpW2GbtS7TiE4Y= 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 MWHPR11MB1775.namprd11.prod.outlook.com (2603:10b6:300:10e::14) by MWHPR11MB1824.namprd11.prod.outlook.com (2603:10b6:300:110::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.19; Tue, 5 May 2020 12:38:27 +0000 Received: from MWHPR11MB1775.namprd11.prod.outlook.com ([fe80::81d5:b62b:3770:ffbe]) by MWHPR11MB1775.namprd11.prod.outlook.com ([fe80::81d5:b62b:3770:ffbe%10]) with mapi id 15.20.2958.030; Tue, 5 May 2020 12:38:26 +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 07/15] staging: wfx: introduce a way to poll IRQ Date: Tue, 5 May 2020 14:37:49 +0200 Message-Id: <20200505123757.39506-8-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200505123757.39506-1-Jerome.Pouiller@silabs.com> References: <20200505123757.39506-1-Jerome.Pouiller@silabs.com> X-ClientProxiedBy: PR3P189CA0022.EURP189.PROD.OUTLOOK.COM (2603:10a6:102:52::27) To MWHPR11MB1775.namprd11.prod.outlook.com (2603:10b6:300:10e::14) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc-42.home (2a01:e35:2435:66a0:1265:30ff:fefd:6e7f) by PR3P189CA0022.EURP189.PROD.OUTLOOK.COM (2603:10a6:102:52::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.20 via Frontend Transport; Tue, 5 May 2020 12:38:24 +0000 X-Mailer: git-send-email 2.26.1 X-Originating-IP: [2a01:e35:2435:66a0:1265:30ff:fefd:6e7f] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9fe488cf-928d-4865-c3cc-08d7f0f1350d X-MS-TrafficTypeDiagnostic: MWHPR11MB1824: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-Forefront-PRVS: 0394259C80 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uwy6JxzVHlUPwRXcN0Q21anwH7G3IAIT7nNlFtWEYAaYMam1UxFY4flaD4UGMlMOnwS9ASDeDbkqVB4M12Ls6URu+I2pVc9NWptIvzbFQpap0U7bo07debwYc4EvGhjykmPsowKfEWu7iPuDhF4PoJ6lM9qRnU+Q9EewZnsaZJyUckAYHZHrpYLdSglUi4z9D7u8G6jl5qMABJ2KNCzsWW4On70DNJXSiGn/ZEK4cHOiEatKOpmlXpuCz+w5SOvQqmVy0r/c4ghTArsfHmHlrp0vCKoN4SjxzeaJtgRNHNzmpy5ImOiio6g0EpOrp4K8loJR23XoM7R7k1xZGaO9avPwRh7x5IG65sHfUqFoL6FzUst+hiudl95GUGkMLDcA+NmC8BhzOMKbRpmCGcFjvSzukeyyGVGUvLeJCR62bmYf+yHh//v/we02ob+RlgZ40yv83aftZ0BsKKeBSXE80DzIPhccBwDq8J6L8PT0YS6V8AAjOgR2ysKlGpCKmJ2IIIZSSc7B4cbj63TVDscFdNyovqFETnphsYVXqDRKdF1kiU+WmiQIQbCUQNC5q2PI X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR11MB1775.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(136003)(396003)(39850400004)(366004)(376002)(346002)(33430700001)(86362001)(6666004)(107886003)(8886007)(1076003)(6512007)(6486002)(66574012)(36756003)(5660300002)(2906002)(66476007)(6506007)(16526019)(186003)(52116002)(66946007)(66556008)(54906003)(2616005)(4326008)(8936002)(8676002)(316002)(33440700001)(478600001)(43043002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: mxtROYWbXqQ0ZOPPXaz/1Irp5fqRWD92XRfdZBlYq+WEN+c9pMkZy7B9QSHgGbqxxXpu6i2zupA45Ovx9DRhl/FIKVeSOGV2fYvHypqtyiUi6B2W/mUdDyJxA3uadV3ey1VchVCNYet3zXMCMtwBI5jeKz6ItS3KebnyP17r9gh+Okq8xv6avk3aON394PEvv7clx11DrD9374znAKd18ESrFesE85PwNHdF0+1SD1g1cxN2M4DdRBTS+/dyTyBqQhLCf9sAQ88x3Q6KhRIj3fqYoykpPnbxLBEmUEBbj2VR65OzgF8hNoMOhOypqW0AJAKf95ne4WwVovc6LgyBcrubXEBeeJVkVi9AE2lVyY9Z1SX0q3UvheECxnrDcFa7BquvVRuvB7Od0p4hVo78QRQoOtncIaoaeb7iAYq0eWYuJwsCJSsG0A2rAaRAIUP8uPeBkecROfuR8ft2V+QpAEHD79e1TG3V8AtPN+FCikIhwvni+SJw4GfIA2k9GVQHyxE6U8szEes4gI2FRnzJ3fZl2JLecEk79x2m7DoXh0tswj3cZ8tIKbvK0lB6zbsHnH7KIYhhIXJOQzZTLiWroNhcLY4k+ZEM3wbNGieksN1rUl16BF8N73O1wrAmbCCRa2DXgQzuHH+0jXyEZfTwvZ4jQNKkeIxP34ZKvQCRpKxiyBxIBLH1XWcvlHZ1K/fnUU/5IQo63pjdKWNE0BqqvwQP7DVKWOEd0iEoxK2WCl8OvodfUNlo2I++8VR0ODrrqseJLhpaX2w1efwuhRLsXAywsWCgQfyZacNCxbDNqjRQg4yz6sD3wCCZ4ABK+ncA6/PXQW25CC6457rv0yQcvdeHIiqexu/esckTc+Qx0Ec= X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9fe488cf-928d-4865-c3cc-08d7f0f1350d X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2020 12:38:26.8151 (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: jNtWZfCnAtlpm+fuKb4nj/N/wNN95vNtRMjd+utct2mZygeA7+4lg4ViwbgpOR4V2p8qheel0yR4LadbAGduug== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1824 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jérôme Pouiller It is possible to check if an IRQ is ending by polling the control register. This function must used with care: if an IRQ fires while the host reads control register, the IRQ can be lost. However, it could be useful in some cases. Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/bh.c | 28 ++++++++++++++++++++++++++++ drivers/staging/wfx/bh.h | 1 + 2 files changed, 29 insertions(+) diff --git a/drivers/staging/wfx/bh.c b/drivers/staging/wfx/bh.c index ba7fa0a7cd9a..d3e7eed89c38 100644 --- a/drivers/staging/wfx/bh.c +++ b/drivers/staging/wfx/bh.c @@ -307,6 +307,34 @@ void wfx_bh_request_tx(struct wfx_dev *wdev) queue_work(system_highpri_wq, &wdev->hif.bh); } +/* + * If IRQ is not available, this function allow to manually poll the control + * register and simulate an IRQ ahen an event happened. + * + * Note that the device has a bug: If an IRQ raise while host read control + * register, the IRQ is lost. So, use this function carefully (only duing + * device initialisation). + */ +void wfx_bh_poll_irq(struct wfx_dev *wdev) +{ + ktime_t now, start; + u32 reg; + + start = ktime_get(); + for (;;) { + control_reg_read(wdev, ®); + now = ktime_get(); + if (reg & 0xFFF) + break; + if (ktime_after(now, ktime_add_ms(start, 1000))) { + dev_err(wdev->dev, "time out while polling control register\n"); + return; + } + udelay(200); + } + wfx_bh_request_rx(wdev); +} + void wfx_bh_register(struct wfx_dev *wdev) { INIT_WORK(&wdev->hif.bh, bh_work); diff --git a/drivers/staging/wfx/bh.h b/drivers/staging/wfx/bh.h index 93ca98424e0b..4b73437869e1 100644 --- a/drivers/staging/wfx/bh.h +++ b/drivers/staging/wfx/bh.h @@ -28,5 +28,6 @@ void wfx_bh_register(struct wfx_dev *wdev); void wfx_bh_unregister(struct wfx_dev *wdev); void wfx_bh_request_rx(struct wfx_dev *wdev); void wfx_bh_request_tx(struct wfx_dev *wdev); +void wfx_bh_poll_irq(struct wfx_dev *wdev); #endif /* WFX_BH_H */