From patchwork Mon Jan 9 02:17:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 640938 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6006DC54EBC for ; Mon, 9 Jan 2023 02:18:45 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 7715F8A24; Mon, 9 Jan 2023 03:17:53 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 7715F8A24 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673230723; bh=QQ+ysRLrKaKEED9EZZcLcwnSHJEnYtESaKwVYm8Xwr4=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=VsD7RC5NEkWNv77+Y2t8f8L+aEAF40qq+5sJv5BM6KGxT8G2HQScYUORJm1Egwn8N K1fJZlzVBgj/08/agsonY2J2XTJ8R2Hn55X5GbICKW6Obc0Gd2g2/3Jb1xj/5vLmUc 7wzgtAJxIyRzvdOiRLDf4HdtTLgOmau5R2wnNOK0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 3710DF804D9; Mon, 9 Jan 2023 03:17:53 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D9251F804DC; Mon, 9 Jan 2023 03:17:51 +0100 (CET) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id B61FFF80236 for ; Mon, 9 Jan 2023 03:17:46 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B61FFF80236 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.a=rsa-sha256 header.s=fm3 header.b=IA5Y1GrU; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=fop2WOcT Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 6C2AC5C007A; Sun, 8 Jan 2023 21:17:45 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Sun, 08 Jan 2023 21:17:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1673230665; x= 1673317065; bh=6NqHpuEHWVrn5HpT90XSJk2Abb5pY4uZHPL5ol0KGyU=; b=I A5Y1GrU0zosZXZ37PfUFFVOH8fP++m/KG1fo7Bne8rZD1Fy2QYP1ts9VlVdPvUmU Uw0ts51gt2vTDj6p2IEvb7n5Wa6ZpjmDSFWWrkgLEA1hnQaEJi78SdtcUUDA3KCb QT9rCYQPfRDVtGQjqxBDgGuRDe0IUNRq5KpUgXIwsKgCL/YuG3cAXQROnsMhrp0U GKYOkJ4bVlWMEZHviKFcnCDLKelxLj26/QdhYRLU/zcOvUHZuvtQEgRgCw/absQR FcTdG9Vi4EX4bx5bYPEgQJImt93atAOIPqARKn7UJcCQIky+4wTSj/cE+E2JXijS Yj18/+k4oMEJ2YaOWLNDA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1673230665; x=1673317065; bh=6NqHpuEHWVrn5 HpT90XSJk2Abb5pY4uZHPL5ol0KGyU=; b=fop2WOcTwm2+Cr+eWIhNVa8heLZPb vzpROBr6+UTVvjFsGec9rPkGpio/qgX8HtHnrhWmcDUtNym2oQllEI/bwWax8RI2 q1xkiyNkDtcC05j6tbIsemwt6hJnehrozNKuPAq0/ZH6XyfVzj8ACp7mmLWT7Emt g4gJSEHofJQ03sDr4KzD2yuEol/IAN/ZmO2aKY29/X2UpINA12At60nqfphqs7Gk XhpvxyP6kcWstm5BUoNXRy1udl+08u+Ms14VZ5tiYcf+VPRz+yXitKsb8Gl4mjXY fpjsT9ZwWKn4CooGlohmr5s+JDg9EVqoSosVF+gSXqgsOsYSR/NhaHPBA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrkeehgdegiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejue dvgfduudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihessh grkhgrmhhotggthhhirdhjph X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 8 Jan 2023 21:17:44 -0500 (EST) From: Takashi Sakamoto To: tiwai@suse.de Subject: [PATCH 1/3] ALSA: firewire-lib: use circular linked list to enumerate packet descriptors Date: Mon, 9 Jan 2023 11:17:36 +0900 Message-Id: <20230109021738.75543-2-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230109021738.75543-1-o-takashi@sakamocchi.jp> References: <20230109021738.75543-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alsa-devel@alsa-project.org, clemens@ladisch.de Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Current implementation uses list of packet descriptor as template to schedule isochronous packet. The packet descriptors are operated by position and size, while circular linked list is convenient to enumerate the packet descriptors. This commit utilizes circular linked list for the purpose. Signed-off-by: Takashi Sakamoto --- sound/firewire/amdtp-stream.c | 47 ++++++++++++++++++++++------------- sound/firewire/amdtp-stream.h | 12 +++++++++ 2 files changed, 42 insertions(+), 17 deletions(-) diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c index 5ecb449ff6fa..794ac693aae6 100644 --- a/sound/firewire/amdtp-stream.c +++ b/sound/firewire/amdtp-stream.c @@ -504,7 +504,7 @@ static unsigned int calculate_cached_cycle_count(struct amdtp_stream *s, unsigne return cycles; } -static void cache_seq(struct amdtp_stream *s, const struct pkt_desc *descs, unsigned int desc_count) +static void cache_seq(struct amdtp_stream *s, const struct pkt_desc *src, unsigned int desc_count) { const unsigned int transfer_delay = s->transfer_delay; const unsigned int cache_size = s->ctx_data.tx.cache.size; @@ -515,7 +515,6 @@ static void cache_seq(struct amdtp_stream *s, const struct pkt_desc *descs, unsi for (i = 0; i < desc_count; ++i) { struct seq_desc *dst = cache + cache_pos; - const struct pkt_desc *src = descs + i; if (aware_syt && src->syt != CIP_SYT_NO_INFO) dst->syt_offset = compute_syt_offset(src->syt, src->cycle, transfer_delay); @@ -524,6 +523,7 @@ static void cache_seq(struct amdtp_stream *s, const struct pkt_desc *descs, unsi dst->data_blocks = src->data_blocks; cache_pos = (cache_pos + 1) % cache_size; + src = amdtp_stream_next_packet_desc(s, src); } s->ctx_data.tx.cache.pos = cache_pos; @@ -881,7 +881,7 @@ static inline u32 compute_ohci_it_cycle(const __be32 ctx_header_tstamp, return increment_ohci_cycle_count(cycle, queue_size); } -static int generate_tx_packet_descs(struct amdtp_stream *s, struct pkt_desc *descs, +static int generate_tx_packet_descs(struct amdtp_stream *s, struct pkt_desc *desc, const __be32 *ctx_header, unsigned int packet_count, unsigned int *desc_count) { @@ -894,7 +894,6 @@ static int generate_tx_packet_descs(struct amdtp_stream *s, struct pkt_desc *des *desc_count = 0; for (i = 0; i < packet_count; ++i) { - struct pkt_desc *desc = descs + *desc_count; unsigned int cycle; bool lost; unsigned int data_blocks; @@ -918,7 +917,7 @@ static int generate_tx_packet_descs(struct amdtp_stream *s, struct pkt_desc *des desc->data_blocks = 0; desc->data_block_counter = dbc; desc->ctx_payload = NULL; - ++desc; + desc = amdtp_stream_next_packet_desc(s, desc); ++(*desc_count); } } else if (s->flags & CIP_JUMBO_PAYLOAD) { @@ -951,6 +950,7 @@ static int generate_tx_packet_descs(struct amdtp_stream *s, struct pkt_desc *des dbc = (dbc + desc->data_blocks) & 0xff; next_cycle = increment_ohci_cycle_count(next_cycle, 1); + desc = amdtp_stream_next_packet_desc(s, desc); ++(*desc_count); ctx_header += s->ctx_data.tx.ctx_header_size / sizeof(*ctx_header); packet_index = (packet_index + 1) % queue_size; @@ -973,7 +973,7 @@ static unsigned int compute_syt(unsigned int syt_offset, unsigned int cycle, return syt & CIP_SYT_MASK; } -static void generate_rx_packet_descs(struct amdtp_stream *s, struct pkt_desc *descs, +static void generate_rx_packet_descs(struct amdtp_stream *s, struct pkt_desc *desc, const __be32 *ctx_header, unsigned int packet_count) { struct seq_desc *seq_descs = s->ctx_data.rx.seq.descs; @@ -986,7 +986,6 @@ static void generate_rx_packet_descs(struct amdtp_stream *s, struct pkt_desc *de pool_seq_descs(s, seq_descs, seq_size, seq_pos, packet_count); for (i = 0; i < packet_count; ++i) { - struct pkt_desc *desc = descs + i; unsigned int index = (s->packet_index + i) % s->queue_size; const struct seq_desc *seq = seq_descs + seq_pos; @@ -1010,6 +1009,7 @@ static void generate_rx_packet_descs(struct amdtp_stream *s, struct pkt_desc *de desc->ctx_payload = s->buffer.packets[index].buffer; seq_pos = (seq_pos + 1) % seq_size; + desc = amdtp_stream_next_packet_desc(s, desc); ++ctx_header; } @@ -1047,6 +1047,7 @@ static void process_rx_packets(struct fw_iso_context *context, u32 tstamp, size_ const __be32 *ctx_header = header; const unsigned int events_per_period = d->events_per_period; unsigned int event_count = s->ctx_data.rx.event_count; + struct pkt_desc *desc = s->pkt_descs; unsigned int pkt_header_length; unsigned int packets; bool need_hw_irq; @@ -1058,9 +1059,9 @@ static void process_rx_packets(struct fw_iso_context *context, u32 tstamp, size_ // Calculate the number of packets in buffer and check XRUN. packets = header_length / sizeof(*ctx_header); - generate_rx_packet_descs(s, s->pkt_descs, ctx_header, packets); + generate_rx_packet_descs(s, desc, ctx_header, packets); - process_ctx_payloads(s, s->pkt_descs, packets); + process_ctx_payloads(s, desc, packets); if (!(s->flags & CIP_NO_HEADER)) pkt_header_length = IT_PKT_HEADER_SIZE_CIP; @@ -1078,7 +1079,6 @@ static void process_rx_packets(struct fw_iso_context *context, u32 tstamp, size_ } for (i = 0; i < packets; ++i) { - const struct pkt_desc *desc = s->pkt_descs + i; struct { struct fw_iso_packet params; __be32 header[CIP_HEADER_QUADLETS]; @@ -1101,6 +1101,8 @@ static void process_rx_packets(struct fw_iso_context *context, u32 tstamp, size_ cancel_stream(s); return; } + + desc = amdtp_stream_next_packet_desc(s, desc); } s->ctx_data.rx.event_count = event_count; @@ -1200,6 +1202,7 @@ static void process_tx_packets(struct fw_iso_context *context, u32 tstamp, size_ { struct amdtp_stream *s = private_data; __be32 *ctx_header = header; + struct pkt_desc *desc = s->pkt_descs; unsigned int packet_count; unsigned int desc_count; int i; @@ -1212,7 +1215,7 @@ static void process_tx_packets(struct fw_iso_context *context, u32 tstamp, size_ packet_count = header_length / s->ctx_data.tx.ctx_header_size; desc_count = 0; - err = generate_tx_packet_descs(s, s->pkt_descs, ctx_header, packet_count, &desc_count); + err = generate_tx_packet_descs(s, desc, ctx_header, packet_count, &desc_count); if (err < 0) { if (err != -EAGAIN) { cancel_stream(s); @@ -1221,10 +1224,10 @@ static void process_tx_packets(struct fw_iso_context *context, u32 tstamp, size_ } else { struct amdtp_domain *d = s->domain; - process_ctx_payloads(s, s->pkt_descs, desc_count); + process_ctx_payloads(s, desc, desc_count); if (d->replay.enable) - cache_seq(s, s->pkt_descs, desc_count); + cache_seq(s, desc, desc_count); } for (i = 0; i < packet_count; ++i) { @@ -1547,7 +1550,8 @@ static int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed, unsigned int ctx_header_size; unsigned int max_ctx_payload_size; enum dma_data_direction dir; - int type, tag, err; + struct pkt_desc *descs; + int i, type, tag, err; mutex_lock(&s->mutex); @@ -1655,12 +1659,19 @@ static int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed, else s->tag = TAG_CIP; - s->pkt_descs = kcalloc(s->queue_size, sizeof(*s->pkt_descs), - GFP_KERNEL); - if (!s->pkt_descs) { + descs = kcalloc(s->queue_size, sizeof(*descs), GFP_KERNEL); + if (!descs) { err = -ENOMEM; goto err_context; } + s->pkt_descs = descs; + + INIT_LIST_HEAD(&s->packet_descs_list); + for (i = 0; i < s->queue_size; ++i) { + INIT_LIST_HEAD(&descs->link); + list_add_tail(&descs->link, &s->packet_descs_list); + ++descs; + } s->packet_index = 0; do { @@ -1700,6 +1711,7 @@ static int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed, return 0; err_pkt_descs: kfree(s->pkt_descs); + s->pkt_descs = NULL; err_context: if (s->direction == AMDTP_OUT_STREAM) { kfree(s->ctx_data.rx.seq.descs); @@ -1794,6 +1806,7 @@ static void amdtp_stream_stop(struct amdtp_stream *s) s->context = ERR_PTR(-1); iso_packets_buffer_destroy(&s->buffer, s->unit); kfree(s->pkt_descs); + s->pkt_descs = NULL; if (s->direction == AMDTP_OUT_STREAM) { kfree(s->ctx_data.rx.seq.descs); diff --git a/sound/firewire/amdtp-stream.h b/sound/firewire/amdtp-stream.h index f021c1f49137..4bf701796166 100644 --- a/sound/firewire/amdtp-stream.h +++ b/sound/firewire/amdtp-stream.h @@ -103,6 +103,7 @@ struct pkt_desc { unsigned int data_blocks; unsigned int data_block_counter; __be32 *ctx_payload; + struct list_head link; }; struct amdtp_stream; @@ -126,6 +127,7 @@ struct amdtp_stream { unsigned int queue_size; int packet_index; struct pkt_desc *pkt_descs; + struct list_head packet_descs_list; int tag; union { struct { @@ -276,6 +278,16 @@ static inline void amdtp_stream_pcm_trigger(struct amdtp_stream *s, WRITE_ONCE(s->pcm, pcm); } +/** + * amdtp_stream_next_packet_desc - retrieve next descriptor for amdtp packet. + * @s: the AMDTP stream + * @desc: the descriptor of packet + * + * This macro computes next descriptor so that the list of descriptors behaves circular queue. + */ +#define amdtp_stream_next_packet_desc(s, desc) \ + list_next_entry_circular(desc, &s->packet_descs_list, link) + static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc) { return sfc & 1; From patchwork Mon Jan 9 02:17:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 640714 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9244EC61DB3 for ; Mon, 9 Jan 2023 02:19:39 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id CD66D8A55; Mon, 9 Jan 2023 03:18:47 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz CD66D8A55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673230777; bh=DrCfU/IuAmWewChOVRWON85IbXcUfD7VuJgFc+xwT1E=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=R3fKZbHF8a6GN11bCvHEOCbeWTxdMX7ZTssVtsJVZAXcCm+wqgPVNwxPc3k2BaGSp kgCmitT3J/V0ZICIzqe/7w7Sgx5Fq8DsK314srx94OX2o1nfKVtjNPFRPdwTM7XCmm 4rKJoh2LRQgKNzh+Vbnm26MWUpEgbh+1AVQ8OESg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id C18C9F80553; Mon, 9 Jan 2023 03:17:58 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id AFF4FF804BD; Mon, 9 Jan 2023 03:17:57 +0100 (CET) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 8C68BF804BD for ; Mon, 9 Jan 2023 03:17:47 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8C68BF804BD Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.a=rsa-sha256 header.s=fm3 header.b=g6JA+CRA; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=I/Dh4eKz Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id D01225C0094; Sun, 8 Jan 2023 21:17:46 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Sun, 08 Jan 2023 21:17:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1673230666; x= 1673317066; bh=zgwbMvKHSftrMDX0bIzhtglMebSJF8Z7hUtoDaq+z0o=; b=g 6JA+CRA0+2+prb626JHgp1qlpmMYZ7osm/8eqRh36ETbsVYCKBrFxm5lbrpDcmct MROjqYguacPAA1LlQvJ6c62w3U6b8QTxjOcqWcpK7/cQCZB9ZZf7XbU6mXBTyj+O ukarK+5Jd8Ws9KDnIeUCq/TfihHAic+QtFOZOGF9ROWF8TN/3nHIa3t/5/djs6jI zX9ITU9wX8ty3OxEgI3YSipOIRFWj6zgUGosRH4PagBNakkHjs6GAjwx2rHoH3rm 6uWtyHCavPqc6UXEubr2O/zNvLaih+0edTFy+P/uvE9Ski05aO5H42mu9HSAOPz9 j6miI0oCnhAbsj7XMtZtA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1673230666; x=1673317066; bh=zgwbMvKHSftrM DX0bIzhtglMebSJF8Z7hUtoDaq+z0o=; b=I/Dh4eKzgZIeL4S3prRV/+Yvqo20z QbP+N6yEoBbXfQuBwwTBxi7biK3xkro+KqJ734weUySnavb4zZa/fubbSPHaD/UF W76nK0PlHQsEsb1zq9AacxrpyJMrKns63du41IIYUYFVg2hQUIcEUrgrdrkC1m4b cPVr8/YoFWcKqwzlBqprY5BWt8+UvHCbyK9UZLGF99dmPrKgasOG1N3lv+z/0YvZ w0H8uxYCBV5yqo10IToeWKxqLvOSdr6g9gASLyMY7xXE/GAN9wQeayseJpBjwIlJ 1DArZTOa3kDTzFKEynMfe0rnoujHEy0th5T35rlxWTcmH2/kCxRL84wsg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrkeehgdegiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejue dvgfduudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihessh grkhgrmhhotggthhhirdhjph X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 8 Jan 2023 21:17:45 -0500 (EST) From: Takashi Sakamoto To: tiwai@suse.de Subject: [PATCH 2/3] ALSA: firewire-lib: use circular linked list for context payload processing layer Date: Mon, 9 Jan 2023 11:17:37 +0900 Message-Id: <20230109021738.75543-3-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230109021738.75543-1-o-takashi@sakamocchi.jp> References: <20230109021738.75543-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alsa-devel@alsa-project.org, clemens@ladisch.de Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" The list of packet descriptor is passed to context payload processing layer so that each driver can copy PCM frames, MIDI messages, and device specific data between packet payload buffer and intermediate buffer for user space application. The list of packet descriptor was replaced by circular linked list in a previous commit. This commit uses circular linked in context payload processing layer as well. Signed-off-by: Takashi Sakamoto --- sound/firewire/amdtp-am824.c | 18 +++---- sound/firewire/amdtp-stream.c | 4 +- sound/firewire/amdtp-stream.h | 2 +- sound/firewire/digi00x/amdtp-dot.c | 18 +++---- sound/firewire/fireface/amdtp-ff.c | 18 +++---- sound/firewire/motu/amdtp-motu.c | 48 ++++++++++--------- .../motu/motu-command-dsp-message-parser.c | 11 +++-- .../motu/motu-register-dsp-message-parser.c | 11 +++-- sound/firewire/motu/motu.h | 8 ++-- sound/firewire/tascam/amdtp-tascam.c | 18 +++---- 10 files changed, 87 insertions(+), 69 deletions(-) diff --git a/sound/firewire/amdtp-am824.c b/sound/firewire/amdtp-am824.c index d9c700f652bb..cf55f7784d23 100644 --- a/sound/firewire/amdtp-am824.c +++ b/sound/firewire/amdtp-am824.c @@ -347,16 +347,15 @@ static void read_midi_messages(struct amdtp_stream *s, __be32 *buffer, } static unsigned int process_it_ctx_payloads(struct amdtp_stream *s, - const struct pkt_desc *descs, - unsigned int packets, + const struct pkt_desc *desc, + unsigned int count, struct snd_pcm_substream *pcm) { struct amdtp_am824 *p = s->protocol; unsigned int pcm_frames = 0; int i; - for (i = 0; i < packets; ++i) { - const struct pkt_desc *desc = descs + i; + for (i = 0; i < count; ++i) { __be32 *buf = desc->ctx_payload; unsigned int data_blocks = desc->data_blocks; @@ -371,22 +370,23 @@ static unsigned int process_it_ctx_payloads(struct amdtp_stream *s, write_midi_messages(s, buf, data_blocks, desc->data_block_counter); } + + desc = amdtp_stream_next_packet_desc(s, desc); } return pcm_frames; } static unsigned int process_ir_ctx_payloads(struct amdtp_stream *s, - const struct pkt_desc *descs, - unsigned int packets, + const struct pkt_desc *desc, + unsigned int count, struct snd_pcm_substream *pcm) { struct amdtp_am824 *p = s->protocol; unsigned int pcm_frames = 0; int i; - for (i = 0; i < packets; ++i) { - const struct pkt_desc *desc = descs + i; + for (i = 0; i < count; ++i) { __be32 *buf = desc->ctx_payload; unsigned int data_blocks = desc->data_blocks; @@ -399,6 +399,8 @@ static unsigned int process_ir_ctx_payloads(struct amdtp_stream *s, read_midi_messages(s, buf, data_blocks, desc->data_block_counter); } + + desc = amdtp_stream_next_packet_desc(s, desc); } return pcm_frames; diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c index 794ac693aae6..006dc939065f 100644 --- a/sound/firewire/amdtp-stream.c +++ b/sound/firewire/amdtp-stream.c @@ -1028,13 +1028,13 @@ static inline void cancel_stream(struct amdtp_stream *s) static void process_ctx_payloads(struct amdtp_stream *s, const struct pkt_desc *descs, - unsigned int packets) + unsigned int count) { struct snd_pcm_substream *pcm; unsigned int pcm_frames; pcm = READ_ONCE(s->pcm); - pcm_frames = s->process_ctx_payloads(s, descs, packets, pcm); + pcm_frames = s->process_ctx_payloads(s, descs, count, pcm); if (pcm) update_pcm_pointers(s, pcm, pcm_frames); } diff --git a/sound/firewire/amdtp-stream.h b/sound/firewire/amdtp-stream.h index 4bf701796166..84156d0d57b8 100644 --- a/sound/firewire/amdtp-stream.h +++ b/sound/firewire/amdtp-stream.h @@ -110,7 +110,7 @@ struct amdtp_stream; typedef unsigned int (*amdtp_stream_process_ctx_payloads_t)( struct amdtp_stream *s, const struct pkt_desc *desc, - unsigned int packets, + unsigned int count, struct snd_pcm_substream *pcm); struct amdtp_domain; diff --git a/sound/firewire/digi00x/amdtp-dot.c b/sound/firewire/digi00x/amdtp-dot.c index 59b86c8d89e1..fcae7d07aa03 100644 --- a/sound/firewire/digi00x/amdtp-dot.c +++ b/sound/firewire/digi00x/amdtp-dot.c @@ -342,15 +342,14 @@ void amdtp_dot_midi_trigger(struct amdtp_stream *s, unsigned int port, } static unsigned int process_ir_ctx_payloads(struct amdtp_stream *s, - const struct pkt_desc *descs, - unsigned int packets, + const struct pkt_desc *desc, + unsigned int count, struct snd_pcm_substream *pcm) { unsigned int pcm_frames = 0; int i; - for (i = 0; i < packets; ++i) { - const struct pkt_desc *desc = descs + i; + for (i = 0; i < count; ++i) { __be32 *buf = desc->ctx_payload; unsigned int data_blocks = desc->data_blocks; @@ -360,21 +359,22 @@ static unsigned int process_ir_ctx_payloads(struct amdtp_stream *s, } read_midi_messages(s, buf, data_blocks); + + desc = amdtp_stream_next_packet_desc(s, desc); } return pcm_frames; } static unsigned int process_it_ctx_payloads(struct amdtp_stream *s, - const struct pkt_desc *descs, - unsigned int packets, + const struct pkt_desc *desc, + unsigned int count, struct snd_pcm_substream *pcm) { unsigned int pcm_frames = 0; int i; - for (i = 0; i < packets; ++i) { - const struct pkt_desc *desc = descs + i; + for (i = 0; i < count; ++i) { __be32 *buf = desc->ctx_payload; unsigned int data_blocks = desc->data_blocks; @@ -387,6 +387,8 @@ static unsigned int process_it_ctx_payloads(struct amdtp_stream *s, write_midi_messages(s, buf, data_blocks, desc->data_block_counter); + + desc = amdtp_stream_next_packet_desc(s, desc); } return pcm_frames; diff --git a/sound/firewire/fireface/amdtp-ff.c b/sound/firewire/fireface/amdtp-ff.c index 98177b0666d3..2402e2be87a6 100644 --- a/sound/firewire/fireface/amdtp-ff.c +++ b/sound/firewire/fireface/amdtp-ff.c @@ -113,15 +113,14 @@ int amdtp_ff_add_pcm_hw_constraints(struct amdtp_stream *s, } static unsigned int process_it_ctx_payloads(struct amdtp_stream *s, - const struct pkt_desc *descs, - unsigned int packets, + const struct pkt_desc *desc, + unsigned int count, struct snd_pcm_substream *pcm) { unsigned int pcm_frames = 0; int i; - for (i = 0; i < packets; ++i) { - const struct pkt_desc *desc = descs + i; + for (i = 0; i < count; ++i) { __le32 *buf = (__le32 *)desc->ctx_payload; unsigned int data_blocks = desc->data_blocks; @@ -131,21 +130,22 @@ static unsigned int process_it_ctx_payloads(struct amdtp_stream *s, } else { write_pcm_silence(s, buf, data_blocks); } + + desc = amdtp_stream_next_packet_desc(s, desc); } return pcm_frames; } static unsigned int process_ir_ctx_payloads(struct amdtp_stream *s, - const struct pkt_desc *descs, - unsigned int packets, + const struct pkt_desc *desc, + unsigned int count, struct snd_pcm_substream *pcm) { unsigned int pcm_frames = 0; int i; - for (i = 0; i < packets; ++i) { - const struct pkt_desc *desc = descs + i; + for (i = 0; i < count; ++i) { __le32 *buf = (__le32 *)desc->ctx_payload; unsigned int data_blocks = desc->data_blocks; @@ -153,6 +153,8 @@ static unsigned int process_ir_ctx_payloads(struct amdtp_stream *s, read_pcm_s32(s, pcm, buf, data_blocks, pcm_frames); pcm_frames += data_blocks; } + + desc = amdtp_stream_next_packet_desc(s, desc); } return pcm_frames; diff --git a/sound/firewire/motu/amdtp-motu.c b/sound/firewire/motu/amdtp-motu.c index 2fb52f481d12..ea0063cec5fb 100644 --- a/sound/firewire/motu/amdtp-motu.c +++ b/sound/firewire/motu/amdtp-motu.c @@ -284,19 +284,19 @@ static void __maybe_unused copy_message(u64 *frames, __be32 *buffer, } } -static void probe_tracepoints_events(struct amdtp_stream *s, - const struct pkt_desc *descs, - unsigned int packets) +static void probe_tracepoints_events(struct amdtp_stream *s, const struct pkt_desc *desc, + unsigned int count) { int i; - for (i = 0; i < packets; ++i) { - const struct pkt_desc *desc = descs + i; + for (i = 0; i < count; ++i) { __be32 *buf = desc->ctx_payload; unsigned int data_blocks = desc->data_blocks; trace_data_block_sph(s, data_blocks, buf); trace_data_block_message(s, data_blocks, buf); + + desc = amdtp_stream_next_packet_desc(s, desc); } } @@ -329,12 +329,13 @@ static void cache_event_offsets(struct amdtp_motu_cache *cache, const __be32 *bu } static unsigned int process_ir_ctx_payloads(struct amdtp_stream *s, - const struct pkt_desc *descs, - unsigned int packets, + const struct pkt_desc *desc, + unsigned int count, struct snd_pcm_substream *pcm) { struct snd_motu *motu = container_of(s, struct snd_motu, tx_stream); struct amdtp_motu *p = s->protocol; + const struct pkt_desc *cursor = desc; unsigned int pcm_frames = 0; int i; @@ -342,8 +343,7 @@ static unsigned int process_ir_ctx_payloads(struct amdtp_stream *s, p->cache->tx_cycle_count = (s->domain->processing_cycle.tx_start % CYCLES_PER_SECOND); // For data block processing. - for (i = 0; i < packets; ++i) { - const struct pkt_desc *desc = descs + i; + for (i = 0; i < count; ++i) { __be32 *buf = desc->ctx_payload; unsigned int data_blocks = desc->data_blocks; @@ -356,20 +356,20 @@ static unsigned int process_ir_ctx_payloads(struct amdtp_stream *s, if (p->midi_ports) read_midi_messages(s, buf, data_blocks); - } - if (motu->spec->flags & SND_MOTU_SPEC_REGISTER_DSP) { - snd_motu_register_dsp_message_parser_parse(motu, descs, packets, - s->data_block_quadlets); - } else if (motu->spec->flags & SND_MOTU_SPEC_COMMAND_DSP) { - snd_motu_command_dsp_message_parser_parse(motu, descs, packets, - s->data_block_quadlets); + desc = amdtp_stream_next_packet_desc(s, desc); } + desc = cursor; + if (motu->spec->flags & SND_MOTU_SPEC_REGISTER_DSP) + snd_motu_register_dsp_message_parser_parse(s, desc, count); + else if (motu->spec->flags & SND_MOTU_SPEC_COMMAND_DSP) + snd_motu_command_dsp_message_parser_parse(s, desc, count); + // For tracepoints. if (trace_data_block_sph_enabled() || trace_data_block_message_enabled()) - probe_tracepoints_events(s, descs, packets); + probe_tracepoints_events(s, desc, count); return pcm_frames; } @@ -397,11 +397,12 @@ static void write_sph(struct amdtp_motu_cache *cache, __be32 *buffer, unsigned i } static unsigned int process_it_ctx_payloads(struct amdtp_stream *s, - const struct pkt_desc *descs, - unsigned int packets, + const struct pkt_desc *desc, + unsigned int count, struct snd_pcm_substream *pcm) { struct amdtp_motu *p = s->protocol; + const struct pkt_desc *cursor = desc; unsigned int pcm_frames = 0; int i; @@ -409,8 +410,7 @@ static unsigned int process_it_ctx_payloads(struct amdtp_stream *s, p->cache->rx_cycle_count = (s->domain->processing_cycle.rx_start % CYCLES_PER_SECOND); // For data block processing. - for (i = 0; i < packets; ++i) { - const struct pkt_desc *desc = descs + i; + for (i = 0; i < count; ++i) { __be32 *buf = desc->ctx_payload; unsigned int data_blocks = desc->data_blocks; @@ -425,12 +425,16 @@ static unsigned int process_it_ctx_payloads(struct amdtp_stream *s, write_midi_messages(s, buf, data_blocks); write_sph(p->cache, buf, data_blocks, s->data_block_quadlets); + + desc = amdtp_stream_next_packet_desc(s, desc); } + desc = cursor; + // For tracepoints. if (trace_data_block_sph_enabled() || trace_data_block_message_enabled()) - probe_tracepoints_events(s, descs, packets); + probe_tracepoints_events(s, desc, count); return pcm_frames; } diff --git a/sound/firewire/motu/motu-command-dsp-message-parser.c b/sound/firewire/motu/motu-command-dsp-message-parser.c index 9efe4d364baf..5d8a86a12f1f 100644 --- a/sound/firewire/motu/motu-command-dsp-message-parser.c +++ b/sound/firewire/motu/motu-command-dsp-message-parser.c @@ -80,9 +80,11 @@ int snd_motu_command_dsp_message_parser_init(struct snd_motu *motu, enum cip_sfc #define FRAGMENTS_PER_VALUE 4 #define VALUES_AT_IMAGE_END 0xffffffffffffffff -void snd_motu_command_dsp_message_parser_parse(struct snd_motu *motu, const struct pkt_desc *descs, - unsigned int desc_count, unsigned int data_block_quadlets) +void snd_motu_command_dsp_message_parser_parse(const struct amdtp_stream *s, + const struct pkt_desc *desc, unsigned int count) { + struct snd_motu *motu = container_of(s, struct snd_motu, tx_stream); + unsigned int data_block_quadlets = s->data_block_quadlets; struct msg_parser *parser = motu->message_parser; unsigned int interval = parser->interval; unsigned long flags; @@ -90,12 +92,13 @@ void snd_motu_command_dsp_message_parser_parse(struct snd_motu *motu, const stru spin_lock_irqsave(&parser->lock, flags); - for (i = 0; i < desc_count; ++i) { - const struct pkt_desc *desc = descs + i; + for (i = 0; i < count; ++i) { __be32 *buffer = desc->ctx_payload; unsigned int data_blocks = desc->data_blocks; int j; + desc = amdtp_stream_next_packet_desc(s, desc); + for (j = 0; j < data_blocks; ++j) { u8 *b = (u8 *)buffer; buffer += data_block_quadlets; diff --git a/sound/firewire/motu/motu-register-dsp-message-parser.c b/sound/firewire/motu/motu-register-dsp-message-parser.c index 0c587567540f..ef3b0b0f0dab 100644 --- a/sound/firewire/motu/motu-register-dsp-message-parser.c +++ b/sound/firewire/motu/motu-register-dsp-message-parser.c @@ -142,9 +142,11 @@ static void queue_event(struct snd_motu *motu, u8 msg_type, u8 identifier0, u8 i parser->push_pos = pos; } -void snd_motu_register_dsp_message_parser_parse(struct snd_motu *motu, const struct pkt_desc *descs, - unsigned int desc_count, unsigned int data_block_quadlets) +void snd_motu_register_dsp_message_parser_parse(const struct amdtp_stream *s, + const struct pkt_desc *desc, unsigned int count) { + struct snd_motu *motu = container_of(s, struct snd_motu, tx_stream); + unsigned int data_block_quadlets = s->data_block_quadlets; struct msg_parser *parser = motu->message_parser; bool meter_pos_quirk = parser->meter_pos_quirk; unsigned int pos = parser->push_pos; @@ -153,12 +155,13 @@ void snd_motu_register_dsp_message_parser_parse(struct snd_motu *motu, const str spin_lock_irqsave(&parser->lock, flags); - for (i = 0; i < desc_count; ++i) { - const struct pkt_desc *desc = descs + i; + for (i = 0; i < count; ++i) { __be32 *buffer = desc->ctx_payload; unsigned int data_blocks = desc->data_blocks; int j; + desc = amdtp_stream_next_packet_desc(s, desc); + for (j = 0; j < data_blocks; ++j) { u8 *b = (u8 *)buffer; u8 msg_type = (b[MSG_FLAG_POS] & MSG_FLAG_TYPE_MASK) >> MSG_FLAG_TYPE_SHIFT; diff --git a/sound/firewire/motu/motu.h b/sound/firewire/motu/motu.h index 4189f2192284..3b1dc98a7be0 100644 --- a/sound/firewire/motu/motu.h +++ b/sound/firewire/motu/motu.h @@ -279,8 +279,8 @@ static inline int snd_motu_protocol_cache_packet_formats(struct snd_motu *motu) int snd_motu_register_dsp_message_parser_new(struct snd_motu *motu); int snd_motu_register_dsp_message_parser_init(struct snd_motu *motu); -void snd_motu_register_dsp_message_parser_parse(struct snd_motu *motu, const struct pkt_desc *descs, - unsigned int desc_count, unsigned int data_block_quadlets); +void snd_motu_register_dsp_message_parser_parse(const struct amdtp_stream *s, + const struct pkt_desc *descs, unsigned int count); void snd_motu_register_dsp_message_parser_copy_meter(struct snd_motu *motu, struct snd_firewire_motu_register_dsp_meter *meter); void snd_motu_register_dsp_message_parser_copy_parameter(struct snd_motu *motu, @@ -290,8 +290,8 @@ bool snd_motu_register_dsp_message_parser_copy_event(struct snd_motu *motu, u32 int snd_motu_command_dsp_message_parser_new(struct snd_motu *motu); int snd_motu_command_dsp_message_parser_init(struct snd_motu *motu, enum cip_sfc sfc); -void snd_motu_command_dsp_message_parser_parse(struct snd_motu *motu, const struct pkt_desc *descs, - unsigned int desc_count, unsigned int data_block_quadlets); +void snd_motu_command_dsp_message_parser_parse(const struct amdtp_stream *s, + const struct pkt_desc *descs, unsigned int count); void snd_motu_command_dsp_message_parser_copy_meter(struct snd_motu *motu, struct snd_firewire_motu_command_dsp_meter *meter); diff --git a/sound/firewire/tascam/amdtp-tascam.c b/sound/firewire/tascam/amdtp-tascam.c index 64d66a802545..c367a6ee6121 100644 --- a/sound/firewire/tascam/amdtp-tascam.c +++ b/sound/firewire/tascam/amdtp-tascam.c @@ -177,15 +177,14 @@ static void read_status_messages(struct amdtp_stream *s, } static unsigned int process_ir_ctx_payloads(struct amdtp_stream *s, - const struct pkt_desc *descs, - unsigned int packets, + const struct pkt_desc *desc, + unsigned int count, struct snd_pcm_substream *pcm) { unsigned int pcm_frames = 0; int i; - for (i = 0; i < packets; ++i) { - const struct pkt_desc *desc = descs + i; + for (i = 0; i < count; ++i) { __be32 *buf = desc->ctx_payload; unsigned int data_blocks = desc->data_blocks; @@ -195,21 +194,22 @@ static unsigned int process_ir_ctx_payloads(struct amdtp_stream *s, } read_status_messages(s, buf, data_blocks); + + desc = amdtp_stream_next_packet_desc(s, desc); } return pcm_frames; } static unsigned int process_it_ctx_payloads(struct amdtp_stream *s, - const struct pkt_desc *descs, - unsigned int packets, + const struct pkt_desc *desc, + unsigned int count, struct snd_pcm_substream *pcm) { unsigned int pcm_frames = 0; int i; - for (i = 0; i < packets; ++i) { - const struct pkt_desc *desc = descs + i; + for (i = 0; i < count; ++i) { __be32 *buf = desc->ctx_payload; unsigned int data_blocks = desc->data_blocks; @@ -219,6 +219,8 @@ static unsigned int process_it_ctx_payloads(struct amdtp_stream *s, } else { write_pcm_silence(s, buf, data_blocks); } + + desc = amdtp_stream_next_packet_desc(s, desc); } return pcm_frames; From patchwork Mon Jan 9 02:17:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 640715 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EAECBC54EBD for ; Mon, 9 Jan 2023 02:18:55 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 4317F8A35; Mon, 9 Jan 2023 03:18:03 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4317F8A35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673230733; bh=x6wpKG7SiuKXbPgbOV8uFGRKMWza+3OGT5Qklvwr1LI=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=XBr2En1f3dJUVlLjNwM2zn8DRhJKaqJV9pTrfPWsFnV5vdIrptqXD0abO4mGbzRpA 1uilKC1WAW+oYTiXZp8YkSZVOCgK14mVWXIlLTbWc7ysywvvmrLjeFuJgekBfNBx0o DaskLlQU+YSAT4THOyjwIbweMzFW6RaBjN+zTVjg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 14FD0F804DD; Mon, 9 Jan 2023 03:17:54 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7AC7BF804DC; Mon, 9 Jan 2023 03:17:52 +0100 (CET) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 4CC09F804D9 for ; Mon, 9 Jan 2023 03:17:48 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4CC09F804D9 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.a=rsa-sha256 header.s=fm3 header.b=b3yfLs5j; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=skekFnYa Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 2A9125C00B0; Sun, 8 Jan 2023 21:17:48 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Sun, 08 Jan 2023 21:17:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1673230668; x= 1673317068; bh=Lb0qaaltjygtBi1wp4EQ+VP3kcbzQrUE+0aGW8KUv78=; b=b 3yfLs5jQQfc12I6CQIbgdqUCfshftMmVaI6oiW67yjsJCEFuQomHGu44SKUzOL9X btd0o+LhhAjavoDIHdFCM1I0xU00TP7iQoUYtSdeIbNVzQTyhoWGdx1Grs80QarP i1UsWuqOHNvk1OkiYUja/c/cAWuQz8aQo0oUt80bxl3aS2kX6L58QPNIKU/GZfUl iAz/DjYGwz9TNYbSUYoA46jQISwSV16cd9q7hi6RbHIhTtv18kcDHrhRuZFO/+n4 eumbq5V0SJZejJMCilHzigeLaxwirFfVvq+8c0yU1jZjfg7zHqYAzVXzxOsdpptH lSZUIVp12JiKz14dh03NQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1673230668; x=1673317068; bh=Lb0qaaltjygtB i1wp4EQ+VP3kcbzQrUE+0aGW8KUv78=; b=skekFnYa4DR3ova+8PrLAhBOTEQnC rsP6FAnpAUZ3Jk+zbLHKoGNdyjtgWc0PFiCd4d68//ZP7xpijCNUbZXStSUOgxEn MPZRxvSNjUBN4R+oKAv6m6v/nBT5T+rQFnuOJOUI1sCrz0gLtcB0x7BaTYJQTNIW TIXq7UBOiM3/FUvgwTlV1UKVgLa6BTIE9Wno8u5ERfVEq76jAmu60+2TggbXJL30 V0DfXZHRlFUS0lppFjDjZEbZE3JWCewOOSDG7m48j7glvut/oG65J507KojG96H3 9vup0kNc2DXGB3PJeLjx+wH9BetnJvBuae8ZqxsO+6X4lKk16FLprhilA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrkeehgdegiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejue dvgfduudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihessh grkhgrmhhotggthhhirdhjph X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 8 Jan 2023 21:17:47 -0500 (EST) From: Takashi Sakamoto To: tiwai@suse.de Subject: [PATCH 3/3] ALSA: firewire-lib: keep history to process isochronous packet Date: Mon, 9 Jan 2023 11:17:38 +0900 Message-Id: <20230109021738.75543-4-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230109021738.75543-1-o-takashi@sakamocchi.jp> References: <20230109021738.75543-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alsa-devel@alsa-project.org, clemens@ladisch.de Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" The history to process isochronous packets is useful when computing gap between current isochronous cycle and the latest isochronous cycle in which packet is processed (in IR context) and scheduled (in IT context). This commit stores the most recent packet descriptors to keep the history. Signed-off-by: Takashi Sakamoto --- sound/firewire/amdtp-stream.c | 20 +++++++++++++------- sound/firewire/amdtp-stream.h | 3 ++- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c index 006dc939065f..430b33dc60b3 100644 --- a/sound/firewire/amdtp-stream.c +++ b/sound/firewire/amdtp-stream.c @@ -1047,7 +1047,7 @@ static void process_rx_packets(struct fw_iso_context *context, u32 tstamp, size_ const __be32 *ctx_header = header; const unsigned int events_per_period = d->events_per_period; unsigned int event_count = s->ctx_data.rx.event_count; - struct pkt_desc *desc = s->pkt_descs; + struct pkt_desc *desc = s->packet_descs_cursor; unsigned int pkt_header_length; unsigned int packets; bool need_hw_irq; @@ -1106,6 +1106,7 @@ static void process_rx_packets(struct fw_iso_context *context, u32 tstamp, size_ } s->ctx_data.rx.event_count = event_count; + s->packet_descs_cursor = desc; } static void skip_rx_packets(struct fw_iso_context *context, u32 tstamp, size_t header_length, @@ -1202,7 +1203,7 @@ static void process_tx_packets(struct fw_iso_context *context, u32 tstamp, size_ { struct amdtp_stream *s = private_data; __be32 *ctx_header = header; - struct pkt_desc *desc = s->pkt_descs; + struct pkt_desc *desc = s->packet_descs_cursor; unsigned int packet_count; unsigned int desc_count; int i; @@ -1228,6 +1229,10 @@ static void process_tx_packets(struct fw_iso_context *context, u32 tstamp, size_ if (d->replay.enable) cache_seq(s, desc, desc_count); + + for (i = 0; i < desc_count; ++i) + desc = amdtp_stream_next_packet_desc(s, desc); + s->packet_descs_cursor = desc; } for (i = 0; i < packet_count; ++i) { @@ -1664,7 +1669,7 @@ static int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed, err = -ENOMEM; goto err_context; } - s->pkt_descs = descs; + s->packet_descs = descs; INIT_LIST_HEAD(&s->packet_descs_list); for (i = 0; i < s->queue_size; ++i) { @@ -1672,6 +1677,7 @@ static int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed, list_add_tail(&descs->link, &s->packet_descs_list); ++descs; } + s->packet_descs_cursor = list_first_entry(&s->packet_descs_list, struct pkt_desc, link); s->packet_index = 0; do { @@ -1710,8 +1716,8 @@ static int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed, return 0; err_pkt_descs: - kfree(s->pkt_descs); - s->pkt_descs = NULL; + kfree(s->packet_descs); + s->packet_descs = NULL; err_context: if (s->direction == AMDTP_OUT_STREAM) { kfree(s->ctx_data.rx.seq.descs); @@ -1805,8 +1811,8 @@ static void amdtp_stream_stop(struct amdtp_stream *s) fw_iso_context_destroy(s->context); s->context = ERR_PTR(-1); iso_packets_buffer_destroy(&s->buffer, s->unit); - kfree(s->pkt_descs); - s->pkt_descs = NULL; + kfree(s->packet_descs); + s->packet_descs = NULL; if (s->direction == AMDTP_OUT_STREAM) { kfree(s->ctx_data.rx.seq.descs); diff --git a/sound/firewire/amdtp-stream.h b/sound/firewire/amdtp-stream.h index 84156d0d57b8..a8dd1c3ec8d9 100644 --- a/sound/firewire/amdtp-stream.h +++ b/sound/firewire/amdtp-stream.h @@ -126,8 +126,9 @@ struct amdtp_stream { struct iso_packets_buffer buffer; unsigned int queue_size; int packet_index; - struct pkt_desc *pkt_descs; + struct pkt_desc *packet_descs; struct list_head packet_descs_list; + struct pkt_desc *packet_descs_cursor; int tag; union { struct {