Skip to contentSkip to conversation

Revert "iommu/arm-smmu-v3: Decrease the queue size of evtq and priq"

PATCH Applied Zhou Wang 4 participants 5 messages Dec 7, 2021 – Dec 15, 2021

Subsystems (2)
lore
Share & tools
lore

Zhou Wang

author
#0 lore raw

PATCH 1/1 Revert "iommu/arm-smmu-v3: Decrease the queue size of evtq and priq"

The commit f115f3c0d5d8 ("iommu/arm-smmu-v3: Decrease the queue size of evtq and priq") decreases evtq and priq, which may lead evtq/priq to be full with fault events, e.g HiSilicon ZIP/SEC/HPRE have maximum 1024 queues in one device, every queue could be binded with one process and trigger a fault event. So let's revert f115f3c0d5d8.

In fact, if an implementation of SMMU really does not need so long evtq and priq, value of IDR1_EVTQS and IDR1_PRIQS can be set to proper ones.

---
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +2 -3
index 4cb136f..cd48590 100644
@@ -184,7 +184,6 @@
 #else
 #define Q_MAX_SZ_SHIFT			(PAGE_SHIFT + MAX_ORDER - 1)
 #endif
-#define Q_MIN_SZ_SHIFT			(PAGE_SHIFT)
 
 /*
  * Stream table.
@@ -374,7 +373,7 @@
 /* Event queue */
 #define EVTQ_ENT_SZ_SHIFT		5
 #define EVTQ_ENT_DWORDS			((1 << EVTQ_ENT_SZ_SHIFT) >> 3)
-#define EVTQ_MAX_SZ_SHIFT		(Q_MIN_SZ_SHIFT - EVTQ_ENT_SZ_SHIFT)
+#define EVTQ_MAX_SZ_SHIFT		(Q_MAX_SZ_SHIFT - EVTQ_ENT_SZ_SHIFT)
 
 #define EVTQ_0_ID			GENMASK_ULL(7, 0)
 
@@ -400,7 +399,7 @@
 /* PRI queue */
 #define PRIQ_ENT_SZ_SHIFT		4
 #define PRIQ_ENT_DWORDS			((1 << PRIQ_ENT_SZ_SHIFT) >> 3)
-#define PRIQ_MAX_SZ_SHIFT		(Q_MIN_SZ_SHIFT - PRIQ_ENT_SZ_SHIFT)
+#define PRIQ_MAX_SZ_SHIFT		(Q_MAX_SZ_SHIFT - PRIQ_ENT_SZ_SHIFT)
 
 #define PRIQ_0_SID			GENMASK_ULL(31, 0)
 #define PRIQ_0_SSID			GENMASK_ULL(51, 32)
Signature · 7 lines
2.8.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
maintainer
#1 lore raw
Quoted 6 lines · Zhou Wang

The commit f115f3c0d5d8 ("iommu/arm-smmu-v3: Decrease the queue size of evtq and priq") decreases evtq and priq, which may lead evtq/priq to be full with fault events, e.g HiSilicon ZIP/SEC/HPRE have maximum 1024 queues in one device, every queue could be binded with one process and trigger a fault event. So let's revert f115f3c0d5d8.

Quoted 7 lines

In fact, if an implementation of SMMU really does not need so long evtq and priq, value of IDR1_EVTQS and IDR1_PRIQS can be set to proper ones.

---
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

I'd like an Ack from Zhen Lei on this, as the aim of the original patch was to reduce memory consumption.

Will
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

reviewer
#2 lore raw
Quoted 10 lines · Will Deacon
Quoted 9 lines · Zhou Wang

The commit f115f3c0d5d8 ("iommu/arm-smmu-v3: Decrease the queue size of evtq and priq") decreases evtq and priq, which may lead evtq/priq to be full with fault events, e.g HiSilicon ZIP/SEC/HPRE have maximum 1024 queues in one device, every queue could be binded with one process and trigger a fault event. So let's revert f115f3c0d5d8.

In fact, if an implementation of SMMU really does not need so long evtq and priq, value of IDR1_EVTQS and IDR1_PRIQS can be set to proper ones.

Quoted 7 lines
Quoted 4 lines
---
  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)

I'd like an Ack from Zhen Lei on this, as the aim of the original patch was to reduce memory consumption.

I wonder if it's time to start trying to be a bit cleverer than just allocating the smallest/largest possible queues, and try to scale them to some heuristic of the "size" of the system? Certainly a module parameter so that users can manually tune for their system/workload might be a reasonable compromise.

I'm also tempted by the idea of trying to dynamically reallocate larger queues if they fill up, but I guess that depends on whether it's already game over if events or PRI requests are lost...

Robin.
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

#3 lore raw
In reply to Will Deacon
Quoted 10 lines · Will Deacon
Quoted 9 lines · Zhou Wang

The commit f115f3c0d5d8 ("iommu/arm-smmu-v3: Decrease the queue size of evtq and priq") decreases evtq and priq, which may lead evtq/priq to be full with fault events, e.g HiSilicon ZIP/SEC/HPRE have maximum 1024 queues in one device, every queue could be binded with one process and trigger a fault event. So let's revert f115f3c0d5d8.

In fact, if an implementation of SMMU really does not need so long evtq and priq, value of IDR1_EVTQS and IDR1_PRIQS can be set to proper ones.

Quoted 7 lines
Quoted 4 lines
---
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

I'd like an Ack from Zhen Lei on this, as the aim of the original patch was to reduce memory consumption.

I did it for the purpose of saving memory. At the time, I didn't think it would have accumulated so many events. Now there is such a practical situation. Ensuring functionality stability is more important than saving a little memory. So I have no objection to reverting my patch.

Quoted 4 lines

Will
.

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

maintainer Applied
#4 lore raw
In reply to Zhou Wang
Quoted 10 lines · Zhou Wang

The commit f115f3c0d5d8 ("iommu/arm-smmu-v3: Decrease the queue size of evtq and priq") decreases evtq and priq, which may lead evtq/priq to be full with fault events, e.g HiSilicon ZIP/SEC/HPRE have maximum 1024 queues in one device, every queue could be binded with one process and trigger a fault event. So let's revert f115f3c0d5d8.

In fact, if an implementation of SMMU really does not need so long evtq and priq, value of IDR1_EVTQS and IDR1_PRIQS can be set to proper ones.

[...]

Applied to will (for-joerg/arm-smmu/updates), thanks!

[1/1] Revert "iommu/arm-smmu-v3: Decrease the queue size of evtq and priq"

      https://git.kernel.org/will/c/477436699e78

Cheers,

Signature · 9 lines
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu