From nobody Wed Feb 11 01:00:04 2026 Received: from fout-a6-smtp.messagingengine.com (fout-a6-smtp.messagingengine.com [103.168.172.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1FC342367B5 for ; Sat, 10 Jan 2026 01:39:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.149 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768009162; cv=none; b=gNomoE3pMbqEN6W8Op7bGRyN4vkophfrsTdBBIPJRG3XCXUxKWjWgQ5VImhVeliRIy/wXcokzJKLrbQCh8ySiEsB0Ml0t03YE8Ob3cXhYhsUXQIL/XWNkJuAhU6yRWMDH9ilj43DVs83X9HAkA1/s4+tEl/Vynp4UUAQjkzkEOk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768009162; c=relaxed/simple; bh=AzJqGhMBeIoMjKSn7ggaXsJT6S6ZEv6g94Qwv91of3c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ou5NkPlxlFAZ4h/70YZ9jH3zEUd79yqV3z8EG4Tj6t9Uq4TcAMcXwLDvO6ymY1rg6I6AOSlMWy78V76B8mbX/nkAei1EMzeeFsJeFG50QDRK+owHbNeo1yk3Rihr42I/6guyH+AVl4komrkJz5mOjO6E0aXwTyOyufE199cD2xU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sakamocchi.jp; spf=pass smtp.mailfrom=sakamocchi.jp; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b=VbvXUTPn; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=Eq7KQCO3; arc=none smtp.client-ip=103.168.172.149 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sakamocchi.jp Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="VbvXUTPn"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Eq7KQCO3" Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfout.phl.internal (Postfix) with ESMTP id 6ACB9EC0118; Fri, 9 Jan 2026 20:39:20 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Fri, 09 Jan 2026 20:39:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1768009160; x= 1768095560; bh=EiYDyRw08I7TcXnhftv0D6o2bdWQLkS+DKUbg4F+khE=; b=V bvXUTPncXp+pTX3CUJ0XqEEBqZUXlmEnWjYOXUYqkoXUV9oOVstiD5I1xfJZPYpq JopyJ2aZgHyc24Ix9Rla37Is9GmVtEZN6Ip+9bnjhKpCV84scSpnStwiMak6ZCSo 0op4eHkFmP5yaVEvVk99Ogf++2ZZUT3u5O0mpSIA0XRM59iRbtIpdMnEd1CY5Mi9 F9DYLpfI4thvw6zP0bdkyi4qYenbH3uHTYmFKSjYe5OVSKd7nPi5NHac8xg7clhk PJojjtFlkoZ7H2qx5/P+AHBcAKGHJsRF/q+hegPRunWsYs3DmJMTIE1ZRxt1Lx0F YigQIKdWOJmBkRskkdfZA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1768009160; x=1768095560; bh=E iYDyRw08I7TcXnhftv0D6o2bdWQLkS+DKUbg4F+khE=; b=Eq7KQCO38sW45sR55 haIKuaszfy5FioIIL+SK9179MM53Qd7v+kn5mcaA6vGTPsPAnmoH49SHUB2H8m4B AmMRCVOJTVE/o2VSM/swMxlcprDCRAjzYadGL8UMeElfqyBda53Kv6SyqxVG2IR1 rC2HiV28jDQ7eT0wYKyR699sRvGx3AqA3BRQkRDz98DqTQLMTPm5YrJZdDdK6sIS ppbMhwmGf1/c6KIttcPazKUByah/AaMrA0CubK+1yA12ikLISGgg53P8Wi+BxqBQ bcHEBgd88C0oNOJt2P9dV/BiF/0EDnuXoaPpyq2jhW3GMNabUuRMyWv+pGH5awS0 uiLkQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdduuddtfeelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtkeertd ertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghkrghs hhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpedvjefgjeeuvd fguddukeelveetgfdtvefhtdfffeeigfevueetffeivdffkedvtdenucevlhhushhtvghr ufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrg hkrghmohgttghhihdrjhhppdhnsggprhgtphhtthhopeefpdhmohguvgepshhmthhpohhu thdprhgtphhtthhopehlihhnuhigudefleegqdguvghvvghlsehlihhsthhsrdhsohhurh gtvghfohhrghgvrdhnvghtpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgv rhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepjhhgghesnhhvihguihgrrdgtohhm X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 9 Jan 2026 20:39:19 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org, jgg@nvidia.com Subject: [PATCH 4/8] firewire: core: use common kernel API to allocate and release a batch of pages Date: Sat, 10 Jan 2026 10:39:07 +0900 Message-ID: <20260110013911.19160-5-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260110013911.19160-1-o-takashi@sakamocchi.jp> References: <20260110013911.19160-1-o-takashi@sakamocchi.jp> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The pair of alloc_pages_bulk() and release_pages() are convenient to allocate and release a batch of pages. This commit utilizes the pair to maintain pages for isochronous DMA context. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-iso.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/drivers/firewire/core-iso.c b/drivers/firewire/core-iso.c index e678ffba5de2..f2e35ac7a476 100644 --- a/drivers/firewire/core-iso.c +++ b/drivers/firewire/core-iso.c @@ -31,22 +31,18 @@ int fw_iso_buffer_alloc(struct fw_iso_buffer *buffer, int page_count) { struct page **page_array __free(kfree) =3D kcalloc(page_count, sizeof(pag= e_array[0]), GFP_KERNEL); - int i; =20 if (!page_array) return -ENOMEM; =20 - for (i =3D 0; i < page_count; ++i) { - struct page *page =3D alloc_page(GFP_KERNEL | GFP_DMA32 | __GFP_ZERO); - - if (!page) - break; - page_array[i] =3D page; - } - - if (i < page_count) { - while (i-- > 0) - __free_page(page_array[i]); + // Retrieve noncontiguous pages. The descriptors for 1394 OHCI isochronou= s DMA contexts + // have a set of address and length per each, while the reason to use pag= es is the + // convenience to map them into virtual address space of user process. + unsigned long nr_populated =3D alloc_pages_bulk(GFP_KERNEL | GFP_DMA32 | = __GFP_ZERO, + page_count, page_array); + if (nr_populated !=3D page_count) { + // Assuming the above call fills page_array sequentially from the beginn= ing. + release_pages(page_array, nr_populated); return -ENOMEM; } =20 @@ -64,7 +60,10 @@ int fw_iso_buffer_map_dma(struct fw_iso_buffer *buffer, = struct fw_card *card, =20 buffer->direction =3D direction; =20 + // Retrieve DMA mapping addresses for the pages. They are not contiguous.= Maintain the cache + // coherency for the pages by hand. for (i =3D 0; i < buffer->page_count; i++) { + // The dma_map_phys() with a physical address per page is available here= , instead. address =3D dma_map_page(card->device, buffer->pages[i], 0, PAGE_SIZE, direction); if (dma_mapping_error(card->device, address)) @@ -109,8 +108,7 @@ void fw_iso_buffer_destroy(struct fw_iso_buffer *buffer, } =20 if (buffer->pages) { - for (int i =3D 0; i < buffer->page_count; ++i) - __free_page(buffer->pages[i]); + release_pages(buffer->pages, buffer->page_count); kfree(buffer->pages); buffer->pages =3D NULL; } --=20 2.51.0