From nobody Tue Feb 10 13:17:11 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 6CA4D234984 for ; Sat, 10 Jan 2026 01:39:22 +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=1768009164; cv=none; b=nsXhjNHSmnktfB4mJewhgGKkrc4hJFN9bYoKb7MJnZTxPsx0gdnWWJcGRe87j1g2I00M2MLnd3DLj6bwqiK7qHv3+GVSsqSnlqGlYDzmKe8tFVS+5NFD/HvgGA+BDKsxm3fxe8C6pk+WXKNSk/kfAPhDMiRx/HT/F9T8KmKZnzA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768009164; c=relaxed/simple; bh=BLrdqFM/J0qggJs/wtFaDhxDAhoy9wP1sbFNdlfGzvU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UggPSuVbeg21I7I5ub1kgHz41h9hULOX9ouCaUHuVkcaNECqnQfV42eG8p1ny3hgLG5vSmUom+cQ6Xh58Ks/nsGn8nJ2qnzcwRQwQACKLAUrRn5cOsvvlj7Gu8Phal2l41x3EoWb8jaiMaiQiD2kz2tYKJxsA3qg4jOtT5uE7nI= 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=XqQtcOfz; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=oM5eEts3; 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="XqQtcOfz"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="oM5eEts3" Received: from phl-compute-12.internal (phl-compute-12.internal [10.202.2.52]) by mailfout.phl.internal (Postfix) with ESMTP id B6B92EC016E; Fri, 9 Jan 2026 20:39:21 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Fri, 09 Jan 2026 20:39:21 -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=1768009161; x= 1768095561; bh=nvi2YFB+cOaDy5eldI3l6OcbnVQr1axnxuUdxcNk+Wk=; b=X qQtcOfz588EyVD7sj17fZhr+r+EY643p6dTJjy/tZxufyL+B3vmHuxWkdlc/I91H rW4khZi/8wKZme6NGhGtB3bvvuNZ4u+rzHpatixDNOu3VtIDCcWEjS1/20xk3S1r w0n0ERNDGHmaddxLmqm/bJ5GxzX5wi4cDRZs+YrOmY5vcFbuAN6Z0wA/NqzEper5 B963axWN1htiVoo4bGKpYs4F0YhUFsnlcuayCHUuau8KUBSWNrJ8/qjcJcBRxZX8 3WO0FBNmBmlUhh4LSNaA7Y2AVUPCzlBDo3yXhmlid0luMRccZsLYaq6jThXUUO4T DMmw0smuRFA9QcBcRw3/g== 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=1768009161; x=1768095561; bh=n vi2YFB+cOaDy5eldI3l6OcbnVQr1axnxuUdxcNk+Wk=; b=oM5eEts3SZaQQtvmx Z+LmsVsJJOkjM+dBdTyTqHPXCyF5mSeEwVfqoxUsJhSoD/TkoaY6p0otod8ficJw 3CPot2q9colT/3EL2cZBfpI3JNtZw/uLtRORIFMlj9WKtaseSoDViE4N5c0hEPek S/K/+SBsnGnbsnt4huHkHuC9nLZOtxtoyLLaYdUj2+h7t/dLSEb3lMj1brvIDQZq Hh1/LDrLxBdx7nFhgpMa94F1mP2i7ZtFUkreB9/QHLogzZbyiK3LTlAuJT55WHkr KoDiQp+qqg6cB6NKu+PSqJrJBEw6Sar9cO12EZJs0tXnFj+cNyGGKy9gn2sFx4Sl 5CwpQ== 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:20 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org, jgg@nvidia.com Subject: [PATCH 5/8] firewire: core: stop using page private to store DMA mapping address Date: Sat, 10 Jan 2026 10:39:08 +0900 Message-ID: <20260110013911.19160-6-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" There is a long discussion about the use of private field in page structure between Linux kernel developers. This commit stop using page private to store DMA mapping address for isochronous context, to prepare for mm future change. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-cdev.c | 5 +--- drivers/firewire/core-iso.c | 48 +++++++++++++++++++----------------- drivers/firewire/ohci.c | 24 +++++++++--------- include/linux/firewire.h | 2 +- 4 files changed, 39 insertions(+), 40 deletions(-) diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index 2b8a878c8aae..bb4d0f938f5b 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c @@ -67,7 +67,6 @@ struct client { u64 iso_closure; struct fw_iso_buffer buffer; unsigned long vm_start; - bool buffer_is_mapped; =20 struct list_head phy_receiver_link; u64 phy_receiver_closure; @@ -1098,7 +1097,7 @@ static int ioctl_create_iso_context(struct client *cl= ient, union ioctl_arg *arg) } // The DMA mapping operation is available if the buffer is already alloc= ated by // mmap(2) system call. If not, it is delegated to the system call. - if (!client->buffer_is_mapped) { + if (client->buffer.pages && !client->buffer.dma_addrs) { ret =3D fw_iso_buffer_map_dma(&client->buffer, client->device->card, iso_dma_direction(context)); if (ret < 0) { @@ -1106,7 +1105,6 @@ static int ioctl_create_iso_context(struct client *cl= ient, union ioctl_arg *arg) =20 return ret; } - client->buffer_is_mapped =3D true; } client->iso_closure =3D a->closure; client->iso_context =3D context; @@ -1837,7 +1835,6 @@ static int fw_device_op_mmap(struct file *file, struc= t vm_area_struct *vma) iso_dma_direction(client->iso_context)); if (ret < 0) goto fail; - client->buffer_is_mapped =3D true; } } =20 diff --git a/drivers/firewire/core-iso.c b/drivers/firewire/core-iso.c index f2e35ac7a476..3f36243ec0c1 100644 --- a/drivers/firewire/core-iso.c +++ b/drivers/firewire/core-iso.c @@ -55,25 +55,32 @@ int fw_iso_buffer_alloc(struct fw_iso_buffer *buffer, i= nt page_count) int fw_iso_buffer_map_dma(struct fw_iso_buffer *buffer, struct fw_card *ca= rd, enum dma_data_direction direction) { - dma_addr_t address; + dma_addr_t *dma_addrs __free(kfree) =3D kcalloc(buffer->page_count, sizeo= f(dma_addrs[0]), + GFP_KERNEL); int i; =20 - buffer->direction =3D direction; + if (!dma_addrs) + return -ENOMEM; =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)) + dma_addr_t dma_addr =3D dma_map_page(card->device, buffer->pages[i], 0, = PAGE_SIZE, + direction); + if (dma_mapping_error(card->device, dma_addr)) break; =20 - set_page_private(buffer->pages[i], address); + dma_addrs[i] =3D dma_addr; } - buffer->page_count_mapped =3D i; - if (i < buffer->page_count) + if (i < buffer->page_count) { + while (i-- > 0) + dma_unmap_page(card->device, dma_addrs[i], PAGE_SIZE, buffer->direction= ); return -ENOMEM; + } + + buffer->direction =3D direction; + buffer->dma_addrs =3D no_free_ptr(dma_addrs); =20 return 0; } @@ -98,13 +105,13 @@ EXPORT_SYMBOL(fw_iso_buffer_init); void fw_iso_buffer_destroy(struct fw_iso_buffer *buffer, struct fw_card *card) { - int i; - dma_addr_t address; - - for (i =3D 0; i < buffer->page_count_mapped; i++) { - address =3D page_private(buffer->pages[i]); - dma_unmap_page(card->device, address, - PAGE_SIZE, buffer->direction); + if (buffer->dma_addrs) { + for (int i =3D 0; i < buffer->page_count; ++i) { + dma_addr_t dma_addr =3D buffer->dma_addrs[i]; + dma_unmap_page(card->device, dma_addr, PAGE_SIZE, buffer->direction); + } + kfree(buffer->dma_addrs); + buffer->dma_addrs =3D NULL; } =20 if (buffer->pages) { @@ -114,20 +121,15 @@ void fw_iso_buffer_destroy(struct fw_iso_buffer *buff= er, } =20 buffer->page_count =3D 0; - buffer->page_count_mapped =3D 0; } EXPORT_SYMBOL(fw_iso_buffer_destroy); =20 /* Convert DMA address to offset into virtually contiguous buffer. */ size_t fw_iso_buffer_lookup(struct fw_iso_buffer *buffer, dma_addr_t compl= eted) { - size_t i; - dma_addr_t address; - ssize_t offset; - - for (i =3D 0; i < buffer->page_count; i++) { - address =3D page_private(buffer->pages[i]); - offset =3D (ssize_t)completed - (ssize_t)address; + for (int i =3D 0; i < buffer->page_count; i++) { + dma_addr_t dma_addr =3D buffer->dma_addrs[i]; + ssize_t offset =3D (ssize_t)completed - (ssize_t)dma_addr; if (offset > 0 && offset <=3D PAGE_SIZE) return (i << PAGE_SHIFT) + offset; } diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index e3e78dc42530..68a336577d36 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c @@ -3184,7 +3184,7 @@ static int queue_iso_transmit(struct iso_context *ctx, struct descriptor *d, *last, *pd; struct fw_iso_packet *p; __le32 *header; - dma_addr_t d_bus, page_bus; + dma_addr_t d_bus; u32 z, header_z, payload_z, irq; u32 payload_index, payload_end_index, next_page_index; int page, end_page, i, length, offset; @@ -3254,11 +3254,11 @@ static int queue_iso_transmit(struct iso_context *c= tx, min(next_page_index, payload_end_index) - payload_index; pd[i].req_count =3D cpu_to_le16(length); =20 - page_bus =3D page_private(buffer->pages[page]); - pd[i].data_address =3D cpu_to_le32(page_bus + offset); + dma_addr_t dma_addr =3D buffer->dma_addrs[i]; + pd[i].data_address =3D cpu_to_le32(dma_addr + offset); =20 dma_sync_single_range_for_device(ctx->context.ohci->card.device, - page_bus, offset, length, + dma_addr, offset, length, DMA_TO_DEVICE); =20 payload_index +=3D length; @@ -3287,7 +3287,7 @@ static int queue_iso_packet_per_buffer(struct iso_con= text *ctx, { struct device *device =3D ctx->context.ohci->card.device; struct descriptor *d, *pd; - dma_addr_t d_bus, page_bus; + dma_addr_t d_bus; u32 z, header_z, rest; int i, j, length; int page, offset, packet_count, header_size, payload_per_buffer; @@ -3337,10 +3337,10 @@ static int queue_iso_packet_per_buffer(struct iso_c= ontext *ctx, pd->res_count =3D pd->req_count; pd->transfer_status =3D 0; =20 - page_bus =3D page_private(buffer->pages[page]); - pd->data_address =3D cpu_to_le32(page_bus + offset); + dma_addr_t dma_addr =3D buffer->dma_addrs[page]; + pd->data_address =3D cpu_to_le32(dma_addr + offset); =20 - dma_sync_single_range_for_device(device, page_bus, + dma_sync_single_range_for_device(device, dma_addr, offset, length, DMA_FROM_DEVICE); =20 @@ -3367,7 +3367,7 @@ static int queue_iso_buffer_fill(struct iso_context *= ctx, unsigned long payload) { struct descriptor *d; - dma_addr_t d_bus, page_bus; + dma_addr_t d_bus; int page, offset, rest, z, i, length; =20 page =3D payload >> PAGE_SHIFT; @@ -3400,11 +3400,11 @@ static int queue_iso_buffer_fill(struct iso_context= *ctx, d->res_count =3D d->req_count; d->transfer_status =3D 0; =20 - page_bus =3D page_private(buffer->pages[page]); - d->data_address =3D cpu_to_le32(page_bus + offset); + dma_addr_t dma_addr =3D buffer->dma_addrs[page]; + d->data_address =3D cpu_to_le32(dma_addr + offset); =20 dma_sync_single_range_for_device(ctx->context.ohci->card.device, - page_bus, offset, length, + dma_addr, offset, length, DMA_FROM_DEVICE); =20 rest -=3D length; diff --git a/include/linux/firewire.h b/include/linux/firewire.h index aa84421b58ac..09c8484f7430 100644 --- a/include/linux/firewire.h +++ b/include/linux/firewire.h @@ -526,8 +526,8 @@ struct fw_iso_packet { struct fw_iso_buffer { enum dma_data_direction direction; struct page **pages; + dma_addr_t *dma_addrs; int page_count; - int page_count_mapped; }; =20 int fw_iso_buffer_init(struct fw_iso_buffer *buffer, struct fw_card *card, --=20 2.51.0