Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp113042ybv; Tue, 4 Feb 2020 17:29:28 -0800 (PST) X-Google-Smtp-Source: APXvYqyvObjCktJV1w6t0n+TjMZF9eaX0jd7MDFSP6nxWz7by+GgGmUF2TQTkaOJme4Y7I7sE+Mb X-Received: by 2002:a05:6830:10d7:: with SMTP id z23mr23944684oto.114.1580866168713; Tue, 04 Feb 2020 17:29:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580866168; cv=none; d=google.com; s=arc-20160816; b=H2x/J0M9z0xphhsd4+qLiLd7kWjGg1LdOwFVrdt+1dC5mRulh3ldJLAKckMBVXuTDy FVM/cEF1ymEBZD4xaMySTx4Sf9loDPpHyldYQbbcS6mc+DjO+vHmoIkf0PvDq1EfhY77 b6MiaW1OuZFKnWwX2zJFQB2xh7acb7/TG/1Pt+k6aD3TI62XY1SIP+QKeoSmzQ9Cy10A D1JDYqIkNKHR62YOTXQkEoJsQaL5XOeRjlhPbvWYCJOxRt1QHKgGqhKNjhwsUGemv4WS f1DpmnT+zSBKpjeCWyP30dwZF74j6FTnUKq2FEcpae4xHm6fKAQ2c0NX3iBQDNAiZjdJ FO1Q== 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=8nWmTyelX+0JujN3mlDDEMg++gRTkGDwQ3uEWRShlfo=; b=Oc9Ne8BiuGMZ4aUaX9ebvXMY7BxRvHblRoEf2cB0EbRnlRoHwFhQynDfCpwns4qkHO O3M+S+tAalehErQYVk8zDmanInXsASU9YXVN6FpkYiuci/QtPLXR/VJgtPn54lMYUjKu kAYLWH2gE36WRZuc2CJpNP61fGoJvSTUgkXd7l8ucrHBN/skgPe7Uc2sPpdmf5BcCmcg MJrgyLQqITZb9OXVtQMKSTk+FFzPH5dExA9useGea/F4Z6YsO1O3Sa2HK0dtQhuRddOh dT76o56aIl60Q7RWZr4DrF7nYtau+Kw3bo5moX7B+/kmwAYwpNoNp64vDJXK1nxVz4jY Qp3w== 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 y24si11506896oih.24.2020.02.04.17.29.13; Tue, 04 Feb 2020 17:29:28 -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 S1727746AbgBEB2N (ORCPT + 99 others); Tue, 4 Feb 2020 20:28:13 -0500 Received: from mga03.intel.com ([134.134.136.65]:45636 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727674AbgBEB2N (ORCPT ); Tue, 4 Feb 2020 20:28:13 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Feb 2020 17:28:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,403,1574150400"; d="scan'208";a="225690656" Received: from jingyilu-mobl2.ccr.corp.intel.com (HELO [10.254.209.127]) ([10.254.209.127]) by fmsmga008.fm.intel.com with ESMTP; 04 Feb 2020 17:28:10 -0800 Subject: Re: [PATCH] iommu/intel-iommu: set as DUMMY_DEVICE_DOMAIN_INFO if no IOMMU To: Jian-Hong Pan Cc: David Woodhouse , Joerg Roedel , iommu@lists.linux-foundation.org, Linux Kernel , Linux Upstreaming Team References: <20200203091009.196658-1-jian-hong@endlessm.com> From: Lu Baolu Message-ID: <948da337-128f-22ae-7b2e-730b4b8da446@linux.intel.com> Date: Wed, 5 Feb 2020 09:28:09 +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: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 2020/2/4 17:25, Jian-Hong Pan wrote: > Lu Baolu 於 2020年2月4日 週二 下午2:11寫道: >> >> 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? > > Do you mean is the device in DMA Remapping table? > Dump DMAR from ACPI table. The device is not in the table. > So, it does not support DMAR, Intel IOMMU. > > Or, should device_to_iommu be invoked in iommu_need_mapping to check > IOMMU feature again? > Normally intel_iommu_add_device() should only be called for PCI devices and APCI name space devices (reported in ACPI/DMAR table). In both cases, device_to_iommu() should always return a corresponding iommu. I just tried to understand why it failed for your case. Best regards, baolu