From patchwork Tue May 5 12:37:47 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: 215719 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 72FE8C47259 for ; Tue, 5 May 2020 12:39:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 43BE020735 for ; Tue, 5 May 2020 12:39:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="RAmZxdHS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728948AbgEEMjr (ORCPT ); Tue, 5 May 2020 08:39:47 -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 S1729066AbgEEMid (ORCPT ); Tue, 5 May 2020 08:38:33 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a2+NwKMuAgDgcU6ihmSbBANq/3XshjVH4UEqu3IteijXAeYM1dxpeNe65pT7ksYQ485WyNE+lmwlqI4GRNebfqTtAPI9oUzq/+wQz1rBgiif0qtZbinYe6cdPI9A6jquuOZg2XF0Z0QITGKTSCsYnBND3OUPkLk4CfdvXiRgrdpXXd6qfz8YIcBAKN9o1CGY/7vW2Y97Klr3h9BtrF9EEIuS2Aiz9kEljdtLwBuHtolr+6cdgP5dCdo4CoRdfIk8i6kOePAXHgyYldMwrsc0zAR3Z8HO/eH9hdEbPiSUX2JSPF++EcCoZtR4/vqdOTg1sxeuQfNyyUgXPFU0kYEv1g== 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=fqh9i9zscCRg6KNYtU+dKQ57CReCKoYmlR6a8QVmV+s=; b=BjMMSLSPIQv/feKdF8IGDGBqAZTQjkYSRRS46d+JiqPULrR66LalgtDvuz7iUnF95iAO6S3vkjgJRo9rmCfKl5UNTwRNhy9VoklwyzW+7XFwB/euTKYlUj0/YzrCugc2OHi7spN1R9SSX8b3Jt8Dn3KlVh4UTcwWQsdk2M/JDEuOS0S/DRIzcWCOe5VnmjhvQj5AkCqoPaqZIryeKGnnpYib/oalGQhqTIXJiBZ00EOPRMjF2T5xechvgWRKgyAtg/RXh1i+1fZgsMQ7mLN5IkKFt2zxenlJfJfV7hzLGoMEA0BtyJfm/JkqieFZcxRgmiJz8uNhExK13cSosNvpBQ== 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=fqh9i9zscCRg6KNYtU+dKQ57CReCKoYmlR6a8QVmV+s=; b=RAmZxdHSrXRm1QR+FLSidpj+0dtc26UJtUoq1avZBEwU5OKlRH98k3KCqEvAs0LrZsAXL5ougHJHmEsVIxwYjSwExdFUTQg379aB4uugqq9sWEuaXUMdcN1C87NgE0FCcaq3Kge5eYubd4fvVgsyAXMlptQ81TCWy7XBLCod2U8= 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:22 +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:22 +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 05/15] staging: wfx: repair external IRQ for SDIO Date: Tue, 5 May 2020 14:37:47 +0200 Message-Id: <20200505123757.39506-6-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:20 +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: 6ce4bd42-1d5f-4e1e-2d7b-08d7f0f1328d X-MS-TrafficTypeDiagnostic: MWHPR11MB1824: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3383; X-Forefront-PRVS: 0394259C80 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tIKwI4+8dQG/RjhU/WGaiTMgdknsfezdW0QlKHvKwFCxJGlMpedBE6mW8H/WpjfRO+kFcITR4FZgIrzksKWkYOtSykJzABy6cARt2TFHjrX/My6xfQHqK+/7io7k0qCongr1h52a4k2WeFXu1HC+E49kidjtKdHgiq0PeynqBYk75H5K33IFy6OqMer5aiakPHEJF0Tf534whoairwZz7ObarXsbpHDNjoNKD6QjkjaYC/o7DbTnQ43X2NiXJ+vWPBjs834bplKKO8ibwRDfDVBmAbVTluAt8S0B9aRWQqEqm6QAWnknBLNDYCPIIIBf5V4Cwe9CbUlgTrayqYdGMIqOgLIHEdb0YR5hp/6FSoZyK5MovWpc7YH12vphClyPMY2rUNJIlcD9Y9AfOE7vjru409O0n7lvKAkaPGoICgvWnRwzodW9SH5bZo/87mbpijkOiMoFRxL2+fHFKVli4gtSegxdzv4zL3pcwA8g3qUEIWRnxjMJLXHFKRJjxF6QTQpvbtLZalkYV4IIucoCXQ== 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); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 5XZVLeb4HQ28JcvB2MEwFK+/jsULNfsch3q999yW+PvWvqoJ1RlK1pP9xZEig8atieo9YUunnOzGyNhvjOj5PHBjONPeij2sLXeE3RM9UaNDQXhvu9VzVOthwnGz+CeB3hLJyAchzxdSapK2rdnYvhXheM7bqZchU95DTqNjXaLknVlEor2wn7DL+2zt8j768zTuu5+dBxJOr+VTUrCZGZSICIpWtyxrlKLN2CY8WhONG7uZJI8QAeHLZsYkTkt6MABeroAigabaufDiAINemQ+7dZqAyRiNxR4pm0OlIWnG3bspAqbqQYkX4XHDnQIG0Q5yVVis4PIUelO/cgKdWq+JisqCCK9G6vf+fb6X4aUYPWxm3tyRct1ivvQaONZC2AR9UTWlZTMEsNE50XSoKxZ7fiaewfts3FKBTQ/oI83fRFDHGJzZ+R8xM9fZR8GU7v74xiX5id1DDXFp0ETLkXhY9pVTMCjXQEKWO7sFi1yKbC9ptG1DfQQ/FnZmMDRU7HQOWdM6Aq26WVFo6QfiSykHWmsykic9zca7V7w1Rx1Dn3pn+nsuDN0yIltm4dPdt5ucko0yLOZQ3+NtJmj7Q+7TYZdXTAHdmN4TLV/m2PduxZ8M+VgcRp4OfaDuzBNxGG/eRVndHmI0XDwdnORdNXi1g0YZQ96IJxEsLSw+ROp/0pApUORo+brlnmgPU0H9ak6z7g+5dFtgZmqyO0csExQOAUh1pl601A0mJ/Dqni9tA8pF/kswydO76361jWf3g5h4A0ZNq9je361VPSo+7TY5h4Y4j7kdvVCC7Id3TvTp0yvwD1etQo18JtzCuQPvAy/0OCiz7KT20Tbnhwpy11Dl8bSl/wDg8Tmb06dFOf4= X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6ce4bd42-1d5f-4e1e-2d7b-08d7f0f1328d X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2020 12:38:22.4591 (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: CkIEvWg8SDHZlHkx5YOspGtSd/9L2LmgpVsfE6rFWbnuSZpMXNM0vWndLAVWdKn8BxDIyJwxVC5SZNhH6ch/TA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1824 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Jérôme Pouiller When used over SDIO bus, device is able to use an external line to signal IRQs (also called Out-Of-Band IRQ). The current code have several problems: 1. The ISR cannot directly acknowledge IRQ since access to the bus is not atomic. This patch use a threaded IRQ to solve that issue. 2. On certain platforms, it is necessary to keep SDIO interruption enabled (with register SDIO_CCCR_IENx) (this part has inspired from the brcmfmac driver). Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/bus_sdio.c | 38 ++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/drivers/staging/wfx/bus_sdio.c b/drivers/staging/wfx/bus_sdio.c index 9ac87178270f..2f782120e438 100644 --- a/drivers/staging/wfx/bus_sdio.c +++ b/drivers/staging/wfx/bus_sdio.c @@ -6,10 +6,12 @@ * Copyright (c) 2010, ST-Ericsson */ #include +#include #include #include #include #include +#include #include "bus.h" #include "wfx.h" @@ -106,31 +108,41 @@ static irqreturn_t wfx_sdio_irq_handler_ext(int irq, void *priv) static int wfx_sdio_irq_subscribe(struct wfx_sdio_priv *bus) { + u32 flags; int ret; + u8 cccr; - if (bus->of_irq) { - ret = request_irq(bus->of_irq, wfx_sdio_irq_handler_ext, - IRQF_TRIGGER_RISING, "wfx", bus); - } else { + if (!bus->of_irq) { sdio_claim_host(bus->func); ret = sdio_claim_irq(bus->func, wfx_sdio_irq_handler); sdio_release_host(bus->func); + return ret; } - return ret; + + sdio_claim_host(bus->func); + cccr = sdio_f0_readb(bus->func, SDIO_CCCR_IENx, NULL); + cccr |= BIT(0); + cccr |= BIT(bus->func->num); + sdio_f0_writeb(bus->func, cccr, SDIO_CCCR_IENx, NULL); + sdio_release_host(bus->func); + flags = irq_get_trigger_type(bus->of_irq); + if (!flags) + flags = IRQF_TRIGGER_HIGH; + flags |= IRQF_ONESHOT; + return devm_request_threaded_irq(&bus->func->dev, bus->of_irq, NULL, + wfx_sdio_irq_handler_ext, flags, + "wfx", bus); } static int wfx_sdio_irq_unsubscribe(struct wfx_sdio_priv *bus) { int ret; - if (bus->of_irq) { - free_irq(bus->of_irq, bus); - ret = 0; - } else { - sdio_claim_host(bus->func); - ret = sdio_release_irq(bus->func); - sdio_release_host(bus->func); - } + if (bus->of_irq) + devm_free_irq(&bus->func->dev, bus->of_irq, bus); + sdio_claim_host(bus->func); + ret = sdio_release_irq(bus->func); + sdio_release_host(bus->func); return ret; }