Skip to contentSkip to conversation

iommu/arm-smmu-v3: Make the queue depths tunable, and shrink them in a kdump kernel

PATCH In review Kiryl Shutsemau (Meta) 5 participants 10 messages Sep 9 – Oct 2

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v6 cover iommu/arm-smmu-v3: Make the queue depths tunable, and shrink them in a kdump kernel

The queues are sized from the IDR1 maxima and allocated at probe, costing megabytes per queue per SMMU instance. A kdump capture kernel pays that out of a small crashkernel reservation, for queues it barely uses and two of which it switches off anyway.

Patch 1 adds a cmdq_max_n_shift module parameter, decided in a per-queue helper and floored at one page. Patch 2 has a kdump kernel default all three depths to one page through the same helper. An explicit cmdq_max_n_shift still wins.

Measured per instance under QEMU on -M virt,iommu=smmuv3, through a real panic and kexec into a capture kernel:

                        4K page          64K page
      cmdq         1 MB -> 4 KB      8 MB -> 64 KB
      evtq         1 MB -> 4 KB     16 MB -> 64 KB

Every clamped queue lands on exactly one page. cmdq_max_n_shift moves the command queue alone and beats the kdump default; the capture kernel attached four devices with no CMD_SYNC timeout, GERROR or context fault. QEMU exposes no PRI queue, which takes the same path. Build-tested across 4K/16K/64K, TEGRA241_CMDQV=n, CRASH_DUMP=n and =m, every commit warning-free.

v6:
- Take the parameter as a log2 depth and call it cmdq_max_n_shift (Nicolin).
- Nicolin's Reviewed-by and Tested-by from v5 are not carried over, as the parameter changed shape.

v5: https://lore.kernel.org/all/[email protected]/
v4: https://lore.kernel.org/all/[email protected]/
v3: https://lore.kernel.org/all/[email protected]/

Kiryl Shutsemau (Meta) (2):
iommu/arm-smmu-v3: Add a cmdq_max_n_shift module parameter iommu/arm-smmu-v3: Default queue depths to one page in a kdump kernel

 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c   | 75 +++++++++++++++++--
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h   |  1 +
 .../iommu/arm/arm-smmu-v3/tegra241-cmdqv.c    |  2 +-
 3 files changed, 70 insertions(+), 8 deletions(-)

base-commit: cee9395acd8043be0644b25c34bfa86623f2b935

Signature · 1 line
2.54.0
#1 lore raw

PATCH v6 1/2 iommu/arm-smmu-v3: Add a cmdq_max_n_shift module parameter

The command queue depth comes straight from the maximum the hardware advertises in IDR1, which reaches megabytes of coherent DMA per queue. A system with several SMMUv3 instances pays that per instance, and the Tegra241 CMDQV pays it again for every VCMDQ it preallocates.

Queue depth only bounds how many commands may be in flight before a sync. A machine driving a handful of devices, or one with a tight memory budget, has no use for the maximum, and no way to say so.

Add cmdq_max_n_shift, a cap on the depth given as the log2 of the entry count, the form the hardware itself takes in the LOG2SIZE field of CMDQ_BASE. Decide the depth in arm_smmu_cmdq_max_n_shift(), which caps the IDR1 value for natural alignment and then applies the parameter, so the queue is allocated at the requested size. The Tegra241 CMDQV sizes its VCMDQs from IDR1 itself, so route that through the same helper.

Floor the request at one page worth of entries. Without the floor, a small request trips the CMDQ_BATCH_ENTRIES check in arm_smmu_device_hw_probe() and the SMMU fails to probe. The floor also costs nothing: coherent DMA is page granular, so a shallower queue occupies the same memory as one that fills the page.

Assisted-by LLM
---
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c   | 43 ++++++++++++++++++-
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h   |  1 +
 .../iommu/arm/arm-smmu-v3/tegra241-cmdqv.c    |  2 +-
 3 files changed, 43 insertions(+), 3 deletions(-)
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +41 -2
index 5732f3ba0122..78618a9dfa8b 100644
@@ -40,6 +40,11 @@ module_param(disable_msipolling, bool, 0444);
 MODULE_PARM_DESC(disable_msipolling,
 	"Disable MSI-based polling for CMD_SYNC completion.");
 
