[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8f5ee898-162a-49f6-9044-7e3ef6dafe1e@linux.intel.com>
Date: Sat, 10 Aug 2024 16:01:40 +0800
From: Baolu Lu <baolu.lu@...ux.intel.com>
To: "Tian, Kevin" <kevin.tian@...el.com>, Joerg Roedel <joro@...tes.org>,
Will Deacon <will@...nel.org>, Robin Murphy <robin.murphy@....com>,
Jason Gunthorpe <jgg@...pe.ca>
Cc: baolu.lu@...ux.intel.com, "iommu@...ts.linux.dev"
<iommu@...ts.linux.dev>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Jason Gunthorpe <jgg@...dia.com>
Subject: Re: [PATCH v4 6/7] iommu/vt-d: Add support for static identity domain
On 2024/8/9 16:29, Tian, Kevin wrote:
>> From: Lu Baolu <baolu.lu@...ux.intel.com>
>> Sent: Friday, August 9, 2024 1:55 PM
>>
>> +static int context_setup_pass_through(struct device *dev, u8 bus, u8 devfn)
>> +{
>> + struct device_domain_info *info = dev_iommu_priv_get(dev);
>> + struct intel_iommu *iommu = info->iommu;
>> + struct context_entry *context;
>> +
>> + spin_lock(&iommu->lock);
>> + context = iommu_context_addr(iommu, bus, devfn, 1);
>> + if (!context) {
>> + spin_unlock(&iommu->lock);
>> + return -ENOMEM;
>> + }
>> +
>> + if (context_present(context) && !context_copied(iommu, bus, devfn))
>> {
>> + spin_unlock(&iommu->lock);
>> + return 0;
>> + }
>
> Is it a valid case to setup passthrough on a present entry?
It's valid but unnecessary.
Since the context is present, it indicates that the configuration has
already been setup by a PCI aliased device. The iommu group mandates
that all PCI aliased devices must be attached to the same iommu domain.
Consequently, there's no need for additional configuration.
While it's feasible to remove this line of code due to the check in the
pci_for_each_dma_alias() callback:
static int context_setup_pass_through_cb(struct pci_dev *pdev, u16
alias, void *data)
{
struct device *dev = data;
if (dev != &pdev->dev)
return 0;
return context_setup_pass_through(dev, PCI_BUS_NUM(alias),
alias & 0xff);
}
But it's in the original code, I've retained it to prevent any potential
regression.
Thanks,
baolu
Powered by blists - more mailing lists