[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v1 3/6] iommu/arm: Introduce iommu_add_dt_pci_device API


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
  • Date: Mon, 8 May 2023 10:12:41 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=GeJaDIJJReWZD9EkDq23oZ61Jfq8KZPalADMHBqnzQ4=; b=JnunmsxoHvie1DOg1XFccF+Kjz81S3R3CLZejx5z5VmzjKIN7okwyTIVzAHGy0VByGfQapo5cpPoJ3pO1P3mjxrlD9Z59Zf5A1cN6XHUg0QFtKJ0Tnr0Rzq5/iAzPi+lHeUenbSyq/oxegVkLBKZ5Y8JTgd4MHPknNNoCGuV+3/yUTPHd1qxUDhTwxD2WU+9BRquFE1MP1ug46fBrd7rtwr+2nMtNFmAAxoIkFoxcaBg5mpAdpg8Gff/74U7/xtBnfx/Gtl92mHyxdU2UhFaxnKiospUoEjl2NW4iqEQHXrr8xtSvTK/Ng4Sq48v7NixP6OiyQdrYfkuokjV1EmMcA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iXQyMI35v3ND2QJyPMNGVlEIRsOUo+Io2Rj/9CeUuGSe+0OVfaKmOKnzoRKcYufRRgyGTHralB96HNGX68B06LzTda+N4lh3IVMNosqCafD1ZI6qOGA6i/MgBsROtllKNf7gi2KPf7ENdThnui/l6V3I5hqWx74FbJHRv0xgpSKNopOwkzxk8wUuvoeClJBBptnTFuMgUm/xWwBH4opFjuNNS6cJdeKYhVotDYDn8Fi7dXDE/WRu2eTdRrzpaE1brwRtULEzTXf+wHAi+8YfDAdd0pmCwyfGO3zghPRA8ffEPL7zsi9e8+veLUyeSe02jFLH/Q8LGkBpd4yEyDw85g==
  • Cc: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Paul Durrant <paul@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 08 May 2023 14:13:12 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 5/5/23 02:20, Jan Beulich wrote:
> On 04.05.2023 23:54, Stewart Hildebrand wrote:
>> On 5/2/23 03:44, Jan Beulich wrote:
>>> On 01.05.2023 22:03, Stewart Hildebrand wrote:
>>>> @@ -228,6 +229,9 @@ int iommu_release_dt_devices(struct domain *d);
>>>>   *      (IOMMU is not enabled/present or device is not connected to it).
>>>>   */
>>>>  int iommu_add_dt_device(struct dt_device_node *np);
>>>> +#ifdef CONFIG_HAS_PCI
>>>> +int iommu_add_dt_pci_device(uint8_t devfn, struct pci_dev *pdev);
>>>> +#endif
>>>
>>> Why the first parameter? Doesn't the 2nd one describe the device in full?
>>
>> It's related to phantom device/function handling, although this series 
>> unfortunately does not properly handle phantom devices.
>>
>>> If this is about phantom devices, then I'd expect the function to take
>>> care of those (like iommu_add_device() does), rather than its caller.
>>
>> In the next patch ("[PATCH v1 4/6] pci/arm: Use iommu_add_dt_pci_device() 
>> instead of arch hook"), we will invoke iommu_add_dt_pci_device(devfn, pdev) 
>> from iommu_add_device().
> 
> Which I think I said there already I consider wrong.

Okay, I'm following now. Right, so, the first parameter is not needed.

>> Since iommu_add_device() iterates over the phantom functions, it would be 
>> redundant to also have such a loop inside of iommu_add_dt_pci_device().
>>
>> If we are to properly handle phantom devices on ARM, the SMMU drivers 
>> (smmu.c/smmu-v3.c) would need some more work. In patches 5/6 and 6/6 in this 
>> series, we have:
>>
>> if ( devfn != pdev->devfn )
>>     return -EOPNOTSUPP;
>>
>> Also, the ARM SMMU drivers in Xen currently only support a single AXI stream 
>> ID per device, so some development would need to occur in order to support 
>> phantom devices.

I spoke too soon, the SMMU drivers do appear to support multiple IDs.

>>
>> Should phantom device support be part of this series, or would it be 
>> acceptable to introduce phantom device support on ARM as part of a future 
>> series?
> 
> I wouldn't view this as a strict requirement, so long as it is made clear in
> respective patch descriptions.

After doing a little more investigation, I should be able to add in the 
plumbing to iterate over the phantom functions in iommu_add_dt_pci_device(). 
Stay tuned for v2 of this series.

>> Lastly, I'd like to check my understanding since phantom devices are new to 
>> me. Here's my understanding:
>>
>> A phantom device is a device that advertises itself as single function, but 
>> actually has multiple phantom functions. These phantom functions will have 
>> unique requestor IDs (RID). The RID is essentially the BDF. To use a phantom 
>> device with Xen, we specify the pci-phantom command line option, and we 
>> identify phantom devices/functions in code by devfn != pdev->devfn.
> 
> The command line option is there only to work around errata, i.e. devices
> behaving as if they had phantom functions without advertising themselves
> as such. See our use of PCI_EXP_DEVCAP_PHANTOM. As you can see, this being
> PCIe only, and legacy PCI device bevaing this way would require use of the
> command line option.
> 
>> On ARM, we need to map/translate a BDF to an AXI stream ID in order for the 
>> SMMU to identify the device and apply translation. That BDF -> stream ID 
>> mapping is defined by the iommu-map/iommu-map-mask property in the device 
>> tree [1]. The BDF -> AXI stream ID mapping in DT could allow phantom devices 
>> (i.e. devices with phantom functions) to use different stream IDs based on 
>> the (phantom) function.
>>
>> So, in theory, on ARM, there is a possibility we may have a device that 
>> advertises itself as single function, but will issue AXI transactions with 
>> multiple different AXI stream IDs due to phantom functions. In this case, we 
>> will want each AXI stream ID to be programmed into the SMMU to avoid SMMU 
>> faults.
> 
> Right, which of course first requires that you know the mapping between
> these IDs.

Thanks for clarifying!

Stewart



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.