From nobody Sun Sep 14 10:19:01 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 779DFC77B7A for ; Mon, 29 May 2023 11:35:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231658AbjE2LfH (ORCPT ); Mon, 29 May 2023 07:35:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231669AbjE2Lex (ORCPT ); Mon, 29 May 2023 07:34:53 -0400 Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2780413A for ; Mon, 29 May 2023 04:34:34 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 60C0232003AC; Mon, 29 May 2023 07:34:33 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 29 May 2023 07:34:33 -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=1685360072; x= 1685446472; bh=fzYN89ZMFMfUx+g08kllNmIdNawZyAy6SkyrK59Skkc=; b=k q3hQNcEvdYLw7WNM+QLeh3rgSjaYsz613Grs8OI7jadHAgNSo1gJqCR6/MfyRqOC siD6aLZYuLvHi0QoEtS10YWdpVZ0Q6vE770Q+7Fm/DkzCfbozlE0u6vvShaBYX5S AWeXGIbu2zBQckWsdXpBts2sEFTZyhXpQgEbj2a9nrBgEmbGe61ozCKf+YgP4/Pz AI7MPB2Bo+wOahuKgf6lvF3yyO8uOIXAUz8R5NLqK+/m9hZSDLs9w8LulSUQTm7j y104fYWcBWv+Si2RrD8Rh2yeWENCiLUHo7NA7Y+z5JMcSijC52CcyTJwQwchiH9O cRZE0Z2GW7iVghUPlPB2Q== 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=1685360072; x=1685446472; bh=f zYN89ZMFMfUx+g08kllNmIdNawZyAy6SkyrK59Skkc=; b=BLufKp+ELSaoycQKt Q8YQSe4Mhqp7965Ghn0MdjqVQnfnQ9psuPSwhbBSi1BAP4XIjw+GT8gu3x73+omL 6+CEQYSJ8fUgz0uF0PB7eOJ6SwHHy5GH8Nl6g6Z7J3ny3rO1jCf1/Y0P97T0UhiF Zy3ZAbl5oEuQAhsa9z7rXyJQZ3q93iG7fuGH3vbFVFN1ZPD/I/AFE26JfEBDnsso +XgBIBb4egA70fpIvSEBOWCPQAANbcpdvS17oKJYCrNsZEqklA6zrgpOsW3DNwoP UIfvUMHLnZwqVOvdPApq+7X9F4pNR1XpxfVNwEAlD4Niq3MySkkdqBgODnybOEf+ na4/w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeekhedggedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepveefffefke etgfevgeefleehfffhueejtdejveethfekveektdejjedvtdejhfejnecuvehluhhsthgv rhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihessh grkhgrmhhotggthhhirdhjph X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 29 May 2023 07:34:31 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH v3 10/12] firewire: cdev: code refactoring to dispatch event for phy packet Date: Mon, 29 May 2023 20:34:04 +0900 Message-Id: <20230529113406.986289-11-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 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.39.2