From patchwork Sun Sep 8 04:05:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 13795319 Received: from fout2-smtp.messagingengine.com (fout2-smtp.messagingengine.com [103.168.172.145]) (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 3AC031C6A3; Sun, 8 Sep 2024 04:05:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.145 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725768358; cv=none; b=FHpv84cCGDFvngwdf1Od3MYFC5LDzq5LNRcvtDH+VXV1ugshfD1K9FHbCY5MPjapGYG0xmrIi5hQXzXIoT3H8VDAeghgMwqXncXrUSGgh3sGOkeqr0nTekqiAVVrfVanFNTaKklPg1Ubxhfjuy9DN4aJ41pyc/821rjB0Hn4Hsg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725768358; c=relaxed/simple; bh=J1c3/nOGUYXW5uEzGGBsX0YXh6C+4ObMNDeGZYE5sy4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BmsCEwwA9mk4BSOr+LIwAiVlfBlWmAiq0Pcudi6KVvgBdsgKPVyvsao6TGjriEVSU8HXalPzF6vhwsAvE1IHYF5zHHLtZMx8J3vUxFDgFo4eI6yvEEKUBXgCHCvw+LWe0SJ+IqJVxr/RaDUjRO0uLG0DyqWeFfQ6ufbOc3CYCD4= 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=kr6K13Q/; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=OZ7trhaz; arc=none smtp.client-ip=103.168.172.145 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="kr6K13Q/"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="OZ7trhaz" Received: from phl-compute-05.internal (phl-compute-05.phl.internal [10.202.2.45]) by mailfout.phl.internal (Postfix) with ESMTP id 5870E13802A3; Sun, 8 Sep 2024 00:05:55 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Sun, 08 Sep 2024 00:05:55 -0400 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=fm1; t=1725768355; x= 1725854755; bh=mJwi+7OIrvSrvVQo9tdtMjx8ghAQaQmxWlk/p3qeXeM=; b=k r6K13Q/lId0bkyeHz9WsNagIQgNOyBbaGBD1s7nYQiyQfnGkFzo5ERgwDBkQvMzF Bub++Qq1ZNOPZVmxpcZBjHqK9/iVaBbVA9LRtS7JMrTIdfHFnZyJXF6/nrrbYqYp qdkXu/HDERNC6mST0kFm3EB8qzA61B0/KmdS3fRKqIwZNfM7TaJ19tYTQVbn75H8 1dbfNKnro4+3H9Cb86SD31L6qcQ/UEYaw2/EIDekCTYSJAb/7rfkmpTwohnBSGnV n0dOYocArf713wrzkltmgtgJtvlWnIyqHxmpVmE2KsR3SADnVtbodDvUwCEqPPpy 1jLcjrPxOcbYkvvXiOSuw== 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-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1725768355; x= 1725854755; bh=mJwi+7OIrvSrvVQo9tdtMjx8ghAQaQmxWlk/p3qeXeM=; b=O Z7trhazK5ERy8eRvIPAmRu+o+wJcvZF+bNV4spz8aX3NQaB14W/llVJMIkq0YY/U ip6EwXBLEfudGGXBeJiVXSZpPsVR/llmXq3HHDDCFecLv7PfJrtLJyogbi5Umcuu t2K+5dPjKXb+zQSZjhztetw7SWM/2xszvA28v8jfmuUAWOoFaJOIAvFvELNjHYoY AIYRYx+AnuUyCGboLZld0O3fp5za9Z82dJk3mrbFcnyikSds+Bilxx+aUdpSVK3d ulrprQ4tXIqom8MpLblXoSh45SP4WVwFZNwkGZtcc5a51PQ1//z1mDRLrKTI1XkN xQbNJKMHKPmaUg+0nl8ng== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudeigedgjeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevuf ffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghm ohhtohcuoehoqdhtrghkrghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrg htthgvrhhnpedvjefgjeeuvdfguddukeelveetgfdtvefhtdfffeeigfevueetffeivdff kedvtdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hoqdhtrghkrghshhhisehsrghkrghmohgttghhihdrjhhppdhnsggprhgtphhtthhopeef pdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehlihhnuhigudefleegqdguvghvvg hlsehlihhsthhsrdhsohhurhgtvghfohhrghgvrdhnvghtpdhrtghpthhtoheplhhinhhu gidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinh hugidqshhouhhnugesvhhgvghrrdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 8 Sep 2024 00:05:54 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org Subject: [PATCH 1/2] firewire: core: expose kernel API to schedule work item to process isochronous context Date: Sun, 8 Sep 2024 13:05:48 +0900 Message-ID: <20240908040549.75304-2-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240908040549.75304-1-o-takashi@sakamocchi.jp> References: <20240908040549.75304-1-o-takashi@sakamocchi.jp> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In packet-per-buffer mode for isochronous context of 1394 OHCI, software can schedule hardIRQ to the buffer in which the content of isochronous packet is processed. The actual behaviour is different between isochronous receive (IR) and transmit (IT) contexts in respect to isochronous cycle in which the hardIRQ occurs. In IR context, the hardIRQ occurs when the buffer is filled actually by the content of received packet. If there are any isochronous cycles in which the packet transmission is skipped, it is postponed to generate the hardIRQ in respect to the isochronous cycle. In IT context, software can schedule the content of packet every isochronous cycle including skipping, therefore the hardIRQ occurs in the isochronous cycle to which the software scheduled. ALSA firewire stack uses the packet-per-buffer mode for both IR/IT contexts. To process time stamp per packet (or per sample in some cases) steadily for media clock recovery against unexpected transmission skips, it uses an IT context to operate all of isochronous contexts by calls of fw_iso_context_flush_completions() in the bottom-half of hardIRQ for the IT context. Although it looks well to handle all of isochronous contexts in a single bottom-half context, it relatively takes longer time. In the future code integration (not yet), it is possible to apply parallelism method to process these context. In the case, it is useful to allow unit drivers to schedule work items to process these isochronous contexts. As a preparation, this commit exposes fw_iso_context_schedule_flush_completions() as a kernel API available by unit drivers. It is renamed from fw_iso_context_queue_work() since it is a counter part of fw_iso_context_flush_completions(). Signed-off-by: Takashi Sakamoto --- Documentation/driver-api/firewire.rst | 2 ++ drivers/firewire/core.h | 5 ----- drivers/firewire/ohci.c | 4 ++-- include/linux/firewire.h | 17 +++++++++++++++++ 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Documentation/driver-api/firewire.rst b/Documentation/driver-api/firewire.rst index d3cfa73cbb2b..28a32410f7d2 100644 --- a/Documentation/driver-api/firewire.rst +++ b/Documentation/driver-api/firewire.rst @@ -43,6 +43,8 @@ Firewire core transaction interfaces Firewire Isochronous I/O interfaces =================================== +.. kernel-doc:: include/linux/firewire.h + :functions: fw_iso_context_schedule_flush_completions .. kernel-doc:: drivers/firewire/core-iso.c :export: diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h index 2874f316156a..0ae2c84ecafe 100644 --- a/drivers/firewire/core.h +++ b/drivers/firewire/core.h @@ -164,11 +164,6 @@ static inline void fw_iso_context_init_work(struct fw_iso_context *ctx, work_fun INIT_WORK(&ctx->work, func); } -static inline void fw_iso_context_queue_work(struct fw_iso_context *ctx) -{ - queue_work(ctx->card->isoc_wq, &ctx->work); -} - /* -topology */ diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index d0b1fccc450f..3a911cfb5ff3 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c @@ -2283,7 +2283,7 @@ static irqreturn_t irq_handler(int irq, void *data) while (iso_event) { i = ffs(iso_event) - 1; - fw_iso_context_queue_work(&ohci->ir_context_list[i].base); + fw_iso_context_schedule_flush_completions(&ohci->ir_context_list[i].base); iso_event &= ~(1 << i); } } @@ -2294,7 +2294,7 @@ static irqreturn_t irq_handler(int irq, void *data) while (iso_event) { i = ffs(iso_event) - 1; - fw_iso_context_queue_work(&ohci->it_context_list[i].base); + fw_iso_context_schedule_flush_completions(&ohci->it_context_list[i].base); iso_event &= ~(1 << i); } } diff --git a/include/linux/firewire.h b/include/linux/firewire.h index 72f497b61739..f815d12deda0 100644 --- a/include/linux/firewire.h +++ b/include/linux/firewire.h @@ -531,6 +531,23 @@ int fw_iso_context_queue(struct fw_iso_context *ctx, unsigned long payload); void fw_iso_context_queue_flush(struct fw_iso_context *ctx); int fw_iso_context_flush_completions(struct fw_iso_context *ctx); + +/** + * fw_iso_context_schedule_flush_completions() - schedule work item to process isochronous context. + * @ctx: the isochronous context + * + * Schedule a work item on workqueue to process the isochronous context. The registered callback + * function is called in the worker if some packets have been already transferred since the last + * time. If it is required to process the context in the current context, + * fw_iso_context_flush_completions() is available instead. + * + * Context: Any context. + */ +static inline void fw_iso_context_schedule_flush_completions(struct fw_iso_context *ctx) +{ + queue_work(ctx->card->isoc_wq, &ctx->work); +} + int fw_iso_context_start(struct fw_iso_context *ctx, int cycle, int sync, int tags); int fw_iso_context_stop(struct fw_iso_context *ctx); From patchwork Sun Sep 8 04:05:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 13795320 Received: from fout2-smtp.messagingengine.com (fout2-smtp.messagingengine.com [103.168.172.145]) (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 A783629D19; Sun, 8 Sep 2024 04:05:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.145 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725768359; cv=none; b=A8zQv331AeIgVTjwBN0FcbbNCuTFxSbajALfiB9foici+/6YC0dUCE9DPQS7aIZXuZ+QqTKfO33xoFtCfBZ1Sqi6afel/R8r3VyweA28UKGao96kZAYE1RJHhWtbqwb0UE3lpG/yHJ7FIf4bUh7dXoX4OevE77Y2HD7x26GsX+I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725768359; c=relaxed/simple; bh=ZX3+HkeTf3IDOyCdWnmGLRu2Y1CXaszCrkxBkeSgqyY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QpjZa7cUFxWeDw3ar6g/Rcvu7G9TI4AaB1P7gkmIZXRNRi4395XPBTuMmWe9+Pene05moaFMqZ488e0VFuK078M6EwhnUAvdhmYR9whZLZpBLrBDWBzFg4OQXvUcQfvoU0NA/2cLFZmLkfSj7+sBCrs9UDvLdT34GeMgKbR8Ae4= 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=cQKJtZXJ; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=BI6uAxry; arc=none smtp.client-ip=103.168.172.145 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="cQKJtZXJ"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="BI6uAxry" Received: from phl-compute-09.internal (phl-compute-09.phl.internal [10.202.2.49]) by mailfout.phl.internal (Postfix) with ESMTP id D3A8D13802A2; Sun, 8 Sep 2024 00:05:56 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-09.internal (MEProxy); Sun, 08 Sep 2024 00:05:56 -0400 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=fm1; t=1725768356; x= 1725854756; bh=g3rVD5AMlaA9gk9eYXsId57UmfOtU4hWVY6wnZR27GA=; b=c QKJtZXJVfBhH88DEnrt3ibxpI4iMC/52cmJ/tYqis6dXH9WrNWomXW/yaMKjZMZ4 3xBj4dS8Szyd6OIiD4phP4T5H+holYErWY1EXyTc69cDvIUsld8ka/CzuvO8ehM3 JFlBugPverI0lOazy+RoOlMaCTUKOijk9cJQo83GrMQFBVS51Y0YeHMZAvyMKPU6 K6+Lk6Um3anOqiuZJBDEsCNWvwQwWGhi2ka13001ZrcbaMTaVhEARbS0UkmIyXgq JF2nwokCRJghCK0mZNBrrs11RIoEpGskrQQbYIpPJdjz0j4LySjD/l7zGx7JMJ+G OtwTLkHM11JDwGNVJ8y+Q== 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-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1725768356; x= 1725854756; bh=g3rVD5AMlaA9gk9eYXsId57UmfOtU4hWVY6wnZR27GA=; b=B I6uAxrygoNzOunL6IUC00vJAsU2GItBvlfqpOEkLB+EgbvlwUDDmKWd9byYaP9na XplNlhuT3hpfaTgknTrABiEqIS58e6qxKLZ8Kzxx6UavaVquOGG3ZA3L1tEYGFXi SdgtxmJbC3kijUxzrf8Ox7f5YY4pXekdqpMod7pxzluIy9lL0vHB26Xjqlysd/7E 6yNm+VaVm5VZbD+/NcHT0N1GgJOSU+FqAYnpWn2tCmSxbqmRI8D3OtCOWSWBiEg1 cv81Hu7V53MWlRR7nQBH4qazuqrjK67ycF1b5/o6863Dl86QOqeRjZhFJHXI2roW 5ZAJIeDlm/PSAzO2N3rGg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudeigedgjeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevuf ffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghm ohhtohcuoehoqdhtrghkrghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrg htthgvrhhnpedvjefgjeeuvdfguddukeelveetgfdtvefhtdfffeeigfevueetffeivdff kedvtdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hoqdhtrghkrghshhhisehsrghkrghmohgttghhihdrjhhppdhnsggprhgtphhtthhopeef pdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehlihhnuhigudefleegqdguvghvvg hlsehlihhsthhsrdhsohhurhgtvghfohhrghgvrdhnvghtpdhrtghpthhtoheplhhinhhu gidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinh hugidqshhouhhnugesvhhgvghrrdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 8 Sep 2024 00:05:55 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org Subject: [PATCH 2/2] firewire: core: fulfill documentation of fw_iso_context_flush_completions() Date: Sun, 8 Sep 2024 13:05:49 +0900 Message-ID: <20240908040549.75304-3-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240908040549.75304-1-o-takashi@sakamocchi.jp> References: <20240908040549.75304-1-o-takashi@sakamocchi.jp> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The fw_iso_context_flush_completions() is the counterpart of fw_iso_context_schedule_work() to process isochronous context in current process context. This commit fulfills its documentation. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-iso.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/firewire/core-iso.c b/drivers/firewire/core-iso.c index a249974a0f87..f2394f3ed194 100644 --- a/drivers/firewire/core-iso.c +++ b/drivers/firewire/core-iso.c @@ -209,6 +209,17 @@ void fw_iso_context_queue_flush(struct fw_iso_context *ctx) } EXPORT_SYMBOL(fw_iso_context_queue_flush); +/** + * fw_iso_context_flush_completions() - process isochronous context in current process context. + * @ctx: the isochronous context + * + * Process the isochronous context in the current process context. The registered callback function + * is called if some packets have been already transferred since the last time. If it is required + * to process the context asynchronously, fw_iso_context_schedule_flush_completions() is available + * instead. + * + * Context: Process context. May sleep due to disable_work_sync(). + */ int fw_iso_context_flush_completions(struct fw_iso_context *ctx) { int err;