Skip to content

Commit cd2c9fc

Browse files
shamiali2008joergroedel
authored andcommitted
iommu/dma: Move PCI window region reservation back into dma specific path.
This pretty much reverts commit 273df96 ("iommu/dma: Make PCI window reservation generic") by moving the PCI window region reservation back into the dma specific path so that these regions doesn't get exposed via the IOMMU API interface. With this change, the vfio interface will report only iommu specific reserved regions to the user space. Cc: Joerg Roedel <[email protected]> Signed-off-by: Shameer Kolothum <[email protected]> Reviewed-by: Robin Murphy <[email protected]> Fixes: 273df96 ('iommu/dma: Make PCI window reservation generic') Signed-off-by: Joerg Roedel <[email protected]>
1 parent 2f8c7f2 commit cd2c9fc

File tree

1 file changed

+25
-29
lines changed

1 file changed

+25
-29
lines changed

drivers/iommu/dma-iommu.c

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -167,40 +167,16 @@ EXPORT_SYMBOL(iommu_put_dma_cookie);
167167
* @list: Reserved region list from iommu_get_resv_regions()
168168
*
169169
* IOMMU drivers can use this to implement their .get_resv_regions callback
170-
* for general non-IOMMU-specific reservations. Currently, this covers host
171-
* bridge windows for PCI devices and GICv3 ITS region reservation on ACPI
172-
* based ARM platforms that may require HW MSI reservation.
170+
* for general non-IOMMU-specific reservations. Currently, this covers GICv3
171+
* ITS region reservation on ACPI based ARM platforms that may require HW MSI
172+
* reservation.
173173
*/
174174
void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list)
175175
{
176-
struct pci_host_bridge *bridge;
177-
struct resource_entry *window;
178-
179-
if (!is_of_node(dev->iommu_fwspec->iommu_fwnode) &&
180-
iort_iommu_msi_get_resv_regions(dev, list) < 0)
181-
return;
182-
183-
if (!dev_is_pci(dev))
184-
return;
185-
186-
bridge = pci_find_host_bridge(to_pci_dev(dev)->bus);
187-
resource_list_for_each_entry(window, &bridge->windows) {
188-
struct iommu_resv_region *region;
189-
phys_addr_t start;
190-
size_t length;
191-
192-
if (resource_type(window->res) != IORESOURCE_MEM)
193-
continue;
194176

195-
start = window->res->start - window->offset;
196-
length = window->res->end - window->res->start + 1;
197-
region = iommu_alloc_resv_region(start, length, 0,
198-
IOMMU_RESV_RESERVED);
199-
if (!region)
200-
return;
177+
if (!is_of_node(dev->iommu_fwspec->iommu_fwnode))
178+
iort_iommu_msi_get_resv_regions(dev, list);
201179

202-
list_add_tail(&region->list, list);
203-
}
204180
}
205181
EXPORT_SYMBOL(iommu_dma_get_resv_regions);
206182

@@ -229,6 +205,23 @@ static int cookie_init_hw_msi_region(struct iommu_dma_cookie *cookie,
229205
return 0;
230206
}
231207

208+
static void iova_reserve_pci_windows(struct pci_dev *dev,
209+
struct iova_domain *iovad)
210+
{
211+
struct pci_host_bridge *bridge = pci_find_host_bridge(dev->bus);
212+
struct resource_entry *window;
213+
unsigned long lo, hi;
214+
215+
resource_list_for_each_entry(window, &bridge->windows) {
216+
if (resource_type(window->res) != IORESOURCE_MEM)
217+
continue;
218+
219+
lo = iova_pfn(iovad, window->res->start - window->offset);
220+
hi = iova_pfn(iovad, window->res->end - window->offset);
221+
reserve_iova(iovad, lo, hi);
222+
}
223+
}
224+
232225
static int iova_reserve_iommu_regions(struct device *dev,
233226
struct iommu_domain *domain)
234227
{
@@ -238,6 +231,9 @@ static int iova_reserve_iommu_regions(struct device *dev,
238231
LIST_HEAD(resv_regions);
239232
int ret = 0;
240233

234+
if (dev_is_pci(dev))
235+
iova_reserve_pci_windows(to_pci_dev(dev), iovad);
236+
241237
iommu_get_resv_regions(dev, &resv_regions);
242238
list_for_each_entry(region, &resv_regions, list) {
243239
unsigned long lo, hi;

0 commit comments

Comments
 (0)