* [PATCH 1/2] firewire: core: retry page batch allocation in fw_iso_buffer_alloc()
[not found] <20261201194109.3566-1-kaloz@kernel.org>
@ 2026-12-01 19:41 ` Imre Kaloz
2026-12-01 19:41 ` [PATCH 2/2] firewire: ohci: retry page batch allocation in ar_context_init() Imre Kaloz
1 sibling, 0 replies; 2+ messages in thread
From: Imre Kaloz @ 2026-12-01 19:41 UTC (permalink / raw)
To: Takashi Sakamoto; +Cc: linux1394-devel, stable
alloc_pages_bulk() may return fewer pages than requested, e.g. a single
page when the per-cpu page lists are not used on a CONFIG_SMP=n kernel
since commit a373f371166d ("mm/page_alloc: effectively disable pcp with
CONFIG_SMP=n"). fw_iso_buffer_alloc() treats any short count as failure,
so isochronous buffers with more than one page cannot be allocated
there.
Call alloc_pages_bulk() again until the array is filled, and fail only
when a call makes no progress.
Cc: stable@vger.kernel.org # v7.1
Fixes: c2f60aa1602d ("firewire: core: use common kernel API to allocate and release a batch of pages")
Signed-off-by: Imre Kaloz <kaloz@kernel.org>
---
drivers/firewire/core-iso.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/firewire/core-iso.c b/drivers/firewire/core-iso.c
index fd6cbbf79d0b..09fb213cfe4a 100644
--- a/drivers/firewire/core-iso.c
+++ b/drivers/firewire/core-iso.c
@@ -39,8 +39,17 @@ int fw_iso_buffer_alloc(struct fw_iso_buffer *buffer, int page_count)
// Retrieve noncontiguous pages. The descriptors for 1394 OHCI isochronous DMA contexts
// have a set of address and length per each, while the reason to use pages is the
// convenience to map them into virtual address space of user process.
- unsigned long nr_populated = alloc_pages_bulk(GFP_KERNEL | GFP_DMA32 | __GFP_ZERO,
- page_count, page_array);
+ // A single call may return fewer pages than requested, e.g. when the per-cpu page lists
+ // are unavailable. Call again until the array is filled, or no progress is made.
+ unsigned long nr_populated = 0;
+ unsigned long last;
+
+ do {
+ last = nr_populated;
+ nr_populated = alloc_pages_bulk(GFP_KERNEL | GFP_DMA32 | __GFP_ZERO, page_count,
+ page_array);
+ } while (nr_populated != page_count && nr_populated != last);
+
if (nr_populated != page_count) {
// Assuming the above call fills page_array sequentially from the beginning.
release_pages(page_array, nr_populated);
--
2.47.3
^ permalink raw reply related [flat|nested] 2+ messages in thread* [PATCH 2/2] firewire: ohci: retry page batch allocation in ar_context_init()
[not found] <20261201194109.3566-1-kaloz@kernel.org>
2026-12-01 19:41 ` [PATCH 1/2] firewire: core: retry page batch allocation in fw_iso_buffer_alloc() Imre Kaloz
@ 2026-12-01 19:41 ` Imre Kaloz
1 sibling, 0 replies; 2+ messages in thread
From: Imre Kaloz @ 2026-12-01 19:41 UTC (permalink / raw)
To: Takashi Sakamoto; +Cc: linux1394-devel, stable
alloc_pages_bulk() may return fewer pages than requested, e.g. a single
page when the per-cpu page lists are not used on a CONFIG_SMP=n kernel
since commit a373f371166d ("mm/page_alloc: effectively disable pcp with
CONFIG_SMP=n"). ar_context_init() treats any short count as failure, so
the probe fails with -ENOMEM there.
Call alloc_pages_bulk() again until the array is filled, and fail only
when a call makes no progress.
Cc: stable@vger.kernel.org # v7.1
Fixes: f2ae92780ab9 ("firewire: ohci: split page allocation from dma mapping")
Signed-off-by: Imre Kaloz <kaloz@kernel.org>
---
drivers/firewire/ohci.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c
index 2dd9b6bdca2b..5300623a6284 100644
--- a/drivers/firewire/ohci.c
+++ b/drivers/firewire/ohci.c
@@ -871,7 +871,15 @@ static int ar_context_init(struct ar_context *ctx, struct fw_ohci *ohci,
// Retrieve noncontiguous pages. The descriptors for 1394 OHCI AR DMA contexts have a set
// of address and length per each. The reason to use pages is to construct contiguous
// address range in kernel virtual address space.
- unsigned long nr_populated = alloc_pages_bulk(GFP_KERNEL | GFP_DMA32, AR_BUFFERS, pages);
+ // A single call may return fewer pages than requested, e.g. when the per-cpu page lists
+ // are unavailable. Call again until the array is filled, or no progress is made.
+ unsigned long nr_populated = 0;
+ unsigned long last;
+
+ do {
+ last = nr_populated;
+ nr_populated = alloc_pages_bulk(GFP_KERNEL | GFP_DMA32, AR_BUFFERS, pages);
+ } while (nr_populated != AR_BUFFERS && nr_populated != last);
if (nr_populated != AR_BUFFERS) {
release_pages(pages, nr_populated);
--
2.47.3
^ permalink raw reply related [flat|nested] 2+ messages in thread