From nobody Mon Feb 9 11:55:52 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 3990921CC62 for ; Sat, 10 Jan 2026 01:39:17 +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=1768009158; cv=none; b=nf7PVeRQv1+FGcsqArBaQS0mCzRSm2r44+2HFLXR+qUXtb4H8O+fihqhiFgjfGmlYTYyPQVcYOGqkVXIfg2V1UwFYjoIMRQyFqZRX/6klJqBWmf1aw9tIvjbzkeB4Yk+MVlXJZXrlM0C8jKBTz+/cZ0OEkSCoICW9RJHTwYXyb8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768009158; c=relaxed/simple; bh=P5SHru9Fw39gqbqFNPV9Tn1raVnT4aHJAfZW2Qf3G3M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DSKIwE91CEYWQu8OIYp6u3E2pP4o7+Oo0aw/krMlkGe6wa3OcT7NN5mlsLfvbZF5nwjMV4orgpxwPRMeHSTVxLIdepVF6GQREXCUS7WtbCIgRO/VbM8jUO0yhQT9/v3zaje64bFIQW3YtLxHLaNBLVkNMQFu3rRZ4SygjNxU/lY= 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=U/gMuDlA; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=a4C8Y+Wk; 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="U/gMuDlA"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="a4C8Y+Wk" Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfout.phl.internal (Postfix) with ESMTP id 87EB4EC0123; Fri, 9 Jan 2026 20:39:16 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Fri, 09 Jan 2026 20:39:16 -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=1768009156; x= 1768095556; bh=/USqrIhzNwvOIg7VpeHZ+THvSNF3Rt04y9067B5c5iM=; b=U /gMuDlAb/ENOdy3dRW2j+mJA9510C+DzfXQJylZDcwYitQod9V3xacUQzUHVACHI KfgvdoeCRXCpbdwp+9hHIjBgjLA5g7r1KJWzAwIJAhODqE/gEQ70waj1FZr+BtQV c/W7rjXaWYNx+Q4W82mLBvXm2iyLtH2hZxCjdcwIzFDMaec58Uc4mmueU7PYXjgO NAHl3O7CCOuWJ7FDDKcV8RHEUaBboB4ZR94Ya5d45Aj6Owvknsv2CyEyHjWMa8Mo PiypFvDMBM/ojTlAeqAE+Znm5r9nbvLu0xKhSjMwDe8ev8BF4n0RShBS19Ec2AHU QtSZGfYZKnmnYaAKKJbnA== 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=1768009156; x=1768095556; bh=/ USqrIhzNwvOIg7VpeHZ+THvSNF3Rt04y9067B5c5iM=; b=a4C8Y+WkaWi9EHj9c +pgiMallbjXnNXr1HgMju48IaG/U8gCLeW8p42JtPCIrhwjFwWOqCe13/ZjnwmEc 46CnMEJZGTmROq66FPsRLLv68x7NcnK5BlM8qNOi6CI+r8dp/4HeFJMvDZjoAsXy Jbgu0Oz28vt1lg+iu+Zc9xODZIVMAq7E3kDjA20LFZwZ+Ch3KRpKhpuwHkxHm3Mk 2p0fwvMVoxEV9b3WhwjVoBEwHrbEosUT+t5TEudpkZTo5lX5Wgs/OFsUB+2xU20T Nc3w9aUDPRbYToCrZINP1WS7alwvlX5RbTFz3AKk9TcLoFWAuOsr7N/fzNN1zsFy wkQ0A== 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:15 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org, jgg@nvidia.com Subject: [PATCH 1/8] firewire: core: move private function declaration from public header to internal header Date: Sat, 10 Jan 2026 10:39:04 +0900 Message-ID: <20260110013911.19160-2-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 fw_iso_buffer_lookup function is used by core module only, thus no need to describe its prototype in kernel internal header. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core.h | 1 + include/linux/firewire.h | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h index 41fb39d9a4e6..26868f007131 100644 --- a/drivers/firewire/core.h +++ b/drivers/firewire/core.h @@ -166,6 +166,7 @@ void fw_node_event(struct fw_card *card, struct fw_node= *node, int event); int fw_iso_buffer_alloc(struct fw_iso_buffer *buffer, int page_count); int fw_iso_buffer_map_dma(struct fw_iso_buffer *buffer, struct fw_card *ca= rd, enum dma_data_direction direction); +size_t fw_iso_buffer_lookup(struct fw_iso_buffer *buffer, dma_addr_t compl= eted); =20 static inline void fw_iso_context_init_work(struct fw_iso_context *ctx, wo= rk_func_t func) { diff --git a/include/linux/firewire.h b/include/linux/firewire.h index 6143b7d28eac..aa84421b58ac 100644 --- a/include/linux/firewire.h +++ b/include/linux/firewire.h @@ -533,7 +533,6 @@ struct fw_iso_buffer { int fw_iso_buffer_init(struct fw_iso_buffer *buffer, struct fw_card *card, int page_count, enum dma_data_direction direction); void fw_iso_buffer_destroy(struct fw_iso_buffer *buffer, struct fw_card *c= ard); -size_t fw_iso_buffer_lookup(struct fw_iso_buffer *buffer, dma_addr_t compl= eted); =20 struct fw_iso_context; typedef void (*fw_iso_callback_t)(struct fw_iso_context *context, --=20 2.51.0 From nobody Mon Feb 9 11:55:52 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 918CB22B5A3 for ; Sat, 10 Jan 2026 01:39:18 +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=1768009160; cv=none; b=W+BdkJNSgP/OV7G0vRBX864neqX6CmOZlQC4URZva/naZg9U/CXoqI66FY8aWPjIVdhE5xhIwHgSIzgPR4x12h1YePLTh9qznq7odWz3ecjAgE1wl9kMPkdszIB7quETum+sZoenf2m0g+JbwLu6nxFaIMA8R466muj5s27xJ6M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768009160; c=relaxed/simple; bh=h0ShMIi+pT6lnNcWSLqshk/hcavuY6GKaZQdB5PEuvU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H9bk+v9LjIgvZoXi7f2YEgWNAYbI7TzK6I9kY5KbX3slaaQrJk6Cr5ELg7utuJGIoqcoPtZ6de+PE3IxXAXb0i5RtPSABNJsXS8ZQqtxwUOxle0v6QjqMWkbeWSvH6gCeAzUv5jCIV/vk8splXGWQgXK1+66q2SwLF9xlyQrAmQ= 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=etsWmFQo; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=M+JabEGm; 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="etsWmFQo"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="M+JabEGm" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.phl.internal (Postfix) with ESMTP id CF868EC0129; Fri, 9 Jan 2026 20:39:17 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Fri, 09 Jan 2026 20:39:17 -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=1768009157; x= 1768095557; bh=bgkZrJie3U4WbN7TceY0STDRrtzjsYUXJEYO4Gsh+BM=; b=e tsWmFQoz+XriFWomAAAf0Dc0w47MIwLofnUqktEz7cjZpVG2vSiyNPFctLLrUXPl Z3sm0wHzofEIXZN/eCM0+VkU9j5+ixbWP0hLq+0FbOqq3Mn7tpaI7vhi5SwDTMMn q4gNcCRmShSTiWfq5KaSPQBx1Yk2t54fInzsxMOOKoFuLO7fiR1EH24Inz+oXn5N 5dK5i0kBhlzjTKLB/gaLb331LTV2mwfytctDZShwcwoRa1i09O9Ww+lm40PvqgsG sED92t+mzDBQEjicFF2NgVbXs3RTNO2zqqPcq9oAFCxIb2thbzwC1JnpBYaL56P/ k7Q0YG52yWN/oyeHK/llQ== 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=1768009157; x=1768095557; bh=b gkZrJie3U4WbN7TceY0STDRrtzjsYUXJEYO4Gsh+BM=; b=M+JabEGmT3ucfjEyp TLlwMMYViq7IzrPGWeIKmxI4r2tDEqWNX3tKB69qqQg6a/uM+32Rz8xMoReXUzxt gHIkWb9ZnOeTIx8/iqJoMrSbNxMYOQEqdgzSVVnk9fT428hl+0sUCYAoFZ5AVCOJ Lyz7bGx18V+vfUROdnTUYdf9xonRMx3Gdz15WiK5y1aNnIewQthUhIt90Pk9W3X3 2+/h5OmvnsgwPYcXCIe2Yo6s6o7pZSBBXUc23WapLvaTau8qW4E75hu+BSblDW0A di0cQdj97m1pou3guLuHPp6wYAgC52eBBAMmcAre2NDhhg6+a/xOQjyIkAFg7Jl8 cppyA== 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:16 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org, jgg@nvidia.com Subject: [PATCH 2/8] firewire: core: use mutex instead of spinlock for client isochronous context Date: Sat, 10 Jan 2026 10:39:05 +0900 Message-ID: <20260110013911.19160-3-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 restriction that the userspace client associated to a file descriptor can hold one isochronous context. The client-level spinning lock is used to guarantee it, however the lock is also used for multi-purposes. Additionally, there is no need to use this type of lock, and the mutex is available, instead. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-cdev.c | 40 +++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index 49dc1612c691..2b8a878c8aae 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c @@ -63,6 +63,7 @@ struct client { u64 bus_reset_closure; =20 struct fw_iso_context *iso_context; + struct mutex iso_context_mutex; u64 iso_closure; struct fw_iso_buffer buffer; unsigned long vm_start; @@ -306,6 +307,7 @@ static int fw_device_op_open(struct inode *inode, struc= t file *file) INIT_LIST_HEAD(&client->phy_receiver_link); INIT_LIST_HEAD(&client->link); kref_init(&client->kref); + mutex_init(&client->iso_context_mutex); =20 file->private_data =3D client; =20 @@ -1088,26 +1090,27 @@ static int ioctl_create_iso_context(struct client *= client, union ioctl_arg *arg) context->drop_overflow_headers =3D true; =20 // We only support one context at this time. - guard(spinlock_irq)(&client->lock); - - if (client->iso_context !=3D NULL) { - fw_iso_context_destroy(context); - - return -EBUSY; - } - if (!client->buffer_is_mapped) { - ret =3D fw_iso_buffer_map_dma(&client->buffer, - client->device->card, - iso_dma_direction(context)); - if (ret < 0) { + scoped_guard(mutex, &client->iso_context_mutex) { + if (client->iso_context !=3D NULL) { fw_iso_context_destroy(context); =20 - return ret; + return -EBUSY; } - client->buffer_is_mapped =3D true; + // 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) { + ret =3D fw_iso_buffer_map_dma(&client->buffer, client->device->card, + iso_dma_direction(context)); + if (ret < 0) { + fw_iso_context_destroy(context); + + return ret; + } + client->buffer_is_mapped =3D true; + } + client->iso_closure =3D a->closure; + client->iso_context =3D context; } - client->iso_closure =3D a->closure; - client->iso_context =3D context; =20 a->handle =3D 0; =20 @@ -1826,7 +1829,9 @@ static int fw_device_op_mmap(struct file *file, struc= t vm_area_struct *vma) if (ret < 0) return ret; =20 - scoped_guard(spinlock_irq, &client->lock) { + scoped_guard(mutex, &client->iso_context_mutex) { + // The direction of DMA can be determined if the isochronous context is = already + // allocated. If not, the DMA mapping operation is postponed after the a= llocation. if (client->iso_context) { ret =3D fw_iso_buffer_map_dma(&client->buffer, client->device->card, iso_dma_direction(client->iso_context)); @@ -1879,6 +1884,7 @@ static int fw_device_op_release(struct inode *inode, = struct file *file) =20 if (client->iso_context) fw_iso_context_destroy(client->iso_context); + mutex_destroy(&client->iso_context_mutex); =20 if (client->buffer.pages) fw_iso_buffer_destroy(&client->buffer, client->device->card); --=20 2.51.0 From nobody Mon Feb 9 11:55:52 2026 Received: from fhigh-a6-smtp.messagingengine.com (fhigh-a6-smtp.messagingengine.com [103.168.172.157]) (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 DA215238178 for ; Sat, 10 Jan 2026 01:39:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768009161; cv=none; b=G1K4mBbPgthyBqENt4ID3zOO+7e1uFLdUl0oiNI5xkG5CzsyCxK5a6Kfldf5sGTjjaQ2pMVqYdBeGfvN3uFKMtZ7VqCxbtwEORNLLeeusxnge7xRkY7TCj6DvEOKRVpWcYn/rmVY6AJRx8RipSi+LVR5wplEp7KCaOarzSALdmQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768009161; c=relaxed/simple; bh=Ol6igVD2G1M+M+pRlhUiF0UPa0x5bGP2EZkqTmp+62Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AMN1VVXjRu+AjasIBXAQ15N906nEYljV6+rkpQG9mg6Ah/hQEuJYv0u9Uamf7qlI2oTGaVFMcZQGTYVfl/EoF6UC5yFQSnxMERW207YTLtblNBYB2Qr8eucafiJpf18HER+8mXhjujBvjm8/fXoSc0oLahZvjvMPei1nuFUXlsE= 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=EUsZfGgC; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=fre9FhZZ; arc=none smtp.client-ip=103.168.172.157 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="EUsZfGgC"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="fre9FhZZ" Received: from phl-compute-09.internal (phl-compute-09.internal [10.202.2.49]) by mailfhigh.phl.internal (Postfix) with ESMTP id 2569514000B0; Fri, 9 Jan 2026 20:39:19 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-09.internal (MEProxy); Fri, 09 Jan 2026 20:39:19 -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=1768009159; x= 1768095559; bh=sVJaivj5Ky8I+xGb1QTAmBOCvix87KiE9SGbed9PRJo=; b=E UsZfGgCeltT7thGebvRanVJ+VnZhSdxzeL6Tx8EZbTwNqKTXx3KLeMZmOTno9S31 kSjcsO8gH4Qzb9tw/RapreydZwSs17tejKTp0hu6bZofh69Uo/esssnUc+IH2yvE MF08Cl5S5LRO4MMlm6CU6awrUlFz3zghd/foy8tW9fE/eXy3U4VnjeFPhrqiW50U Cq3Yj/mf+/EYnIFpdkLsf3LlW3ohj/2n8mH+rpU1b2QQ+VSG5+t3juWyitaK+nRp 596pJP//pSmvTMgdukKKaHwWvH9vs/G+nGKtDwRak7x3+feTgxo2u2Yd7vo86GoH Ht+njGHUKUgj6ypYXEFLA== 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=1768009159; x=1768095559; bh=s VJaivj5Ky8I+xGb1QTAmBOCvix87KiE9SGbed9PRJo=; b=fre9FhZZ3MGnj72Ge wx0xRwA06Gc3XCyAYuSallRcdaI2BNau9wlJfDRnzaaVj7/jzFZxxGN05txKUgPa hYm7wR7smd3j1Ux38f4ZrGFQwN0du3IfPiFQxxE/zQu4cxvJ6LuJO5Idh2Kpmmow twC5MSWZ1hP5OgAHROFLOl6uV2+7NPfIMqwzm1QIHXzSRUSC82HrWLzO1+8kE3jB Ratm6GZ6eK8BwyveT5hlt/Zl1WSfYVIfm/5oT43ovKUt/ONNv2zzhgcUJRuC+nuH T/+rJTFEYwH8NsSl+X8gp0HtBJuB2Kh1ttPlUUuwr1xQFIr/sPSFkCwLpkp/pR2q juqyQ== 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:18 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org, jgg@nvidia.com Subject: [PATCH 3/8] firewire: core: code refactoring with cleanup function for isoc pages Date: Sat, 10 Jan 2026 10:39:06 +0900 Message-ID: <20260110013911.19160-4-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" This commit refactors the implementation to allocate pages for isochronous DMA contexts with cleanup function. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-iso.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/drivers/firewire/core-iso.c b/drivers/firewire/core-iso.c index a67493862c85..e678ffba5de2 100644 --- a/drivers/firewire/core-iso.c +++ b/drivers/firewire/core-iso.c @@ -30,26 +30,29 @@ =20 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 - buffer->page_count =3D 0; - buffer->page_count_mapped =3D 0; - buffer->pages =3D kmalloc_array(page_count, sizeof(buffer->pages[0]), - GFP_KERNEL); - if (buffer->pages =3D=3D NULL) + if (!page_array) return -ENOMEM; =20 - for (i =3D 0; i < page_count; i++) { - buffer->pages[i] =3D alloc_page(GFP_KERNEL | GFP_DMA32 | __GFP_ZERO); - if (buffer->pages[i] =3D=3D NULL) + 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; } - buffer->page_count =3D i; + if (i < page_count) { - fw_iso_buffer_destroy(buffer, NULL); + while (i-- > 0) + __free_page(page_array[i]); return -ENOMEM; } =20 + buffer->page_count =3D page_count; + buffer->pages =3D no_free_ptr(page_array); + return 0; } =20 @@ -104,11 +107,14 @@ void fw_iso_buffer_destroy(struct fw_iso_buffer *buff= er, dma_unmap_page(card->device, address, PAGE_SIZE, buffer->direction); } - for (i =3D 0; i < buffer->page_count; i++) - __free_page(buffer->pages[i]); =20 - kfree(buffer->pages); - buffer->pages =3D NULL; + if (buffer->pages) { + for (int i =3D 0; i < buffer->page_count; ++i) + __free_page(buffer->pages[i]); + kfree(buffer->pages); + buffer->pages =3D NULL; + } + buffer->page_count =3D 0; buffer->page_count_mapped =3D 0; } --=20 2.51.0 From nobody Mon Feb 9 11:55:52 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 From nobody Mon Feb 9 11:55:52 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 From nobody Mon Feb 9 11:55:52 2026 Received: from fhigh-a6-smtp.messagingengine.com (fhigh-a6-smtp.messagingengine.com [103.168.172.157]) (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 C40BA239E75 for ; Sat, 10 Jan 2026 01:39:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768009165; cv=none; b=tNOQX18rZ3UzdN8ZqJrMtrk/96HDjEDIkbZQT4wObRXSSHoZ/zcmPnEEpGy9DvJsUxxjLQxlIxlZhuyRTFGa483ulGJr7lbPzOxty23guktVfsPSiG0xVak++d3J8XBqXIjzVsKysaZUtzh0XS3/kn2SJ/WAnPnOcbxLXHyYxhE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768009165; c=relaxed/simple; bh=sMIa3Izd8hc1Csv0lXR67e5vRHowGQl5UuYss6ayar4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MGg3nFOX9h83u13qmPkLkvFee9QH/4eWRIFXSOStRWZcGcd9mZn1Vdhee/sIlw7Lrs6RcFqT3TN3MYgh+m7aPR3kns1mGvKcDJGjAMg3ZMaWi/tEHkkJ3C3nwFMeqKcHxzNkElT78bYqYUsz/YIvjfLg6G1+88xhoEBaTlIWWng= 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=Eo77zuNN; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=qGFafP+v; arc=none smtp.client-ip=103.168.172.157 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="Eo77zuNN"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="qGFafP+v" Received: from phl-compute-12.internal (phl-compute-12.internal [10.202.2.52]) by mailfhigh.phl.internal (Postfix) with ESMTP id 0D15914000B3; Fri, 9 Jan 2026 20:39:23 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Fri, 09 Jan 2026 20:39:23 -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=1768009163; x= 1768095563; bh=w2apLbBCDPMElkZ2Il83KFAe9ExfrWY3DP8BCFMPYuQ=; b=E o77zuNNg9MHl3yNJcTM5UZ9PQ8JqYEJi6Uf3oAXeOsbNpbQlAaRmoL+nnH3nTLtM REITTGjktOJva+G16VsrgoelTaCimDLwBYo28LNyylu2gd7n1LuHEpDI5j6oNNN6 MP6YWv5Q0/KK0VwuvAY2NbD10+MUq7aGyu1L3ITUq0e1Y/uDWk3mvZF1b0mhICSI Q485+uVi6jXo0DWQ7DBcVgV/af76samxrDvb4vOZJYuCkb4RMmnOKorEOOxcgNgD 8qYdfOVARfNoFf4XTFDOD1GsYp8XJjm5uvXKvXScRGzpCBWfKLSHNxGI84V0DRMh d99fTJSYhSYivejV9U7IQ== 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=1768009163; x=1768095563; bh=w 2apLbBCDPMElkZ2Il83KFAe9ExfrWY3DP8BCFMPYuQ=; b=qGFafP+vMyeDIBObU AVHOTgHwtp3yVSXgPVGMPZNiB0Qd21LZUaNUYNoJDvoyqh3zYw3t7I8Ic5yKgcES xRmkwHQ6Qwoucq26wnAGbpVS3XIt2B31x49b5eMGg0zGQ9dkg3ZUcqaYOqo8gVhO XT9brRpUm6bBorjcvmX0p7FxKsoARpy4QvrJ/EqTU5tbSUG3mFT8iST7EEMRsvR3 uh4ZzWfZ55a8NHKpzHhmtdEvHjIOnohT2r+odKDKuMUDiyeHxviYIkkzsxKHROL7 eOUva9HabKZG5I9w+7T2DOWUROEOrbRs9OZ+3A93jlWAuy/jq45LhQkZIsnP6mly JKEFw== 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:21 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org, jgg@nvidia.com Subject: [PATCH 6/8] firewire: ohci: use MAX macro to guarantee minimum count of pages for AR contexts Date: Sat, 10 Jan 2026 10:39:09 +0900 Message-ID: <20260110013911.19160-7-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 computation of page size for AR DMA context can be simplified by MAX macro. Signed-off-by: Takashi Sakamoto --- drivers/firewire/ohci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index 68a336577d36..f6da4cd7d123 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c @@ -86,7 +86,7 @@ struct descriptor { #define AR_BUFFER_SIZE (32*1024) #define AR_BUFFERS_MIN DIV_ROUND_UP(AR_BUFFER_SIZE, PAGE_SIZE) /* we need at least two pages for proper list management */ -#define AR_BUFFERS (AR_BUFFERS_MIN >=3D 2 ? AR_BUFFERS_MIN : 2) +#define AR_BUFFERS MAX(2, AR_BUFFERS_MIN) =20 #define MAX_ASYNC_PAYLOAD 4096 #define MAX_AR_PACKET_SIZE (16 + MAX_ASYNC_PAYLOAD + 4) --=20 2.51.0 From nobody Mon Feb 9 11:55:52 2026 Received: from fhigh-a6-smtp.messagingengine.com (fhigh-a6-smtp.messagingengine.com [103.168.172.157]) (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 DD76223A9BD for ; Sat, 10 Jan 2026 01:39:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768009166; cv=none; b=M6PdBftkzrwmzhBWfzXdMCSmIVbawjxvw/H+MRaDKWCWbUa4GLaqKX03F3+FNT1Y20fX6mnruVsbZDB+AJwkAymypMu/rHvbnJccLhQloAEydYrCgCyKvRtvXpeqQO65moG0r70jY8PDnDyt4egeczQvAsXpusYrhrhRGx0XOWk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768009166; c=relaxed/simple; bh=Ri/rGuPzpK+ccPzTpOGc/avVpk40zMgJ9QhoG11EIzM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H/fyx90taO6bNIpb2/GOTzfpDFwylnqW8Dan/bnKLgGKg68Wjt+xbBwcgYkhmzI7f9dE9EI5Kl7tX8CUa7WZftd1EU3SFDEetra0WXLG+sx+R6YoeAWfu7YzL/a0ADjAXVLJVbiL3IcOydbWuIoU5FAMPk/LMj6KvfCS1YdG9I0= 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=NMjw86Id; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=Qowb2bcg; arc=none smtp.client-ip=103.168.172.157 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="NMjw86Id"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Qowb2bcg" Received: from phl-compute-09.internal (phl-compute-09.internal [10.202.2.49]) by mailfhigh.phl.internal (Postfix) with ESMTP id 5891B14000FB; Fri, 9 Jan 2026 20:39:24 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-09.internal (MEProxy); Fri, 09 Jan 2026 20:39:24 -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=1768009164; x= 1768095564; bh=VgBfqooDKEgNn8IDcbep9PMHlwrIxlzMxOmAvkjasI8=; b=N Mjw86Id/9FB/VY0dvinhzilc8OPFxYaJoav2doDI3kQRioOx5p8BxKuqTNnDm2em D8wgGTajYy0Dlex5veqc/joU2lhYrMgGL5XCsXhQdFNtNjo3y0hLAvGpIJi8C9Gh XDteoWskFoxFiLjtCcnYKrjhcZDHCIzGj0KkS8TKCo2bkmsZRvIpRa4ZIfwFwTKU XE/KoxV99hTfhMNOzojgZ/8AxJtjsQkAqou+8Cm32sXQHqekjbyW7ninvtjmPz+O 7GKYBFsjLDsWF18yhSyHHULluXclZTXRpGorcBiy+Pi7Fp+DVGsXZHWTLu8xROtc X7SQyaZTXKjyRBqpovydg== 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=1768009164; x=1768095564; bh=V gBfqooDKEgNn8IDcbep9PMHlwrIxlzMxOmAvkjasI8=; b=Qowb2bcgRyBKpxJc7 Nb2D/NLJ7L9XF+Na2HjYeCwE/kvqwF6KhNm8Bt5nuacoy+Gd1t49ryDpTiTPLwPL SLvMFNiws9VeEMp+xA+9zGg1H90hVt30XsMqqHWiBH3eB6m9l9GiszW/ETHNLPVA syyxe8GJO5lUoevg2D27QWdfyrUqgCo+ya56ySDG6l/lFyigC6L9cL79DY13Lj+n mQfFboxrHhLnJtJm06ercs8DPK0652GywZHfaVpYJp03Vo8BCyt8XqwxlRXhv1C7 98suxPz7e6jCrWFXq2DuLdoyQhy5xYEiQ3jtcv3gphJfCZUmYasKJosUkedKuP6a uN2sQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdduuddtfeelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtkeertd ertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghkrghs hhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeejvdetteduhf eivdehgeeivdekgfektdelfedtteeljeekvdeukeehkedvgffgveenucffohhmrghinhep khgvrhhnvghlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjphdpnhgspghr tghpthhtohepfedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoheplhhinhhugidufe elgedquggvvhgvlheslhhishhtshdrshhouhhrtggvfhhorhhgvgdrnhgvthdprhgtphht thhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtph htthhopehjghhgsehnvhhiughirgdrtghomh X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 9 Jan 2026 20:39:23 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org, jgg@nvidia.com Subject: [PATCH 7/8] firewire: ohci: split page allocation from dma mapping Date: Sat, 10 Jan 2026 10:39:10 +0900 Message-ID: <20260110013911.19160-8-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" 1394 OHCI PCI driver had long been the only user of dma_alloc_pages(). Although tee subsystem recently started using it, they are still a few users of the infrequently-used function. In the discussion for dma-mapping function, Jason Gunthorpe shows his opinion about the design of public API for the function. According to it, the users provide physical address to the function, then receive DMA mapping address, regardless of the location of mapping target. With the above aspects, this commit eliminates the use of dma_alloc_pages() from this subsystem. Link: https://lore.kernel.org/lkml/20250905174324.GI616306@nvidia.com/ Signed-off-by: Takashi Sakamoto --- drivers/firewire/ohci.c | 77 +++++++++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 26 deletions(-) diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index f6da4cd7d123..e34965acb925 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c @@ -539,18 +539,22 @@ static void ar_context_link_page(struct ar_context *c= tx, unsigned int index) static void ar_context_release(struct ar_context *ctx) { struct device *dev =3D ctx->ohci->card.device; - unsigned int i; =20 if (!ctx->buffer) return; =20 - vunmap(ctx->buffer); + for (int i =3D 0; i < AR_BUFFERS; ++i) { + dma_addr_t dma_addr =3D page_private(ctx->pages[i]); =20 - for (i =3D 0; i < AR_BUFFERS; i++) { - if (ctx->pages[i]) - dma_free_pages(dev, PAGE_SIZE, ctx->pages[i], - ar_buffer_bus(ctx, i), DMA_FROM_DEVICE); + dma_unmap_page(dev, dma_addr, PAGE_SIZE, DMA_FROM_DEVICE); + set_page_private(ctx->pages[i], 0); } + + vunmap(ctx->buffer); + ctx->buffer =3D NULL; + + release_pages(ctx->pages, AR_BUFFERS); + memset(ctx->pages, 0, sizeof(ctx->pages)); } =20 static void ar_context_abort(struct ar_context *ctx, const char *error_msg) @@ -845,31 +849,57 @@ static int ar_context_init(struct ar_context *ctx, st= ruct fw_ohci *ohci, { struct device *dev =3D ohci->card.device; unsigned int i; - dma_addr_t dma_addr; struct page *pages[AR_BUFFERS + AR_WRAPAROUND_PAGES]; + void *vaddr; struct descriptor *d; =20 ctx->regs =3D regs; ctx->ohci =3D ohci; INIT_WORK(&ctx->work, ohci_ar_context_work); =20 - for (i =3D 0; i < AR_BUFFERS; i++) { - ctx->pages[i] =3D dma_alloc_pages(dev, PAGE_SIZE, &dma_addr, - DMA_FROM_DEVICE, GFP_KERNEL); - if (!ctx->pages[i]) - goto out_of_memory; - set_page_private(ctx->pages[i], dma_addr); - dma_sync_single_for_device(dev, dma_addr, PAGE_SIZE, - DMA_FROM_DEVICE); + // Retrieve noncontiguous pages. The descriptors for 1394 OHCI AR DMA con= texts have a set + // of address and length per each. The reason to use pages is to construc= t contiguous + // address range in kernel virtual address space. + unsigned long nr_populated =3D alloc_pages_bulk(GFP_KERNEL | GFP_DMA32, A= R_BUFFERS, pages); + + if (nr_populated !=3D AR_BUFFERS) { + release_pages(pages, nr_populated); + return -ENOMEM; } =20 - for (i =3D 0; i < AR_BUFFERS; i++) - pages[i] =3D ctx->pages[i]; + // Map the pages into contiguous kernel virtual addresses so that the pac= ket data + // across the pages can be referred as being contiguous, especially acros= s the last + // and first pages. for (i =3D 0; i < AR_WRAPAROUND_PAGES; i++) - pages[AR_BUFFERS + i] =3D ctx->pages[i]; - ctx->buffer =3D vmap(pages, ARRAY_SIZE(pages), VM_MAP, PAGE_KERNEL); - if (!ctx->buffer) - goto out_of_memory; + pages[AR_BUFFERS + i] =3D pages[i]; + vaddr =3D vmap(pages, ARRAY_SIZE(pages), VM_MAP, PAGE_KERNEL); + if (!vaddr) { + release_pages(pages, nr_populated); + return -ENOMEM; + } + + // 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 < AR_BUFFERS; i++) { + // The dma_map_phys() with a physical address per page is available here= , instead. + dma_addr_t dma_addr =3D dma_map_page(dev, pages[i], 0, PAGE_SIZE, DMA_FR= OM_DEVICE); + if (dma_mapping_error(dev, dma_addr)) + break; + set_page_private(pages[i], dma_addr); + dma_sync_single_for_device(dev, dma_addr, PAGE_SIZE, DMA_FROM_DEVICE); + } + if (i < AR_BUFFERS) { + while (i-- > 0) { + dma_addr_t dma_addr =3D page_private(pages[i]); + dma_unmap_page(dev, dma_addr, PAGE_SIZE, DMA_FROM_DEVICE); + } + vunmap(vaddr); + release_pages(pages, nr_populated); + return -ENOMEM; + } + + ctx->buffer =3D vaddr; + memcpy(ctx->pages, pages, sizeof(ctx->pages)); =20 ctx->descriptors =3D ohci->misc_buffer + descriptors_offset; ctx->descriptors_bus =3D ohci->misc_buffer_bus + descriptors_offset; @@ -886,11 +916,6 @@ static int ar_context_init(struct ar_context *ctx, str= uct fw_ohci *ohci, } =20 return 0; - -out_of_memory: - ar_context_release(ctx); - - return -ENOMEM; } =20 static void ar_context_run(struct ar_context *ctx) --=20 2.51.0 From nobody Mon Feb 9 11:55:52 2026 Received: from fhigh-a6-smtp.messagingengine.com (fhigh-a6-smtp.messagingengine.com [103.168.172.157]) (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 65CF623B62B for ; Sat, 10 Jan 2026 01:39:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768009176; cv=none; b=fRzb3f4lMBoBeDRJg0sxKQl5f6+UYt/Zruh7z3f7txNOElYv0fYHXaDUMzMFghHuxQOEugeyVHBIEi9L82tXWe+zSAYxPl3qanTRcIshAJ2ab/UhEN+/yw6YAUHoKPkOjOzm18VRtgFS8MBRWhFUSM9GQTE+UN0tH1H4gQDQ9A8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768009176; c=relaxed/simple; bh=jTfpCoUp+JBLFGoYQOTJWb+tIVx3sqr5L5hxyicsQKE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WNEaGCQHHZYpJcALtV29+LjWl24qvxHu2Sq4CQkp6OOyo5CrJuklipi2mYHhqGqnUXwMFmhSe+fX3hC7YezXPFeiS76sfPYHVU9s5gmx7UymurpN8NmYlmLP62aX93Fwe47co3+q4VdEzI+5jFWVCuWAqDgxwZhYvpMzix75jpQ= 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=NAcQgHG4; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=QCPu9agA; arc=none smtp.client-ip=103.168.172.157 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="NAcQgHG4"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="QCPu9agA" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.phl.internal (Postfix) with ESMTP id A8C191400100; Fri, 9 Jan 2026 20:39:25 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Fri, 09 Jan 2026 20:39:25 -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=1768009165; x= 1768095565; bh=H39eFB7dHZGvrVm7AcOydI1W4i68bG/6Nu3FCkdDSKU=; b=N AcQgHG4+b7E6EH5WyT/6yDWqBb2gSPl4UZRb28gkKAIp2YfObOCrDhN82JK0wBYT 76d3UvC0T+OSFCRoykh1c/2dj1D9uXzn7mdma0r4PhJ/Ugl6WXHqBSAqJoTkOduI vjgofIY7KuJSMGNOYd2+Mxs5SfbUkfdGbZTPZTavIg/0v9gYVEJ/hpUmpkkPYXeQ jyAwNUwNeN9TvkBQC3jjquIdGwOGxuqxf713PCqYy08tJzsKWzMSPNfzPq4t7aZ7 ecUZMUKYTZPfe+1oLZX0rLI6307RzcIk1rtXJJ6PJSatmeBbrncR6nidSTME/v0o 9tUjitpu4e8X8Kq7YoQgQ== 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=1768009165; x=1768095565; bh=H 39eFB7dHZGvrVm7AcOydI1W4i68bG/6Nu3FCkdDSKU=; b=QCPu9agAUfyE7la+/ CMJTpxVd+RjcZhPTEShDbASoMa9c6S50jlQQkqN/RheoBBor/034JJgUq3dUrpvg dX4NnTOUuV1Y7vx470x8DDKnx5ceeNeDw6hbQw7zrmCB4iJR0eXNnPA3fn6oC0V2 pcWFYrSaZCE3B3b3Nm6Nh4VTqCCJ1Onb0zrw+BER1rx9zR+8xHLDTPhuS2GmGvQO 0daX4Wxj8E4IsjpxVv+f2lb1tFPgEsSXrcKUxIRWf3vmi/65GGHO5cJY+eLT069W ysQ8FXn7L/DvuoZArji95OzbPpAZpGbwTXnEWEOxoeeZNgq+Z5mB/lX6OkoiTBBS 25B/A== 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:24 -0500 (EST) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org, jgg@nvidia.com Subject: [PATCH 8/8] firewire: ohci: stop using page private to store DMA mapping address Date: Sat, 10 Jan 2026 10:39:11 +0900 Message-ID: <20260110013911.19160-9-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 AR context, to prepare for mm future change. Signed-off-by: Takashi Sakamoto --- drivers/firewire/ohci.c | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index e34965acb925..a43fe680d508 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c @@ -96,6 +96,7 @@ struct ar_context { struct fw_ohci *ohci; struct page *pages[AR_BUFFERS]; void *buffer; + dma_addr_t dma_addrs[AR_BUFFERS]; struct descriptor *descriptors; dma_addr_t descriptors_bus; void *pointer; @@ -513,11 +514,6 @@ static int ohci_update_phy_reg(struct fw_card *card, i= nt addr, return update_phy_reg(ohci, addr, clear_bits, set_bits); } =20 -static inline dma_addr_t ar_buffer_bus(struct ar_context *ctx, unsigned in= t i) -{ - return page_private(ctx->pages[i]); -} - static void ar_context_link_page(struct ar_context *ctx, unsigned int inde= x) { struct descriptor *d; @@ -544,11 +540,11 @@ static void ar_context_release(struct ar_context *ctx) return; =20 for (int i =3D 0; i < AR_BUFFERS; ++i) { - dma_addr_t dma_addr =3D page_private(ctx->pages[i]); - - dma_unmap_page(dev, dma_addr, PAGE_SIZE, DMA_FROM_DEVICE); - set_page_private(ctx->pages[i], 0); + dma_addr_t dma_addr =3D ctx->dma_addrs[i]; + if (dma_addr) + dma_unmap_page(dev, dma_addr, PAGE_SIZE, DMA_FROM_DEVICE); } + memset(ctx->dma_addrs, 0, sizeof(ctx->dma_addrs)); =20 vunmap(ctx->buffer); ctx->buffer =3D NULL; @@ -647,14 +643,12 @@ static void ar_sync_buffers_for_cpu(struct ar_context= *ctx, =20 i =3D ar_first_buffer_index(ctx); while (i !=3D end_buffer_index) { - dma_sync_single_for_cpu(ctx->ohci->card.device, - ar_buffer_bus(ctx, i), - PAGE_SIZE, DMA_FROM_DEVICE); + dma_sync_single_for_cpu(ctx->ohci->card.device, ctx->dma_addrs[i], PAGE_= SIZE, + DMA_FROM_DEVICE); i =3D ar_next_buffer_index(i); } if (end_buffer_offset > 0) - dma_sync_single_for_cpu(ctx->ohci->card.device, - ar_buffer_bus(ctx, i), + dma_sync_single_for_cpu(ctx->ohci->card.device, ctx->dma_addrs[i], end_buffer_offset, DMA_FROM_DEVICE); } =20 @@ -795,9 +789,8 @@ static void ar_recycle_buffers(struct ar_context *ctx, = unsigned int end_buffer) =20 i =3D ar_first_buffer_index(ctx); while (i !=3D end_buffer) { - dma_sync_single_for_device(ctx->ohci->card.device, - ar_buffer_bus(ctx, i), - PAGE_SIZE, DMA_FROM_DEVICE); + dma_sync_single_for_device(ctx->ohci->card.device, ctx->dma_addrs[i], PA= GE_SIZE, + DMA_FROM_DEVICE); ar_context_link_page(ctx, i); i =3D ar_next_buffer_index(i); } @@ -850,6 +843,7 @@ static int ar_context_init(struct ar_context *ctx, stru= ct fw_ohci *ohci, struct device *dev =3D ohci->card.device; unsigned int i; struct page *pages[AR_BUFFERS + AR_WRAPAROUND_PAGES]; + dma_addr_t dma_addrs[AR_BUFFERS]; void *vaddr; struct descriptor *d; =20 @@ -885,19 +879,18 @@ static int ar_context_init(struct ar_context *ctx, st= ruct fw_ohci *ohci, dma_addr_t dma_addr =3D dma_map_page(dev, pages[i], 0, PAGE_SIZE, DMA_FR= OM_DEVICE); if (dma_mapping_error(dev, dma_addr)) break; - set_page_private(pages[i], dma_addr); + dma_addrs[i] =3D dma_addr; dma_sync_single_for_device(dev, dma_addr, PAGE_SIZE, DMA_FROM_DEVICE); } if (i < AR_BUFFERS) { - while (i-- > 0) { - dma_addr_t dma_addr =3D page_private(pages[i]); - dma_unmap_page(dev, dma_addr, PAGE_SIZE, DMA_FROM_DEVICE); - } + while (i-- > 0) + dma_unmap_page(dev, dma_addrs[i], PAGE_SIZE, DMA_FROM_DEVICE); vunmap(vaddr); release_pages(pages, nr_populated); return -ENOMEM; } =20 + memcpy(ctx->dma_addrs, dma_addrs, sizeof(ctx->dma_addrs)); ctx->buffer =3D vaddr; memcpy(ctx->pages, pages, sizeof(ctx->pages)); =20 @@ -910,7 +903,7 @@ static int ar_context_init(struct ar_context *ctx, stru= ct fw_ohci *ohci, d->control =3D cpu_to_le16(DESCRIPTOR_INPUT_MORE | DESCRIPTOR_STATUS | DESCRIPTOR_BRANCH_ALWAYS); - d->data_address =3D cpu_to_le32(ar_buffer_bus(ctx, i)); + d->data_address =3D cpu_to_le32(ctx->dma_addrs[i]); d->branch_address =3D cpu_to_le32(ctx->descriptors_bus + ar_next_buffer_index(i) * sizeof(struct descriptor)); } --=20 2.51.0