linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Axtens <dja@axtens.net>
To: linuxppc-dev@ozlabs.org
Cc: mpe@ellerman.id.au, benh@kernel.crashing.org, cyrilbur@gmail.com,
	"Matthew R. Ochs" <mrochs@linux.vnet.ibm.com>,
	Manoj Kumar <kumarmn@us.ibm.com>,
	mikey@neuling.org, imunsie@au.ibm.com,
	Daniel Axtens <dja@axtens.net>
Subject: [PATCH v4 05/11] cxl: Clean up adapter MMIO unmap path.
Date: Thu, 13 Aug 2015 14:11:23 +1000	[thread overview]
Message-ID: <1439439089-25151-6-git-send-email-dja@axtens.net> (raw)
In-Reply-To: <1439439089-25151-1-git-send-email-dja@axtens.net>

 - MMIO pointer unmapping is guarded by a null pointer check.
   However, iounmap doesn't null the pointer, just invalidate it.
   Therefore, explicitly null the pointer after unmapping.

 - afu_desc_mmio also needs to be unmapped.

 - PCI regions are allocated in cxl_map_adapter_regs.
   Therefore they should be released in unmap, not elsewhere.

Acked-by: Cyril Bur <cyrilbur@gmail.com>
Signed-off-by: Daniel Axtens <dja@axtens.net>
---
 drivers/misc/cxl/pci.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
index 62a762d94de3..484d35a5aead 100644
--- a/drivers/misc/cxl/pci.c
+++ b/drivers/misc/cxl/pci.c
@@ -539,10 +539,18 @@ err:
 
 static void cxl_unmap_slice_regs(struct cxl_afu *afu)
 {
-	if (afu->p2n_mmio)
+	if (afu->p2n_mmio) {
 		iounmap(afu->p2n_mmio);
-	if (afu->p1n_mmio)
+		afu->p2n_mmio = NULL;
+	}
+	if (afu->p1n_mmio) {
 		iounmap(afu->p1n_mmio);
+		afu->p1n_mmio = NULL;
+	}
+	if (afu->afu_desc_mmio) {
+		iounmap(afu->afu_desc_mmio);
+		afu->afu_desc_mmio = NULL;
+	}
 }
 
 static void cxl_release_afu(struct device *dev)
@@ -919,10 +927,16 @@ err1:
 
 static void cxl_unmap_adapter_regs(struct cxl *adapter)
 {
-	if (adapter->p1_mmio)
+	if (adapter->p1_mmio) {
 		iounmap(adapter->p1_mmio);
-	if (adapter->p2_mmio)
+		adapter->p1_mmio = NULL;
+		pci_release_region(to_pci_dev(adapter->dev.parent), 2);
+	}
+	if (adapter->p2_mmio) {
 		iounmap(adapter->p2_mmio);
+		adapter->p2_mmio = NULL;
+		pci_release_region(to_pci_dev(adapter->dev.parent), 0);
+	}
 }
 
 static int cxl_read_vsec(struct cxl *adapter, struct pci_dev *dev)
@@ -1131,8 +1145,6 @@ static void cxl_remove_adapter(struct cxl *adapter)
 
 	device_unregister(&adapter->dev);
 
-	pci_release_region(pdev, 0);
-	pci_release_region(pdev, 2);
 	pci_disable_device(pdev);
 }
 
-- 
2.1.4

  parent reply	other threads:[~2015-08-13  4:14 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-13  4:11 [PATCH v4 00/11] CXL EEH Handling Daniel Axtens
2015-08-13  4:11 ` [PATCH v4 01/11] cxl: Convert MMIO read/write macros to inline functions Daniel Axtens
2015-08-14  5:12   ` Ian Munsie
2015-08-13  4:11 ` [PATCH v4 02/11] cxl: Drop commands if the PCI channel is not in normal state Daniel Axtens
2015-08-14  5:23   ` Ian Munsie
2015-08-13  4:11 ` [PATCH v4 03/11] cxl: Allocate and release the SPA with the AFU Daniel Axtens
2015-08-14  5:35   ` Ian Munsie
2015-08-13  4:11 ` [PATCH v4 04/11] cxl: Make IRQ release idempotent Daniel Axtens
2015-08-14  5:35   ` Ian Munsie
2015-08-13  4:11 ` Daniel Axtens [this message]
2015-08-14  5:37   ` [PATCH v4 05/11] cxl: Clean up adapter MMIO unmap path Ian Munsie
2015-08-13  4:11 ` [PATCH v4 06/11] cxl: Refactor adaptor init/teardown Daniel Axtens
2015-08-14  6:12   ` Ian Munsie
2015-08-14  7:55     ` Daniel Axtens
2015-08-13  4:11 ` [PATCH v4 07/11] cxl: Refactor AFU init/teardown Daniel Axtens
2015-08-14  6:22   ` Ian Munsie
2015-08-13  4:11 ` [PATCH v4 08/11] cxl: Don't remove AFUs/vPHBs in cxl_reset Daniel Axtens
2015-08-14  6:23   ` Ian Munsie
2015-08-13  4:11 ` [PATCH v4 09/11] cxl: Allow the kernel to trust that an image won't change on PERST Daniel Axtens
2015-08-14  6:27   ` Ian Munsie
2015-08-13  4:11 ` [PATCH v4 10/11] cxl: EEH support Daniel Axtens
2015-08-14  6:31   ` Ian Munsie
2015-08-13  4:11 ` [PATCH v4 11/11] cxl: Add CONFIG_CXL_EEH symbol Daniel Axtens
2015-08-14  6:33   ` Ian Munsie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1439439089-25151-6-git-send-email-dja@axtens.net \
    --to=dja@axtens.net \
    --cc=benh@kernel.crashing.org \
    --cc=cyrilbur@gmail.com \
    --cc=imunsie@au.ibm.com \
    --cc=kumarmn@us.ibm.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=mikey@neuling.org \
    --cc=mpe@ellerman.id.au \
    --cc=mrochs@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).