Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4599583ybl; Mon, 3 Feb 2020 22:13:27 -0800 (PST) X-Google-Smtp-Source: APXvYqznSlRg37Lwkgh7UEXt/Ah78EnqqVXWyOyz89BwArLVzmsH1h7sgJC1wWop6j1uPbSo7Lco X-Received: by 2002:a9d:12a8:: with SMTP id g37mr21516462otg.261.1580796807521; Mon, 03 Feb 2020 22:13:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580796807; cv=none; d=google.com; s=arc-20160816; b=xSEwB6tyy9x6vIEnRxbQ1YFC2yJrrANTbSR3rQ0rMyJkh4ujQ7J7MNNitHtheY4dCq mTjiyZ8jm2B5HmON5YQ7eGmg/yq/3zh5d8GYvLQFZKTMlQhko7X2WJ7I6l7z1BPqVLaq Y9zWfjr7fkTVyBRiK4JUxOHR8PGIqwh333+tdFch0UdtGvBZbXQAweFg7A5ZE8oCJvfl /RoKUX7R1GUh4C1g1hpnPwEfO3s9bIdls525LlCe4sloZx46hO8/2ObRsOmoiTA4N5Q2 PD+G+RgEgW7N0Niy7QJG2yRfUlGGKiepmykHlFzOoaiRmLWwQWPa5fASVrCOl0ArLhMC NqXA== 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:cc:to:subject; bh=Elg8GWEff0BWNA47z475CGHnb5fE2updTsFw9DNh8/g=; b=qlNuTRT8LR7cCoRwa+IFDJCKL3yKEMueyHDyXjRZPH3SmZiHvh/bIzXJt8Q9OOWM5X FBe7txiJvyy/DvuS2BRBzSB226/Qyx6wSSMUj3xCIDBiH6BnpaH5GFC5OSxyVojzIcFs ZoR/ULHVBS0JpJIPeCbOajHZM3WNPWxEDuZxwuUbAsuNlnYvrttPziGp6XTekdJNJunD PBo0s7S0BEA7+UTUKir/6XR8tttE5l2DTG4Apf0U2QCBMbOWwk3kG5FLeKXqUJLfaNY/ pMnfs+SmvLDnyRe8cuU+yckp4/TrDwIa0zCvWi5Mymd1Kg7MyBnI9YAqBWBBx4u7qAl1 BbUw== 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 i9si10995916otp.139.2020.02.03.22.13.13; Mon, 03 Feb 2020 22:13:27 -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 S1726343AbgBDGLs (ORCPT + 99 others); Tue, 4 Feb 2020 01:11:48 -0500 Received: from mga09.intel.com ([134.134.136.24]:38538 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725834AbgBDGLs (ORCPT ); Tue, 4 Feb 2020 01:11:48 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Feb 2020 22:11:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,398,1574150400"; d="scan'208";a="254308213" Received: from blu2-mobl3.ccr.corp.intel.com (HELO [10.254.209.105]) ([10.254.209.105]) by fmsmga004.fm.intel.com with ESMTP; 03 Feb 2020 22:11:46 -0800 Subject: Re: [PATCH] iommu/intel-iommu: set as DUMMY_DEVICE_DOMAIN_INFO if no IOMMU To: Jian-Hong Pan , David Woodhouse , Joerg Roedel Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux@endlessm.com References: <20200203091009.196658-1-jian-hong@endlessm.com> From: Lu Baolu Message-ID: Date: Tue, 4 Feb 2020 14:11:45 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.4.2 MIME-Version: 1.0 In-Reply-To: <20200203091009.196658-1-jian-hong@endlessm.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 2020/2/3 17:10, Jian-Hong Pan wrote: > If the device has no IOMMU, it still invokes iommu_need_mapping during > intel_alloc_coherent. However, iommu_need_mapping can only check the > device is DUMMY_DEVICE_DOMAIN_INFO or not. This patch marks the device > is a DUMMY_DEVICE_DOMAIN_INFO if the device has no IOMMU. > > Signed-off-by: Jian-Hong Pan > --- > drivers/iommu/intel-iommu.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c > index 35a4a3abedc6..878bc986a015 100644 > --- a/drivers/iommu/intel-iommu.c > +++ b/drivers/iommu/intel-iommu.c > @@ -5612,8 +5612,10 @@ static int intel_iommu_add_device(struct device *dev) > int ret; > > iommu = device_to_iommu(dev, &bus, &devfn); > - if (!iommu) > + if (!iommu) { > + dev->archdata.iommu = DUMMY_DEVICE_DOMAIN_INFO; Is this a DMA capable device? I am afraid some real bugs might be covered up if we marking the device as IOMMU dummy here. Best regards, baolu > return -ENODEV; > + } > > iommu_device_link(&iommu->iommu, dev); > >