From nobody Sun Sep 14 10:04:33 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 D1177C54EAA for ; Wed, 25 Jan 2023 12:03:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235671AbjAYMDn (ORCPT ); Wed, 25 Jan 2023 07:03:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235817AbjAYMDg (ORCPT ); Wed, 25 Jan 2023 07:03:36 -0500 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16E0F577E2 for ; Wed, 25 Jan 2023 04:03:21 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 86B245C01B7; Wed, 25 Jan 2023 07:03:20 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 25 Jan 2023 07:03:20 -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=1674648200; x= 1674734600; bh=ahqs1LYctapqd3obfcgxXTbiu9HxxUAsecH2A0pcwOo=; b=H xHPjCINz7UPVaQ0a70ohdvxAVldZo4NeDXnkFV8L/TKVi0VChMCZiSaBtMjJUB5c oWWarWJx5zyU8JCZBz+4Wt3q4mn0xKN7TMTgp8d/kZ3SHum1qX9NmrI/GDM9/0aA dOX6MVj3M4xkmmVuj5cB1BMbhQ01/9ZhMQLInuS3eapN0EoflSbd2IHb7E4wVB6D wnv1KhDBz4+gJ6tK6PowDL5tz2G5g/qbQghMw0d3K6M2Gy38T2zVArn8MCEyLo5g CLFhVh9c7zs6WHMOOya2DP/BhKHLsHIfVst3brfhQwAHUK3bauSW+5WREKqQktDu 7VxVqopty9hAvjwnncFCQ== 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=1674648200; x=1674734600; bh=ahqs1LYctapqd 3obfcgxXTbiu9HxxUAsecH2A0pcwOo=; b=X0iMZwkCCyaKwV2nIbcITALUnh9mj eblsuVBDZXJM/jTI3t2JqL0YEnU0O5QpQsECPUsUp8SpDYr8O87i0kLkbDMZdD4Y 3iKwc4sAiLjgFHNXMS/L4FWVwc071RI7R3ympFypAqvtNK9AcEuTNBCrlnFiRe8a N30nDxfqRGQYSl/d9nKygKV99dv8znjJ54JugPu7d92d5KRU/a2A15JWiHzSRdl0 2WMtAxGwhCFQGUJXin55vql3luE9hd6PtuBXxKqGRxzIwgGE9BXxOr+GNK1P5dJJ xku8omaZ3V6PXvE9vdnACnX1jz0w01crxJ5e07bRWfKF6qiLB/bW+RQJQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedruddvvddgfeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpedvjefgje euvdfguddukeelveetgfdtvefhtdfffeeigfevueetffeivdffkedvtdenucevlhhushht vghrufhiiigvpedvnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 25 Jan 2023 07:03:19 -0500 (EST) From: Takashi Sakamoto To: stefanr@s5r6.in-berlin.de Cc: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, tiwai@suse.de Subject: [PATCH 09/11] firewire: cdev: code refactoring to dispatch event for phy packet Date: Wed, 25 Jan 2023 21:02:59 +0900 Message-Id: <20230125120301.51585-10-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230125120301.51585-1-o-takashi@sakamocchi.jp> References: <20230125120301.51585-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 1394 OHCI, both Asynchronous Transmit (AT) and Asynchronous Receive (AR) contexts are used to deliver the phy packet of IEEE 1394. The time stamp is available as well as the usual asynchronous transaction. This commit is a preparation for future commit to handle the time stamp. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-cdev.c | 78 +++++++++++++++++++++++------------- 1 file changed, 51 insertions(+), 27 deletions(-) diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index 8b24abdd51b8..2220de3c945e 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c @@ -204,12 +204,16 @@ struct outbound_phy_packet_event { struct event event; struct client *client; struct fw_packet p; - struct fw_cdev_event_phy_packet phy_packet; + union { + struct fw_cdev_event_phy_packet without_tstamp; + } phy_packet; }; =20 struct inbound_phy_packet_event { struct event event; - struct fw_cdev_event_phy_packet phy_packet; + union { + struct fw_cdev_event_phy_packet without_tstamp; + } phy_packet; }; =20 #ifdef CONFIG_COMPAT @@ -1549,26 +1553,41 @@ static void outbound_phy_packet_callback(struct fw_= packet *packet, { struct outbound_phy_packet_event *e =3D container_of(packet, struct outbound_phy_packet_event, p); - struct client *e_client; + struct client *e_client =3D e->client; + u32 rcode; + struct fw_cdev_event_phy_packet *pp; =20 switch (status) { - /* expected: */ - case ACK_COMPLETE: e->phy_packet.rcode =3D RCODE_COMPLETE; break; - /* should never happen with PHY packets: */ - case ACK_PENDING: e->phy_packet.rcode =3D RCODE_COMPLETE; break; + // expected: + case ACK_COMPLETE: + rcode =3D RCODE_COMPLETE; + break; + // should never happen with PHY packets: + case ACK_PENDING: + rcode =3D RCODE_COMPLETE; + break; case ACK_BUSY_X: case ACK_BUSY_A: - case ACK_BUSY_B: e->phy_packet.rcode =3D RCODE_BUSY; break; - case ACK_DATA_ERROR: e->phy_packet.rcode =3D RCODE_DATA_ERROR; break; - case ACK_TYPE_ERROR: e->phy_packet.rcode =3D RCODE_TYPE_ERROR; break; - /* stale generation; cancelled; on certain controllers: no ack */ - default: e->phy_packet.rcode =3D status; break; + case ACK_BUSY_B: + rcode =3D RCODE_BUSY; + break; + case ACK_DATA_ERROR: + rcode =3D RCODE_DATA_ERROR; + break; + case ACK_TYPE_ERROR: + rcode =3D RCODE_TYPE_ERROR; + break; + // stale generation; cancelled; on certain controllers: no ack + default: + rcode =3D status; + break; } - e->phy_packet.data[0] =3D packet->timestamp; =20 - e_client =3D e->client; - queue_event(e->client, &e->event, &e->phy_packet, - sizeof(e->phy_packet) + e->phy_packet.length, NULL, 0); + pp =3D &e->phy_packet.without_tstamp; + pp->rcode =3D rcode; + pp->data[0] =3D packet->timestamp; + queue_event(e->client, &e->event, &e->phy_packet, sizeof(*pp) + pp->lengt= h, NULL, 0); + client_put(e_client); } =20 @@ -1577,6 +1596,7 @@ static int ioctl_send_phy_packet(struct client *clien= t, union ioctl_arg *arg) struct fw_cdev_send_phy_packet *a =3D &arg->send_phy_packet; struct fw_card *card =3D client->device->card; struct outbound_phy_packet_event *e; + struct fw_cdev_event_phy_packet *pp; =20 /* Access policy: Allow this ioctl only on local nodes' device files. */ if (!client->device->is_local) @@ -1595,10 +1615,12 @@ static int ioctl_send_phy_packet(struct client *cli= ent, union ioctl_arg *arg) e->p.header[2] =3D a->data[1]; e->p.header_length =3D 12; e->p.callback =3D outbound_phy_packet_callback; - e->phy_packet.closure =3D a->closure; - e->phy_packet.type =3D FW_CDEV_EVENT_PHY_PACKET_SENT; + + pp =3D &e->phy_packet.without_tstamp; + pp->closure =3D a->closure; + pp->type =3D FW_CDEV_EVENT_PHY_PACKET_SENT; if (is_ping_packet(a->data)) - e->phy_packet.length =3D 4; + pp->length =3D 4; =20 card->driver->send_request(card, &e->p); =20 @@ -1633,18 +1655,20 @@ void fw_cdev_handle_phy_packet(struct fw_card *card= , struct fw_packet *p) spin_lock_irqsave(&card->lock, flags); =20 list_for_each_entry(client, &card->phy_receiver_list, phy_receiver_link) { + struct fw_cdev_event_phy_packet *pp; + e =3D kmalloc(sizeof(*e) + 8, GFP_ATOMIC); if (e =3D=3D NULL) break; =20 - e->phy_packet.closure =3D client->phy_receiver_closure; - e->phy_packet.type =3D FW_CDEV_EVENT_PHY_PACKET_RECEIVED; - e->phy_packet.rcode =3D RCODE_COMPLETE; - e->phy_packet.length =3D 8; - e->phy_packet.data[0] =3D p->header[1]; - e->phy_packet.data[1] =3D p->header[2]; - queue_event(client, &e->event, - &e->phy_packet, sizeof(e->phy_packet) + 8, NULL, 0); + pp =3D &e->phy_packet.without_tstamp; + pp->closure =3D client->phy_receiver_closure; + pp->type =3D FW_CDEV_EVENT_PHY_PACKET_RECEIVED; + pp->rcode =3D RCODE_COMPLETE; + pp->length =3D 8; + pp->data[0] =3D p->header[1]; + pp->data[1] =3D p->header[2]; + queue_event(client, &e->event, &e->phy_packet, sizeof(*pp) + 8, NULL, 0); } =20 spin_unlock_irqrestore(&card->lock, flags); --=20 2.37.2