Skip to content

Commit

Permalink
iommu: intel-ipu: use IOMMU passthrough mode for Intel IPUs
Browse files Browse the repository at this point in the history
Intel IPU(Image Processing Unit) has its own (IO)MMU hardware,
The IPU driver allocates its own page table that is not mapped
via the DMA, and thus the Intel IOMMU driver blocks access giving
this error: DMAR: DRHD: handling fault status reg 3 DMAR:
[DMA Read] Request device [00:05.0] PASID ffffffff
fault addr 76406000 [fault reason 06] PTE Read access is not set
As IPU is not an external facing device which is not risky, so use
IOMMU passthrough mode for Intel IPUs.

Change-Id: I6dcccdadac308cf42e20a18e1b593381391e3e6b
Depends-On: Iacd67578e8c6a9b9ac73285f52b4081b72fb68a6
Tracked-On: #JIITL8-411
Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: zouxiaoh <xiaohong.zou@intel.com>
Signed-off-by: Xu Chongyang <chongyang.xu@intel.com>
Patchset: cameras
  • Loading branch information
zouxiaoh authored and qzed committed Sep 17, 2024
1 parent 60b2e71 commit a06834b
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions drivers/iommu/intel/iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@
((pdev)->vendor == PCI_VENDOR_ID_INTEL && (pdev)->device == 0x34E4) \
)

#define IS_INTEL_IPU(pdev) ((pdev)->vendor == PCI_VENDOR_ID_INTEL && \
((pdev)->device == 0x9a19 || \
(pdev)->device == 0x9a39 || \
(pdev)->device == 0x4e19 || \
(pdev)->device == 0x465d || \
(pdev)->device == 0x1919))

#define IOAPIC_RANGE_START (0xfee00000)
#define IOAPIC_RANGE_END (0xfeefffff)
#define IOVA_START_ADDR (0x1000)
Expand Down Expand Up @@ -223,12 +230,14 @@ int intel_iommu_enabled = 0;
EXPORT_SYMBOL_GPL(intel_iommu_enabled);

static int dmar_map_ipts = 1;
static int dmar_map_ipu = 1;
static int intel_iommu_superpage = 1;
static int iommu_identity_mapping;
static int iommu_skip_te_disable;
static int disable_igfx_iommu;

#define IDENTMAP_AZALIA 4
#define IDENTMAP_IPU 8
#define IDENTMAP_IPTS 16

const struct iommu_ops intel_iommu_ops;
Expand Down Expand Up @@ -2164,6 +2173,9 @@ static int device_def_domain_type(struct device *dev)
if ((iommu_identity_mapping & IDENTMAP_AZALIA) && IS_AZALIA(pdev))
return IOMMU_DOMAIN_IDENTITY;

if ((iommu_identity_mapping & IDENTMAP_IPU) && IS_INTEL_IPU(pdev))
return IOMMU_DOMAIN_IDENTITY;

if ((iommu_identity_mapping & IDENTMAP_IPTS) && IS_IPTS(pdev))
return IOMMU_DOMAIN_IDENTITY;
}
Expand Down Expand Up @@ -2466,6 +2478,9 @@ static int __init init_dmars(void)
iommu_set_root_entry(iommu);
}

if (!dmar_map_ipu)
iommu_identity_mapping |= IDENTMAP_IPU;

if (!dmar_map_ipts)
iommu_identity_mapping |= IDENTMAP_IPTS;

Expand Down Expand Up @@ -4712,6 +4727,18 @@ static void quirk_iommu_igfx(struct pci_dev *dev)
disable_igfx_iommu = 1;
}

static void quirk_iommu_ipu(struct pci_dev *dev)
{
if (!IS_INTEL_IPU(dev))
return;

if (risky_device(dev))
return;

pci_info(dev, "Passthrough IOMMU for integrated Intel IPU\n");
dmar_map_ipu = 0;
}

static void quirk_iommu_ipts(struct pci_dev *dev)
{
if (!IS_IPTS(dev))
Expand Down Expand Up @@ -4759,6 +4786,9 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x1632, quirk_iommu_igfx);
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x163A, quirk_iommu_igfx);
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x163D, quirk_iommu_igfx);

/* disable IPU dmar support */
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_ANY_ID, quirk_iommu_ipu);

/* disable IPTS dmar support */
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x9D3E, quirk_iommu_ipts);
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x34E4, quirk_iommu_ipts);
Expand Down

0 comments on commit a06834b

Please sign in to comment.