From patchwork Sat Feb 10 14:04:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Matyukevich X-Patchwork-Id: 10210499 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 A3A06602D8 for ; Sat, 10 Feb 2018 14:04:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 957F5286CF for ; Sat, 10 Feb 2018 14:04:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8948C29920; 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 0DE18286CF for ; Sat, 10 Feb 2018 14:04:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751333AbeBJOEk (ORCPT ); Sat, 10 Feb 2018 09:04:40 -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 S1750946AbeBJOEf (ORCPT ); Sat, 10 Feb 2018 09:04:35 -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=kZdz7Ruz1QI74uFBdogAH9//FIRG8HggImtjVrkRdy8=; b=v3o1CS0aXq9n11MWEjcXT3GP5h5+lVQv3m5fwuY5gC+//xEuAymGYbGqym5h2ucVmEHpUp17PdBmf7Cma+rFeh0FEgtNbLHPOpCQgRMGP3K/ZEGU4jyp4NgOqi0T0KpJNb5DHz/Ao901YVjYUGCWQR2XeID634YHxTZAnsQKWMM= 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:32 +0000 From: Sergey Matyukevich To: linux-wireless@vger.kernel.org Cc: Igor Mitsyanko , Avinash Patil , Sergei Maksimenko , Sergey Matyukevich Subject: [PATCH v2 1/4] qtnfmac: fix releasing Tx/Rx data buffers Date: Sat, 10 Feb 2018 17:04:17 +0300 Message-Id: <20180210140420.17013-2-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: 00fca204-cb6a-4516-1431-08d5708f3668 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:TjAae3Kc/COC6U8w+1zOeoC51WR3kdTY5LRITLVRUZpXfuXSHeudFnRgauujM6SmA7GqpsHY/UqcD5v+LEnZKb+XM5v5U3Q61b3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GZE+PyovLI5NQ5znv+0qXMLr5efG3pUkBPG5HKVJWgN0y3yoVJjHb9ZDH4BPusYchyeRUCyqVbamkoQMaXEiQ9A6OJ/B5r6wKueX1Glmly07FHxUoKv1TP0hN5CX07xl0UBHc6123nsP6NvqvfEyFZntRE78o+0k7cn/+9N81RtTosbNDFkZ+2pAqy1E56dKtSNJEXKbQOq2XomkdEvBolXGUB0xg88HoPHq+dZTEwZW7mN5; 4:hLZ1mYvO9/pVID6+c9HyLPuNPugieQpHilAe6I3108YNwkeRU4kwoTvadTdboylj2AklCU2uvrHh4uGtDZrBJxPhlIADVNHeVFUhZoEOgzbUxapvrbnUN3ba+tHSfPiSbUkItLl1CxHtu1gbAwJ9FrwCctS3LJ7HNAs0vjGi6jgmcTWJjnwSoRPDjlu8X8XVfaUtZHxvrhvllwX9gGQPys0zYDr8StiOXcV4qh//QltTuf2TxhzkVX5pCSn65rQtVCDDlyFHd8zHOdLVpb1juA== 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:A4dC4o8/Sx4yJDWc/VCoACzG8evEWKRGCGMaGe+64?= =?us-ascii?Q?9sS9B6QorXNw+p9furfCkGRR3cME3R+aa2y2tsLUX2nTqgMFBj4ri+okPHbl?= =?us-ascii?Q?PHoYsIfPJI7I7jvvjVQZsHnZb0IYO0IyOoAqcYTiCfpx80WOVq+hgLaLHZ3e?= =?us-ascii?Q?ZDoPDS3EBWkSs78HVG671vO4mb51hWwvtnDrcY2LAFiTnfU365fVW3wXRcr6?= =?us-ascii?Q?UrwToAjQ+wD5yDV2JW1mENNlzkPBrOF0kCy1JnOkQvUVK7y03PdCitJMz8Ub?= =?us-ascii?Q?Dd4WCXF2nWp+FDwFOG562q2zJJMV8BggRkjBcjtX/jFH5hIkzGGvBSOGk0EE?= =?us-ascii?Q?30D26j55b+ij681zX7ZBAA1MbSnaW0qLybaULUBPcwjxF8TL5QKjg3DJ5f/b?= =?us-ascii?Q?5FKYs1qm9qAOsiWdMLs6Gsb3FduObO+uGabtMsg//ITT4KzYP0MpwbNZbsCO?= =?us-ascii?Q?IL5FOjBb35ggkclZdPLi5SfhgMX2vA3udR7QF4pFAxGws3A10+u2/LtsOreN?= =?us-ascii?Q?9X7CKMbTQnAC3Y4GUxrTM/YUFY5wCLfm/x9OwLqirDFss+yTInSs2Tnt5Vpv?= =?us-ascii?Q?F5R+Z4ipJowcs9JJW7z56r6U76I8RsAK8nRELz/hRye5mHXZ3xbrBBjamfkB?=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g2ZmnjKroVD6mYMJ2kETjDF2dh7GgfbjlzQbB8aYkOp0zaaGsVMEvy8cNmRmxVMGYeUOO9KPFt5iYqQaEIv9JaGVtFWJ6g1O3j3SMpj+EhPCJVX9pMwrxCYt8uGN/9O5Hk0OynLdV9rSwQ8gdTrPegalDh0=; 5:xj3Zr4sivWFGqui84F6sy8JOwgNjNfFZxBmD9P7rnbhoscBmemYXx9s9aKg8kZTtsIYpkFZgOgAUNBFBCmywB5aVEuwR8rgyPjkazNC0/69Oxk1BQJk7O7F/0y59E0bO+PbMY/2xUoYxIa1Y7LSIzK7EqzWjBF6/fFeMww/r60w=; 24:2PVlwOcruV2yRzeFtA9oAGHuu4INa3KJ5xqNP0W7VzXiFR53honk+Zol57MtVkqsmooj+5JAUfF7C+Ic6TA1xIFT2xfxJgg5SLv+ehEKWC4=; 7:ltHK6BQBzeJPTg4O7Qv6p04EajinkEA0sJTKfA5outOwFQCzvn8DtgSvD3ZB7cV8S8lheNAHMPfQlamJMAIDUtPIkWYOv5d2KcKPk4KtWqMsguN9cMXNZjLz0VdSoHpMevAoSyqle2cco6j3DJrLXTHt2JgyOGdBbOYFLZGZ/N5lzNL4PySgD98vnQKKFkfqBCbrxQoDVetF1SohQTr4VYD3pQ56ExqLDvO20RWllwSuVpIY8XG5cLoY3eIMWnMm SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: quantenna.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2018 14:04:32.6655 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 00fca204-cb6a-4516-1431-08d5708f3668 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 Add missing PCI unmap for Tx buffers and release all buffers explicitly. Managed release using devm_add_action is not suitable for qtnfmac Tx/Rx data buffers. The reason is in ordering and dependencies: buffers should be released after transmission is stopped but before PCI device resources and DMA allocations are released. Signed-off-by: Sergey Matyukevich --- .../net/wireless/quantenna/qtnfmac/pearl/pcie.c | 30 +++++++++++++--------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c b/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c index 6f6190964320..be5813aa1486 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c +++ b/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c @@ -478,10 +478,11 @@ static int alloc_rx_buffers(struct qtnf_pcie_bus_priv *priv) } /* all rx/tx activity should have ceased before calling this function */ -static void free_xfer_buffers(void *data) +static void qtnf_free_xfer_buffers(struct qtnf_pcie_bus_priv *priv) { - struct qtnf_pcie_bus_priv *priv = (struct qtnf_pcie_bus_priv *)data; + struct qtnf_tx_bd *txbd; struct qtnf_rx_bd *rxbd; + struct sk_buff *skb; dma_addr_t paddr; int i; @@ -489,19 +490,26 @@ static void free_xfer_buffers(void *data) for (i = 0; i < priv->rx_bd_num; i++) { if (priv->rx_skb && priv->rx_skb[i]) { rxbd = &priv->rx_bd_vbase[i]; + skb = priv->rx_skb[i]; paddr = QTN_HOST_ADDR(le32_to_cpu(rxbd->addr_h), le32_to_cpu(rxbd->addr)); pci_unmap_single(priv->pdev, paddr, SKB_BUF_SIZE, PCI_DMA_FROMDEVICE); - - dev_kfree_skb_any(priv->rx_skb[i]); + dev_kfree_skb_any(skb); + priv->rx_skb[i] = NULL; } } /* free tx buffers */ for (i = 0; i < priv->tx_bd_num; i++) { if (priv->tx_skb && priv->tx_skb[i]) { - dev_kfree_skb_any(priv->tx_skb[i]); + txbd = &priv->tx_bd_vbase[i]; + skb = priv->tx_skb[i]; + paddr = QTN_HOST_ADDR(le32_to_cpu(txbd->addr_h), + le32_to_cpu(txbd->addr)); + pci_unmap_single(priv->pdev, paddr, skb->len, + PCI_DMA_TODEVICE); + dev_kfree_skb_any(skb); priv->tx_skb[i] = NULL; } } @@ -1321,12 +1329,6 @@ static int qtnf_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto err_base; } - ret = devm_add_action(&pdev->dev, free_xfer_buffers, (void *)pcie_priv); - if (ret) { - pr_err("custom release callback init failed\n"); - goto err_base; - } - ret = qtnf_pcie_init_xfer(pcie_priv); if (ret) { pr_err("PCIE xfer init failed\n"); @@ -1343,7 +1345,7 @@ static int qtnf_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) "qtnf_pcie_irq", (void *)bus); if (ret) { pr_err("failed to request pcie irq %d\n", pdev->irq); - goto err_base; + goto err_xfer; } tasklet_init(&pcie_priv->reclaim_tq, qtnf_reclaim_tasklet_fn, @@ -1387,6 +1389,9 @@ static int qtnf_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) err_bringup_fw: netif_napi_del(&bus->mux_napi); +err_xfer: + qtnf_free_xfer_buffers(pcie_priv); + err_base: flush_workqueue(pcie_priv->workqueue); destroy_workqueue(pcie_priv->workqueue); @@ -1416,6 +1421,7 @@ static void qtnf_pcie_remove(struct pci_dev *pdev) destroy_workqueue(priv->workqueue); tasklet_kill(&priv->reclaim_tq); + qtnf_free_xfer_buffers(priv); qtnf_debugfs_remove(bus); qtnf_pcie_free_shm_ipc(priv);