Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'iommu-fixes-v5.0-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu

Pull IOMMU fixes from Joerg Roedel:
"A few more fixes this time:

- Two patches to fix the error path of the map_sg implementation of
the AMD IOMMU driver.

- Also a missing IOTLB flush is fixed in the AMD IOMMU driver.

- Memory leak fix for the Intel IOMMU driver.

- Fix a regression in the Mediatek IOMMU driver which caused device
initialization to fail (seen as broken HDMI output)"

* tag 'iommu-fixes-v5.0-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu:
iommu/amd: Fix IOMMU page flush when detach device from a domain
iommu/mediatek: Use correct fwspec in mtk_iommu_add_device()
iommu/vt-d: Fix memory leak in intel_iommu_put_resv_regions()
iommu/amd: Unmap all mapped pages in error path of map_sg
iommu/amd: Call free_iova_fast with pfn in map_sg

+18 -7
+13 -6
drivers/iommu/amd_iommu.c
··· 1991 1991 1992 1992 static void do_detach(struct iommu_dev_data *dev_data) 1993 1993 { 1994 + struct protection_domain *domain = dev_data->domain; 1994 1995 struct amd_iommu *iommu; 1995 1996 u16 alias; 1996 1997 1997 1998 iommu = amd_iommu_rlookup_table[dev_data->devid]; 1998 1999 alias = dev_data->alias; 1999 - 2000 - /* decrease reference counters */ 2001 - dev_data->domain->dev_iommu[iommu->index] -= 1; 2002 - dev_data->domain->dev_cnt -= 1; 2003 2000 2004 2001 /* Update data structures */ 2005 2002 dev_data->domain = NULL; ··· 2007 2010 2008 2011 /* Flush the DTE entry */ 2009 2012 device_flush_dte(dev_data); 2013 + 2014 + /* Flush IOTLB */ 2015 + domain_flush_tlb_pde(domain); 2016 + 2017 + /* Wait for the flushes to finish */ 2018 + domain_flush_complete(domain); 2019 + 2020 + /* decrease reference counters - needs to happen after the flushes */ 2021 + domain->dev_iommu[iommu->index] -= 1; 2022 + domain->dev_cnt -= 1; 2010 2023 } 2011 2024 2012 2025 /* ··· 2624 2617 bus_addr = address + s->dma_address + (j << PAGE_SHIFT); 2625 2618 iommu_unmap_page(domain, bus_addr, PAGE_SIZE); 2626 2619 2627 - if (--mapped_pages) 2620 + if (--mapped_pages == 0) 2628 2621 goto out_free_iova; 2629 2622 } 2630 2623 } 2631 2624 2632 2625 out_free_iova: 2633 - free_iova_fast(&dma_dom->iovad, address, npages); 2626 + free_iova_fast(&dma_dom->iovad, address >> PAGE_SHIFT, npages); 2634 2627 2635 2628 out_err: 2636 2629 return 0;
+1 -1
drivers/iommu/intel-iommu.c
··· 5294 5294 struct iommu_resv_region *entry, *next; 5295 5295 5296 5296 list_for_each_entry_safe(entry, next, head, list) { 5297 - if (entry->type == IOMMU_RESV_RESERVED) 5297 + if (entry->type == IOMMU_RESV_MSI) 5298 5298 kfree(entry); 5299 5299 } 5300 5300 }
+4
drivers/iommu/mtk_iommu_v1.c
··· 441 441 iommu_spec.args_count = count; 442 442 443 443 mtk_iommu_create_mapping(dev, &iommu_spec); 444 + 445 + /* dev->iommu_fwspec might have changed */ 446 + fwspec = dev_iommu_fwspec_get(dev); 447 + 444 448 of_node_put(iommu_spec.np); 445 449 } 446 450