From: Shivaprasad G Bhat <sbhat@linux.ibm.com>
To: mpe@ellerman.id.au, tpearson@raptorengineering.com,
alex.williamson@redhat.com, linuxppc-dev@lists.ozlabs.org,
aik@amd.com
Cc: svaidy@linux.ibm.com, robh@kernel.org, jroedel@suse.de,
sbhat@linux.ibm.com, gbatra@linux.vnet.ibm.com, jgg@ziepe.ca,
aik@ozlabs.ru, sanastasio@raptorengineering.com,
linux-kernel@vger.kernel.org, christophe.leroy@csgroup.eu,
mahesh@linux.ibm.com, aneesh.kumar@kernel.org,
brking@linux.vnet.ibm.com, oohall@gmail.com, npiggin@gmail.com,
kvm@vger.kernel.org, ruscur@russell.cc,
naveen.n.rao@linux.ibm.com, vaibhav@linux.ibm.com,
msuchanek@suse.de, joel@jms.id.au
Subject: [PATCH v4 3/6] powerpc/pseries/iommu: Use the iommu table[0] for IOV VF's DDW
Date: Mon, 24 Jun 2024 12:38:46 +0000 [thread overview]
Message-ID: <171923272328.1397.1817843961216868850.stgit@linux.ibm.com> (raw)
In-Reply-To: <171923268781.1397.8871195514893204050.stgit@linux.ibm.com>
This patch basically brings consistency with PowerNV approach
to use the first freely available iommu table when the default
window is removed.
The pSeries iommu code convention has been that the table[0] is
for the default 32 bit DMA window and the table[1] is for the
64 bit DDW.
With VFs having only 1 DMA window, the default has to be removed
for creating the larger DMA window. The existing code uses the
table[1] for that, while marking the table[0] as NULL. This is
fine as long as the host driver itself uses the device.
For the VFIO user, on pSeries there is no way to skip table[0]
as the VFIO subdriver uses the first freely available table.
The window 0, when created as 64-bit DDW in that context would
still be on table[0], as the maximum number of windows is 1.
This won't have any impact for the host driver as the table is
fetched from the device's iommu_table_base.
Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
---
arch/powerpc/platforms/pseries/iommu.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
index 97b9a4e6bf8a..d2ac6c19cf9b 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -155,7 +155,7 @@ static void iommu_pseries_free_group(struct iommu_table_group *table_group,
#endif
/* Default DMA window table is at index 0, while DDW at 1. SR-IOV
- * adapters only have table on index 1.
+ * adapters only have table on index 0(if not direct mapped).
*/
if (table_group->tables[0])
iommu_tce_table_put(table_group->tables[0]);
@@ -1527,6 +1527,11 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)
clean_dma_window(pdn, win64->value);
goto out_del_list;
}
+ if (default_win_removed) {
+ iommu_tce_table_put(pci->table_group->tables[0]);
+ pci->table_group->tables[0] = NULL;
+ set_iommu_table_base(&dev->dev, NULL);
+ }
} else {
struct iommu_table *newtbl;
int i;
@@ -1556,15 +1561,12 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)
1UL << len, page_shift, NULL, &iommu_table_lpar_multi_ops);
iommu_init_table(newtbl, pci->phb->node, start, end);
- pci->table_group->tables[1] = newtbl;
+ pci->table_group->tables[default_win_removed ? 0 : 1] = newtbl;
set_iommu_table_base(&dev->dev, newtbl);
}
if (default_win_removed) {
- iommu_tce_table_put(pci->table_group->tables[0]);
- pci->table_group->tables[0] = NULL;
-
/* default_win is valid here because default_win_removed == true */
of_remove_property(pdn, default_win);
dev_info(&dev->dev, "Removed default DMA window for %pOF\n", pdn);
next prev parent reply other threads:[~2024-06-24 12:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-24 12:38 [PATCH v4 0/6] powerpc: pSeries: vfio: iommu: Re-enable support for SPAPR TCE VFIO Shivaprasad G Bhat
2024-06-24 12:38 ` [PATCH v4 1/6] powerpc/iommu: Move pSeries specific functions to pseries/iommu.c Shivaprasad G Bhat
2024-06-24 12:38 ` [PATCH v4 2/6] powerpc/pseries/iommu: Fix the VFIO_IOMMU_SPAPR_TCE_GET_INFO ioctl output Shivaprasad G Bhat
2024-06-24 12:38 ` Shivaprasad G Bhat [this message]
2024-06-24 12:38 ` [PATCH v4 4/6] vfio/spapr: Always clear TCEs before unsetting the window Shivaprasad G Bhat
2024-06-24 12:39 ` [PATCH v4 5/6] powerpc/iommu: Move dev_has_iommu_table() to iommu.c Shivaprasad G Bhat
2024-06-24 12:39 ` [PATCH v4 6/6] powerpc/iommu: Reimplement the iommu_table_group_ops for pSeries Shivaprasad G Bhat
2024-07-06 23:10 ` [PATCH v4 0/6] powerpc: pSeries: vfio: iommu: Re-enable support for SPAPR TCE VFIO 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=171923272328.1397.1817843961216868850.stgit@linux.ibm.com \
--to=sbhat@linux.ibm.com \
--cc=aik@amd.com \
--cc=aik@ozlabs.ru \
--cc=alex.williamson@redhat.com \
--cc=aneesh.kumar@kernel.org \
--cc=brking@linux.vnet.ibm.com \
--cc=christophe.leroy@csgroup.eu \
--cc=gbatra@linux.vnet.ibm.com \
--cc=jgg@ziepe.ca \
--cc=joel@jms.id.au \
--cc=jroedel@suse.de \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mahesh@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=msuchanek@suse.de \
--cc=naveen.n.rao@linux.ibm.com \
--cc=npiggin@gmail.com \
--cc=oohall@gmail.com \
--cc=robh@kernel.org \
--cc=ruscur@russell.cc \
--cc=sanastasio@raptorengineering.com \
--cc=svaidy@linux.ibm.com \
--cc=tpearson@raptorengineering.com \
--cc=vaibhav@linux.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).