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 2/2] firewire: ohci: retry page batch allocation in ar_context_init()
Date: Tue,  1 Dec 2026 20:41:09 +0100	[thread overview]
Message-ID: <20261201194109.3566-3-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"). 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


      parent 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 ` [PATCH 1/2] firewire: core: retry page batch allocation in fw_iso_buffer_alloc() Imre Kaloz
2026-12-01 19:41 ` Imre Kaloz [this message]

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-3-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.