Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp26229ybl; Tue, 10 Dec 2019 16:55:52 -0800 (PST) X-Google-Smtp-Source: APXvYqzLxVoun6nWD2o2zAxqzNF8OvkLsXp3dWI36Mp11Bpbj65AfVldKcckE/2tr57GtdXFIpDt X-Received: by 2002:a05:6808:681:: with SMTP id k1mr736478oig.117.1576025751974; Tue, 10 Dec 2019 16:55:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576025751; cv=none; d=google.com; s=arc-20160816; b=Qge9Il7XTkd6M961eV0p4kjeXq019R+4DYEg4otwlWKFRo8pJ6lTexjuyXoGb4KPgs FGHB3+pwXrcQh/xCzrx/ychwdtyu70u6ZZDBcJbGQaNXN7eIKlkalWKKGvFVHKY8R9UK iS1OuS9AIUj+R0NAtntP4oUbFXt9uCrGbo7BudNLjV6TgjeKlIeFbDqIZjJv/OAOuK4K bv4bz2YAdI2pvyZkQSAdRecAOQFathxAMUT+jLNtTjly97g1S3F+iHQJj3KpUhg40XNA ea01x34cFWEqjj2Zm/cDybI/CsG5LR4Me9goMYDHmNolv6xC/b3xjR15V32nU7U6dDTF JPJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:cc; bh=rscQwkriVj14I41WJDyVma4zmYwlQBU4ddM4x8JyGp4=; b=w35GuoBbowEJyaA0/dgqDY4eMQNts1zVubT1ul2LZZMmYA/oSsQId+2X+6+eEJXKP4 9gHUok/HXxTKzcO2zBM7XeZkPRyTHR1cbuC4iD5pun3UQlLCR9zPZEYn/0W8DC7Z2iAI BRj2XOSivUBHwcKi12dxi/nAB2b3nv74i4LjZJFVBXl7ob+Y3l4BZFUBZ8bPs4ebYLfC ikQ8LBHC5L/Aj2BodqYnApfq/mTyls3pSuuOVMaKADXMSxjlHaTRgggRjkj5/4Du0cYk OHl1wG07ENebd6Ql9t+o2ucOjBtrE4UAI5JraQFg4VZsOWyDxJHYfAlTbAdp2V4HNghh +2oA== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i6si80291oth.182.2019.12.10.16.55.39; Tue, 10 Dec 2019 16:55:51 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726592AbfLKAzI (ORCPT + 99 others); Tue, 10 Dec 2019 19:55:08 -0500 Received: from mga05.intel.com ([192.55.52.43]:28187 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725999AbfLKAzI (ORCPT ); Tue, 10 Dec 2019 19:55:08 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Dec 2019 16:55:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,301,1571727600"; d="scan'208";a="225336040" Received: from allen-box.sh.intel.com (HELO [10.239.159.136]) ([10.239.159.136]) by orsmga002.jf.intel.com with ESMTP; 10 Dec 2019 16:55:05 -0800 Cc: baolu.lu@linux.intel.com, Joerg Roedel , iommu@lists.linux-foundation.org, stable@vger.kernel.org Subject: Re: [PATCH] iommu: set group default domain before creating direct mappings To: Jerry Snitselaar , linux-kernel@vger.kernel.org References: <20191210185606.11329-1-jsnitsel@redhat.com> From: Lu Baolu Message-ID: <49bca506-1f6a-ab2d-fac0-302073737af7@linux.intel.com> Date: Wed, 11 Dec 2019 08:54:21 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.1 MIME-Version: 1.0 In-Reply-To: <20191210185606.11329-1-jsnitsel@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 12/11/19 2:56 AM, Jerry Snitselaar wrote: > iommu_group_create_direct_mappings uses group->default_domain, but > right after it is called, request_default_domain_for_dev calls > iommu_domain_free for the default domain, and sets the group default > domain to a different domain. Move the > iommu_group_create_direct_mappings call to after the group default > domain is set, so the direct mappings get associated with that domain. > > Cc: Joerg Roedel > Cc: Lu Baolu This fix looks good to me. Reviewed-by: Lu Baolu Best regards, baolu > Cc: iommu@lists.linux-foundation.org > Cc: stable@vger.kernel.org > Fixes: 7423e01741dd ("iommu: Add API to request DMA domain for device") > Signed-off-by: Jerry Snitselaar > --- > drivers/iommu/iommu.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c > index db7bfd4f2d20..fa908179b80b 100644 > --- a/drivers/iommu/iommu.c > +++ b/drivers/iommu/iommu.c > @@ -2282,13 +2282,13 @@ request_default_domain_for_dev(struct device *dev, unsigned long type) > goto out; > } > > - iommu_group_create_direct_mappings(group, dev); > - > /* Make the domain the default for this group */ > if (group->default_domain) > iommu_domain_free(group->default_domain); > group->default_domain = domain; > > + iommu_group_create_direct_mappings(group, dev); > + > dev_info(dev, "Using iommu %s mapping\n", > type == IOMMU_DOMAIN_DMA ? "dma" : "direct"); > >