Skip to content

Commit 772d4f8

Browse files
committed
Merge tag 'iommu-fixes-v4.17-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu
Pull iommu fixes from Joerg Roedel: - fix a compile warning in the AMD IOMMU driver with irq remapping disabled - fix for VT-d interrupt remapping and invalidation size (caused a BUG_ON when trying to invalidate more than 4GB) - build fix and a regression fix for broken graphics with old DTS for the rockchip iommu driver - a revert in the PCI window reservation code which fixes a regression with VFIO. * tag 'iommu-fixes-v4.17-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu: iommu: rockchip: fix building without CONFIG_OF iommu/vt-d: Use WARN_ON_ONCE instead of BUG_ON in qi_flush_dev_iotlb() iommu/vt-d: fix shift-out-of-bounds in bug checking iommu/dma: Move PCI window region reservation back into dma specific path. iommu/rockchip: Make clock handling optional iommu/amd: Hide unused iommu_table_lock iommu/vt-d: Fix usage of force parameter in intel_ir_reconfigure_irte()
2 parents 9c48eb6 + 40fa84e commit 772d4f8

File tree

5 files changed

+37
-34
lines changed

5 files changed

+37
-34
lines changed

drivers/iommu/amd_iommu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@
8383

8484
static DEFINE_SPINLOCK(amd_iommu_devtable_lock);
8585
static DEFINE_SPINLOCK(pd_bitmap_lock);
86-
static DEFINE_SPINLOCK(iommu_table_lock);
8786

8887
/* List of all available dev_data structures */
8988
static LLIST_HEAD(dev_data_list);
@@ -3562,6 +3561,7 @@ EXPORT_SYMBOL(amd_iommu_device_info);
35623561
*****************************************************************************/
35633562

35643563
static struct irq_chip amd_ir_chip;
3564+
static DEFINE_SPINLOCK(iommu_table_lock);
35653565

35663566
static void set_dte_irq_entry(u16 devid, struct irq_remap_table *table)
35673567
{

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;

drivers/iommu/dmar.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1345,7 +1345,7 @@ void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 qdep,
13451345
struct qi_desc desc;
13461346

13471347
if (mask) {
1348-
BUG_ON(addr & ((1 << (VTD_PAGE_SHIFT + mask)) - 1));
1348+
WARN_ON_ONCE(addr & ((1ULL << (VTD_PAGE_SHIFT + mask)) - 1));
13491349
addr |= (1ULL << (VTD_PAGE_SHIFT + mask - 1)) - 1;
13501350
desc.high = QI_DEV_IOTLB_ADDR(addr) | QI_DEV_IOTLB_SIZE;
13511351
} else

drivers/iommu/intel_irq_remapping.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,7 @@ static void intel_ir_reconfigure_irte(struct irq_data *irqd, bool force)
11361136
irte->dest_id = IRTE_DEST(cfg->dest_apicid);
11371137

11381138
/* Update the hardware only if the interrupt is in remapped mode. */
1139-
if (!force || ir_data->irq_2_iommu.mode == IRQ_REMAPPING)
1139+
if (force || ir_data->irq_2_iommu.mode == IRQ_REMAPPING)
11401140
modify_irte(&ir_data->irq_2_iommu, irte);
11411141
}
11421142

drivers/iommu/rockchip-iommu.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,7 @@ static int rk_iommu_of_xlate(struct device *dev,
10981098
data->iommu = platform_get_drvdata(iommu_dev);
10991099
dev->archdata.iommu = data;
11001100

1101-
of_dev_put(iommu_dev);
1101+
platform_device_put(iommu_dev);
11021102

11031103
return 0;
11041104
}
@@ -1175,8 +1175,15 @@ static int rk_iommu_probe(struct platform_device *pdev)
11751175
for (i = 0; i < iommu->num_clocks; ++i)
11761176
iommu->clocks[i].id = rk_iommu_clocks[i];
11771177

1178+
/*
1179+
* iommu clocks should be present for all new devices and devicetrees
1180+
* but there are older devicetrees without clocks out in the wild.
1181+
* So clocks as optional for the time being.
1182+
*/
11781183
err = devm_clk_bulk_get(iommu->dev, iommu->num_clocks, iommu->clocks);
1179-
if (err)
1184+
if (err == -ENOENT)
1185+
iommu->num_clocks = 0;
1186+
else if (err)
11801187
return err;
11811188

11821189
err = clk_bulk_prepare(iommu->num_clocks, iommu->clocks);

0 commit comments

Comments
 (0)