From patchwork Mon Feb 5 15:05:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Matyukevich X-Patchwork-Id: 10200623 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2172260247 for ; Mon, 5 Feb 2018 15:05:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F7C82000A for ; Mon, 5 Feb 2018 15:05:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 03518285F5; Mon, 5 Feb 2018 15:05:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8399F2000A for ; Mon, 5 Feb 2018 15:05:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753194AbeBEPFo (ORCPT ); Mon, 5 Feb 2018 10:05:44 -0500 Received: from mail-sn1nam02on0069.outbound.protection.outlook.com ([104.47.36.69]:44244 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752933AbeBEPFk (ORCPT ); Mon, 5 Feb 2018 10:05:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quantenna.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=fpi+c6zxieMgaXHQWM749UhPyxgWpJ0/IgQXOIFPW8Q=; b=0Uw1hgm0bUS43CDTabJUR0nLUYKfByq3h1c9gEmBa4+TYEgWkAUIPwAg6+DiN+BSnRO74etA1Kgwf13yr1XW0rk4S0KqgwY/IvbvDSVqVGfpwJy4HIF0QcOMViBXf1Ni5HDsxmecI2OeUuAbZkpKrXnrkjqzMYz1+7i3DLy2sT8= Received: from bars.quantenna.com (195.182.157.78) by CY1PR05MB1929.namprd05.prod.outlook.com (10.162.216.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.485.3; Mon, 5 Feb 2018 15:05:33 +0000 From: Sergey Matyukevich To: linux-wireless@vger.kernel.org Cc: Igor Mitsyanko , Avinash Patil , Sergei Maksimenko , Sergey Matyukevich Subject: [PATCH 2/6] qtnfmac: enable reloading of qtnfmac kernel modules Date: Mon, 5 Feb 2018 18:05:12 +0300 Message-Id: <20180205150516.16030-3-sergey.matyukevich.os@quantenna.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180205150516.16030-1-sergey.matyukevich.os@quantenna.com> References: <20180205150516.16030-1-sergey.matyukevich.os@quantenna.com> MIME-Version: 1.0 X-Originating-IP: [195.182.157.78] X-ClientProxiedBy: AM5PR04CA0009.eurprd04.prod.outlook.com (10.167.167.150) To CY1PR05MB1929.namprd05.prod.outlook.com (10.162.216.11) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7c863538-60cc-42c0-66d7-08d56ca9e84a X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:CY1PR05MB1929; X-Microsoft-Exchange-Diagnostics: 1; CY1PR05MB1929; 3:tWOFr22Kl07GWxy2xo/p+Iv4ToW35oatbJVUMk1xIp11TH8dVzvblHlwrFYFNr7+YLHa2Bx/J8RGHVC3Gsvu9hUsOY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YHE6/HpppLZ87XZ5jjcBIHdHCFfHUU9kkN8y6fhLdIAdqX3Gq2M3UjP3XRL3raTmHvc0I7iWbZfURXsHkzCOxAWcOyWjvZghh2kZrW7ftm5jYdxyWIRLlPieiXHWVZ8eOHnWANrrmVafZhJi90ofUbQ5UjpadZZ0q2jASqu8htDro/hmPQDIax2kgrI1YkaN5YG7o9sUsKETM7wcMtQCSJTZzlKzk2HPpjkpy59+VsDm0uLKJptmT9b9Jl2; 4:+JXxMSBdcDtqxKPSQOJTQsiKKb+Ri4lAqw0MhKdFd81WmnQObLwpdsntdgqDEhqq3a5ml3Y1nBuhvpyAJw6pXWu+LvAd7zbrl6MhNNuulfG3zJJgY0A4al2sNqSjE420tdCmXSvP4lfW3S2l6BJzp6oD6Z0qtiWL/TzOrh9VRIpAo+YqbeSKDGgv2eWODU0uCtBJvWljldZghqhoiSgcoB0VeS3fdRUNEgSHyOMLDHv5YUDbkOgmAvKjdAAX9ofC1W6zCAqA5WGu6CVRTWyFcw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(5005006)(8121501046)(3231101)(2400082)(944501161)(10201501046)(93006095)(93001095)(3002001)(6041288)(20161123564045)(20161123562045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:CY1PR05MB1929; BCL:0; PCL:0; RULEID:; SRVR:CY1PR05MB1929; X-Forefront-PRVS: 0574D4712B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(346002)(39840400004)(376002)(39380400002)(366004)(199004)(189003)(52116002)(51416003)(7696005)(69596002)(48376002)(6486002)(50466002)(3846002)(105586002)(53936002)(4326008)(6116002)(2906002)(86362001)(81156014)(81166006)(25786009)(107886003)(47776003)(5660300001)(26005)(54906003)(59450400001)(6666003)(8676002)(53416004)(2351001)(16526019)(8936002)(386003)(6346003)(66066001)(103116003)(36756003)(68736007)(186003)(106356001)(7736002)(2361001)(76176011)(1076002)(6916009)(305945005)(2950100002)(16586007)(97736004)(316002)(478600001)(50226002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR05MB1929; H:bars.quantenna.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: quantenna.com does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=sergey.matyukevich.os@quantenna.com; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR05MB1929; 23:YbCoQ6rdYEnApumktJjsdZ/f8GS/gIeNNldibI+Mx?= =?us-ascii?Q?VaTNK34iuZn1DGnnvXsd2H2LJfaiPWBPNdKDctTabhxlYT6srr8EubPgCvfe?= =?us-ascii?Q?zxE5j5pq6VmgYvHigM2EgQymyxQ9U2/siDlZzj411qwXuzL7OxfCJg9U1IoE?= =?us-ascii?Q?PSKTb/bMt1iBIPHh2gVbajeoKa0JgfNgVGgc6paEAlASQOK95vlwqXwoHtYZ?= =?us-ascii?Q?hPDSRxMwpSfHtKT9nqaOY4sr+R8eUgjV3eBlfhGYIRNixmvjcqwaxXR0znZA?= =?us-ascii?Q?qkhjJEXznKeCRUbbdqviXfHrmcpegC2sVgSnvaTjA5EgUssO1SI8cRw4YrPX?= =?us-ascii?Q?lZx/M9XiBDm6MwVXPx8Mwo5JGEFWsN0dHwfZjGkZfDD4Pa3e1Ukv9RawLum6?= =?us-ascii?Q?LJ8XlNSeSS8tF7PCbzRZON1vcafC4T/cDbm1Mt1ikiXjgKt5iaBFVB56JkVo?= =?us-ascii?Q?5511MoZxCGXr+ki0XffZmViAuL9y6/74nqVBrLwpk/MIDLtqnIgLn2X5HHAN?= =?us-ascii?Q?t6TjzZeKXx1Ls6Zb3GXoMMpLMmFH+UKdIl+FkLMW9JAFI7zzMdzJCIrJH3/z?= =?us-ascii?Q?F3CLkX3VextP62B+aduclR4qEaGkl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B008t1qP0UygCnBis96f5L9ypQWaXkZDvVHQSoyltegClUxrOWvlBToL7/9A1hE00v8rAogWqv4WCEz5Uz4Q/nsFCi44PNgMy5CAdctbR49dVa5C6Ncpaqg0w9o7gbMFtRIwq6S+nSdo2puLor72wGhw8LGGNWr0rBbD8GOMKlK/78/vwLg53HYbxL6sy3WRpk=; 5:53z4d5koGe58e3F9Hn8l24dyEe0PPOOE3JeLIq4iuVqu9XuHU//+cmwERip7w1Jkg+36otDhPG1Sy/+eKPCvCl+Uc57A5BeVZsTb4oPw9Vdc/g84P1eos55lu/09mHVhUOUO68JHxx71h/q6/8eWh3u+xlpoiP6QK0etlAX57Q4=; 24:3tHd3KkD9zSuBPG1SGrcbj4PZ2uAKcWnJn+5AkN1l9UlBLJ+f8iSkkYnl5XOAvUMw4biM9umOz1DmZZPTHzZyd53qLmMX7HWEI14njTIrzs=; 7:pueJF6kV2LDfnRRE37yqPAGNUi0qNiUyQESfqIfhY39ANLJYg39fx1WPXb+9HcgnOlYtYGH+kv0mnlIrHk1e+tyBbfI1X8ysqxheM7De0tVFQ1exaGg63KWuVv+/c0BOT5FGzDOUf51YbhLd/GORGKPqSR+j2qQ/eJei+DQ8E7jG2tLlXhecCFakIBPADMsMWh8q9yEAcR9IBLv5mg4jdEzLs31cski3NgtifourUB/IRcZ3MMJJtWrEXIM8rnyl SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: quantenna.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Feb 2018 15:05:33.2443 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7c863538-60cc-42c0-66d7-08d56ca9e84a X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a355dbce-62b4-4789-9446-c1d5582180ff X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR05MB1929 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sergei Maksimenko This patch enables rmmod/insmod for qtnfmac kernel modules: - do not 'pin' pci device in order to disable it on module unload - implement card reset procedure - restore PCI bar addresses for restarted wireless card Signed-off-by: Sergei Maksimenko Signed-off-by: Sergey Matyukevich --- drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c | 15 ++++++++++++++- drivers/net/wireless/quantenna/qtnfmac/pearl/pcie_ipc.h | 1 + .../wireless/quantenna/qtnfmac/pearl/pcie_regs_pearl.h | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c b/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c index be5813aa1486..7aa222286d8e 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c +++ b/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c @@ -162,6 +162,17 @@ static void qtnf_deassert_intx(struct qtnf_pcie_bus_priv *priv) qtnf_non_posted_write(cfg, reg); } +static void qtnf_reset_card(struct qtnf_pcie_bus_priv *priv) +{ + const u32 data = QTN_PEARL_IPC_IRQ_WORD(QTN_PEARL_LHOST_EP_RESET); + void __iomem *reg = priv->sysctl_bar + + QTN_PEARL_SYSCTL_LHOST_IRQ_OFFSET; + + qtnf_non_posted_write(data, reg); + msleep(QTN_EP_RESET_WAIT_MS); + pci_restore_state(priv->pdev); +} + static void qtnf_ipc_gen_ep_int(void *arg) { const struct qtnf_pcie_bus_priv *priv = arg; @@ -1308,7 +1319,6 @@ static int qtnf_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto err_base; } - pcim_pin_device(pdev); pci_set_master(pdev); ret = qtnf_pcie_init_irq(pcie_priv); @@ -1323,6 +1333,8 @@ static int qtnf_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto err_base; } + pci_save_state(pdev); + ret = qtnf_pcie_init_shm_ipc(pcie_priv); if (ret < 0) { pr_err("PCIE SHM IPC init failed\n"); @@ -1425,6 +1437,7 @@ static void qtnf_pcie_remove(struct pci_dev *pdev) qtnf_debugfs_remove(bus); qtnf_pcie_free_shm_ipc(priv); + qtnf_reset_card(priv); } #ifdef CONFIG_PM_SLEEP diff --git a/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie_ipc.h b/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie_ipc.h index c5a4e46d26ef..00bb21a1c47a 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie_ipc.h +++ b/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie_ipc.h @@ -46,6 +46,7 @@ /* state transition timeouts */ #define QTN_FW_DL_TIMEOUT_MS 3000 #define QTN_FW_QLINK_TIMEOUT_MS 30000 +#define QTN_EP_RESET_WAIT_MS 1000 #define PCIE_HDP_INT_RX_BITS (0 \ | PCIE_HDP_INT_EP_TXDMA \ diff --git a/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie_regs_pearl.h b/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie_regs_pearl.h index 5b48b425fa7f..0bfe285b6b48 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie_regs_pearl.h +++ b/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie_regs_pearl.h @@ -351,5 +351,6 @@ #define QTN_PEARL_IPC_IRQ_WORD(irq) (BIT(irq) | BIT(irq + 16)) #define QTN_PEARL_LHOST_IPC_IRQ (6) +#define QTN_PEARL_LHOST_EP_RESET (7) #endif /* __PEARL_PCIE_H */