From nobody Sun Sep 14 10:16:03 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55B64C77B7E for ; Mon, 29 May 2023 11:34:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231593AbjE2Leg (ORCPT ); Mon, 29 May 2023 07:34:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229606AbjE2Le2 (ORCPT ); Mon, 29 May 2023 07:34:28 -0400 Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BBB7E4 for ; Mon, 29 May 2023 04:34:26 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 42F9E3200392; Mon, 29 May 2023 07:34:25 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Mon, 29 May 2023 07:34:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1685360064; x= 1685446464; bh=Zx5vRuZcoTFwzB00ySCuly08OEL537Ypl8d8EH6oHiA=; b=i 2A7DnyPey/vY8w8dZY1/Sf2qnTaXL8TpEhP4UDEls+xyt4rC8XI3TS8DMYCKQmlw WRa/1FnSjbJDRM1wtPmpby7UbxdGdqB+kXAquNFnwqu0pOykWNEoBn6Yev1ynZsI 5ww+igXez/118tHu6cza+nhzozeLM3HLe3trn6e/C/TLcG7IpZCNVjhhPcqy92TW Gy6Rux8s/tCz6enjKbJWEtxAyjY0NioTEiZCfAWZpe8vej1Bmpsc5FNm0ooiAHkW LuMri+mQeqs2aZrqDrVUI6RWeBQDpNIN0SrfN0u09hk/AqgFg2TknOW4csKlGWcS SUVD2omT9g3wCbDqW5nCg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1685360064; x=1685446464; bh=Z x5vRuZcoTFwzB00ySCuly08OEL537Ypl8d8EH6oHiA=; b=rHy0fOgdVxFdQoiAn Ob2MhSTuufPVZsLgK6KgMTBJoNQZA5nYiZ1j4mNPYnncPsie5s+48V7jG0LxeQZ7 t7x3satvNB4HSGjrHjr0vdrp4biMYWivFpoHpXKm8sDb5TsQdhgKXVipoVxd82Py cby2Spv5Eu29/4tXyyEBr9y+gijE1irWUtxkFpiCxmdmZnd11eHQA1M4oOyzx+i/ Hs0Qaf3fs48YHTJFSHjb2t6C6DzFKIsGRHUykrTCyI/CkPmton6ca0U0UoSZBAA2 jgM9R12LmtTj/mKE6jg9emAOAVHjf8kf6EdCPQoCwNTnBCe8dyYseRN/i4v7+afo 7IOOw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeekhedggedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepveefffefke etgfevgeefleehfffhueejtdejveethfekveektdejjedvtdejhfejnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihessh grkhgrmhhotggthhhirdhjph X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 29 May 2023 07:34:23 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH v3 06/12] firewire: core: implement variations to send request and wait for response with time stamp Date: Mon, 29 May 2023 20:34:00 +0900 Message-Id: <20230529113406.986289-7-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230529113406.986289-1-o-takashi@sakamocchi.jp> References: <20230529113406.986289-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In the previous commit, the core function of Linux FireWire subsystem was changed for two cases to operate asynchronous transaction with or without time stamp. This commit changes kernel API for the two cases. Current kernel API, fw_send_request(), is changed to be static inline function to call __fw_send_request(), which receives two argument for union and flag of callback function. The new kernel API, fw_send_request_with_tstamp() is also added as static inline function, too. When calling, the two arguments are copied to internal structure, then used in softIRQ context. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-transaction.c | 41 +++++++++++------ include/linux/firewire.h | 69 +++++++++++++++++++++++++++-- 2 files changed, 92 insertions(+), 18 deletions(-) diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-tr= ansaction.c index a20f97fdd06c..130b95aca629 100644 --- a/drivers/firewire/core-transaction.c +++ b/drivers/firewire/core-transaction.c @@ -316,7 +316,8 @@ static int allocate_tlabel(struct fw_card *card) } =20 /** - * fw_send_request() - submit a request packet for transmission + * __fw_send_request() - submit a request packet for transmission to gener= ate callback for response + * subaction with or without time stamp. * @card: interface to send the request at * @t: transaction instance to which the request belongs * @tcode: transaction code @@ -326,7 +327,9 @@ static int allocate_tlabel(struct fw_card *card) * @offset: 48bit wide offset into destination's address space * @payload: data payload for the request subaction * @length: length of the payload, in bytes - * @callback: function to be called when the transaction is completed + * @callback: union of two functions whether to receive time stamp or not= for response + * subaction. + * @with_tstamp: Whether to receive time stamp or not for response subacti= on. * @callback_data: data to be passed to the transaction completion callback * * Submit a request packet into the asynchronous request transmission queu= e. @@ -363,10 +366,10 @@ static int allocate_tlabel(struct fw_card *card) * transaction completion and hence execution of @callback may happen even * before fw_send_request() returns. */ -void fw_send_request(struct fw_card *card, struct fw_transaction *t, int t= code, - int destination_id, int generation, int speed, - unsigned long long offset, void *payload, size_t length, - fw_transaction_callback_t callback, void *callback_data) +void __fw_send_request(struct fw_card *card, struct fw_transaction *t, int= tcode, + int destination_id, int generation, int speed, unsigned long long offset, + void *payload, size_t length, union fw_transaction_callback callback, + bool with_tstamp, void *callback_data) { unsigned long flags; int tlabel; @@ -381,7 +384,19 @@ void fw_send_request(struct fw_card *card, struct fw_t= ransaction *t, int tcode, tlabel =3D allocate_tlabel(card); if (tlabel < 0) { spin_unlock_irqrestore(&card->lock, flags); - callback(card, RCODE_SEND_ERROR, NULL, 0, callback_data); + if (!with_tstamp) { + callback.without_tstamp(card, RCODE_SEND_ERROR, NULL, 0, callback_data); + } else { + // Timestamping on behalf of hardware. + u32 curr_cycle_time =3D 0; + u32 tstamp; + + (void)fw_card_read_cycle_time(card, &curr_cycle_time); + tstamp =3D cycle_time_to_ohci_tstamp(curr_cycle_time); + + callback.with_tstamp(card, RCODE_SEND_ERROR, tstamp, tstamp, NULL, 0, + callback_data); + } return; } =20 @@ -389,14 +404,12 @@ void fw_send_request(struct fw_card *card, struct fw_= transaction *t, int tcode, t->tlabel =3D tlabel; t->card =3D card; t->is_split_transaction =3D false; - timer_setup(&t->split_timeout_timer, - split_transaction_timeout_callback, 0); - t->callback.without_tstamp =3D callback; - t->with_tstamp =3D false; + timer_setup(&t->split_timeout_timer, split_transaction_timeout_callback, = 0); + t->callback =3D callback; + t->with_tstamp =3D with_tstamp; t->callback_data =3D callback_data; =20 - fw_fill_request(&t->packet, tcode, t->tlabel, - destination_id, card->node_id, generation, + fw_fill_request(&t->packet, tcode, t->tlabel, destination_id, card->node_= id, generation, speed, offset, payload, length); t->packet.callback =3D transmit_complete_callback; =20 @@ -406,7 +419,7 @@ void fw_send_request(struct fw_card *card, struct fw_tr= ansaction *t, int tcode, =20 card->driver->send_request(card, &t->packet); } -EXPORT_SYMBOL(fw_send_request); +EXPORT_SYMBOL_GPL(__fw_send_request); =20 struct transaction_callback_data { struct completion done; diff --git a/include/linux/firewire.h b/include/linux/firewire.h index d61693341da1..a7fd23d0010d 100644 --- a/include/linux/firewire.h +++ b/include/linux/firewire.h @@ -356,10 +356,71 @@ void fw_send_response(struct fw_card *card, struct fw_request *request, int rcode); int fw_get_request_speed(struct fw_request *request); u32 fw_request_get_timestamp(const struct fw_request *request); -void fw_send_request(struct fw_card *card, struct fw_transaction *t, - int tcode, int destination_id, int generation, int speed, - unsigned long long offset, void *payload, size_t length, - fw_transaction_callback_t callback, void *callback_data); + +void __fw_send_request(struct fw_card *card, struct fw_transaction *t, int= tcode, + int destination_id, int generation, int speed, unsigned long long offset, + void *payload, size_t length, union fw_transaction_callback callback, + bool with_tstamp, void *callback_data); + +/** + * fw_send_request() - submit a request packet for transmission to generat= e callback for response + * subaction without time stamp. + * @card: interface to send the request at + * @t: transaction instance to which the request belongs + * @tcode: transaction code + * @destination_id: destination node ID, consisting of bus_ID and phy_ID + * @generation: bus generation in which request and response are valid + * @speed: transmission speed + * @offset: 48bit wide offset into destination's address space + * @payload: data payload for the request subaction + * @length: length of the payload, in bytes + * @callback: function to be called when the transaction is completed + * @callback_data: data to be passed to the transaction completion callback + * + * A variation of __fw_send_request() to generate callback for response su= baction without time + * stamp. + */ +static inline void fw_send_request(struct fw_card *card, struct fw_transac= tion *t, int tcode, + int destination_id, int generation, int speed, + unsigned long long offset, void *payload, size_t length, + fw_transaction_callback_t callback, void *callback_data) +{ + union fw_transaction_callback cb =3D { + .without_tstamp =3D callback, + }; + __fw_send_request(card, t, tcode, destination_id, generation, speed, offs= et, payload, + length, cb, false, callback_data); +} + +/** + * fw_send_request_with_tstamp() - submit a request packet for transmissio= n to generate callback for + * response with time stamp. + * @card: interface to send the request at + * @t: transaction instance to which the request belongs + * @tcode: transaction code + * @destination_id: destination node ID, consisting of bus_ID and phy_ID + * @generation: bus generation in which request and response are valid + * @speed: transmission speed + * @offset: 48bit wide offset into destination's address space + * @payload: data payload for the request subaction + * @length: length of the payload, in bytes + * @callback: function to be called when the transaction is completed + * @callback_data: data to be passed to the transaction completion callback + * + * A variation of __fw_send_request() to generate callback for response su= baction with time stamp. + */ +static inline void fw_send_request_with_tstamp(struct fw_card *card, struc= t fw_transaction *t, + int tcode, int destination_id, int generation, int speed, unsigned long l= ong offset, + void *payload, size_t length, fw_transaction_callback_with_tstamp_t callb= ack, + void *callback_data) +{ + union fw_transaction_callback cb =3D { + .with_tstamp =3D callback, + }; + __fw_send_request(card, t, tcode, destination_id, generation, speed, offs= et, payload, + length, cb, true, callback_data); +} + int fw_cancel_transaction(struct fw_card *card, struct fw_transaction *transaction); int fw_run_transaction(struct fw_card *card, int tcode, int destination_id, --=20 2.39.2