All of lore.kernel.org
 help / color / mirror / Atom feed
From: Imre Kaloz <kaloz@kernel.org>
To: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: linux1394-devel@lists.sourceforge.net, stable@vger.kernel.org
Subject: [PATCH 1/2] firewire: core: retry page batch allocation in fw_iso_buffer_alloc()
Date: Tue,  1 Dec 2026 20:41:08 +0100	[thread overview]
Message-ID: <20261201194109.3566-2-kaloz@kernel.org> (raw)
In-Reply-To: <20261201194109.3566-1-kaloz@kernel.org>

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


       reply	other threads:[~2026-12-01 19:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20261201194109.3566-1-kaloz@kernel.org>
2026-12-01 19:41 ` Imre Kaloz [this message]
2026-12-01 19:41 ` [PATCH 2/2] firewire: ohci: retry page batch allocation in ar_context_init() Imre Kaloz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261201194109.3566-2-kaloz@kernel.org \
    --to=kaloz@kernel.org \
    --cc=linux1394-devel@lists.sourceforge.net \
    --cc=o-takashi@sakamocchi.jp \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.