Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13476237ybl; Sun, 29 Dec 2019 12:49:45 -0800 (PST) X-Google-Smtp-Source: APXvYqyryOsytQnUychJxEqE5SlEBEooKqKTZoINVP5J0vywElaN0Bi86x/mKTg9CnEnAZ3ie7Ho X-Received: by 2002:a9d:6516:: with SMTP id i22mr52472744otl.94.1577652585762; Sun, 29 Dec 2019 12:49:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577652585; cv=none; d=google.com; s=arc-20160816; b=upljBLAOUUQj1DiqHeI2No1RwvdV3xROFGkCQSzr8X7pSYxCz1ATtbI0hGUtaJ8LYs NpxRSUNI1mQ+A0oFPiDSWbYH2av6NpbcugkwmhxjtbVpnm4VQFGDL4nV6Pxk4JCnbhsP 7awCKGfVYH+//jN9fpKvPJFryFd/MDkU3f4J8cUkhOun36ZWyefZpULSbXfarQTVyRil kPov0BYFsiVJmaRiA8BJFVDln73X5PhUIWZijG+0tPSuqp3foB+lMDQwhQkZ/cUfB5gq qE49mugebt7zlfFDXDSIHcF9b5oGUNDRm4EVWqJ3sVpggx26Vb35aLI1w+GIbEQ6N6Kh dQVA== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IHt+j63KuVoTS1YRueh1WH9sx9Ygz4OotbrxPsrcibc=; b=XB7UAWZH+qAFM1NtwkGmyscUHXfhfadFkFBmYcXdSLXOsqvv5WxlH+3qr+OWvdjoS/ 0+ulGmQrfiyvtvFi1+XemACfJiS7Jgy6tqCqNduOvY3sqljbXPIEEjGAKnR9yfG36xnV C6ASInLeM58ekBy2WS9TkNzfGhubcvrJnx7tN2uUkGhZHlUNobag7JSpY5IGei/kodq3 3erKvGR2SihlSNdpE7QBA29ZxWku/ONqvF7ZYDJNA/q2GYx6naUyzqDsQEeBIbYUXipu xM6JpKrVD0Wos/oYHQdrZAEaOF5gYSElTGRqkWS3NgWdOqAmMQMPfkVjup/1HmOfKBqR Hp3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Y6XZWJQi; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u25si19579365otg.170.2019.12.29.12.49.34; Sun, 29 Dec 2019 12:49:45 -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=@kernel.org header.s=default header.b=Y6XZWJQi; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733042AbfL2R4N (ORCPT + 99 others); Sun, 29 Dec 2019 12:56:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:45386 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732568AbfL2R4I (ORCPT ); Sun, 29 Dec 2019 12:56:08 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5007821744; Sun, 29 Dec 2019 17:56:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577642167; bh=n5k8+TCNH9B+qSI6yihNx4FPmGe+bGpxEcJW5s93Il8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y6XZWJQiDMP2xwkyEPNdfjRsjftKp313Bf+AXW74FH+2GOeZyopa+DM3EsxMuDrBd 6hGnin/lK4YlWK2RB7LDGAdpD3xmSZ2Ozc/u8PCaBJgWCowMs6mXZqcoO2ynDpYLhM BUadDPngiZBaIN4IO/ZPWvjE93JO6w18BVL91fiE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joerg Roedel , Lu Baolu , iommu@lists.linux-foundation.org, Jerry Snitselaar Subject: [PATCH 5.4 368/434] iommu: set group default domain before creating direct mappings Date: Sun, 29 Dec 2019 18:27:01 +0100 Message-Id: <20191229172726.418027951@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229172702.393141737@linuxfoundation.org> References: <20191229172702.393141737@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jerry Snitselaar commit d360211524bece6db9920f32c91808235290b51c upstream. 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 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 Reviewed-by: Lu Baolu Signed-off-by: Joerg Roedel Signed-off-by: Greg Kroah-Hartman --- drivers/iommu/iommu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -2221,13 +2221,13 @@ request_default_domain_for_dev(struct de 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");