Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2971061pxb; Mon, 19 Apr 2021 19:50:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyhskXvUudGtKCKhfro+VSzUdMahUuJszW2+piYHGECVWL17WuKt+UdUAq0O9gjNN+hKd4r X-Received: by 2002:a63:fe53:: with SMTP id x19mr14448926pgj.449.1618887022463; Mon, 19 Apr 2021 19:50:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618887022; cv=none; d=google.com; s=arc-20160816; b=EVJlz5JGOHhO8wHgD4CjXZ5SNf+qhYUM3a36bmQfKfkldKMOKvEFef8E1IHBstXGtv KCdR+11qtFInHfO1p50smX2mVYghgkMFTiboHFE9cgKam1CnOYCw7mGW6LzbSA69Mlkq AhilE72p23IyZcx4KNysQRYyiKJPQn6REMywC/XwNTZB90pxUkFQMnC8hXAHKz65BL4O qum76rf8vZaoyapeylr7hWSk4/vISXcRSfee/Aqgjz/ddZNDM8IeQl623t4XycC5aOSQ 0C+/0l8mru4lDl2yNX8RvSsLMzVcqks+sBgU/RnFwOBXWoMqQxcwGAHww7lrECa9LMdT c5Nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from:ironport-sdr :ironport-sdr; bh=TOGE8J0gpHxgQsCICwk7SPS0gtBLmgnV0SEMYdSnM0c=; b=RaRKFo0qrZGc6Q8fTRBmBOvRsK4dZSclzVxJoOvl92km2pjEyc+iNwsgWiHJA4uD6G 8DefsRzp2yulT0kdq+m6vIuN2UCTLwCaOhSMlCOab0vXAER5qKVcW35zNLuRS/iyrXig Yz+a51YCp7EUtZOIMOmcj0yDkRfEapq51ncnxDw53SbaDEC3Ly9cY3KzSz/ELD/EnJYK tGnOSL7Kj01a+Lgso9uo7Xj1RAI4X0TBe58fAmIjESqkY1cS+XbBXJm1llaVTVe9V1K1 r8cddkIWUougBcSTxTs35b4TZsVXWaNeXt7BsiBTSc73fleXM0sYJdohe49gjUfiuPW0 NMqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m18si18398220pfo.85.2021.04.19.19.50.10; Mon, 19 Apr 2021 19:50:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229667AbhDTCuK (ORCPT + 99 others); Mon, 19 Apr 2021 22:50:10 -0400 Received: from mga05.intel.com ([192.55.52.43]:64046 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229508AbhDTCuK (ORCPT ); Mon, 19 Apr 2021 22:50:10 -0400 IronPort-SDR: 0UlayDdUJWfk2YeLyjMNpR1kfzId1HhLio17rBpFch6WvYKNsYe9NlfCO7mKMPTqCyl9ujf40O ehyRgiR6rpzA== X-IronPort-AV: E=McAfee;i="6200,9189,9959"; a="280758686" X-IronPort-AV: E=Sophos;i="5.82,235,1613462400"; d="scan'208";a="280758686" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2021 19:49:39 -0700 IronPort-SDR: rTnn6ycqI0aiWmbkDOqGJ7/a9qIe/xFdKLSNYge8jfGYHa47etVRhbcqrizoDTs9ywOI3wpqGF hc1GlQ7pYg9g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,235,1613462400"; d="scan'208";a="523636963" Received: from ipu5-build.bj.intel.com ([10.238.232.202]) by fmsmga001.fm.intel.com with ESMTP; 19 Apr 2021 19:49:35 -0700 From: Bingbu Cao To: linux-kernel@vger.kernel.org, stable.vger.kernel.org@vger.kernel.org, linux-pci@vger.kernel.org, iommu@lists.linux-foundation.org Cc: dwmw2@infradead.org, baolu.lu@linux.intel.com, joro@8bytes.org, will@kernel.org, bhelgaas@google.com, rajatja@google.com, grundler@chromium.org, tfiga@chromium.org, senozhatsky@chromium.org, sakari.ailus@linux.intel.com, andriy.shevchenko@linux.intel.com, bingbu.cao@intel.com, bingbu.cao@linux.intel.com Subject: [PATCH v2] iommu/vt-d: Use passthrough mode for the Intel IPUs Date: Tue, 20 Apr 2021 10:42:36 +0800 Message-Id: <1618886556-6412-1-git-send-email-bingbu.cao@intel.com> X-Mailer: git-send-email 2.7.4 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Fixes: 26f5689592e2 ("media: staging/intel-ipu3: mmu: Implement driver") Signed-off-by: Bingbu Cao --- Changes since v1: - Use IPU PCI DID value instead of macros to align with others - Check IPU PCI device ID in quirk --- drivers/iommu/intel/iommu.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index ee0932307d64..7e2fbdae467e 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -55,6 +55,12 @@ #define IS_GFX_DEVICE(pdev) ((pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY) #define IS_USB_DEVICE(pdev) ((pdev->class >> 8) == PCI_CLASS_SERIAL_USB) #define IS_ISA_DEVICE(pdev) ((pdev->class >> 8) == PCI_CLASS_BRIDGE_ISA) +#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 IS_AZALIA(pdev) ((pdev)->vendor == 0x8086 && (pdev)->device == 0x3a3e) #define IOAPIC_RANGE_START (0xfee00000) @@ -360,6 +366,7 @@ int intel_iommu_enabled = 0; EXPORT_SYMBOL_GPL(intel_iommu_enabled); static int dmar_map_gfx = 1; +static int dmar_map_ipu = 1; static int dmar_forcedac; static int intel_iommu_strict; static int intel_iommu_superpage = 1; @@ -368,6 +375,7 @@ static int iommu_skip_te_disable; #define IDENTMAP_GFX 2 #define IDENTMAP_AZALIA 4 +#define IDENTMAP_IPU 8 int intel_iommu_gfx_mapped; EXPORT_SYMBOL_GPL(intel_iommu_gfx_mapped); @@ -2839,6 +2847,9 @@ static int device_def_domain_type(struct device *dev) if ((iommu_identity_mapping & IDENTMAP_GFX) && IS_GFX_DEVICE(pdev)) return IOMMU_DOMAIN_IDENTITY; + + if ((iommu_identity_mapping & IDENTMAP_IPU) && IS_INTEL_IPU(pdev)) + return IOMMU_DOMAIN_IDENTITY; } return 0; @@ -3278,6 +3289,9 @@ static int __init init_dmars(void) if (!dmar_map_gfx) iommu_identity_mapping |= IDENTMAP_GFX; + if (!dmar_map_ipu) + iommu_identity_mapping |= IDENTMAP_IPU; + check_tylersburg_isoch(); ret = si_domain_init(hw_pass_through); @@ -5622,6 +5636,18 @@ static void quirk_iommu_igfx(struct pci_dev *dev) dmar_map_gfx = 0; } +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; +} + /* G4x/GM45 integrated gfx dmar support is totally busted. */ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2a40, quirk_iommu_igfx); DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e00, quirk_iommu_igfx); @@ -5657,6 +5683,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); + static void quirk_iommu_rwbf(struct pci_dev *dev) { if (risky_device(dev)) -- 2.7.4