Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1692324yba; Thu, 9 May 2019 22:37:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqxvT06Huf5Vd4921jxC+HnVWrHbHricxhdgzEK8iMa6a+BHpO31Q8iRwj91Toe0QCH9+SqB X-Received: by 2002:a17:902:8bca:: with SMTP id r10mr10652902plo.67.1557466629313; Thu, 09 May 2019 22:37:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557466629; cv=none; d=google.com; s=arc-20160816; b=bFaYoAa6qOANGmDUp4G5TZqpJSKawa5kbM2iZ8L3+N7e2pzrkIWs+696QjxcAcMuC0 M+TLYP7ebfjwuYP0+vfzwZ/K3knM7Lw8spscVFUwvcT9BHKUnTJQv3EDMd9TV/sGyj79 cmggfUWLFe3G+GHHad70cJbS16hTiD/RlTCAm+Vn0S+7g4a2wajnZ+R07QlQeltEn3lx ud8q4twkd3ZcrCbFxvjjrhFcp3fB9FkG81uWU3a4csrOBO4/6oAwfBaOZNdxzN8a3YM2 r5MBStTGHEAOnA3F9M6pFMI51sjjNnyEmDtj1ZrxoGMAvDS8YZbK9FqBOn9T5J/yLYSP iV/w== 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=yrzJGHURrX8BTR5AqvFxcHcgWjSCEFtxzKQVr/N/8Wg=; b=ykUvN8hZ9Ggrtc9l9/Sq+AUusok7rwQgR/XY2Z6SbYpGEX/5WKZxr0P23n543grUtj +bAoq3u3HjONeViYEN6mpsJO/k9VIllSACl3qIiAUGfH6zDF0S315AKQAILZGD9ccbDU oA4lzQN+t65ILOz8F06B1lgtxMfDKgw8k0L74TX2CR2+hJSMel9LxAmuwuwvCAqJ9JzJ c5ucwnascF/iaXDfdtpLux51fKDdUiIsHf5DC3oFIsTwSCkaHsGOZKh90EYijO4T456y 4H14TAMQj7FcIIm3PV+bFetZQez214cqprsG5fESNLqYj2+h9S/jQ20KzIzJkwt3C9hP EZ0Q== 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 d16si6217376pfr.229.2019.05.09.22.36.52; Thu, 09 May 2019 22:37:09 -0700 (PDT) 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 S1726964AbfEJFgC (ORCPT + 99 others); Fri, 10 May 2019 01:36:02 -0400 Received: from mga03.intel.com ([134.134.136.65]:1335 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725927AbfEJFgC (ORCPT ); Fri, 10 May 2019 01:36:02 -0400 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; 09 May 2019 22:36:01 -0700 X-ExtLoop1: 1 Received: from allen-box.sh.intel.com (HELO [10.239.159.136]) ([10.239.159.136]) by fmsmga008.fm.intel.com with ESMTP; 09 May 2019 22:35:59 -0700 Cc: baolu.lu@linux.intel.com, "Tian, Kevin" , Ashok Raj , Dmitry Safonov , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, jacob.jun.pan@intel.com, David Woodhouse Subject: Re: [PATCH v3 1/8] iommu: Add ops entry for supported default domain type To: Robin Murphy , Tom Murphy References: <20190429020925.18136-1-baolu.lu@linux.intel.com> <20190429020925.18136-2-baolu.lu@linux.intel.com> <3e0da076-4916-1a02-615c-927c1b3528b8@linux.intel.com> <56205a21-c72f-a460-77a2-4bb4f46f6e08@arm.com> From: Lu Baolu Message-ID: <6dbbfc10-3247-744c-ae8d-443a336e0c50@linux.intel.com> Date: Fri, 10 May 2019 13:29:30 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <56205a21-c72f-a460-77a2-4bb4f46f6e08@arm.com> 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 Robin, On 5/10/19 12:11 AM, Robin Murphy wrote: > On 09/05/2019 03:30, Lu Baolu wrote: >> Hi Robin, >> >> On 5/7/19 6:28 PM, Robin Murphy wrote: >>> On 06/05/2019 16:32, Tom Murphy via iommu wrote: >>>> The AMD driver already solves this problem and uses the generic >>>> iommu_request_dm_for_dev function. It seems like both drivers have the >>>> same problem and could use the same solution. Is there any reason we >>>> can't have use the same solution for the intel and amd driver? >>>> >>>> Could we justĀ  copy the implementation of the AMD driver? It would be >>>> nice to have the same behavior across both drivers especially as we >>>> move to make both drivers use more generic code. >>> >>> TBH I don't think the API really needs to be involved at all here. >>> Drivers can already not provide the requested default domain type if >>> they don't support it, so as long as the driver can ensure that the >>> device ends up with IOMMU or direct DMA ops as appropriate, I don't >>> see any great problem with drivers just returning a passthrough >>> domain when a DMA domain was requested, or vice versa (and logging a >>> message that the requested type was overridden). The only type that >>> we really do have to honour strictly is non-default (i.e. unmanaged) >>> domains. >> >> I agree with you that we only have to honor strictly the non-default >> domains. But domain type saved in iommu_domain is consumed in iommu.c >> and exposed to user through sysfs. It's not clean if the iommu driver >> silently replace the default domain. > > Right, I did get a bit ahead of myself there - the implicit step before > that is to fix default domain allocation so that the core actually > passes the relevant device which it has to hand, such that the IOMMU > drivers *can* make the right decision up-front. > Yes, passing the relevant device when allocating the default domain so that the IOMMU driver could make right decision seems to be a better solution. Somebody can come up with a patch set to bring this up for discussion. I won't include this in this patch set since it's not for that purpose. I will follow the existing mechanism that is using on amd and other iommu drivers. Best regards, Lu Baolu