Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5995893ybv; Tue, 18 Feb 2020 07:54:50 -0800 (PST) X-Google-Smtp-Source: APXvYqxMTTkkc/88EZHAC+6c5Ix9rHITVOEjQl0Og08ND8eciCZsS/GAwnl2Ci9Uo4O/K77AcRSg X-Received: by 2002:aca:5844:: with SMTP id m65mr1673521oib.136.1582041290033; Tue, 18 Feb 2020 07:54:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582041290; cv=none; d=google.com; s=arc-20160816; b=lqiubWjo+HXyojxslZO53zL/G60cwAF0Q0hZF/mi38UDCyvacnPa9tF6QzIQyg0TIP PZCbPjMKlppB9cOaMvlxPGragNOV8PeRM+zlZghJJJxNSdJpRg6Y2Jo2moRFfStrSSEu qXWDrlBjmAvOB5Bq6Z/Ld3sIQiLMzgLRX87NUtWOPOijoYrs5cFlF6A0VA6r8v7z74U9 bb/lppCa6Io7puJdOdNstAtAWHop2OFfQm1zGUSJlfwDUHy+yks4ClT5PcswYTe1pN1t bewlFxrEzCwJcFOeXTGAyoEFE3a5yhUpE2ijtAEqIffvdsTFR0Z2/pgNTjx7LI1RpRNM VNug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:mail-followup-to:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=Q+LvgNaJ530nPcNkzsaYj3wiY+FNtaDd/w1XVB2i/Z8=; b=k70nTZKxABtZIb08O5R6Y08iaXhHY2fbIEIJvxRKMyB2+ML0YlCglhpoqZnS8a8Vw5 S430NT+Wj0eAuL6Op4+ch871BSKhQQdOHjXjmXYdFcxKXkTxdx7bLRUWInGTngO2Mfax oWAWegU704kJoixnNmntDID/xYxZxW1kJAnOpy7KQQK91k5A7/qaTaV65z04jgLpHtYh D6kk5BOiZyznuT2WzJWIs0W9/ox79wrihNEjKqL27rc6pbdsux3Y/WqPLL2uou5YEgJ2 vhV2mLx0Q4XbaJ5k9+O+/oMvc8BQ7ZrTDqacx9zmbM/aQrW7QZFlQK+MkbHUxCD28ZDR Wivw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RQHiDiSJ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d23si8393108oij.270.2020.02.18.07.54.36; Tue, 18 Feb 2020 07:54:50 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RQHiDiSJ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726546AbgBRPxY (ORCPT + 99 others); Tue, 18 Feb 2020 10:53:24 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:54050 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726373AbgBRPxY (ORCPT ); Tue, 18 Feb 2020 10:53:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582041203; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=Q+LvgNaJ530nPcNkzsaYj3wiY+FNtaDd/w1XVB2i/Z8=; b=RQHiDiSJKdxFItonq5XUCHEVV+fB+qM38c9nBpBfGwU7gRbG4uJxcTdQxbcemzU7RiZEDZ KrDBCazsbfUY57AtC/ipE8yO+f9yEveVjV5syrKeYY+69qBsG0Ej8H1K3HdNaKkm75Efke 9gcdt5v2UOdTXskOqgmE6yjuSne5ksk= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-393-szdE0gK1MwSFkEVpoRqaOg-1; Tue, 18 Feb 2020 10:53:14 -0500 X-MC-Unique: szdE0gK1MwSFkEVpoRqaOg-1 Received: by mail-qt1-f197.google.com with SMTP id x8so13379677qtq.14 for ; Tue, 18 Feb 2020 07:53:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:reply-to :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=Q+LvgNaJ530nPcNkzsaYj3wiY+FNtaDd/w1XVB2i/Z8=; b=clYN3Eo3Mm9Jw7sx+CJ71msHIKYROcQe4Xyprx3PhgFibOQFUoxFLA/+PDid1wZydo AyS9yaGRJ54A0o/cIE2y/2MoJ28BbZ5s+KppBnfC4o5DI4X4XVWqVXnN7zM+YYmoIQTC 54W7GhStlBlgP0kbQeZHrQ7NRHtKW/SsoTWEzkW51/2kdsNAhPCqp7H66Lgwf3naTQ7L 3FkSen5ZEUXzDcvhWwlqzNQ7jfYIPYfxqrUz0ClcYOss2JkUGD187Ls4Q2t+U1ePPI1H lw/y1t6nh64yBx22j5oj2nV5FwHkOAGZ0b5hD1xhYAeHCB27bfDdzzGmcVlAtfKWGA0s 1jSw== X-Gm-Message-State: APjAAAXU+ylo1G7agnl7QpJTKcHyAokOsU4QnO88TUKtce67YBY49dh4 jX2r/UrwOruMEfHhv2eui+mZNeZCKV38bz1RagiKUQHaNhjg/qSFq4aoZ8WQiyXqMgvhU9Y9Dq8 /n4Pkk4WPmHb5QUEKeRfBFEJF X-Received: by 2002:ac8:2a55:: with SMTP id l21mr18262804qtl.111.1582041193920; Tue, 18 Feb 2020 07:53:13 -0800 (PST) X-Received: by 2002:ac8:2a55:: with SMTP id l21mr18262775qtl.111.1582041193542; Tue, 18 Feb 2020 07:53:13 -0800 (PST) Received: from localhost (ip70-163-223-149.ph.ph.cox.net. [70.163.223.149]) by smtp.gmail.com with ESMTPSA id x3sm2037808qts.35.2020.02.18.07.53.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Feb 2020 07:53:12 -0800 (PST) Date: Tue, 18 Feb 2020 08:53:11 -0700 From: Jerry Snitselaar To: Joerg Roedel Cc: Lu Baolu , iommu@lists.linux-foundation.org, jroedel@suse.de, David Woodhouse , linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/5 v2] iommu/vt-d: Do deferred attachment in iommu_need_mapping() Message-ID: <20200218155311.kt6fd25odl2gzu2t@cantor> Reply-To: Jerry Snitselaar Mail-Followup-To: Joerg Roedel , Lu Baolu , iommu@lists.linux-foundation.org, jroedel@suse.de, David Woodhouse , linux-kernel@vger.kernel.org References: <20200217193858.26990-1-joro@8bytes.org> <20200217193858.26990-4-joro@8bytes.org> <83b21e50-9097-06db-d404-8fe400134bac@linux.intel.com> <20200218092827.tp3pq67adzr56k7e@8bytes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline In-Reply-To: <20200218092827.tp3pq67adzr56k7e@8bytes.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue Feb 18 20, Joerg Roedel wrote: >Hi Baolu, > >On Tue, Feb 18, 2020 at 10:38:14AM +0800, Lu Baolu wrote: >> > 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); >> > - >> >> This should also be moved to the call place of deferred_attach_domain() >> in bounce_map_single(). >> >> bounce_map_single() assumes that devices always use DMA domain, so it >> doesn't call iommu_need_mapping(). We could do_deferred_attach() there >> manually. > >Good point, thanks for your review. Updated patch below. > >From 3a5b8a66d288d86ac1fd45092e7d96f842d0cccf Mon Sep 17 00:00:00 2001 >From: Joerg Roedel >Date: Mon, 17 Feb 2020 17:20:59 +0100 >Subject: [PATCH 3/5] iommu/vt-d: Do deferred attachment in > iommu_need_mapping() > >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 Reviewed-by: Jerry Snitselaar