Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5075239ybv; Mon, 17 Feb 2020 11:43:31 -0800 (PST) X-Google-Smtp-Source: APXvYqykdQ6+vsseSN+eY5OOJ8oAE8PPniTwkpPrg0rTRIfNjbJ8fq8Bsx4BgXL1xTTON2FtRK5m X-Received: by 2002:a05:6830:1188:: with SMTP id u8mr13339799otq.274.1581968610979; Mon, 17 Feb 2020 11:43:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581968610; cv=none; d=google.com; s=arc-20160816; b=vNHcEkzD7X0rpNdiU/+4KC54PcSLvdffQbZTc0fEEj1gF4EeuuwWaWr+r2234oqgtt HX2shBKNz/HoimL4WKLPnP435t+3NXP6YBbB4TicwgMeuxGJ+vXJi1140yuYBF/+rROw iAfXinq9rnuTPjdDIc78PM53omsLnhnAwsgQyuzDilCQzCnfpGG3pD0FLTmQa2PgV426 G+d+doQSAoQTAaAJYkU7oYVY9pKP0m/tcRVK8FyxxEi5+CLPgG9id34ahtKacuil2qSd WqPB+H/iyFcXPPRpx+aBa3NDEXtwMeR9cqnMCpaM3bqv+w2SPpdHvFPfQlxDLX7/Try0 2SCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=Dq2d7ZLRDv9hNiR4QrEMZd9LRdawhCAKqkMh6NWGtiA=; b=Xh56NAzK6PDzOAP8V3CGYYcQRFfGzD67RQvnVOZiUkj8E3XD3PKkBZ3asW83IB+38y EQqaf+jwJ3MlOui6FGs9ZVjSk9XP1rg88gtqz7KVise3rwqaUxgjVUvSbLAdbaSKH4sc EqaUlAlouviqUvc3Ye3ABTmAKsO3EjqHLNj73MuXsfIQu5jv2I1LcrxGrfHDNdglmsvU TjrF7EJxMCS8ih7kcWeWVZWp08bIyzivsS891Cc4dVFCM1dg9FZPm5rlHt0nvErKXLOv 4O3MYxUKzjVnw12WQu6wnsfwTgeQ7VGWxogBWazprWlrvHdqxQXycP4Wbjes2DUOVXvT g0Qg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f190si7277629oig.229.2020.02.17.11.43.19; Mon, 17 Feb 2020 11:43:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729606AbgBQTjJ (ORCPT + 99 others); Mon, 17 Feb 2020 14:39:09 -0500 Received: from 8bytes.org ([81.169.241.247]:54520 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729324AbgBQTjI (ORCPT ); Mon, 17 Feb 2020 14:39:08 -0500 Received: by theia.8bytes.org (Postfix, from userid 1000) id 106255BB; Mon, 17 Feb 2020 20:39:07 +0100 (CET) From: Joerg Roedel To: Lu Baolu , David Woodhouse Cc: Joerg Roedel , jroedel@suse.de, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/5] iommu/vt-d: Do deferred attachment in iommu_need_mapping() Date: Mon, 17 Feb 2020 20:38:56 +0100 Message-Id: <20200217193858.26990-4-joro@8bytes.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200217193858.26990-1-joro@8bytes.org> References: <20200217193858.26990-1-joro@8bytes.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel The attachment of deferred devices needs to happen before the check whether the device is identity mapped or not. Otherwise the check will return wrong results, cause warnings boot failures in kdump kernels, like WARNING: CPU: 0 PID: 318 at ../drivers/iommu/intel-iommu.c:592 domain_get_iommu+0x61/0x70 [...] Call Trace: __intel_map_single+0x55/0x190 intel_alloc_coherent+0xac/0x110 dmam_alloc_attrs+0x50/0xa0 ahci_port_start+0xfb/0x1f0 [libahci] ata_host_start.part.39+0x104/0x1e0 [libata] With the earlier check the kdump boot succeeds and a crashdump is written. Signed-off-by: Joerg Roedel --- drivers/iommu/intel-iommu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 42cdcce1602e..32f43695a22b 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -2541,9 +2541,6 @@ static void do_deferred_attach(struct device *dev) static struct dmar_domain *deferred_attach_domain(struct device *dev) { - if (unlikely(attach_deferred(dev))) - do_deferred_attach(dev); - return find_domain(dev); } @@ -3595,6 +3592,9 @@ static bool iommu_need_mapping(struct device *dev) if (iommu_dummy(dev)) return false; + if (unlikely(attach_deferred(dev))) + do_deferred_attach(dev); + ret = identity_mapping(dev); if (ret) { u64 dma_mask = *dev->dma_mask; -- 2.17.1