Re: [PATCH v2 2/6] iommu/vt-d: Remove scalable mode context entry setup from attach_dev

Baolu Lu
2023-12-09T08:01:54Z

On 12/8/23 4:56 PM, Tian, Kevin wrote:
>> From: Lu Baolu <baolu.lu@linux.intel.com>
>> Sent: Tuesday, December 5, 2023 9:22 AM
>>
>> static int domain_context_mapping_one(struct dmar_domain *domain,
>> struct intel_iommu *iommu,
>> - struct pasid_table *table,
>> u8 bus, u8 devfn)
>
> since this is called in legacy now it's clearer to add a legacy_ prefix
> to this and other related functions.

Okay, that would make the code more readable.

>>
>> - /* PASID table is mandatory for a PCI device in scalable mode. */
>> - if (sm_supported(iommu) && !dev_is_real_dma_subdevice(dev)) {
>> - /* Setup the PASID entry for requests without PASID: */
>> - if (hw_pass_through && domain_type_is_si(domain))
>> - ret = intel_pasid_setup_pass_through(iommu,
>> - dev, IOMMU_NO_PASID);
>> - else if (domain->use_first_level)
>> - ret = domain_setup_first_level(iommu, domain, dev,
>> - IOMMU_NO_PASID);
>> - else
>> - ret = intel_pasid_setup_second_level(iommu,
>> domain,
>> - dev, IOMMU_NO_PASID);
>> - if (ret) {
>> - dev_err(dev, "Setup RID2PASID failed\n");
>> - device_block_translation(dev);
>> - return ret;
>> - }
>> - }
>> + if (dev_is_real_dma_subdevice(dev))
>> + return 0;
>
> is it a functional change? old code doesn't early exit for such device.

This type of device is aliased to a RID on another bus. Therefore,
there's no need to set up the context and PASID table for them. I should
make the change mentioned above in a separate patch to make the
background clear.

Best regards,
baolu