Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5472818pxb; Wed, 26 Jan 2022 12:50:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJz52XVbpi7jnMLdgTRuRtIwOiPAO7eh98+D73y0HHmRVVYWioeKn6rXxsGU9xfEGUULosmV X-Received: by 2002:a17:907:9603:: with SMTP id gb3mr450838ejc.416.1643230231264; Wed, 26 Jan 2022 12:50:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643230231; cv=none; d=google.com; s=arc-20160816; b=HlyGLM0UuBqdJxIWoD50MllJVPPyaOJ+NigCjYpP7WuBq3+svHncZU6dK66zZvVYag uMS/Qautu2tJmUv1zN1yjVoigWd/L4JWP45CMMNKBzmf4DnsYAgoNw7iUowLhrb/YhtG 5uNuCc5Lyn69MwtbGEZwiYx6irdsRJ1cUh5b1qiRxZ8TYgPBng3njjFReuZZG6jlprR7 4wU3Ca4S1psPQ+oUSt1zYKGU6rF1678L8hC132qhSjYSgqT8CrH8KNZukNDCHRBffSRy lqSvGIHjkktnBYpMz+iUNmIrdL13kblxhQ1795IgoyNJHDozMuwp7mmgbgE0DBFi/D+z hy+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=DgC3fBf+JMernk9UtJYHLs3WXUQ4WF2uVpf9z50+mN4=; b=eprPhNftVHfZhq7YIHP91mUfD1uUo6coZjy/v9c6jhGDckroI3+3llgcpkJtL8b13e tyNkSd5xH/ljDLXxV9/m18rfvI4jk82SBkH72QbHuvrrFBugwY5NvIPUypbLVM0uPCJQ iTsnqkPUlf0vXbnXUSRCgsf7p/JKL980O9kbtVjLbqLLE9w1uABXi6S3T8LXbRnAFiG5 SUtbfk/SzpfGtZpmTf9O3Ix5U4F2F+sc+cgcmhbOIHmOR+IHCY0ty3HW03/IElHUz24z 3oOSGcbzRYb1+eH2LLScmwYNQLoG4a7CRGKEc7+JkE0Fhho7SurJUx3QXu4YcrLStmj/ yS6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KSl6lTYm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z2si179060ejm.243.2022.01.26.12.50.03; Wed, 26 Jan 2022 12:50:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KSl6lTYm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239293AbiAZJlv (ORCPT + 99 others); Wed, 26 Jan 2022 04:41:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239305AbiAZJlj (ORCPT ); Wed, 26 Jan 2022 04:41:39 -0500 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35962C061749 for ; Wed, 26 Jan 2022 01:41:39 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id j5-20020a05600c1c0500b0034d2e956aadso3806345wms.4 for ; Wed, 26 Jan 2022 01:41:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=DgC3fBf+JMernk9UtJYHLs3WXUQ4WF2uVpf9z50+mN4=; b=KSl6lTYmsVi33WHBN3QnElkvHgGznKo+f/d/ZSM8+9YhM6kZn6ta1q4C0eEBpR7H7H q2pHOPd4qHOfapjgox1untAEzse5dCyt6yyT3CefQZZRFK8z0sNVUWu4xyM9qaQ/lCmz +UfOOiLYGJw99mue93gUeV/HldhzX3TQrtN5o5o/ka41LY2jN0+yuckYPwxVyrDXvIKN D7y6CqTsUwSdza5+t0tNt8p0zDQi9zhZNVyhiANXZjPp2NifE/JOmirFKQeBVO8hTTiq 2PmDXc+706mQQ+8M4xyBRdTU9kB6hy0N6wsGZXqd3kgdyQb7qUDcIchacnRsxDTVOvjt Faog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=DgC3fBf+JMernk9UtJYHLs3WXUQ4WF2uVpf9z50+mN4=; b=gKQt/nEHR7owe7wMcGGSmHZH+TFDl+ck4lNewnvgZkG8FOvaCiE+dkkcQSRjkMO/aU E10AZGG/DmzAbpCWmokECvBjszL7HE6v3J9WjxTt6SwAZgzAKfkTE0ZKd8R2qNfvtU56 B/0HEY3FDboarwa9naAcjbtWYKKTvdrvlX7lPSDWHhe2W3BdIHHlH+DuSdXiyaBZ+KCo q7Ek7lblL73aBYMScWvXXV/lLvr+Tocenutw+KxAQgR6a1eSyEBQAyrbeFYxd51dj38U HVP5X+bBrZHp6z4nIqHFkn8fEf1qjHP99y6fGXlfI24lGsATkpQquq+Jyvdvp8EXi1Aj oVug== X-Gm-Message-State: AOAM533EHTskJ4pSBQVeHGuB2Q9+5kdeRnAFPsHxwd84xVZH9HmNx19m amo0Fowq+gKO0Nyfsp9gIjiTXg== X-Received: by 2002:a05:600c:4a09:: with SMTP id c9mr6475785wmp.83.1643190097727; Wed, 26 Jan 2022 01:41:37 -0800 (PST) Received: from myrica (cpc92880-cmbg19-2-0-cust679.5-4.cable.virginm.net. [82.27.106.168]) by smtp.gmail.com with ESMTPSA id m4sm2710543wmc.1.2022.01.26.01.41.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jan 2022 01:41:36 -0800 (PST) Date: Wed, 26 Jan 2022 09:41:13 +0000 From: Jean-Philippe Brucker To: Jason Gunthorpe Cc: "Tian, Kevin" , Lu Baolu , Joerg Roedel , Christoph Hellwig , Ben Skeggs , "Raj, Ashok" , Will Deacon , Robin Murphy , David Airlie , "linux-kernel@vger.kernel.org" , "iommu@lists.linux-foundation.org" , Jonathan Hunter , Alex Williamson , Thierry Reding , "Pan, Jacob jun" , Daniel Vetter Subject: Re: [PATCH 7/7] iommu: Add iommu_domain::domain_ops Message-ID: References: <20220124071103.2097118-1-baolu.lu@linux.intel.com> <20220124071103.2097118-8-baolu.lu@linux.intel.com> <20220124163302.GC966497@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220124163302.GC966497@nvidia.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 24, 2022 at 12:33:02PM -0400, Jason Gunthorpe wrote: > On Mon, Jan 24, 2022 at 10:16:07AM +0000, Jean-Philippe Brucker wrote: > > On Mon, Jan 24, 2022 at 09:58:18AM +0000, Tian, Kevin wrote: > > > > From: Lu Baolu > > > > Sent: Monday, January 24, 2022 3:11 PM > > > > +/** > > > > + * struct domain_ops - per-domain ops > > > > + * @attach_dev: attach an iommu domain to a device > > > > + * @detach_dev: detach an iommu domain from a device > > > > > > What is the criteria about whether an op should be iommu_ops or domain_ops > > > when it requires both domain and device pointers like above two (and future > > > PASID-based attach)? > > > > > > Other examples include: > > > @apply_resv_region > > > @is_attach_deferred > > > > Could attach_dev() be an IOMMU op? So a driver could set the domain ops > > in attach_dev() rather than domain_alloc(). That would allow to install > > map()/unmap() ops that are tailored for the device's IOMMU, which we don't > > know at domain_alloc() time. > > I think we should be moving toward 'domain_alloc' returning the > correct domain and the way the driver implements the domain shouldn't > change after that. > > > I'm thinking about a guest that has both physical and virtual > > endpoints, which would ideally use different kinds of domain ops to > > support both efficiently (caching mode vs page tables) > > In this case shouldn't domain_alloc() reached from the struct device > already do the correct thing? Sure, if we can finalise the domains before attach that could also clean up the drivers a bit. Thanks, Jean