From patchwork Tue Jan 8 14:51:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jose Abreu X-Patchwork-Id: 1021942 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=synopsys.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.b="fjMJ3rGO"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43YwFZ0YjSz9sDL for ; Wed, 9 Jan 2019 01:51:46 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728695AbfAHOvU (ORCPT ); Tue, 8 Jan 2019 09:51:20 -0500 Received: from smtprelay2.synopsys.com ([198.182.60.111]:39278 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728123AbfAHOvS (ORCPT ); Tue, 8 Jan 2019 09:51:18 -0500 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id 5698C10C0853; Tue, 8 Jan 2019 06:51:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1546959078; bh=VbwA2/CvsCw7hMnkKmRU1QWpzxSGssVYdnS79M5v0FU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=fjMJ3rGOCd/vjL/i5bhv5CMPVxpD0jyIgI1cm0VJvm1Vr8W2R82M/VeCnf/AVChp7 +HHZq3RgfehMG506aIW2H3Y4bazZp8R0HmxDWUQ1hoH83m+CKKqBDalW5AgyK440Ks hAllcSs00vKLUQmzzxmZEikMtJ5e/hKB6OBMgnGcRwmwh+4Al6KtsHNfAzaMd7ZLv7 JrO53pIxAcUL7QcZQzE/X0zpOXPM3oFcjNbajJbzwouHGIGnoORXtm3LgPn2lblwHS kTHieRGhYn6r2WjKtTa3PkgTH/oKFeedJLGu04FePbI8oungEVDVxo4Ckz5+nrTxBz dPM7FFfq9hkRQ== Received: from de02dwia024.internal.synopsys.com (de02dwia024.internal.synopsys.com [10.225.19.81]) by mailhost.synopsys.com (Postfix) with ESMTP id DCDBF5842; Tue, 8 Jan 2019 06:51:16 -0800 (PST) From: Jose Abreu To: netdev@vger.kernel.org Cc: Jose Abreu , Joao Pinto , "David S . Miller" , Giuseppe Cavallaro , Alexandre Torgue Subject: [PATCH net 1/5] net: stmmac: Fix PCI module removal leak Date: Tue, 8 Jan 2019 15:51:05 +0100 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Since commit b7d0f08e9129, the enable / disable of PCI device is not managed which will result in IO regions not being automatically unmapped. As regions continue mapped it is currently not possible to remove and then probe again the PCI module of stmmac. Fix this by manually unmapping regions on remove callback. Cc: Joao Pinto Cc: David S. Miller Cc: Giuseppe Cavallaro Cc: Alexandre Torgue Fixes: b7d0f08e9129 ("net: stmmac: Fix WoL for PCI-based setups") Signed-off-by: Jose Abreu --- drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c index c54a50dbd5ac..9d58c7cb243c 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c @@ -299,7 +299,17 @@ static int stmmac_pci_probe(struct pci_dev *pdev, */ static void stmmac_pci_remove(struct pci_dev *pdev) { + int i; + stmmac_dvr_remove(&pdev->dev); + + for (i = 0; i <= PCI_STD_RESOURCE_LEN; i++) { + if (pci_resource_len(pdev, i) == 0) + continue; + pcim_iounmap_regions(pdev, BIT(i)); + break; + } + pci_disable_device(pdev); }