diff mbox series

[3/8] iommu/vt-d: Use ops->blocked_domain

Message ID 3-v1-8060f06462cc+c0a39-dart_paging_jgg@nvidia.com (mailing list archive)
State New, archived
Headers show
Series iommu: Convert dart & iommufd to the new domain_alloc_paging() | expand

Commit Message

Jason Gunthorpe Sept. 22, 2023, 5:07 p.m. UTC
Trivially migrate to the ops->blocked_domain for the existing global
static.

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
 drivers/iommu/intel/iommu.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Baolu Lu Sept. 25, 2023, 2:29 a.m. UTC | #1
On 9/23/23 1:07 AM, Jason Gunthorpe wrote:
> Trivially migrate to the ops->blocked_domain for the existing global
> static.
> 
> Signed-off-by: Jason Gunthorpe<jgg@nvidia.com>
> ---
>   drivers/iommu/intel/iommu.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)

Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>

P.S. We can further do the same thing to the identity domain. I will
clean it up after all patches are landed.

Best regards,
baolu
Jason Gunthorpe Sept. 25, 2023, 11:41 a.m. UTC | #2
On Mon, Sep 25, 2023 at 10:29:52AM +0800, Baolu Lu wrote:
> On 9/23/23 1:07 AM, Jason Gunthorpe wrote:
> > Trivially migrate to the ops->blocked_domain for the existing global
> > static.
> > 
> > Signed-off-by: Jason Gunthorpe<jgg@nvidia.com>
> > ---
> >   drivers/iommu/intel/iommu.c | 3 +--
> >   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
> 
> P.S. We can further do the same thing to the identity domain. I will
> clean it up after all patches are landed.

I looked at that, and it is not trivial..

Both the Intel and virtio-iommu drivers create an "identity" domain
out of a paging domain and pass that off as a true "identity"
domain. So neither can set the global static since the determination
is at runtime..

What I was thinking about doing is consolidating that code so that the
core logic is the thing turning a paging domain into an identity
domain.

Jason
Baolu Lu Sept. 26, 2023, 3:28 a.m. UTC | #3
On 9/25/23 7:41 PM, Jason Gunthorpe wrote:
> On Mon, Sep 25, 2023 at 10:29:52AM +0800, Baolu Lu wrote:
>> On 9/23/23 1:07 AM, Jason Gunthorpe wrote:
>>> Trivially migrate to the ops->blocked_domain for the existing global
>>> static.
>>>
>>> Signed-off-by: Jason Gunthorpe<jgg@nvidia.com>
>>> ---
>>>    drivers/iommu/intel/iommu.c | 3 +--
>>>    1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
>>
>> P.S. We can further do the same thing to the identity domain. I will
>> clean it up after all patches are landed.
> 
> I looked at that, and it is not trivial..
> 
> Both the Intel and virtio-iommu drivers create an "identity" domain
> out of a paging domain and pass that off as a true "identity"
> domain. So neither can set the global static since the determination
> is at runtime..

Emm, yes. The early hardware requires a real 1:1 mapped page table. The
recent implementations are no longer needed.

> 
> What I was thinking about doing is consolidating that code so that the
> core logic is the thing turning a paging domain into an identity
> domain.

Yes. It's not trivial. Needs a separated series with some refactoring
efforts.

Best regards,
baolu
diff mbox series

Patch

diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 0d0cb2534972a2..b79188d0c67e95 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -4041,8 +4041,6 @@  static struct iommu_domain *intel_iommu_domain_alloc(unsigned type)
 	struct iommu_domain *domain;
 
 	switch (type) {
-	case IOMMU_DOMAIN_BLOCKED:
-		return &blocking_domain;
 	case IOMMU_DOMAIN_DMA:
 	case IOMMU_DOMAIN_UNMANAGED:
 		dmar_domain = alloc_domain(type);
@@ -4803,6 +4801,7 @@  static void *intel_iommu_hw_info(struct device *dev, u32 *length, u32 *type)
 }
 
 const struct iommu_ops intel_iommu_ops = {
+	.blocked_domain		= &blocking_domain,
 	.capable		= intel_iommu_capable,
 	.hw_info		= intel_iommu_hw_info,
 	.domain_alloc		= intel_iommu_domain_alloc,