[RFC PATCH] iommu/arm-smmu-v3: Allow stream ID sharing for devices behind PCIe-to-PCI bridges

Nirmoy Das posted 1 patch 1 month, 4 weeks ago
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 11 +++++++++++
1 file changed, 11 insertions(+)
[RFC PATCH] iommu/arm-smmu-v3: Allow stream ID sharing for devices behind PCIe-to-PCI bridges
Posted by Nirmoy Das 1 month, 4 weeks ago
ASPEED BMC controllers have VGA and USB functions behind a PCIe-to-PCI
bridge that causes them to share the same stream ID:

  \-[0005:e0]---00.0-[e1-e2]----00.0-[e2]--+-00.0  ASPEED Graphics Family
                                           \-02.0  ASPEED USB Controller

Both devices get stream ID(0x5e200) due to bridge aliasing. Currently this
USB controller gets rejected with "Aliasing StreamID unsupported", causing
USB timeout errors. Allow stream ID sharing when both devices are on
the same bus behind a PCIe-to-PCI bridge to fix this issue.

Signed-off-by: Nirmoy Das <nirmoyd@nvidia.com>
---
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
index 2a8b46b948f05..411b8803eb46f 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -3480,6 +3480,17 @@ static int arm_smmu_insert_master(struct arm_smmu_device *smmu,
 			if (existing_master == master)
 				continue;

+			/* Allow PCI devices on the same bus to share stream IDs
+			 * due to PCIe-to-PCI bridge aliasing.
+			 */
+			if (dev_is_pci(master->dev) && dev_is_pci(existing_master->dev)) {
+				struct pci_dev *pdev = to_pci_dev(master->dev);
+				struct pci_dev *existing_pdev = to_pci_dev(existing_master->dev);
+
+				if (pdev->bus == existing_pdev->bus)
+					continue;
+			}
+
 			dev_warn(master->dev,
 				 "Aliasing StreamID 0x%x (from %s) unsupported, expect DMA to be broken\n",
 				 sid, dev_name(existing_master->dev));
--
2.43.0
Re: [RFC PATCH] iommu/arm-smmu-v3: Allow stream ID sharing for devices behind PCIe-to-PCI bridges
Posted by Jason Gunthorpe 1 month, 3 weeks ago
On Thu, Dec 11, 2025 at 05:39:33AM -0800, Nirmoy Das wrote:
> ASPEED BMC controllers have VGA and USB functions behind a PCIe-to-PCI
> bridge that causes them to share the same stream ID:
> 
>   \-[0005:e0]---00.0-[e1-e2]----00.0-[e2]--+-00.0  ASPEED Graphics Family
>                                            \-02.0  ASPEED USB Controller
> 
> Both devices get stream ID(0x5e200) due to bridge aliasing. Currently this
> USB controller gets rejected with "Aliasing StreamID unsupported", causing
> USB timeout errors. Allow stream ID sharing when both devices are on
> the same bus behind a PCIe-to-PCI bridge to fix this issue.

I don't think this is right, if you actually need stream ID sharing
then I seem to recall the driver needs more changes. We don't want
this in general.

IMHO ASPEED has wrong PCI config space and there isn't any actual PCI
bus here that would force RID aliasing to worry about. I suggest going
to ASPEED to find out and confirm that they don't actually share the
RIDs and then let's quirk the PCI devices to disable alias generation
in the first place.

Also, complain to them to fix their config space to report a PCIe bridge
type in future devices. :)

Jason
Re: [RFC PATCH] iommu/arm-smmu-v3: Allow stream ID sharing for devices behind PCIe-to-PCI bridges
Posted by Robin Murphy 1 month, 3 weeks ago
On 2025-12-12 6:40 am, Jason Gunthorpe wrote:
> On Thu, Dec 11, 2025 at 05:39:33AM -0800, Nirmoy Das wrote:
>> ASPEED BMC controllers have VGA and USB functions behind a PCIe-to-PCI
>> bridge that causes them to share the same stream ID:
>>
>>    \-[0005:e0]---00.0-[e1-e2]----00.0-[e2]--+-00.0  ASPEED Graphics Family
>>                                             \-02.0  ASPEED USB Controller
>>
>> Both devices get stream ID(0x5e200) due to bridge aliasing. Currently this
>> USB controller gets rejected with "Aliasing StreamID unsupported", causing
>> USB timeout errors. Allow stream ID sharing when both devices are on
>> the same bus behind a PCIe-to-PCI bridge to fix this issue.
> 
> I don't think this is right, if you actually need stream ID sharing
> then I seem to recall the driver needs more changes. We don't want
> this in general.

Yes, as I said on the last one not so long ago, we cannot simply cross 
our fingers and hope that aliasing at the SMMU StreamID level stems from 
something at the PCI RID level that pci_device_group() would be aware 
of, because there is no guarantee that RID->StreamID mappings are 1:1.

Thanks,
Robin.

> IMHO ASPEED has wrong PCI config space and there isn't any actual PCI
> bus here that would force RID aliasing to worry about. I suggest going
> to ASPEED to find out and confirm that they don't actually share the
> RIDs and then let's quirk the PCI devices to disable alias generation
> in the first place.
> 
> Also, complain to them to fix their config space to report a PCIe bridge
> type in future devices. :)
> 
> Jason
Re: [RFC PATCH] iommu/arm-smmu-v3: Allow stream ID sharing for devices behind PCIe-to-PCI bridges
Posted by Nirmoy Das 1 month, 3 weeks ago
On 12.12.25 11:46, Robin Murphy wrote:
> On 2025-12-12 6:40 am, Jason Gunthorpe wrote:
>> On Thu, Dec 11, 2025 at 05:39:33AM -0800, Nirmoy Das wrote:
>>> ASPEED BMC controllers have VGA and USB functions behind a PCIe-to-PCI
>>> bridge that causes them to share the same stream ID:
>>>
>>>    \-[0005:e0]---00.0-[e1-e2]----00.0-[e2]--+-00.0  ASPEED Graphics 
>>> Family
>>>                                             \-02.0  ASPEED USB 
>>> Controller
>>>
>>> Both devices get stream ID(0x5e200) due to bridge aliasing. 
>>> Currently this
>>> USB controller gets rejected with "Aliasing StreamID unsupported", 
>>> causing
>>> USB timeout errors. Allow stream ID sharing when both devices are on
>>> the same bus behind a PCIe-to-PCI bridge to fix this issue.
>>
>> I don't think this is right, if you actually need stream ID sharing
>> then I seem to recall the driver needs more changes. We don't want
>> this in general.
>
> Yes, as I said on the last one not so long ago, we cannot simply cross 
> our fingers and hope that aliasing at the SMMU StreamID level stems 
> from something at the PCI RID level that pci_device_group() would be 
> aware of, because there is no guarantee that RID->StreamID mappings 
> are 1:1.
>
> Thanks,
> Robin.
>

Thanks, Jason and Robin for your feedback. I will reach out to ASPEED to 
find out if they are actually sharing RID as suggested by Jason.

>> IMHO ASPEED has wrong PCI config space and there isn't any actual PCI
>> bus here that would force RID aliasing to worry about. I suggest going
>> to ASPEED to find out and confirm that they don't actually share the
>> RIDs and then let's quirk the PCI devices to disable alias generation
>> in the first place.
>>
>> Also, complain to them to fix their config space to report a PCIe bridge
>> type in future devices. :)

I will do that :)


Thanks,

Nirmoy

>>
>> Jason
>