From patchwork Sat Feb 10 14:04:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Matyukevich X-Patchwork-Id: 10210501 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 0CACB60594 for ; Sat, 10 Feb 2018 14:04:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1124286CF for ; Sat, 10 Feb 2018 14:04:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E0E50298F9; Sat, 10 Feb 2018 14:04:44 +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 720562991F for ; Sat, 10 Feb 2018 14:04:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751275AbeBJOEi (ORCPT ); Sat, 10 Feb 2018 09:04:38 -0500 Received: from mail-by2nam03on0061.outbound.protection.outlook.com ([104.47.42.61]:55552 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750832AbeBJOEg (ORCPT ); Sat, 10 Feb 2018 09:04:36 -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=XkVfolqTWUsRBOINk1GHF2nEK853g9s6YCCDP/65M0iCZImK88vv1KOcMDpxcDBAcqEDQwqvJmkEeT+bOu/L8bXlM78DySXgQRlpdGckHVP4U9cWnQ9M4n5WkOXrR5889iqOfGFA8uM/KYpS1SIDg2Tv+thu9dogkWJDocOXwrA= Received: from bars.quantenna.com (195.182.157.78) by SN1PR05MB1936.namprd05.prod.outlook.com (10.162.132.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.485.3; Sat, 10 Feb 2018 14:04:34 +0000 From: Sergey Matyukevich To: linux-wireless@vger.kernel.org Cc: Igor Mitsyanko , Avinash Patil , Sergei Maksimenko , Sergey Matyukevich Subject: [PATCH v2 2/4] qtnfmac: enable reloading of qtnfmac kernel modules Date: Sat, 10 Feb 2018 17:04:18 +0300 Message-Id: <20180210140420.17013-3-sergey.matyukevich.os@quantenna.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180210140420.17013-1-sergey.matyukevich.os@quantenna.com> References: <20180210140420.17013-1-sergey.matyukevich.os@quantenna.com> MIME-Version: 1.0 X-Originating-IP: [195.182.157.78] X-ClientProxiedBy: AM6PR0402CA0007.eurprd04.prod.outlook.com (52.133.16.20) To SN1PR05MB1936.namprd05.prod.outlook.com (10.162.132.14) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cf966248-bc62-45f7-7fa0-08d5708f3775 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:SN1PR05MB1936; X-Microsoft-Exchange-Diagnostics: 1; SN1PR05MB1936; 3:Yo5l6NZRIJk0XxvYYWLVHCzSiehciDArT5wwwIW67F6ErOdxVdzYXBpFyJf2q0yTEFyxMtQhLGAK9PprM9x/TUNKC3T5kizvzrDTw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+4gJivXOjc/b1qaMYEiQWuhFBPR2IA3wtcM0GqwDc1xCAcSczbXFtf3RTg3FXYjuQ8k8ver+gmsSkbvVbseNE/AAhfXiFKvEt0I7RCS6WoWzvqcrpDmmfV1jbfzxBjHWW+BmR6G76oNzrQuthuo1lCLxExuWxgPgcQXD5kcom1SSlg558m4y+aT6KahaobSQ3iQuKltVMEP2Ee7OTnGTZ4WlAUgqo40A4RElA4klrf7Aa3LEIxfQXg1vmVsgpkZZj; 4:qZBPLBptMMHKiRBsPog7s65Sb4wCEDOYRDNMfSb5Kx7nDGCdW1NE2EqJO7Bq8/sEyDP9tDaf70ncTuDjUFW1KxsKKEQB0kIN+5TqbEy4IFDtv6dgxBYh7eBkB7igEl3o4sTQzhMjEtaQ+k9r2DsFjQJuplaxd6O3xaSvPNa3Alrsbn+fhuxheJlvZP+fiP9DY6o+DNVLxdkEEBfe7XUBECChOX2MH2/jyg6eYB2R1RDB5uv7Qh4toM5qn4RuM0qJD6ZeeTja86dcWG8iHIVBaw== 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)(3002001)(10201501046)(93006095)(93001095)(3231101)(2400082)(944501161)(6041288)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011); SRVR:SN1PR05MB1936; BCL:0; PCL:0; RULEID:; SRVR:SN1PR05MB1936; X-Forefront-PRVS: 057906460E X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(39380400002)(39840400004)(396003)(346002)(366004)(199004)(189003)(478600001)(54906003)(68736007)(386003)(26005)(76176011)(16586007)(105586002)(66066001)(59450400001)(16526019)(186003)(6346003)(53936002)(51416003)(7696005)(52116002)(107886003)(6916009)(2950100002)(6666003)(5660300001)(36756003)(97736004)(316002)(25786009)(4326008)(6486002)(48376002)(2361001)(2906002)(81156014)(106356001)(81166006)(1076002)(47776003)(8676002)(2351001)(86362001)(3846002)(6116002)(50466002)(69596002)(7736002)(305945005)(8936002)(50226002)(53416004)(103116003); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR05MB1936; 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; SN1PR05MB1936; 23:2uHX9xpQVuFYEGpC01HcY33PG73qHVddqHbU5eudp?= =?us-ascii?Q?bPlcgJzJ0lq3gzwYR3Fz2/8GSd5gwSUHMvLMCiMp8t5N1EAAYE6vRvPsru2l?= =?us-ascii?Q?vc/rLCWoZYESVsQ5r13kcysDrO0/EZNyGHfviD+/QyhP2MFooe4W7H2e+obH?= =?us-ascii?Q?djSPzfU1KuJJt9iENYLTAKrWkgr8ZPkLaQhrwYbq6uzPTta/mNOcyR62QxFQ?= =?us-ascii?Q?ETbjhZy5U6g2HLkPGIkxwAWT7drYzB7XgZ7WbFys2XqovZyhh8h9zZ3+cPz9?= =?us-ascii?Q?UT2CKfs12p/32ACAI57w6lhbtftkJ4ASHDpuTmfgv3I6wre+yTUGHeIizmgb?= =?us-ascii?Q?ltV4pIW4A8ownzMNDnt2u7kHMVKlvzOb/6jVNWQaMjVOZc4zkQmY8sU/wL80?= =?us-ascii?Q?8p1EUiLd+YUF9oKIKrdu0SmFeb2PmTV+QcS26pTpGd0R5VU3xDmOYo5NmG11?= =?us-ascii?Q?1g6inJlapVJ5qVU21wd8P4c19pnIgplb4e/vY1KAFFa9aOpfunIFPgSEqbmO?= =?us-ascii?Q?cuJ4r6fwK3ZSP8wxcVtI+UmycmVfeF8ZXUwDI0jJ/w9ZfcvXU1CvTeIo2JWU?= =?us-ascii?Q?kQDyqHWGjLRJAv+3fjjhDy3kSXwUyUAXnyBxkUYEN0G3nbs2up/BxaFCAHyw?= =?us-ascii?Q?Vw18uRz21SOWP8z8Ll7xhWNN9jJS5HHhMkYl4skchroAA7ttSOqH6c9Qs8yY?= =?us-ascii?Q?djre/oR+MsmJ01BJCyacrisUzyfC8FlCviM+5og2eAB2jOMFlaSlvvTur53b?= =?us-ascii?Q?9L5wLOjLIhR+IB3mg/LflgossIiBlsALGLEzYy+PFVZcKtVx0Xvu0otXZbLC?= =?us-ascii?Q?bGOLllUuW+75XQ/BUOSQVMImD1tL38HffQaGNbYAiPHUIsXL973xpuC3Fp7R?= =?us-ascii?Q?IEdiIK+tnH+wGHi2NHdd9hEnUCHrubzCCew4OV1713E/sEMeahUmnV6+ccaM?= =?us-ascii?Q?Oib/Y2mq+VxUKK3Ab3Je65rJDh5KN0hccvhXL9vAiRfq9Sw77iXxE9G+uxa/?= =?us-ascii?Q?lY5kYIgS4RQ6RfHOYXDRUxRJ576paRPBrAj643yN+DJGG6z7YfTUrByp+HrU?= =?us-ascii?Q?U5OaWstu/gA3kFgPMVQHO5GGBMuE0Eg4B/h2xIK6c+NR7/evO8gXJEyV6bSA?= =?us-ascii?Q?XwKgt4dedst9Z/VclAqfdIeoNN+aOf1sAquX0+U+IHNqQfeTv2/lszP0lzuf?= =?us-ascii?Q?4jdRKK6RjBf0sHpxNblRlvD+DM+LvZWqLEl3EnhQuzMoexYjNyqdAPoImahy?= =?us-ascii?Q?6Mh0Wv5w4Tft3m1CMtYKdHNqrGjkhhTWOB4pWK4rCNn3Zd2TXrl2rX7QzZFn?= =?us-ascii?B?Zz09?= X-Microsoft-Exchange-Diagnostics: 1; SN1PR05MB1936; 6:gP7wrWm7TTo6gYupabcXTtw6IjsfdYlRIsfVe1vYHSaxXVU+HVuBpwnCBrOZfiJk40bnHoKbL1gbpF64kqyK+aYiuozq7zMxDytCuParQNJaMxbDGjzddPc4t9+sph9VjeQhUqQsp30xEcpeukdFscA1GngyDB9z/YKtafYypiiWwxrUh5ppbv9gzzpv586GKQjLzi7rkJXzyHT1HrMIl3tCDXeYZv0c+zfvYhdTJG9noB5uw6S+MwGw1rJAMZbeAASqSssUrKPvxgdEYxPEPeM8rhFBEJ8CO/9/v2WqvhbC9aplIg3OoSiGw2Ld4A/AuPkzTKTXJq/M9WoP5jA/YLGh9TkThXLpoBOVbkIUYJc=; 5:7itXbuqr4g3tqpofvfoRpOvi0V/1dTxWFohAZYQy6XJN68ch1WD9d/1GRc2lYakygH/y1hZTIQ+W90qq7yyyAKCF+9ekFmv213K//DEDZz0Zs6IvSdGGE9VEafnrmZ1jEU/vZxfGuGbfGG0Yd9MmDrqk2b92yvZSnT5nU2dQkjw=; 24:1krHo13JNmFLIpptnb4SKYGAcyNAt7XFSskUuRjyAuEj5t4w5CxfwcgohO6vFf09fbj1nFb+BbK6R9EcYzqB/jG+Cof8oPhNFGlPssVEjxU=; 7:SsM/Uw/eh0PngClXKoAylNGT9lim628KFaiKQrGKjmzWIgH9PAYE/7vHHmflZnMOulBtMQR7J6r+kbMF74Vodi8pBaYzLBpsC5rpQcdpMLQqD/S+bxHhU7MkkZLtK/Rz4faPPE/H1QWcfaoE9x90raCE6oNpMzEiuPhhfIvENCQd7/EPgaHlIlHojmesoS1W2QkjJALU036HnOetQES8cNeJAnmvs0lpzCrTFue9SWqmJQxuILSFBkf48lAu0S4I SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: quantenna.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2018 14:04:34.4311 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cf966248-bc62-45f7-7fa0-08d5708f3775 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a355dbce-62b4-4789-9446-c1d5582180ff X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR05MB1936 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 */