linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: linuxppc-dev@ozlabs.org
Subject: [PATCH v2 11/14] powerpc/powernv/pci: Fallback to OPAL for TCE invalidations
Date: Fri, 08 Jul 2016 18:28:24 +1000	[thread overview]
Message-ID: <1467966504.2874.27.camel@kernel.crashing.org> (raw)
In-Reply-To: <1467959838-6900-11-git-send-email-benh@kernel.crashing.org>

If we don't find registers for the PHB or don't know the model
specific invalidation method, use OPAL calls instead.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---

v2. Missed some new invalidation calls that went upstream since I
    wrote the original patch.

 arch/powerpc/platforms/powernv/pci-ioda.c | 37 ++++++++++++++++++++++++++-----
 1 file changed, 31 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index ac4a432..4e9b000 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -1867,6 +1867,17 @@ static void pnv_pci_phb3_tce_invalidate(struct pnv_ioda_pe *pe, bool rm,
 	}
 }
 
+static inline void pnv_pci_ioda2_tce_invalidate_pe(struct pnv_ioda_pe *pe)
+{
+	struct pnv_phb *phb = pe->phb;
+
+	if (phb->model == PNV_PHB_MODEL_PHB3 && phb->regs)
+		pnv_pci_phb3_tce_invalidate_pe(pe);
+	else
+		opal_pci_tce_kill(phb->opal_id, OPAL_PCI_TCE_KILL_PE,
+				  pe->pe_number, 0, 0, 0);
+}
+
 static void pnv_pci_ioda2_tce_invalidate(struct iommu_table *tbl,
 		unsigned long index, unsigned long npages, bool rm)
 {
@@ -1875,17 +1886,31 @@ static void pnv_pci_ioda2_tce_invalidate(struct iommu_table *tbl,
 	list_for_each_entry_rcu(tgl, &tbl->it_group_list, next) {
 		struct pnv_ioda_pe *pe = container_of(tgl->table_group,
 				struct pnv_ioda_pe, table_group);
-		if (pe->phb->type == PNV_PHB_NPU) {
+		struct pnv_phb *phb = pe->phb;
+		unsigned int shift = tbl->it_page_shift;
+
+		if (phb->type == PNV_PHB_NPU) {
 			/*
 			 * The NVLink hardware does not support TCE kill
 			 * per TCE entry so we have to invalidate
 			 * the entire cache for it.
 			 */
-			pnv_pci_phb3_tce_invalidate_entire(pe->phb, rm);
+			pnv_pci_phb3_tce_invalidate_entire(phb, rm);
 			continue;
 		}
-		pnv_pci_phb3_tce_invalidate(pe, rm, tbl->it_page_shift,
-					    index, npages);
+		if (phb->model == PNV_PHB_MODEL_PHB3 && phb->regs)
+			pnv_pci_phb3_tce_invalidate(pe, rm, shift,
+						    index, npages);
+		else if (rm)
+			opal_rm_pci_tce_kill(phb->opal_id,
+					     OPAL_PCI_TCE_KILL_PAGES,
+					     pe->pe_number, 1u << shift,
+					     index << shift, npages);
+		else
+			opal_pci_tce_kill(phb->opal_id,
+					  OPAL_PCI_TCE_KILL_PAGES,
+					  pe->pe_number, 1u << shift,
+					  index << shift, npages);
 	}
 }
 
@@ -2151,7 +2176,7 @@ static long pnv_pci_ioda2_set_window(struct iommu_table_group *table_group,
 
 	pnv_pci_link_table_and_group(phb->hose->node, num,
 			tbl, &pe->table_group);
-	pnv_pci_phb3_tce_invalidate_pe(pe);
+	pnv_pci_ioda2_tce_invalidate_pe(pe);
 
 	return 0;
 }
@@ -2289,7 +2314,7 @@ static long pnv_pci_ioda2_unset_window(struct iommu_table_group *table_group,
 	if (ret)
 		pe_warn(pe, "Unmapping failed, ret = %ld\n", ret);
 	else
-		pnv_pci_phb3_tce_invalidate_pe(pe);
+		pnv_pci_ioda2_tce_invalidate_pe(pe);
 
 	pnv_pci_unlink_table_and_group(table_group->tables[num], table_group);
 

  reply	other threads:[~2016-07-08  8:28 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-08  6:37 [PATCH 01/14] powerpc/powernv: Add XICS emulation APIs Benjamin Herrenschmidt
2016-07-08  6:37 ` [PATCH 02/14] powerpc/irq: Add support for HV virtualization interrupts Benjamin Herrenschmidt
2016-07-16 10:40   ` Michael Ellerman
2016-07-16 21:33     ` Benjamin Herrenschmidt
2016-07-16 22:55       ` Benjamin Herrenschmidt
2016-07-08  6:37 ` [PATCH 03/14] powerpc/irq: Add mechanism to force a replay of interrupts Benjamin Herrenschmidt
2016-07-08  6:37 ` [PATCH 04/14] powerpc/xics: Add ICP OPAL backend Benjamin Herrenschmidt
2016-07-08  6:37 ` [PATCH 05/14] powerpc/powernv: Discover IODA3 PHBs Benjamin Herrenschmidt
2016-07-08  6:37 ` [PATCH 06/14] powerpc/pseries/pci: Remove obsolete SW invalidate Benjamin Herrenschmidt
2016-07-08  6:37 ` [PATCH 07/14] powerpc/opal: Add real mode call wrappers Benjamin Herrenschmidt
2016-07-08  6:37 ` [PATCH 08/14] powerpc/powernv/pci: Rename TCE invalidation calls Benjamin Herrenschmidt
2016-07-08  6:37 ` [PATCH 09/14] powerpc/powernv/pci: Remove SWINV constants and obsolete TCE code Benjamin Herrenschmidt
2016-07-08  6:37 ` [PATCH 10/14] powerpc/powernv/pci: Rework accessing the TCE invalidate register Benjamin Herrenschmidt
2016-07-08  6:37 ` [PATCH 11/14] powerpc/powernv/pci: Fallback to OPAL for TCE invalidations Benjamin Herrenschmidt
2016-07-08  8:28   ` Benjamin Herrenschmidt [this message]
2016-07-08  6:37 ` [PATCH 12/14] powerpc/powernv/pci: Use the device-tree to get available range of M64's Benjamin Herrenschmidt
2016-07-08  6:37 ` [PATCH 13/14] powerpc/powernv/pci: Check status of a PHB before using it Benjamin Herrenschmidt
2016-07-08  6:37 ` [PATCH 14/14] powerpc/pci: Don't try to allocate resources that will be reassigned Benjamin Herrenschmidt
2016-07-12  6:52 ` [PATCH 01/14] powerpc/powernv: Add XICS emulation APIs Stewart Smith
2016-07-17 10:28 ` [01/14] " Michael Ellerman

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=1467966504.2874.27.camel@kernel.crashing.org \
    --to=benh@kernel.crashing.org \
    --cc=linuxppc-dev@ozlabs.org \
    /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).