+static unsigned int cmdq_max_n_shift;
+module_param(cmdq_max_n_shift, uint, 0444);
+MODULE_PARM_DESC(cmdq_max_n_shift,
+	"Cap on the command queue depth, as log2 of the number of entries. Zero means the hardware maximum; the queue never shrinks below one page.");
+
 static const struct iommu_ops arm_smmu_ops;
 static struct iommu_dirty_ops arm_smmu_dirty_ops;
 
@@ -4412,6 +4417,40 @@ static struct iommu_dirty_ops arm_smmu_dirty_ops = {
 };
 
 /* Probing and initialisation functions */
+
+/**
+ * arm_smmu_queue_max_n_shift() - pick the log2 depth of a queue
+ * @ceiling: default log2 depth ceiling of the queue
+ * @ent_sz_shift: log2 of the queue entry size in bytes
+ * @shift: log2 depth asked for, or zero for the default
+ *
+ * @shift is floored at one page, because coherent DMA is page granular: a
+ * shallower queue occupies the same memory as one that fills the page, and
+ * arm_smmu_init_one_queue() stops shrinking at a page too.
+ */
+static u32 arm_smmu_queue_max_n_shift(u32 ceiling, u32 ent_sz_shift, u32 shift)
+{
+	u32 floor = PAGE_SHIFT - ent_sz_shift;
+
+	if (!shift)
+		return ceiling;
+
+	return min(ceiling, max(shift, floor));
+}
+
+/*
+ * Command queues are also allocated by the Tegra241 CMDQV for its VCMDQs, which
+ * need the same depth decision.
+ */
+u32 arm_smmu_cmdq_max_n_shift(u32 ceiling)
+{
+	/* Capped to ensure natural alignment */
+	ceiling = min(CMDQ_MAX_SZ_SHIFT, ceiling);
+
+	return arm_smmu_queue_max_n_shift(ceiling, CMDQ_ENT_SZ_SHIFT,
+					  cmdq_max_n_shift);
+}
+
 int arm_smmu_init_one_queue(struct arm_smmu_device *smmu,
 			    struct arm_smmu_queue *q, void __iomem *page,
 			    unsigned long prod_off, unsigned long cons_off,
@@ -5156,8 +5195,8 @@ static int arm_smmu_device_hw_probe(struct arm_smmu_device *smmu)
 		smmu->features |= ARM_SMMU_FEAT_ATTR_TYPES_OVR;
 
 	/* Queue sizes, capped to ensure natural alignment */
-	smmu->cmdq.q.llq.max_n_shift = min_t(u32, CMDQ_MAX_SZ_SHIFT,
-					     FIELD_GET(IDR1_CMDQS, reg));
+	smmu->cmdq.q.llq.max_n_shift =
+		arm_smmu_cmdq_max_n_shift(FIELD_GET(IDR1_CMDQS, reg));
 	if (smmu->cmdq.q.llq.max_n_shift <= ilog2(CMDQ_BATCH_ENTRIES)) {
 		/*
 		 * We don't support splitting up batches, so one batch of
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +1 -0
index 50f8321e979c..11ae4d8f4ad2 100644
@@ -1165,6 +1165,7 @@ static inline void arm_smmu_domain_inv(struct arm_smmu_domain *smmu_domain)
 
 void __arm_smmu_cmdq_skip_err(struct arm_smmu_device *smmu,
 			      struct arm_smmu_cmdq *cmdq);
+u32 arm_smmu_cmdq_max_n_shift(u32 ceiling);
 int arm_smmu_init_one_queue(struct arm_smmu_device *smmu,
 			    struct arm_smmu_queue *q, void __iomem *page,
 			    unsigned long prod_off, unsigned long cons_off,
drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c +1 -1
index 6644075c1431..710a4c694b94 100644
@@ -663,7 +663,7 @@ static int tegra241_vcmdq_alloc_smmu_cmdq(struct tegra241_vcmdq *vcmdq)
 	/* Cap queue size to SMMU's IDR1.CMDQS and ensure natural alignment */
 	regval = readl_relaxed(smmu->base + ARM_SMMU_IDR1);
 	q->llq.max_n_shift =
-		min_t(u32, CMDQ_MAX_SZ_SHIFT, FIELD_GET(IDR1_CMDQS, regval));
+		arm_smmu_cmdq_max_n_shift(FIELD_GET(IDR1_CMDQS, regval));
 
 	/* Use the common helper to init the VCMDQ, and then... */
 	ret = arm_smmu_init_one_queue(smmu, q, vcmdq->page0,
Signature · 1 line
2.54.0
Reviewed-by on v6 1/2
#2 lore raw

Re: [PATCH v6 1/2] iommu/arm-smmu-v3: Add a cmdq_max_n_shift module parameter

Quoted 4 lines · Kiryl Shutsemau (Meta)

The command queue depth comes straight from the maximum the hardware advertises in IDR1, which reaches megabytes of coherent DMA per queue. A system with several SMMUv3 instances pays that per instance, and the Tegra241 CMDQV pays it again for every VCMDQ it preallocates.

Thanks. I've seen this issue while investigating another SMMU issue[1]. Thanks for fixing it.

Quoted 11 lines

Queue depth only bounds how many commands may be in flight before a sync. A machine driving a handful of devices, or one with a tight memory budget, has no use for the maximum, and no way to say so.

Add cmdq_max_n_shift, a cap on the depth given as the log2 of the entry count, the form the hardware itself takes in the LOG2SIZE field of CMDQ_BASE. Decide the depth in arm_smmu_cmdq_max_n_shift(), which caps the IDR1 value for natural alignment and then applies the parameter, so the queue is allocated at the requested size. The Tegra241 CMDQV sizes its VCMDQs from IDR1 itself, so route that through the same helper.

Quoted 8 lines

Floor the request at one page worth of entries. Without the floor, a small request trips the CMDQ_BATCH_ENTRIES check in arm_smmu_device_hw_probe() and the SMMU fails to probe. The floor also costs nothing: coherent DMA is page granular, so a shallower queue occupies the same memory as one that fills the page.

Assisted-by LLM
Reviewed-by on v6 1/2
#3 lore raw

Re: [PATCH v6 1/2] iommu/arm-smmu-v3: Add a cmdq_max_n_shift module parameter

In reply to Kiryl Shutsemau (Meta)

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c module_param(disable_msipolling, bool, 0444); · line 46

Quoted 9 lines

[ ... 34 lines skipped ... ]

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +4 -0
@@ -40,6 +40,11 @@ module_param(disable_msipolling, bool, 0444);
 MODULE_PARM_DESC(disable_msipolling,
 	"Disable MSI-based polling for CMD_SYNC completion.");
 
+static unsigned int cmdq_max_n_shift;
+module_param(cmdq_max_n_shift, uint, 0444);
+MODULE_PARM_DESC(cmdq_max_n_shift,
+	"Cap on the command queue depth, as log2 of the number of entries. Zero means the hardware maximum; the queue never shrinks below one page.");

The patch looks ok

But I'd rather use lg2 as name, especially user visible, instead of n_shift. "shift" is a word for bitwise stuff, this is a 2**N log2 encoded value.

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c static struct iommu_dirty_ops arm_smmu_dirty_ops = { · line 4431

Quoted 12 lines

[ ... 9 lines skipped ... ]

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +11 -0
+/**
+ * arm_smmu_queue_max_n_shift() - pick the log2 depth of a queue
+ * @ceiling: default log2 depth ceiling of the queue
+ * @ent_sz_shift: log2 of the queue entry size in bytes
+ * @shift: log2 depth asked for, or zero for the default
+ *
+ * @shift is floored at one page, because coherent DMA is page granular: a
+ * shallower queue occupies the same memory as one that fills the page, and
+ * arm_smmu_init_one_queue() stops shrinking at a page too.
+ */
+static u32 arm_smmu_queue_max_n_shift(u32 ceiling, u32 ent_sz_shift, u32 shift)

These names took me a while to figure out. Something like this seems much clearer:

hw_max_lg2
ent_size_lg2
user_limit_lg2

And the flow can be simplified alot:

static u32 arm_smmu_queue_max_lg2(u32 hw_max_lg2, u32 ent_sz_lg2,

				  u32 user_limit_lg2)
{
	u32 floor_lg2 = PAGE_SHIFT - ent_sz_lg2;

	if (is_kdump_kernel())
		return min(hw_max_lg2, floor_lg2);
	user_limit_lg2 = max(user_limit_lg2, floor_lg2);
	return min(hw_max_lg2, user_limit_lg2);

Just pass the MAX's as the user limit:

static inline u32 arm_smmu_evtq_max_n_shift(u32 ceiling)

{
	return arm_smmu_queue_max_lg2(ceiling, EVTQ_ENT_SZ_SHIFT,
				      EVTQ_MAX_SZ_SHIFT);

With only one min:

	return arm_smmu_queue_max_lg2(ceiling, CMDQ_ENT_SZ_SHIFT,
				      min(CMDQ_MAX_SZ_SHIFT, cmdq_max_n_shift));

Jason

Signature · 1 line
Jason
#4 lore raw

Re: [PATCH v6 1/2] iommu/arm-smmu-v3: Add a cmdq_max_n_shift module parameter

Quoted 12 lines · Jason Gunthorpe

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c module_param(disable_msipolling, bool, 0444); · line 46

Quoted 9 lines

[ ... 34 lines skipped ... ]

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +4 -0
@@ -40,6 +40,11 @@ module_param(disable_msipolling, bool, 0444);
 MODULE_PARM_DESC(disable_msipolling,
 	"Disable MSI-based polling for CMD_SYNC completion.");
 
+static unsigned int cmdq_max_n_shift;
+module_param(cmdq_max_n_shift, uint, 0444);
+MODULE_PARM_DESC(cmdq_max_n_shift,
+	"Cap on the command queue depth, as log2 of the number of entries. Zero means the hardware maximum; the queue never shrinks below one page.");

The patch looks ok

Quoted 5 lines

But I'd rather use lg2 as name, especially user visible, instead of n_shift. "shift" is a word for bitwise stuff, this is a 2**N log2 encoded value.

This name has changed twice already. v5 took the value in entries. Nicolin asked for a log2 value and named it after max_n_shift, which is what the driver calls this quantity everywhere else.

I would rather not rename it a third time without input from the maintainer.

Will, this is the user-visible name. Do you have a preference here? Unless you want it changed I will leave v6 as it is.

Signature · 1 line
  Kiryl Shutsemau / Kirill A. Shutemov
#5 lore raw

Re: [PATCH v6 1/2] iommu/arm-smmu-v3: Add a cmdq_max_n_shift module parameter

Quoted 23 lines · Kiryl Shutsemau
Quoted 12 lines · Jason Gunthorpe

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c module_param(disable_msipolling, bool, 0444); · line 46

Quoted 9 lines

[ ... 34 lines skipped ... ]

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +4 -0
@@ -40,6 +40,11 @@ module_param(disable_msipolling, bool, 0444);
 MODULE_PARM_DESC(disable_msipolling,
 	"Disable MSI-based polling for CMD_SYNC completion.");
 
+static unsigned int cmdq_max_n_shift;
+module_param(cmdq_max_n_shift, uint, 0444);
+MODULE_PARM_DESC(cmdq_max_n_shift,
+	"Cap on the command queue depth, as log2 of the number of entries. Zero means the hardware maximum; the queue never shrinks below one page.");

The patch looks ok

Quoted 5 lines

But I'd rather use lg2 as name, especially user visible, instead of n_shift. "shift" is a word for bitwise stuff, this is a 2**N log2 encoded value.

This name has changed twice already. v5 took the value in entries. Nicolin asked for a log2 value and named it after max_n_shift, which is what the driver calls this quantity everywhere else.

Quoted 5 lines

I would rather not rename it a third time without input from the maintainer.

Will, this is the user-visible name. Do you have a preference here? Unless you want it changed I will leave v6 as it is.

Please at least fix the internal logic to work in the saner way I showed

Jason

maintainer
#6 lore raw

Re: [PATCH v6 1/2] iommu/arm-smmu-v3: Add a cmdq_max_n_shift module parameter

In reply to Kiryl Shutsemau
Quoted 23 lines · Kiryl Shutsemau
Quoted 12 lines · Jason Gunthorpe

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c module_param(disable_msipolling, bool, 0444); · line 46

Quoted 9 lines

[ ... 34 lines skipped ... ]

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +4 -0
@@ -40,6 +40,11 @@ module_param(disable_msipolling, bool, 0444);
 MODULE_PARM_DESC(disable_msipolling,
 	"Disable MSI-based polling for CMD_SYNC completion.");
 
+static unsigned int cmdq_max_n_shift;
+module_param(cmdq_max_n_shift, uint, 0444);
+MODULE_PARM_DESC(cmdq_max_n_shift,
+	"Cap on the command queue depth, as log2 of the number of entries. Zero means the hardware maximum; the queue never shrinks below one page.");

The patch looks ok

Quoted 5 lines

But I'd rather use lg2 as name, especially user visible, instead of n_shift. "shift" is a word for bitwise stuff, this is a 2**N log2 encoded value.

This name has changed twice already. v5 took the value in entries. Nicolin asked for a log2 value and named it after max_n_shift, which is what the driver calls this quantity everywhere else.

Quoted 5 lines

I would rather not rename it a third time without input from the maintainer.

Will, this is the user-visible name. Do you have a preference here? Unless you want it changed I will leave v6 as it is.

I don't have really strong opinions on naming, but since Jason has given a reasonably complete outline of the change and I have a small preference for the lg2-style naming (rather than exposing the name of an internal driver variable), it would be great if you can spin a v7 with that included so that I can pick it up.

Thanks,

Will

#7 lore raw

PATCH v6 2/2 iommu/arm-smmu-v3: Default queue depths to one page in a kdump kernel

In reply to Kiryl Shutsemau (Meta)

All three queues are sized from the maxima the hardware advertises in IDR1 and allocated at probe, up to 4 MB each on a 4K-page kernel. The capture kernel already disables two of them: arm_smmu_device_reset() drops CR0_EVTQEN and CR0_PRIQEN. It still allocates both at full size.

A kdump capture kernel runs from a small crashkernel reservation, and every SMMUv3 instance pays that cost again, up to 12 MB apiece. It goes to queues that either serve the handful of devices used to save the dump or are switched off outright, and it is memory the dump itself needs.

Default all three depths to one page worth of entries when is_kdump_kernel(). The queues carry commands and fault records rather than DMA data, so dump throughput is unaffected. A shallower command queue only bounds how many commands may be in flight before a sync, which does not matter for the few devices that save the dump.

An explicit cmdq_max_n_shift still wins, so a capture kernel that wants a deeper command queue can ask for one on the command line.

---
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 36 +++++++++++++++++----
 1 file changed, 29 insertions(+), 7 deletions(-)
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +29 -7
index 78618a9dfa8b..3a6de5e667e0 100644
@@ -4424,6 +4424,9 @@ static struct iommu_dirty_ops arm_smmu_dirty_ops = {
  * @ent_sz_shift: log2 of the queue entry size in bytes
  * @shift: log2 depth asked for, or zero for the default
  *
+ * The default is @ceiling, except in a kdump capture kernel, which defaults to
+ * one page worth of entries.
+ *
  * @shift is floored at one page, because coherent DMA is page granular: a
  * shallower queue occupies the same memory as one that fills the page, and
  * arm_smmu_init_one_queue() stops shrinking at a page too.
@@ -4432,10 +4435,30 @@ static u32 arm_smmu_queue_max_n_shift(u32 ceiling, u32 ent_sz_shift, u32 shift)
 {
 	u32 floor = PAGE_SHIFT - ent_sz_shift;
 
-	if (!shift)
+	if (shift)
+		shift = max(shift, floor);
+	else if (is_kdump_kernel())
+		shift = floor;
+	else
 		return ceiling;
 
-	return min(ceiling, max(shift, floor));
+	return min(ceiling, shift);
+}
+
+static inline u32 arm_smmu_evtq_max_n_shift(u32 ceiling)
+{
+	/* Capped to ensure natural alignment */
+	ceiling = min(EVTQ_MAX_SZ_SHIFT, ceiling);
+
+	return arm_smmu_queue_max_n_shift(ceiling, EVTQ_ENT_SZ_SHIFT, 0);
+}
+
+static inline u32 arm_smmu_priq_max_n_shift(u32 ceiling)
+{
+	/* Capped to ensure natural alignment */
+	ceiling = min(PRIQ_MAX_SZ_SHIFT, ceiling);
+
+	return arm_smmu_queue_max_n_shift(ceiling, PRIQ_ENT_SZ_SHIFT, 0);
 }
 
 /*
@@ -5194,7 +5217,6 @@ static int arm_smmu_device_hw_probe(struct arm_smmu_device *smmu)
 	if (reg & IDR1_ATTR_TYPES_OVR)
 		smmu->features |= ARM_SMMU_FEAT_ATTR_TYPES_OVR;
 
-	/* Queue sizes, capped to ensure natural alignment */
 	smmu->cmdq.q.llq.max_n_shift =
 		arm_smmu_cmdq_max_n_shift(FIELD_GET(IDR1_CMDQS, reg));
 	if (smmu->cmdq.q.llq.max_n_shift <= ilog2(CMDQ_BATCH_ENTRIES)) {
@@ -5209,10 +5231,10 @@ static int arm_smmu_device_hw_probe(struct arm_smmu_device *smmu)
 		return -ENXIO;
 	}
 
-	smmu->evtq.q.llq.max_n_shift = min_t(u32, EVTQ_MAX_SZ_SHIFT,
-					     FIELD_GET(IDR1_EVTQS, reg));
-	smmu->priq.q.llq.max_n_shift = min_t(u32, PRIQ_MAX_SZ_SHIFT,
-					     FIELD_GET(IDR1_PRIQS, reg));
+	smmu->evtq.q.llq.max_n_shift =
+		arm_smmu_evtq_max_n_shift(FIELD_GET(IDR1_EVTQS, reg));
+	smmu->priq.q.llq.max_n_shift =
+		arm_smmu_priq_max_n_shift(FIELD_GET(IDR1_PRIQS, reg));
 
 	/* SID/SSID sizes */
 	smmu->ssid_bits = FIELD_GET(IDR1_SSIDSIZE, reg);
Signature · 1 line
2.54.0
Tested-by on v6 2/2
#8 lore raw

Re: [PATCH v6 2/2] iommu/arm-smmu-v3: Default queue depths to one page in a kdump kernel

We hit the same problem on our arm64 platform: the kdump capture kernel runs out of memory because the SMMUv3 queues are still allocated at full hardware size. We had started looking into it ourselves, then came across this series, so we tested it on the affected hardware rather than prepare a duplicate fix.

It resolves the problem for us - details below.

Test platform: an arm64 server, 128 cores, 2 NUMA nodes, 512 GiB RAM, exposing 6 SMMUv3 instances. 64K-page kernel (PAGE_SHIFT=16) based on Linux 7.0.14 with the series applied on top; crashkernel reservation is 512 MiB.

On this platform kdump FAILS without the patch, and the series fixes it.

Before - capture kernel WITHOUT the series:
All 6 SMMUv3 instances still allocate the hardware-maximum queues:
arm-smmu-v3 arm-smmu-v3.0.auto: allocated 524288 entries for cmdq arm-smmu-v3 arm-smmu-v3.0.auto: allocated 524288 entries for evtq arm-smmu-v3 arm-smmu-v3.0.auto: allocated 524288 entries for priq (... same for all 6 instances)
That is 8 + 16 + 8 = 32 MiB per instance, 192 MiB total - 37.5% of the 512 MiB reservation. The capture kernel OOMs before makedumpfile runs:
swapper/0 invoked oom-killer: gfp_mask=0x2040cc0(GFP_KERNEL|...), order=0 Out of memory and no killable processes...
Rebooting in 10 seconds..
=> no vmcore is saved.

After - capture kernel WITH the series:
All three queues are floored to one page per instance:
arm-smmu-v3 arm-smmu-v3.0.auto: allocated 4096 entries for cmdq arm-smmu-v3 arm-smmu-v3.0.auto: allocated 2048 entries for evtq arm-smmu-v3 arm-smmu-v3.0.auto: allocated 4096 entries for priq (... same for all 6 instances)
=> ~1.1 MiB total (~191 MiB freed). All 6 instances re-probe cleanly (no -ENXIO, no allocation failure) and a 608 MB vmcore is saved.

Same machine, same 512 MiB reservation; the only difference is the v6 series, so this is a controlled before/after.

Thanks,
Yuanhe

Reviewed-by on v6 2/2
#9 lore raw

Re: [PATCH v6 2/2] iommu/arm-smmu-v3: Default queue depths to one page in a kdump kernel

In reply to Kiryl Shutsemau (Meta)
Quoted 6 lines

[ ... 40 lines skipped ... ]

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +0 -1
@@ -4432,10 +4435,30 @@ static u32 arm_smmu_queue_max_n_shift(u32 ceiling, u32 ent_sz_shift, u32 shift)
 {
 	u32 floor = PAGE_SHIFT - ent_sz_shift;
 
-	if (!shift)

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c static u32 arm_smmu_queue_max_n_shift(u32 ceiling, u32 ent_sz_shift, u32 shift) · line 4446

Quoted 10 lines
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +7 -1
+	if (shift)
+		shift = max(shift, floor);
+	else if (is_kdump_kernel())
+		shift = floor;
+	else
 		return ceiling;
 
-	return min(ceiling, max(shift, floor));
+	return min(ceiling, shift);
+}

The logic looks OK

Signature · 1 line
Jason